@npmcli/config 10.4.1 → 10.4.3
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/README.md +64 -95
- package/lib/definitions/definition.js +2 -2
- package/lib/definitions/definitions.js +122 -6
- package/lib/index.js +3 -3
- package/lib/set-envs.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,53 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
Configuration management for the npm cli.
|
|
4
4
|
|
|
5
|
-
This module is the spiritual descendant of
|
|
6
|
-
[`npmconf`](http://npm.im/npmconf), and the code that once lived in npm's
|
|
5
|
+
This module is the spiritual descendant of [`npmconf`](http://npm.im/npmconf), and the code that once lived in npm's
|
|
7
6
|
`lib/config/` folder.
|
|
8
7
|
|
|
9
|
-
It does the management of configuration files that npm uses, but
|
|
10
|
-
importantly, does _not_ define all the configuration defaults or types, as
|
|
11
|
-
those parts make more sense to live within the npm CLI itself.
|
|
8
|
+
It does the management of configuration files that npm uses, but importantly, does _not_ define all the configuration defaults or types, as those parts make more sense to live within the npm CLI itself.
|
|
12
9
|
|
|
13
10
|
The only exceptions:
|
|
14
11
|
|
|
15
|
-
- The `prefix` config value has some special semantics, setting the local
|
|
16
|
-
|
|
17
|
-
global prefix otherwise.
|
|
18
|
-
- The `project` config file is loaded based on the local prefix (which can
|
|
19
|
-
only be set by the CLI config options, and otherwise defaults to a walk
|
|
20
|
-
up the folder tree to the first parent containing a `node_modules`
|
|
21
|
-
folder, `package.json` file, or `package-lock.json` file.)
|
|
12
|
+
- The `prefix` config value has some special semantics, setting the local prefix if specified on the CLI options and not in global mode, or the global prefix otherwise.
|
|
13
|
+
- The `project` config file is loaded based on the local prefix (which can only be set by the CLI config options, and otherwise defaults to a walk up the folder tree to the first parent containing a `node_modules` folder, `package.json` file, or `package-lock.json` file.)
|
|
22
14
|
- The `userconfig` value, as set by the environment and CLI (defaulting to
|
|
23
15
|
`~/.npmrc`, is used to load user configs.
|
|
24
16
|
- The `globalconfig` value, as set by the environment, CLI, and
|
|
25
|
-
`userconfig` file (defaulting to `$PREFIX/etc/npmrc`) is used to load
|
|
26
|
-
|
|
27
|
-
- A `builtin` config, read from a `npmrc` file in the root of the npm
|
|
28
|
-
project itself, overrides all defaults.
|
|
17
|
+
`userconfig` file (defaulting to `$PREFIX/etc/npmrc`) is used to load global configs.
|
|
18
|
+
- A `builtin` config, read from a `npmrc` file in the root of the npm project itself, overrides all defaults.
|
|
29
19
|
|
|
30
20
|
The resulting hierarchy of configs:
|
|
31
21
|
|
|
32
|
-
- CLI switches.
|
|
33
|
-
|
|
34
|
-
it's the one that npm has used forever, and changing it will be
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- INI-formatted project configs.
|
|
39
|
-
`
|
|
40
|
-
either a `node_modules` folder or `package.json` file.)
|
|
41
|
-
- INI-formatted userconfig file.
|
|
22
|
+
- CLI switches.
|
|
23
|
+
eg `--some-key=some-value` on the command line.
|
|
24
|
+
These are parsed by [`nopt`](http://npm.im/nopt), which is not a great choice, but it's the one that npm has used forever, and changing it will be difficult.
|
|
25
|
+
- Environment variables.
|
|
26
|
+
eg `npm_config_some_key=some_value` in the environment.
|
|
27
|
+
There is no way at this time to modify this prefix.
|
|
28
|
+
- INI-formatted project configs.
|
|
29
|
+
eg `some-key = some-value` in the
|
|
30
|
+
`localPrefix` folder (ie, the `cwd`, or its nearest parent that contains either a `node_modules` folder or `package.json` file.)
|
|
31
|
+
- INI-formatted userconfig file.
|
|
32
|
+
eg `some-key = some-value` in `~/.npmrc`.
|
|
42
33
|
The `userconfig` config value can be overridden by the `cli`, `env`, or
|
|
43
34
|
`project` configs to change this value.
|
|
44
|
-
- INI-formatted globalconfig file.
|
|
45
|
-
the `globalPrefix` folder, which is inferred by looking at the location
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
`/usr/local/lib/node_modules/npm/npmrc`. This is not configurable, and
|
|
51
|
-
is determined by looking in the `npmPath` folder.
|
|
35
|
+
- INI-formatted globalconfig file.
|
|
36
|
+
eg `some-key = some-value` in the `globalPrefix` folder, which is inferred by looking at the location of the node executable, or the `prefix` setting in the `cli`, `env`, `project`, or `userconfig`.
|
|
37
|
+
The `globalconfig` value at any of those levels can override this.
|
|
38
|
+
- INI-formatted builtin config file.
|
|
39
|
+
eg `some-key = some-value` in `/usr/local/lib/node_modules/npm/npmrc`.
|
|
40
|
+
This is not configurable, and is determined by looking in the `npmPath` folder.
|
|
52
41
|
- Default values (passed in by npm when it loads this module).
|
|
53
42
|
|
|
54
43
|
## USAGE
|
|
@@ -65,7 +54,7 @@ const conf = new Config({
|
|
|
65
54
|
flatten,
|
|
66
55
|
// optional, defaults to process.argv
|
|
67
56
|
// argv: [] <- if you are using this package in your own cli
|
|
68
|
-
// and
|
|
57
|
+
// and don't want to have colliding argv
|
|
69
58
|
argv: process.argv,
|
|
70
59
|
// optional, defaults to process.env
|
|
71
60
|
env: process.env,
|
|
@@ -103,57 +92,50 @@ const Config = require('@npmcli/config')
|
|
|
103
92
|
|
|
104
93
|
### static `Config.typeDefs`
|
|
105
94
|
|
|
106
|
-
The type definitions passed to `nopt` for CLI option parsing and known
|
|
107
|
-
configuration validation.
|
|
95
|
+
The type definitions passed to `nopt` for CLI option parsing and known configuration validation.
|
|
108
96
|
|
|
109
97
|
### constructor `new Config(options)`
|
|
110
98
|
|
|
111
99
|
Options:
|
|
112
100
|
|
|
113
|
-
- `types` Types of all known config values.
|
|
114
|
-
|
|
115
|
-
- `shorthands` An object mapping a shorthand value to an array of CLI
|
|
116
|
-
arguments that replace it.
|
|
101
|
+
- `types` Types of all known config values.
|
|
102
|
+
Note that some are effectively given semantic value in the config loading process itself.
|
|
103
|
+
- `shorthands` An object mapping a shorthand value to an array of CLI arguments that replace it.
|
|
117
104
|
- `defaults` Default values for each of the known configuration keys.
|
|
118
105
|
These should be defined for all configs given a type, and must be valid.
|
|
119
|
-
- `npmPath` The path to the `npm` module, for loading the `builtin` config
|
|
120
|
-
file.
|
|
106
|
+
- `npmPath` The path to the `npm` module, for loading the `builtin` config file.
|
|
121
107
|
- `cwd` Optional, defaults to `process.cwd()`, used for inferring the
|
|
122
108
|
`localPrefix` and loading the `project` config.
|
|
123
|
-
- `platform` Optional, defaults to `process.platform`.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
109
|
+
- `platform` Optional, defaults to `process.platform`.
|
|
110
|
+
Used when inferring the `globalPrefix` from the `execPath`, since this is done differently on Windows.
|
|
111
|
+
- `execPath` Optional, defaults to `process.execPath`.
|
|
112
|
+
Used to infer the
|
|
127
113
|
`globalPrefix`.
|
|
128
|
-
- `env` Optional, defaults to `process.env`.
|
|
129
|
-
|
|
130
|
-
- `argv` Optional, defaults to `process.argv`.
|
|
131
|
-
|
|
114
|
+
- `env` Optional, defaults to `process.env`.
|
|
115
|
+
Source of the environment variables for configuration.
|
|
116
|
+
- `argv` Optional, defaults to `process.argv`.
|
|
117
|
+
Source of the CLI options used for configuration.
|
|
132
118
|
|
|
133
119
|
Returns a `config` object, which is not yet loaded.
|
|
134
120
|
|
|
135
121
|
Fields:
|
|
136
122
|
|
|
137
|
-
- `config.globalPrefix` The prefix for `global` operations.
|
|
123
|
+
- `config.globalPrefix` The prefix for `global` operations.
|
|
124
|
+
Set by the
|
|
138
125
|
`prefix` config value, or defaults based on the location of the
|
|
139
126
|
`execPath` option.
|
|
140
|
-
- `config.localPrefix` The prefix for `local` operations.
|
|
141
|
-
|
|
142
|
-
its nearest ancestor containing a `node_modules` folder or `package.json`
|
|
143
|
-
|
|
144
|
-
- `config.
|
|
145
|
-
|
|
146
|
-
- `config.data` A `Map` of config level to `ConfigData` objects. These
|
|
147
|
-
objects should not be modified directly under any circumstances.
|
|
127
|
+
- `config.localPrefix` The prefix for `local` operations.
|
|
128
|
+
Set by the
|
|
129
|
+
`prefix` config value on the CLI only, or defaults to either the `cwd` or its nearest ancestor containing a `node_modules` folder or `package.json` file.
|
|
130
|
+
- `config.sources` A read-only `Map` of the file (or a comment, if no file found, or relevant) to the config level loaded from that source.
|
|
131
|
+
- `config.data` A `Map` of config level to `ConfigData` objects.
|
|
132
|
+
These objects should not be modified directly under any circumstances.
|
|
148
133
|
- `source` The source where this data was loaded from.
|
|
149
|
-
- `raw` The raw data used to generate this config data, as it was parsed
|
|
150
|
-
|
|
151
|
-
- `
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
config data.
|
|
155
|
-
- `config.list` A list sorted in priority of all the config data objects in
|
|
156
|
-
the prototype chain. `config.list[0]` is the `cli` level,
|
|
134
|
+
- `raw` The raw data used to generate this config data, as it was parsed initially from the environment, config file, or CLI options.
|
|
135
|
+
- `data` The data object reflecting the inheritance of configs up to this point in the chain.
|
|
136
|
+
- `loadError` Any errors encountered that prevented the loading of this config data.
|
|
137
|
+
- `config.list` A list sorted in priority of all the config data objects in the prototype chain.
|
|
138
|
+
`config.list[0]` is the `cli` level,
|
|
157
139
|
`config.list[1]` is the `env` level, and so on.
|
|
158
140
|
- `cwd` The `cwd` param
|
|
159
141
|
- `env` The `env` param
|
|
@@ -166,21 +148,17 @@ Fields:
|
|
|
166
148
|
- `npmPath` The `npmPath` param
|
|
167
149
|
- `globalPrefix` The effective `globalPrefix`
|
|
168
150
|
- `localPrefix` The effective `localPrefix`
|
|
169
|
-
- `prefix` If `config.get('global')` is true, then `globalPrefix`,
|
|
170
|
-
|
|
171
|
-
- `home` The user's home directory, found by looking at `env.HOME` or
|
|
172
|
-
calling `os.homedir()`.
|
|
151
|
+
- `prefix` If `config.get('global')` is true, then `globalPrefix`, otherwise `localPrefix`
|
|
152
|
+
- `home` The user's home directory, found by looking at `env.HOME` or calling `os.homedir()`.
|
|
173
153
|
- `loaded` A boolean indicating whether or not configs are loaded
|
|
174
154
|
- `valid` A getter that returns `true` if all the config objects are valid.
|
|
175
|
-
Any data objects that have been modified with `config.set(...)` will be
|
|
176
|
-
re-evaluated when `config.valid` is read.
|
|
155
|
+
Any data objects that have been modified with `config.set(...)` will be re-evaluated when `config.valid` is read.
|
|
177
156
|
|
|
178
157
|
### `config.load()`
|
|
179
158
|
|
|
180
159
|
Load configuration from the various sources of information.
|
|
181
160
|
|
|
182
|
-
Returns a `Promise` that resolves when configuration is loaded, and fails
|
|
183
|
-
if a fatal error is encountered.
|
|
161
|
+
Returns a `Promise` that resolves when configuration is loaded, and fails if a fatal error is encountered.
|
|
184
162
|
|
|
185
163
|
### `config.find(key)`
|
|
186
164
|
|
|
@@ -196,8 +174,7 @@ Load the given key from the config stack.
|
|
|
196
174
|
|
|
197
175
|
### `config.set(key, value, where = 'cli')`
|
|
198
176
|
|
|
199
|
-
Set the key to the specified value, at the specified level in the config
|
|
200
|
-
stack.
|
|
177
|
+
Set the key to the specified value, at the specified level in the config stack.
|
|
201
178
|
|
|
202
179
|
### `config.delete(key, where = 'cli')`
|
|
203
180
|
|
|
@@ -205,12 +182,9 @@ Delete the configuration key from the specified level in the config stack.
|
|
|
205
182
|
|
|
206
183
|
### `config.validate(where)`
|
|
207
184
|
|
|
208
|
-
Verify that all known configuration options are set to valid values, and
|
|
209
|
-
log a warning if they are invalid.
|
|
185
|
+
Verify that all known configuration options are set to valid values, and log a warning if they are invalid.
|
|
210
186
|
|
|
211
|
-
Invalid auth options will cause this method to throw an error with a `code`
|
|
212
|
-
property of `ERR_INVALID_AUTH`, and a `problems` property listing the specific
|
|
213
|
-
concerns with the current configuration.
|
|
187
|
+
Invalid auth options will cause this method to throw an error with a `code` property of `ERR_INVALID_AUTH`, and a `problems` property listing the specific concerns with the current configuration.
|
|
214
188
|
|
|
215
189
|
If `where` is not set, then all config objects are validated.
|
|
216
190
|
|
|
@@ -222,30 +196,24 @@ Note that it's usually enough (and more efficient) to just check
|
|
|
222
196
|
|
|
223
197
|
### `config.repair(problems)`
|
|
224
198
|
|
|
225
|
-
Accept an optional array of problems (as thrown by `config.validate()`) and
|
|
226
|
-
|
|
227
|
-
this method will call `config.validate()` internally to retrieve them.
|
|
199
|
+
Accept an optional array of problems (as thrown by `config.validate()`) and perform the necessary steps to resolve them.
|
|
200
|
+
If no problems are provided, this method will call `config.validate()` internally to retrieve them.
|
|
228
201
|
|
|
229
202
|
Note that you must `await config.save('user')` in order to persist the changes.
|
|
230
203
|
|
|
231
204
|
### `config.isDefault(key)`
|
|
232
205
|
|
|
233
|
-
Returns `true` if the value is coming directly from the
|
|
234
|
-
default definitions, if the current value for the key config is
|
|
235
|
-
coming from any other source, returns `false`.
|
|
206
|
+
Returns `true` if the value is coming directly from the default definitions, if the current value for the key config is coming from any other source, returns `false`.
|
|
236
207
|
|
|
237
208
|
This method can be used for avoiding or tweaking default values, e.g:
|
|
238
209
|
|
|
239
|
-
> Given a global default definition of foo='foo' it's possible to read that
|
|
240
|
-
> value such as:
|
|
210
|
+
> Given a global default definition of foo='foo' it's possible to read that value such as:
|
|
241
211
|
>
|
|
242
212
|
> ```js
|
|
243
213
|
> const save = config.get('foo')
|
|
244
214
|
> ```
|
|
245
215
|
>
|
|
246
|
-
> Now in a different place of your app it's possible to avoid using the `foo`
|
|
247
|
-
> default value, by checking to see if the current config value is currently
|
|
248
|
-
> one that was defined by the default definitions:
|
|
216
|
+
> Now in a different place of your app it's possible to avoid using the `foo` default value, by checking to see if the current config value is currently one that was defined by the default definitions:
|
|
249
217
|
>
|
|
250
218
|
> ```js
|
|
251
219
|
> const save = config.isDefault('foo') ? 'bar' : config.get('foo')
|
|
@@ -253,5 +221,6 @@ This method can be used for avoiding or tweaking default values, e.g:
|
|
|
253
221
|
|
|
254
222
|
### `config.save(where)`
|
|
255
223
|
|
|
256
|
-
Save the config file specified by the `where` param.
|
|
224
|
+
Save the config file specified by the `where` param.
|
|
225
|
+
Must be one of
|
|
257
226
|
`project`, `user`, `global`, `builtin`.
|
|
@@ -34,7 +34,7 @@ const {
|
|
|
34
34
|
class Definition {
|
|
35
35
|
constructor (key, def) {
|
|
36
36
|
this.key = key
|
|
37
|
-
// if it's set falsey, don't export it
|
|
37
|
+
// if it's set falsey, don't export it; otherwise, we do by default
|
|
38
38
|
this.envExport = true
|
|
39
39
|
Object.assign(this, def)
|
|
40
40
|
this.validate()
|
|
@@ -83,7 +83,7 @@ This value is not exported to the environment for child processes.
|
|
|
83
83
|
`
|
|
84
84
|
const deprecated = !this.deprecated ? '' : `* DEPRECATED: ${unindent(this.deprecated)}\n`
|
|
85
85
|
/* eslint-disable-next-line max-len */
|
|
86
|
-
const exclusive = !this.exclusive ? '' : `\nThis config
|
|
86
|
+
const exclusive = !this.exclusive ? '' : `\nThis config cannot be used with: \`${this.exclusive.join('`, `')}\``
|
|
87
87
|
return wrapAll(`#### \`${this.key}\`
|
|
88
88
|
|
|
89
89
|
* Default: ${unindent(this.defaultDescription)}
|
|
@@ -158,7 +158,7 @@ const definitions = {
|
|
|
158
158
|
If you do not want your scoped package to be publicly viewable (and
|
|
159
159
|
installable) set \`--access=restricted\`.
|
|
160
160
|
|
|
161
|
-
Unscoped packages
|
|
161
|
+
Unscoped packages cannot be set to \`restricted\`.
|
|
162
162
|
|
|
163
163
|
Note: This defaults to not changing the current access level for existing
|
|
164
164
|
packages. Specifying a value of \`restricted\` or \`public\` during
|
|
@@ -274,6 +274,16 @@ const definitions = {
|
|
|
274
274
|
`,
|
|
275
275
|
flatten,
|
|
276
276
|
}),
|
|
277
|
+
'bypass-2fa': new Definition('bypass-2fa', {
|
|
278
|
+
default: false,
|
|
279
|
+
type: Boolean,
|
|
280
|
+
description: `
|
|
281
|
+
When creating a Granular Access Token with \`npm token create\`,
|
|
282
|
+
setting this to true will allow the token to bypass two-factor
|
|
283
|
+
authentication. This is useful for automation and CI/CD workflows.
|
|
284
|
+
`,
|
|
285
|
+
flatten,
|
|
286
|
+
}),
|
|
277
287
|
ca: new Definition('ca', {
|
|
278
288
|
default: null,
|
|
279
289
|
type: [null, String, Array],
|
|
@@ -462,7 +472,7 @@ const definitions = {
|
|
|
462
472
|
depth: new Definition('depth', {
|
|
463
473
|
default: null,
|
|
464
474
|
defaultDescription: `
|
|
465
|
-
\`Infinity\` if \`--all\` is set
|
|
475
|
+
\`Infinity\` if \`--all\` is set; otherwise, \`0\`
|
|
466
476
|
`,
|
|
467
477
|
type: [null, Number],
|
|
468
478
|
description: `
|
|
@@ -624,6 +634,16 @@ const definitions = {
|
|
|
624
634
|
Can be either true (expect some results) or false (expect no results).
|
|
625
635
|
`,
|
|
626
636
|
}),
|
|
637
|
+
expires: new Definition('expires', {
|
|
638
|
+
default: null,
|
|
639
|
+
type: [null, Number],
|
|
640
|
+
description: `
|
|
641
|
+
When creating a Granular Access Token with \`npm token create\`,
|
|
642
|
+
this sets the expiration in days. If not specified, the server
|
|
643
|
+
will determine the default expiration.
|
|
644
|
+
`,
|
|
645
|
+
flatten,
|
|
646
|
+
}),
|
|
627
647
|
'fetch-retries': new Definition('fetch-retries', {
|
|
628
648
|
default: 2,
|
|
629
649
|
type: Number,
|
|
@@ -1205,7 +1225,7 @@ const definitions = {
|
|
|
1205
1225
|
default: null,
|
|
1206
1226
|
type: [null, 1, 2, 3, '1', '2', '3'],
|
|
1207
1227
|
defaultDescription: `
|
|
1208
|
-
Version 3 if no lockfile, auto-converting v1 lockfiles to v3
|
|
1228
|
+
Version 3 if no lockfile, auto-converting v1 lockfiles to v3; otherwise,
|
|
1209
1229
|
maintain current lockfile version.`,
|
|
1210
1230
|
description: `
|
|
1211
1231
|
Set the lockfile format version to be used in package-lock.json and
|
|
@@ -1281,6 +1301,16 @@ const definitions = {
|
|
|
1281
1301
|
Show extended information in \`ls\`, \`search\`, and \`help-search\`.
|
|
1282
1302
|
`,
|
|
1283
1303
|
}),
|
|
1304
|
+
name: new Definition('name', {
|
|
1305
|
+
default: null,
|
|
1306
|
+
type: [null, String],
|
|
1307
|
+
hint: '<name>',
|
|
1308
|
+
description: `
|
|
1309
|
+
When creating a Granular Access Token with \`npm token create\`,
|
|
1310
|
+
this sets the name/description for the token.
|
|
1311
|
+
`,
|
|
1312
|
+
flatten,
|
|
1313
|
+
}),
|
|
1284
1314
|
maxsockets: new Definition('maxsockets', {
|
|
1285
1315
|
default: 15,
|
|
1286
1316
|
type: Number,
|
|
@@ -1304,7 +1334,13 @@ const definitions = {
|
|
|
1304
1334
|
flatten,
|
|
1305
1335
|
}),
|
|
1306
1336
|
'node-gyp': new Definition('node-gyp', {
|
|
1307
|
-
default:
|
|
1337
|
+
default: (() => {
|
|
1338
|
+
try {
|
|
1339
|
+
return require.resolve('node-gyp/bin/node-gyp.js')
|
|
1340
|
+
} catch {
|
|
1341
|
+
return ''
|
|
1342
|
+
}
|
|
1343
|
+
})(),
|
|
1308
1344
|
defaultDescription: `
|
|
1309
1345
|
The path to the node-gyp bin that ships with npm
|
|
1310
1346
|
`,
|
|
@@ -1356,8 +1392,8 @@ const definitions = {
|
|
|
1356
1392
|
omit: new Definition('omit', {
|
|
1357
1393
|
default: process.env.NODE_ENV === 'production' ? ['dev'] : [],
|
|
1358
1394
|
defaultDescription: `
|
|
1359
|
-
'dev' if the \`NODE_ENV\` environment variable is set to 'production'
|
|
1360
|
-
otherwise empty.
|
|
1395
|
+
'dev' if the \`NODE_ENV\` environment variable is set to 'production';
|
|
1396
|
+
otherwise, empty.
|
|
1361
1397
|
`,
|
|
1362
1398
|
type: [Array, 'dev', 'optional', 'peer'],
|
|
1363
1399
|
description: `
|
|
@@ -1403,6 +1439,17 @@ const definitions = {
|
|
|
1403
1439
|
definitions.omit.flatten('omit', obj, flatOptions)
|
|
1404
1440
|
},
|
|
1405
1441
|
}),
|
|
1442
|
+
orgs: new Definition('orgs', {
|
|
1443
|
+
default: null,
|
|
1444
|
+
type: [null, String, Array],
|
|
1445
|
+
hint: '<org1,org2>',
|
|
1446
|
+
description: `
|
|
1447
|
+
When creating a Granular Access Token with \`npm token create\`,
|
|
1448
|
+
this limits the token access to specific organizations. Provide
|
|
1449
|
+
a comma-separated list of organization names.
|
|
1450
|
+
`,
|
|
1451
|
+
flatten,
|
|
1452
|
+
}),
|
|
1406
1453
|
optional: new Definition('optional', {
|
|
1407
1454
|
default: null,
|
|
1408
1455
|
type: [null, Boolean],
|
|
@@ -1499,6 +1546,17 @@ const definitions = {
|
|
|
1499
1546
|
`,
|
|
1500
1547
|
flatten,
|
|
1501
1548
|
}),
|
|
1549
|
+
packages: new Definition('packages', {
|
|
1550
|
+
default: [],
|
|
1551
|
+
type: [null, String, Array],
|
|
1552
|
+
hint: '<pkg1,pkg2>',
|
|
1553
|
+
description: `
|
|
1554
|
+
When creating a Granular Access Token with \`npm token create\`,
|
|
1555
|
+
this limits the token access to specific packages. Provide
|
|
1556
|
+
a comma-separated list of package names.
|
|
1557
|
+
`,
|
|
1558
|
+
flatten,
|
|
1559
|
+
}),
|
|
1502
1560
|
parseable: new Definition('parseable', {
|
|
1503
1561
|
default: false,
|
|
1504
1562
|
type: Boolean,
|
|
@@ -1894,6 +1952,64 @@ const definitions = {
|
|
|
1894
1952
|
flatOptions.projectScope = scope
|
|
1895
1953
|
},
|
|
1896
1954
|
}),
|
|
1955
|
+
scopes: new Definition('scopes', {
|
|
1956
|
+
default: null,
|
|
1957
|
+
type: [null, String, Array],
|
|
1958
|
+
hint: '<@scope1,@scope2>',
|
|
1959
|
+
description: `
|
|
1960
|
+
When creating a Granular Access Token with \`npm token create\`,
|
|
1961
|
+
this limits the token access to specific scopes. Provide
|
|
1962
|
+
a comma-separated list of scope names (with or without @ prefix).
|
|
1963
|
+
`,
|
|
1964
|
+
flatten,
|
|
1965
|
+
}),
|
|
1966
|
+
'packages-all': new Definition('packages-all', {
|
|
1967
|
+
default: false,
|
|
1968
|
+
type: Boolean,
|
|
1969
|
+
description: `
|
|
1970
|
+
When creating a Granular Access Token with \`npm token create\`,
|
|
1971
|
+
grants the token access to all packages instead of limiting to
|
|
1972
|
+
specific packages.
|
|
1973
|
+
`,
|
|
1974
|
+
flatten,
|
|
1975
|
+
}),
|
|
1976
|
+
'packages-and-scopes-permission': new Definition('packages-and-scopes-permission', {
|
|
1977
|
+
default: null,
|
|
1978
|
+
type: [null, 'read-only', 'read-write', 'no-access'],
|
|
1979
|
+
description: `
|
|
1980
|
+
When creating a Granular Access Token with \`npm token create\`,
|
|
1981
|
+
sets the permission level for packages and scopes. Options are
|
|
1982
|
+
"read-only", "read-write", or "no-access".
|
|
1983
|
+
`,
|
|
1984
|
+
flatten,
|
|
1985
|
+
}),
|
|
1986
|
+
'orgs-permission': new Definition('orgs-permission', {
|
|
1987
|
+
default: null,
|
|
1988
|
+
type: [null, 'read-only', 'read-write', 'no-access'],
|
|
1989
|
+
description: `
|
|
1990
|
+
When creating a Granular Access Token with \`npm token create\`,
|
|
1991
|
+
sets the permission level for organizations. Options are
|
|
1992
|
+
"read-only", "read-write", or "no-access".
|
|
1993
|
+
`,
|
|
1994
|
+
flatten,
|
|
1995
|
+
}),
|
|
1996
|
+
password: new Definition('password', {
|
|
1997
|
+
default: null,
|
|
1998
|
+
type: [null, String],
|
|
1999
|
+
description: `
|
|
2000
|
+
Password for authentication. Can be provided via command line when
|
|
2001
|
+
creating tokens, though it's generally safer to be prompted for it.
|
|
2002
|
+
`,
|
|
2003
|
+
flatten,
|
|
2004
|
+
}),
|
|
2005
|
+
'token-description': new Definition('token-description', {
|
|
2006
|
+
default: null,
|
|
2007
|
+
type: [null, String],
|
|
2008
|
+
description: `
|
|
2009
|
+
Description text for the token when using \`npm token create\`.
|
|
2010
|
+
`,
|
|
2011
|
+
flatten,
|
|
2012
|
+
}),
|
|
1897
2013
|
'script-shell': new Definition('script-shell', {
|
|
1898
2014
|
default: null,
|
|
1899
2015
|
defaultDescription: `
|
package/lib/index.js
CHANGED
|
@@ -281,7 +281,7 @@ class Config {
|
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
try {
|
|
284
|
-
// This does not have an actual definition because this is not user
|
|
284
|
+
// This does not have an actual definition because this is not user definable
|
|
285
285
|
defaultsObject['npm-version'] = require(join(this.npmPath, 'package.json')).version
|
|
286
286
|
} catch {
|
|
287
287
|
// in some weird state where the passed in npmPath does not have a package.json
|
|
@@ -589,7 +589,7 @@ class Config {
|
|
|
589
589
|
if (this.definitions[key]?.exclusive) {
|
|
590
590
|
for (const exclusive of this.definitions[key].exclusive) {
|
|
591
591
|
if (!this.isDefault(exclusive)) {
|
|
592
|
-
throw new TypeError(`--${key}
|
|
592
|
+
throw new TypeError(`--${key} cannot be provided when using --${exclusive}`)
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
}
|
|
@@ -672,7 +672,7 @@ class Config {
|
|
|
672
672
|
// if we're in the ~ directory, and there happens to be a node_modules
|
|
673
673
|
// folder (which is not TOO uncommon, it turns out), then we can end
|
|
674
674
|
// up loading the "project" config where the "userconfig" will be,
|
|
675
|
-
// which causes some
|
|
675
|
+
// which causes some calamities. So, we only load project config if
|
|
676
676
|
// it doesn't match what the userconfig will be.
|
|
677
677
|
if (projectFile !== this.#get('userconfig')) {
|
|
678
678
|
return this.#loadFile(projectFile, 'project')
|
package/lib/set-envs.js
CHANGED
|
@@ -97,7 +97,7 @@ const setEnvs = (config) => {
|
|
|
97
97
|
env.EDITOR = cliConf.editor
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
// note: this doesn't
|
|
100
|
+
// note: this doesn't affect the *current* node process, of course, since
|
|
101
101
|
// it's already started, but it does affect the options passed to scripts.
|
|
102
102
|
if (cliConf['node-options']) {
|
|
103
103
|
env.NODE_OPTIONS = cliConf['node-options']
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npmcli/config",
|
|
3
|
-
"version": "10.4.
|
|
3
|
+
"version": "10.4.3",
|
|
4
4
|
"files": [
|
|
5
5
|
"bin/",
|
|
6
6
|
"lib/"
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"@npmcli/map-workspaces": "^5.0.0",
|
|
41
41
|
"@npmcli/package-json": "^7.0.0",
|
|
42
42
|
"ci-info": "^4.0.0",
|
|
43
|
-
"ini": "^
|
|
43
|
+
"ini": "^6.0.0",
|
|
44
44
|
"nopt": "^8.1.0",
|
|
45
|
-
"proc-log": "^
|
|
45
|
+
"proc-log": "^6.0.0",
|
|
46
46
|
"semver": "^7.3.5",
|
|
47
47
|
"walk-up-path": "^4.0.0"
|
|
48
48
|
},
|