cli: pass npm_token for private repos (#2987)
This commit is contained in:
parent
26cc87a2ac
commit
5482de08bc
@ -110,8 +110,13 @@ function validate(packageName, version, keyword) {
|
||||
|
||||
// Gets the registry of the package. Scoped packages may not be using the global default.
|
||||
const registryUrlOfPackage = registryUrl(scope);
|
||||
|
||||
const response = await fetch(`${registryUrlOfPackage}${packageName}`);
|
||||
let options = {}
|
||||
if (process.env.NPM_TOKEN){
|
||||
options['headers'] = {
|
||||
'Authorization': `Bearer ${process.env.NPM_TOKEN}`,
|
||||
}
|
||||
}
|
||||
const response = await fetch(`${registryUrlOfPackage}${packageName}`, options);
|
||||
const json = await response.json();
|
||||
|
||||
if (json.error && json.error === NOT_FOUND) {
|
||||
|
||||
@ -289,3 +289,14 @@ can take a look at what this file contains by going to
|
||||
`platform/viewer/PluginConfig.json` in your project's root directory. In short,
|
||||
this file tracks and stores all the extensions/modes and the their version that
|
||||
are currently being used by the viewer.
|
||||
|
||||
## Private NPM Repos
|
||||
|
||||
For the `yarn cli` to view private NPM repos, create a read-only token with the
|
||||
following steps and export it as an environmental variable. You may also export
|
||||
an existing npm token.
|
||||
```
|
||||
npm login
|
||||
npm token create --read-only
|
||||
export NPM_TOKEN=<your readonly token>
|
||||
```
|
||||
|
||||
Loading…
Reference in New Issue
Block a user