@npmcli/config 8.2.1 → 8.2.2
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/lib/definitions/definitions.js +2081 -2240
- package/lib/index.js +21 -28
- package/lib/nerf-dart.js +1 -1
- package/lib/parse-field.js +1 -1
- package/lib/type-defs.js +6 -4
- package/lib/umask.js +1 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
const { walkUp } = require('walk-up-path')
|
|
3
3
|
const ini = require('ini')
|
|
4
4
|
const nopt = require('nopt')
|
|
5
|
-
const mapWorkspaces = require('@npmcli/map-workspaces')
|
|
6
|
-
const rpj = require('read-package-json-fast')
|
|
7
5
|
const log = require('proc-log')
|
|
8
6
|
|
|
9
|
-
const { resolve, dirname, join } = require('path')
|
|
10
|
-
const { homedir } = require('os')
|
|
7
|
+
const { resolve, dirname, join } = require('node:path')
|
|
8
|
+
const { homedir } = require('node:os')
|
|
11
9
|
const {
|
|
12
10
|
readFile,
|
|
13
11
|
writeFile,
|
|
@@ -28,35 +26,12 @@ const dirExists = (...p) => stat(resolve(...p))
|
|
|
28
26
|
const hasOwnProperty = (obj, key) =>
|
|
29
27
|
Object.prototype.hasOwnProperty.call(obj, key)
|
|
30
28
|
|
|
31
|
-
// define a custom getter, but turn into a normal prop
|
|
32
|
-
// if we set it. otherwise it can't be set on child objects
|
|
33
|
-
const settableGetter = (obj, key, get) => {
|
|
34
|
-
Object.defineProperty(obj, key, {
|
|
35
|
-
get,
|
|
36
|
-
set (value) {
|
|
37
|
-
Object.defineProperty(obj, key, {
|
|
38
|
-
value,
|
|
39
|
-
configurable: true,
|
|
40
|
-
writable: true,
|
|
41
|
-
enumerable: true,
|
|
42
|
-
})
|
|
43
|
-
},
|
|
44
|
-
configurable: true,
|
|
45
|
-
enumerable: true,
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
|
|
49
29
|
const typeDefs = require('./type-defs.js')
|
|
50
30
|
const nerfDart = require('./nerf-dart.js')
|
|
51
31
|
const envReplace = require('./env-replace.js')
|
|
52
32
|
const parseField = require('./parse-field.js')
|
|
53
|
-
const typeDescription = require('./type-description.js')
|
|
54
33
|
const setEnvs = require('./set-envs.js')
|
|
55
34
|
|
|
56
|
-
const {
|
|
57
|
-
ErrInvalidAuth,
|
|
58
|
-
} = require('./errors.js')
|
|
59
|
-
|
|
60
35
|
// types that can be saved back to
|
|
61
36
|
const confFileTypes = new Set([
|
|
62
37
|
'global',
|
|
@@ -329,7 +304,21 @@ class Config {
|
|
|
329
304
|
// default the globalconfig file to that location, instead of the default
|
|
330
305
|
// global prefix. It's weird that `npm get globalconfig --prefix=/foo`
|
|
331
306
|
// returns `/foo/etc/npmrc`, but better to not change it at this point.
|
|
332
|
-
|
|
307
|
+
// define a custom getter, but turn into a normal prop
|
|
308
|
+
// if we set it. otherwise it can't be set on child objects
|
|
309
|
+
Object.defineProperty(data, 'globalconfig', {
|
|
310
|
+
get: () => resolve(this.#get('prefix'), 'etc/npmrc'),
|
|
311
|
+
set (value) {
|
|
312
|
+
Object.defineProperty(data, 'globalconfig', {
|
|
313
|
+
value,
|
|
314
|
+
configurable: true,
|
|
315
|
+
writable: true,
|
|
316
|
+
enumerable: true,
|
|
317
|
+
})
|
|
318
|
+
},
|
|
319
|
+
configurable: true,
|
|
320
|
+
enumerable: true,
|
|
321
|
+
})
|
|
333
322
|
}
|
|
334
323
|
|
|
335
324
|
loadHome () {
|
|
@@ -444,6 +433,7 @@ class Config {
|
|
|
444
433
|
}
|
|
445
434
|
|
|
446
435
|
if (authProblems.length) {
|
|
436
|
+
const { ErrInvalidAuth } = require('./errors.js')
|
|
447
437
|
throw new ErrInvalidAuth(authProblems)
|
|
448
438
|
}
|
|
449
439
|
|
|
@@ -512,6 +502,7 @@ class Config {
|
|
|
512
502
|
}
|
|
513
503
|
|
|
514
504
|
invalidHandler (k, val, type, source, where) {
|
|
505
|
+
const typeDescription = require('./type-description.js')
|
|
515
506
|
log.warn(
|
|
516
507
|
'invalid config',
|
|
517
508
|
k + '=' + JSON.stringify(val),
|
|
@@ -696,6 +687,7 @@ class Config {
|
|
|
696
687
|
}
|
|
697
688
|
|
|
698
689
|
if (this.localPrefix && hasPackageJson) {
|
|
690
|
+
const rpj = require('read-package-json-fast')
|
|
699
691
|
// if we already set localPrefix but this dir has a package.json
|
|
700
692
|
// then we need to see if `p` is a workspace root by reading its package.json
|
|
701
693
|
// however, if reading it fails then we should just move on
|
|
@@ -704,6 +696,7 @@ class Config {
|
|
|
704
696
|
continue
|
|
705
697
|
}
|
|
706
698
|
|
|
699
|
+
const mapWorkspaces = require('@npmcli/map-workspaces')
|
|
707
700
|
const workspaces = await mapWorkspaces({ cwd: p, pkg })
|
|
708
701
|
for (const w of workspaces.values()) {
|
|
709
702
|
if (w === this.localPrefix) {
|
package/lib/nerf-dart.js
CHANGED
package/lib/parse-field.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Parse a field, coercing it to the best type available.
|
|
2
2
|
const typeDefs = require('./type-defs.js')
|
|
3
3
|
const envReplace = require('./env-replace.js')
|
|
4
|
-
const { resolve } = require('path')
|
|
4
|
+
const { resolve } = require('node:path')
|
|
5
5
|
|
|
6
6
|
const { parse: umaskParse } = require('./umask.js')
|
|
7
7
|
|
package/lib/type-defs.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
const nopt = require('nopt')
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { validate: validateUmask } = require('./umask.js')
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
class Umask {}
|
|
6
|
+
class Semver {}
|
|
7
|
+
const semverValid = require('semver/functions/valid')
|
|
6
8
|
const validateSemver = (data, k, val) => {
|
|
7
|
-
const valid =
|
|
9
|
+
const valid = semverValid(val)
|
|
8
10
|
if (!valid) {
|
|
9
11
|
return false
|
|
10
12
|
}
|
|
@@ -23,7 +25,7 @@ const validatePath = (data, k, val) => {
|
|
|
23
25
|
module.exports = {
|
|
24
26
|
...nopt.typeDefs,
|
|
25
27
|
semver: {
|
|
26
|
-
type:
|
|
28
|
+
type: Semver,
|
|
27
29
|
validate: validateSemver,
|
|
28
30
|
description: 'full valid SemVer string',
|
|
29
31
|
},
|
package/lib/umask.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
class Umask {}
|
|
2
1
|
const parse = val => {
|
|
3
2
|
// this is run via nopt and parse field where everything is
|
|
4
3
|
// converted to a string first, ignoring coverage for now
|
|
@@ -33,4 +32,4 @@ const validate = (data, k, val) => {
|
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
module.exports = {
|
|
35
|
+
module.exports = { parse, validate }
|