diff options
Diffstat (limited to 'deps/npm/lib')
-rw-r--r-- | deps/npm/lib/ci.js | 4 | ||||
-rw-r--r-- | deps/npm/lib/config/defaults.js | 5 | ||||
-rw-r--r-- | deps/npm/lib/doctor/check-ping.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/install/actions.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/install/deps.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/install/validate-args.js | 25 | ||||
-rw-r--r-- | deps/npm/lib/npm.js | 22 | ||||
-rw-r--r-- | deps/npm/lib/shrinkwrap.js | 8 | ||||
-rw-r--r-- | deps/npm/lib/token.js | 1 |
9 files changed, 55 insertions, 16 deletions
diff --git a/deps/npm/lib/ci.js b/deps/npm/lib/ci.js index 309ad2f784..a0df3b86ff 100644 --- a/deps/npm/lib/ci.js +++ b/deps/npm/lib/ci.js @@ -4,6 +4,7 @@ const npm = require('./npm.js') const Installer = require('libcipm') const log = require('npmlog') const path = require('path') +const pack = require('./pack.js') ci.usage = 'npm ci' @@ -27,7 +28,8 @@ function ci (args, cb) { fmode: npm.modes.file, umask: npm.modes.umask, npmVersion: npm.version, - tmp: npm.tmp + tmp: npm.tmp, + dirPacker: pack.packGitDep } for (const key in npm.config.list[0]) { diff --git a/deps/npm/lib/config/defaults.js b/deps/npm/lib/config/defaults.js index f563357d4c..57d373df1e 100644 --- a/deps/npm/lib/config/defaults.js +++ b/deps/npm/lib/config/defaults.js @@ -141,6 +141,7 @@ Object.defineProperty(exports, 'defaults', {get: function () { editor: osenv.editor(), 'engine-strict': false, force: false, + 'format-package-lock': true, 'fetch-retries': 2, 'fetch-retry-factor': 10, @@ -201,7 +202,8 @@ Object.defineProperty(exports, 'defaults', {get: function () { 'user-agent': 'npm/{npm-version} ' + 'node/{node-version} ' + '{platform} ' + - '{arch}', + '{arch} ' + + '{ci}', 'read-only': false, 'rebuild-bundle': true, registry: 'https://registry.npmjs.org/', @@ -282,6 +284,7 @@ exports.types = { editor: String, 'engine-strict': Boolean, force: Boolean, + 'format-package-lock': Boolean, 'fetch-retries': Number, 'fetch-retry-factor': Number, 'fetch-retry-mintimeout': Number, diff --git a/deps/npm/lib/doctor/check-ping.js b/deps/npm/lib/doctor/check-ping.js index 70db255480..58f14fe69e 100644 --- a/deps/npm/lib/doctor/check-ping.js +++ b/deps/npm/lib/doctor/check-ping.js @@ -8,7 +8,7 @@ function checkPing (cb) { if (err && err.code && err.code.match(/^E\d{3}$/)) { return cb(null, [err.code.substr(1)]) } else { - cb(null, [200, 'OK']) + cb(null, [200, 'ok']) } }) } diff --git a/deps/npm/lib/install/actions.js b/deps/npm/lib/install/actions.js index a34d03ffe2..e26432b77c 100644 --- a/deps/npm/lib/install/actions.js +++ b/deps/npm/lib/install/actions.js @@ -49,7 +49,7 @@ Object.keys(actions).forEach(function (actionName) { if (pkg.knownInstallable) { actionP = runAction(action, staging, pkg, log) } else { - actionP = isInstallable(pkg.package).then(() => { + actionP = isInstallable(null, pkg.package).then(() => { pkg.knownInstallable = true return runAction(action, staging, pkg, log) }) diff --git a/deps/npm/lib/install/deps.js b/deps/npm/lib/install/deps.js index bfc94ae504..dfe30b6c0f 100644 --- a/deps/npm/lib/install/deps.js +++ b/deps/npm/lib/install/deps.js @@ -665,7 +665,7 @@ function resolveWithNewModule (pkg, tree, log, next) { validate('OOOF', arguments) log.silly('resolveWithNewModule', packageId(pkg), 'checking installable status') - return isInstallable(pkg, (err) => { + return isInstallable(tree, pkg, (err) => { let installable = !err addBundled(pkg, (bundleErr) => { var parent = earliestInstallable(tree, tree, pkg, log) || tree diff --git a/deps/npm/lib/install/validate-args.js b/deps/npm/lib/install/validate-args.js index 65b660417a..b680a1b24b 100644 --- a/deps/npm/lib/install/validate-args.js +++ b/deps/npm/lib/install/validate-args.js @@ -16,7 +16,7 @@ module.exports = function (idealTree, args, next) { chain([ [hasMinimumFields, pkg], [checkSelf, idealTree, pkg, force], - [isInstallable, pkg] + [isInstallable, idealTree, pkg] ], done) }, next) } @@ -31,13 +31,24 @@ function hasMinimumFields (pkg, cb) { } } -function getWarnings (pkg) { - while (pkg.parent) pkg = pkg.parent - if (!pkg.warnings) pkg.warnings = [] - return pkg.warnings +function setWarnings (idealTree, warn) { + function top (tree) { + if (tree.parent) return top(tree.parent) + return tree + } + + var topTree = top(idealTree) + if (!topTree.warnings) topTree.warnings = [] + + if (topTree.warnings.every(i => ( + i.code !== warn.code || + i.required !== warn.required || + i.pkgid !== warn.pkgid))) { + topTree.warnings.push(warn) + } } -var isInstallable = module.exports.isInstallable = function (pkg, next) { +var isInstallable = module.exports.isInstallable = function (idealTree, pkg, next) { var force = npm.config.get('force') var nodeVersion = npm.config.get('node-version') if (/-/.test(nodeVersion)) { @@ -48,7 +59,7 @@ var isInstallable = module.exports.isInstallable = function (pkg, next) { var strict = npm.config.get('engine-strict') checkEngine(pkg, npm.version, nodeVersion, force, strict, iferr(next, thenWarnEngineIssues)) function thenWarnEngineIssues (warn) { - if (warn) getWarnings(pkg).push(warn) + if (idealTree && warn) setWarnings(idealTree, warn) checkPlatform(pkg, force, next) } } diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js index 2ee9a99126..35850078f8 100644 --- a/deps/npm/lib/npm.js +++ b/deps/npm/lib/npm.js @@ -281,7 +281,27 @@ ua = ua.replace(/\{npm-version\}/gi, npm.version) ua = ua.replace(/\{platform\}/gi, process.platform) ua = ua.replace(/\{arch\}/gi, process.arch) - config.set('user-agent', ua) + + // continuous integration platforms + const ci = process.env.GERRIT_PROJECT ? 'ci/gerrit' + : process.env.GITLAB_CI ? 'ci/gitlab' + : process.env.CIRCLECI ? 'ci/circle-ci' + : process.env.SEMAPHORE ? 'ci/semaphore' + : process.env.DRONE ? 'ci/drone' + : process.env.GITHUB_ACTION ? 'ci/github-actions' + : process.env.TDDIUM ? 'ci/tddium' + : process.env.JENKINS_URL ? 'ci/jenkins' + : process.env['bamboo.buildKey'] ? 'ci/bamboo' + : process.env.GO_PIPELINE_NAME ? 'ci/gocd' + // codeship and a few others + : process.env.CI_NAME ? `ci/${process.env.CI_NAME}` + // test travis last, since many of these mimic it + : process.env.TRAVIS ? 'ci/travis-ci' + : process.env.CI === 'true' || process.env.CI === '1' ? 'ci/custom' + : '' + ua = ua.replace(/\{ci\}/gi, ci) + + config.set('user-agent', ua.trim()) if (config.get('metrics-registry') == null) { config.set('metrics-registry', config.get('registry')) diff --git a/deps/npm/lib/shrinkwrap.js b/deps/npm/lib/shrinkwrap.js index 0a3f53546c..5428e7255b 100644 --- a/deps/npm/lib/shrinkwrap.js +++ b/deps/npm/lib/shrinkwrap.js @@ -282,11 +282,15 @@ function checkPackageFile (dir, name) { return readFile( file, 'utf8' ).then((data) => { + const format = npm.config.get('format-package-lock') !== false + const indent = format ? detectIndent(data).indent : 0 + const newline = format ? detectNewline(data) : 0 + return { path: file, raw: data, - indent: detectIndent(data).indent, - newline: detectNewline(data) + indent, + newline } }).catch({code: 'ENOENT'}, () => {}) } diff --git a/deps/npm/lib/token.js b/deps/npm/lib/token.js index 9b1fbef9ce..96a05e4566 100644 --- a/deps/npm/lib/token.js +++ b/deps/npm/lib/token.js @@ -118,7 +118,6 @@ function config () { }) } else { conf = conf.concat({ auth: {} }) - conf.auth = {} } if (conf.otp) conf.auth.otp = conf.otp return conf |