@preventive/upstream 1.13.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/npm.d.ts +3 -2
- package/package.json +1 -1
- package/src/npm/registry.js +6 -4
package/npm.d.ts
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
*
|
|
8
8
|
* `setCacheDir()` sets where every module of this package caches: nothing is written to a cache until it is called.
|
|
9
9
|
* Names and versions are checked before any request. A scoped package is read with its scope's own token where it
|
|
10
|
-
* is set, `ACME_CORP_NPM_TOKEN` for `@acme-corp/x` (`.` and `-` read as `_`;
|
|
11
|
-
*
|
|
10
|
+
* is set, `ACME_CORP_NPM_TOKEN`, else `NPM_TOKEN_ACME_CORP`, for `@acme-corp/x` (`.` and `-` read as `_`;
|
|
11
|
+
* `PREVENTIVE_MEASURES_NPM_TOKEN` and `STASIS_NPM_TOKEN` are for every scope, not `@preventive-measures`'s or
|
|
12
|
+
* `@stasis`'s own), else with `PREVENTIVE_MEASURES_NPM_TOKEN`, `STASIS_NPM_TOKEN` or `NPM_TOKEN`, the first set.
|
|
12
13
|
*
|
|
13
14
|
* @module @preventive/upstream/npm.js
|
|
14
15
|
*/
|
package/package.json
CHANGED
package/src/npm/registry.js
CHANGED
|
@@ -3,11 +3,13 @@ import assert from 'node:assert/strict'
|
|
|
3
3
|
import { show } from '../args.js'
|
|
4
4
|
import { NPM_REGISTRY, buildUrl, request } from '../http.js'
|
|
5
5
|
|
|
6
|
-
// @acme-corp/x is read with ACME_CORP_NPM_TOKEN
|
|
7
|
-
//
|
|
6
|
+
// @acme-corp/x is read with ACME_CORP_NPM_TOKEN, else NPM_TOKEN_ACME_CORP, where
|
|
7
|
+
// set. PREVENTIVE_MEASURES_NPM_TOKEN and STASIS_NPM_TOKEN are for every scope,
|
|
8
|
+
// never @preventive-measures's or @stasis's own.
|
|
9
|
+
const SHARED = new Set(['PREVENTIVE_MEASURES', 'STASIS'])
|
|
8
10
|
function scopeToken(name) {
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
+
const org = name.slice(1, name.indexOf('/')).toUpperCase().replaceAll(/[.-]/gu, '_')
|
|
12
|
+
return (SHARED.has(org) ? undefined : process.env[`${org}_NPM_TOKEN`]) || process.env[`NPM_TOKEN_${org}`]
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
const npmToken = (name) => scopeToken(name) || process.env.PREVENTIVE_MEASURES_NPM_TOKEN || process.env.STASIS_NPM_TOKEN || process.env.NPM_TOKEN
|