summaryrefslogtreecommitdiff
path: root/deps/npm
diff options
context:
space:
mode:
authornpm team <ops+robot@npmjs.com>2021-09-20 19:18:58 +0000
committerRich Trott <rtrott@gmail.com>2021-09-20 15:51:14 -0700
commit7153d25dd6e570aeedc7762a7b0f94207280bb09 (patch)
tree2f8c1ddab2b0ad65417d4a252fa3739342d996c2 /deps/npm
parent931abc085e772d3ad35de2d45b22aa4e677b702d (diff)
downloadnode-new-7153d25dd6e570aeedc7762a7b0f94207280bb09.tar.gz
deps: upgrade npm to 7.24.0
PR-URL: https://github.com/nodejs/node/pull/40167 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'deps/npm')
-rw-r--r--deps/npm/docs/content/using-npm/scripts.md2
-rw-r--r--deps/npm/docs/output/commands/npm-ls.html2
-rw-r--r--deps/npm/docs/output/commands/npm.html2
-rw-r--r--deps/npm/docs/output/using-npm/scripts.html2
-rw-r--r--deps/npm/lib/install.js3
-rw-r--r--deps/npm/lib/search/format-package-stream.js2
-rw-r--r--deps/npm/lib/utils/config/definitions.js12
-rw-r--r--deps/npm/lib/utils/did-you-mean.js29
-rw-r--r--deps/npm/lib/utils/error-message.js2
-rw-r--r--deps/npm/lib/view.js2
-rw-r--r--deps/npm/man/man1/npm-ls.12
-rw-r--r--deps/npm/man/man1/npm.12
-rw-r--r--deps/npm/node_modules/init-package-json/LICENSE15
-rw-r--r--deps/npm/node_modules/init-package-json/LICENSE.md18
-rw-r--r--deps/npm/node_modules/init-package-json/lib/default-input.js (renamed from deps/npm/node_modules/init-package-json/default-input.js)177
-rw-r--r--deps/npm/node_modules/init-package-json/lib/init-package-json.js (renamed from deps/npm/node_modules/init-package-json/init-package-json.js)66
-rw-r--r--deps/npm/node_modules/init-package-json/package.json34
-rw-r--r--deps/npm/node_modules/minipass/index.js14
-rw-r--r--deps/npm/node_modules/minipass/package.json4
-rw-r--r--deps/npm/package.json4
-rw-r--r--deps/npm/tap-snapshots/test/lib/config.js.test.cjs4
-rw-r--r--deps/npm/tap-snapshots/test/lib/utils/error-message.js.test.cjs34
-rw-r--r--deps/npm/tap-snapshots/test/lib/view.js.test.cjs23
-rw-r--r--deps/npm/test/lib/search.js31
-rw-r--r--deps/npm/test/lib/utils/config/definitions.js30
-rw-r--r--deps/npm/test/lib/utils/did-you-mean.js71
-rw-r--r--deps/npm/test/lib/utils/error-message.js11
-rw-r--r--deps/npm/test/lib/view.js12
28 files changed, 429 insertions, 181 deletions
diff --git a/deps/npm/docs/content/using-npm/scripts.md b/deps/npm/docs/content/using-npm/scripts.md
index 2f2d53c1c2..fba37c2860 100644
--- a/deps/npm/docs/content/using-npm/scripts.md
+++ b/deps/npm/docs/content/using-npm/scripts.md
@@ -259,7 +259,7 @@ package.json file, then your package scripts would have the
in your code with `process.env.npm_package_name` and
`process.env.npm_package_version`, and so on for other fields.
-See [`package-json.md`](/using-npm/package-json) for more on package configs.
+See [`package-json.md`](/configuring-npm/package-json) for more on package configs.
#### current lifecycle event
diff --git a/deps/npm/docs/output/commands/npm-ls.html b/deps/npm/docs/output/commands/npm-ls.html
index 252e478513..0ce0ef1e18 100644
--- a/deps/npm/docs/output/commands/npm-ls.html
+++ b/deps/npm/docs/output/commands/npm-ls.html
@@ -159,7 +159,7 @@ tree at all, use <a href="../commands/npm-explain.html"><code>npm explain</code>
the results to only the paths to the packages named. Note that nested
packages will <em>also</em> show the paths to the specified packages. For
example, running <code>npm ls promzard</code> in npm’s source tree will show:</p>
-<pre lang="bash"><code>npm@7.23.0 /path/to/npm
+<pre lang="bash"><code>npm@7.24.0 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
</code></pre>
diff --git a/deps/npm/docs/output/commands/npm.html b/deps/npm/docs/output/commands/npm.html
index 6670f691d5..0956b0ef0d 100644
--- a/deps/npm/docs/output/commands/npm.html
+++ b/deps/npm/docs/output/commands/npm.html
@@ -148,7 +148,7 @@ npm command-line interface
<pre lang="bash"><code>npm &lt;command&gt; [args]
</code></pre>
<h3 id="version">Version</h3>
-<p>7.23.0</p>
+<p>7.24.0</p>
<h3 id="description">Description</h3>
<p>npm is the package manager for the Node JavaScript platform. It puts
modules in place so that node can find them, and manages dependency
diff --git a/deps/npm/docs/output/using-npm/scripts.html b/deps/npm/docs/output/using-npm/scripts.html
index 6dcf9a0416..1b4556a1f8 100644
--- a/deps/npm/docs/output/using-npm/scripts.html
+++ b/deps/npm/docs/output/using-npm/scripts.html
@@ -379,7 +379,7 @@ package.json file, then your package scripts would have the
<code>npm_package_version</code> set to “1.2.5”. You can access these variables
in your code with <code>process.env.npm_package_name</code> and
<code>process.env.npm_package_version</code>, and so on for other fields.</p>
-<p>See <a href="../using-npm/package-json.html"><code>package-json.md</code></a> for more on package configs.</p>
+<p>See <a href="../configuring-npm/package-json.html"><code>package-json.md</code></a> for more on package configs.</p>
<h4 id="current-lifecycle-event">current lifecycle event</h4>
<p>Lastly, the <code>npm_lifecycle_event</code> environment variable is set to
whichever stage of the cycle is being executed. So, you could have a
diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js
index 1589ff589c..99f75b7138 100644
--- a/deps/npm/lib/install.js
+++ b/deps/npm/lib/install.js
@@ -135,7 +135,8 @@ class Install extends ArboristWorkspaceCmd {
// be very strict about engines when trying to update npm itself
const npmInstall = args.find(arg => arg.startsWith('npm@') || arg === 'npm')
if (isGlobalInstall && npmInstall) {
- const npmManifest = await pacote.manifest(npmInstall)
+ const npmOptions = this.npm.flatOptions
+ const npmManifest = await pacote.manifest(npmInstall, npmOptions)
try {
checks.checkEngine(npmManifest, npmManifest.version, process.version)
} catch (e) {
diff --git a/deps/npm/lib/search/format-package-stream.js b/deps/npm/lib/search/format-package-stream.js
index c88df5eb4b..fb7d81856d 100644
--- a/deps/npm/lib/search/format-package-stream.js
+++ b/deps/npm/lib/search/format-package-stream.js
@@ -42,7 +42,7 @@ class JSONOutputStream extends Minipass {
}
end () {
- super.write(this._didFirst ? ']\n' : '\n]\n')
+ super.write(this._didFirst ? ']\n' : '\n[]\n')
super.end()
}
}
diff --git a/deps/npm/lib/utils/config/definitions.js b/deps/npm/lib/utils/config/definitions.js
index 092e0fc435..009f60a7bc 100644
--- a/deps/npm/lib/utils/config/definitions.js
+++ b/deps/npm/lib/utils/config/definitions.js
@@ -2053,10 +2053,14 @@ define('user-agent', {
.replace(/\{workspaces\}/gi, inWorkspaces)
.replace(/\{ci\}/gi, ciName ? `ci/${ciName}` : '')
.trim()
+
+ // We can't clobber the original or else subsequent flattening will fail
+ // (i.e. when we change the underlying config values)
+ // obj[key] = flatOptions.userAgent
+
// user-agent is a unique kind of config item that gets set from a template
// and ends up translated. Because of this, the normal "should we set this
// to process.env also doesn't work
- obj[key] = flatOptions.userAgent
process.env.npm_config_user_agent = flatOptions.userAgent
},
})
@@ -2140,6 +2144,9 @@ define('workspace', {
a workspace which does not yet exist, to create the folder and set it
up as a brand new workspace within the project.
`,
+ flatten: (key, obj, flatOptions) => {
+ definitions['user-agent'].flatten('user-agent', obj, flatOptions)
+ },
})
define('workspaces', {
@@ -2151,6 +2158,9 @@ define('workspaces', {
Enable running a command in the context of **all** the configured
workspaces.
`,
+ flatten: (key, obj, flatOptions) => {
+ definitions['user-agent'].flatten('user-agent', obj, flatOptions)
+ },
})
define('yes', {
diff --git a/deps/npm/lib/utils/did-you-mean.js b/deps/npm/lib/utils/did-you-mean.js
index 0cfdd03525..c324253af2 100644
--- a/deps/npm/lib/utils/did-you-mean.js
+++ b/deps/npm/lib/utils/did-you-mean.js
@@ -3,25 +3,26 @@ const readJson = require('read-package-json-fast')
const { cmdList } = require('./cmd-list.js')
const didYouMean = async (npm, path, scmd) => {
- const bestCmd = cmdList
+ let best = cmdList
.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 && scmd !== cmd)
.map(str => ` npm ${str} # ${npm.commands[str].description}`)
- const pkg = await readJson(`${path}/package.json`)
- const { scripts } = pkg
// We would already be suggesting this in `npm x` so omit them here
const runScripts = ['stop', 'start', 'test', 'restart']
- const bestRun = Object.keys(scripts || {})
- .filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 &&
- !runScripts.includes(cmd))
- .map(str => ` npm run ${str} # run the "${str}" package script`)
-
- const { bin } = pkg
- const bestBin = Object.keys(bin || {})
- .filter(cmd => distance(scmd, cmd) < scmd.length * 0.4)
- .map(str => ` npm exec ${str} # run the "${str}" command from either this or a remote npm package`)
-
- const best = [...bestCmd, ...bestRun, ...bestBin]
+ try {
+ const { bin, scripts } = await readJson(`${path}/package.json`)
+ best = best.concat(
+ Object.keys(scripts || {})
+ .filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 &&
+ !runScripts.includes(cmd))
+ .map(str => ` npm run ${str} # run the "${str}" package script`),
+ Object.keys(bin || {})
+ .filter(cmd => distance(scmd, cmd) < scmd.length * 0.4)
+ .map(str => ` npm exec ${str} # run the "${str}" command from either this or a remote npm package`)
+ )
+ } catch (_) {
+ // gracefully ignore not being in a folder w/ a package.json
+ }
if (best.length === 0)
return ''
diff --git a/deps/npm/lib/utils/error-message.js b/deps/npm/lib/utils/error-message.js
index 6e12bcb918..9343d37d54 100644
--- a/deps/npm/lib/utils/error-message.js
+++ b/deps/npm/lib/utils/error-message.js
@@ -367,7 +367,7 @@ module.exports = (er, npm) => {
detail.push(['signal', er.signal])
if (er.cmd && Array.isArray(er.args))
- detail.push(['command', ...[er.cmd, ...er.args]])
+ detail.push(['command', ...[er.cmd, ...er.args.map(replaceInfo)]])
if (er.stdout)
detail.push(['', er.stdout.trim()])
diff --git a/deps/npm/lib/view.js b/deps/npm/lib/view.js
index f4fc5974ee..0124bfb7d3 100644
--- a/deps/npm/lib/view.js
+++ b/deps/npm/lib/view.js
@@ -336,7 +336,7 @@ class View extends BaseCommand {
email: color.cyan(manifest._npmUser.email),
}),
modified: !packument.time ? undefined
- : color.yellow(relativeDate(packument.time[packument.version])),
+ : color.yellow(relativeDate(packument.time[manifest.version])),
maintainers: (packument.maintainers || []).map((u) => unparsePerson({
name: color.yellow(u.name),
email: color.cyan(u.email),
diff --git a/deps/npm/man/man1/npm-ls.1 b/deps/npm/man/man1/npm-ls.1
index 8ff55b216f..e9c5d78d82 100644
--- a/deps/npm/man/man1/npm-ls.1
+++ b/deps/npm/man/man1/npm-ls.1
@@ -26,7 +26,7 @@ example, running \fBnpm ls promzard\fP in npm's source tree will show:
.P
.RS 2
.nf
-npm@7\.23\.0 /path/to/npm
+npm@7\.24\.0 /path/to/npm
└─┬ init\-package\-json@0\.0\.4
└── promzard@0\.1\.5
.fi
diff --git a/deps/npm/man/man1/npm.1 b/deps/npm/man/man1/npm.1
index e9e1165238..8e07933b21 100644
--- a/deps/npm/man/man1/npm.1
+++ b/deps/npm/man/man1/npm.1
@@ -10,7 +10,7 @@ npm <command> [args]
.RE
.SS Version
.P
-7\.23\.0
+7\.24\.0
.SS Description
.P
npm is the package manager for the Node JavaScript platform\. It puts
diff --git a/deps/npm/node_modules/init-package-json/LICENSE b/deps/npm/node_modules/init-package-json/LICENSE
deleted file mode 100644
index 05eeeb88c2..0000000000
--- a/deps/npm/node_modules/init-package-json/LICENSE
+++ /dev/null
@@ -1,15 +0,0 @@
-The ISC License
-
-Copyright (c) Isaac Z. Schlueter
-
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
-IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/deps/npm/node_modules/init-package-json/LICENSE.md b/deps/npm/node_modules/init-package-json/LICENSE.md
new file mode 100644
index 0000000000..845be76f64
--- /dev/null
+++ b/deps/npm/node_modules/init-package-json/LICENSE.md
@@ -0,0 +1,18 @@
+ISC License
+
+Copyright npm, Inc.
+
+Permission to use, copy, modify, and/or distribute this
+software for any purpose with or without fee is hereby
+granted, provided that the above copyright notice and this
+permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
+USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/deps/npm/node_modules/init-package-json/default-input.js b/deps/npm/node_modules/init-package-json/lib/default-input.js
index d1f65841d6..0003472975 100644
--- a/deps/npm/node_modules/init-package-json/default-input.js
+++ b/deps/npm/node_modules/init-package-json/lib/default-input.js
@@ -1,5 +1,5 @@
+/* eslint-disable no-undef */
var fs = require('fs')
-var glob = require('glob')
var path = require('path')
var validateLicense = require('validate-npm-package-license')
var validateName = require('validate-npm-package-name')
@@ -15,35 +15,57 @@ function niceName (n) {
return n.replace(/^node-|[.-]js$/g, '').replace(/\s+/g, ' ').replace(/ /g, '-').toLowerCase()
}
-function readDeps (test, excluded) { return function (cb) {
- fs.readdir('node_modules', function (er, dir) {
- if (er) return cb()
- var deps = {}
- var n = dir.length
- if (n === 0) return cb(null, deps)
- dir.forEach(function (d) {
- if (d.match(/^\./)) return next()
- if (test !== isTestPkg(d) || excluded[d])
- return next()
-
- var dp = path.join(dirname, 'node_modules', d, 'package.json')
- fs.readFile(dp, 'utf8', function (er, p) {
- if (er) return next()
- try { p = JSON.parse(p) }
- catch (e) { return next() }
- if (!p.version) return next()
- if (p._requiredBy) {
- if (!p._requiredBy.some(function (req) { return req === '#USER' })) return next()
+function readDeps (test, excluded) {
+ return function (cb) {
+ fs.readdir('node_modules', function (er, dir) {
+ if (er) {
+ return cb()
+ }
+ var deps = {}
+ var n = dir.length
+ if (n === 0) {
+ return cb(null, deps)
+ }
+ dir.forEach(function (d) {
+ if (d.match(/^\./)) {
+ return next()
+ }
+ if (test !== isTestPkg(d) || excluded[d]) {
+ return next()
}
- deps[d] = config.get('save-exact') ? p.version : config.get('save-prefix') + p.version
- return next()
+
+ var dp = path.join(dirname, 'node_modules', d, 'package.json')
+ fs.readFile(dp, 'utf8', function (er, p) {
+ if (er) {
+ return next()
+ }
+ try {
+ p = JSON.parse(p)
+ } catch (e) {
+ return next()
+ }
+ if (!p.version) {
+ return next()
+ }
+ if (p._requiredBy) {
+ if (!p._requiredBy.some(function (req) {
+ return req === '#USER'
+ })) {
+ return next()
+ }
+ }
+ deps[d] = config.get('save-exact') ? p.version : config.get('save-prefix') + p.version
+ return next()
+ })
})
+ function next () {
+ if (--n === 0) {
+ return cb(null, deps)
+ }
+ }
})
- function next () {
- if (--n === 0) return cb(null, deps)
- }
- })
-}}
+ }
+}
var name = niceName(package.name || basename)
var spec
@@ -54,16 +76,20 @@ try {
}
var scope = config.get('scope')
if (scope) {
- if (scope.charAt(0) !== '@') scope = '@' + scope
+ if (scope.charAt(0) !== '@') {
+ scope = '@' + scope
+ }
if (spec.scope) {
name = scope + '/' + spec.name.split('/')[1]
} else {
name = scope + '/' + name
}
}
-exports.name = yes ? name : prompt('package name', name, function (data) {
+exports.name = yes ? name : prompt('package name', name, function (data) {
var its = validateName(data)
- if (its.validForNewPackages) return data
+ if (its.validForNewPackages) {
+ return data
+ }
var errors = (its.errors || []).concat(its.warnings || [])
var er = new Error('Sorry, ' + errors.join(' and ') + '.')
er.notValid = true
@@ -83,7 +109,9 @@ var version = package.version ||
exports.version = yes ?
version :
prompt('version', version, function (version) {
- if (semver.valid(version)) return version
+ if (semver.valid(version)) {
+ return version
+ }
var er = new Error('Invalid version: "' + version + '"')
er.notValid = true
return er
@@ -96,22 +124,25 @@ if (!package.description) {
if (!package.main) {
exports.main = function (cb) {
fs.readdir(dirname, function (er, f) {
- if (er) f = []
+ if (er) {
+ f = []
+ }
f = f.filter(function (f) {
return f.match(/\.js$/)
})
- if (f.indexOf('index.js') !== -1)
+ if (f.indexOf('index.js') !== -1) {
f = 'index.js'
- else if (f.indexOf('main.js') !== -1)
+ } else if (f.indexOf('main.js') !== -1) {
f = 'main.js'
- else if (f.indexOf(basename + '.js') !== -1)
+ } else if (f.indexOf(basename + '.js') !== -1) {
f = basename + '.js'
- else
+ } else {
f = f[0]
+ }
- var index = f || 'index.js'
+ var index = f || 'index.js'
return cb(null, yes ? index : prompt('entry point', index))
})
}
@@ -121,18 +152,24 @@ if (!package.bin) {
exports.bin = function (cb) {
fs.readdir(path.resolve(dirname, 'bin'), function (er, d) {
// no bins
- if (er) return cb()
+ if (er) {
+ return cb()
+ }
// just take the first js file we find there, or nada
- return cb(null, d.filter(function (f) {
- return f.match(/\.js$/)
- })[0])
+ let r = d.find(f => f.match(/\.js$/))
+ if (r) {
+ r = `bin/${r}`
+ }
+ return cb(null, r)
})
}
}
exports.directories = function (cb) {
fs.readdir(dirname, function (er, dirs) {
- if (er) return cb(er)
+ if (er) {
+ return cb(er)
+ }
var res = {}
dirs.forEach(function (d) {
switch (d) {
@@ -143,7 +180,9 @@ exports.directories = function (cb) {
case 'lib': return res.lib = d
}
})
- if (Object.keys(res).length === 0) res = undefined
+ if (Object.keys(res).length === 0) {
+ res = undefined
+ }
return cb(null, res)
})
}
@@ -173,13 +212,15 @@ function setupScripts (d, cb) {
}
if (!s.test || s.test === notest) {
var commands = {
- 'tap':'tap test/*.js'
- , 'expresso':'expresso test'
- , 'mocha':'mocha'
+ tap: 'tap test/*.js',
+ expresso: 'expresso test',
+ mocha: 'mocha',
}
var command
Object.keys(commands).forEach(function (k) {
- if (d.indexOf(k) !== -1) command = commands[k]
+ if (d.indexOf(k) !== -1) {
+ command = commands[k]
+ }
})
var ps = 'test command'
if (yes) {
@@ -201,12 +242,18 @@ if (!package.repository) {
var i = gconf.indexOf('[remote "origin"]')
if (i !== -1) {
var u = gconf[i + 1]
- if (!u.match(/^\s*url =/)) u = gconf[i + 2]
- if (!u.match(/^\s*url =/)) u = null
- else u = u.replace(/^\s*url = /, '')
+ if (!u.match(/^\s*url =/)) {
+ u = gconf[i + 2]
+ }
+ if (!u.match(/^\s*url =/)) {
+ u = null
+ } else {
+ u = u.replace(/^\s*url = /, '')
+ }
}
- if (u && u.match(/^git@github.com:/))
+ if (u && u.match(/^git@github.com:/)) {
u = u.replace(/^git@github.com:/, 'https://github.com/')
+ }
return cb(null, yes ? u : prompt('git repository', u))
})
@@ -215,9 +262,15 @@ if (!package.repository) {
if (!package.keywords) {
exports.keywords = yes ? '' : prompt('keywords', function (s) {
- if (!s) return undefined
- if (Array.isArray(s)) s = s.join(' ')
- if (typeof s !== 'string') return s
+ if (!s) {
+ return undefined
+ }
+ if (Array.isArray(s)) {
+ s = s.join(' ')
+ }
+ if (typeof s !== 'string') {
+ return s
+ }
return s.split(/[\s,]+/)
})
}
@@ -225,15 +278,15 @@ if (!package.keywords) {
if (!package.author) {
exports.author = config.get('init.author.name') ||
config.get('init-author-name')
- ? {
- "name" : config.get('init.author.name') ||
+ ? {
+ name: config.get('init.author.name') ||
config.get('init-author-name'),
- "email" : config.get('init.author.email') ||
+ email: config.get('init.author.email') ||
config.get('init-author-email'),
- "url" : config.get('init.author.url') ||
- config.get('init-author-url')
+ url: config.get('init.author.url') ||
+ config.get('init-author-url'),
}
- : yes ? '' : prompt('author')
+ : yes ? '' : prompt('author')
}
const defaultDottedInitLicense = config &&
@@ -248,7 +301,9 @@ var license = package.license ||
'ISC'
exports.license = yes ? license : prompt('license', license, function (data) {
var its = validateLicense(data)
- if (its.validForNewPackages) return data
+ if (its.validForNewPackages) {
+ return data
+ }
var errors = (its.errors || []).concat(its.warnings || [])
var er = new Error('Sorry, ' + errors.join(' and ') + '.')
er.notValid = true
diff --git a/deps/npm/node_modules/init-package-json/init-package-json.js b/deps/npm/node_modules/init-package-json/lib/init-package-json.js
index 83e7342d0a..bee79351ca 100644
--- a/deps/npm/node_modules/init-package-json/init-package-json.js
+++ b/deps/npm/node_modules/init-package-json/lib/init-package-json.js
@@ -12,7 +12,6 @@ var read = require('read')
// to validate the data object at the end as a worthwhile package
// and assign default values for things.
-// readJson.extras(file, data, cb)
var readJson = require('read-package-json')
function yes (conf) {
@@ -23,8 +22,10 @@ function yes (conf) {
}
function init (dir, input, config, cb) {
- if (typeof config === 'function')
- cb = config, config = {}
+ if (typeof config === 'function') {
+ cb = config
+ config = {}
+ }
// accept either a plain-jane object, or a config object
// with a "get" method.
@@ -36,7 +37,7 @@ function init (dir, input, config, cb) {
},
toJSON: function () {
return data
- }
+ },
}
}
@@ -52,14 +53,18 @@ function init (dir, input, config, cb) {
readJson(packageFile, function (er, d) {
readJson.extraSet = es
- if (er) pkg = {}
- else pkg = d
+ if (er) {
+ pkg = {}
+ } else {
+ pkg = d
+ }
ctx.filename = packageFile
ctx.dirname = path.dirname(packageFile)
ctx.basename = path.basename(ctx.dirname)
- if (!pkg.version || !semver.valid(pkg.version))
+ if (!pkg.version || !semver.valid(pkg.version)) {
delete pkg.version
+ }
ctx.package = pkg
ctx.config = config || {}
@@ -71,7 +76,9 @@ function init (dir, input, config, cb) {
pz.on('error', cb)
pz.on('data', function (data) {
Object.keys(data).forEach(function (k) {
- if (data[k] !== undefined && data[k] !== null) pkg[k] = data[k]
+ if (data[k] !== undefined && data[k] !== null) {
+ pkg[k] = data[k]
+ }
})
// only do a few of these.
@@ -81,8 +88,10 @@ function init (dir, input, config, cb) {
return fn.name !== 'authors' && fn.name !== 'mans'
})
readJson.extras(packageFile, pkg, function (er, pkg) {
+ if (er) {
+ return cb(er, pkg)
+ }
readJson.extraSet = es
- if (er) return cb(er, pkg)
pkg = unParsePeople(pkg)
// no need for the readme now.
delete pkg.readme
@@ -95,13 +104,15 @@ function init (dir, input, config, cb) {
delete pkg.gitHead
// if the repo is empty, remove it.
- if (!pkg.repository)
+ if (!pkg.repository) {
delete pkg.repository
+ }
// readJson filters out empty descriptions, but init-package-json
// traditionally leaves them alone
- if (!pkg.description)
+ if (!pkg.description) {
pkg.description = data.description
+ }
var d = JSON.stringify(updateDeps(pkg), null, 2) + '\n'
function write (yes) {
@@ -116,7 +127,7 @@ function init (dir, input, config, cb) {
return write(true)
}
console.log('About to write to %s:\n\n%s\n', packageFile, d)
- read({prompt:'Is this OK? ', default: 'yes'}, function (er, ok) {
+ read({prompt: 'Is this OK? ', default: 'yes'}, function (er, ok) {
if (er) {
return cb(er)
}
@@ -129,18 +140,19 @@ function init (dir, input, config, cb) {
})
})
})
-
}
-function updateDeps(depsData) {
+function updateDeps (depsData) {
// optionalDependencies don't need to be repeated in two places
if (depsData.dependencies) {
if (depsData.optionalDependencies) {
- for (const name of Object.keys(depsData.optionalDependencies))
+ for (const name of Object.keys(depsData.optionalDependencies)) {
delete depsData.dependencies[name]
+ }
}
- if (Object.keys(depsData.dependencies).length === 0)
+ if (Object.keys(depsData.dependencies).length === 0) {
delete depsData.dependencies
+ }
}
return depsData
@@ -148,21 +160,25 @@ function updateDeps(depsData) {
// turn the objects into somewhat more humane strings.
function unParsePeople (data) {
- if (data.author) data.author = unParsePerson(data.author)
- ;["maintainers", "contributors"].forEach(function (set) {
- if (!Array.isArray(data[set])) return;
+ if (data.author) {
+ data.author = unParsePerson(data.author)
+ }['maintainers', 'contributors'].forEach(function (set) {
+ if (!Array.isArray(data[set])) {
+ return
+ }
data[set] = data[set].map(unParsePerson)
})
return data
}
function unParsePerson (person) {
- if (typeof person === "string") return person
- var name = person.name || ""
+ if (typeof person === 'string') {
+ return person
+ }
+ var name = person.name || ''
var u = person.url || person.web
- var url = u ? (" ("+u+")") : ""
+ var url = u ? (' (' + u + ')') : ''
var e = person.email || person.mail
- var email = e ? (" <"+e+">") : ""
- return name+email+url
+ var email = e ? (' <' + e + '>') : ''
+ return name + email + url
}
-
diff --git a/deps/npm/node_modules/init-package-json/package.json b/deps/npm/node_modules/init-package-json/package.json
index 0e07f48f49..6d642f6cf6 100644
--- a/deps/npm/node_modules/init-package-json/package.json
+++ b/deps/npm/node_modules/init-package-json/package.json
@@ -1,41 +1,46 @@
{
"name": "init-package-json",
- "version": "2.0.4",
- "main": "init-package-json.js",
+ "version": "2.0.5",
+ "main": "lib/init-package-json.js",
"scripts": {
"test": "tap",
"preversion": "npm test",
"postversion": "npm publish",
- "prepublishOnly": "git push origin --follow-tags"
+ "prepublishOnly": "git push origin --follow-tags",
+ "lint": "eslint '**/*.js'",
+ "postlint": "npm-template-check",
+ "lintfix": "npm run lint -- --fix",
+ "snap": "tap",
+ "posttest": "npm run lint"
},
"repository": {
"type": "git",
"url": "https://github.com/npm/init-package-json.git"
},
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "author": "GitHub Inc.",
"license": "ISC",
"description": "A node module to get your node module started",
"dependencies": {
- "glob": "^7.1.1",
- "npm-package-arg": "^8.1.2",
+ "npm-package-arg": "^8.1.5",
"promzard": "^0.3.0",
"read": "~1.0.1",
- "read-package-json": "^4.0.0",
+ "read-package-json": "^4.1.1",
"semver": "^7.3.5",
"validate-npm-package-license": "^3.0.4",
"validate-npm-package-name": "^3.0.0"
},
"devDependencies": {
"@npmcli/config": "^2.1.0",
- "mkdirp": "^1.0.4",
- "rimraf": "^3.0.2",
- "tap": "^14.11.0"
+ "@npmcli/template-oss": "^1.0.3",
+ "tap": "^15.0.9"
},
"engines": {
"node": ">=10"
},
"tap": {
- "jobs": "1"
+ "statements": "94",
+ "branches": "83",
+ "lines": "94"
},
"keywords": [
"init",
@@ -48,7 +53,8 @@
"start"
],
"files": [
- "default-input.js",
- "init-package-json.js"
- ]
+ "bin",
+ "lib"
+ ],
+ "templateVersion": "1.0.3"
}
diff --git a/deps/npm/node_modules/minipass/index.js b/deps/npm/node_modules/minipass/index.js
index 56cbd665d2..ae134a066d 100644
--- a/deps/npm/node_modules/minipass/index.js
+++ b/deps/npm/node_modules/minipass/index.js
@@ -1,4 +1,8 @@
'use strict'
+const proc = typeof process === 'object' && process ? process : {
+ stdout: null,
+ stderr: null,
+}
const EE = require('events')
const Stream = require('stream')
const Yallist = require('yallist')
@@ -8,6 +12,7 @@ const EOF = Symbol('EOF')
const MAYBE_EMIT_END = Symbol('maybeEmitEnd')
const EMITTED_END = Symbol('emittedEnd')
const EMITTING_END = Symbol('emittingEnd')
+const EMITTED_ERROR = Symbol('emittedError')
const CLOSED = Symbol('closed')
const READ = Symbol('read')
const FLUSH = Symbol('flush')
@@ -66,6 +71,7 @@ module.exports = class Minipass extends Stream {
this[EMITTED_END] = false
this[EMITTING_END] = false
this[CLOSED] = false
+ this[EMITTED_ERROR] = null
this.writable = true
this.readable = true
this[BUFFERLENGTH] = 0
@@ -310,7 +316,7 @@ module.exports = class Minipass extends Stream {
const ended = this[EMITTED_END]
opts = opts || {}
- if (dest === process.stdout || dest === process.stderr)
+ if (dest === proc.stdout || dest === proc.stderr)
opts.end = false
else
opts.end = opts.end !== false
@@ -339,6 +345,8 @@ module.exports = class Minipass extends Stream {
else if (isEndish(ev) && this[EMITTED_END]) {
super.emit(ev)
this.removeAllListeners(ev)
+ } else if (ev === 'error' && this[EMITTED_ERROR]) {
+ fn.call(this, this[EMITTED_ERROR])
}
}
}
@@ -400,6 +408,8 @@ module.exports = class Minipass extends Stream {
// don't emit close before 'end' and 'finish'
if (!this[EMITTED_END] && !this[DESTROYED])
return
+ } else if (ev === 'error') {
+ this[EMITTED_ERROR] = data
}
// TODO: replace with a spread operator when Node v4 support drops
@@ -452,8 +462,8 @@ module.exports = class Minipass extends Stream {
promise () {
return new Promise((resolve, reject) => {
this.on(DESTROYED, () => reject(new Error('stream destroyed')))
- this.on('end', () => resolve())
this.on('error', er => reject(er))
+ this.on('end', () => resolve())
})
}
diff --git a/deps/npm/node_modules/minipass/package.json b/deps/npm/node_modules/minipass/package.json
index 54f62d56d4..165fa662ab 100644
--- a/deps/npm/node_modules/minipass/package.json
+++ b/deps/npm/node_modules/minipass/package.json
@@ -1,6 +1,6 @@
{
"name": "minipass",
- "version": "3.1.3",
+ "version": "3.1.5",
"description": "minimal implementation of a PassThrough stream",
"main": "index.js",
"dependencies": {
@@ -8,7 +8,7 @@
},
"devDependencies": {
"end-of-stream": "^1.4.0",
- "tap": "^14.6.5",
+ "tap": "^15.0.9",
"through2": "^2.0.3"
},
"scripts": {
diff --git a/deps/npm/package.json b/deps/npm/package.json
index 20b80c7ebe..38b4594770 100644
--- a/deps/npm/package.json
+++ b/deps/npm/package.json
@@ -1,5 +1,5 @@
{
- "version": "7.23.0",
+ "version": "7.24.0",
"name": "npm",
"description": "a package manager for JavaScript",
"workspaces": [
@@ -74,7 +74,7 @@
"graceful-fs": "^4.2.8",
"hosted-git-info": "^4.0.2",
"ini": "^2.0.0",
- "init-package-json": "^2.0.4",
+ "init-package-json": "^2.0.5",
"is-cidr": "^4.0.2",
"json-parse-even-better-errors": "^2.3.1",
"libnpmaccess": "^4.0.2",
diff --git a/deps/npm/tap-snapshots/test/lib/config.js.test.cjs b/deps/npm/tap-snapshots/test/lib/config.js.test.cjs
index 8f349a6f54..dab7ef55f6 100644
--- a/deps/npm/tap-snapshots/test/lib/config.js.test.cjs
+++ b/deps/npm/tap-snapshots/test/lib/config.js.test.cjs
@@ -146,7 +146,7 @@ exports[`test/lib/config.js TAP config list --json > output matches snapshot 1`]
"unicode": false,
"update-notifier": true,
"usage": false,
- "user-agent": "npm/{NPM-VERSION} node/{NODE-VERSION} {PLATFORM} {ARCH} workspaces/false",
+ "user-agent": "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}",
"version": false,
"versions": false,
"viewer": "{VIEWER}",
@@ -296,7 +296,7 @@ umask = 0
unicode = false
update-notifier = true
usage = false
-user-agent = "npm/{NPM-VERSION} node/{NODE-VERSION} {PLATFORM} {ARCH} workspaces/false"
+user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}"
; userconfig = "{HOME}/.npmrc" ; overridden by cli
version = false
versions = false
diff --git a/deps/npm/tap-snapshots/test/lib/utils/error-message.js.test.cjs b/deps/npm/tap-snapshots/test/lib/utils/error-message.js.test.cjs
index 4eb5ea3bc5..c963ca2040 100644
--- a/deps/npm/tap-snapshots/test/lib/utils/error-message.js.test.cjs
+++ b/deps/npm/tap-snapshots/test/lib/utils/error-message.js.test.cjs
@@ -180,6 +180,40 @@ Object {
}
`
+exports[`test/lib/utils/error-message.js TAP args are cleaned > must match snapshot 1`] = `
+Object {
+ "detail": Array [
+ Array [
+ "signal",
+ "SIGYOLO",
+ ],
+ Array [
+ "command",
+ "some command",
+ "a",
+ "r",
+ "g",
+ "s",
+ "https://evil:***@npmjs.org",
+ ],
+ Array [
+ "",
+ "stdout",
+ ],
+ Array [
+ "",
+ "stderr",
+ ],
+ ],
+ "summary": Array [
+ Array [
+ "",
+ "cmd err",
+ ],
+ ],
+}
+`
+
exports[`test/lib/utils/error-message.js TAP bad engine with config loaded > must match snapshot 1`] = `
Object {
"detail": Array [
diff --git a/deps/npm/tap-snapshots/test/lib/view.js.test.cjs b/deps/npm/tap-snapshots/test/lib/view.js.test.cjs
index 27ba7b1eb6..9ed8334138 100644
--- a/deps/npm/tap-snapshots/test/lib/view.js.test.cjs
+++ b/deps/npm/tap-snapshots/test/lib/view.js.test.cjs
@@ -82,7 +82,7 @@ dist
dist-tags:
latest: 1.0.0
-published {TIME} ago
+published yesterday
`
exports[`test/lib/view.js TAP should log info of package in current working dir specific version > must match snapshot 1`] = `
@@ -99,7 +99,7 @@ dist
dist-tags:
latest: 1.0.0
-published {TIME} ago
+published yesterday
`
exports[`test/lib/view.js TAP should log package info package from git > must match snapshot 1`] = `
@@ -302,7 +302,24 @@ dist
dist-tags:
latest: 1.0.0
-published {TIME} ago
+published yesterday
+`
+
+exports[`test/lib/view.js TAP should log package info package with semver range > must match snapshot 1`] = `
+
+
+blue@1.0.0 | Proprietary | deps: none | versions: 2
+
+dist
+.tarball:http://hm.blue.com/1.0.0.tgz
+.shasum:123
+.integrity:---
+.unpackedSize:1 B
+
+dist-tags:
+latest: 1.0.0
+
+published yesterday
`
exports[`test/lib/view.js TAP workspaces all workspaces --json > must match snapshot 1`] = `
diff --git a/deps/npm/test/lib/search.js b/deps/npm/test/lib/search.js
index 510a470f48..55b584b8aa 100644
--- a/deps/npm/test/lib/search.js
+++ b/deps/npm/test/lib/search.js
@@ -130,6 +130,37 @@ t.test('search <name> --json', (t) => {
src.end()
})
+t.test('search <invalid-module> --json', (t) => {
+ const src = new Minipass()
+ src.objectMode = true
+
+ npm.flatOptions.json = true
+ config.json = true
+ const libnpmsearch = {
+ stream () {
+ return src
+ },
+ }
+
+ const Search = t.mock('../../lib/search.js', {
+ ...mocks,
+ libnpmsearch,
+ })
+ const search = new Search(npm)
+
+ search.exec(['foo'], (err) => {
+ if (err)
+ throw err
+
+ t.equal(result, '\n[]\n', 'should have expected empty square brackets')
+
+ config.json = false
+ t.end()
+ })
+
+ src.end()
+})
+
t.test('search <name> --searchexclude --searchopts', t => {
npm.flatOptions.search = {
...flatOptions.search,
diff --git a/deps/npm/test/lib/utils/config/definitions.js b/deps/npm/test/lib/utils/config/definitions.js
index 65193020d0..88993303b5 100644
--- a/deps/npm/test/lib/utils/config/definitions.js
+++ b/deps/npm/test/lib/utils/config/definitions.js
@@ -747,7 +747,7 @@ t.test('user-agent', t => {
definitions['user-agent'].flatten('user-agent', obj, flat)
t.equal(flat.userAgent, expectNoCI)
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
- t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
+ t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')
obj['ci-name'] = 'foo'
obj['user-agent'] = definitions['user-agent'].default
@@ -755,7 +755,7 @@ t.test('user-agent', t => {
definitions['user-agent'].flatten('user-agent', obj, flat)
t.equal(flat.userAgent, expectCI)
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
- t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
+ t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')
delete obj['ci-name']
obj.workspaces = true
@@ -764,7 +764,7 @@ t.test('user-agent', t => {
definitions['user-agent'].flatten('user-agent', obj, flat)
t.equal(flat.userAgent, expectWorkspaces)
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
- t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
+ t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')
delete obj.workspaces
obj.workspace = ['foo']
@@ -772,7 +772,7 @@ t.test('user-agent', t => {
definitions['user-agent'].flatten('user-agent', obj, flat)
t.equal(flat.userAgent, expectWorkspaces)
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
- t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
+ t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')
t.end()
})
@@ -853,3 +853,25 @@ t.test('package-lock-only', t => {
t.strictSame(flat, { packageLock: false, packageLockOnly: false })
t.end()
})
+
+t.test('workspaces', t => {
+ const obj = {
+ workspaces: true,
+ 'user-agent': definitions['user-agent'].default,
+ }
+ const flat = {}
+ definitions.workspaces.flatten('workspaces', obj, flat)
+ t.match(flat.userAgent, /workspaces\/true/)
+ t.end()
+})
+
+t.test('workspace', t => {
+ const obj = {
+ workspace: ['workspace-a'],
+ 'user-agent': definitions['user-agent'].default,
+ }
+ const flat = {}
+ definitions.workspace.flatten('workspaces', obj, flat)
+ t.match(flat.userAgent, /workspaces\/true/)
+ t.end()
+})
diff --git a/deps/npm/test/lib/utils/did-you-mean.js b/deps/npm/test/lib/utils/did-you-mean.js
index 15712b665b..1285d53008 100644
--- a/deps/npm/test/lib/utils/did-you-mean.js
+++ b/deps/npm/test/lib/utils/did-you-mean.js
@@ -5,34 +5,55 @@ const dym = require('../../../lib/utils/did-you-mean.js')
t.test('did-you-mean', t => {
npm.load(err => {
t.notOk(err)
- t.test('nistall', async t => {
- const result = await dym(npm, npm.localPrefix, 'nistall')
- t.match(result, 'npm install')
- })
- t.test('sttest', async t => {
- const result = await dym(npm, npm.localPrefix, 'sttest')
- t.match(result, 'npm test')
- t.match(result, 'npm run posttest')
+ t.test('with package.json', t => {
+ const testdir = t.testdir({
+ 'package.json': JSON.stringify({
+ bin: {
+ npx: 'exists',
+ },
+ scripts: {
+ install: 'exists',
+ posttest: 'exists',
+ },
+ }),
+ })
+ t.test('nistall', async t => {
+ const result = await dym(npm, testdir, 'nistall')
+ t.match(result, 'npm install')
+ })
+ t.test('sttest', async t => {
+ const result = await dym(npm, testdir, 'sttest')
+ t.match(result, 'npm test')
+ t.match(result, 'npm run posttest')
+ })
+ t.test('npz', async t => {
+ const result = await dym(npm, testdir, 'npxx')
+ t.match(result, 'npm exec npx')
+ })
+ t.test('qwuijbo', async t => {
+ const result = await dym(npm, testdir, 'qwuijbo')
+ t.match(result, '')
+ })
+ t.end()
})
- t.test('npz', async t => {
- const result = await dym(npm, npm.localPrefix, 'npxx')
- t.match(result, 'npm exec npx')
+ t.test('with no package.json', t => {
+ const testdir = t.testdir({})
+ t.test('nistall', async t => {
+ const result = await dym(npm, testdir, 'nistall')
+ t.match(result, 'npm install')
+ })
+ t.end()
})
- t.test('qwuijbo', async t => {
- const result = await dym(npm, npm.localPrefix, 'qwuijbo')
- t.match(result, '')
+ t.test('missing bin and script properties', async t => {
+ const testdir = t.testdir({
+ 'package.json': JSON.stringify({
+ name: 'missing-bin',
+ }),
+ })
+
+ const result = await dym(npm, testdir, 'nistall')
+ t.match(result, 'npm install')
})
t.end()
})
})
-
-t.test('missing bin and script properties', async t => {
- const path = t.testdir({
- 'package.json': JSON.stringify({
- name: 'missing-bin',
- }),
- })
-
- const result = await dym(npm, path, 'nistall')
- t.match(result, 'npm install')
-})
diff --git a/deps/npm/test/lib/utils/error-message.js b/deps/npm/test/lib/utils/error-message.js
index d1c67a9513..6b2b5c9222 100644
--- a/deps/npm/test/lib/utils/error-message.js
+++ b/deps/npm/test/lib/utils/error-message.js
@@ -201,6 +201,17 @@ t.test('default message', t => {
t.end()
})
+t.test('args are cleaned', t => {
+ t.matchSnapshot(errorMessage(Object.assign(new Error('cmd err'), {
+ cmd: 'some command',
+ signal: 'SIGYOLO',
+ args: ['a', 'r', 'g', 's', 'https://evil:password@npmjs.org'],
+ stdout: 'stdout',
+ stderr: 'stderr',
+ }), npm))
+ t.end()
+})
+
t.test('eacces/eperm', t => {
const runTest = (windows, loaded, cachePath, cacheDest) => t => {
if (windows)
diff --git a/deps/npm/test/lib/view.js b/deps/npm/test/lib/view.js
index 793917adc6..096ababb29 100644
--- a/deps/npm/test/lib/view.js
+++ b/deps/npm/test/lib/view.js
@@ -17,6 +17,9 @@ const cleanLogs = () => {
console.log = fn
}
+// 25 hours ago
+const yesterday = new Date(Date.now() - 1000 * 60 * 60 * 25)
+
const packument = (nv, opts) => {
if (!opts.fullMetadata)
throw new Error('must fetch fullMetadata')
@@ -40,7 +43,7 @@ const packument = (nv, opts) => {
latest: '1.0.0',
},
time: {
- '1.0.0': '2019-08-06T16:21:09.842Z',
+ '1.0.0': yesterday,
},
versions: {
'1.0.0': {
@@ -332,6 +335,13 @@ t.test('should log package info', t => {
})
})
+ t.test('package with semver range', t => {
+ view.exec(['blue@^1.0.0'], () => {
+ t.matchSnapshot(logs)
+ t.end()
+ })
+ })
+
t.test('package with no modified time', t => {
viewUnicode.exec(['cyan@1.0.0'], () => {
t.matchSnapshot(logs)