From d25fa4a4db74c1d32fcaa3ee437cacb9be7f466e Mon Sep 17 00:00:00 2001 From: metaraine Date: Fri, 12 Dec 2014 08:47:52 -0700 Subject: [PATCH] README: Simplify examples and add options. --- README.md | 69 ++++++++++++++++------------------------ lib/npm-check-updates.js | 26 +++------------ 2 files changed, 31 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 1b105024..b62d3dca 100644 --- a/README.md +++ b/README.md @@ -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. @@ -43,24 +37,17 @@ 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) @@ -68,28 +55,26 @@ $ npm-check-updates -u 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 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 -------------- diff --git a/lib/npm-check-updates.js b/lib/npm-check-updates.js index f4ecf20f..658a918f 100644 --- a/lib/npm-check-updates.js +++ b/lib/npm-check-updates.js @@ -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'); @@ -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"); } } }); @@ -136,12 +118,12 @@ function printDependencyUpgrades(currentDependencies, upgradedDependencies, inst program .version(require('../package').version) .usage('[options] ') - .option('-f, --filter ', 'list or regex of packages to search (all others will be ignored)') + .option('-d, --dev', 'check only devDependencies') + .option('-f, --filter ', '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) {