diff options
-rw-r--r-- | lib/cache.js | 31 | ||||
-rw-r--r-- | lib/dedupe.js | 4 | ||||
-rw-r--r-- | lib/deprecate.js | 2 | ||||
-rw-r--r-- | lib/install.js | 22 | ||||
-rw-r--r-- | lib/ls.js | 5 | ||||
-rw-r--r-- | lib/npm.js | 5 | ||||
-rw-r--r-- | lib/outdated.js | 1 | ||||
-rw-r--r-- | lib/rebuild.js | 2 | ||||
-rw-r--r-- | lib/search.js | 1 | ||||
-rw-r--r-- | lib/uninstall.js | 1 | ||||
-rw-r--r-- | lib/version.js | 2 | ||||
-rw-r--r-- | lib/view.js | 6 | ||||
-rw-r--r-- | package.json | 16 |
13 files changed, 53 insertions, 45 deletions
diff --git a/lib/cache.js b/lib/cache.js index 9f8819e68..db8efd865 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -600,8 +600,8 @@ function addNamed (name, x, data, cb_) { lock(k, function (er, fd) { if (er) return cb(er) - var fn = ( null !== semver.valid(x) ? addNameVersion - : null !== semver.validRange(x) ? addNameRange + var fn = ( semver.valid(x, true) ? addNameVersion + : semver.validRange(x, true) ? addNameRange : addNameTag ) fn(name, x, data, cb) @@ -655,8 +655,8 @@ function engineFilter (data) { var eng = data.versions[v].engines if (!eng) return if (!strict && !data.versions[v].engineStrict) return - if (eng.node && !semver.satisfies(nodev, eng.node) - || eng.npm && !semver.satisfies(npmv, eng.npm)) { + if (eng.node && !semver.satisfies(nodev, eng.node, true) + || eng.npm && !semver.satisfies(npmv, eng.npm, true)) { delete data.versions[v] } }) @@ -665,7 +665,7 @@ function engineFilter (data) { function addNameRange (name, range, data, cb) { if (typeof cb !== "function") cb = data, data = null - range = semver.validRange(range) + range = semver.validRange(range, true) if (range === null) return cb(new Error( "Invalid version range: "+range)) @@ -688,12 +688,15 @@ function addNameRange (name, range, data, cb) { // if the tagged version satisfies, then use that. var tagged = data["dist-tags"][npm.config.get("tag")] - if (tagged && data.versions[tagged] && semver.satisfies(tagged, range)) { + if (tagged + && data.versions[tagged] + && semver.satisfies(tagged, range, true)) { return addNamed(name, tagged, data.versions[tagged], cb) } // find the max satisfying version. - var ms = semver.maxSatisfying(Object.keys(data.versions || {}), range) + var versions = Object.keys(data.versions || {}) + var ms = semver.maxSatisfying(versions, range, true) if (!ms) { return cb(installTargetsError(range, data)) } @@ -720,11 +723,11 @@ function installTargetsError (requested, data) { + requested + "\n" + targets) } -function addNameVersion (name, ver, data, cb) { +function addNameVersion (name, v, data, cb) { if (typeof cb !== "function") cb = data, data = null - ver = semver.valid(ver) - if (ver === null) return cb(new Error("Invalid version: "+ver)) + ver = semver.valid(v, true) + if (!ver) return cb(new Error("Invalid version: "+v)) var response @@ -1107,7 +1110,9 @@ function addLocalDirectory (p, name, shasum, cb) { // tar it to the proper place, and add the cache tar if (p.indexOf(npm.cache) === 0) return cb(new Error( "Adding a cache directory to the cache will make the world implode.")) - readJson(path.join(p, "package.json"), function (er, data) { + var strict = p.indexOf(npm.tmp) !== 0 + && p.indexOf(npm.cache) !== 0 + readJson(path.join(p, "package.json"), strict, function (er, data) { er = needName(er, data) er = needVersion(er, data) if (er) return cb(er) @@ -1119,12 +1124,10 @@ function addLocalDirectory (p, name, shasum, cb) { , data.version, "package.tgz" ) , placeDirect = path.basename(p) === "package" , tgz = placeDirect ? placed : tmptgz - , doFancyCrap = p.indexOf(npm.tmp) !== 0 - && p.indexOf(npm.cache) !== 0 getCacheStat(function (er, cs) { mkdir(path.dirname(tgz), function (er, made) { if (er) return cb(er) - tar.pack(tgz, p, data, doFancyCrap, function (er) { + tar.pack(tgz, p, data, strict, function (er) { if (er) { log.error( "addLocalDirectory", "Could not pack %j to %j" , p, tgz ) diff --git a/lib/dedupe.js b/lib/dedupe.js index bd0056e99..648397b7a 100644 --- a/lib/dedupe.js +++ b/lib/dedupe.js @@ -258,9 +258,9 @@ function findVersions (npm, summary, cb) { function bestMatch (versions, ranges) { return versions.filter(function (v) { return !ranges.some(function (r) { - return !semver.satisfies(v, r) + return !semver.satisfies(v, r, true) }) - }).sort(semver.compare).pop() + }).sort(semver.compareLoose).pop() } diff --git a/lib/deprecate.js b/lib/deprecate.js index 1ba4305cd..7d0b41ac7 100644 --- a/lib/deprecate.js +++ b/lib/deprecate.js @@ -37,7 +37,7 @@ function deprecate (args, cb) { if (er) return cb(er) // filter all the versions that match Object.keys(data.versions).filter(function (v) { - return semver.satisfies(v, ver) + return semver.satisfies(v, ver, true) }).forEach(function (v) { data.versions[v].deprecated = msg }) diff --git a/lib/install.js b/lib/install.js index 50ba5ebc5..dd40775fa 100644 --- a/lib/install.js +++ b/lib/install.js @@ -160,8 +160,11 @@ function install (args, cb_) { // initial "family" is the name:version of the root, if it's got // a package.json file. - readJson(path.resolve(where, "package.json"), function (er, data) { - if (er && er.code !== "ENOENT" && er.code !== "ENOTDIR") return cb(er) + var jsonFile = path.resolve(where, "package.json") + readJson(jsonFile, true, function (er, data) { + if (er + && er.code !== "ENOENT" + && er.code !== "ENOTDIR") return cb(er) if (er) data = null var context = { family: {} , ancestors: {} @@ -178,7 +181,7 @@ function install (args, cb_) { } function findPeerInvalid (where, cb) { - readInstalled(where, function (er, data) { + readInstalled(where, log.warn, function (er, data) { if (er) return cb(er) cb(null, findPeerInvalid_(data.dependencies, [])) @@ -337,8 +340,8 @@ function save (where, installed, tree, pretty, cb) { if (u && u.protocol) w[1] = t.from return w }).reduce(function (set, k) { - var rangeDescriptor = semver.valid(k[1]) && - semver.gte(k[1], "0.1.0") + var rangeDescriptor = semver.valid(k[1], true) && + semver.gte(k[1], "0.1.0", true) ? "~" : "" set[k[0]] = rangeDescriptor + k[1] return set @@ -494,7 +497,7 @@ function installManyTop (what, where, context, cb_) { if (context.explicit) return next() - readJson(path.join(where, "package.json"), function (er, data) { + readJson(path.join(where, "package.json"), true, function (er, data) { if (er) return next(er) lifecycle(data, "preinstall", where, next) }) @@ -619,7 +622,7 @@ function targetResolver (where, context, deps) { // otherwise, make sure that it's a semver match with what we want. var bd = parent.bundleDependencies if (bd && bd.indexOf(d.name) !== -1 || - semver.satisfies(d.version, deps[d.name] || "*")) { + semver.satisfies(d.version, deps[d.name] || "*", true)) { return cb(null, d.name) } @@ -1066,7 +1069,10 @@ function prepareForInstallMany (packageData, depsKey, bundled, wrap, family) { // prefer to not install things that are satisfied by // something in the "family" list, unless we're installing // from a shrinkwrap. - return wrap || !semver.satisfies(family[d], packageData[depsKey][d]) + if (wrap) return wrap + if (semver.validRange(family[d], true)) + return !semver.satisfies(family[d], packageData[depsKey][d], true) + return true }).map(function (d) { var t = packageData[depsKey][d] , parsed = url.parse(t.replace(/^git\+/, "git")) @@ -33,7 +33,8 @@ function ls (args, silent, cb) { return [ name, ver ] }) - readInstalled(dir, npm.config.get("depth"), function (er, data) { + var depth = npm.config.get("depth") + readInstalled(dir, depth, log.warn, function (er, data) { var bfs = bfsify(data, args) , lite = getLite(bfs) @@ -196,7 +197,7 @@ function filterFound (root, args) { var found = false for (var i = 0; !found && i < args.length; i ++) { if (d === args[i][0]) { - found = semver.satisfies(dep.version, args[i][1]) + found = semver.satisfies(dep.version, args[i][1], true) } } // included explicitly diff --git a/lib/npm.js b/lib/npm.js index 6cd7888d0..dffe35625 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -53,15 +53,16 @@ function mkdir (p, cb) { npm.commands = {} try { + var pv = process.version.replace(/^v/, '') // startup, ok to do this synchronously var j = JSON.parse(fs.readFileSync( path.join(__dirname, "../package.json"))+"") npm.version = j.version npm.nodeVersionRequired = j.engines.node - if (!semver.satisfies(process.version, j.engines.node)) { + if (!semver.satisfies(pv, j.engines.node)) { log.warn("unsupported version", ["" ,"npm requires node version: "+j.engines.node - ,"And you have: "+process.version + ,"And you have: "+pv ,"which is not satisfactory." ,"" ,"Bad things will likely happen. You have been warned." diff --git a/lib/outdated.js b/lib/outdated.js index 038f18bfa..b205922ef 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -24,7 +24,6 @@ var path = require("path") , cache = require("./cache.js") , asyncMap = require("slide").asyncMap , npm = require("./npm.js") - , semver = require("semver") function outdated (args, silent, cb) { if (typeof cb !== "function") cb = silent, silent = false diff --git a/lib/rebuild.js b/lib/rebuild.js index 35bb454d7..7cea3efff 100644 --- a/lib/rebuild.js +++ b/lib/rebuild.js @@ -52,7 +52,7 @@ function filter (data, args, set, seen) { , n = nv.shift() , v = nv.join("@") if (n !== data.name) continue - if (!semver.satisfies(data.version, v)) continue + if (!semver.satisfies(data.version, v, true)) continue pass = true break } diff --git a/lib/search.js b/lib/search.js index edbdc70b1..c758f869a 100644 --- a/lib/search.js +++ b/lib/search.js @@ -3,7 +3,6 @@ module.exports = exports = search var npm = require("./npm.js") , registry = npm.registry - , semver = require("semver") search.usage = "npm search [some search terms ...]" diff --git a/lib/uninstall.js b/lib/uninstall.js index bebc2300b..072d46bcf 100644 --- a/lib/uninstall.js +++ b/lib/uninstall.js @@ -13,7 +13,6 @@ var fs = require("graceful-fs") , readJson = require("read-package-json") , path = require("path") , npm = require("./npm.js") - , semver = require("semver") , asyncMap = require("slide").asyncMap function uninstall (args, cb) { diff --git a/lib/version.js b/lib/version.js index 73cd163f4..386001eb2 100644 --- a/lib/version.js +++ b/lib/version.js @@ -11,7 +11,7 @@ var exec = require("child_process").execFile , which = require("which") , npm = require("./npm.js") -version.usage = "npm version [<newversion> | major | minor | patch | build]\n" +version.usage = "npm version [<newversion> | major | minor | patch]\n" + "\n(run in package dir)\n" + "'npm -v' or 'npm --version' to print npm version " + "("+npm.version+")\n" diff --git a/lib/view.js b/lib/view.js index b88f98a09..babd072f7 100644 --- a/lib/view.js +++ b/lib/view.js @@ -13,7 +13,7 @@ view.completion = function (opts, cb) { if (er) return cb(er) var dv = d.versions[d["dist-tags"][tag]] , fields = [] - d.versions = Object.keys(d.versions).sort(semver.compare) + d.versions = Object.keys(d.versions).sort(semver.compareLoose) fields = getFields(d).concat(getFields(dv)) cb(null, fields) }) @@ -64,7 +64,7 @@ function view (args, silent, cb) { var results = [] , error = null , versions = data.versions - data.versions = Object.keys(data.versions).sort(semver.compare) + data.versions = Object.keys(data.versions).sort(semver.compareLoose) if (!args.length) args = [""] // remove readme unless we asked for it @@ -73,7 +73,7 @@ function view (args, silent, cb) { } Object.keys(versions).forEach(function (v) { - if (semver.satisfies(v, version)) args.forEach(function (args) { + if (semver.satisfies(v, version, true)) args.forEach(function (args) { // remove readme unless we asked for it if (-1 === args.indexOf("readme")) { delete versions[v].readme diff --git a/package.json b/package.json index bea589077..ee54f5814 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "main": "./lib/npm.js", "bin": "./bin/npm-cli.js", "dependencies": { - "semver": "~1.1.2", + "semver": "~2.0.7", "ini": "~1.1.0", "slide": "~1.1.4", "abbrev": "~1.0.4", @@ -51,23 +51,23 @@ "mkdirp": "~0.3.3", "read": "~1.0.4", "lru-cache": "~2.3.0", - "node-gyp": "~0.10.0", + "node-gyp": "~0.10.1", "fstream-npm": "~0.1.3", "uid-number": "0", "archy": "0", "chownr": "0", - "npmlog": "0", + "npmlog": "0.0.3", "ansi": "~0.1.2", - "npm-registry-client": "~0.2.22", - "read-package-json": "~0.4.1", - "read-installed": "0", + "npm-registry-client": "~0.2.25", + "read-package-json": "~1.1.0", + "read-installed": "~0.2.2", "glob": "~3.2.1", - "init-package-json": "0.0.9", + "init-package-json": "0.0.10", "osenv": "0", "lockfile": "~0.3.2", "retry": "~0.6.0", "once": "~1.1.1", - "npmconf": "~0.1.0", + "npmconf": "~0.1.1", "opener": "~1.3.0", "chmodr": "~0.1.0", "cmd-shim": "~1.1.0", |