updates/README.md

110 lines
4.0 KiB
Markdown
Raw Normal View History

2017-12-03 11:15:02 +00:00
# updates
2020-03-08 16:15:46 +00:00
[![](https://img.shields.io/npm/v/updates.svg?style=flat)](https://www.npmjs.org/package/updates) [![](https://img.shields.io/npm/dm/updates.svg)](https://www.npmjs.org/package/updates)
2019-04-10 20:19:45 +00:00
> Flexible npm dependency update tool
2019-03-07 20:23:03 +00:00
`updates` is a CLI tool which checks for npm dependency updates of the current project and optionally updates `package.json`. It is highly configurable and is typically able to complete in less than a second.
2017-12-03 11:15:02 +00:00
2020-03-08 16:06:58 +00:00
```
$ updates
2020-03-11 12:37:23 +00:00
NAME OLD NEW AGE INFO
p-map 3.0.0 4.0.0 3 days https://github.com/sindresorhus/p-map
rrdir 4.0.0 5.0.0 11 days https://github.com/silverwind/rrdir
eslint 6.7.2 6.8.0 3 months https://github.com/eslint/eslint
rimraf 3.0.0 3.0.2 28 days https://github.com/isaacs/rimraf
versions 7.0.5 8.2.3 1 day https://github.com/silverwind/versions
updates 6941e05 815cc8b 16 hours https://github.com/silverwind/updates
2020-03-08 16:06:58 +00:00
```
2017-12-03 13:14:30 +00:00
2019-03-07 20:23:03 +00:00
## Usage
2017-12-03 11:30:39 +00:00
2017-12-03 12:18:53 +00:00
```console
2020-03-08 16:18:46 +00:00
$ npm i -D updates
2017-12-03 11:30:39 +00:00
```
2019-03-07 20:23:03 +00:00
Then, check for new updates:
```console
$ npx updates
2019-03-07 20:23:03 +00:00
```
2019-07-12 14:26:32 +00:00
When changes are satisfactory, update `package.json` and reinstall modules:
2019-03-07 20:23:03 +00:00
```console
$ npx updates -u && rm -rf node_modules && npm i
2019-03-07 20:23:03 +00:00
```
2019-07-12 14:37:24 +00:00
To only reinstall modules when updates are available:
```console
2019-07-12 14:37:24 +00:00
$ npx updates -uU && rm -rf node_modules && npm i
```
2019-07-12 14:37:24 +00:00
On a CI, it might be desireable to fail a build when updates are available:
```console
$ npx updates -E
2019-07-12 14:38:41 +00:00
```
2019-07-12 14:37:24 +00:00
2019-03-07 20:23:03 +00:00
## Options
2019-03-07 20:28:20 +00:00
See `--help` or below for the available options. Option that take multiple arguments can take them either via comma-separated value or by specifying the option multiple times. If an option has a optional `pkg` argument but none is given, the option will be applied to all packages instead.
2019-03-07 20:23:03 +00:00
2018-09-02 08:35:47 +00:00
```
usage: updates [options]
Options:
-u, --update Update versions and write package.json
-p, --prerelease [<pkg,...>] Consider prerelease versions
-R, --release [<pkg,...>] Only use release versions, may downgrade
-g, --greatest [<pkg,...>] Prefer greatest over latest version
-i, --include <pkg,...> Include only given packages
-e, --exclude <pkg,...> Exclude given packages
-t, --types <type,...> Check only given dependency types
-P, --patch [<pkg,...>] Consider only up to semver-patch
-m, --minor [<pkg,...>] Consider only up to semver-minor
-d, --allow-downgrade [<pkg,...>] Allow version downgrades when using latest version
-E, --error-on-outdated Exit with code 2 when updates are available and code 0 when not
-U, --error-on-unchanged Exit with code 0 when updates are available and code 2 when not
-r, --registry <url> Override npm registry URL
2020-03-09 16:55:59 +00:00
-G, --githubapi <url> Override Github API URL
-f, --file <path> Use given package.json file or module directory
-S, --sockets <num> Maximum number of parallel HTTP sockets opened. Default: 64
-j, --json Output a JSON object
-c, --color Force-enable color output
-n, --no-color Disable color output
-v, --version Print the version
-h, --help Print this help
2018-09-02 08:35:47 +00:00
Examples:
$ updates
$ updates -u
2019-07-19 13:34:04 +00:00
$ updates -u -m -e eslint
2019-07-13 16:06:15 +00:00
$ updates -u -U && rm -rf node_modules && npm i
2018-09-02 08:36:52 +00:00
```
2018-09-02 08:35:47 +00:00
2019-03-07 20:23:03 +00:00
## JSON Output
2018-12-02 08:20:31 +00:00
The JSON output is an object with possible properties `results`, `message` and `error`:
2017-12-03 16:05:35 +00:00
```console
2018-10-25 20:36:41 +00:00
$ updates -j | jq
{
"results": {
"dependencies": {
2020-03-08 16:13:23 +00:00
"p-map": {
"old": "3.0.0",
"new": "4.0.0",
"info": "https://github.com/sindresorhus/p-map",
"age": "3 days"
}
},
"devDependencies": {
"eslint": {
2020-03-08 16:13:23 +00:00
"old": "6.7.2",
"new": "6.8.0",
"info": "https://github.com/eslint/eslint",
"age": "3 months"
}
}
2017-12-03 16:05:35 +00:00
}
}
2017-12-03 16:05:35 +00:00
```
2017-12-03 11:15:02 +00:00
© [silverwind](https://github.com/silverwind), distributed under BSD licence