Skip to content

Commit b0393fa

Browse files
MylesBorinstargos
authored andcommitted
deps: upgrade npm to 7.2.0
PR-URL: #36543 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 7b8d373 commit b0393fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2217
-562
lines changed

deps/npm/CHANGELOG.md

+59
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,62 @@
1+
## 7.2.0 (2020-12-15)
2+
3+
### FEATURES
4+
5+
* [`a9c4b158c`](https://github.com/npm/cli/commit/a9c4b158c46dd0d0c8d8744a97750ffd0c30cc09)
6+
[#2342](https://github.com/npm/cli/issues/2342)
7+
allow npm rebuild to accept a path to a module
8+
([@nlf](https://github.com/nlf))
9+
10+
### DEPENDENCIES
11+
12+
* [`beb371800`](https://github.com/npm/cli/commit/beb371800292140bf3882253c447168a378bc154)
13+
[#2334](https://github.com/npm/cli/issues/2334)
14+
remove unused top level dep tough-cookie
15+
([@darcyclarke](https://github.com/darcyclarke))
16+
* [`d45e181d1`](https://github.com/npm/cli/commit/d45e181d17dd88d82b3a97f8d9cd5fa5b6230e48)
17+
[#2335](https://github.com/npm/cli/issues/2335)
18+
`ini@2.0.0`, `@npmcli/config@1.2.7`
19+
([@isaacs](https://github.com/isaacs))
20+
* [`ef4b18b5a`](https://github.com/npm/cli/commit/ef4b18b5a70381b264d234817cff32eeb6848a73)
21+
[#2309](https://github.com/npm/cli/issues/2309)
22+
`@npmcli/arborist@2.0.2`
23+
* properly remove deps when no lockfile and package.json is present
24+
* [`c6c013e6e`](https://github.com/npm/cli/commit/c6c013e6ebc4fe036695db1fd491eb68f3b57c68)
25+
`readdir-scoped-modules@1.1.0`
26+
* [`a1a2134aa`](https://github.com/npm/cli/commit/a1a2134aa9a1092493db6d6c9a729ff5203f0dd4)
27+
remove unused sorted-object dep
28+
([@nlf](https://github.com/nlf))
29+
* [`85c2a2d31`](https://github.com/npm/cli/commit/85c2a2d318ae066fb2c161174f5aea97e18bc9c5)
30+
[#2344](https://github.com/npm/cli/issues/2344)
31+
remove editor dependency
32+
([@nlf](https://github.com/nlf))
33+
34+
### TESTING
35+
36+
* [`3a6dd511c`](https://github.com/npm/cli/commit/3a6dd511c944c5f2699825a99bba1dde333a45ef)
37+
npm edit
38+
([@nlf](https://github.com/nlf))
39+
* [`3ba5de4e7`](https://github.com/npm/cli/commit/3ba5de4e7f6c5c0f995a29844926d6ed2833addd)
40+
[#2347](https://github.com/npm/cli/issues/2347)
41+
npm help-search
42+
([@nlf](https://github.com/nlf))
43+
* [`6caf19f49`](https://github.com/npm/cli/commit/6caf19f491e144be3e2a1a50f492dad48b01f361)
44+
[#2348](https://github.com/npm/cli/issues/2348)
45+
npm help
46+
([@nlf](https://github.com/nlf))
47+
* [`cb5847e32`](https://github.com/npm/cli/commit/cb5847e3203c52062485b5de68e4f6d29b33c361)
48+
[#2349](https://github.com/npm/cli/issues/2349)
49+
npm hook
50+
([@nlf](https://github.com/nlf))
51+
* [`996a2f6b1`](https://github.com/npm/cli/commit/996a2f6b130d6678998a2f6a5ec97d75534d5f66)
52+
[#2353](https://github.com/npm/cli/issues/2353)
53+
npm org
54+
([@nlf](https://github.com/nlf))
55+
* [`8c67c38a4`](https://github.com/npm/cli/commit/8c67c38a4f476ff5be938db6b6b3ee9ac6b44db5)
56+
[#2354](https://github.com/npm/cli/issues/2354)
57+
npm set
58+
([@nlf](https://github.com/nlf))
59+
160
## 7.1.2 (2020-12-11)
261

362
### DEPENDENCIES

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.1.2 /path/to/npm
162+
<pre lang="bash"><code>npm@7.2.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.1.2</p>
151+
<p>7.2.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/lib/config.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { promisify } = require('util')
99
const fs = require('fs')
1010
const readFile = promisify(fs.readFile)
1111
const writeFile = promisify(fs.writeFile)
12-
const editor = promisify(require('editor'))
12+
const { spawn } = require('child_process')
1313
const { EOL } = require('os')
1414
const ini = require('ini')
1515

@@ -138,9 +138,6 @@ const del = async key => {
138138

139139
const edit = async () => {
140140
const { editor: e, global } = npm.flatOptions
141-
if (!e)
142-
throw new Error('No `editor` config or EDITOR environment variable set')
143-
144141
const where = global ? 'global' : 'user'
145142
const file = npm.config.data.get(where).source
146143

@@ -183,7 +180,15 @@ ${defData}
183180
`.split('\n').join(EOL)
184181
await mkdirp(dirname(file))
185182
await writeFile(file, tmpData, 'utf8')
186-
await editor(file, { editor: e })
183+
await new Promise((resolve, reject) => {
184+
const [bin, ...args] = e.split(/\s+/)
185+
const editor = spawn(bin, [...args, file], { stdio: 'inherit' })
186+
editor.on('exit', (code) => {
187+
if (code)
188+
return reject(new Error(`editor process exited with code: ${code}`))
189+
return resolve()
190+
})
191+
})
187192
}
188193

189194
const publicVar = k => !/^(\/\/[^:]+:)?_/.test(k)

deps/npm/lib/edit.js

+28-44
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,36 @@
11
// npm edit <pkg>
22
// open the package folder in the $EDITOR
33

4-
module.exports = edit
5-
edit.usage = 'npm edit <pkg>[/<subpkg>...]'
4+
const { resolve } = require('path')
5+
const fs = require('graceful-fs')
6+
const { spawn } = require('child_process')
7+
const npm = require('./npm.js')
8+
const usageUtil = require('./utils/usage.js')
9+
const splitPackageNames = require('./utils/split-package-names.js')
610

7-
edit.completion = require('./utils/completion/installed-shallow.js')
8-
9-
var npm = require('./npm.js')
10-
var path = require('path')
11-
var fs = require('graceful-fs')
12-
var editor = require('editor')
13-
var noProgressTillDone = require('./utils/no-progress-while-running').tillDone
11+
const usage = usageUtil('edit', 'npm edit <pkg>[/<subpkg>...]')
12+
const completion = require('./utils/completion/installed-shallow.js')
1413

1514
function edit (args, cb) {
16-
var p = args[0]
17-
if (args.length !== 1 || !p)
18-
return cb(edit.usage)
19-
var e = npm.config.get('editor')
20-
if (!e) {
21-
return cb(new Error(
22-
"No editor set. Set the 'editor' config, or $EDITOR environ."
23-
))
24-
}
25-
p = p.split('/')
26-
// combine scoped parts
27-
.reduce(function (parts, part) {
28-
if (parts.length === 0)
29-
return [part]
30-
31-
var lastPart = parts[parts.length - 1]
32-
// check if previous part is the first part of a scoped package
33-
if (lastPart[0] === '@' && !lastPart.includes('/'))
34-
parts[parts.length - 1] += '/' + part
35-
else
36-
parts.push(part)
37-
38-
return parts
39-
}, [])
40-
.join('/node_modules/')
41-
.replace(/(\/node_modules)+/, '/node_modules')
42-
var f = path.resolve(npm.dir, p)
43-
fs.lstat(f, function (er) {
44-
if (er)
45-
return cb(er)
46-
editor(f, { editor: e }, noProgressTillDone(function (er) {
47-
if (er)
48-
return cb(er)
49-
npm.commands.rebuild(args, cb)
50-
}))
15+
if (args.length !== 1)
16+
return cb(usage)
17+
18+
const path = splitPackageNames(args[0])
19+
const dir = resolve(npm.dir, path)
20+
21+
fs.lstat(dir, (err) => {
22+
if (err)
23+
return cb(err)
24+
25+
const [bin, ...args] = npm.config.get('editor').split(/\s+/)
26+
const editor = spawn(bin, [...args, dir], { stdio: 'inherit' })
27+
editor.on('exit', (code) => {
28+
if (code)
29+
return cb(new Error(`editor process exited with code: ${code}`))
30+
31+
npm.commands.rebuild([dir], cb)
32+
})
5133
})
5234
}
35+
36+
module.exports = Object.assign(edit, { completion, usage })

deps/npm/lib/help-search.js

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
const fs = require('fs')
22
const path = require('path')
33
const npm = require('./npm.js')
4-
const glob = require('glob')
54
const color = require('ansicolors')
65
const output = require('./utils/output.js')
76
const usageUtil = require('./utils/usage.js')
87
const { promisify } = require('util')
8+
const glob = promisify(require('glob'))
99
const readFile = promisify(fs.readFile)
1010
const didYouMean = require('./utils/did-you-mean.js')
1111
const { cmdList } = require('./utils/cmd-list.js')
@@ -23,12 +23,17 @@ const helpSearch = async args => {
2323

2424
const docPath = path.resolve(__dirname, '..', 'docs/content')
2525

26-
// XXX: make glob return a promise and remove this wrapping
27-
const files = await new Promise((res, rej) =>
28-
glob(`${docPath}/*/*.md`, (er, files) => er ? rej(er) : res(files)))
29-
26+
const files = await glob(`${docPath}/*/*.md`)
3027
const data = await readFiles(files)
3128
const results = await searchFiles(args, data, files)
29+
// if only one result, then just show that help section.
30+
if (results.length === 1) {
31+
return npm.commands.help([path.basename(results[0].file, '.md')], er => {
32+
if (er)
33+
throw er
34+
})
35+
}
36+
3237
const formatted = formatResults(args, results)
3338
if (!formatted.trim())
3439
npmUsage(false)
@@ -125,15 +130,6 @@ const searchFiles = async (args, data, files) => {
125130
})
126131
}
127132

128-
// if only one result, then just show that help section.
129-
if (results.length === 1) {
130-
npm.commands.help([results[0].file.replace(/\.md$/, '')], er => {
131-
if (er)
132-
throw er
133-
})
134-
return []
135-
}
136-
137133
// sort results by number of results found, then by number of hits
138134
// then by number of matching lines
139135
return results.sort((a, b) =>
@@ -147,9 +143,6 @@ const searchFiles = async (args, data, files) => {
147143
}
148144

149145
const formatResults = (args, results) => {
150-
if (!results)
151-
return 'No results for ' + args.map(JSON.stringify).join(' ')
152-
153146
const cols = Math.min(process.stdout.columns || Infinity, 80) + 1
154147

155148
const out = results.map(res => {

deps/npm/lib/help.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ function viewMan (man, cb) {
133133
break
134134

135135
case 'browser':
136-
openUrl(htmlMan(man), 'help available at the following URL', cb)
136+
try {
137+
var url = htmlMan(man)
138+
} catch (err) {
139+
return cb(err)
140+
}
141+
openUrl(url, 'help available at the following URL', cb)
137142
break
138143

139144
default:

deps/npm/lib/org.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ function orgSet (org, user, role, opts) {
7373
memDeets.org.size,
7474
memDeets.user,
7575
memDeets.role,
76-
])
76+
].join('\t'))
7777
} else if (!opts.silent && opts.loglevel !== 'silent')
78-
output(`Added ${memDeets.user} as ${memDeets.role} to ${memDeets.org.name}. You now ${memDeets.org.size} member${memDeets.org.size === 1 ? '' : 's'} in this org.`)
78+
output(`Added ${memDeets.user} as ${memDeets.role} to ${memDeets.org.name}. You now have ${memDeets.org.size} member${memDeets.org.size === 1 ? '' : 's'} in this org.`)
7979

8080
return memDeets
8181
})

deps/npm/lib/rebuild.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,25 @@ const getFilterFn = args => {
3939
const spec = npa(arg)
4040
if (spec.type === 'tag' && spec.rawSpec === '')
4141
return spec
42-
if (spec.type !== 'range' && spec.type !== 'version')
42+
43+
if (spec.type !== 'range' && spec.type !== 'version' && spec.type !== 'directory')
4344
throw new Error('`npm rebuild` only supports SemVer version/range specifiers')
45+
4446
return spec
4547
})
48+
4649
return node => specs.some(spec => {
47-
const { version } = node.package
50+
if (spec.type === 'directory')
51+
return node.path === spec.fetchSpec
52+
4853
if (spec.name !== node.name)
4954
return false
55+
5056
if (spec.rawSpec === '' || spec.rawSpec === '*')
5157
return true
58+
59+
const { version } = node.package
60+
// TODO: add tests for a package with missing version
5261
return semver.satisfies(version, spec.fetchSpec)
5362
})
5463
}

deps/npm/lib/utils/child-path.js

-9
This file was deleted.

deps/npm/lib/utils/completion/file-completion.js

-23
This file was deleted.

deps/npm/lib/utils/deep-sort-object.js

-14
This file was deleted.

0 commit comments

Comments
 (0)