diff options
author | Kat Marchán <kzm@sykosomatic.org> | 2017-06-05 16:31:14 -0700 |
---|---|---|
committer | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2017-06-06 14:27:48 -0400 |
commit | a4444c546211cac0f5efba8b03a681546e3e184f (patch) | |
tree | a378b37fefd4fac786850c41f32eee8d07e339c7 /deps/npm/lib | |
parent | df46fcb61a6f64cebffd26c8dbd4f24c8058fe25 (diff) | |
download | node-new-a4444c546211cac0f5efba8b03a681546e3e184f.tar.gz |
deps: upgrade npm to 5.0.3
PR-URL: https://github.com/nodejs/node/pull/13487
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'deps/npm/lib')
-rw-r--r-- | deps/npm/lib/build.js | 3 | ||||
-rw-r--r-- | deps/npm/lib/config/pacote.js | 8 | ||||
-rw-r--r-- | deps/npm/lib/config/reg-client.js | 29 | ||||
-rw-r--r-- | deps/npm/lib/doctor.js | 6 | ||||
-rw-r--r-- | deps/npm/lib/doctor/check-files-permission.js | 6 | ||||
-rw-r--r-- | deps/npm/lib/init.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/install.js | 5 | ||||
-rw-r--r-- | deps/npm/lib/install/action/finalize.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/install/action/prepare.js | 4 | ||||
-rw-r--r-- | deps/npm/lib/install/inflate-bundled.js | 4 | ||||
-rw-r--r-- | deps/npm/lib/install/inflate-shrinkwrap.js | 6 | ||||
-rw-r--r-- | deps/npm/lib/ls.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/npm.js | 30 | ||||
-rw-r--r-- | deps/npm/lib/pack.js | 4 | ||||
-rw-r--r-- | deps/npm/lib/test.js | 8 | ||||
-rw-r--r-- | deps/npm/lib/utils/error-handler.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/utils/get-publish-config.js | 16 | ||||
-rw-r--r-- | deps/npm/lib/utils/module-name.js | 2 |
18 files changed, 82 insertions, 57 deletions
diff --git a/deps/npm/lib/build.js b/deps/npm/lib/build.js index 5dd243a795..c2acc00662 100644 --- a/deps/npm/lib/build.js +++ b/deps/npm/lib/build.js @@ -79,7 +79,8 @@ var writeBuiltinConf = build.writeBuiltinConf = function (pkg, folder, cb) { var parent = path.dirname(folder) var dir = npm.globalDir - if (pkg.name !== 'npm' || + // Make this count for canary, too + if ((pkg.name !== 'npm' && pkg.name !== 'npmc') || !npm.config.get('global') || !npm.config.usingBuiltin || dir !== parent) { diff --git a/deps/npm/lib/config/pacote.js b/deps/npm/lib/config/pacote.js index 705544fe3c..2d2dda59fa 100644 --- a/deps/npm/lib/config/pacote.js +++ b/deps/npm/lib/config/pacote.js @@ -2,6 +2,7 @@ const Buffer = require('safe-buffer').Buffer +const crypto = require('crypto') const npm = require('../npm') const log = require('npmlog') let pack @@ -9,6 +10,9 @@ const path = require('path') let effectiveOwner +const npmSession = crypto.randomBytes(8).toString('hex') +log.verbose('npm-session', npmSession) + module.exports = pacoteOpts function pacoteOpts (moreOpts) { if (!pack) { @@ -17,13 +21,17 @@ function pacoteOpts (moreOpts) { const ownerStats = calculateOwner() const opts = { cache: path.join(npm.config.get('cache'), '_cacache'), + ca: npm.config.get('ca'), + cert: npm.config.get('cert'), defaultTag: npm.config.get('tag'), dirPacker: pack.packGitDep, hashAlgorithm: 'sha1', + key: npm.config.get('key'), localAddress: npm.config.get('local-address'), log: log, maxAge: npm.config.get('cache-min'), maxSockets: npm.config.get('maxsockets'), + npmSession: npmSession, offline: npm.config.get('offline'), preferOffline: npm.config.get('prefer-offline') || npm.config.get('cache-min') > 9999, preferOnline: npm.config.get('prefer-online') || npm.config.get('cache-max') <= 0, diff --git a/deps/npm/lib/config/reg-client.js b/deps/npm/lib/config/reg-client.js new file mode 100644 index 0000000000..d4e2417097 --- /dev/null +++ b/deps/npm/lib/config/reg-client.js @@ -0,0 +1,29 @@ +'use strict' + +module.exports = regClientConfig +function regClientConfig (npm, log, config) { + return { + proxy: { + http: config.get('proxy'), + https: config.get('https-proxy'), + localAddress: config.get('local-address') + }, + ssl: { + certificate: config.get('cert'), + key: config.get('key'), + ca: config.get('ca'), + strict: config.get('strict-ssl') + }, + retry: { + retries: config.get('fetch-retries'), + factor: config.get('fetch-retry-factor'), + minTimeout: config.get('fetch-retry-mintimeout'), + maxTimeout: config.get('fetch-retry-maxtimeout') + }, + userAgent: config.get('user-agent'), + log: log, + defaultTag: config.get('tag'), + maxSockets: config.get('maxsockets'), + scope: npm.projectScope + } +} diff --git a/deps/npm/lib/doctor.js b/deps/npm/lib/doctor.js index 357ba91a5a..95ede1bc87 100644 --- a/deps/npm/lib/doctor.js +++ b/deps/npm/lib/doctor.js @@ -39,9 +39,9 @@ function doctor (args, silent, cb) { [getLatestNpmVersion], [getLatestNodejsVersion, args['node-url']], [getGitPath], - [checkFilesPermission, npm.cache, 6], - [checkFilesPermission, globalNodeModules, 4], - [checkFilesPermission, localNodeModules, 6], + [checkFilesPermission, npm.cache, 4, 6], + [checkFilesPermission, globalNodeModules, 4, 4], + [checkFilesPermission, localNodeModules, 6, 6], [verifyCachedFiles, path.join(npm.cache, '_cacache')] ] diff --git a/deps/npm/lib/doctor/check-files-permission.js b/deps/npm/lib/doctor/check-files-permission.js index 50014fd232..1cefb6e64c 100644 --- a/deps/npm/lib/doctor/check-files-permission.js +++ b/deps/npm/lib/doctor/check-files-permission.js @@ -6,7 +6,7 @@ var log = require('npmlog') var npm = require('../npm.js') var fileCompletion = require('../utils/completion/file-completion.js') -function checkFilesPermission (root, mask, cb) { +function checkFilesPermission (root, fmask, dmask, cb) { if (process.platform === 'win32') return cb(null, true) getUid(npm.config.get('user'), npm.config.get('group'), function (e, uid, gid) { var tracker = log.newItem('checkFilePermissions', 1) @@ -37,10 +37,10 @@ function checkFilesPermission (root, mask, cb) { fs.lstat(file, function (e, stat) { tracker.completeWork(1) if (e) return next(e) - if (!stat.isFile()) return next() + if (!stat.isDirectory() && !stat.isFile()) return next() // 6 = fs.constants.R_OK | fs.constants.W_OK // constants aren't available on v4 - fs.access(file, 6, (err) => { + fs.access(file, stat.isFile() ? fmask : dmask, (err) => { if (err) { tracker.error('checkFilePermissions', `Missing permissions on ${file}`) return next(new Error('Missing permissions for ' + file)) diff --git a/deps/npm/lib/init.js b/deps/npm/lib/init.js index df5615e476..000fa1a5b6 100644 --- a/deps/npm/lib/init.js +++ b/deps/npm/lib/init.js @@ -22,7 +22,7 @@ function init (args, cb) { 'See `npm help json` for definitive documentation on these fields', 'and exactly what they do.', '', - 'Use `npm install <pkg> --save` afterwards to install a package and', + 'Use `npm install <pkg>` afterwards to install a package and', 'save it as a dependency in the package.json file.', '', 'Press ^C at any time to quit.' diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js index 5d111b32c8..67dcf98b70 100644 --- a/deps/npm/lib/install.js +++ b/deps/npm/lib/install.js @@ -741,6 +741,11 @@ Installer.prototype.printInstalledForHuman = function (diffs, cb) { } }) var report = '' + if (this.args.length && (added || updated)) { + report += this.args.map((p) => { + return `+ ${p.name}@${p.version}` + }).join('\n') + '\n' + } var actions = [] if (added) actions.push('added ' + packages(added)) if (removed) actions.push('removed ' + packages(removed)) diff --git a/deps/npm/lib/install/action/finalize.js b/deps/npm/lib/install/action/finalize.js index ba38e602f8..ded2350dff 100644 --- a/deps/npm/lib/install/action/finalize.js +++ b/deps/npm/lib/install/action/finalize.js @@ -90,6 +90,6 @@ module.exports = function (staging, pkg, log) { module.exports.rollback = function (top, staging, pkg, next) { const requested = pkg.package._requested || getRequested(pkg) - if (requested.type === 'directory') return next() + if (requested && requested.type === 'directory') return next() gentlyRm(pkg.realpath, false, top, next) } diff --git a/deps/npm/lib/install/action/prepare.js b/deps/npm/lib/install/action/prepare.js index 771a2a9399..5e4333a5b5 100644 --- a/deps/npm/lib/install/action/prepare.js +++ b/deps/npm/lib/install/action/prepare.js @@ -11,8 +11,8 @@ module.exports = function (staging, pkg, log, next) { // see https://github.com/npm/npm/issues/10074 for details if (pkg.package && pkg.package.scripts && pkg.package.scripts.prepublish) { prepublishWarning([ - 'As of npm@5, `prepublish` scripts will run only for `npm publish`.', - '(In npm@4 and previous versions, it also runs for `npm install`.)', + 'As of npm@5, `prepublish` scripts are deprecated.', + 'Use `prepare` for build steps and `prepublishOnly` for upload-only.', 'See the deprecation note in `npm help scripts` for more information.' ]) } diff --git a/deps/npm/lib/install/inflate-bundled.js b/deps/npm/lib/install/inflate-bundled.js index 70da583df4..66bbb44a33 100644 --- a/deps/npm/lib/install/inflate-bundled.js +++ b/deps/npm/lib/install/inflate-bundled.js @@ -1,11 +1,11 @@ 'use strict' -var validate = require('aproba') + var childPath = require('../utils/child-path.js') var reset = require('./node.js').reset module.exports = function inflateBundled (bundler, parent, children) { - validate('OOA', arguments) children.forEach(function (child) { + if (child.fromBundle === bundler) return reset(child) child.fromBundle = bundler child.isInLink = bundler.isLink diff --git a/deps/npm/lib/install/inflate-shrinkwrap.js b/deps/npm/lib/install/inflate-shrinkwrap.js index 8cb75626bb..7ad966ea0a 100644 --- a/deps/npm/lib/install/inflate-shrinkwrap.js +++ b/deps/npm/lib/install/inflate-shrinkwrap.js @@ -19,13 +19,13 @@ module.exports = function (tree, swdeps, opts, finishInflating) { fetchPackageMetadata = BB.promisify(require('../fetch-package-metadata.js')) addBundled = BB.promisify(fetchPackageMetadata.addBundled) } - if (!npm.config.get('shrinkwrap') || !npm.config.get('package-lock')) { - return finishInflating() - } if (arguments.length === 3) { finishInflating = opts opts = {} } + if (!npm.config.get('shrinkwrap') || !npm.config.get('package-lock')) { + return finishInflating() + } tree.loaded = true return inflateShrinkwrap(tree.path, tree, swdeps, opts).then( () => finishInflating(), diff --git a/deps/npm/lib/ls.js b/deps/npm/lib/ls.js index b993dd6235..3e2f2ce8fa 100644 --- a/deps/npm/lib/ls.js +++ b/deps/npm/lib/ls.js @@ -429,7 +429,7 @@ function makeArchy_ (data, long, dir, depth, parent, d) { if (long) { if (dir === data.path) out.label += '\n' + dir - out.label += '\n' + getExtras(data, dir) + out.label += '\n' + getExtras(data) } else if (dir === data.path) { if (out.label) out.label += ' ' out.label += dir diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js index dbd8e97150..990d8c5109 100644 --- a/deps/npm/lib/npm.js +++ b/deps/npm/lib/npm.js @@ -33,6 +33,7 @@ var rimraf = require('rimraf') var lazyProperty = require('lazy-property') var parseJSON = require('./utils/parse-json.js') + var clientConfig = require('./config/reg-client.js') var aliases = require('./config/cmd-list').aliases var cmdList = require('./config/cmd-list').cmdList var plumbing = require('./config/cmd-list').plumbing @@ -344,7 +345,7 @@ lazyProperty(npm, 'registry', function () { registryLoaded = true var RegClient = require('npm-registry-client') - var registry = new RegClient(adaptClientConfig(npm.config)) + var registry = new RegClient(clientConfig(npm, log, npm.config)) registry.version = npm.version registry.refer = registryRefer return registry @@ -467,31 +468,4 @@ return '' } } - - function adaptClientConfig (config) { - return { - proxy: { - http: config.get('proxy'), - https: config.get('https-proxy'), - localAddress: config.get('local-address') - }, - ssl: { - certificate: config.get('cert'), - key: config.get('key'), - ca: config.get('ca'), - strict: config.get('strict-ssl') - }, - retry: { - retries: config.get('fetch-retries'), - factor: config.get('fetch-retry-factor'), - minTimeout: config.get('fetch-retry-mintimeout'), - maxTimeout: config.get('fetch-retry-maxtimeout') - }, - userAgent: config.get('user-agent'), - log: log, - defaultTag: config.get('tag'), - maxSockets: config.get('maxsockets'), - scope: npm.projectScope - } - } })() diff --git a/deps/npm/lib/pack.js b/deps/npm/lib/pack.js index 075a672d66..4552bbc498 100644 --- a/deps/npm/lib/pack.js +++ b/deps/npm/lib/pack.js @@ -92,8 +92,8 @@ function prepareDirectory (dir) { if (pkg.scripts && pkg.scripts.prepublish) { prepublishWarning([ 'As of npm@5, `prepublish` scripts are deprecated.', - 'Use `prepare` for build steps and `prepublishOnly` for upload-only', - 'See the deprecation note in `npm help scripts` for more information' + 'Use `prepare` for build steps and `prepublishOnly` for upload-only.', + 'See the deprecation note in `npm help scripts` for more information.' ]) } if (npm.config.get('ignore-prepublish')) { diff --git a/deps/npm/lib/test.js b/deps/npm/lib/test.js index cbc7582170..4ef025c4ba 100644 --- a/deps/npm/lib/test.js +++ b/deps/npm/lib/test.js @@ -1,6 +1,12 @@ module.exports = test -var testCmd = require('./utils/lifecycle.js').cmd('test') +const testCmd = require('./utils/lifecycle.js').cmd('test') +const usage = require('./utils/usage') + +test.usage = usage( + 'test', + 'npm test [-- <args>]' +) function test (args, cb) { testCmd(args, function (er) { diff --git a/deps/npm/lib/utils/error-handler.js b/deps/npm/lib/utils/error-handler.js index 5374d1feec..b13d42e1df 100644 --- a/deps/npm/lib/utils/error-handler.js +++ b/deps/npm/lib/utils/error-handler.js @@ -120,7 +120,7 @@ function exit (code, noLog) { }) rollbacks.length = 0 } else if (code && !noLog) { - writeLogFile(reallyExit) + writeLogFile() } else { reallyExit() } diff --git a/deps/npm/lib/utils/get-publish-config.js b/deps/npm/lib/utils/get-publish-config.js index fa475434ff..ac0ef09342 100644 --- a/deps/npm/lib/utils/get-publish-config.js +++ b/deps/npm/lib/utils/get-publish-config.js @@ -1,12 +1,16 @@ -var Conf = require('../config/core.js').Conf -var RegClient = require('npm-registry-client') -var log = require('npmlog') +'use strict' + +const clientConfig = require('../config/reg-client.js') +const Conf = require('../config/core.js').Conf +const log = require('npmlog') +const npm = require('../npm.js') +const RegClient = require('npm-registry-client') module.exports = getPublishConfig function getPublishConfig (publishConfig, defaultConfig, defaultClient) { - var config = defaultConfig - var client = defaultClient + let config = defaultConfig + let client = defaultClient log.verbose('getPublishConfig', publishConfig) if (publishConfig) { config = new Conf(defaultConfig) @@ -18,7 +22,7 @@ function getPublishConfig (publishConfig, defaultConfig, defaultClient) { s[k] = publishConfig[k] return s }, {})) - client = new RegClient(config) + client = new RegClient(clientConfig(npm, log, config)) } return { config: config, client: client } diff --git a/deps/npm/lib/utils/module-name.js b/deps/npm/lib/utils/module-name.js index 649dfac01b..43e0f5fb12 100644 --- a/deps/npm/lib/utils/module-name.js +++ b/deps/npm/lib/utils/module-name.js @@ -1,6 +1,5 @@ 'use strict' var path = require('path') -var validate = require('aproba') module.exports = moduleName module.exports.test = {} @@ -22,7 +21,6 @@ function isNotEmpty (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) |