@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 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 `_`; `@stasis` has none, as `STASIS_NPM_TOKEN`
11
- * is for every scope), else with `PREVENTIVE_MEASURES_NPM_TOKEN`, `STASIS_NPM_TOKEN` or `NPM_TOKEN`, the first set.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preventive/upstream",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "description": "Minimal npm, crates.io, RubyGems, Soldeer, CocoaPods trunk, GitHub, Electron release and git checkout clients",
5
5
  "type": "module",
6
6
  "exports": {
@@ -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 where it is set. STASIS_NPM_TOKEN
7
- // is stasis's token for every scope, never @stasis's own.
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 key = `${name.slice(1, name.indexOf('/')).toUpperCase().replaceAll(/[.-]/gu, '_')}_NPM_TOKEN`
10
- return key === 'STASIS_NPM_TOKEN' ? undefined : process.env[key]
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