@baicie/ncu 0.1.14

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 ADDED
@@ -0,0 +1,981 @@
1
+ # npm-check-updates
2
+
3
+ [![npm version](https://img.shields.io/npm/v/npm-check-updates)](https://www.npmjs.com/package/npm-check-updates)
4
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/raineorshine/npm-check-updates/test.yml?branch=main&label=tests&logo=github)](https://github.com/raineorshine/npm-check-updates/actions?query=workflow%3ATests+branch%3Amain)
5
+
6
+ **npm-check-updates upgrades your package.json dependencies to the _latest_ versions, ignoring specified versions.**
7
+
8
+ - maintains existing semantic versioning _policies_, i.e. `"react": "^17.0.2"` to `"react": "^18.3.1"`.
9
+ - _only_ modifies package.json file. Run `npm install` to update your installed packages and package-lock.json.
10
+ - sensible defaults, but highly customizable
11
+ - compatible with npm, yarn, pnpm, deno, and bun
12
+ - CLI and module usage
13
+
14
+ <img width="500" alt="example output" src="https://github.com/user-attachments/assets/4808618b-ac20-4fc0-92e0-a777de70a2b6">
15
+
16
+ $${\color{red}Red}$$ major upgrade (and all [major version zero](https://semver.org/#spec-item-4))<br/>
17
+ $${\color{cyan}Cyan}$$ minor upgrade<br/>
18
+ $${\color{green}Green}$$ patch upgrade<br/>
19
+
20
+ ## Installation
21
+
22
+ Install globally to use `npm-check-updates` or the shorter `ncu`:
23
+
24
+ ```sh
25
+ npm install -g npm-check-updates
26
+ ```
27
+
28
+ Or run with [npx](https://docs.npmjs.com/cli/v7/commands/npx) (only the long form is supported):
29
+
30
+ ```sh
31
+ npx npm-check-updates
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Check the latest versions of all project dependencies:
37
+
38
+ ```sh
39
+ $ ncu
40
+ Checking package.json
41
+ [====================] 5/5 100%
42
+
43
+ eslint 7.32.0 → 8.0.0
44
+ prettier ^2.7.1 → ^3.0.0
45
+ svelte ^3.48.0 → ^3.51.0
46
+ typescript >3.0.0 → >4.0.0
47
+ untildify <4.0.0 → ^4.0.0
48
+ webpack 4.x → 5.x
49
+
50
+ Run ncu -u to upgrade package.json
51
+ ```
52
+
53
+ Upgrade a project's package file:
54
+
55
+ > **Make sure your package file is in version control and all changes have been committed. This _will_ overwrite your package file.**
56
+
57
+ ```sh
58
+ $ ncu -u
59
+ Upgrading package.json
60
+ [====================] 1/1 100%
61
+
62
+ express 4.12.x → 4.13.x
63
+
64
+ Run npm install to install new versions.
65
+
66
+ $ npm install # update installed packages and package-lock.json
67
+ ```
68
+
69
+ Check global packages:
70
+
71
+ ```sh
72
+ ncu -g
73
+ ```
74
+
75
+ ## Interactive Mode
76
+
77
+ Choose which packages to update in interactive mode:
78
+
79
+ ```sh
80
+ ncu --interactive
81
+ ncu -i
82
+ ```
83
+
84
+ ![ncu --interactive](https://user-images.githubusercontent.com/750276/175337598-cdbb2c46-64f8-44f5-b54e-4ad74d7b52b4.png)
85
+
86
+ Combine with `--format group` for a truly _luxe_ experience:
87
+
88
+ ![ncu --interactive --format group](https://user-images.githubusercontent.com/750276/175336533-539261e4-5cf1-458f-9fbb-a7be2b477ebb.png)
89
+
90
+ ### Keys
91
+
92
+ - <kbd>↑</kbd><kbd>↓</kbd> Select a package
93
+ - <kbd>Space</kbd> Toggle selection
94
+ - <kbd>a</kbd> Toggle all
95
+ - <kbd>Enter</kbd> Upgrade
96
+
97
+ ## Filter packages
98
+
99
+ Filter packages using the `--filter` option or adding additional cli arguments:
100
+
101
+ ```sh
102
+ # upgrade only mocha
103
+ ncu mocha
104
+ ncu -f mocha
105
+ ncu --filter mocha
106
+
107
+ # upgrade only chalk, mocha, and react
108
+ ncu chalk mocha react
109
+ ncu chalk, mocha, react
110
+ ncu -f "chalk mocha react"
111
+ ```
112
+
113
+ Filter with wildcards or regex:
114
+
115
+ ```sh
116
+ # upgrade packages that start with "react-"
117
+ ncu react-*
118
+ ncu "/^react-.*$/"
119
+ ```
120
+
121
+ Exclude specific packages with the `--reject` option or prefixing a filter with `!`. Supports strings, wildcards, globs, comma-or-space-delimited lists, and regex:
122
+
123
+ ```sh
124
+ # upgrade everything except nodemon
125
+ ncu \!nodemon
126
+ ncu -x nodemon
127
+ ncu --reject nodemon
128
+
129
+ # upgrade packages that do not start with "react-".
130
+ ncu \!react-*
131
+ ncu '/^(?!react-).*$/' # mac/linux
132
+ ncu "/^(?!react-).*$/" # windows
133
+ ```
134
+
135
+ Advanced filters: [filter](https://github.com/raineorshine/npm-check-updates#filter), [filterResults](https://github.com/raineorshine/npm-check-updates#filterresults), [filterVersion](https://github.com/raineorshine/npm-check-updates#filterversion)
136
+
137
+ ## How dependency updates are determined
138
+
139
+ - Direct dependencies are updated to the latest stable version:
140
+ - `2.0.1` → `2.2.0`
141
+ - `1.2` → `1.3`
142
+ - `0.1.0` → `1.0.1`
143
+ - Range operators are preserved and the version is updated:
144
+ - `^1.2.0` → `^2.0.0`
145
+ - `1.x` → `2.x`
146
+ - `>0.2.0` → `>0.3.0`
147
+ - "Less than" is replaced with a wildcard:
148
+ - `<2.0.0` → `^3.0.0`
149
+ - `1.0.0 < 2.0.0` → `^3.0.0`
150
+ - "Any version" is preserved:
151
+ - `*` → `*`
152
+ - Prerelease versions are ignored by default.
153
+ - Use `--pre` to include prerelease versions (e.g. `alpha`, `beta`, `build1235`)
154
+ - Choose what level to upgrade to:
155
+ - With `--target semver`, update according to your specified [semver](https://semver.org/) version ranges:
156
+ - `^1.1.0` → `^1.9.99`
157
+ - With `--target minor`, strictly update the patch and minor versions (including major version zero):
158
+ - `0.1.0` → `0.2.1`
159
+ - With `--target patch`, strictly update the patch version (including major version zero):
160
+ - `0.1.0` → `0.1.2`
161
+ - With `--target @next`, update to the version published on the `next` tag:
162
+ - `0.1.0` -> `0.1.1-next.1`
163
+
164
+ ## Options
165
+
166
+ Options are merged with the following precedence:
167
+
168
+ 1. Command line options
169
+ 2. Local [Config File](#config-file) (current working directory)
170
+ 3. Project Config File (next to package.json)
171
+ 4. User Config File (`$HOME`)
172
+
173
+ Options that take no arguments can be negated by prefixing them with `--no-`, e.g. `--no-peer`.
174
+
175
+ <!-- BEGIN Options -->
176
+ <!-- Do not edit this section by hand. It is auto-generated in build-options.ts. Run "npm run build" or "npm run build:options" to build. -->
177
+
178
+ <table>
179
+ <tr>
180
+ <td>--cache</td>
181
+ <td>Cache versions to a local cache file. Default <code>--cacheFile</code> is ~/.ncu-cache.json and default <code>--cacheExpiration</code> is 10 minutes.</td>
182
+ </tr>
183
+ <tr>
184
+ <td>--cacheClear</td>
185
+ <td>Clear the default cache, or the cache file specified by <code>--cacheFile</code>.</td>
186
+ </tr>
187
+ <tr>
188
+ <td>--cacheExpiration &lt;min&gt;</td>
189
+ <td>Cache expiration in minutes. Only works with <code>--cache</code>. (default: 10)</td>
190
+ </tr>
191
+ <tr>
192
+ <td>--cacheFile &lt;path&gt;</td>
193
+ <td>Filepath for the cache file. Only works with <code>--cache</code>. (default: "~/.ncu-cache.json")</td>
194
+ </tr>
195
+ <tr>
196
+ <td>--color</td>
197
+ <td>Force color in terminal.</td>
198
+ </tr>
199
+ <tr>
200
+ <td>--concurrency &lt;n&gt;</td>
201
+ <td>Max number of concurrent HTTP requests to registry. (default: 8)</td>
202
+ </tr>
203
+ <tr>
204
+ <td>--configFileName &lt;s&gt;</td>
205
+ <td>Config file name. (default: .ncurc.{json,yml,js,cjs})</td>
206
+ </tr>
207
+ <tr>
208
+ <td>--configFilePath &lt;path&gt;</td>
209
+ <td>Directory of .ncurc config file. (default: directory of <code>packageFile</code>)</td>
210
+ </tr>
211
+ <tr>
212
+ <td><a href="#cooldown">-c, --cooldown &lt;n&gt;</a></td>
213
+ <td>Sets a minimum age (in days) for package versions to be considered for upgrade, reducing the risk of installing newly published, potentially compromised packages.</td>
214
+ </tr>
215
+ <tr>
216
+ <td>--cwd &lt;path&gt;</td>
217
+ <td>Working directory in which npm will be executed.</td>
218
+ </tr>
219
+ <tr>
220
+ <td>--deep</td>
221
+ <td>Run recursively in current working directory. Alias of (<code>--packageFile '**/package.json'<code>).</td>
222
+ </tr>
223
+ <tr>
224
+ <td>--dep &lt;value&gt;</td>
225
+ <td>Check one or more sections of dependencies only: dev, optional, peer, prod, or packageManager (comma-delimited). (default: ["prod","dev","optional","packageManager"])</td>
226
+ </tr>
227
+ <tr>
228
+ <td>--deprecated</td>
229
+ <td>Include deprecated packages. Use <code>--no-deprecated</code> to exclude deprecated packages (20–25% slower). (default: true)</td>
230
+ </tr>
231
+ <tr>
232
+ <td><a href="#doctor">-d, --doctor</a></td>
233
+ <td>Iteratively installs upgrades and runs tests to identify breaking upgrades. Requires <code>-u</code> to execute.</td>
234
+ </tr>
235
+ <tr>
236
+ <td>--doctorInstall &lt;command&gt;</td>
237
+ <td>Specifies the install script to use in doctor mode. (default: <code>npm install</code> or the equivalent for your package manager)</td>
238
+ </tr>
239
+ <tr>
240
+ <td>--doctorTest &lt;command&gt;</td>
241
+ <td>Specifies the test script to use in doctor mode. (default: <code>npm test</code>)</td>
242
+ </tr>
243
+ <tr>
244
+ <td>--enginesNode</td>
245
+ <td>Include only packages that satisfy engines.node as specified in the package file.</td>
246
+ </tr>
247
+ <tr>
248
+ <td>-e, --errorLevel &lt;n&gt;</td>
249
+ <td>Set the error level. 1: exits with error code 0 if no errors occur. 2: exits with error code 0 if no packages need updating (useful for continuous integration). (default: 1)</td>
250
+ </tr>
251
+ <tr>
252
+ <td><a href="#filter">-f, --filter &lt;p&gt;</a></td>
253
+ <td>Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.</td>
254
+ </tr>
255
+ <tr>
256
+ <td><a href="#filterresults">filterResults &lt;fn&gt;</a></td>
257
+ <td>Filters results based on a user provided predicate function after fetching new versions.</td>
258
+ </tr>
259
+ <tr>
260
+ <td><a href="#filterversion">--filterVersion &lt;p&gt;</a></td>
261
+ <td>Filter on package version using comma-or-space-delimited list, /regex/, or predicate function.</td>
262
+ </tr>
263
+ <tr>
264
+ <td><a href="#format">--format &lt;value&gt;</a></td>
265
+ <td>Modify the output formatting or show additional information. Specify one or more comma-delimited values: dep, group, ownerChanged, repo, time, lines, installedVersion. (default: [])</td>
266
+ </tr>
267
+ <tr>
268
+ <td>-g, --global</td>
269
+ <td>Check global packages instead of in the current project.</td>
270
+ </tr>
271
+ <tr>
272
+ <td><a href="#groupfunction">groupFunction &lt;fn&gt;</a></td>
273
+ <td>Customize how packages are divided into groups when using <code>--format group</code>.</td>
274
+ </tr>
275
+ <tr>
276
+ <td>--ignoreDirs &lt;dirs&gt;</td>
277
+ <td>Ignore directories containing package.json files (comma-delimited).</td>
278
+ </tr>
279
+ <tr>
280
+ <td><a href="#install">--install &lt;value&gt;</a></td>
281
+ <td>Control the auto-install behavior: always, never, prompt. (default: "prompt")</td>
282
+ </tr>
283
+ <tr>
284
+ <td>-i, --interactive</td>
285
+ <td>Enable interactive prompts for each dependency; implies <code>-u</code> unless one of the json options are set.</td>
286
+ </tr>
287
+ <tr>
288
+ <td>-j, --jsonAll</td>
289
+ <td>Output new package file instead of human-readable message.</td>
290
+ </tr>
291
+ <tr>
292
+ <td>--jsonDeps</td>
293
+ <td>Like <code>jsonAll</code> but only lists <code>dependencies</code>, <code>devDependencies</code>, <code>optionalDependencies</code>, etc of the new package data.</td>
294
+ </tr>
295
+ <tr>
296
+ <td>--jsonUpgraded</td>
297
+ <td>Output upgraded dependencies in json.</td>
298
+ </tr>
299
+ <tr>
300
+ <td>-l, --loglevel &lt;n&gt;</td>
301
+ <td>Amount to log: silent, error, minimal, warn, info, verbose, silly. (default: "warn")</td>
302
+ </tr>
303
+ <tr>
304
+ <td>--mergeConfig</td>
305
+ <td>Merges nested configs with the root config file for <code>--deep</code> or <code>--packageFile</code> options. (default: false)</td>
306
+ </tr>
307
+ <tr>
308
+ <td>-m, --minimal</td>
309
+ <td>Do not upgrade newer versions that are already satisfied by the version range according to semver.</td>
310
+ </tr>
311
+ <tr>
312
+ <td>--packageData &lt;value&gt;</td>
313
+ <td>Package file data (you can also use stdin).</td>
314
+ </tr>
315
+ <tr>
316
+ <td>--packageFile &lt;path|glob&gt;</td>
317
+ <td>Package file(s) location. (default: ./package.json)</td>
318
+ </tr>
319
+ <tr>
320
+ <td><a href="#packagemanager">-p, --packageManager &lt;s&gt;</a></td>
321
+ <td>npm, yarn, pnpm, deno, bun, staticRegistry (default: npm).</td>
322
+ </tr>
323
+ <tr>
324
+ <td><a href="#peer">--peer</a></td>
325
+ <td>Check peer dependencies of installed packages and filter updates to compatible versions.</td>
326
+ </tr>
327
+ <tr>
328
+ <td>--pre &lt;n&gt;</td>
329
+ <td>Include prerelease versions, e.g. -alpha.0, -beta.5, -rc.2. Automatically set to 1 when <code>--target</code> is newest or greatest, or when the current version is a prerelease. (default: 0)</td>
330
+ </tr>
331
+ <tr>
332
+ <td>--prefix &lt;path&gt;</td>
333
+ <td>Current working directory of npm.</td>
334
+ </tr>
335
+ <tr>
336
+ <td>-r, --registry &lt;uri&gt;</td>
337
+ <td>Specify the registry to use when looking up package versions.</td>
338
+ </tr>
339
+ <tr>
340
+ <td><a href="#registrytype">--registryType &lt;type&gt;</a></td>
341
+ <td>Specify whether --registry refers to a full npm registry or a simple JSON file or url: npm, json. (default: npm)</td>
342
+ </tr>
343
+ <tr>
344
+ <td><a href="#reject">-x, --reject &lt;p&gt;</a></td>
345
+ <td>Exclude packages matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.</td>
346
+ </tr>
347
+ <tr>
348
+ <td><a href="#rejectversion">--rejectVersion &lt;p&gt;</a></td>
349
+ <td>Exclude package.json versions using comma-or-space-delimited list, /regex/, or predicate function.</td>
350
+ </tr>
351
+ <tr>
352
+ <td>--removeRange</td>
353
+ <td>Remove version ranges from the final package version.</td>
354
+ </tr>
355
+ <tr>
356
+ <td>--retry &lt;n&gt;</td>
357
+ <td>Number of times to retry failed requests for package info. (default: 3)</td>
358
+ </tr>
359
+ <tr>
360
+ <td>--root</td>
361
+ <td>Runs updates on the root project in addition to specified workspaces. Only allowed with <code>--workspace</code> or <code>--workspaces</code>. (default: true)</td>
362
+ </tr>
363
+ <tr>
364
+ <td>-s, --silent</td>
365
+ <td>Don't output anything. Alias for <code>--loglevel</code> silent.</td>
366
+ </tr>
367
+ <tr>
368
+ <td>--stdin</td>
369
+ <td>Read package.json from stdin.</td>
370
+ </tr>
371
+ <tr>
372
+ <td><a href="#target">-t, --target &lt;value&gt;</a></td>
373
+ <td>Determines the version to upgrade to: latest, newest, greatest, minor, patch, semver, <code>@[tag]<code>, or [function]. (default: latest)</td>
374
+ </tr>
375
+ <tr>
376
+ <td>--timeout &lt;ms&gt;</td>
377
+ <td>Global timeout in milliseconds. (default: no global timeout and 30 seconds per npm-registry-fetch)</td>
378
+ </tr>
379
+ <tr>
380
+ <td>-u, --upgrade</td>
381
+ <td>Overwrite package file with upgraded versions instead of just outputting to console.</td>
382
+ </tr>
383
+ <tr>
384
+ <td>--verbose</td>
385
+ <td>Log additional information for debugging. Alias for <code>--loglevel</code> verbose.</td>
386
+ </tr>
387
+ <tr>
388
+ <td>--workspace &lt;s&gt;</td>
389
+ <td>Run on one or more specified workspaces. Add <code>--no-root</code> to exclude the root project. (default: [])</td>
390
+ </tr>
391
+ <tr>
392
+ <td>-w, --workspaces</td>
393
+ <td>Run on all workspaces. Add <code>--no-root</code> to exclude the root project.</td>
394
+ </tr>
395
+ </table>
396
+
397
+ <!-- END Options -->
398
+
399
+ ## Advanced Options
400
+
401
+ Some options have advanced usage, or allow per-package values by specifying a function in your .ncurc.js file.
402
+
403
+ Run `ncu --help [OPTION]` to view advanced help for a specific option, or see below:
404
+
405
+ <!-- BEGIN Advanced Options -->
406
+ <!-- Do not edit this section by hand. It is auto-generated in build-options.ts. Run "npm run build" or "npm run build:options" to build. -->
407
+
408
+ ## cooldown
409
+
410
+ Usage:
411
+
412
+ ncu --cooldown [n]
413
+ ncu -c [n]
414
+
415
+ The cooldown option helps protect against supply chain attacks by requiring package versions to be published at least the given number of days before considering them for upgrade.
416
+
417
+ Note that previous stable versions will not be suggested. The package will be completely ignored if its latest published version is within the cooldown period. This is due to a limitation of the npm registry, which does not provide a way to query previous stable versions.
418
+
419
+ Example:
420
+
421
+ Let's examine how cooldown works with a package that has these versions available:
422
+
423
+ 1.0.0 Released 7 days ago (initial version)
424
+ 1.1.0 Released 6 days ago (minor update)
425
+ 1.1.1 Released 5 days ago (patch update)
426
+ 1.2.0 Released 5 days ago (minor update)
427
+ 2.0.0-beta.1 Released 5 days ago (beta release)
428
+ 1.2.1 Released 4 days ago (patch update)
429
+ 1.3.0 Released 4 days ago (minor update) [latest]
430
+ 2.0.0-beta.2 Released 3 days ago (beta release)
431
+ 2.0.0-beta.3 Released 2 days ago (beta release) [beta]
432
+
433
+ With default target (latest):
434
+
435
+ ```js
436
+ $ ncu --cooldown 5
437
+ ```
438
+
439
+ No update will be suggested because:
440
+
441
+ - Latest version (1.3.0) is only 4 days old.
442
+ - Cooldown requires versions to be at least 5 days old
443
+ - Use `--cooldown 4` or lower to allow this update
444
+
445
+ With `@beta`/`@tag` target:
446
+
447
+ ```js
448
+ $ ncu --cooldown 3 --target @beta
449
+ ```
450
+
451
+ No update will be suggested because:
452
+
453
+ - Current beta (2.0.0-beta.3) is only 2 days old
454
+ - Cooldown requires versions to be at least 3 days old
455
+ - Use `--cooldown 2` or lower to allow this update
456
+
457
+ With other targets:
458
+
459
+ ```js
460
+ $ ncu --cooldown 5 --target greatest|newest|minor|patch|semver
461
+ ```
462
+
463
+ Each target will select the best version that is at least 5 days old:
464
+
465
+ greatest → 1.2.0 (highest version number outside cooldown)
466
+ newest → 2.0.0-beta.1 (most recently published version outside cooldown)
467
+ minor → 1.2.0 (highest minor version outside cooldown)
468
+ patch → 1.1.1 (highest patch version outside cooldown)
469
+
470
+ Note for latest/tag targets:
471
+
472
+ > :warning: For packages that update frequently (e.g. daily releases), using a long cooldown period (7+ days) with the default `--target latest` or `--target @tag` may prevent all updates since new versions will be published before older ones meet the cooldown requirement. Please consider this when setting your cooldown period.
473
+
474
+ You can also provide a custom function in your .ncurc.js file or when importing npm-check-updates as a module.
475
+
476
+ > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.
477
+
478
+ ```js
479
+ /** Set cooldown to 3 days but skip it for `@my-company` packages.
480
+ @param packageName The name of the dependency.
481
+ @returns Cooldown days restriction for given package.
482
+ */
483
+ cooldown: packageName => (packageName.startsWith('@my-company') ? 0 : 3)
484
+ ```
485
+
486
+ ## doctor
487
+
488
+ Usage:
489
+
490
+ ncu --doctor -u
491
+ ncu --no-doctor
492
+ ncu -du
493
+
494
+ Iteratively installs upgrades and runs your project's tests to identify breaking upgrades. Reverts broken upgrades and updates package.json with working upgrades.
495
+
496
+ Requires `-u` to execute (modifies your package file, lock file, and node_modules)
497
+
498
+ To be more precise:
499
+
500
+ 1. Runs `npm install` and `npm test` to ensure tests are currently passing.
501
+ 2. Runs `ncu -u` to optimistically upgrade all dependencies.
502
+ 3. If tests pass, hurray!
503
+ 4. If tests fail, restores package file and lock file.
504
+ 5. For each dependency, install upgrade and run tests.
505
+ 6. Prints broken upgrades with test error.
506
+ 7. Saves working upgrades to package.json.
507
+
508
+ Additional options:
509
+
510
+ <table>
511
+ <tr><td>--doctorInstall</td><td>specify a custom install script (default: `npm install` or `yarn`)</td></tr>
512
+ <tr><td>--doctorTest</td><td>specify a custom test script (default: `npm test`)</td></tr>
513
+ </table>
514
+
515
+ Example:
516
+
517
+ $ ncu --doctor -u
518
+ Running tests before upgrading
519
+ npm install
520
+ npm run test
521
+ Upgrading all dependencies and re-running tests
522
+ ncu -u
523
+ npm install
524
+ npm run test
525
+ Tests failed
526
+ Identifying broken dependencies
527
+ npm install
528
+ npm install --no-save react@16.0.0
529
+ npm run test
530
+ ✓ react 15.0.0 → 16.0.0
531
+ npm install --no-save react-redux@7.0.0
532
+ npm run test
533
+ ✗ react-redux 6.0.0 → 7.0.0
534
+
535
+ /projects/myproject/test.js:13
536
+ throw new Error('Test failed!')
537
+ ^
538
+
539
+ npm install --no-save react-dnd@11.1.3
540
+ npm run test
541
+ ✓ react-dnd 10.0.0 → 11.1.3
542
+ Saving partially upgraded package.json
543
+
544
+ ## filter
545
+
546
+ Usage:
547
+
548
+ ncu --filter [p]
549
+ ncu -f [p]
550
+
551
+ Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. Only included packages will be checked with `--peer`.
552
+
553
+ `--filter` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_.
554
+
555
+ You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module.
556
+
557
+ > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.
558
+
559
+ ```js
560
+ /**
561
+ @param name The name of the dependency.
562
+ @param semver A parsed Semver array of the current version.
563
+ (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
564
+ @returns True if the package should be included, false if it should be excluded.
565
+ */
566
+ filter: (name, semver) => {
567
+ if (name.startsWith('@myorg/')) {
568
+ return false
569
+ }
570
+ return true
571
+ }
572
+ ```
573
+
574
+ ## filterResults
575
+
576
+ Filters results based on a user provided predicate function after fetching new versions.
577
+
578
+ `filterResults` runs _after_ new versions are fetched, in contrast to `filter`, `reject`, `filterVersion`, and `rejectVersion`, which run _before_. This allows you to exclude upgrades with `filterResults` based on how the version has changed (e.g. a major version change).
579
+
580
+ > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.
581
+
582
+ ```js
583
+ /** Exclude major version updates. Note this could also be achieved with --target semver.
584
+ @param {string} packageName The name of the dependency.
585
+ @param {string} current Current version declaration (may be a range).
586
+ @param {SemVer[]} currentVersionSemver Current version declaration in semantic versioning format (may be a range).
587
+ @param {string} upgraded Upgraded version.
588
+ @param {SemVer} upgradedVersionSemver Upgraded version in semantic versioning format.
589
+ @returns {boolean} Return true if the upgrade should be kept; otherwise, it will be ignored.
590
+ */
591
+ filterResults: (packageName, { current, currentVersionSemver, upgraded, upgradedVersionSemver }) => {
592
+ const currentMajor = parseInt(currentVersionSemver[0]?.major, 10)
593
+ const upgradedMajor = parseInt(upgradedVersionSemver?.major, 10)
594
+ if (currentMajor && upgradedMajor) {
595
+ return currentMajor >= upgradedMajor
596
+ }
597
+ return true
598
+ }
599
+ ```
600
+
601
+ For the SemVer type definition, see: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring
602
+
603
+ ## filterVersion
604
+
605
+ Usage:
606
+
607
+ ncu --filterVersion [p]
608
+
609
+ Include only versions matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
610
+
611
+ `--filterVersion` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_.
612
+
613
+ You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module.
614
+
615
+ > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. This function is an alias for the `filter` option function.
616
+
617
+ ```js
618
+ /**
619
+ @param name The name of the dependency.
620
+ @param semver A parsed Semver array of the current version.
621
+ (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
622
+ @returns True if the package should be included, false if it should be excluded.
623
+ */
624
+ filterVersion: (name, semver) => {
625
+ if (name.startsWith('@myorg/') && parseInt(semver[0]?.major) > 5) {
626
+ return false
627
+ }
628
+ return true
629
+ }
630
+ ```
631
+
632
+ ## format
633
+
634
+ Usage:
635
+
636
+ ncu --format [value]
637
+
638
+ Modify the output formatting or show additional information. Specify one or more comma-delimited values.
639
+
640
+ <table>
641
+ <tr><td>dep</td><td>Prints the dependency type (dev, peer, optional) of each package.</td></tr>
642
+ <tr><td>group</td><td>Groups packages by major, minor, patch, and major version zero updates.</td></tr>
643
+ <tr><td>installedVersion</td><td>Prints the exact current version number instead of a range.</td></tr>
644
+ <tr><td>lines</td><td>Prints name@version on separate lines. Useful for piping to npm install.</td></tr>
645
+ <tr><td>ownerChanged</td><td>Shows if the package owner has changed.</td></tr>
646
+ <tr><td>repo</td><td>Infers and displays links to the package's source code repository. Requires packages to be installed.</td></tr>
647
+ <tr><td>time</td><td>Shows the publish time of each upgrade.</td></tr>
648
+ </table>
649
+
650
+ ## groupFunction
651
+
652
+ Customize how packages are divided into groups when using `--format group`.
653
+
654
+ Only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.
655
+
656
+ ```js
657
+ /**
658
+ @param name The name of the dependency.
659
+ @param defaultGroup The predefined group name which will be used by default.
660
+ @param currentSpec The current version range in your package.json.
661
+ @param upgradedSpec The upgraded version range that will be written to your package.json.
662
+ @param upgradedVersion The upgraded version number returned by the registry.
663
+ @returns A predefined group name ('major' | 'minor' | 'patch' | 'majorVersionZero' | 'none') or a custom string to create your own group.
664
+ */
665
+ groupFunction: (name, defaultGroup, currentSpec, upgradedSpec, upgradedVersion) => {
666
+ if (name === 'typescript' && defaultGroup === 'minor') {
667
+ return 'major'
668
+ }
669
+ if (name.startsWith('@myorg/')) {
670
+ return 'My Org'
671
+ }
672
+ return defaultGroup
673
+ }
674
+ ```
675
+
676
+ ## install
677
+
678
+ Usage:
679
+
680
+ ncu --install [value]
681
+
682
+ Default: prompt
683
+
684
+ Control the auto-install behavior.
685
+
686
+ <table>
687
+ <tr><td>always</td><td>Runs your package manager's install command automatically after upgrading.</td></tr>
688
+ <tr><td>never</td><td>Does not install and does not prompt.</td></tr>
689
+ <tr><td>prompt</td><td>Shows a message after upgrading that recommends an install, but does not install. In interactive mode, prompts for install. (default)</td></tr>
690
+ </table>
691
+
692
+ ## packageManager
693
+
694
+ Usage:
695
+
696
+ ncu --packageManager [s]
697
+ ncu -p [s]
698
+
699
+ Specifies the package manager to use when looking up versions.
700
+
701
+ <table>
702
+ <tr><td>npm</td><td>System-installed npm. Default.</td></tr>
703
+ <tr><td>yarn</td><td>System-installed yarn. Automatically used if yarn.lock is present.</td></tr>
704
+ <tr><td>pnpm</td><td>System-installed pnpm. Automatically used if pnpm-lock.yaml is present.</td></tr>
705
+ <tr><td>bun</td><td>System-installed bun. Automatically used if bun.lock or bun.lockb is present.</td></tr>
706
+ </table>
707
+
708
+ ## peer
709
+
710
+ Usage:
711
+
712
+ ncu --peer
713
+ ncu --no-peer
714
+
715
+ Check peer dependencies of installed packages and filter updates to compatible versions.
716
+
717
+ Example:
718
+
719
+ The following example demonstrates how `--peer` works, and how it uses peer dependencies from upgraded modules.
720
+
721
+ The package ncu-test-peer-update has two versions published:
722
+
723
+ - 1.0.0 has peer dependency `"ncu-test-return-version": "1.0.x"`
724
+ - 1.1.0 has peer dependency `"ncu-test-return-version": "1.1.x"`
725
+
726
+ Our test app has the following dependencies:
727
+
728
+ "ncu-test-peer-update": "1.0.0",
729
+ "ncu-test-return-version": "1.0.0"
730
+
731
+ The latest versions of these packages are:
732
+
733
+ "ncu-test-peer-update": "1.1.0",
734
+ "ncu-test-return-version": "2.0.0"
735
+
736
+ With `--peer`:
737
+
738
+ ncu upgrades packages to the highest version that still adheres to the peer dependency constraints:
739
+
740
+ ncu-test-peer-update 1.0.0 → 1.1.0
741
+ ncu-test-return-version 1.0.0 → 1.1.0
742
+
743
+ Without `--peer`:
744
+
745
+ As a comparison: without using the `--peer` option, ncu will suggest the latest versions, ignoring peer dependencies:
746
+
747
+ ncu-test-peer-update 1.0.0 → 1.1.0
748
+ ncu-test-return-version 1.0.0 → 2.0.0
749
+
750
+ ## registryType
751
+
752
+ Usage:
753
+
754
+ ncu --registryType [type]
755
+
756
+ Specify whether `--registry` refers to a full npm registry or a simple JSON file.
757
+
758
+ <table>
759
+ <tr><td>npm</td><td>Default npm registry</td></tr>
760
+ <tr><td>json</td><td>Checks versions from a file or url to a simple JSON registry. Must include the `--registry` option.
761
+
762
+ Example:
763
+
764
+ // local file
765
+ $ ncu --registryType json --registry ./registry.json
766
+
767
+ // url
768
+ $ ncu --registryType json --registry https://api.mydomain/registry.json
769
+
770
+ // you can omit --registryType when the registry ends in .json
771
+ $ ncu --registry ./registry.json
772
+ $ ncu --registry https://api.mydomain/registry.json
773
+
774
+ registry.json:
775
+
776
+ {
777
+ "prettier": "2.7.1",
778
+ "typescript": "4.7.4"
779
+ }
780
+
781
+ </td></tr>
782
+ </table>
783
+
784
+ ## reject
785
+
786
+ Usage:
787
+
788
+ ncu --reject [p]
789
+ ncu -x [p]
790
+
791
+ The inverse of `--filter`. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. This will also exclude them from the `--peer` check.
792
+
793
+ `--reject` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_.
794
+
795
+ You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module.
796
+
797
+ > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.
798
+
799
+ ```js
800
+ /**
801
+ @param name The name of the dependency.
802
+ @param semver A parsed Semver array of the current version.
803
+ (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
804
+ @returns True if the package should be excluded, false if it should be included.
805
+ */
806
+ reject: (name, semver) => {
807
+ if (name.startsWith('@myorg/')) {
808
+ return true
809
+ }
810
+ return false
811
+ }
812
+ ```
813
+
814
+ ## rejectVersion
815
+
816
+ Usage:
817
+
818
+ ncu --rejectVersion [p]
819
+
820
+ The inverse of `--filterVersion`. Exclude versions matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
821
+
822
+ `--rejectVersion` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_.
823
+
824
+ You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module.
825
+
826
+ > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. This function is an alias for the reject option function.
827
+
828
+ ```js
829
+ /**
830
+ @param name The name of the dependency.
831
+ @param semver A parsed Semver array of the current version.
832
+ (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
833
+ @returns True if the package should be excluded, false if it should be included.
834
+ */
835
+ rejectVersion: (name, semver) => {
836
+ if (name.startsWith('@myorg/') && parseInt(semver[0]?.major) > 5) {
837
+ return true
838
+ }
839
+ return false
840
+ }
841
+ ```
842
+
843
+ ## target
844
+
845
+ Usage:
846
+
847
+ ncu --target [value]
848
+ ncu -t [value]
849
+
850
+ Determines the version to upgrade to. (default: "latest")
851
+
852
+ <table>
853
+ <tr><td>greatest</td><td>Upgrade to the highest version number published, regardless of release date or tag. Includes prereleases.</td></tr>
854
+ <tr><td>latest</td><td>Upgrade to whatever the package's "latest" git tag points to. Excludes prereleases unless --pre is specified.</td></tr>
855
+ <tr><td>minor</td><td>Upgrade to the highest minor version without bumping the major version.</td></tr>
856
+ <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>
857
+ <tr><td>patch</td><td>Upgrade to the highest patch version without bumping the minor or major versions.</td></tr>
858
+ <tr><td>semver</td><td>Upgrade to the highest version within the semver range specified in your package.json.</td></tr>
859
+ <tr><td>@[tag]</td><td>Upgrade to the version published to a specific tag, e.g. 'next' or 'beta'.</td></tr>
860
+ </table>
861
+
862
+ e.g.
863
+
864
+ ncu --target semver
865
+
866
+ You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module.
867
+
868
+ > :warning: The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.
869
+
870
+ ```js
871
+ /** Upgrade major version zero to the next minor version, and everything else to latest.
872
+ @param name The name of the dependency.
873
+ @param semver A parsed Semver object of the upgraded version.
874
+ (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
875
+ @returns One of the valid target values (specified in the table above).
876
+ */
877
+ target: (name, semver) => {
878
+ if (parseInt(semver[0]?.major) === '0') return 'minor'
879
+ return 'latest'
880
+ }
881
+ ```
882
+
883
+ <!-- END Advanced Options -->
884
+
885
+ ## Config File
886
+
887
+ Add a `.ncurc.{json,yml,js,cjs}` file to your project directory to specify configuration information.
888
+
889
+ For example, `.ncurc.json`:
890
+
891
+ ```json
892
+ {
893
+ "upgrade": true,
894
+ "filter": "svelte",
895
+ "reject": ["@types/estree", "ts-node"]
896
+ }
897
+ ```
898
+
899
+ Options are merged with the following precedence:
900
+
901
+ 1. Command line options
902
+ 2. Local Config File (current working directory)
903
+ 3. Project Config File (next to package.json)
904
+ 4. User Config File (`$HOME`)
905
+
906
+ You can also specify a custom config file name or path using the `--configFileName` or `--configFilePath` command line options.
907
+
908
+ ### Config Functions
909
+
910
+ Some options offer more advanced configuration using a function definition. These include [filter](https://github.com/raineorshine/npm-check-updates#filter), [filterVersion](https://github.com/raineorshine/npm-check-updates#filterversion), [filterResults](https://github.com/raineorshine/npm-check-updates#filterresults), [reject](https://github.com/raineorshine/npm-check-updates#reject), [rejectVersion](https://github.com/raineorshine/npm-check-updates#rejectversion), and [groupFunction](https://github.com/raineorshine/npm-check-updates#groupfunction). To define an options function, convert the config file to a JS file by adding the `.js` extension and setting module.exports:
911
+
912
+ For example, `.ncurc.js`:
913
+
914
+ ```js
915
+ /** @type {import('npm-check-updates').RcOptions } */
916
+ module.exports = {
917
+ upgrade: true,
918
+ filter: name => name.startsWith('@myorg/'),
919
+ }
920
+ ```
921
+
922
+ Alternatively, you can use the defineConfig helper which should provide intellisense without the need for jsdoc annotations:
923
+
924
+ ```js
925
+ const { defineConfig } = require('npm-check-updates')
926
+
927
+ module.exports = defineConfig({
928
+ upgrade: true,
929
+ filter: name => name.startsWith('@myorg/'),
930
+ })
931
+ ```
932
+
933
+ ### JSON Schema
934
+
935
+ If you write `.ncurc` config files using json or yaml, you can add the JSON Schema to your IDE settings for completions.
936
+
937
+ e.g. for VS Code:
938
+
939
+ ```json
940
+ "json.schemas": [
941
+ {
942
+ "fileMatch": [
943
+ ".ncurc",
944
+ ".ncurc.json",
945
+ ],
946
+ "url": "https://raw.githubusercontent.com/raineorshine/npm-check-updates/main/src/types/RunOptions.json"
947
+ }
948
+ ],
949
+ "yaml.schemas": {
950
+ "https://raw.githubusercontent.com/raineorshine/npm-check-updates/main/src/types/RunOptions.json": [
951
+ ".ncurc.yml",
952
+ ]
953
+ },
954
+ ```
955
+
956
+ ## Module/Programmatic Usage
957
+
958
+ npm-check-updates can be imported as a module:
959
+
960
+ ```js
961
+ import ncu from 'npm-check-updates'
962
+
963
+ const upgraded = await ncu.run({
964
+ // Pass any cli option
965
+ packageFile: '../package.json',
966
+ upgrade: true,
967
+ // Defaults:
968
+ // jsonUpgraded: true,
969
+ // silent: true,
970
+ })
971
+
972
+ console.log(upgraded) // { "mypackage": "^2.0.0", ... }
973
+ ```
974
+
975
+ ## Contributing
976
+
977
+ 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).
978
+
979
+ ## Problems?
980
+
981
+ [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.