@npmcli/config 6.2.0 → 7.0.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.
@@ -0,0 +1,2348 @@
1
+ const definitions = {}
2
+ module.exports = definitions
3
+
4
+ const Definition = require('./definition.js')
5
+
6
+ const ciInfo = require('ci-info')
7
+ const querystring = require('querystring')
8
+ const { join } = require('path')
9
+
10
+ const isWindows = process.platform === 'win32'
11
+
12
+ // used by cafile flattening to flatOptions.ca
13
+ const fs = require('fs')
14
+ const maybeReadFile = file => {
15
+ try {
16
+ return fs.readFileSync(file, 'utf8')
17
+ } catch (er) {
18
+ if (er.code !== 'ENOENT') {
19
+ throw er
20
+ }
21
+ return null
22
+ }
23
+ }
24
+
25
+ const buildOmitList = obj => {
26
+ const include = obj.include || []
27
+ const omit = obj.omit || []
28
+
29
+ const only = obj.only
30
+ if (/^prod(uction)?$/.test(only) || obj.production) {
31
+ omit.push('dev')
32
+ } else if (obj.production === false) {
33
+ include.push('dev')
34
+ }
35
+
36
+ if (/^dev/.test(obj.also)) {
37
+ include.push('dev')
38
+ }
39
+
40
+ if (obj.dev) {
41
+ include.push('dev')
42
+ }
43
+
44
+ if (obj.optional === false) {
45
+ omit.push('optional')
46
+ } else if (obj.optional === true) {
47
+ include.push('optional')
48
+ }
49
+
50
+ obj.omit = [...new Set(omit)].filter(type => !include.includes(type))
51
+ obj.include = [...new Set(include)]
52
+
53
+ if (obj.omit.includes('dev')) {
54
+ process.env.NODE_ENV = 'production'
55
+ }
56
+
57
+ return obj.omit
58
+ }
59
+
60
+ const editor = process.env.EDITOR ||
61
+ process.env.VISUAL ||
62
+ (isWindows ? `${process.env.SYSTEMROOT}\\notepad.exe` : 'vi')
63
+
64
+ const shell = isWindows ? process.env.ComSpec || 'cmd'
65
+ : process.env.SHELL || 'sh'
66
+
67
+ const { networkInterfaces } = require('os')
68
+ const getLocalAddresses = () => {
69
+ try {
70
+ return Object.values(networkInterfaces()).map(
71
+ int => int.map(({ address }) => address)
72
+ ).reduce((set, addrs) => set.concat(addrs), [null])
73
+ } catch (e) {
74
+ return [null]
75
+ }
76
+ }
77
+
78
+ const unicode = /UTF-?8$/i.test(
79
+ process.env.LC_ALL ||
80
+ process.env.LC_CTYPE ||
81
+ process.env.LANG
82
+ )
83
+
84
+ // use LOCALAPPDATA on Windows, if set
85
+ // https://github.com/npm/cli/pull/899
86
+ const cacheRoot = (isWindows && process.env.LOCALAPPDATA) || '~'
87
+ const cacheExtra = isWindows ? 'npm-cache' : '.npm'
88
+ const cache = `${cacheRoot}/${cacheExtra}`
89
+
90
+ // TODO: refactor these type definitions so that they are less
91
+ // weird to pull out of the config module.
92
+ // TODO: use better type definition/validation API, nopt's is so weird.
93
+ const {
94
+ semver: { type: semver },
95
+ Umask: { type: Umask },
96
+ url: { type: url },
97
+ path: { type: path },
98
+ } = require('../type-defs.js')
99
+
100
+ const define = (key, def) => {
101
+ /* istanbul ignore if - this should never happen, prevents mistakes below */
102
+ if (definitions[key]) {
103
+ throw new Error(`defining key more than once: ${key}`)
104
+ }
105
+ definitions[key] = new Definition(key, def)
106
+ }
107
+
108
+ // basic flattening function, just copy it over camelCase
109
+ const flatten = (key, obj, flatOptions) => {
110
+ const camel = key.replace(/-([a-z])/g, (_0, _1) => _1.toUpperCase())
111
+ flatOptions[camel] = obj[key]
112
+ }
113
+
114
+ // TODO:
115
+ // Instead of having each definition provide a flatten method,
116
+ // provide the (?list of?) flat option field(s?) that it impacts.
117
+ // When that config is set, we mark the relevant flatOption fields
118
+ // dirty. Then, a getter for that field defines how we actually
119
+ // set it.
120
+ //
121
+ // So, `save-dev`, `save-optional`, `save-prod`, et al would indicate
122
+ // that they affect the `saveType` flat option. Then the config.flat
123
+ // object has a `get saveType () { ... }` that looks at the "real"
124
+ // config settings from files etc and returns the appropriate value.
125
+ //
126
+ // Getters will also (maybe?) give us a hook to audit flat option
127
+ // usage, so we can document and group these more appropriately.
128
+ //
129
+ // This will be a problem with cases where we currently do:
130
+ // const opts = { ...npm.flatOptions, foo: 'bar' }, but we can maybe
131
+ // instead do `npm.config.set('foo', 'bar')` prior to passing the
132
+ // config object down where it needs to go.
133
+ //
134
+ // This way, when we go hunting for "where does saveType come from anyway!?"
135
+ // while fixing some Arborist bug, we won't have to hunt through too
136
+ // many places.
137
+
138
+ // Define all config keys we know about
139
+
140
+ define('_auth', {
141
+ default: null,
142
+ type: [null, String],
143
+ description: `
144
+ A basic-auth string to use when authenticating against the npm registry.
145
+ This will ONLY be used to authenticate against the npm registry. For other
146
+ registries you will need to scope it like "//other-registry.tld/:_auth"
147
+
148
+ Warning: This should generally not be set via a command-line option. It
149
+ is safer to use a registry-provided authentication bearer token stored in
150
+ the ~/.npmrc file by running \`npm login\`.
151
+ `,
152
+ flatten,
153
+ })
154
+
155
+ define('access', {
156
+ default: null,
157
+ defaultDescription: `
158
+ 'public' for new packages, existing packages it will not change the current level
159
+ `,
160
+ type: [null, 'restricted', 'public'],
161
+ description: `
162
+ If you do not want your scoped package to be publicly viewable (and
163
+ installable) set \`--access=restricted\`.
164
+
165
+ Unscoped packages can not be set to \`restricted\`.
166
+
167
+ Note: This defaults to not changing the current access level for existing
168
+ packages. Specifying a value of \`restricted\` or \`public\` during
169
+ publish will change the access for an existing package the same way that
170
+ \`npm access set status\` would.
171
+ `,
172
+ flatten,
173
+ })
174
+
175
+ define('all', {
176
+ default: false,
177
+ type: Boolean,
178
+ short: 'a',
179
+ description: `
180
+ When running \`npm outdated\` and \`npm ls\`, setting \`--all\` will show
181
+ all outdated or installed packages, rather than only those directly
182
+ depended upon by the current project.
183
+ `,
184
+ flatten,
185
+ })
186
+
187
+ define('allow-same-version', {
188
+ default: false,
189
+ type: Boolean,
190
+ description: `
191
+ Prevents throwing an error when \`npm version\` is used to set the new
192
+ version to the same value as the current version.
193
+ `,
194
+ flatten,
195
+ })
196
+
197
+ define('also', {
198
+ default: null,
199
+ type: [null, 'dev', 'development'],
200
+ description: `
201
+ When set to \`dev\` or \`development\`, this is an alias for
202
+ \`--include=dev\`.
203
+ `,
204
+ deprecated: 'Please use --include=dev instead.',
205
+ flatten (key, obj, flatOptions) {
206
+ definitions.omit.flatten('omit', obj, flatOptions)
207
+ },
208
+ })
209
+
210
+ define('audit', {
211
+ default: true,
212
+ type: Boolean,
213
+ description: `
214
+ When "true" submit audit reports alongside the current npm command to the
215
+ default registry and all registries configured for scopes. See the
216
+ documentation for [\`npm audit\`](/commands/npm-audit) for details on what
217
+ is submitted.
218
+ `,
219
+ flatten,
220
+ })
221
+
222
+ define('audit-level', {
223
+ default: null,
224
+ type: [null, 'info', 'low', 'moderate', 'high', 'critical', 'none'],
225
+ description: `
226
+ The minimum level of vulnerability for \`npm audit\` to exit with
227
+ a non-zero exit code.
228
+ `,
229
+ flatten,
230
+ })
231
+
232
+ define('auth-type', {
233
+ default: 'web',
234
+ type: ['legacy', 'web'],
235
+ description: `
236
+ What authentication strategy to use with \`login\`.
237
+ Note that if an \`otp\` config is given, this value will always be set to \`legacy\`.
238
+ `,
239
+ flatten,
240
+ })
241
+
242
+ define('before', {
243
+ default: null,
244
+ type: [null, Date],
245
+ description: `
246
+ If passed to \`npm install\`, will rebuild the npm tree such that only
247
+ versions that were available **on or before** the \`--before\` time get
248
+ installed. If there's no versions available for the current set of
249
+ direct dependencies, the command will error.
250
+
251
+ If the requested version is a \`dist-tag\` and the given tag does not
252
+ pass the \`--before\` filter, the most recent version less than or equal
253
+ to that tag will be used. For example, \`foo@latest\` might install
254
+ \`foo@1.2\` even though \`latest\` is \`2.0\`.
255
+ `,
256
+ flatten,
257
+ })
258
+
259
+ define('bin-links', {
260
+ default: true,
261
+ type: Boolean,
262
+ description: `
263
+ Tells npm to create symlinks (or \`.cmd\` shims on Windows) for package
264
+ executables.
265
+
266
+ Set to false to have it not do this. This can be used to work around the
267
+ fact that some file systems don't support symlinks, even on ostensibly
268
+ Unix systems.
269
+ `,
270
+ flatten,
271
+ })
272
+
273
+ define('browser', {
274
+ default: null,
275
+ defaultDescription: `
276
+ OS X: \`"open"\`, Windows: \`"start"\`, Others: \`"xdg-open"\`
277
+ `,
278
+ type: [null, Boolean, String],
279
+ description: `
280
+ The browser that is called by npm commands to open websites.
281
+
282
+ Set to \`false\` to suppress browser behavior and instead print urls to
283
+ terminal.
284
+
285
+ Set to \`true\` to use default system URL opener.
286
+ `,
287
+ flatten,
288
+ })
289
+
290
+ define('ca', {
291
+ default: null,
292
+ type: [null, String, Array],
293
+ description: `
294
+ The Certificate Authority signing certificate that is trusted for SSL
295
+ connections to the registry. Values should be in PEM format (Windows
296
+ calls it "Base-64 encoded X.509 (.CER)") with newlines replaced by the
297
+ string "\\n". For example:
298
+
299
+ \`\`\`ini
300
+ ca="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----"
301
+ \`\`\`
302
+
303
+ Set to \`null\` to only allow "known" registrars, or to a specific CA
304
+ cert to trust only that specific signing authority.
305
+
306
+ Multiple CAs can be trusted by specifying an array of certificates:
307
+
308
+ \`\`\`ini
309
+ ca[]="..."
310
+ ca[]="..."
311
+ \`\`\`
312
+
313
+ See also the \`strict-ssl\` config.
314
+ `,
315
+ flatten,
316
+ })
317
+
318
+ define('cache', {
319
+ default: cache,
320
+ defaultDescription: `
321
+ Windows: \`%LocalAppData%\\npm-cache\`, Posix: \`~/.npm\`
322
+ `,
323
+ type: path,
324
+ description: `
325
+ The location of npm's cache directory.
326
+ `,
327
+ flatten (key, obj, flatOptions) {
328
+ flatOptions.cache = join(obj.cache, '_cacache')
329
+ flatOptions.npxCache = join(obj.cache, '_npx')
330
+ flatOptions.tufCache = join(obj.cache, '_tuf')
331
+ },
332
+ })
333
+
334
+ define('cache-max', {
335
+ default: Infinity,
336
+ type: Number,
337
+ description: `
338
+ \`--cache-max=0\` is an alias for \`--prefer-online\`
339
+ `,
340
+ deprecated: `
341
+ This option has been deprecated in favor of \`--prefer-online\`
342
+ `,
343
+ flatten (key, obj, flatOptions) {
344
+ if (obj[key] <= 0) {
345
+ flatOptions.preferOnline = true
346
+ }
347
+ },
348
+ })
349
+
350
+ define('cache-min', {
351
+ default: 0,
352
+ type: Number,
353
+ description: `
354
+ \`--cache-min=9999 (or bigger)\` is an alias for \`--prefer-offline\`.
355
+ `,
356
+ deprecated: `
357
+ This option has been deprecated in favor of \`--prefer-offline\`.
358
+ `,
359
+ flatten (key, obj, flatOptions) {
360
+ if (obj[key] >= 9999) {
361
+ flatOptions.preferOffline = true
362
+ }
363
+ },
364
+ })
365
+
366
+ define('cafile', {
367
+ default: null,
368
+ type: path,
369
+ description: `
370
+ A path to a file containing one or multiple Certificate Authority signing
371
+ certificates. Similar to the \`ca\` setting, but allows for multiple
372
+ CA's, as well as for the CA information to be stored in a file on disk.
373
+ `,
374
+ flatten (key, obj, flatOptions) {
375
+ // always set to null in defaults
376
+ if (!obj.cafile) {
377
+ return
378
+ }
379
+
380
+ const raw = maybeReadFile(obj.cafile)
381
+ if (!raw) {
382
+ return
383
+ }
384
+
385
+ const delim = '-----END CERTIFICATE-----'
386
+ flatOptions.ca = raw.replace(/\r\n/g, '\n').split(delim)
387
+ .filter(section => section.trim())
388
+ .map(section => section.trimLeft() + delim)
389
+ },
390
+ })
391
+
392
+ define('call', {
393
+ default: '',
394
+ type: String,
395
+ short: 'c',
396
+ description: `
397
+ Optional companion option for \`npm exec\`, \`npx\` that allows for
398
+ specifying a custom command to be run along with the installed packages.
399
+
400
+ \`\`\`bash
401
+ npm exec --package yo --package generator-node --call "yo node"
402
+ \`\`\`
403
+ `,
404
+ flatten,
405
+ })
406
+
407
+ define('cert', {
408
+ default: null,
409
+ type: [null, String],
410
+ description: `
411
+ A client certificate to pass when accessing the registry. Values should
412
+ be in PEM format (Windows calls it "Base-64 encoded X.509 (.CER)") with
413
+ newlines replaced by the string "\\n". For example:
414
+
415
+ \`\`\`ini
416
+ cert="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----"
417
+ \`\`\`
418
+
419
+ It is _not_ the path to a certificate file, though you can set a registry-scoped
420
+ "certfile" path like "//other-registry.tld/:certfile=/path/to/cert.pem".
421
+ `,
422
+ deprecated: `
423
+ \`key\` and \`cert\` are no longer used for most registry operations.
424
+ Use registry scoped \`keyfile\` and \`certfile\` instead.
425
+ Example:
426
+ //other-registry.tld/:keyfile=/path/to/key.pem
427
+ //other-registry.tld/:certfile=/path/to/cert.crt
428
+ `,
429
+ flatten,
430
+ })
431
+
432
+ define('cidr', {
433
+ default: null,
434
+ type: [null, String, Array],
435
+ description: `
436
+ This is a list of CIDR address to be used when configuring limited access
437
+ tokens with the \`npm token create\` command.
438
+ `,
439
+ flatten,
440
+ })
441
+
442
+ // This should never be directly used, the flattened value is the derived value
443
+ // and is sent to other modules, and is also exposed as `npm.color` for use
444
+ // inside npm itself.
445
+ define('color', {
446
+ default: !process.env.NO_COLOR || process.env.NO_COLOR === '0',
447
+ usage: '--color|--no-color|--color always',
448
+ defaultDescription: `
449
+ true unless the NO_COLOR environ is set to something other than '0'
450
+ `,
451
+ type: ['always', Boolean],
452
+ description: `
453
+ If false, never shows colors. If \`"always"\` then always shows colors.
454
+ If true, then only prints color codes for tty file descriptors.
455
+ `,
456
+ flatten (key, obj, flatOptions) {
457
+ flatOptions.color = !obj.color ? false
458
+ : obj.color === 'always' ? true
459
+ : !!process.stdout.isTTY
460
+ flatOptions.logColor = !obj.color ? false
461
+ : obj.color === 'always' ? true
462
+ : !!process.stderr.isTTY
463
+ },
464
+ })
465
+
466
+ define('commit-hooks', {
467
+ default: true,
468
+ type: Boolean,
469
+ description: `
470
+ Run git commit hooks when using the \`npm version\` command.
471
+ `,
472
+ flatten,
473
+ })
474
+
475
+ define('depth', {
476
+ default: null,
477
+ defaultDescription: `
478
+ \`Infinity\` if \`--all\` is set, otherwise \`1\`
479
+ `,
480
+ type: [null, Number],
481
+ description: `
482
+ The depth to go when recursing packages for \`npm ls\`.
483
+
484
+ If not set, \`npm ls\` will show only the immediate dependencies of the
485
+ root project. If \`--all\` is set, then npm will show all dependencies
486
+ by default.
487
+ `,
488
+ flatten,
489
+ })
490
+
491
+ define('description', {
492
+ default: true,
493
+ type: Boolean,
494
+ usage: '--no-description',
495
+ description: `
496
+ Show the description in \`npm search\`
497
+ `,
498
+ flatten (key, obj, flatOptions) {
499
+ flatOptions.search = flatOptions.search || { limit: 20 }
500
+ flatOptions.search[key] = obj[key]
501
+ },
502
+ })
503
+
504
+ define('dev', {
505
+ default: false,
506
+ type: Boolean,
507
+ description: `
508
+ Alias for \`--include=dev\`.
509
+ `,
510
+ deprecated: 'Please use --include=dev instead.',
511
+ flatten (key, obj, flatOptions) {
512
+ definitions.omit.flatten('omit', obj, flatOptions)
513
+ },
514
+ })
515
+
516
+ define('diff', {
517
+ default: [],
518
+ hint: '<package-spec>',
519
+ type: [String, Array],
520
+ description: `
521
+ Define arguments to compare in \`npm diff\`.
522
+ `,
523
+ flatten,
524
+ })
525
+
526
+ define('diff-ignore-all-space', {
527
+ default: false,
528
+ type: Boolean,
529
+ description: `
530
+ Ignore whitespace when comparing lines in \`npm diff\`.
531
+ `,
532
+ flatten,
533
+ })
534
+
535
+ define('diff-name-only', {
536
+ default: false,
537
+ type: Boolean,
538
+ description: `
539
+ Prints only filenames when using \`npm diff\`.
540
+ `,
541
+ flatten,
542
+ })
543
+
544
+ define('diff-no-prefix', {
545
+ default: false,
546
+ type: Boolean,
547
+ description: `
548
+ Do not show any source or destination prefix in \`npm diff\` output.
549
+
550
+ Note: this causes \`npm diff\` to ignore the \`--diff-src-prefix\` and
551
+ \`--diff-dst-prefix\` configs.
552
+ `,
553
+ flatten,
554
+ })
555
+
556
+ define('diff-dst-prefix', {
557
+ default: 'b/',
558
+ hint: '<path>',
559
+ type: String,
560
+ description: `
561
+ Destination prefix to be used in \`npm diff\` output.
562
+ `,
563
+ flatten,
564
+ })
565
+
566
+ define('diff-src-prefix', {
567
+ default: 'a/',
568
+ hint: '<path>',
569
+ type: String,
570
+ description: `
571
+ Source prefix to be used in \`npm diff\` output.
572
+ `,
573
+ flatten,
574
+ })
575
+
576
+ define('diff-text', {
577
+ default: false,
578
+ type: Boolean,
579
+ description: `
580
+ Treat all files as text in \`npm diff\`.
581
+ `,
582
+ flatten,
583
+ })
584
+
585
+ define('diff-unified', {
586
+ default: 3,
587
+ type: Number,
588
+ description: `
589
+ The number of lines of context to print in \`npm diff\`.
590
+ `,
591
+ flatten,
592
+ })
593
+
594
+ define('dry-run', {
595
+ default: false,
596
+ type: Boolean,
597
+ description: `
598
+ Indicates that you don't want npm to make any changes and that it should
599
+ only report what it would have done. This can be passed into any of the
600
+ commands that modify your local installation, eg, \`install\`,
601
+ \`update\`, \`dedupe\`, \`uninstall\`, as well as \`pack\` and
602
+ \`publish\`.
603
+
604
+ Note: This is NOT honored by other network related commands, eg
605
+ \`dist-tags\`, \`owner\`, etc.
606
+ `,
607
+ flatten,
608
+ })
609
+
610
+ define('editor', {
611
+ default: editor,
612
+ defaultDescription: `
613
+ The EDITOR or VISUAL environment variables, or '%SYSTEMROOT%\\notepad.exe' on Windows,
614
+ or 'vi' on Unix systems
615
+ `,
616
+ type: String,
617
+ description: `
618
+ The command to run for \`npm edit\` and \`npm config edit\`.
619
+ `,
620
+ flatten,
621
+ })
622
+
623
+ define('engine-strict', {
624
+ default: false,
625
+ type: Boolean,
626
+ description: `
627
+ If set to true, then npm will stubbornly refuse to install (or even
628
+ consider installing) any package that claims to not be compatible with
629
+ the current Node.js version.
630
+
631
+ This can be overridden by setting the \`--force\` flag.
632
+ `,
633
+ flatten,
634
+ })
635
+
636
+ define('fetch-retries', {
637
+ default: 2,
638
+ type: Number,
639
+ description: `
640
+ The "retries" config for the \`retry\` module to use when fetching
641
+ packages from the registry.
642
+
643
+ npm will retry idempotent read requests to the registry in the case
644
+ of network failures or 5xx HTTP errors.
645
+ `,
646
+ flatten (key, obj, flatOptions) {
647
+ flatOptions.retry = flatOptions.retry || {}
648
+ flatOptions.retry.retries = obj[key]
649
+ },
650
+ })
651
+
652
+ define('fetch-retry-factor', {
653
+ default: 10,
654
+ type: Number,
655
+ description: `
656
+ The "factor" config for the \`retry\` module to use when fetching
657
+ packages.
658
+ `,
659
+ flatten (key, obj, flatOptions) {
660
+ flatOptions.retry = flatOptions.retry || {}
661
+ flatOptions.retry.factor = obj[key]
662
+ },
663
+ })
664
+
665
+ define('fetch-retry-maxtimeout', {
666
+ default: 60000,
667
+ defaultDescription: '60000 (1 minute)',
668
+ type: Number,
669
+ description: `
670
+ The "maxTimeout" config for the \`retry\` module to use when fetching
671
+ packages.
672
+ `,
673
+ flatten (key, obj, flatOptions) {
674
+ flatOptions.retry = flatOptions.retry || {}
675
+ flatOptions.retry.maxTimeout = obj[key]
676
+ },
677
+ })
678
+
679
+ define('fetch-retry-mintimeout', {
680
+ default: 10000,
681
+ defaultDescription: '10000 (10 seconds)',
682
+ type: Number,
683
+ description: `
684
+ The "minTimeout" config for the \`retry\` module to use when fetching
685
+ packages.
686
+ `,
687
+ flatten (key, obj, flatOptions) {
688
+ flatOptions.retry = flatOptions.retry || {}
689
+ flatOptions.retry.minTimeout = obj[key]
690
+ },
691
+ })
692
+
693
+ define('fetch-timeout', {
694
+ default: 5 * 60 * 1000,
695
+ defaultDescription: `${5 * 60 * 1000} (5 minutes)`,
696
+ type: Number,
697
+ description: `
698
+ The maximum amount of time to wait for HTTP requests to complete.
699
+ `,
700
+ flatten (key, obj, flatOptions) {
701
+ flatOptions.timeout = obj[key]
702
+ },
703
+ })
704
+
705
+ define('force', {
706
+ default: false,
707
+ type: Boolean,
708
+ short: 'f',
709
+ description: `
710
+ Removes various protections against unfortunate side effects, common
711
+ mistakes, unnecessary performance degradation, and malicious input.
712
+
713
+ * Allow clobbering non-npm files in global installs.
714
+ * Allow the \`npm version\` command to work on an unclean git repository.
715
+ * Allow deleting the cache folder with \`npm cache clean\`.
716
+ * Allow installing packages that have an \`engines\` declaration
717
+ requiring a different version of npm.
718
+ * Allow installing packages that have an \`engines\` declaration
719
+ requiring a different version of \`node\`, even if \`--engine-strict\`
720
+ is enabled.
721
+ * Allow \`npm audit fix\` to install modules outside your stated
722
+ dependency range (including SemVer-major changes).
723
+ * Allow unpublishing all versions of a published package.
724
+ * Allow conflicting peerDependencies to be installed in the root project.
725
+ * Implicitly set \`--yes\` during \`npm init\`.
726
+ * Allow clobbering existing values in \`npm pkg\`
727
+ * Allow unpublishing of entire packages (not just a single version).
728
+
729
+ If you don't have a clear idea of what you want to do, it is strongly
730
+ recommended that you do not use this option!
731
+ `,
732
+ flatten,
733
+ })
734
+
735
+ define('foreground-scripts', {
736
+ default: false,
737
+ type: Boolean,
738
+ description: `
739
+ Run all build scripts (ie, \`preinstall\`, \`install\`, and
740
+ \`postinstall\`) scripts for installed packages in the foreground
741
+ process, sharing standard input, output, and error with the main npm
742
+ process.
743
+
744
+ Note that this will generally make installs run slower, and be much
745
+ noisier, but can be useful for debugging.
746
+ `,
747
+ flatten,
748
+ })
749
+
750
+ define('format-package-lock', {
751
+ default: true,
752
+ type: Boolean,
753
+ description: `
754
+ Format \`package-lock.json\` or \`npm-shrinkwrap.json\` as a human
755
+ readable file.
756
+ `,
757
+ flatten,
758
+ })
759
+
760
+ define('fund', {
761
+ default: true,
762
+ type: Boolean,
763
+ description: `
764
+ When "true" displays the message at the end of each \`npm install\`
765
+ acknowledging the number of dependencies looking for funding.
766
+ See [\`npm fund\`](/commands/npm-fund) for details.
767
+ `,
768
+ flatten,
769
+ })
770
+
771
+ define('git', {
772
+ default: 'git',
773
+ type: String,
774
+ description: `
775
+ The command to use for git commands. If git is installed on the
776
+ computer, but is not in the \`PATH\`, then set this to the full path to
777
+ the git binary.
778
+ `,
779
+ flatten,
780
+ })
781
+
782
+ define('git-tag-version', {
783
+ default: true,
784
+ type: Boolean,
785
+ description: `
786
+ Tag the commit when using the \`npm version\` command. Setting this to
787
+ false results in no commit being made at all.
788
+ `,
789
+ flatten,
790
+ })
791
+
792
+ define('global', {
793
+ default: false,
794
+ type: Boolean,
795
+ short: 'g',
796
+ description: `
797
+ Operates in "global" mode, so that packages are installed into the
798
+ \`prefix\` folder instead of the current working directory. See
799
+ [folders](/configuring-npm/folders) for more on the differences in
800
+ behavior.
801
+
802
+ * packages are installed into the \`{prefix}/lib/node_modules\` folder,
803
+ instead of the current working directory.
804
+ * bin files are linked to \`{prefix}/bin\`
805
+ * man pages are linked to \`{prefix}/share/man\`
806
+ `,
807
+ flatten: (key, obj, flatOptions) => {
808
+ flatten(key, obj, flatOptions)
809
+ if (flatOptions.global) {
810
+ flatOptions.location = 'global'
811
+ }
812
+ },
813
+ })
814
+
815
+ // the globalconfig has its default defined outside of this module
816
+ define('globalconfig', {
817
+ type: path,
818
+ default: '',
819
+ defaultDescription: `
820
+ The global --prefix setting plus 'etc/npmrc'. For example,
821
+ '/usr/local/etc/npmrc'
822
+ `,
823
+ description: `
824
+ The config file to read for global config options.
825
+ `,
826
+ flatten,
827
+ })
828
+
829
+ define('global-style', {
830
+ default: false,
831
+ type: Boolean,
832
+ description: `
833
+ Only install direct dependencies in the top level \`node_modules\`,
834
+ but hoist on deeper dependencies.
835
+ Sets \`--install-strategy=shallow\`.
836
+ `,
837
+ deprecated: `
838
+ This option has been deprecated in favor of \`--install-strategy=shallow\`
839
+ `,
840
+ flatten (key, obj, flatOptions) {
841
+ if (obj[key]) {
842
+ obj['install-strategy'] = 'shallow'
843
+ flatOptions.installStrategy = 'shallow'
844
+ }
845
+ },
846
+ })
847
+
848
+ define('heading', {
849
+ default: 'npm',
850
+ type: String,
851
+ description: `
852
+ The string that starts all the debugging log output.
853
+ `,
854
+ flatten,
855
+ })
856
+
857
+ define('https-proxy', {
858
+ default: null,
859
+ type: [null, url],
860
+ description: `
861
+ A proxy to use for outgoing https requests. If the \`HTTPS_PROXY\` or
862
+ \`https_proxy\` or \`HTTP_PROXY\` or \`http_proxy\` environment variables
863
+ are set, proxy settings will be honored by the underlying
864
+ \`make-fetch-happen\` library.
865
+ `,
866
+ flatten,
867
+ })
868
+
869
+ define('if-present', {
870
+ default: false,
871
+ type: Boolean,
872
+ envExport: false,
873
+ description: `
874
+ If true, npm will not exit with an error code when \`run-script\` is
875
+ invoked for a script that isn't defined in the \`scripts\` section of
876
+ \`package.json\`. This option can be used when it's desirable to
877
+ optionally run a script when it's present and fail if the script fails.
878
+ This is useful, for example, when running scripts that may only apply for
879
+ some builds in an otherwise generic CI setup.
880
+ `,
881
+ flatten,
882
+ })
883
+
884
+ define('ignore-scripts', {
885
+ default: false,
886
+ type: Boolean,
887
+ description: `
888
+ If true, npm does not run scripts specified in package.json files.
889
+
890
+ Note that commands explicitly intended to run a particular script, such
891
+ as \`npm start\`, \`npm stop\`, \`npm restart\`, \`npm test\`, and \`npm
892
+ run-script\` will still run their intended script if \`ignore-scripts\` is
893
+ set, but they will *not* run any pre- or post-scripts.
894
+ `,
895
+ flatten,
896
+ })
897
+
898
+ define('include', {
899
+ default: [],
900
+ type: [Array, 'prod', 'dev', 'optional', 'peer'],
901
+ description: `
902
+ Option that allows for defining which types of dependencies to install.
903
+
904
+ This is the inverse of \`--omit=<type>\`.
905
+
906
+ Dependency types specified in \`--include\` will not be omitted,
907
+ regardless of the order in which omit/include are specified on the
908
+ command-line.
909
+ `,
910
+ flatten (key, obj, flatOptions) {
911
+ // just call the omit flattener, it reads from obj.include
912
+ definitions.omit.flatten('omit', obj, flatOptions)
913
+ },
914
+ })
915
+
916
+ define('include-staged', {
917
+ default: false,
918
+ type: Boolean,
919
+ description: `
920
+ Allow installing "staged" published packages, as defined by [npm RFC PR
921
+ #92](https://github.com/npm/rfcs/pull/92).
922
+
923
+ This is experimental, and not implemented by the npm public registry.
924
+ `,
925
+ flatten,
926
+ })
927
+
928
+ define('include-workspace-root', {
929
+ default: false,
930
+ type: Boolean,
931
+ envExport: false,
932
+ description: `
933
+ Include the workspace root when workspaces are enabled for a command.
934
+
935
+ When false, specifying individual workspaces via the \`workspace\` config,
936
+ or all workspaces via the \`workspaces\` flag, will cause npm to operate only
937
+ on the specified workspaces, and not on the root project.
938
+ `,
939
+ flatten,
940
+ })
941
+
942
+ define('init-author-email', {
943
+ default: '',
944
+ type: String,
945
+ description: `
946
+ The value \`npm init\` should use by default for the package author's
947
+ email.
948
+ `,
949
+ })
950
+
951
+ define('init-author-name', {
952
+ default: '',
953
+ type: String,
954
+ description: `
955
+ The value \`npm init\` should use by default for the package author's name.
956
+ `,
957
+ })
958
+
959
+ define('init-author-url', {
960
+ default: '',
961
+ type: ['', url],
962
+ description: `
963
+ The value \`npm init\` should use by default for the package author's homepage.
964
+ `,
965
+ })
966
+
967
+ define('init-license', {
968
+ default: 'ISC',
969
+ type: String,
970
+ description: `
971
+ The value \`npm init\` should use by default for the package license.
972
+ `,
973
+ })
974
+
975
+ define('init-module', {
976
+ default: '~/.npm-init.js',
977
+ type: path,
978
+ description: `
979
+ A module that will be loaded by the \`npm init\` command. See the
980
+ documentation for the
981
+ [init-package-json](https://github.com/npm/init-package-json) module for
982
+ more information, or [npm init](/commands/npm-init).
983
+ `,
984
+ })
985
+
986
+ define('init-version', {
987
+ default: '1.0.0',
988
+ type: semver,
989
+ description: `
990
+ The value that \`npm init\` should use by default for the package
991
+ version number, if not already set in package.json.
992
+ `,
993
+ })
994
+
995
+ // these "aliases" are historically supported in .npmrc files, unfortunately
996
+ // They should be removed in a future npm version.
997
+ define('init.author.email', {
998
+ default: '',
999
+ type: String,
1000
+ deprecated: `
1001
+ Use \`--init-author-email\` instead.`,
1002
+ description: `
1003
+ Alias for \`--init-author-email\`
1004
+ `,
1005
+ })
1006
+
1007
+ define('init.author.name', {
1008
+ default: '',
1009
+ type: String,
1010
+ deprecated: `
1011
+ Use \`--init-author-name\` instead.
1012
+ `,
1013
+ description: `
1014
+ Alias for \`--init-author-name\`
1015
+ `,
1016
+ })
1017
+
1018
+ define('init.author.url', {
1019
+ default: '',
1020
+ type: ['', url],
1021
+ deprecated: `
1022
+ Use \`--init-author-url\` instead.
1023
+ `,
1024
+ description: `
1025
+ Alias for \`--init-author-url\`
1026
+ `,
1027
+ })
1028
+
1029
+ define('init.license', {
1030
+ default: 'ISC',
1031
+ type: String,
1032
+ deprecated: `
1033
+ Use \`--init-license\` instead.
1034
+ `,
1035
+ description: `
1036
+ Alias for \`--init-license\`
1037
+ `,
1038
+ })
1039
+
1040
+ define('init.module', {
1041
+ default: '~/.npm-init.js',
1042
+ type: path,
1043
+ deprecated: `
1044
+ Use \`--init-module\` instead.
1045
+ `,
1046
+ description: `
1047
+ Alias for \`--init-module\`
1048
+ `,
1049
+ })
1050
+
1051
+ define('init.version', {
1052
+ default: '1.0.0',
1053
+ type: semver,
1054
+ deprecated: `
1055
+ Use \`--init-version\` instead.
1056
+ `,
1057
+ description: `
1058
+ Alias for \`--init-version\`
1059
+ `,
1060
+ })
1061
+
1062
+ define('install-links', {
1063
+ default: false,
1064
+ type: Boolean,
1065
+ description: `
1066
+ When set file: protocol dependencies will be packed and installed as
1067
+ regular dependencies instead of creating a symlink. This option has
1068
+ no effect on workspaces.
1069
+ `,
1070
+ flatten,
1071
+ })
1072
+
1073
+ define('install-strategy', {
1074
+ default: 'hoisted',
1075
+ type: ['hoisted', 'nested', 'shallow', 'linked'],
1076
+ description: `
1077
+ Sets the strategy for installing packages in node_modules.
1078
+ hoisted (default): Install non-duplicated in top-level, and duplicated as
1079
+ necessary within directory structure.
1080
+ nested: (formerly --legacy-bundling) install in place, no hoisting.
1081
+ shallow (formerly --global-style) only install direct deps at top-level.
1082
+ linked: (experimental) install in node_modules/.store, link in place,
1083
+ unhoisted.
1084
+ `,
1085
+ flatten,
1086
+ })
1087
+
1088
+ define('json', {
1089
+ default: false,
1090
+ type: Boolean,
1091
+ description: `
1092
+ Whether or not to output JSON data, rather than the normal output.
1093
+
1094
+ * In \`npm pkg set\` it enables parsing set values with JSON.parse()
1095
+ before saving them to your \`package.json\`.
1096
+
1097
+ Not supported by all npm commands.
1098
+ `,
1099
+ flatten,
1100
+ })
1101
+
1102
+ define('key', {
1103
+ default: null,
1104
+ type: [null, String],
1105
+ description: `
1106
+ A client key to pass when accessing the registry. Values should be in
1107
+ PEM format with newlines replaced by the string "\\n". For example:
1108
+
1109
+ \`\`\`ini
1110
+ key="-----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY-----"
1111
+ \`\`\`
1112
+
1113
+ It is _not_ the path to a key file, though you can set a registry-scoped
1114
+ "keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem".
1115
+ `,
1116
+ deprecated: `
1117
+ \`key\` and \`cert\` are no longer used for most registry operations.
1118
+ Use registry scoped \`keyfile\` and \`certfile\` instead.
1119
+ Example:
1120
+ //other-registry.tld/:keyfile=/path/to/key.pem
1121
+ //other-registry.tld/:certfile=/path/to/cert.crt
1122
+ `,
1123
+ flatten,
1124
+ })
1125
+
1126
+ define('legacy-bundling', {
1127
+ default: false,
1128
+ type: Boolean,
1129
+ description: `
1130
+ Instead of hoisting package installs in \`node_modules\`, install packages
1131
+ in the same manner that they are depended on. This may cause very deep
1132
+ directory structures and duplicate package installs as there is no
1133
+ de-duplicating.
1134
+ Sets \`--install-strategy=nested\`.
1135
+ `,
1136
+ deprecated: `
1137
+ This option has been deprecated in favor of \`--install-strategy=nested\`
1138
+ `,
1139
+ flatten (key, obj, flatOptions) {
1140
+ if (obj[key]) {
1141
+ obj['install-strategy'] = 'nested'
1142
+ flatOptions.installStrategy = 'nested'
1143
+ }
1144
+ },
1145
+ })
1146
+
1147
+ define('legacy-peer-deps', {
1148
+ default: false,
1149
+ type: Boolean,
1150
+ description: `
1151
+ Causes npm to completely ignore \`peerDependencies\` when building a
1152
+ package tree, as in npm versions 3 through 6.
1153
+
1154
+ If a package cannot be installed because of overly strict
1155
+ \`peerDependencies\` that collide, it provides a way to move forward
1156
+ resolving the situation.
1157
+
1158
+ This differs from \`--omit=peer\`, in that \`--omit=peer\` will avoid
1159
+ unpacking \`peerDependencies\` on disk, but will still design a tree such
1160
+ that \`peerDependencies\` _could_ be unpacked in a correct place.
1161
+
1162
+ Use of \`legacy-peer-deps\` is not recommended, as it will not enforce
1163
+ the \`peerDependencies\` contract that meta-dependencies may rely on.
1164
+ `,
1165
+ flatten,
1166
+ })
1167
+
1168
+ define('link', {
1169
+ default: false,
1170
+ type: Boolean,
1171
+ description: `
1172
+ Used with \`npm ls\`, limiting output to only those packages that are
1173
+ linked.
1174
+ `,
1175
+ })
1176
+
1177
+ define('local-address', {
1178
+ default: null,
1179
+ type: getLocalAddresses(),
1180
+ typeDescription: 'IP Address',
1181
+ description: `
1182
+ The IP address of the local interface to use when making connections to
1183
+ the npm registry. Must be IPv4 in versions of Node prior to 0.12.
1184
+ `,
1185
+ flatten,
1186
+ })
1187
+
1188
+ define('location', {
1189
+ default: 'user',
1190
+ short: 'L',
1191
+ type: [
1192
+ 'global',
1193
+ 'user',
1194
+ 'project',
1195
+ ],
1196
+ defaultDescription: `
1197
+ "user" unless \`--global\` is passed, which will also set this value to "global"
1198
+ `,
1199
+ description: `
1200
+ When passed to \`npm config\` this refers to which config file to use.
1201
+
1202
+ When set to "global" mode, packages are installed into the \`prefix\` folder
1203
+ instead of the current working directory. See
1204
+ [folders](/configuring-npm/folders) for more on the differences in behavior.
1205
+
1206
+ * packages are installed into the \`{prefix}/lib/node_modules\` folder,
1207
+ instead of the current working directory.
1208
+ * bin files are linked to \`{prefix}/bin\`
1209
+ * man pages are linked to \`{prefix}/share/man\`
1210
+ `,
1211
+ flatten: (key, obj, flatOptions) => {
1212
+ flatten(key, obj, flatOptions)
1213
+ if (flatOptions.global) {
1214
+ flatOptions.location = 'global'
1215
+ }
1216
+ if (obj.location === 'global') {
1217
+ flatOptions.global = true
1218
+ }
1219
+ },
1220
+ })
1221
+
1222
+ define('lockfile-version', {
1223
+ default: null,
1224
+ type: [null, 1, 2, 3, '1', '2', '3'],
1225
+ defaultDescription: `
1226
+ Version 3 if no lockfile, auto-converting v1 lockfiles to v3, otherwise
1227
+ maintain current lockfile version.`,
1228
+ description: `
1229
+ Set the lockfile format version to be used in package-lock.json and
1230
+ npm-shrinkwrap-json files. Possible options are:
1231
+
1232
+ 1: The lockfile version used by npm versions 5 and 6. Lacks some data that
1233
+ is used during the install, resulting in slower and possibly less
1234
+ deterministic installs. Prevents lockfile churn when interoperating with
1235
+ older npm versions.
1236
+
1237
+ 2: The default lockfile version used by npm version 7 and 8. Includes both
1238
+ the version 1 lockfile data and version 3 lockfile data, for maximum
1239
+ determinism and interoperability, at the expense of more bytes on disk.
1240
+
1241
+ 3: Only the new lockfile information introduced in npm version 7. Smaller
1242
+ on disk than lockfile version 2, but not interoperable with older npm
1243
+ versions. Ideal if all users are on npm version 7 and higher.
1244
+ `,
1245
+ flatten: (key, obj, flatOptions) => {
1246
+ flatOptions.lockfileVersion = obj[key] && parseInt(obj[key], 10)
1247
+ },
1248
+ })
1249
+
1250
+ define('loglevel', {
1251
+ default: 'notice',
1252
+ type: [
1253
+ 'silent',
1254
+ 'error',
1255
+ 'warn',
1256
+ 'notice',
1257
+ 'http',
1258
+ 'info',
1259
+ 'verbose',
1260
+ 'silly',
1261
+ ],
1262
+ description: `
1263
+ What level of logs to report. All logs are written to a debug log,
1264
+ with the path to that file printed if the execution of a command fails.
1265
+
1266
+ Any logs of a higher level than the setting are shown. The default is
1267
+ "notice".
1268
+
1269
+ See also the \`foreground-scripts\` config.
1270
+ `,
1271
+ flatten (key, obj, flatOptions) {
1272
+ flatOptions.silent = obj[key] === 'silent'
1273
+ },
1274
+ })
1275
+
1276
+ define('logs-dir', {
1277
+ default: null,
1278
+ type: [null, path],
1279
+ defaultDescription: `
1280
+ A directory named \`_logs\` inside the cache
1281
+ `,
1282
+ description: `
1283
+ The location of npm's log directory. See [\`npm
1284
+ logging\`](/using-npm/logging) for more information.
1285
+ `,
1286
+ })
1287
+
1288
+ define('logs-max', {
1289
+ default: 10,
1290
+ type: Number,
1291
+ description: `
1292
+ The maximum number of log files to store.
1293
+
1294
+ If set to 0, no log files will be written for the current run.
1295
+ `,
1296
+ })
1297
+
1298
+ define('long', {
1299
+ default: false,
1300
+ type: Boolean,
1301
+ short: 'l',
1302
+ description: `
1303
+ Show extended information in \`ls\`, \`search\`, and \`help-search\`.
1304
+ `,
1305
+ })
1306
+
1307
+ define('maxsockets', {
1308
+ default: 15,
1309
+ type: Number,
1310
+ description: `
1311
+ The maximum number of connections to use per origin (protocol/host/port
1312
+ combination).
1313
+ `,
1314
+ flatten (key, obj, flatOptions) {
1315
+ flatOptions.maxSockets = obj[key]
1316
+ },
1317
+ })
1318
+
1319
+ define('message', {
1320
+ default: '%s',
1321
+ type: String,
1322
+ short: 'm',
1323
+ description: `
1324
+ Commit message which is used by \`npm version\` when creating version commit.
1325
+
1326
+ Any "%s" in the message will be replaced with the version number.
1327
+ `,
1328
+ flatten,
1329
+ })
1330
+
1331
+ define('node-options', {
1332
+ default: null,
1333
+ type: [null, String],
1334
+ description: `
1335
+ Options to pass through to Node.js via the \`NODE_OPTIONS\` environment
1336
+ variable. This does not impact how npm itself is executed but it does
1337
+ impact how lifecycle scripts are called.
1338
+ `,
1339
+ })
1340
+
1341
+ define('noproxy', {
1342
+ default: '',
1343
+ defaultDescription: `
1344
+ The value of the NO_PROXY environment variable
1345
+ `,
1346
+ type: [String, Array],
1347
+ description: `
1348
+ Domain extensions that should bypass any proxies.
1349
+
1350
+ Also accepts a comma-delimited string.
1351
+ `,
1352
+ flatten (key, obj, flatOptions) {
1353
+ if (Array.isArray(obj[key])) {
1354
+ flatOptions.noProxy = obj[key].join(',')
1355
+ } else {
1356
+ flatOptions.noProxy = obj[key]
1357
+ }
1358
+ },
1359
+ })
1360
+
1361
+ define('offline', {
1362
+ default: false,
1363
+ type: Boolean,
1364
+ description: `
1365
+ Force offline mode: no network requests will be done during install. To allow
1366
+ the CLI to fill in missing cache data, see \`--prefer-offline\`.
1367
+ `,
1368
+ flatten,
1369
+ })
1370
+
1371
+ define('omit', {
1372
+ default: process.env.NODE_ENV === 'production' ? ['dev'] : [],
1373
+ defaultDescription: `
1374
+ 'dev' if the \`NODE_ENV\` environment variable is set to 'production',
1375
+ otherwise empty.
1376
+ `,
1377
+ type: [Array, 'dev', 'optional', 'peer'],
1378
+ description: `
1379
+ Dependency types to omit from the installation tree on disk.
1380
+
1381
+ Note that these dependencies _are_ still resolved and added to the
1382
+ \`package-lock.json\` or \`npm-shrinkwrap.json\` file. They are just
1383
+ not physically installed on disk.
1384
+
1385
+ If a package type appears in both the \`--include\` and \`--omit\`
1386
+ lists, then it will be included.
1387
+
1388
+ If the resulting omit list includes \`'dev'\`, then the \`NODE_ENV\`
1389
+ environment variable will be set to \`'production'\` for all lifecycle
1390
+ scripts.
1391
+ `,
1392
+ flatten (key, obj, flatOptions) {
1393
+ flatOptions.omit = buildOmitList(obj)
1394
+ },
1395
+ })
1396
+
1397
+ define('omit-lockfile-registry-resolved', {
1398
+ default: false,
1399
+ type: Boolean,
1400
+ description: `
1401
+ This option causes npm to create lock files without a \`resolved\` key for
1402
+ registry dependencies. Subsequent installs will need to resolve tarball
1403
+ endpoints with the configured registry, likely resulting in a longer install
1404
+ time.
1405
+ `,
1406
+ flatten,
1407
+ })
1408
+
1409
+ define('only', {
1410
+ default: null,
1411
+ type: [null, 'prod', 'production'],
1412
+ deprecated: `
1413
+ Use \`--omit=dev\` to omit dev dependencies from the install.
1414
+ `,
1415
+ description: `
1416
+ When set to \`prod\` or \`production\`, this is an alias for
1417
+ \`--omit=dev\`.
1418
+ `,
1419
+ flatten (key, obj, flatOptions) {
1420
+ definitions.omit.flatten('omit', obj, flatOptions)
1421
+ },
1422
+ })
1423
+
1424
+ define('optional', {
1425
+ default: null,
1426
+ type: [null, Boolean],
1427
+ deprecated: `
1428
+ Use \`--omit=optional\` to exclude optional dependencies, or
1429
+ \`--include=optional\` to include them.
1430
+
1431
+ Default value does install optional deps unless otherwise omitted.
1432
+ `,
1433
+ description: `
1434
+ Alias for --include=optional or --omit=optional
1435
+ `,
1436
+ flatten (key, obj, flatOptions) {
1437
+ definitions.omit.flatten('omit', obj, flatOptions)
1438
+ },
1439
+ })
1440
+
1441
+ define('otp', {
1442
+ default: null,
1443
+ type: [null, String],
1444
+ description: `
1445
+ This is a one-time password from a two-factor authenticator. It's needed
1446
+ when publishing or changing package permissions with \`npm access\`.
1447
+
1448
+ If not set, and a registry response fails with a challenge for a one-time
1449
+ password, npm will prompt on the command line for one.
1450
+ `,
1451
+ flatten (key, obj, flatOptions) {
1452
+ flatten(key, obj, flatOptions)
1453
+ if (obj.otp) {
1454
+ obj['auth-type'] = 'legacy'
1455
+ flatten('auth-type', obj, flatOptions)
1456
+ }
1457
+ },
1458
+ })
1459
+
1460
+ define('package', {
1461
+ default: [],
1462
+ hint: '<package-spec>',
1463
+ type: [String, Array],
1464
+ description: `
1465
+ The package or packages to install for [\`npm exec\`](/commands/npm-exec)
1466
+ `,
1467
+ flatten,
1468
+ })
1469
+
1470
+ define('package-lock', {
1471
+ default: true,
1472
+ type: Boolean,
1473
+ description: `
1474
+ If set to false, then ignore \`package-lock.json\` files when installing.
1475
+ This will also prevent _writing_ \`package-lock.json\` if \`save\` is
1476
+ true.
1477
+ `,
1478
+ flatten: (key, obj, flatOptions) => {
1479
+ flatten(key, obj, flatOptions)
1480
+ if (flatOptions.packageLockOnly) {
1481
+ flatOptions.packageLock = true
1482
+ }
1483
+ },
1484
+ })
1485
+
1486
+ define('package-lock-only', {
1487
+ default: false,
1488
+ type: Boolean,
1489
+ description: `
1490
+ If set to true, the current operation will only use the \`package-lock.json\`,
1491
+ ignoring \`node_modules\`.
1492
+
1493
+ For \`update\` this means only the \`package-lock.json\` will be updated,
1494
+ instead of checking \`node_modules\` and downloading dependencies.
1495
+
1496
+ For \`list\` this means the output will be based on the tree described by the
1497
+ \`package-lock.json\`, rather than the contents of \`node_modules\`.
1498
+ `,
1499
+ flatten: (key, obj, flatOptions) => {
1500
+ flatten(key, obj, flatOptions)
1501
+ if (flatOptions.packageLockOnly) {
1502
+ flatOptions.packageLock = true
1503
+ }
1504
+ },
1505
+ })
1506
+
1507
+ define('pack-destination', {
1508
+ default: '.',
1509
+ type: String,
1510
+ description: `
1511
+ Directory in which \`npm pack\` will save tarballs.
1512
+ `,
1513
+ flatten,
1514
+ })
1515
+
1516
+ define('parseable', {
1517
+ default: false,
1518
+ type: Boolean,
1519
+ short: 'p',
1520
+ description: `
1521
+ Output parseable results from commands that write to standard output. For
1522
+ \`npm search\`, this will be tab-separated table format.
1523
+ `,
1524
+ flatten,
1525
+ })
1526
+
1527
+ define('prefer-dedupe', {
1528
+ default: false,
1529
+ type: Boolean,
1530
+ description: `
1531
+ Prefer to deduplicate packages if possible, rather than
1532
+ choosing a newer version of a dependency.
1533
+ `,
1534
+ flatten,
1535
+ })
1536
+
1537
+ define('prefer-offline', {
1538
+ default: false,
1539
+ type: Boolean,
1540
+ description: `
1541
+ If true, staleness checks for cached data will be bypassed, but missing
1542
+ data will be requested from the server. To force full offline mode, use
1543
+ \`--offline\`.
1544
+ `,
1545
+ flatten,
1546
+ })
1547
+
1548
+ define('prefer-online', {
1549
+ default: false,
1550
+ type: Boolean,
1551
+ description: `
1552
+ If true, staleness checks for cached data will be forced, making the CLI
1553
+ look for updates immediately even for fresh package data.
1554
+ `,
1555
+ flatten,
1556
+ })
1557
+
1558
+ // `prefix` has its default defined outside of this module
1559
+ define('prefix', {
1560
+ type: path,
1561
+ short: 'C',
1562
+ default: '',
1563
+ defaultDescription: `
1564
+ In global mode, the folder where the node executable is installed.
1565
+ Otherwise, the nearest parent folder containing either a package.json
1566
+ file or a node_modules folder.
1567
+ `,
1568
+ description: `
1569
+ The location to install global items. If set on the command line, then
1570
+ it forces non-global commands to run in the specified folder.
1571
+ `,
1572
+ })
1573
+
1574
+ define('preid', {
1575
+ default: '',
1576
+ hint: 'prerelease-id',
1577
+ type: String,
1578
+ description: `
1579
+ The "prerelease identifier" to use as a prefix for the "prerelease" part
1580
+ of a semver. Like the \`rc\` in \`1.2.0-rc.8\`.
1581
+ `,
1582
+ flatten,
1583
+ })
1584
+
1585
+ define('production', {
1586
+ default: null,
1587
+ type: [null, Boolean],
1588
+ deprecated: 'Use `--omit=dev` instead.',
1589
+ description: 'Alias for `--omit=dev`',
1590
+ flatten (key, obj, flatOptions) {
1591
+ definitions.omit.flatten('omit', obj, flatOptions)
1592
+ },
1593
+ })
1594
+
1595
+ define('progress', {
1596
+ default: !ciInfo.isCI,
1597
+ defaultDescription: `
1598
+ \`true\` unless running in a known CI system
1599
+ `,
1600
+ type: Boolean,
1601
+ description: `
1602
+ When set to \`true\`, npm will display a progress bar during time
1603
+ intensive operations, if \`process.stderr\` is a TTY.
1604
+
1605
+ Set to \`false\` to suppress the progress bar.
1606
+ `,
1607
+ flatten (key, obj, flatOptions) {
1608
+ flatOptions.progress = !obj.progress ? false
1609
+ : !!process.stderr.isTTY && process.env.TERM !== 'dumb'
1610
+ },
1611
+ })
1612
+
1613
+ define('provenance', {
1614
+ default: false,
1615
+ type: Boolean,
1616
+ exclusive: ['provenance-file'],
1617
+ description: `
1618
+ When publishing from a supported cloud CI/CD system, the package will be
1619
+ publicly linked to where it was built and published from.
1620
+ `,
1621
+ flatten,
1622
+ })
1623
+
1624
+ define('provenance-file', {
1625
+ default: null,
1626
+ type: path,
1627
+ hint: '<file>',
1628
+ exclusive: ['provenance'],
1629
+ description: `
1630
+ When publishing, the provenance bundle at the given path will be used.
1631
+ `,
1632
+ flatten,
1633
+ })
1634
+
1635
+ define('proxy', {
1636
+ default: null,
1637
+ type: [null, false, url], // allow proxy to be disabled explicitly
1638
+ description: `
1639
+ A proxy to use for outgoing http requests. If the \`HTTP_PROXY\` or
1640
+ \`http_proxy\` environment variables are set, proxy settings will be
1641
+ honored by the underlying \`request\` library.
1642
+ `,
1643
+ flatten,
1644
+ })
1645
+
1646
+ define('read-only', {
1647
+ default: false,
1648
+ type: Boolean,
1649
+ description: `
1650
+ This is used to mark a token as unable to publish when configuring
1651
+ limited access tokens with the \`npm token create\` command.
1652
+ `,
1653
+ flatten,
1654
+ })
1655
+
1656
+ define('rebuild-bundle', {
1657
+ default: true,
1658
+ type: Boolean,
1659
+ description: `
1660
+ Rebuild bundled dependencies after installation.
1661
+ `,
1662
+ flatten,
1663
+ })
1664
+
1665
+ define('registry', {
1666
+ default: 'https://registry.npmjs.org/',
1667
+ type: url,
1668
+ description: `
1669
+ The base URL of the npm registry.
1670
+ `,
1671
+ flatten,
1672
+ })
1673
+
1674
+ define('replace-registry-host', {
1675
+ default: 'npmjs',
1676
+ hint: '<npmjs|never|always> | hostname',
1677
+ type: ['npmjs', 'never', 'always', String],
1678
+ description: `
1679
+ Defines behavior for replacing the registry host in a lockfile with the
1680
+ configured registry.
1681
+
1682
+ The default behavior is to replace package dist URLs from the default
1683
+ registry (https://registry.npmjs.org) to the configured registry. If set to
1684
+ "never", then use the registry value. If set to "always", then replace the
1685
+ registry host with the configured host every time.
1686
+
1687
+ You may also specify a bare hostname (e.g., "registry.npmjs.org").
1688
+ `,
1689
+ flatten,
1690
+ })
1691
+
1692
+ define('save', {
1693
+ default: true,
1694
+ defaultDescription: `\`true\` unless when using \`npm update\` where it
1695
+ defaults to \`false\``,
1696
+ usage: '-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle',
1697
+ type: Boolean,
1698
+ short: 'S',
1699
+ description: `
1700
+ Save installed packages to a \`package.json\` file as dependencies.
1701
+
1702
+ When used with the \`npm rm\` command, removes the dependency from
1703
+ \`package.json\`.
1704
+
1705
+ Will also prevent writing to \`package-lock.json\` if set to \`false\`.
1706
+ `,
1707
+ flatten,
1708
+ })
1709
+
1710
+ define('save-bundle', {
1711
+ default: false,
1712
+ type: Boolean,
1713
+ short: 'B',
1714
+ description: `
1715
+ If a package would be saved at install time by the use of \`--save\`,
1716
+ \`--save-dev\`, or \`--save-optional\`, then also put it in the
1717
+ \`bundleDependencies\` list.
1718
+
1719
+ Ignored if \`--save-peer\` is set, since peerDependencies cannot be bundled.
1720
+ `,
1721
+ flatten (key, obj, flatOptions) {
1722
+ // XXX update arborist to just ignore it if resulting saveType is peer
1723
+ // otherwise this won't have the expected effect:
1724
+ //
1725
+ // npm config set save-peer true
1726
+ // npm i foo --save-bundle --save-prod <-- should bundle
1727
+ flatOptions.saveBundle = obj['save-bundle'] && !obj['save-peer']
1728
+ },
1729
+ })
1730
+
1731
+ // XXX: We should really deprecate all these `--save-blah` switches
1732
+ // in favor of a single `--save-type` option. The unfortunate shortcut
1733
+ // we took for `--save-peer --save-optional` being `--save-type=peerOptional`
1734
+ // makes this tricky, and likely a breaking change.
1735
+
1736
+ define('save-dev', {
1737
+ default: false,
1738
+ type: Boolean,
1739
+ short: 'D',
1740
+ description: `
1741
+ Save installed packages to a package.json file as \`devDependencies\`.
1742
+ `,
1743
+ flatten (key, obj, flatOptions) {
1744
+ if (!obj[key]) {
1745
+ if (flatOptions.saveType === 'dev') {
1746
+ delete flatOptions.saveType
1747
+ }
1748
+ return
1749
+ }
1750
+
1751
+ flatOptions.saveType = 'dev'
1752
+ },
1753
+ })
1754
+
1755
+ define('save-exact', {
1756
+ default: false,
1757
+ type: Boolean,
1758
+ short: 'E',
1759
+ description: `
1760
+ Dependencies saved to package.json will be configured with an exact
1761
+ version rather than using npm's default semver range operator.
1762
+ `,
1763
+ flatten (key, obj, flatOptions) {
1764
+ // just call the save-prefix flattener, it reads from obj['save-exact']
1765
+ definitions['save-prefix'].flatten('save-prefix', obj, flatOptions)
1766
+ },
1767
+ })
1768
+
1769
+ define('save-optional', {
1770
+ default: false,
1771
+ type: Boolean,
1772
+ short: 'O',
1773
+ description: `
1774
+ Save installed packages to a package.json file as
1775
+ \`optionalDependencies\`.
1776
+ `,
1777
+ flatten (key, obj, flatOptions) {
1778
+ if (!obj[key]) {
1779
+ if (flatOptions.saveType === 'optional') {
1780
+ delete flatOptions.saveType
1781
+ } else if (flatOptions.saveType === 'peerOptional') {
1782
+ flatOptions.saveType = 'peer'
1783
+ }
1784
+ return
1785
+ }
1786
+
1787
+ if (flatOptions.saveType === 'peerOptional') {
1788
+ return
1789
+ }
1790
+
1791
+ if (flatOptions.saveType === 'peer') {
1792
+ flatOptions.saveType = 'peerOptional'
1793
+ } else {
1794
+ flatOptions.saveType = 'optional'
1795
+ }
1796
+ },
1797
+ })
1798
+
1799
+ define('save-peer', {
1800
+ default: false,
1801
+ type: Boolean,
1802
+ description: `
1803
+ Save installed packages to a package.json file as \`peerDependencies\`
1804
+ `,
1805
+ flatten (key, obj, flatOptions) {
1806
+ if (!obj[key]) {
1807
+ if (flatOptions.saveType === 'peer') {
1808
+ delete flatOptions.saveType
1809
+ } else if (flatOptions.saveType === 'peerOptional') {
1810
+ flatOptions.saveType = 'optional'
1811
+ }
1812
+ return
1813
+ }
1814
+
1815
+ if (flatOptions.saveType === 'peerOptional') {
1816
+ return
1817
+ }
1818
+
1819
+ if (flatOptions.saveType === 'optional') {
1820
+ flatOptions.saveType = 'peerOptional'
1821
+ } else {
1822
+ flatOptions.saveType = 'peer'
1823
+ }
1824
+ },
1825
+ })
1826
+
1827
+ define('save-prefix', {
1828
+ default: '^',
1829
+ type: String,
1830
+ description: `
1831
+ Configure how versions of packages installed to a package.json file via
1832
+ \`--save\` or \`--save-dev\` get prefixed.
1833
+
1834
+ For example if a package has version \`1.2.3\`, by default its version is
1835
+ set to \`^1.2.3\` which allows minor upgrades for that package, but after
1836
+ \`npm config set save-prefix='~'\` it would be set to \`~1.2.3\` which
1837
+ only allows patch upgrades.
1838
+ `,
1839
+ flatten (key, obj, flatOptions) {
1840
+ flatOptions.savePrefix = obj['save-exact'] ? '' : obj['save-prefix']
1841
+ obj['save-prefix'] = flatOptions.savePrefix
1842
+ },
1843
+ })
1844
+
1845
+ define('save-prod', {
1846
+ default: false,
1847
+ type: Boolean,
1848
+ short: 'P',
1849
+ description: `
1850
+ Save installed packages into \`dependencies\` specifically. This is
1851
+ useful if a package already exists in \`devDependencies\` or
1852
+ \`optionalDependencies\`, but you want to move it to be a non-optional
1853
+ production dependency.
1854
+
1855
+ This is the default behavior if \`--save\` is true, and neither
1856
+ \`--save-dev\` or \`--save-optional\` are true.
1857
+ `,
1858
+ flatten (key, obj, flatOptions) {
1859
+ if (!obj[key]) {
1860
+ if (flatOptions.saveType === 'prod') {
1861
+ delete flatOptions.saveType
1862
+ }
1863
+ return
1864
+ }
1865
+
1866
+ flatOptions.saveType = 'prod'
1867
+ },
1868
+ })
1869
+
1870
+ define('scope', {
1871
+ default: '',
1872
+ defaultDescription: `
1873
+ the scope of the current project, if any, or ""
1874
+ `,
1875
+ type: String,
1876
+ hint: '<@scope>',
1877
+ description: `
1878
+ Associate an operation with a scope for a scoped registry.
1879
+
1880
+ Useful when logging in to or out of a private registry:
1881
+
1882
+ \`\`\`
1883
+ # log in, linking the scope to the custom registry
1884
+ npm login --scope=@mycorp --registry=https://registry.mycorp.com
1885
+
1886
+ # log out, removing the link and the auth token
1887
+ npm logout --scope=@mycorp
1888
+ \`\`\`
1889
+
1890
+ This will cause \`@mycorp\` to be mapped to the registry for future
1891
+ installation of packages specified according to the pattern
1892
+ \`@mycorp/package\`.
1893
+
1894
+ This will also cause \`npm init\` to create a scoped package.
1895
+
1896
+ \`\`\`
1897
+ # accept all defaults, and create a package named "@foo/whatever",
1898
+ # instead of just named "whatever"
1899
+ npm init --scope=@foo --yes
1900
+ \`\`\`
1901
+ `,
1902
+ flatten (key, obj, flatOptions) {
1903
+ const value = obj[key]
1904
+ const scope = value && !/^@/.test(value) ? `@${value}` : value
1905
+ flatOptions.scope = scope
1906
+ // projectScope is kept for compatibility with npm-registry-fetch
1907
+ flatOptions.projectScope = scope
1908
+ },
1909
+ })
1910
+
1911
+ define('script-shell', {
1912
+ default: null,
1913
+ defaultDescription: `
1914
+ '/bin/sh' on POSIX systems, 'cmd.exe' on Windows
1915
+ `,
1916
+ type: [null, String],
1917
+ description: `
1918
+ The shell to use for scripts run with the \`npm exec\`,
1919
+ \`npm run\` and \`npm init <package-spec>\` commands.
1920
+ `,
1921
+ flatten (key, obj, flatOptions) {
1922
+ flatOptions.scriptShell = obj[key] || undefined
1923
+ },
1924
+ })
1925
+
1926
+ define('searchexclude', {
1927
+ default: '',
1928
+ type: String,
1929
+ description: `
1930
+ Space-separated options that limit the results from search.
1931
+ `,
1932
+ flatten (key, obj, flatOptions) {
1933
+ flatOptions.search = flatOptions.search || { limit: 20 }
1934
+ flatOptions.search.exclude = obj[key].toLowerCase()
1935
+ },
1936
+ })
1937
+
1938
+ define('searchlimit', {
1939
+ default: 20,
1940
+ type: Number,
1941
+ description: `
1942
+ Number of items to limit search results to. Will not apply at all to
1943
+ legacy searches.
1944
+ `,
1945
+ flatten (key, obj, flatOptions) {
1946
+ flatOptions.search = flatOptions.search || {}
1947
+ flatOptions.search.limit = obj[key]
1948
+ },
1949
+ })
1950
+
1951
+ define('searchopts', {
1952
+ default: '',
1953
+ type: String,
1954
+ description: `
1955
+ Space-separated options that are always passed to search.
1956
+ `,
1957
+ flatten (key, obj, flatOptions) {
1958
+ flatOptions.search = flatOptions.search || { limit: 20 }
1959
+ flatOptions.search.opts = querystring.parse(obj[key])
1960
+ },
1961
+ })
1962
+
1963
+ define('searchstaleness', {
1964
+ default: 15 * 60,
1965
+ type: Number,
1966
+ description: `
1967
+ The age of the cache, in seconds, before another registry request is made
1968
+ if using legacy search endpoint.
1969
+ `,
1970
+ flatten (key, obj, flatOptions) {
1971
+ flatOptions.search = flatOptions.search || { limit: 20 }
1972
+ flatOptions.search.staleness = obj[key]
1973
+ },
1974
+ })
1975
+
1976
+ define('shell', {
1977
+ default: shell,
1978
+ defaultDescription: `
1979
+ SHELL environment variable, or "bash" on Posix, or "cmd.exe" on Windows
1980
+ `,
1981
+ type: String,
1982
+ description: `
1983
+ The shell to run for the \`npm explore\` command.
1984
+ `,
1985
+ flatten,
1986
+ })
1987
+
1988
+ define('shrinkwrap', {
1989
+ default: true,
1990
+ type: Boolean,
1991
+ deprecated: `
1992
+ Use the --package-lock setting instead.
1993
+ `,
1994
+ description: `
1995
+ Alias for --package-lock
1996
+ `,
1997
+ flatten (key, obj, flatOptions) {
1998
+ obj['package-lock'] = obj.shrinkwrap
1999
+ definitions['package-lock'].flatten('package-lock', obj, flatOptions)
2000
+ },
2001
+ })
2002
+
2003
+ define('sign-git-commit', {
2004
+ default: false,
2005
+ type: Boolean,
2006
+ description: `
2007
+ If set to true, then the \`npm version\` command will commit the new
2008
+ package version using \`-S\` to add a signature.
2009
+
2010
+ Note that git requires you to have set up GPG keys in your git configs
2011
+ for this to work properly.
2012
+ `,
2013
+ flatten,
2014
+ })
2015
+
2016
+ define('sign-git-tag', {
2017
+ default: false,
2018
+ type: Boolean,
2019
+ description: `
2020
+ If set to true, then the \`npm version\` command will tag the version
2021
+ using \`-s\` to add a signature.
2022
+
2023
+ Note that git requires you to have set up GPG keys in your git configs
2024
+ for this to work properly.
2025
+ `,
2026
+ flatten,
2027
+ })
2028
+
2029
+ define('strict-peer-deps', {
2030
+ default: false,
2031
+ type: Boolean,
2032
+ description: `
2033
+ If set to \`true\`, and \`--legacy-peer-deps\` is not set, then _any_
2034
+ conflicting \`peerDependencies\` will be treated as an install failure,
2035
+ even if npm could reasonably guess the appropriate resolution based on
2036
+ non-peer dependency relationships.
2037
+
2038
+ By default, conflicting \`peerDependencies\` deep in the dependency graph
2039
+ will be resolved using the nearest non-peer dependency specification,
2040
+ even if doing so will result in some packages receiving a peer dependency
2041
+ outside the range set in their package's \`peerDependencies\` object.
2042
+
2043
+ When such an override is performed, a warning is printed, explaining the
2044
+ conflict and the packages involved. If \`--strict-peer-deps\` is set,
2045
+ then this warning is treated as a failure.
2046
+ `,
2047
+ flatten,
2048
+ })
2049
+
2050
+ define('strict-ssl', {
2051
+ default: true,
2052
+ type: Boolean,
2053
+ description: `
2054
+ Whether or not to do SSL key validation when making requests to the
2055
+ registry via https.
2056
+
2057
+ See also the \`ca\` config.
2058
+ `,
2059
+ flatten (key, obj, flatOptions) {
2060
+ flatOptions.strictSSL = obj[key]
2061
+ },
2062
+ })
2063
+
2064
+ define('tag', {
2065
+ default: 'latest',
2066
+ type: String,
2067
+ description: `
2068
+ If you ask npm to install a package and don't tell it a specific version,
2069
+ then it will install the specified tag.
2070
+
2071
+ Also the tag that is added to the package@version specified by the \`npm
2072
+ tag\` command, if no explicit tag is given.
2073
+
2074
+ When used by the \`npm diff\` command, this is the tag used to fetch the
2075
+ tarball that will be compared with the local files by default.
2076
+ `,
2077
+ flatten (key, obj, flatOptions) {
2078
+ flatOptions.defaultTag = obj[key]
2079
+ },
2080
+ })
2081
+
2082
+ define('tag-version-prefix', {
2083
+ default: 'v',
2084
+ type: String,
2085
+ description: `
2086
+ If set, alters the prefix used when tagging a new version when performing
2087
+ a version increment using \`npm version\`. To remove the prefix
2088
+ altogether, set it to the empty string: \`""\`.
2089
+
2090
+ Because other tools may rely on the convention that npm version tags look
2091
+ like \`v1.0.0\`, _only use this property if it is absolutely necessary_.
2092
+ In particular, use care when overriding this setting for public packages.
2093
+ `,
2094
+ flatten,
2095
+ })
2096
+
2097
+ define('timing', {
2098
+ default: false,
2099
+ type: Boolean,
2100
+ description: `
2101
+ If true, writes timing information to a process specific json file in
2102
+ the cache or \`logs-dir\`. The file name ends with \`-timing.json\`.
2103
+
2104
+ You can quickly view it with this [json](https://npm.im/json) command
2105
+ line: \`cat ~/.npm/_logs/*-timing.json | npm exec -- json -g\`.
2106
+
2107
+ Timing information will also be reported in the terminal. To suppress this
2108
+ while still writing the timing file, use \`--silent\`.
2109
+ `,
2110
+ })
2111
+
2112
+ define('umask', {
2113
+ default: 0,
2114
+ type: Umask,
2115
+ description: `
2116
+ The "umask" value to use when setting the file creation mode on files and
2117
+ folders.
2118
+
2119
+ Folders and executables are given a mode which is \`0o777\` masked
2120
+ against this value. Other files are given a mode which is \`0o666\`
2121
+ masked against this value.
2122
+
2123
+ Note that the underlying system will _also_ apply its own umask value to
2124
+ files and folders that are created, and npm does not circumvent this, but
2125
+ rather adds the \`--umask\` config to it.
2126
+
2127
+ Thus, the effective default umask value on most POSIX systems is 0o22,
2128
+ meaning that folders and executables are created with a mode of 0o755 and
2129
+ other files are created with a mode of 0o644.
2130
+ `,
2131
+ flatten,
2132
+ })
2133
+
2134
+ define('unicode', {
2135
+ default: unicode,
2136
+ defaultDescription: `
2137
+ false on windows, true on mac/unix systems with a unicode locale, as
2138
+ defined by the \`LC_ALL\`, \`LC_CTYPE\`, or \`LANG\` environment variables.
2139
+ `,
2140
+ type: Boolean,
2141
+ description: `
2142
+ When set to true, npm uses unicode characters in the tree output. When
2143
+ false, it uses ascii characters instead of unicode glyphs.
2144
+ `,
2145
+ flatten,
2146
+ })
2147
+
2148
+ define('update-notifier', {
2149
+ default: true,
2150
+ type: Boolean,
2151
+ description: `
2152
+ Set to false to suppress the update notification when using an older
2153
+ version of npm than the latest.
2154
+ `,
2155
+ })
2156
+
2157
+ define('usage', {
2158
+ default: false,
2159
+ type: Boolean,
2160
+ short: ['?', 'H', 'h'],
2161
+ description: `
2162
+ Show short usage output about the command specified.
2163
+ `,
2164
+ })
2165
+
2166
+ define('user-agent', {
2167
+ default: 'npm/{npm-version} ' +
2168
+ 'node/{node-version} ' +
2169
+ '{platform} ' +
2170
+ '{arch} ' +
2171
+ 'workspaces/{workspaces} ' +
2172
+ '{ci}',
2173
+ type: String,
2174
+ description: `
2175
+ Sets the User-Agent request header. The following fields are replaced
2176
+ with their actual counterparts:
2177
+
2178
+ * \`{npm-version}\` - The npm version in use
2179
+ * \`{node-version}\` - The Node.js version in use
2180
+ * \`{platform}\` - The value of \`process.platform\`
2181
+ * \`{arch}\` - The value of \`process.arch\`
2182
+ * \`{workspaces}\` - Set to \`true\` if the \`workspaces\` or \`workspace\`
2183
+ options are set.
2184
+ * \`{ci}\` - The value of the \`ci-name\` config, if set, prefixed with
2185
+ \`ci/\`, or an empty string if \`ci-name\` is empty.
2186
+ `,
2187
+ flatten (key, obj, flatOptions) {
2188
+ const value = obj[key]
2189
+ const ciName = ciInfo.name?.toLowerCase().split(' ').join('-') || null
2190
+ let inWorkspaces = false
2191
+ if (obj.workspaces || obj.workspace && obj.workspace.length) {
2192
+ inWorkspaces = true
2193
+ }
2194
+ flatOptions.userAgent =
2195
+ value.replace(/\{node-version\}/gi, process.version)
2196
+ .replace(/\{npm-version\}/gi, obj['npm-version'])
2197
+ .replace(/\{platform\}/gi, process.platform)
2198
+ .replace(/\{arch\}/gi, process.arch)
2199
+ .replace(/\{workspaces\}/gi, inWorkspaces)
2200
+ .replace(/\{ci\}/gi, ciName ? `ci/${ciName}` : '')
2201
+ .trim()
2202
+
2203
+ // We can't clobber the original or else subsequent flattening will fail
2204
+ // (i.e. when we change the underlying config values)
2205
+ // obj[key] = flatOptions.userAgent
2206
+
2207
+ // user-agent is a unique kind of config item that gets set from a template
2208
+ // and ends up translated. Because of this, the normal "should we set this
2209
+ // to process.env also doesn't work
2210
+ process.env.npm_config_user_agent = flatOptions.userAgent
2211
+ },
2212
+ })
2213
+
2214
+ define('userconfig', {
2215
+ default: '~/.npmrc',
2216
+ type: path,
2217
+ description: `
2218
+ The location of user-level configuration settings.
2219
+
2220
+ This may be overridden by the \`npm_config_userconfig\` environment
2221
+ variable or the \`--userconfig\` command line option, but may _not_
2222
+ be overridden by settings in the \`globalconfig\` file.
2223
+ `,
2224
+ })
2225
+
2226
+ define('version', {
2227
+ default: false,
2228
+ type: Boolean,
2229
+ short: 'v',
2230
+ description: `
2231
+ If true, output the npm version and exit successfully.
2232
+
2233
+ Only relevant when specified explicitly on the command line.
2234
+ `,
2235
+ })
2236
+
2237
+ define('versions', {
2238
+ default: false,
2239
+ type: Boolean,
2240
+ description: `
2241
+ If true, output the npm version as well as node's \`process.versions\`
2242
+ map and the version in the current working directory's \`package.json\`
2243
+ file if one exists, and exit successfully.
2244
+
2245
+ Only relevant when specified explicitly on the command line.
2246
+ `,
2247
+ })
2248
+
2249
+ define('viewer', {
2250
+ default: isWindows ? 'browser' : 'man',
2251
+ defaultDescription: `
2252
+ "man" on Posix, "browser" on Windows
2253
+ `,
2254
+ type: String,
2255
+ description: `
2256
+ The program to use to view help content.
2257
+
2258
+ Set to \`"browser"\` to view html help content in the default web browser.
2259
+ `,
2260
+ })
2261
+
2262
+ define('which', {
2263
+ default: null,
2264
+ hint: '<fundingSourceNumber>',
2265
+ type: [null, Number],
2266
+ description: `
2267
+ If there are multiple funding sources, which 1-indexed source URL to open.
2268
+ `,
2269
+ })
2270
+
2271
+ define('workspace', {
2272
+ default: [],
2273
+ type: [String, Array],
2274
+ hint: '<workspace-name>',
2275
+ short: 'w',
2276
+ envExport: false,
2277
+ description: `
2278
+ Enable running a command in the context of the configured workspaces of the
2279
+ current project while filtering by running only the workspaces defined by
2280
+ this configuration option.
2281
+
2282
+ Valid values for the \`workspace\` config are either:
2283
+
2284
+ * Workspace names
2285
+ * Path to a workspace directory
2286
+ * Path to a parent workspace directory (will result in selecting all
2287
+ workspaces within that folder)
2288
+
2289
+ When set for the \`npm init\` command, this may be set to the folder of
2290
+ a workspace which does not yet exist, to create the folder and set it
2291
+ up as a brand new workspace within the project.
2292
+ `,
2293
+ flatten: (key, obj, flatOptions) => {
2294
+ definitions['user-agent'].flatten('user-agent', obj, flatOptions)
2295
+ },
2296
+ })
2297
+
2298
+ define('workspaces', {
2299
+ default: null,
2300
+ type: [null, Boolean],
2301
+ short: 'ws',
2302
+ envExport: false,
2303
+ description: `
2304
+ Set to true to run the command in the context of **all** configured
2305
+ workspaces.
2306
+
2307
+ Explicitly setting this to false will cause commands like \`install\` to
2308
+ ignore workspaces altogether.
2309
+ When not set explicitly:
2310
+
2311
+ - Commands that operate on the \`node_modules\` tree (install, update,
2312
+ etc.) will link workspaces into the \`node_modules\` folder.
2313
+ - Commands that do other things (test, exec, publish, etc.) will operate
2314
+ on the root project, _unless_ one or more workspaces are specified in
2315
+ the \`workspace\` config.
2316
+ `,
2317
+ flatten: (key, obj, flatOptions) => {
2318
+ definitions['user-agent'].flatten('user-agent', obj, flatOptions)
2319
+
2320
+ // TODO: this is a derived value, and should be reworked when we have a
2321
+ // pattern for derived value
2322
+
2323
+ // workspacesEnabled is true whether workspaces is null or true
2324
+ // commands contextually work with workspaces or not regardless of
2325
+ // configuration, so we need an option specifically to disable workspaces
2326
+ flatOptions.workspacesEnabled = obj[key] !== false
2327
+ },
2328
+ })
2329
+
2330
+ define('workspaces-update', {
2331
+ default: true,
2332
+ type: Boolean,
2333
+ description: `
2334
+ If set to true, the npm cli will run an update after operations that may
2335
+ possibly change the workspaces installed to the \`node_modules\` folder.
2336
+ `,
2337
+ flatten,
2338
+ })
2339
+
2340
+ define('yes', {
2341
+ default: null,
2342
+ type: [null, Boolean],
2343
+ short: 'y',
2344
+ description: `
2345
+ Automatically answer "yes" to any prompts that npm might print on
2346
+ the command line.
2347
+ `,
2348
+ })