npm-check-updates
Advanced tools
Comparing version 2.0.0-alpha4 to 2.0.0-alpha5
var program = require('commander'); | ||
var async = require('async'); | ||
var cint = require('cint'); | ||
var fs = require('fs'); | ||
@@ -10,5 +11,3 @@ var path = require('path'); | ||
readPackageFile(packageFile, function (error, packageData) { | ||
if (error) { | ||
return callback(error); | ||
} | ||
if (error) return callback(error); | ||
@@ -26,5 +25,3 @@ var newPackageData = vm.updatePackageData(packageData, currentDependencies, upgradedDependencies); | ||
function (error, latestVersions, failedDependencies) { | ||
if (error) { | ||
return callback(error); | ||
} | ||
if (error) return callback(error); | ||
@@ -41,3 +38,4 @@ var upgradedDependencies = vm.upgradeDependencies(currentDependencies, latestVersions); | ||
if (error) { | ||
return console.error("There was an error reading the global packages: "); | ||
console.error("There was an error reading the global packages: "); | ||
process.exit(1); | ||
} | ||
@@ -47,3 +45,4 @@ | ||
if (error) { | ||
return console.error("There was an error determining the latest package versions: " + error); | ||
console.error("There was an error determining the latest package versions: " + error); | ||
process.exit(1); | ||
} | ||
@@ -59,2 +58,5 @@ | ||
} | ||
if(program.errorLevel >= 2) { | ||
process.exit(1); | ||
} | ||
} | ||
@@ -74,8 +76,7 @@ }); | ||
}, | ||
installed: function (callback) { | ||
vm.getInstalledPackages(callback); | ||
} | ||
installed: vm.getInstalledPackages | ||
}, function (error, results) { | ||
if (error) { | ||
return console.error("There was an error analyzing the dependencies: " + error); | ||
console.error("There was an error analyzing the dependencies: " + error); | ||
process.exit(1); | ||
} | ||
@@ -85,3 +86,4 @@ | ||
if (error) { | ||
return console.error("There was an error determining the latest package versions: " + error); | ||
console.error("There was an error determining the latest package versions: " + error); | ||
process.exit(1); | ||
} | ||
@@ -92,7 +94,8 @@ | ||
if (isEmpty(upgradedDependencies) === false) { | ||
if (!isEmpty(upgradedDependencies)) { | ||
if (program.upgrade) { | ||
upgradePackageFile(packageFile, results.current, upgradedDependencies, function (error) { | ||
if (error) { | ||
return console.error("There was an error writing the package.json file: " + error); | ||
console.error("There was an error writing the package.json file: " + error); | ||
process.exit(1); | ||
} | ||
@@ -105,2 +108,5 @@ | ||
} | ||
if(program.errorLevel >= 2) { | ||
process.exit(1); | ||
} | ||
} | ||
@@ -134,2 +140,3 @@ }); | ||
.option('-d, --dev', 'check only devDependencies') | ||
.option('-e, --error-level <n>', '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 is 1.', cint.partialAt(parseInt, 1, 10), 1) | ||
.option('-f, --filter <packages>', 'list or regex of package names to search (all others will be ignored). Note: single quotes may be required to avoid inadvertant bash parsing.') | ||
@@ -165,4 +172,3 @@ .option('-g, --global', 'check global packages instead of in the current project') | ||
process.exit(1); | ||
} | ||
else { | ||
} else { | ||
packageFile = closestPackage.sync(process.cwd()); | ||
@@ -169,0 +175,0 @@ packageInSameDir = false; |
@@ -304,14 +304,11 @@ var npm = require('npm'); | ||
async.map(packageList, errorCollectorWrapper, function (error, latestVersions) { | ||
if (error) { | ||
return callback(error); | ||
} | ||
if (error) { return callback(error); } | ||
// The error wrapper will insert empty elements for the errors, remove those | ||
latestVersions = latestVersions.filter(function (n) { | ||
return n != undefined | ||
}); | ||
// remove empty objects left from errorCollectorWrapper | ||
// merge the array of versions into one object, for easier lookups | ||
latestDependencies = latestVersions | ||
.filter(cint.not(_.isEmpty)) | ||
.reduce(_.assign, {}); | ||
// Merge the array of versions into one object, for easier lookups | ||
var latestDependencies = arrayToObject(latestVersions); | ||
callback(error, latestDependencies, failedDependencies); | ||
callback(null, latestDependencies, failedDependencies); | ||
}); | ||
@@ -318,0 +315,0 @@ } |
{ | ||
"name": "npm-check-updates", | ||
"version": "2.0.0-alpha4", | ||
"version": "2.0.0-alpha5", | ||
"author": "Tomas Junnonen <tomas1@gmail.com>", | ||
@@ -37,6 +37,6 @@ "description": "Find newer versions of dependencies than what your package.json allows", | ||
"commander": "^2.6.0", | ||
"lodash": "^3.1.0", | ||
"npm": "^2.5.0", | ||
"lodash": "^3.2.0", | ||
"npm": "^2.5.1", | ||
"read-package-json": "^1.3.1", | ||
"semver": "^4.2.2" | ||
"semver": "^4.3.0" | ||
}, | ||
@@ -43,0 +43,0 @@ "devDependencies": { |
@@ -12,4 +12,4 @@ npm-check-updates | ||
Put plainly, it will upgrade your "express": "3.3.x" dependency to | ||
"express": "3.4.x" when express 3.4.0 hits the scene. | ||
Put plainly, it will upgrade your "express": "^4.11.2" dependency to | ||
"express": "^5.0.0" when express 5.0.0 hits the scene. | ||
@@ -21,3 +21,3 @@ View the [options](#options) for global, dev-only, prod-only, or filtering by package name. | ||
[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.0" style dependency in your package.json, whereby patch-level updates are automatically allowed but major and minor releases require manual verification. | ||
@@ -38,2 +38,8 @@ Unfortunately, it then becomes your responsibility to find out about new | ||
Please consider installing the unstable version to help test pre-release features. You may even find [some features](#history) you needed that are not yet in the stable version. | ||
```sh | ||
npm install -g npm-check-updates@unstable | ||
``` | ||
Examples | ||
@@ -46,4 +52,4 @@ -------------- | ||
"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) | ||
"connect" can be updated from ^2.8.0 to ^2.11.0 (Installed: 2.8.8, Latest: 2.11.0) | ||
"commander" can be updated from ^1.3.0 to ^2.0.0 (Installed: 1.3.2, Latest: 2.0.0) | ||
@@ -57,3 +63,3 @@ Run with '-u' to upgrade your package.json | ||
"request" can be updated from 2.20.x to 2.27.x (Installed: 2.20.0, Latest: 2.27.1) | ||
"request" can be updated from ^2.20.0 to ^2.27.0 (Installed: 2.20.0, Latest: 2.27.1) | ||
@@ -83,2 +89,6 @@ package.json upgraded | ||
to avoid inadvertant bash parsing. | ||
-e, --error-level 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) (alpha release only) | ||
-g, --global check global packages instead of in the current project | ||
@@ -88,3 +98,3 @@ -p, --prod check only dependencies (not devDependencies) | ||
-t, --greatest find the highest versions available instead of the | ||
latest stable versions | ||
latest stable versions (alpha release only) | ||
-u, --upgrade upgrade package.json dependencies to match latest | ||
@@ -98,7 +108,9 @@ versions (maintaining existing policy) | ||
- 2.0.0-alpha4 | ||
- *2.0.0-alpha5* | ||
- Add -e/--error-level option | ||
- *2.0.0-alpha4* | ||
- Add -t/--greatest option to search for the highest versions instead of the default latest stable versions. | ||
- 2.0.0-alpha3 | ||
- *2.0.0-alpha3* | ||
- Automatically look for the closest descendant package.json if not found in current directory | ||
- 2.0.0-alpha1 | ||
- *2.0.0-alpha1* | ||
- Do not downgrade packages | ||
@@ -132,3 +144,3 @@ - 1.5.1 | ||
- Semantic versioning policies for levels are maintained while satisfying the latest version: | ||
- 1.2.x => 1.3.x | ||
- ^1.2.0 => ^1.3.0 | ||
- 1.x => 2.x | ||
@@ -138,3 +150,3 @@ - "Any version" is maintained: | ||
- Version constraints are maintained: | ||
- \>0.2.x => \> 0.3.x | ||
- \>0.2.0 => \> 0.3.0 | ||
- \>=1.0.0 => >=1.1.0 | ||
@@ -141,0 +153,0 @@ |
35252
10
623
150
Updatedlodash@^3.2.0
Updatednpm@^2.5.1
Updatedsemver@^4.3.0