npm-check-updates 16.8.2 → 16.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -101
- package/build/package.json +9 -9
- package/build/src/bin/cli.js +27 -7
- package/build/src/bin/cli.js.map +1 -1
- package/build/src/cli-options.d.ts +10 -2
- package/build/src/cli-options.js +158 -131
- package/build/src/cli-options.js.map +1 -1
- package/build/src/index.js +2 -1
- package/build/src/index.js.map +1 -1
- package/build/src/lib/mergeOptions.d.ts +1 -0
- package/build/src/lib/table.d.ts +7 -0
- package/build/src/lib/table.js +27 -0
- package/build/src/lib/table.js.map +1 -0
- package/build/src/lib/upgradePackageDefinitions.js +19 -1
- package/build/src/lib/upgradePackageDefinitions.js.map +1 -1
- package/build/src/lib/wrap.d.ts +3 -0
- package/build/src/lib/wrap.js +45 -0
- package/build/src/lib/wrap.js.map +1 -0
- package/build/src/scripts/build-options.js +3 -2
- package/build/src/scripts/build-options.js.map +1 -1
- package/build/src/types/FilterResultsFunction.d.ts +9 -0
- package/build/src/types/FilterResultsFunction.js +3 -0
- package/build/src/types/FilterResultsFunction.js.map +1 -0
- package/build/src/types/RunOptions.d.ts +31 -7
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -174,6 +174,9 @@ ncu "/^(?!react-).*$/" # windows
|
|
|
174
174
|
-f, --filter <p> Include only package names matching the given
|
|
175
175
|
string, wildcard, glob, comma-or-space-delimited
|
|
176
176
|
list, /regex/, or predicate function.
|
|
177
|
+
filterResults* Filters out upgrades based on a user provided
|
|
178
|
+
function. Run "ncu --help --filterResults" for
|
|
179
|
+
details.
|
|
177
180
|
--filterVersion <p> Filter on package version using
|
|
178
181
|
comma-or-space-delimited list, /regex/, or
|
|
179
182
|
predicate function.
|
|
@@ -184,7 +187,7 @@ ncu "/^(?!react-).*$/" # windows
|
|
|
184
187
|
[])
|
|
185
188
|
-g, --global Check global packages instead of in the current
|
|
186
189
|
project.
|
|
187
|
-
|
|
190
|
+
groupFunction* Customize how packages are divided into groups
|
|
188
191
|
when using '--format group'. Run "ncu --help
|
|
189
192
|
--groupFunction" for details.
|
|
190
193
|
-i, --interactive Enable interactive prompts for each dependency;
|
|
@@ -251,8 +254,8 @@ ncu "/^(?!react-).*$/" # windows
|
|
|
251
254
|
[])
|
|
252
255
|
-ws, --workspaces Run on all workspaces. Add --root to also upgrade
|
|
253
256
|
the root project.
|
|
254
|
-
-V, --version
|
|
255
|
-
-h, --help
|
|
257
|
+
-v, -V, --version Output the version number.
|
|
258
|
+
-h, --help You're lookin' at it.
|
|
256
259
|
```
|
|
257
260
|
|
|
258
261
|
<!-- END Options -->
|
|
@@ -275,12 +278,12 @@ Usage:
|
|
|
275
278
|
|
|
276
279
|
Iteratively installs upgrades and runs tests to identify breaking upgrades. Reverts broken upgrades and updates package.json with working upgrades.
|
|
277
280
|
|
|
278
|
-
Add
|
|
281
|
+
Add `-u` to execute (modifies your package file, lock file, and node_modules)
|
|
279
282
|
|
|
280
283
|
To be more precise:
|
|
281
284
|
|
|
282
|
-
1. Runs
|
|
283
|
-
2. Runs
|
|
285
|
+
1. Runs `npm install` and `npm test` to ensure tests are currently passing.
|
|
286
|
+
2. Runs `ncu -u` to optimistically upgrade all dependencies.
|
|
284
287
|
3. If tests pass, hurray!
|
|
285
288
|
4. If tests fail, restores package file and lock file.
|
|
286
289
|
5. For each dependency, install upgrade and run tests.
|
|
@@ -289,8 +292,10 @@ To be more precise:
|
|
|
289
292
|
|
|
290
293
|
Additional options:
|
|
291
294
|
|
|
292
|
-
|
|
293
|
-
|
|
295
|
+
<table>
|
|
296
|
+
<tr><td>--doctorInstall</td><td>specify a custom install script (default: `npm install` or `yarn`)</td></tr>
|
|
297
|
+
<tr><td>--doctorTest</td><td>specify a custom test script (default: `npm test`)</td></tr>
|
|
298
|
+
</table>
|
|
294
299
|
|
|
295
300
|
Example:
|
|
296
301
|
|
|
@@ -321,6 +326,33 @@ Example:
|
|
|
321
326
|
✓ react-dnd 10.0.0 → 11.1.3
|
|
322
327
|
Saving partially upgraded package.json
|
|
323
328
|
|
|
329
|
+
## filterResults
|
|
330
|
+
|
|
331
|
+
Filters out upgrades based on a user provided function.
|
|
332
|
+
|
|
333
|
+
Only available in .ncurc.js or when importing npm-check-updates as a module.
|
|
334
|
+
|
|
335
|
+
```js
|
|
336
|
+
/** Filter out non-major version updates.
|
|
337
|
+
@param {string} packageName The name of the dependency.
|
|
338
|
+
@param {string} currentVersion Current version declaration (may be range).
|
|
339
|
+
@param {SemVer[]} currentVersionSemver Current version declaration in semantic versioning format (may be range).
|
|
340
|
+
@param {string} upgradedVersion Upgraded version.
|
|
341
|
+
@param {SemVer} upgradedVersionSemver Upgraded version in semantic versioning format.
|
|
342
|
+
@returns {boolean} Return true if the upgrade should be kept, otherwise it will be ignored.
|
|
343
|
+
*/
|
|
344
|
+
filterResults: (packageName, { currentVersion, currentVersionSemver, upgradedVersion, upgradedVersionSemver }) => {
|
|
345
|
+
const currentMajorVersion = currentVersionSemver?.[0]?.major
|
|
346
|
+
const upgradedMajorVersion = upgradedVersionSemver?.major
|
|
347
|
+
if (currentMajorVersion && upgradedMajorVersion) {
|
|
348
|
+
return currentMajorVersion < upgradedMajorVersion
|
|
349
|
+
}
|
|
350
|
+
return true
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
For the SemVer type definition, see: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring
|
|
355
|
+
|
|
324
356
|
## format
|
|
325
357
|
|
|
326
358
|
Usage:
|
|
@@ -329,44 +361,39 @@ Usage:
|
|
|
329
361
|
|
|
330
362
|
Modify the output formatting or show additional information. Specify one or more comma-delimited values.
|
|
331
363
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
├──────────────┼────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
340
|
-
│ time │ Shows the publish time of each upgrade. │
|
|
341
|
-
├──────────────┼────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
342
|
-
│ lines │ Prints name@version on separate lines. Useful for piping to npm install. │
|
|
343
|
-
└──────────────┴────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
364
|
+
<table>
|
|
365
|
+
<tr><td>group</td><td>Groups packages by major, minor, patch, and major version zero updates.</td></tr>
|
|
366
|
+
<tr><td>ownerChanged</td><td>Shows if the package owner has changed.</td></tr>
|
|
367
|
+
<tr><td>repo</td><td>Infers and displays links to the package's source code repository. Requires packages to be installed.</td></tr>
|
|
368
|
+
<tr><td>time</td><td>Shows the publish time of each upgrade.</td></tr>
|
|
369
|
+
<tr><td>lines</td><td>Prints name@version on separate lines. Useful for piping to npm install.</td></tr>
|
|
370
|
+
</table>
|
|
344
371
|
|
|
345
372
|
## groupFunction
|
|
346
373
|
|
|
347
|
-
|
|
374
|
+
Customize how packages are divided into groups when using `--format group`.
|
|
348
375
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
376
|
+
Only available in .ncurc.js or when importing npm-check-updates as a module.
|
|
377
|
+
|
|
378
|
+
```js
|
|
379
|
+
/**
|
|
380
|
+
@param name The name of the dependency.
|
|
381
|
+
@param defaultGroup The predefined group name which will be used by default.
|
|
382
|
+
@param currentSpec The current version range in your package.json.
|
|
383
|
+
@param upgradedSpec The upgraded version range that will be written to your package.json.
|
|
384
|
+
@param upgradedVersion The upgraded version number returned by the registry.
|
|
385
|
+
@returns A predefined group name ('major' | 'minor' | 'patch' | 'majorVersionZero' | 'none') or a custom string to create your own group.
|
|
386
|
+
*/
|
|
387
|
+
groupFunction: (name, defaultGroup, currentSpec, upgradedSpec, upgradedVersion) => {
|
|
388
|
+
if (name === 'typescript' && defaultGroup === 'minor') {
|
|
389
|
+
return 'major'
|
|
390
|
+
}
|
|
391
|
+
if (name.startsWith('@myorg/')) {
|
|
392
|
+
return 'My Org'
|
|
393
|
+
}
|
|
394
|
+
return defaultGroup
|
|
395
|
+
}
|
|
396
|
+
```
|
|
370
397
|
|
|
371
398
|
## packageManager
|
|
372
399
|
|
|
@@ -377,27 +404,25 @@ Usage:
|
|
|
377
404
|
|
|
378
405
|
Specifies the package manager to use when looking up version numbers.
|
|
379
406
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
│ │ } │
|
|
400
|
-
└────────────────┴───────────────────────────────────────────────────────────────────────────────────────────┘
|
|
407
|
+
<table>
|
|
408
|
+
<tr><td>npm</td><td>System-installed npm. Default.</td></tr>
|
|
409
|
+
<tr><td>yarn</td><td>System-installed yarn. Automatically used if yarn.lock is present.</td></tr>
|
|
410
|
+
<tr><td>pnpm</td><td>System-installed pnpm. Automatically used if pnpm-lock.yaml is present.</td></tr>
|
|
411
|
+
<tr><td>staticRegistry</td><td>Checks versions from a static file. Must include the `--registry` option with the path to a JSON registry file.
|
|
412
|
+
|
|
413
|
+
Example:
|
|
414
|
+
|
|
415
|
+
$ ncu --packageManager staticRegistry --registry ./my-registry.json
|
|
416
|
+
|
|
417
|
+
my-registry.json:
|
|
418
|
+
|
|
419
|
+
{
|
|
420
|
+
"prettier": "2.7.1",
|
|
421
|
+
"typescript": "4.7.4"
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
</td></tr>
|
|
425
|
+
</table>
|
|
401
426
|
|
|
402
427
|
## peer
|
|
403
428
|
|
|
@@ -409,12 +434,12 @@ Check peer dependencies of installed packages and filter updates to compatible v
|
|
|
409
434
|
|
|
410
435
|
Example:
|
|
411
436
|
|
|
412
|
-
The following example demonstrates how
|
|
437
|
+
The following example demonstrates how `--peer` works, and how it uses peer dependencies from upgraded modules.
|
|
413
438
|
|
|
414
439
|
The package ncu-test-peer-update has two versions published:
|
|
415
440
|
|
|
416
|
-
- 1.0.0 has peer dependency "ncu-test-return-version": "1.0.x"
|
|
417
|
-
- 1.1.0 has peer dependency "ncu-test-return-version": "1.1.x"
|
|
441
|
+
- 1.0.0 has peer dependency `"ncu-test-return-version": "1.0.x"`
|
|
442
|
+
- 1.1.0 has peer dependency `"ncu-test-return-version": "1.1.x"`
|
|
418
443
|
|
|
419
444
|
Our test app has the following dependencies:
|
|
420
445
|
|
|
@@ -426,16 +451,16 @@ The latest versions of these packages are:
|
|
|
426
451
|
"ncu-test-peer-update": "1.1.0",
|
|
427
452
|
"ncu-test-return-version": "2.0.0"
|
|
428
453
|
|
|
429
|
-
With
|
|
454
|
+
With `--peer`:
|
|
430
455
|
|
|
431
456
|
ncu upgrades packages to the highest version that still adheres to the peer dependency constraints:
|
|
432
457
|
|
|
433
458
|
ncu-test-peer-update 1.0.0 → 1.1.0
|
|
434
459
|
ncu-test-return-version 1.0.0 → 1.1.0
|
|
435
460
|
|
|
436
|
-
Without
|
|
461
|
+
Without `--peer`:
|
|
437
462
|
|
|
438
|
-
As a comparison: without using the
|
|
463
|
+
As a comparison: without using the `--peer` option, ncu will suggest the latest versions, ignoring peer dependencies:
|
|
439
464
|
|
|
440
465
|
ncu-test-peer-update 1.0.0 → 1.1.0
|
|
441
466
|
ncu-test-return-version 1.0.0 → 2.0.0
|
|
@@ -449,7 +474,7 @@ Usage:
|
|
|
449
474
|
|
|
450
475
|
Specify the registry to use when looking up package version numbers.
|
|
451
476
|
|
|
452
|
-
When
|
|
477
|
+
When `--packageManager staticRegistry` is set, `--registry` must specify a path to a JSON
|
|
453
478
|
registry file.
|
|
454
479
|
|
|
455
480
|
## target
|
|
@@ -461,33 +486,29 @@ Usage:
|
|
|
461
486
|
|
|
462
487
|
Determines the version to upgrade to. (default: "latest")
|
|
463
488
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
│ │ numbers that are higher. Includes prereleases. │
|
|
473
|
-
├──────────┼──────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
474
|
-
│ patch │ Upgrade to the highest patch version without bumping the minor or major versions. │
|
|
475
|
-
├──────────┼──────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
476
|
-
│ @[tag] │ Upgrade to the version published to a specific tag, e.g. 'next' or 'beta'. │
|
|
477
|
-
└──────────┴──────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
489
|
+
<table>
|
|
490
|
+
<tr><td>greatest</td><td>Upgrade to the highest version number published, regardless of release date or tag. Includes prereleases.</td></tr>
|
|
491
|
+
<tr><td>latest</td><td>Upgrade to whatever the package's "latest" git tag points to. Excludes pre is specified.</td></tr>
|
|
492
|
+
<tr><td>minor</td><td>Upgrade to the highest minor version without bumping the major version.</td></tr>
|
|
493
|
+
<tr><td>newest</td><td>Upgrade to the version with the most recent publish date, even if there are other version numbers that are higher. Includes prereleases.</td></tr>
|
|
494
|
+
<tr><td>patch</td><td>Upgrade to the highest patch version without bumping the minor or major versions.</td></tr>
|
|
495
|
+
<tr><td>@[tag]</td><td>Upgrade to the version published to a specific tag, e.g. 'next' or 'beta'.</td></tr>
|
|
496
|
+
</table>
|
|
478
497
|
|
|
479
498
|
You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module:
|
|
480
499
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
500
|
+
```js
|
|
501
|
+
/** Upgrade major version zero to the next minor version, and everything else to latest.
|
|
502
|
+
@param dependencyName The name of the dependency.
|
|
503
|
+
@param parsedVersion A parsed Semver object from semver-utils.
|
|
504
|
+
(See https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
|
|
505
|
+
@returns One of the valid target values (specified in the table above).
|
|
506
|
+
*/
|
|
507
|
+
target: (dependencyName, [{ semver, version, operator, major, minor, patch, release, build }]) => {
|
|
508
|
+
if (major === '0') return 'minor'
|
|
509
|
+
return 'latest'
|
|
510
|
+
}
|
|
511
|
+
```
|
|
491
512
|
|
|
492
513
|
<!-- END Advanced Options -->
|
|
493
514
|
|
|
@@ -508,8 +529,8 @@ Combine with `--format group` for a truly _luxe_ experience:
|
|
|
508
529
|
|
|
509
530
|
## Config File
|
|
510
531
|
|
|
511
|
-
Use a `.ncurc.{json,yml,js}` file to specify configuration information.
|
|
512
|
-
You can specify file name and path using `--configFileName` and `--configFilePath`
|
|
532
|
+
Use a `.ncurc.{json,yml,js,cjs}` file to specify configuration information.
|
|
533
|
+
You can specify the file name and path using `--configFileName` and `--configFilePath`
|
|
513
534
|
command line options.
|
|
514
535
|
|
|
515
536
|
For example, `.ncurc.json`:
|
|
@@ -545,11 +566,6 @@ console.log(upgraded) // { "mypackage": "^2.0.0", ... }
|
|
|
545
566
|
|
|
546
567
|
Contributions are happily accepted. I respond to all PR's and can offer guidance on where to make changes. For contributing tips see [CONTRIBUTING.md](https://github.com/raineorshine/npm-check-updates/blob/main/.github/CONTRIBUTING.md).
|
|
547
568
|
|
|
548
|
-
## Known Issues
|
|
549
|
-
|
|
550
|
-
- If `ncu` prints output that does not seem related to this package, it may be conflicting with another executable such as `ncu-weather-cli` or Nvidia CUDA. Try using the long name instead: `npm-check-updates`.
|
|
551
|
-
- Windows: If npm-check-updates hangs, try setting the package file explicitly: `ncu --packageFile package.json`. You can run `ncu --loglevel verbose` to confirm that it was incorrectly waiting for stdin. See [#136](https://github.com/raineorshine/npm-check-updates/issues/136#issuecomment-155721102).
|
|
552
|
-
|
|
553
569
|
## Problems?
|
|
554
570
|
|
|
555
571
|
[File an issue](https://github.com/raineorshine/npm-check-updates/issues). Please [search existing issues](https://github.com/raineorshine/npm-check-updates/issues?utf8=%E2%9C%93&q=is%3Aissue) first.
|
package/build/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-check-updates",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.10.0",
|
|
4
4
|
"author": "Tomas Junnonen <tomas1@gmail.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -93,10 +93,10 @@
|
|
|
93
93
|
"@types/ini": "^1.3.31",
|
|
94
94
|
"@types/json-parse-helpfulerror": "^1.0.1",
|
|
95
95
|
"@types/jsonlines": "^0.1.2",
|
|
96
|
-
"@types/lodash": "^4.14.
|
|
96
|
+
"@types/lodash": "^4.14.192",
|
|
97
97
|
"@types/minimatch": "^5.1.2",
|
|
98
98
|
"@types/mocha": "^10.0.1",
|
|
99
|
-
"@types/node": "^18.15.
|
|
99
|
+
"@types/node": "^18.15.11",
|
|
100
100
|
"@types/pacote": "^11.1.5",
|
|
101
101
|
"@types/parse-github-url": "^1.0.0",
|
|
102
102
|
"@types/progress": "^2.0.5",
|
|
@@ -107,30 +107,30 @@
|
|
|
107
107
|
"@types/semver-utils": "^1.1.1",
|
|
108
108
|
"@types/sinon": "^10.0.13",
|
|
109
109
|
"@types/update-notifier": "^6.0.2",
|
|
110
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
111
|
-
"@typescript-eslint/parser": "^5.
|
|
110
|
+
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
111
|
+
"@typescript-eslint/parser": "^5.57.0",
|
|
112
112
|
"c8": "^7.13.0",
|
|
113
113
|
"chai": "^4.3.7",
|
|
114
114
|
"chai-as-promised": "^7.1.1",
|
|
115
115
|
"chai-string": "^1.5.0",
|
|
116
116
|
"cross-env": "^7.0.3",
|
|
117
|
-
"eslint": "^8.
|
|
117
|
+
"eslint": "^8.37.0",
|
|
118
118
|
"eslint-config-prettier": "^8.8.0",
|
|
119
119
|
"eslint-config-raine": "^0.3.0",
|
|
120
120
|
"eslint-config-standard": "^17.0.0",
|
|
121
121
|
"eslint-plugin-fp": "^2.3.0",
|
|
122
122
|
"eslint-plugin-import": "^2.27.5",
|
|
123
123
|
"eslint-plugin-jsdoc": "^40.1.0",
|
|
124
|
-
"eslint-plugin-n": "^15.
|
|
124
|
+
"eslint-plugin-n": "^15.7.0",
|
|
125
125
|
"eslint-plugin-promise": "^6.1.1",
|
|
126
126
|
"husky": "^8.0.3",
|
|
127
127
|
"lockfile-lint": "^4.10.1",
|
|
128
128
|
"markdownlint-cli": "^0.33.0",
|
|
129
129
|
"mocha": "^10.2.0",
|
|
130
130
|
"npm-run-all": "^4.1.5",
|
|
131
|
-
"prettier": "2.8.
|
|
131
|
+
"prettier": "2.8.7",
|
|
132
132
|
"should": "^13.2.3",
|
|
133
|
-
"sinon": "^15.0.
|
|
133
|
+
"sinon": "^15.0.3",
|
|
134
134
|
"strip-ansi": "^7.0.1",
|
|
135
135
|
"ts-node": "^10.9.1",
|
|
136
136
|
"typescript": "^5.0.2",
|
package/build/src/bin/cli.js
CHANGED
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
const commander_1 = require("commander");
|
|
30
|
+
const commander_1 = __importStar(require("commander"));
|
|
31
31
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
32
32
|
const pickBy_1 = __importDefault(require("lodash/pickBy"));
|
|
33
33
|
const semver_1 = __importDefault(require("semver"));
|
|
@@ -102,16 +102,36 @@ ${chalk.dim.underline(notifier.update.type === 'major' ? releaseUrls.map(url =>
|
|
|
102
102
|
}
|
|
103
103
|
process.exit(0);
|
|
104
104
|
}
|
|
105
|
+
// a set of options that only work in an rc config file, not on the command line
|
|
106
|
+
const noCli = new Set(cli_options_1.default.filter(option => option.cli === false).map(option => `--${option.long}`));
|
|
105
107
|
// start commander program
|
|
106
108
|
commander_1.program
|
|
107
109
|
.description('[filter] is a list or regex of package names to check (all others will be ignored).')
|
|
108
|
-
.usage('[options] [filter]')
|
|
110
|
+
.usage('[options] [filter]')
|
|
111
|
+
.addOption(new commander_1.default.Option('-v, --version', 'Version!').hideHelp())
|
|
112
|
+
// See: boolean optional arg below
|
|
113
|
+
.configureHelp({
|
|
114
|
+
optionTerm: option => option.long && noCli.has(option.long)
|
|
115
|
+
? option.long.replace('--', '') + '*'
|
|
116
|
+
: option.long === '--version'
|
|
117
|
+
? '-v, -V, --version'
|
|
118
|
+
: option.flags.replace('[bool]', ''),
|
|
119
|
+
optionDescription: option => option.long === '--version'
|
|
120
|
+
? 'Output the version number.'
|
|
121
|
+
: option.long === '--help'
|
|
122
|
+
? `You're lookin' at it.`
|
|
123
|
+
: commander_1.Help.prototype.optionDescription(option),
|
|
124
|
+
});
|
|
109
125
|
// add cli options
|
|
110
|
-
cli_options_1.default.forEach(({ long, short, arg, description, default: defaultValue, help, parse }) =>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
126
|
+
cli_options_1.default.forEach(({ long, short, arg, description, default: defaultValue, help, parse, type }) => {
|
|
127
|
+
// handle 3rd/4th argument polymorphism
|
|
128
|
+
commander_1.program.option(
|
|
129
|
+
// optional [bool] arg allows boolean options to be set to false, while still allowing unary functionality
|
|
130
|
+
// [bool] is stripped from the help text in configureHelp
|
|
131
|
+
`${short ? `-${short}, ` : ''}--${long}${arg ? ` <${arg}>` : type === 'boolean' ? ' [bool]' : ''}`,
|
|
132
|
+
// point to help in description if extended help text is available
|
|
133
|
+
`${description}${help ? ` Run "ncu --help --${long}" for details.` : ''}`, parse || (type === 'boolean' ? s => s !== 'false' : defaultValue), parse ? defaultValue : undefined);
|
|
134
|
+
});
|
|
115
135
|
// set version option at the end
|
|
116
136
|
commander_1.program.version(package_json_1.default.version);
|
|
117
137
|
// commander mutates its optionValues with program.parse
|
package/build/src/bin/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/bin/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/bin/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uDAAoD;AACpD,iEAAwC;AACxC,2DAAkC;AAClC,oDAA2B;AAC3B,sEAAoC;AACpC,8DAA+D;AAC/D,qDAA0B;AAC1B,wCAAwC;AACxC,+DAEC;AAAA,CAAC,KAAK,IAAI,EAAE;;IACX,yHAAyH;IACzH,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAA;IAEnE,8EAA8E;IAC9E,EAAE;IACF,2CAA2C;IAC3C,EAAE;IACF,mBAAmB;IACnB,WAAW;IACX,iCAAiC;IACjC,qBAAqB;IACrB,OAAO;IACP,2BAA2B;IAC3B,KAAK;IAEL,MAAM,QAAQ,GAAG,cAAc,CAAC,EAAE,GAAG,EAAH,sBAAG,EAAE,CAAC,CAAA;IACxC,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,sBAAG,CAAC,OAAO,EAAE;QAC7D,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAA;QAEhD,6FAA6F;QAC7F,MAAM,YAAY,GAAG,MAAA,gBAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,0CAAE,KAAK,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EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,WAAW,CAAC,CAGjF;IAAC,mBAAe,CAAC,aAAa,GAAG,mBAAmB,CAAA;IACrD,mBAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAChC,MAAM,mBAAmB,GAAG,mBAAO,CAAC,IAAI,EAAE,CAAA;IAE1C,wFAAwF;IACxF,MAAM,OAAO,GAAG;QACd,GAAG,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACrG,GAAG,IAAA,gBAAM,EAAC,mBAAO,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC;QACvD,IAAI,EAAE,mBAAO,CAAC,IAAI;QAClB,GAAG,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/E,GAAG,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;KAChF,CAAA;IAED,oEAAoE;IAEpE,IAAA,eAAG,EAAC,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA;AAC7B,CAAC,CAAC,EAAE,CAAA"}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { Index } from './types/IndexType';
|
|
2
|
+
/** A function that renders extended help for an option. */
|
|
3
|
+
type ExtendedHelp = string | ((options: {
|
|
4
|
+
markdown?: boolean;
|
|
5
|
+
}) => string);
|
|
2
6
|
export interface CLIOption<T = any> {
|
|
3
7
|
arg?: string;
|
|
4
8
|
choices?: T[];
|
|
9
|
+
/** If false, the option is only usable in the ncurc file, or when using npm-check-updates as a module, not on the command line. */
|
|
10
|
+
cli?: boolean;
|
|
5
11
|
default?: T;
|
|
6
12
|
deprecated?: boolean;
|
|
7
13
|
description: string;
|
|
8
|
-
help?:
|
|
14
|
+
help?: ExtendedHelp;
|
|
9
15
|
parse?: (s: string, p?: T) => T;
|
|
10
16
|
long: string;
|
|
11
17
|
short?: string;
|
|
12
18
|
type: string;
|
|
13
19
|
}
|
|
14
20
|
/** Renders the extended help for an option with usage information. */
|
|
15
|
-
export declare const renderExtendedHelp: (option: CLIOption
|
|
21
|
+
export declare const renderExtendedHelp: (option: CLIOption, { markdown }?: {
|
|
22
|
+
markdown?: boolean | undefined;
|
|
23
|
+
}) => string;
|
|
16
24
|
export declare const cliOptionsMap: Index<CLIOption<any>>;
|
|
17
25
|
declare const cliOptionsSorted: CLIOption<any>[];
|
|
18
26
|
export default cliOptionsSorted;
|