Skip to content

Commit

Permalink
deps: upgrade npm to 7.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MylesBorins committed Dec 16, 2020
1 parent 4a6200e commit 1830955
Show file tree
Hide file tree
Showing 41 changed files with 2,217 additions and 562 deletions.
59 changes: 59 additions & 0 deletions deps/npm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
## 7.2.0 (2020-12-15)

### FEATURES

* [`a9c4b158c`](https://github.com/npm/cli/commit/a9c4b158c46dd0d0c8d8744a97750ffd0c30cc09)
[#2342](https://github.com/npm/cli/issues/2342)
allow npm rebuild to accept a path to a module
([@nlf](https://github.com/nlf))

### DEPENDENCIES

* [`beb371800`](https://github.com/npm/cli/commit/beb371800292140bf3882253c447168a378bc154)
[#2334](https://github.com/npm/cli/issues/2334)
remove unused top level dep tough-cookie
([@darcyclarke](https://github.com/darcyclarke))
* [`d45e181d1`](https://github.com/npm/cli/commit/d45e181d17dd88d82b3a97f8d9cd5fa5b6230e48)
[#2335](https://github.com/npm/cli/issues/2335)
`ini@2.0.0`, `@npmcli/config@1.2.7`
([@isaacs](https://github.com/isaacs))
* [`ef4b18b5a`](https://github.com/npm/cli/commit/ef4b18b5a70381b264d234817cff32eeb6848a73)
[#2309](https://github.com/npm/cli/issues/2309)
`@npmcli/arborist@2.0.2`
* properly remove deps when no lockfile and package.json is present
* [`c6c013e6e`](https://github.com/npm/cli/commit/c6c013e6ebc4fe036695db1fd491eb68f3b57c68)
`readdir-scoped-modules@1.1.0`
* [`a1a2134aa`](https://github.com/npm/cli/commit/a1a2134aa9a1092493db6d6c9a729ff5203f0dd4)
remove unused sorted-object dep
([@nlf](https://github.com/nlf))
* [`85c2a2d31`](https://github.com/npm/cli/commit/85c2a2d318ae066fb2c161174f5aea97e18bc9c5)
[#2344](https://github.com/npm/cli/issues/2344)
remove editor dependency
([@nlf](https://github.com/nlf))

### TESTING

* [`3a6dd511c`](https://github.com/npm/cli/commit/3a6dd511c944c5f2699825a99bba1dde333a45ef)
npm edit
([@nlf](https://github.com/nlf))
* [`3ba5de4e7`](https://github.com/npm/cli/commit/3ba5de4e7f6c5c0f995a29844926d6ed2833addd)
[#2347](https://github.com/npm/cli/issues/2347)
npm help-search
([@nlf](https://github.com/nlf))
* [`6caf19f49`](https://github.com/npm/cli/commit/6caf19f491e144be3e2a1a50f492dad48b01f361)
[#2348](https://github.com/npm/cli/issues/2348)
npm help
([@nlf](https://github.com/nlf))
* [`cb5847e32`](https://github.com/npm/cli/commit/cb5847e3203c52062485b5de68e4f6d29b33c361)
[#2349](https://github.com/npm/cli/issues/2349)
npm hook
([@nlf](https://github.com/nlf))
* [`996a2f6b1`](https://github.com/npm/cli/commit/996a2f6b130d6678998a2f6a5ec97d75534d5f66)
[#2353](https://github.com/npm/cli/issues/2353)
npm org
([@nlf](https://github.com/nlf))
* [`8c67c38a4`](https://github.com/npm/cli/commit/8c67c38a4f476ff5be938db6b6b3ee9ac6b44db5)
[#2354](https://github.com/npm/cli/issues/2354)
npm set
([@nlf](https://github.com/nlf))

## 7.1.2 (2020-12-11)

### DEPENDENCIES
Expand Down
2 changes: 1 addition & 1 deletion deps/npm/docs/output/commands/npm-ls.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ <h3 id="description">Description</h3>
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.1.2 /path/to/npm
<pre lang="bash"><code>npm@7.2.0 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
</code></pre>
Expand Down
2 changes: 1 addition & 1 deletion deps/npm/docs/output/commands/npm.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ <h2 id="table-of-contents">Table of contents</h2>
<pre lang="bash"><code>npm &lt;command&gt; [args]
</code></pre>
<h3 id="version">Version</h3>
<p>7.1.2</p>
<p>7.2.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
Expand Down
15 changes: 10 additions & 5 deletions deps/npm/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { promisify } = require('util')
const fs = require('fs')
const readFile = promisify(fs.readFile)
const writeFile = promisify(fs.writeFile)
const editor = promisify(require('editor'))
const { spawn } = require('child_process')
const { EOL } = require('os')
const ini = require('ini')

Expand Down Expand Up @@ -138,9 +138,6 @@ const del = async key => {

const edit = async () => {
const { editor: e, global } = npm.flatOptions
if (!e)
throw new Error('No `editor` config or EDITOR environment variable set')

const where = global ? 'global' : 'user'
const file = npm.config.data.get(where).source

Expand Down Expand Up @@ -183,7 +180,15 @@ ${defData}
`.split('\n').join(EOL)
await mkdirp(dirname(file))
await writeFile(file, tmpData, 'utf8')
await editor(file, { editor: e })
await new Promise((resolve, reject) => {
const [bin, ...args] = e.split(/\s+/)
const editor = spawn(bin, [...args, file], { stdio: 'inherit' })
editor.on('exit', (code) => {
if (code)
return reject(new Error(`editor process exited with code: ${code}`))
return resolve()
})
})
}

const publicVar = k => !/^(\/\/[^:]+:)?_/.test(k)
Expand Down
72 changes: 28 additions & 44 deletions deps/npm/lib/edit.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,36 @@
// npm edit <pkg>
// open the package folder in the $EDITOR

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

edit.completion = require('./utils/completion/installed-shallow.js')

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

function edit (args, cb) {
var p = args[0]
if (args.length !== 1 || !p)
return cb(edit.usage)
var e = npm.config.get('editor')
if (!e) {
return cb(new Error(
"No editor set. Set the 'editor' config, or $EDITOR environ."
))
}
p = p.split('/')
// combine scoped parts
.reduce(function (parts, part) {
if (parts.length === 0)
return [part]

var lastPart = parts[parts.length - 1]
// check if previous part is the first part of a scoped package
if (lastPart[0] === '@' && !lastPart.includes('/'))
parts[parts.length - 1] += '/' + part
else
parts.push(part)

return parts
}, [])
.join('/node_modules/')
.replace(/(\/node_modules)+/, '/node_modules')
var f = path.resolve(npm.dir, p)
fs.lstat(f, function (er) {
if (er)
return cb(er)
editor(f, { editor: e }, noProgressTillDone(function (er) {
if (er)
return cb(er)
npm.commands.rebuild(args, cb)
}))
if (args.length !== 1)
return cb(usage)

const path = splitPackageNames(args[0])
const dir = resolve(npm.dir, path)

fs.lstat(dir, (err) => {
if (err)
return cb(err)

const [bin, ...args] = npm.config.get('editor').split(/\s+/)
const editor = spawn(bin, [...args, dir], { stdio: 'inherit' })
editor.on('exit', (code) => {
if (code)
return cb(new Error(`editor process exited with code: ${code}`))

npm.commands.rebuild([dir], cb)
})
})
}

module.exports = Object.assign(edit, { completion, usage })
27 changes: 10 additions & 17 deletions deps/npm/lib/help-search.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const fs = require('fs')
const path = require('path')
const npm = require('./npm.js')
const glob = require('glob')
const color = require('ansicolors')
const output = require('./utils/output.js')
const usageUtil = require('./utils/usage.js')
const { promisify } = require('util')
const glob = promisify(require('glob'))
const readFile = promisify(fs.readFile)
const didYouMean = require('./utils/did-you-mean.js')
const { cmdList } = require('./utils/cmd-list.js')
Expand All @@ -23,12 +23,17 @@ const helpSearch = async args => {

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

// XXX: make glob return a promise and remove this wrapping
const files = await new Promise((res, rej) =>
glob(`${docPath}/*/*.md`, (er, files) => er ? rej(er) : res(files)))

const files = await glob(`${docPath}/*/*.md`)
const data = await readFiles(files)
const results = await searchFiles(args, data, files)
// if only one result, then just show that help section.
if (results.length === 1) {
return npm.commands.help([path.basename(results[0].file, '.md')], er => {
if (er)
throw er
})
}

const formatted = formatResults(args, results)
if (!formatted.trim())
npmUsage(false)
Expand Down Expand Up @@ -125,15 +130,6 @@ const searchFiles = async (args, data, files) => {
})
}

// if only one result, then just show that help section.
if (results.length === 1) {
npm.commands.help([results[0].file.replace(/\.md$/, '')], er => {
if (er)
throw er
})
return []
}

// sort results by number of results found, then by number of hits
// then by number of matching lines
return results.sort((a, b) =>
Expand All @@ -147,9 +143,6 @@ const searchFiles = async (args, data, files) => {
}

const formatResults = (args, results) => {
if (!results)
return 'No results for ' + args.map(JSON.stringify).join(' ')

const cols = Math.min(process.stdout.columns || Infinity, 80) + 1

const out = results.map(res => {
Expand Down
7 changes: 6 additions & 1 deletion deps/npm/lib/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ function viewMan (man, cb) {
break

case 'browser':
openUrl(htmlMan(man), 'help available at the following URL', cb)
try {
var url = htmlMan(man)
} catch (err) {
return cb(err)
}
openUrl(url, 'help available at the following URL', cb)
break

default:
Expand Down
4 changes: 2 additions & 2 deletions deps/npm/lib/org.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ function orgSet (org, user, role, opts) {
memDeets.org.size,
memDeets.user,
memDeets.role,
])
].join('\t'))
} else if (!opts.silent && opts.loglevel !== 'silent')
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.`)
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.`)

return memDeets
})
Expand Down
13 changes: 11 additions & 2 deletions deps/npm/lib/rebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,25 @@ const getFilterFn = args => {
const spec = npa(arg)
if (spec.type === 'tag' && spec.rawSpec === '')
return spec
if (spec.type !== 'range' && spec.type !== 'version')

if (spec.type !== 'range' && spec.type !== 'version' && spec.type !== 'directory')
throw new Error('`npm rebuild` only supports SemVer version/range specifiers')

return spec
})

return node => specs.some(spec => {
const { version } = node.package
if (spec.type === 'directory')
return node.path === spec.fetchSpec

if (spec.name !== node.name)
return false

if (spec.rawSpec === '' || spec.rawSpec === '*')
return true

const { version } = node.package
// TODO: add tests for a package with missing version
return semver.satisfies(version, spec.fetchSpec)
})
}
Expand Down
9 changes: 0 additions & 9 deletions deps/npm/lib/utils/child-path.js

This file was deleted.

23 changes: 0 additions & 23 deletions deps/npm/lib/utils/completion/file-completion.js

This file was deleted.

14 changes: 0 additions & 14 deletions deps/npm/lib/utils/deep-sort-object.js

This file was deleted.

Loading

0 comments on commit 1830955

Please sign in to comment.