From 5482de08bc40604f3438d88860c2ef365202e7ae Mon Sep 17 00:00:00 2001 From: Ouwen Huang Date: Tue, 18 Oct 2022 16:01:35 -1000 Subject: [PATCH] cli: pass npm_token for private repos (#2987) --- platform/cli/src/commands/utils/validate.js | 9 +++++++-- platform/docs/docs/development/ohif-cli.md | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/platform/cli/src/commands/utils/validate.js b/platform/cli/src/commands/utils/validate.js index 89ccb5891..bd782a73e 100644 --- a/platform/cli/src/commands/utils/validate.js +++ b/platform/cli/src/commands/utils/validate.js @@ -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) { diff --git a/platform/docs/docs/development/ohif-cli.md b/platform/docs/docs/development/ohif-cli.md index cf8af80f5..dc3f95069 100644 --- a/platform/docs/docs/development/ohif-cli.md +++ b/platform/docs/docs/development/ohif-cli.md @@ -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= +```