Skip to content

Commit 85206b7

Browse files
npm-robotBethGriggs
authored andcommittedSep 21, 2021
deps: upgrade npm to 7.24.0
PR-URL: #40167 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 0254b4b commit 85206b7

28 files changed

+429
-181
lines changed
 

‎deps/npm/docs/content/using-npm/scripts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ package.json file, then your package scripts would have the
259259
in your code with `process.env.npm_package_name` and
260260
`process.env.npm_package_version`, and so on for other fields.
261261

262-
See [`package-json.md`](/using-npm/package-json) for more on package configs.
262+
See [`package-json.md`](/configuring-npm/package-json) for more on package configs.
263263

264264
#### current lifecycle event
265265

‎deps/npm/docs/output/commands/npm-ls.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ <h3 id="description">Description</h3>
159159
the results to only the paths to the packages named. Note that nested
160160
packages will <em>also</em> show the paths to the specified packages. For
161161
example, running <code>npm ls promzard</code> in npm’s source tree will show:</p>
162-
<pre lang="bash"><code>npm@7.23.0 /path/to/npm
162+
<pre lang="bash"><code>npm@7.24.0 /path/to/npm
163163
└─┬ init-package-json@0.0.4
164164
└── promzard@0.1.5
165165
</code></pre>

‎deps/npm/docs/output/commands/npm.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ <h2 id="table-of-contents">Table of contents</h2>
148148
<pre lang="bash"><code>npm &lt;command&gt; [args]
149149
</code></pre>
150150
<h3 id="version">Version</h3>
151-
<p>7.23.0</p>
151+
<p>7.24.0</p>
152152
<h3 id="description">Description</h3>
153153
<p>npm is the package manager for the Node JavaScript platform. It puts
154154
modules in place so that node can find them, and manages dependency

‎deps/npm/docs/output/using-npm/scripts.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ <h4 id="packagejson-vars">package.json vars</h4>
379379
<code>npm_package_version</code> set to “1.2.5”. You can access these variables
380380
in your code with <code>process.env.npm_package_name</code> and
381381
<code>process.env.npm_package_version</code>, and so on for other fields.</p>
382-
<p>See <a href="../using-npm/package-json.html"><code>package-json.md</code></a> for more on package configs.</p>
382+
<p>See <a href="../configuring-npm/package-json.html"><code>package-json.md</code></a> for more on package configs.</p>
383383
<h4 id="current-lifecycle-event">current lifecycle event</h4>
384384
<p>Lastly, the <code>npm_lifecycle_event</code> environment variable is set to
385385
whichever stage of the cycle is being executed. So, you could have a

‎deps/npm/lib/install.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ class Install extends ArboristWorkspaceCmd {
135135
// be very strict about engines when trying to update npm itself
136136
const npmInstall = args.find(arg => arg.startsWith('npm@') || arg === 'npm')
137137
if (isGlobalInstall && npmInstall) {
138-
const npmManifest = await pacote.manifest(npmInstall)
138+
const npmOptions = this.npm.flatOptions
139+
const npmManifest = await pacote.manifest(npmInstall, npmOptions)
139140
try {
140141
checks.checkEngine(npmManifest, npmManifest.version, process.version)
141142
} catch (e) {

‎deps/npm/lib/search/format-package-stream.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class JSONOutputStream extends Minipass {
4242
}
4343

4444
end () {
45-
super.write(this._didFirst ? ']\n' : '\n]\n')
45+
super.write(this._didFirst ? ']\n' : '\n[]\n')
4646
super.end()
4747
}
4848
}

‎deps/npm/lib/utils/config/definitions.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -2053,10 +2053,14 @@ define('user-agent', {
20532053
.replace(/\{workspaces\}/gi, inWorkspaces)
20542054
.replace(/\{ci\}/gi, ciName ? `ci/${ciName}` : '')
20552055
.trim()
2056+
2057+
// We can't clobber the original or else subsequent flattening will fail
2058+
// (i.e. when we change the underlying config values)
2059+
// obj[key] = flatOptions.userAgent
2060+
20562061
// user-agent is a unique kind of config item that gets set from a template
20572062
// and ends up translated. Because of this, the normal "should we set this
20582063
// to process.env also doesn't work
2059-
obj[key] = flatOptions.userAgent
20602064
process.env.npm_config_user_agent = flatOptions.userAgent
20612065
},
20622066
})
@@ -2140,6 +2144,9 @@ define('workspace', {
21402144
a workspace which does not yet exist, to create the folder and set it
21412145
up as a brand new workspace within the project.
21422146
`,
2147+
flatten: (key, obj, flatOptions) => {
2148+
definitions['user-agent'].flatten('user-agent', obj, flatOptions)
2149+
},
21432150
})
21442151

21452152
define('workspaces', {
@@ -2151,6 +2158,9 @@ define('workspaces', {
21512158
Enable running a command in the context of **all** the configured
21522159
workspaces.
21532160
`,
2161+
flatten: (key, obj, flatOptions) => {
2162+
definitions['user-agent'].flatten('user-agent', obj, flatOptions)
2163+
},
21542164
})
21552165

21562166
define('yes', {

‎deps/npm/lib/utils/did-you-mean.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@ const readJson = require('read-package-json-fast')
33
const { cmdList } = require('./cmd-list.js')
44

55
const didYouMean = async (npm, path, scmd) => {
6-
const bestCmd = cmdList
6+
let best = cmdList
77
.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 && scmd !== cmd)
88
.map(str => ` npm ${str} # ${npm.commands[str].description}`)
99

10-
const pkg = await readJson(`${path}/package.json`)
11-
const { scripts } = pkg
1210
// We would already be suggesting this in `npm x` so omit them here
1311
const runScripts = ['stop', 'start', 'test', 'restart']
14-
const bestRun = Object.keys(scripts || {})
15-
.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 &&
16-
!runScripts.includes(cmd))
17-
.map(str => ` npm run ${str} # run the "${str}" package script`)
18-
19-
const { bin } = pkg
20-
const bestBin = Object.keys(bin || {})
21-
.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4)
22-
.map(str => ` npm exec ${str} # run the "${str}" command from either this or a remote npm package`)
23-
24-
const best = [...bestCmd, ...bestRun, ...bestBin]
12+
try {
13+
const { bin, scripts } = await readJson(`${path}/package.json`)
14+
best = best.concat(
15+
Object.keys(scripts || {})
16+
.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 &&
17+
!runScripts.includes(cmd))
18+
.map(str => ` npm run ${str} # run the "${str}" package script`),
19+
Object.keys(bin || {})
20+
.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4)
21+
.map(str => ` npm exec ${str} # run the "${str}" command from either this or a remote npm package`)
22+
)
23+
} catch (_) {
24+
// gracefully ignore not being in a folder w/ a package.json
25+
}
2526

2627
if (best.length === 0)
2728
return ''

‎deps/npm/lib/utils/error-message.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ module.exports = (er, npm) => {
367367
detail.push(['signal', er.signal])
368368

369369
if (er.cmd && Array.isArray(er.args))
370-
detail.push(['command', ...[er.cmd, ...er.args]])
370+
detail.push(['command', ...[er.cmd, ...er.args.map(replaceInfo)]])
371371

372372
if (er.stdout)
373373
detail.push(['', er.stdout.trim()])

‎deps/npm/lib/view.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ class View extends BaseCommand {
336336
email: color.cyan(manifest._npmUser.email),
337337
}),
338338
modified: !packument.time ? undefined
339-
: color.yellow(relativeDate(packument.time[packument.version])),
339+
: color.yellow(relativeDate(packument.time[manifest.version])),
340340
maintainers: (packument.maintainers || []).map((u) => unparsePerson({
341341
name: color.yellow(u.name),
342342
email: color.cyan(u.email),

‎deps/npm/man/man1/npm-ls.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ example, running \fBnpm ls promzard\fP in npm's source tree will show:
2626
.P
2727
.RS 2
2828
.nf
29-
npm@7\.23\.0 /path/to/npm
29+
npm@7\.24\.0 /path/to/npm
3030
└─┬ init\-package\-json@0\.0\.4
3131
└── promzard@0\.1\.5
3232
.fi

‎deps/npm/man/man1/npm.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ npm <command> [args]
1010
.RE
1111
.SS Version
1212
.P
13-
7\.23\.0
13+
7\.24\.0
1414
.SS Description
1515
.P
1616
npm is the package manager for the Node JavaScript platform\. It puts

‎deps/npm/node_modules/init-package-json/LICENSE

-15
This file was deleted.

‎deps/npm/node_modules/init-package-json/LICENSE.md

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deps/npm/node_modules/init-package-json/default-input.js ‎deps/npm/node_modules/init-package-json/lib/default-input.js

+116-61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deps/npm/node_modules/init-package-json/init-package-json.js ‎deps/npm/node_modules/init-package-json/lib/init-package-json.js

+41-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deps/npm/node_modules/init-package-json/package.json

+20-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deps/npm/node_modules/minipass/index.js

+12-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deps/npm/node_modules/minipass/package.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deps/npm/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "7.23.0",
2+
"version": "7.24.0",
33
"name": "npm",
44
"description": "a package manager for JavaScript",
55
"workspaces": [
@@ -74,7 +74,7 @@
7474
"graceful-fs": "^4.2.8",
7575
"hosted-git-info": "^4.0.2",
7676
"ini": "^2.0.0",
77-
"init-package-json": "^2.0.4",
77+
"init-package-json": "^2.0.5",
7878
"is-cidr": "^4.0.2",
7979
"json-parse-even-better-errors": "^2.3.1",
8080
"libnpmaccess": "^4.0.2",

‎deps/npm/tap-snapshots/test/lib/config.js.test.cjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ exports[`test/lib/config.js TAP config list --json > output matches snapshot 1`]
146146
"unicode": false,
147147
"update-notifier": true,
148148
"usage": false,
149-
"user-agent": "npm/{NPM-VERSION} node/{NODE-VERSION} {PLATFORM} {ARCH} workspaces/false",
149+
"user-agent": "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}",
150150
"version": false,
151151
"versions": false,
152152
"viewer": "{VIEWER}",
@@ -296,7 +296,7 @@ umask = 0
296296
unicode = false
297297
update-notifier = true
298298
usage = false
299-
user-agent = "npm/{NPM-VERSION} node/{NODE-VERSION} {PLATFORM} {ARCH} workspaces/false"
299+
user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}"
300300
; userconfig = "{HOME}/.npmrc" ; overridden by cli
301301
version = false
302302
versions = false

‎deps/npm/tap-snapshots/test/lib/utils/error-message.js.test.cjs

+34
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,40 @@ Object {
180180
}
181181
`
182182

183+
exports[`test/lib/utils/error-message.js TAP args are cleaned > must match snapshot 1`] = `
184+
Object {
185+
"detail": Array [
186+
Array [
187+
"signal",
188+
"SIGYOLO",
189+
],
190+
Array [
191+
"command",
192+
"some command",
193+
"a",
194+
"r",
195+
"g",
196+
"s",
197+
"https://evil:***@npmjs.org",
198+
],
199+
Array [
200+
"",
201+
"stdout",
202+
],
203+
Array [
204+
"",
205+
"stderr",
206+
],
207+
],
208+
"summary": Array [
209+
Array [
210+
"",
211+
"cmd err",
212+
],
213+
],
214+
}
215+
`
216+
183217
exports[`test/lib/utils/error-message.js TAP bad engine with config loaded > must match snapshot 1`] = `
184218
Object {
185219
"detail": Array [

‎deps/npm/tap-snapshots/test/lib/view.js.test.cjs

+20-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ dist
8282
dist-tags:
8383
latest: 1.0.0
8484
85-
published {TIME} ago[39m
85+
published [33myesterday[39m
8686
`
8787

8888
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
9999
dist-tags:
100100
latest: 1.0.0
101101
102-
published {TIME} ago[39m
102+
published [33myesterday[39m
103103
`
104104

105105
exports[`test/lib/view.js TAP should log package info package from git > must match snapshot 1`] = `
@@ -302,7 +302,24 @@ dist
302302
dist-tags:
303303
latest: 1.0.0
304304
305-
published {TIME} ago
305+
published yesterday
306+
`
307+
308+
exports[`test/lib/view.js TAP should log package info package with semver range > must match snapshot 1`] = `
309+
310+
311+
blue@1.0.0 | Proprietary | deps: none | versions: 2
312+
313+
dist
314+
.tarball:http://hm.blue.com/1.0.0.tgz
315+
.shasum:123
316+
.integrity:---
317+
.unpackedSize:1 B
318+
319+
dist-tags:
320+
latest: 1.0.0
321+
322+
published yesterday
306323
`
307324

308325
exports[`test/lib/view.js TAP workspaces all workspaces --json > must match snapshot 1`] = `

‎deps/npm/test/lib/search.js

+31
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,37 @@ t.test('search <name> --json', (t) => {
130130
src.end()
131131
})
132132

133+
t.test('search <invalid-module> --json', (t) => {
134+
const src = new Minipass()
135+
src.objectMode = true
136+
137+
npm.flatOptions.json = true
138+
config.json = true
139+
const libnpmsearch = {
140+
stream () {
141+
return src
142+
},
143+
}
144+
145+
const Search = t.mock('../../lib/search.js', {
146+
...mocks,
147+
libnpmsearch,
148+
})
149+
const search = new Search(npm)
150+
151+
search.exec(['foo'], (err) => {
152+
if (err)
153+
throw err
154+
155+
t.equal(result, '\n[]\n', 'should have expected empty square brackets')
156+
157+
config.json = false
158+
t.end()
159+
})
160+
161+
src.end()
162+
})
163+
133164
t.test('search <name> --searchexclude --searchopts', t => {
134165
npm.flatOptions.search = {
135166
...flatOptions.search,

‎deps/npm/test/lib/utils/config/definitions.js

+26-4
Original file line numberDiff line numberDiff line change
@@ -747,15 +747,15 @@ t.test('user-agent', t => {
747747
definitions['user-agent'].flatten('user-agent', obj, flat)
748748
t.equal(flat.userAgent, expectNoCI)
749749
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
750-
t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
750+
t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')
751751

752752
obj['ci-name'] = 'foo'
753753
obj['user-agent'] = definitions['user-agent'].default
754754
const expectCI = `${expectNoCI} ci/foo`
755755
definitions['user-agent'].flatten('user-agent', obj, flat)
756756
t.equal(flat.userAgent, expectCI)
757757
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
758-
t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
758+
t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')
759759

760760
delete obj['ci-name']
761761
obj.workspaces = true
@@ -764,15 +764,15 @@ t.test('user-agent', t => {
764764
definitions['user-agent'].flatten('user-agent', obj, flat)
765765
t.equal(flat.userAgent, expectWorkspaces)
766766
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
767-
t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
767+
t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')
768768

769769
delete obj.workspaces
770770
obj.workspace = ['foo']
771771
obj['user-agent'] = definitions['user-agent'].default
772772
definitions['user-agent'].flatten('user-agent', obj, flat)
773773
t.equal(flat.userAgent, expectWorkspaces)
774774
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
775-
t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
775+
t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')
776776
t.end()
777777
})
778778

@@ -853,3 +853,25 @@ t.test('package-lock-only', t => {
853853
t.strictSame(flat, { packageLock: false, packageLockOnly: false })
854854
t.end()
855855
})
856+
857+
t.test('workspaces', t => {
858+
const obj = {
859+
workspaces: true,
860+
'user-agent': definitions['user-agent'].default,
861+
}
862+
const flat = {}
863+
definitions.workspaces.flatten('workspaces', obj, flat)
864+
t.match(flat.userAgent, /workspaces\/true/)
865+
t.end()
866+
})
867+
868+
t.test('workspace', t => {
869+
const obj = {
870+
workspace: ['workspace-a'],
871+
'user-agent': definitions['user-agent'].default,
872+
}
873+
const flat = {}
874+
definitions.workspace.flatten('workspaces', obj, flat)
875+
t.match(flat.userAgent, /workspaces\/true/)
876+
t.end()
877+
})

‎deps/npm/test/lib/utils/did-you-mean.js

+46-25
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,55 @@ const dym = require('../../../lib/utils/did-you-mean.js')
55
t.test('did-you-mean', t => {
66
npm.load(err => {
77
t.notOk(err)
8-
t.test('nistall', async t => {
9-
const result = await dym(npm, npm.localPrefix, 'nistall')
10-
t.match(result, 'npm install')
11-
})
12-
t.test('sttest', async t => {
13-
const result = await dym(npm, npm.localPrefix, 'sttest')
14-
t.match(result, 'npm test')
15-
t.match(result, 'npm run posttest')
8+
t.test('with package.json', t => {
9+
const testdir = t.testdir({
10+
'package.json': JSON.stringify({
11+
bin: {
12+
npx: 'exists',
13+
},
14+
scripts: {
15+
install: 'exists',
16+
posttest: 'exists',
17+
},
18+
}),
19+
})
20+
t.test('nistall', async t => {
21+
const result = await dym(npm, testdir, 'nistall')
22+
t.match(result, 'npm install')
23+
})
24+
t.test('sttest', async t => {
25+
const result = await dym(npm, testdir, 'sttest')
26+
t.match(result, 'npm test')
27+
t.match(result, 'npm run posttest')
28+
})
29+
t.test('npz', async t => {
30+
const result = await dym(npm, testdir, 'npxx')
31+
t.match(result, 'npm exec npx')
32+
})
33+
t.test('qwuijbo', async t => {
34+
const result = await dym(npm, testdir, 'qwuijbo')
35+
t.match(result, '')
36+
})
37+
t.end()
1638
})
17-
t.test('npz', async t => {
18-
const result = await dym(npm, npm.localPrefix, 'npxx')
19-
t.match(result, 'npm exec npx')
39+
t.test('with no package.json', t => {
40+
const testdir = t.testdir({})
41+
t.test('nistall', async t => {
42+
const result = await dym(npm, testdir, 'nistall')
43+
t.match(result, 'npm install')
44+
})
45+
t.end()
2046
})
21-
t.test('qwuijbo', async t => {
22-
const result = await dym(npm, npm.localPrefix, 'qwuijbo')
23-
t.match(result, '')
47+
t.test('missing bin and script properties', async t => {
48+
const testdir = t.testdir({
49+
'package.json': JSON.stringify({
50+
name: 'missing-bin',
51+
}),
52+
})
53+
54+
const result = await dym(npm, testdir, 'nistall')
55+
t.match(result, 'npm install')
2456
})
2557
t.end()
2658
})
2759
})
28-
29-
t.test('missing bin and script properties', async t => {
30-
const path = t.testdir({
31-
'package.json': JSON.stringify({
32-
name: 'missing-bin',
33-
}),
34-
})
35-
36-
const result = await dym(npm, path, 'nistall')
37-
t.match(result, 'npm install')
38-
})

‎deps/npm/test/lib/utils/error-message.js

+11
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ t.test('default message', t => {
201201
t.end()
202202
})
203203

204+
t.test('args are cleaned', t => {
205+
t.matchSnapshot(errorMessage(Object.assign(new Error('cmd err'), {
206+
cmd: 'some command',
207+
signal: 'SIGYOLO',
208+
args: ['a', 'r', 'g', 's', 'https://evil:password@npmjs.org'],
209+
stdout: 'stdout',
210+
stderr: 'stderr',
211+
}), npm))
212+
t.end()
213+
})
214+
204215
t.test('eacces/eperm', t => {
205216
const runTest = (windows, loaded, cachePath, cacheDest) => t => {
206217
if (windows)

‎deps/npm/test/lib/view.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ const cleanLogs = () => {
1717
console.log = fn
1818
}
1919

20+
// 25 hours ago
21+
const yesterday = new Date(Date.now() - 1000 * 60 * 60 * 25)
22+
2023
const packument = (nv, opts) => {
2124
if (!opts.fullMetadata)
2225
throw new Error('must fetch fullMetadata')
@@ -40,7 +43,7 @@ const packument = (nv, opts) => {
4043
latest: '1.0.0',
4144
},
4245
time: {
43-
'1.0.0': '2019-08-06T16:21:09.842Z',
46+
'1.0.0': yesterday,
4447
},
4548
versions: {
4649
'1.0.0': {
@@ -332,6 +335,13 @@ t.test('should log package info', t => {
332335
})
333336
})
334337

338+
t.test('package with semver range', t => {
339+
view.exec(['blue@^1.0.0'], () => {
340+
t.matchSnapshot(logs)
341+
t.end()
342+
})
343+
})
344+
335345
t.test('package with no modified time', t => {
336346
viewUnicode.exec(['cyan@1.0.0'], () => {
337347
t.matchSnapshot(logs)

0 commit comments

Comments
 (0)
Please sign in to comment.