Skip to content

Commit

Permalink
README: Simplify examples and add options.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Dec 12, 2014
1 parent 57d7cc1 commit d25fa4a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 64 deletions.
69 changes: 27 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
npm-check-updates
=================

npm-check-updates is a tool that allows you to **find all updates to
dependencies** in your Node.js project, regardless of any version
npm-check-updates is a tool that allows you to **find the latest versions of
dependencies**, regardless of any version
constraints in your package.json file (unlike npm itself).

Optionally, npm-check-updates can also upgrade your package.json file to
satisfy the latest available versions, all while **maintaining your
npm-check-updates can optionally upgrade your package.json file to
use the latest available versions, all while **maintaining your
existing semantic versioning policies**.

Put plainly, it will upgrade your "express": "3.3.x" dependency to
"express": "3.4.x" when express 3.4.0 hits the scene.

npm-check-updates can also show you all available **updates to your globally
installed packages**.
View the [options](#options) for global, dev-only, prod-only, or filtering by package name.

Motivation
--------------

[Package.json best practices](http://blog.nodejitsu.com/package-dependencies-done-right)
recommends maintaining dependencies using a [semantic versioning](http://semver.org/)
policy. In practice you do this by specifying a "1.2.x" style dependency
in your package.json, whereby patch-level updates are automatically allowed
but major and minor releases require manual verification.
[Package.json best practices](http://blog.nodejitsu.com/package-dependencies-done-right) recommends maintaining dependencies using a [semantic versioning](http://semver.org/) policy. In practice you do this by specifying a "1.2.x" style dependency in your package.json, whereby patch-level updates are automatically allowed but major and minor releases require manual verification.

Unfortunately, it then becomes your responsibility to find out about new
package releases, for example by using "npm info" command one package at a time,
or by visiting project pages.
package releases, for example by using "npm info" command one package at a time, or by visiting project pages.

Whatever your versioning policy, npm-check-updates will make keeping your
dependencies up to date a breeze.
Expand All @@ -43,53 +37,44 @@ Examples
--------------

Show any new dependencies for the project in the current directory:
```
```sh
$ npm-check-updates

"connect" can be updated from 2.8.x to 2.11.x (Installed: 2.8.8, Latest: 2.11.0)
"commander" can be updated from 1.3.x to 2.0.x (Installed: 1.3.2, Latest: 2.0.0)

Run 'npm-check-updates -u' to upgrade your package.json automatically
```

Check global npm packages for updates:
```
$ npm-check-updates -g
"mocha" can be updated to version 1.12.1
Run with '-u' to upgrade your package.json
```

Upgrade a project's package.json:
```
```sh
$ npm-check-updates -u

"request" can be updated from 2.20.x to 2.27.x (Installed: 2.20.0, Latest: 2.27.1)

package.json upgraded
```

Check only devDependencies packages for updates:
```
$ npm-check-updates -d
"mocha" can be updated to version 1.12.1
Filter by package name:
```sh
$ npm-check-updates -f mocha,should # string
$ npm-check-updates -f /^((?!gulp-).)*$/ # regex
```
Check only production dependencies packages for updates:
```
$ npm-check-updates -p
"request" can be updated from 2.20.x to 2.27.x (Installed: 2.20.0, Latest: 2.27.1)
```

Now simply perform the usual "npm update" and verify that your project
works with the upgraded versions.
Options
--------------
-d, --dev check only devDependencies
-h, --help output usage information
-f, --filter <packages> list or regex of package names to search
(all others will be ignored)
-g, --global check global packages instead of in the current
project
-p, --prod check only dependencies (not devDependencies)
-s, --silent don't output anything
-u, --upgrade upgrade package.json dependencies to match latest
versions (maintaining existing policy)
-V, --version output the version number
Filter the packages that are searched with a list or regex:
```
$ npm-check-updates -f mocha,should
$ npm-check-updates -f /^((?!gulp-).)*$/
```
History
--------------
Expand Down
26 changes: 4 additions & 22 deletions lib/npm-check-updates.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
// npm-check-updates
// Tomas Junnonen (c) 2013
//
// Checks a package.json file for updated NPM packages that are *not*
// satisfied by the current package.json dependency declarations.
//
// Example output:
// Dependency "express" could be updated to "3.3.x" (latest is 3.3.8)
//
// Optionally automatically upgrades the dependencies in package.json
// while maintaining your existing versioning policy.
//
// Example:
// Your package.json: "express": "3.2.x."
// Latest version upstream is 3.3.8
// package.json after upgrade: "express": "3.3.x"
//

var program = require('commander');
var async = require('async');
var fs = require('fs');
Expand Down Expand Up @@ -110,7 +92,7 @@ function analyzeProjectDependencies(packageFile) {
print('\n' + packageFile + " upgraded");
});
} else {
print("\nRun with '-u' to upgrade your package.json automatically");
print("\nRun with '-u' to upgrade your package.json");
}
}
});
Expand All @@ -136,12 +118,12 @@ function printDependencyUpgrades(currentDependencies, upgradedDependencies, inst
program
.version(require('../package').version)
.usage('[options] <package.json or dir>')
.option('-f, --filter <packages>', 'list or regex of packages to search (all others will be ignored)')
.option('-d, --dev', 'check only devDependencies')
.option('-f, --filter <packages>', 'list or regex of package names to search (all others will be ignored)')
.option('-g, --global', 'check global packages instead of in the current project')
.option('-p, --prod', 'check only dependencies (not devDependencies)')
.option('-s, --silent', "don't output anything")
.option('-u, --upgrade', 'upgrade package.json dependencies to match latest versions (maintaining existing policy)')
.option('-p, --prod', 'process only dependencies')
.option('-d, --dev', 'process only devDependencies')
.parse(process.argv);

if (program.global && program.upgrade) {
Expand Down

0 comments on commit d25fa4a

Please sign in to comment.