@npmcli/config 10.9.1 → 10.10.0
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const Definition = require('./definition.js')
|
|
2
|
+
const parseAllowScriptsList = require('../parse-allow-scripts-list.js')
|
|
2
3
|
|
|
3
4
|
const ciInfo = require('ci-info')
|
|
4
5
|
const querystring = require('node:querystring')
|
|
@@ -153,7 +154,7 @@ const definitions = {
|
|
|
153
154
|
defaultDescription: `
|
|
154
155
|
'public' for new packages, existing packages it will not change the current level
|
|
155
156
|
`,
|
|
156
|
-
type: [null, 'restricted', 'public'],
|
|
157
|
+
type: [null, 'restricted', 'public', 'private'],
|
|
157
158
|
description: `
|
|
158
159
|
If you do not want your scoped package to be publicly viewable (and
|
|
159
160
|
installable) set \`--access=restricted\`.
|
|
@@ -164,8 +165,13 @@ const definitions = {
|
|
|
164
165
|
packages. Specifying a value of \`restricted\` or \`public\` during
|
|
165
166
|
publish will change the access for an existing package the same way that
|
|
166
167
|
\`npm access set status\` would.
|
|
168
|
+
|
|
169
|
+
The value \`private\` is an alias for \`restricted\`.
|
|
167
170
|
`,
|
|
168
|
-
flatten,
|
|
171
|
+
flatten (key, obj, flatOptions) {
|
|
172
|
+
const value = obj[key]
|
|
173
|
+
flatOptions.access = value === 'private' ? 'restricted' : value
|
|
174
|
+
},
|
|
169
175
|
}),
|
|
170
176
|
all: new Definition('all', {
|
|
171
177
|
default: false,
|
|
@@ -247,6 +253,31 @@ const definitions = {
|
|
|
247
253
|
`,
|
|
248
254
|
flatten,
|
|
249
255
|
}),
|
|
256
|
+
'allow-scripts': new Definition('allow-scripts', {
|
|
257
|
+
default: '',
|
|
258
|
+
type: [String, Array],
|
|
259
|
+
hint: '<package-list>',
|
|
260
|
+
description: `
|
|
261
|
+
Comma-separated list of packages whose install-time lifecycle scripts
|
|
262
|
+
(\`preinstall\`, \`install\`, \`postinstall\`, and \`prepare\` for
|
|
263
|
+
non-registry dependencies) are allowed to run.
|
|
264
|
+
|
|
265
|
+
This setting is intended for one-off and global contexts: \`npm exec\`,
|
|
266
|
+
\`npx\`, and \`npm install -g\`, where no project \`package.json\` is
|
|
267
|
+
involved. For team-wide policy in a project, use the \`allowScripts\`
|
|
268
|
+
field in \`package.json\` (which also supports explicit denials), or
|
|
269
|
+
configure it in \`.npmrc\`. Passing \`--allow-scripts\` on the command
|
|
270
|
+
line during a project-scoped \`npm install\`, \`ci\`, \`update\`, or
|
|
271
|
+
\`rebuild\` is an error.
|
|
272
|
+
|
|
273
|
+
Each name is matched against a dependency's resolved identity, not
|
|
274
|
+
against the package's self-reported name. \`--ignore-scripts\` and
|
|
275
|
+
\`--dangerously-allow-all-scripts\` both override this setting.
|
|
276
|
+
`,
|
|
277
|
+
flatten (key, obj, flatOptions) {
|
|
278
|
+
flatOptions.allowScripts = parseAllowScriptsList(obj[key])
|
|
279
|
+
},
|
|
280
|
+
}),
|
|
250
281
|
also: new Definition('also', {
|
|
251
282
|
default: null,
|
|
252
283
|
type: [null, 'dev', 'development'],
|
|
@@ -535,6 +566,18 @@ const definitions = {
|
|
|
535
566
|
`,
|
|
536
567
|
flatten,
|
|
537
568
|
}),
|
|
569
|
+
'dangerously-allow-all-scripts': new Definition('dangerously-allow-all-scripts', {
|
|
570
|
+
default: false,
|
|
571
|
+
type: Boolean,
|
|
572
|
+
description: `
|
|
573
|
+
If \`true\`, bypass the \`allowScripts\` policy entirely and run every
|
|
574
|
+
dependency install script regardless of whether it was approved or
|
|
575
|
+
denied. Intended as a migration escape hatch only; its use is strongly
|
|
576
|
+
discouraged. \`--ignore-scripts\` still takes precedence over this
|
|
577
|
+
setting.
|
|
578
|
+
`,
|
|
579
|
+
flatten,
|
|
580
|
+
}),
|
|
538
581
|
depth: new Definition('depth', {
|
|
539
582
|
default: null,
|
|
540
583
|
defaultDescription: `
|
|
@@ -1667,6 +1710,27 @@ const definitions = {
|
|
|
1667
1710
|
`,
|
|
1668
1711
|
flatten,
|
|
1669
1712
|
}),
|
|
1713
|
+
'allow-scripts-pending': new Definition('allow-scripts-pending', {
|
|
1714
|
+
default: false,
|
|
1715
|
+
type: Boolean,
|
|
1716
|
+
description: `
|
|
1717
|
+
List packages with install scripts that are not yet covered by the
|
|
1718
|
+
\`allowScripts\` policy, without modifying \`package.json\`. Only
|
|
1719
|
+
meaningful for \`npm approve-scripts\`.
|
|
1720
|
+
`,
|
|
1721
|
+
flatten,
|
|
1722
|
+
}),
|
|
1723
|
+
'allow-scripts-pin': new Definition('allow-scripts-pin', {
|
|
1724
|
+
default: true,
|
|
1725
|
+
type: Boolean,
|
|
1726
|
+
description: `
|
|
1727
|
+
Write pinned (\`pkg@version\`) entries when approving install scripts.
|
|
1728
|
+
Set to \`false\` to write name-only entries that allow any version.
|
|
1729
|
+
Has no effect on \`npm deny-scripts\`, which always writes name-only
|
|
1730
|
+
entries regardless of this setting.
|
|
1731
|
+
`,
|
|
1732
|
+
flatten,
|
|
1733
|
+
}),
|
|
1670
1734
|
'prefer-dedupe': new Definition('prefer-dedupe', {
|
|
1671
1735
|
default: false,
|
|
1672
1736
|
type: Boolean,
|
|
@@ -2238,6 +2302,22 @@ const definitions = {
|
|
|
2238
2302
|
`,
|
|
2239
2303
|
flatten,
|
|
2240
2304
|
}),
|
|
2305
|
+
'strict-allow-scripts': new Definition('strict-allow-scripts', {
|
|
2306
|
+
default: false,
|
|
2307
|
+
type: Boolean,
|
|
2308
|
+
description: `
|
|
2309
|
+
If \`true\`, turn the install-script policy from a warning into a hard
|
|
2310
|
+
error: any dependency with install scripts not covered by
|
|
2311
|
+
\`allowScripts\` will fail the install instead of running with a
|
|
2312
|
+
notice.
|
|
2313
|
+
|
|
2314
|
+
Dependencies explicitly denied with \`false\` in \`allowScripts\` are
|
|
2315
|
+
always silently skipped; this setting only affects unreviewed entries.
|
|
2316
|
+
\`--ignore-scripts\` and \`--dangerously-allow-all-scripts\` both
|
|
2317
|
+
override this setting.
|
|
2318
|
+
`,
|
|
2319
|
+
flatten,
|
|
2320
|
+
}),
|
|
2241
2321
|
'strict-ssl': new Definition('strict-ssl', {
|
|
2242
2322
|
default: true,
|
|
2243
2323
|
type: Boolean,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Parse an `allow-scripts` raw config value (string or array of strings)
|
|
2
|
+
// into a flat array of trimmed package-spec entries. Shared between the
|
|
3
|
+
// CLI/env layer (via the `allow-scripts` definition's `flatten`) and the
|
|
4
|
+
// package.json / .npmrc layer (in lib/utils/resolve-allow-scripts.js) so
|
|
5
|
+
// both paths agree on quoting, whitespace, and duplicate handling.
|
|
6
|
+
const parseAllowScriptsList = (raw) => {
|
|
7
|
+
const parts = []
|
|
8
|
+
const entries = Array.isArray(raw) ? raw : (typeof raw === 'string' ? [raw] : [])
|
|
9
|
+
for (const entry of entries) {
|
|
10
|
+
if (typeof entry !== 'string') {
|
|
11
|
+
continue
|
|
12
|
+
}
|
|
13
|
+
for (const part of entry.split(',')) {
|
|
14
|
+
const trimmed = part.trim()
|
|
15
|
+
if (trimmed) {
|
|
16
|
+
parts.push(trimmed)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return parts
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = parseAllowScriptsList
|