diff options
author | Rebecca Turner <me@re-becca.org> | 2015-10-29 16:50:12 -0700 |
---|---|---|
committer | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2015-11-02 14:25:04 -0500 |
commit | 507fc53e37d3fc6abb5ce0f7c46c8d7479e647ab (patch) | |
tree | 68ea2bbf0733eb1a1977b899040e18d035737a51 /deps/npm/lib/utils | |
parent | 6e40bf065931e20737875b27ab9ee71eaf5c7f99 (diff) | |
download | android-node-v8-507fc53e37d3fc6abb5ce0f7c46c8d7479e647ab.tar.gz android-node-v8-507fc53e37d3fc6abb5ce0f7c46c8d7479e647ab.tar.bz2 android-node-v8-507fc53e37d3fc6abb5ce0f7c46c8d7479e647ab.zip |
deps: upgrade npm to 3.3.10
PR-URL: https://github.com/nodejs/node/pull/3599
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'deps/npm/lib/utils')
-rw-r--r-- | deps/npm/lib/utils/child-path.js | 10 | ||||
-rw-r--r-- | deps/npm/lib/utils/completion/installed-deep.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/utils/error-handler.js | 577 | ||||
-rw-r--r-- | deps/npm/lib/utils/lifecycle.js | 18 | ||||
-rw-r--r-- | deps/npm/lib/utils/module-name.js | 33 | ||||
-rw-r--r-- | deps/npm/lib/utils/package-id.js | 15 | ||||
-rw-r--r-- | deps/npm/lib/utils/tar.js | 14 |
7 files changed, 360 insertions, 309 deletions
diff --git a/deps/npm/lib/utils/child-path.js b/deps/npm/lib/utils/child-path.js new file mode 100644 index 0000000000..4594f43221 --- /dev/null +++ b/deps/npm/lib/utils/child-path.js @@ -0,0 +1,10 @@ +'use strict' +var path = require('path') +var validate = require('aproba') +var moduleName = require('../utils/module-name.js') + +module.exports = childPath +function childPath (parentPath, child) { + validate('SO', arguments) + return path.join(parentPath, 'node_modules', moduleName(child)) +} diff --git a/deps/npm/lib/utils/completion/installed-deep.js b/deps/npm/lib/utils/completion/installed-deep.js index 146a4d7908..dc9bfbee8a 100644 --- a/deps/npm/lib/utils/completion/installed-deep.js +++ b/deps/npm/lib/utils/completion/installed-deep.js @@ -49,6 +49,4 @@ function installedDeep (opts, cb) { var names = local.concat(global) return cb(null, names) } - } - diff --git a/deps/npm/lib/utils/error-handler.js b/deps/npm/lib/utils/error-handler.js index cd61f79129..8a7b1c06da 100644 --- a/deps/npm/lib/utils/error-handler.js +++ b/deps/npm/lib/utils/error-handler.js @@ -171,316 +171,317 @@ function errorHandler (er) { if (log.levels[log.level] <= log.levels.error) console.error('') switch (er.code) { - case 'ECONNREFUSED': - log.error('', er) - log.error( - '', - [ - '\nIf you are behind a proxy, please make sure that the', - "'proxy' config is set properly. See: 'npm help config'" - ].join('\n') - ) - break - - case 'EACCES': - case 'EPERM': - log.error('', er) - log.error('', ['\nPlease try running this command again as root/Administrator.' - ].join('\n')) - break - - case 'ELIFECYCLE': - log.error('', er.message) - log.error( - '', - [ + case 'ECONNREFUSED': + log.error('', er) + log.error( '', - 'Failed at the ' + er.pkgid + ' ' + er.stage + " script '" + er.script + "'.", - 'This is most likely a problem with the ' + er.pkgname + ' package,', - 'not with npm itself.', - 'Tell the author that this fails on your system:', - ' ' + er.script, - 'You can get their info via:', - ' npm owner ls ' + er.pkgname, - 'There is likely additional logging output above.' - ].join('\n') - ) - break - - case 'ENOGIT': - log.error('', er.message) - log.error( - '', - [ + [ + '\nIf you are behind a proxy, please make sure that the', + "'proxy' config is set properly. See: 'npm help config'" + ].join('\n') + ) + break + + case 'EACCES': + case 'EPERM': + log.error('', er) + log.error('', ['\nPlease try running this command again as root/Administrator.' + ].join('\n')) + break + + case 'ELIFECYCLE': + log.error('', er.message) + log.error( '', - 'Failed using git.', - 'This is most likely not a problem with npm itself.', - 'Please check if you have git installed and in your PATH.' - ].join('\n') - ) - break - - case 'EJSONPARSE': - log.error('', er.message) - log.error('', 'File: ' + er.file) - log.error( - '', - [ - 'Failed to parse package.json data.', - 'package.json must be actual JSON, not just JavaScript.', + [ + '', + 'Failed at the ' + er.pkgid + ' ' + er.stage + " script '" + er.script + "'.", + 'Make sure you have the latest version of node.js and npm installed.', + 'If you do, this is most likely a problem with the ' + er.pkgname + ' package,', + 'not with npm itself.', + 'Tell the author that this fails on your system:', + ' ' + er.script, + 'You can get their info via:', + ' npm owner ls ' + er.pkgname, + 'There is likely additional logging output above.' + ].join('\n') + ) + break + + case 'ENOGIT': + log.error('', er.message) + log.error( '', - 'This is not a bug in npm.', - 'Tell the package author to fix their package.json file.' - ].join('\n'), - 'JSON.parse' - ) - break + [ + '', + 'Failed using git.', + 'This is most likely not a problem with npm itself.', + 'Please check if you have git installed and in your PATH.' + ].join('\n') + ) + break + + case 'EJSONPARSE': + log.error('', er.message) + log.error('', 'File: ' + er.file) + log.error( + '', + [ + 'Failed to parse package.json data.', + 'package.json must be actual JSON, not just JavaScript.', + '', + 'This is not a bug in npm.', + 'Tell the package author to fix their package.json file.' + ].join('\n'), + 'JSON.parse' + ) + break - // TODO(isaacs) - // Add a special case here for E401 and E403 explaining auth issues? + // TODO(isaacs) + // Add a special case here for E401 and E403 explaining auth issues? - case 'E404': - var msg = [er.message] - if (er.pkgid && er.pkgid !== '-') { - msg.push('', "'" + er.pkgid + "' is not in the npm registry.") + case 'E404': + var msg = [er.message] + if (er.pkgid && er.pkgid !== '-') { + msg.push('', "'" + er.pkgid + "' is not in the npm registry.") - var valResult = nameValidator(er.pkgid) + var valResult = nameValidator(er.pkgid) - if (valResult.validForNewPackages) { - msg.push('You should bug the author to publish it (or use the name yourself!)') - } else { - msg.push('Your package name is not valid, because', '') + if (valResult.validForNewPackages) { + msg.push('You should bug the author to publish it (or use the name yourself!)') + } else { + msg.push('Your package name is not valid, because', '') - var errorsArray = (valResult.errors || []).concat(valResult.warnings || []) - errorsArray.forEach(function (item, idx) { - msg.push(' ' + (idx + 1) + '. ' + item) - }) + var errorsArray = (valResult.errors || []).concat(valResult.warnings || []) + errorsArray.forEach(function (item, idx) { + msg.push(' ' + (idx + 1) + '. ' + item) + }) + } + + if (er.parent) { + msg.push("It was specified as a dependency of '" + er.parent + "'") + } + msg.push( + '\nNote that you can also install from a', + 'tarball, folder, http url, or git url.' + ) } + // There's no need to have 404 in the message as well. + msg[0] = msg[0].replace(/^404\s+/, '') + log.error('404', msg.join('\n')) + break - if (er.parent) { - msg.push("It was specified as a dependency of '" + er.parent + "'") - } - msg.push( - '\nNote that you can also install from a', - 'tarball, folder, http url, or git url.' + case 'EPUBLISHCONFLICT': + log.error( + 'publish fail', + [ + 'Cannot publish over existing version.', + "Update the 'version' field in package.json and try again.", + '', + 'To automatically increment version numbers, see:', + ' npm help version' + ].join('\n') ) - } - // There's no need to have 404 in the message as well. - msg[0] = msg[0].replace(/^404\s+/, '') - log.error('404', msg.join('\n')) - break - - case 'EPUBLISHCONFLICT': - log.error( - 'publish fail', - [ - 'Cannot publish over existing version.', - "Update the 'version' field in package.json and try again.", - '', - 'To automatically increment version numbers, see:', - ' npm help version' - ].join('\n') - ) - break - - case 'EISGIT': - log.error( - 'git', - [ - er.message, - ' ' + er.path, - 'Refusing to remove it. Update manually,', - 'or move it out of the way first.' - ].join('\n') - ) - break - - case 'ECYCLE': - log.error( - 'cycle', - [ - er.message, - 'While installing: ' + er.pkgid, - 'Found a pathological dependency case that npm cannot solve.', - 'Please report this to the package author.' - ].join('\n') - ) - break - - case 'EBADPLATFORM': - log.error( - 'notsup', - [ - er.message, - 'Not compatible with your operating system or architecture: ' + er.pkgid, - 'Valid OS: ' + er.os.join(','), - 'Valid Arch: ' + er.cpu.join(','), - 'Actual OS: ' + process.platform, - 'Actual Arch: ' + process.arch - ].join('\n') - ) - break - - case 'EEXIST': - log.error( - [ - er.message, - 'File exists: ' + er.path, - 'Move it away, and try again.' - ].join('\n') - ) - break - - case 'ENEEDAUTH': - log.error( - 'need auth', - [ - er.message, - 'You need to authorize this machine using `npm adduser`' - ].join('\n') - ) - break - - case 'EPEERINVALID': - var peerErrors = Object.keys(er.peersDepending).map(function (peer) { - return 'Peer ' + peer + ' wants ' + - er.packageName + '@' + er.peersDepending[peer] - }) - log.error('peerinvalid', [er.message].concat(peerErrors).join('\n')) - break - - case 'ECONNRESET': - case 'ENOTFOUND': - case 'ETIMEDOUT': - case 'EAI_FAIL': - log.error( - 'network', - [ - er.message, - 'This is most likely not a problem with npm itself', - 'and is related to network connectivity.', - 'In most cases you are behind a proxy or have bad network settings.', - '\nIf you are behind a proxy, please make sure that the', - "'proxy' config is set properly. See: 'npm help config'" - ].join('\n') - ) - break - - case 'ENOPACKAGEJSON': - log.error( - 'package.json', - [ - er.message, - 'This is most likely not a problem with npm itself.', - "npm can't find a package.json file in your current directory." - ].join('\n') - ) - break - - case 'ETARGET': - msg = [ - er.message, - 'This is most likely not a problem with npm itself.', - 'In most cases you or one of your dependencies are requesting', - "a package version that doesn't exist." - ] - if (er.parent) { - msg.push("\nIt was specified as a dependency of '" + er.parent + "'\n") - } - log.error('notarget', msg.join('\n')) - break + break - case 'ENOTSUP': - if (er.required) { + case 'EISGIT': + log.error( + 'git', + [ + er.message, + ' ' + er.path, + 'Refusing to remove it. Update manually,', + 'or move it out of the way first.' + ].join('\n') + ) + break + + case 'ECYCLE': + log.error( + 'cycle', + [ + er.message, + 'While installing: ' + er.pkgid, + 'Found a pathological dependency case that npm cannot solve.', + 'Please report this to the package author.' + ].join('\n') + ) + break + + case 'EBADPLATFORM': log.error( 'notsup', [ er.message, - 'Not compatible with your version of node/npm: ' + er.pkgid, - 'Required: ' + JSON.stringify(er.required), - 'Actual: ' + JSON.stringify({ - npm: npm.version, - node: npm.config.get('node-version') - }) + 'Not compatible with your operating system or architecture: ' + er.pkgid, + 'Valid OS: ' + er.os.join(','), + 'Valid Arch: ' + er.cpu.join(','), + 'Actual OS: ' + process.platform, + 'Actual Arch: ' + process.arch ].join('\n') ) break - } // else passthrough - /*eslint no-fallthrough:0*/ - case 'ENOSPC': - log.error( - 'nospc', - [ - er.message, - 'This is most likely not a problem with npm itself', - 'and is related to insufficient space on your system.' - ].join('\n') - ) - break - - case 'EROFS': - log.error( - 'rofs', - [ - er.message, - 'This is most likely not a problem with npm itself', - 'and is related to the file system being read-only.', - '\nOften virtualized file systems, or other file systems', - "that don't support symlinks, give this error." - ].join('\n') - ) - break - - case 'ENOENT': - log.error( - 'enoent', - [ - er.message, - 'This is most likely not a problem with npm itself', - 'and is related to npm not being able to find a file.', - er.file ? "\nCheck if the file '" + er.file + "' is present." : '' - ].join('\n') - ) - break - - case 'EMISSINGARG': - case 'EUNKNOWNTYPE': - case 'EINVALIDTYPE': - case 'ETOOMANYARGS': - log.error( - 'typeerror', - [ - er.stack, - 'This is an error with npm itself. Please report this error at:', - ' <http://github.com/npm/npm/issues>' - ].join('\n') - ) - break - - case 'EISDIR': - log.error( - 'eisdir', - [ + case 'EEXIST': + log.error( + [ + er.message, + 'File exists: ' + er.path, + 'Move it away, and try again.' + ].join('\n') + ) + break + + case 'ENEEDAUTH': + log.error( + 'need auth', + [ + er.message, + 'You need to authorize this machine using `npm adduser`' + ].join('\n') + ) + break + + case 'EPEERINVALID': + var peerErrors = Object.keys(er.peersDepending).map(function (peer) { + return 'Peer ' + peer + ' wants ' + + er.packageName + '@' + er.peersDepending[peer] + }) + log.error('peerinvalid', [er.message].concat(peerErrors).join('\n')) + break + + case 'ECONNRESET': + case 'ENOTFOUND': + case 'ETIMEDOUT': + case 'EAI_FAIL': + log.error( + 'network', + [ + er.message, + 'This is most likely not a problem with npm itself', + 'and is related to network connectivity.', + 'In most cases you are behind a proxy or have bad network settings.', + '\nIf you are behind a proxy, please make sure that the', + "'proxy' config is set properly. See: 'npm help config'" + ].join('\n') + ) + break + + case 'ENOPACKAGEJSON': + log.error( + 'package.json', + [ + er.message, + 'This is most likely not a problem with npm itself.', + "npm can't find a package.json file in your current directory." + ].join('\n') + ) + break + + case 'ETARGET': + msg = [ er.message, - 'This is most likely not a problem with npm itself', - 'and is related to npm not being able to find a package.json in', - 'a package you are trying to install.' - ].join('\n') - ) - break - - default: - log.error('', er.message || er) - log.error( - '', - [ + 'This is most likely not a problem with npm itself.', + 'In most cases you or one of your dependencies are requesting', + "a package version that doesn't exist." + ] + if (er.parent) { + msg.push("\nIt was specified as a dependency of '" + er.parent + "'\n") + } + log.error('notarget', msg.join('\n')) + break + + case 'ENOTSUP': + if (er.required) { + log.error( + 'notsup', + [ + er.message, + 'Not compatible with your version of node/npm: ' + er.pkgid, + 'Required: ' + JSON.stringify(er.required), + 'Actual: ' + JSON.stringify({ + npm: npm.version, + node: npm.config.get('node-version') + }) + ].join('\n') + ) + break + } // else passthrough + /*eslint no-fallthrough:0*/ + + case 'ENOSPC': + log.error( + 'nospc', + [ + er.message, + 'This is most likely not a problem with npm itself', + 'and is related to insufficient space on your system.' + ].join('\n') + ) + break + + case 'EROFS': + log.error( + 'rofs', + [ + er.message, + 'This is most likely not a problem with npm itself', + 'and is related to the file system being read-only.', + '\nOften virtualized file systems, or other file systems', + "that don't support symlinks, give this error." + ].join('\n') + ) + break + + case 'ENOENT': + log.error( + 'enoent', + [ + er.message, + 'This is most likely not a problem with npm itself', + 'and is related to npm not being able to find a file.', + er.file ? "\nCheck if the file '" + er.file + "' is present." : '' + ].join('\n') + ) + break + + case 'EMISSINGARG': + case 'EUNKNOWNTYPE': + case 'EINVALIDTYPE': + case 'ETOOMANYARGS': + log.error( + 'typeerror', + [ + er.stack, + 'This is an error with npm itself. Please report this error at:', + ' <http://github.com/npm/npm/issues>' + ].join('\n') + ) + break + + case 'EISDIR': + log.error( + 'eisdir', + [ + er.message, + 'This is most likely not a problem with npm itself', + 'and is related to npm not being able to find a package.json in', + 'a package you are trying to install.' + ].join('\n') + ) + break + + default: + log.error('', er.message || er) + log.error( '', - 'If you need help, you may report this error at:', - ' <https://github.com/npm/npm/issues>' - ].join('\n') - ) - break + [ + '', + 'If you need help, you may report this error at:', + ' <https://github.com/npm/npm/issues>' + ].join('\n') + ) + break } exit(typeof er.errno === 'number' ? er.errno : 1) diff --git a/deps/npm/lib/utils/lifecycle.js b/deps/npm/lib/utils/lifecycle.js index 1c0d437a90..e2ec37c241 100644 --- a/deps/npm/lib/utils/lifecycle.js +++ b/deps/npm/lib/utils/lifecycle.js @@ -189,7 +189,6 @@ function runCmd (note, cmd, pkg, env, stage, wd, unsafe, cb) { } function runCmd_ (cmd, pkg, env, wd, stage, unsafe, uid, gid, cb_) { - function cb (er) { cb_.apply(null, arguments) log.resume() @@ -237,7 +236,7 @@ function runCmd_ (cmd, pkg, env, wd, stage, unsafe, uid, gid, cb_) { function procError (er) { if (progressEnabled) log.enableProgress() - if (er && !npm.ROLLBACK) { + if (er) { log.info('lifecycle', logid(pkg, stage), 'Failed to exec ' + stage + ' script') er.message = pkg._id + ' ' + stage + ': `' + cmd + '`\n' + er.message @@ -248,13 +247,8 @@ function runCmd_ (cmd, pkg, env, wd, stage, unsafe, uid, gid, cb_) { er.stage = stage er.script = cmd er.pkgname = pkg.name - return cb(er) - } else if (er) { - log.error('lifecycle', logid(pkg, stage), er) - log.error('lifecycle', logid(pkg, stage), 'continuing anyway') - return cb() } - cb(er) + return cb(er) } } @@ -285,7 +279,6 @@ function makeEnv (data, prefix, env) { // express and others respect the NODE_ENV value. if (npm.config.get('production')) env.NODE_ENV = 'production' - } else if (!data.hasOwnProperty('_lifecycleEnv')) { Object.defineProperty(data, '_lifecycleEnv', { @@ -317,11 +310,10 @@ function makeEnv (data, prefix, env) { } } else { env[envKey] = String(data[i]) - env[envKey] = env[envKey].indexOf('\n') !== -1 ? - JSON.stringify(env[envKey]) : - env[envKey] + env[envKey] = env[envKey].indexOf('\n') !== -1 + ? JSON.stringify(env[envKey]) + : env[envKey] } - } if (prefix !== 'npm_package_') return env diff --git a/deps/npm/lib/utils/module-name.js b/deps/npm/lib/utils/module-name.js new file mode 100644 index 0000000000..7ca175487c --- /dev/null +++ b/deps/npm/lib/utils/module-name.js @@ -0,0 +1,33 @@ +'use strict' +var path = require('path') +var validate = require('aproba') + +module.exports = moduleName +module.exports.test = {} + +module.exports.test.pathToPackageName = pathToPackageName +function pathToPackageName (dir) { + if (dir == null) return '' + if (dir === '') return '' + var name = path.relative(path.resolve(dir, '..'), dir) + var scoped = path.relative(path.resolve(dir, '../..'), dir) + if (scoped[0] === '@') return scoped + return name +} + +module.exports.test.isNotEmpty = isNotEmpty +function isNotEmpty (str) { + return str != null && str !== '' +} + +var unknown = 0 +function moduleName (tree) { + validate('O', arguments) + var pkg = tree.package || tree + if (isNotEmpty(pkg.name)) return pkg.name + var pkgName = pathToPackageName(tree.path) + if (pkgName !== '') return pkgName + if (tree._invalidName != null) return tree._invalidName + tree._invalidName = '!invalid#' + (++unknown) + return tree._invalidName +} diff --git a/deps/npm/lib/utils/package-id.js b/deps/npm/lib/utils/package-id.js new file mode 100644 index 0000000000..2c5e331469 --- /dev/null +++ b/deps/npm/lib/utils/package-id.js @@ -0,0 +1,15 @@ +'use strict' +var moduleName = require('./module-name.js') + +module.exports = function (tree) { + var pkg = tree.package || tree + // FIXME: Excluding the '@' here is cleaning up after the mess that + // read-package-json makes. =( + if (pkg._id && pkg._id !== '@') return pkg._id + var name = moduleName(tree) + if (pkg.version) { + return name + '@' + pkg.version + } else { + return name + } +} diff --git a/deps/npm/lib/utils/tar.js b/deps/npm/lib/utils/tar.js index 5b20160ea5..8eb2311d09 100644 --- a/deps/npm/lib/utils/tar.js +++ b/deps/npm/lib/utils/tar.js @@ -21,6 +21,8 @@ var myGid = process.getgid && process.getgid() var readPackageTree = require('read-package-tree') var union = require('lodash.union') var flattenTree = require('../install/flatten-tree.js') +var moduleName = require('./module-name.js') +var packageId = require('./package-id.js') if (process.env.SUDO_UID && myUid === 0) { if (!isNaN(process.env.SUDO_UID)) myUid = +process.env.SUDO_UID @@ -133,7 +135,7 @@ BundledPacker.prototype.applyIgnores = function (entry, partial, entryObj) { return Packer.prototype.applyIgnores.call(this, entry, partial, entryObj) } -function nameMatch (name) { return function (other) { return name === other.package.name } } +function nameMatch (name) { return function (other) { return name === moduleName(other) } } function pack_ (tarball, folder, tree, flatTree, pkg, cb) { function InstancePacker (props) { @@ -145,7 +147,7 @@ function pack_ (tarball, folder, tree, flatTree, pkg, cb) { if (!bd) return false if (!Array.isArray(bd)) { - throw new Error(this.package.name + '\'s `bundledDependencies` should ' + + throw new Error(packageId(this) + '\'s `bundledDependencies` should ' + 'be an array') } if (!tree) return false @@ -161,7 +163,7 @@ function pack_ (tarball, folder, tree, flatTree, pkg, cb) { seen[req] = true var reqPkg = flatTree[req] if (!reqPkg) continue - if (reqPkg.parent === tree && bd.indexOf(reqPkg.package.name) !== -1) { + if (reqPkg.parent === tree && bd.indexOf(moduleName(reqPkg)) !== -1) { return true } requiredBy = union(requiredBy, reqPkg.package._requiredBy) @@ -233,9 +235,9 @@ function unpack_ (tarball, unpackTarget, dMode, fMode, uid, gid, cb) { dMode, fMode, uid, gid, function (er, folder) { - if (er) return cb(er) - readJson(path.resolve(folder, 'package.json'), cb) - }) + if (er) return cb(er) + readJson(path.resolve(folder, 'package.json'), cb) + }) }) } |