summaryrefslogtreecommitdiff
path: root/deps/npm/lib
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2015-07-09 20:48:26 -0700
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2015-07-16 12:26:54 -0700
commit938cc757bb996244df6301cd91187789f4f8a909 (patch)
treee701fd52797d3babf9f1ab3355c96d2d8457c0eb /deps/npm/lib
parent6c3aabf455f5ed9c65bd6ae1ea208c752317216b (diff)
downloadandroid-node-v8-938cc757bb996244df6301cd91187789f4f8a909.tar.gz
android-node-v8-938cc757bb996244df6301cd91187789f4f8a909.tar.bz2
android-node-v8-938cc757bb996244df6301cd91187789f4f8a909.zip
deps: upgrade to npm 2.13.0
PR-URL: https://github.com/nodejs/io.js/pull/2152 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'deps/npm/lib')
-rw-r--r--deps/npm/lib/install.js5
-rw-r--r--deps/npm/lib/npm.js4
-rw-r--r--deps/npm/lib/ping.js20
-rw-r--r--deps/npm/lib/version.js177
4 files changed, 125 insertions, 81 deletions
diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js
index 4ab248a492..9cc6a46fc0 100644
--- a/deps/npm/lib/install.js
+++ b/deps/npm/lib/install.js
@@ -122,10 +122,11 @@ function install (args, cb_) {
if (er) return cb_(er)
if (problem) {
- var peerInvalidError = new Error("The package " + problem.name +
+ var peerInvalidError = new Error("The package " + problem._id +
" does not satisfy its siblings' peerDependencies requirements!")
peerInvalidError.code = "EPEERINVALID"
peerInvalidError.packageName = problem.name
+ peerInvalidError.packageVersion = problem.version
peerInvalidError.peersDepending = problem.peersDepending
return cb(peerInvalidError)
}
@@ -287,7 +288,7 @@ function findPeerInvalid_ (packageMap, fpiList) {
peer.peerDependencies[packageName]
}
}
- return { name: pkg.name, peersDepending: peersDepending }
+ return { name: pkg.name, peersDepending: peersDepending, version: pkg.version, _id: pkg._id }
}
if (pkg.dependencies) {
diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js
index a2756ed7d2..97cdad4de2 100644
--- a/deps/npm/lib/npm.js
+++ b/deps/npm/lib/npm.js
@@ -15,7 +15,8 @@ var EventEmitter = require("events").EventEmitter
, npm = module.exports = new EventEmitter()
, npmconf = require("./config/core.js")
, log = require("npmlog")
- , fs = require("graceful-fs")
+ , gfs = require('graceful-fs')
+ , fs = gfs.gracefulify(require('fs'))
, path = require("path")
, abbrev = require("abbrev")
, which = require("which")
@@ -133,6 +134,7 @@ var commandCache = {}
, "bin"
, "whoami"
, "dist-tag"
+ , "ping"
, "test"
, "stop"
diff --git a/deps/npm/lib/ping.js b/deps/npm/lib/ping.js
new file mode 100644
index 0000000000..23b18bfba0
--- /dev/null
+++ b/deps/npm/lib/ping.js
@@ -0,0 +1,20 @@
+var npm = require('./npm.js')
+
+module.exports = ping
+
+ping.usage = 'npm ping\nping registry'
+
+function ping (args, silent, cb) {
+ if (typeof cb !== 'function') {
+ cb = silent
+ silent = false
+ }
+ var registry = npm.config.get('registry')
+ if (!registry) return cb(new Error('no default registry set'))
+ var auth = npm.config.getCredentialsByURI(registry)
+
+ npm.registry.ping(registry, {auth: auth}, function (er, pong) {
+ if (!silent) console.log(JSON.stringify(pong))
+ cb(er, er ? null : pong)
+ })
+}
diff --git a/deps/npm/lib/version.js b/deps/npm/lib/version.js
index f763aad0ad..b33392488f 100644
--- a/deps/npm/lib/version.js
+++ b/deps/npm/lib/version.js
@@ -2,36 +2,38 @@
module.exports = version
-var semver = require("semver")
- , path = require("path")
- , fs = require("graceful-fs")
- , writeFileAtomic = require("write-file-atomic")
- , chain = require("slide").chain
- , log = require("npmlog")
- , npm = require("./npm.js")
- , git = require("./utils/git.js")
- , assert = require("assert")
- , lifecycle = require("./utils/lifecycle.js")
-
-version.usage = "npm version [<newversion> | major | minor | patch | prerelease | preminor | premajor ]\n"
- + "\n(run in package dir)\n"
- + "'npm -v' or 'npm --version' to print npm version "
- + "("+npm.version+")\n"
- + "'npm view <pkg> version' to view a package's "
- + "published version\n"
- + "'npm ls' to inspect current package/dependency versions"
+var semver = require('semver')
+var path = require('path')
+var fs = require('graceful-fs')
+var writeFileAtomic = require('write-file-atomic')
+var chain = require('slide').chain
+var log = require('npmlog')
+var npm = require('./npm.js')
+var git = require('./utils/git.js')
+var assert = require('assert')
+var lifecycle = require('./utils/lifecycle.js')
+
+version.usage = 'npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]' +
+ '\n(run in package dir)\n' +
+ "'npm -v' or 'npm --version' to print npm version " +
+ '(' + npm.version + ')\n' +
+ "'npm view <pkg> version' to view a package's " +
+ 'published version\n' +
+ "'npm ls' to inspect current package/dependency versions"
function version (args, silent, cb_) {
- if (typeof cb_ !== "function") cb_ = silent, silent = false
+ if (typeof cb_ !== 'function') {
+ cb_ = silent
+ silent = false
+ }
if (args.length > 1) return cb_(version.usage)
- var packagePath = path.join(npm.localPrefix, "package.json")
+ var packagePath = path.join(npm.localPrefix, 'package.json')
fs.readFile(packagePath, function (er, data) {
if (data) data = data.toString()
try {
data = JSON.parse(data)
- }
- catch (e) {
+ } catch (e) {
er = e
data = null
}
@@ -39,65 +41,82 @@ function version (args, silent, cb_) {
if (!args.length) return dump(data, cb_)
if (er) {
- log.error("version", "No valid package.json found")
+ log.error('version', 'No valid package.json found')
return cb_(er)
}
var newVersion = semver.valid(args[0])
if (!newVersion) newVersion = semver.inc(data.version, args[0])
if (!newVersion) return cb_(version.usage)
- if (data.version === newVersion) return cb_(new Error("Version not changed"))
+ if (data.version === newVersion) return cb_(new Error('Version not changed'))
data.version = newVersion
var lifecycleData = Object.create(data)
- lifecycleData._id = data.name + "@" + newVersion
+ lifecycleData._id = data.name + '@' + newVersion
+ var localData = {}
var where = npm.prefix
chain([
- [lifecycle, lifecycleData, "preversion", where]
- , [version_, data, silent]
- , [lifecycle, lifecycleData, "version", where]
- , [lifecycle, lifecycleData, "postversion", where] ]
- , cb_)
+ [checkGit, localData],
+ [lifecycle, lifecycleData, 'preversion', where],
+ [updatePackage, newVersion, silent],
+ [lifecycle, lifecycleData, 'version', where],
+ [commit, localData, newVersion],
+ [lifecycle, lifecycleData, 'postversion', where] ],
+ cb_)
})
}
-function version_ (data, silent, cb_) {
+function readPackage (cb) {
+ var packagePath = path.join(npm.localPrefix, 'package.json')
+ fs.readFile(packagePath, function (er, data) {
+ if (er) return cb(new Error(er))
+ if (data) data = data.toString()
+ try {
+ data = JSON.parse(data)
+ } catch (e) {
+ er = e
+ data = null
+ }
+ cb(er, data)
+ })
+}
+
+function updatePackage (newVersion, silent, cb_) {
function cb (er) {
- if (!er && !silent) console.log("v" + data.version)
+ if (!er && !silent) console.log('v' + newVersion)
cb_(er)
}
- checkGit(function (er, hasGit) {
+ readPackage(function (er, data) {
if (er) return cb(new Error(er))
+ data.version = newVersion
+ write(data, 'package.json', cb)
+ })
+}
- write(data, "package.json", function (er) {
- if (er) return cb(new Error(er))
-
- updateShrinkwrap(data.version, function (er, hasShrinkwrap) {
- if (er || !hasGit) return cb(er)
- commit(data.version, hasShrinkwrap, cb)
- })
- })
+function commit (localData, newVersion, cb) {
+ updateShrinkwrap(newVersion, function (er, hasShrinkwrap) {
+ if (er || !localData.hasGit) return cb(er)
+ _commit(newVersion, hasShrinkwrap, cb)
})
}
function updateShrinkwrap (newVersion, cb) {
- fs.readFile(path.join(npm.localPrefix, "npm-shrinkwrap.json"), function (er, data) {
- if (er && er.code === "ENOENT") return cb(null, false)
+ fs.readFile(path.join(npm.localPrefix, 'npm-shrinkwrap.json'), function (er, data) {
+ if (er && er.code === 'ENOENT') return cb(null, false)
try {
data = data.toString()
data = JSON.parse(data)
- }
- catch (er) {
- log.error("version", "Bad npm-shrinkwrap.json data")
+ } catch (er) {
+ log.error('version', 'Bad npm-shrinkwrap.json data')
return cb(er)
}
data.version = newVersion
- write(data, "npm-shrinkwrap.json", function (er) {
+ write(data, 'npm-shrinkwrap.json', function (er) {
if (er) {
- log.error("version", "Bad npm-shrinkwrap.json data")
+ log.error('version', 'Bad npm-shrinkwrap.json data')
return cb(er)
}
cb(null, true)
@@ -114,74 +133,76 @@ function dump (data, cb) {
v[k] = process.versions[k]
})
- if (npm.config.get("json")) v = JSON.stringify(v, null, 2)
+ if (npm.config.get('json')) v = JSON.stringify(v, null, 2)
console.log(v)
cb()
}
-function checkGit (cb) {
- fs.stat(path.join(npm.localPrefix, ".git"), function (er, s) {
- var doGit = !er && s.isDirectory() && npm.config.get("git-tag-version")
+function checkGit (localData, cb) {
+ fs.stat(path.join(npm.localPrefix, '.git'), function (er, s) {
+ var doGit = !er && s.isDirectory() && npm.config.get('git-tag-version')
if (!doGit) {
- if (er) log.verbose("version", "error checking for .git", er)
- log.verbose("version", "not tagging in git")
+ if (er) log.verbose('version', 'error checking for .git', er)
+ log.verbose('version', 'not tagging in git')
return cb(null, false)
}
// check for git
git.whichAndExec(
- [ "status", "--porcelain" ],
- { env : process.env },
+ [ 'status', '--porcelain' ],
+ { env: process.env },
function (er, stdout) {
- if (er && er.code === "ENOGIT") {
+ if (er && er.code === 'ENOGIT') {
log.warn(
- "version",
- "This is a Git checkout, but the git command was not found.",
- "npm could not create a Git tag for this release!"
+ 'version',
+ 'This is a Git checkout, but the git command was not found.',
+ 'npm could not create a Git tag for this release!'
)
return cb(null, false)
}
- var lines = stdout.trim().split("\n").filter(function (line) {
+ var lines = stdout.trim().split('\n').filter(function (line) {
return line.trim() && !line.match(/^\?\? /)
}).map(function (line) {
return line.trim()
})
- if (lines.length) return cb(new Error(
- "Git working directory not clean.\n"+lines.join("\n")
- ))
-
+ if (lines.length && !npm.config.get('force')) {
+ return cb(new Error(
+ 'Git working directory not clean.\n' + lines.join('\n')
+ ))
+ }
+ localData.hasGit = true
cb(null, true)
}
)
})
}
-function commit (version, hasShrinkwrap, cb) {
- var options = { env : process.env }
- var message = npm.config.get("message").replace(/%s/g, version)
- var sign = npm.config.get("sign-git-tag")
- var flag = sign ? "-sm" : "-am"
+function _commit (version, hasShrinkwrap, cb) {
+ var options = { env: process.env }
+ var message = npm.config.get('message').replace(/%s/g, version)
+ var sign = npm.config.get('sign-git-tag')
+ var flag = sign ? '-sm' : '-am'
chain(
[
- git.chainableExec([ "add", "package.json" ], options),
- hasShrinkwrap && git.chainableExec([ "add", "npm-shrinkwrap.json" ] , options),
- git.chainableExec([ "commit", "-m", message ], options),
- git.chainableExec([ "tag", npm.config.get("tag-version-prefix") + version, flag, message ], options)
+ git.chainableExec([ 'add', 'package.json' ], options),
+ hasShrinkwrap && git.chainableExec([ 'add', 'npm-shrinkwrap.json' ], options),
+ git.chainableExec([ 'commit', '-m', message ], options),
+ git.chainableExec([ 'tag', npm.config.get('tag-version-prefix') + version, flag, message ], options)
],
cb
)
}
function write (data, file, cb) {
- assert(data && typeof data === "object", "must pass data to version write")
- assert(typeof file === "string", "must pass filename to write to version write")
+ assert(data && typeof data === 'object', 'must pass data to version write')
+ assert(typeof file === 'string', 'must pass filename to write to version write')
- log.verbose("version.write", "data", data, "to", file)
+ log.verbose('version.write', 'data', data, 'to', file)
writeFileAtomic(
path.join(npm.localPrefix, file),
- new Buffer(JSON.stringify(data, null, 2) + "\n"),
+ new Buffer(JSON.stringify(data, null, 2) + '\n'),
cb
)
}