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