Skip to content

Commit

Permalink
deps: upgrade npm to 8.1.3
Browse files Browse the repository at this point in the history
PR-URL: #40726
Reviewed-By: Myles Borins <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Voltrex <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
npm-robot authored and Trott committed Nov 11, 2021
1 parent fc4a792 commit 6e16297
Show file tree
Hide file tree
Showing 285 changed files with 12,513 additions and 15,221 deletions.
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>[email protected].2 /path/to/npm
<pre lang="bash"><code>[email protected].3 /path/to/npm
└─┬ [email protected]
└── [email protected]
</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>8.1.2</p>
<p>8.1.3</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
5 changes: 2 additions & 3 deletions deps/npm/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
if (require.main === module) {
if (require.main === module)
require('./lib/cli.js')(process)
} else {
else
throw new Error('The programmatic API was removed in npm v8.0.0')
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// a list of workspace names and passes it on to new Arborist() to
// be able to run a filtered Arborist.reify() at some point.

const BaseCommand = require('../base-command.js')
const BaseCommand = require('./base-command.js')
class ArboristCmd extends BaseCommand {
get isArboristCmd () {
return true
Expand All @@ -17,12 +17,9 @@ class ArboristCmd extends BaseCommand {
]
}

execWorkspaces (args, filters, cb) {
this.setWorkspaces(filters, true)
.then(() => {
this.exec(args, cb)
})
.catch(er => cb(er))
async execWorkspaces (args, filters) {
await this.setWorkspaces(filters)
return this.exec(args)
}
}

Expand Down
16 changes: 6 additions & 10 deletions deps/npm/lib/base-command.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Base class for npm.commands[cmd]
// Base class for npm commands
const usageUtil = require('./utils/usage.js')
const ConfigDefinitions = require('./utils/config/definitions.js')
const getWorkspaces = require('./workspaces/get-workspaces.js')
Expand Down Expand Up @@ -53,19 +53,15 @@ class BaseCommand {
return results
}

usageError (msg) {
if (!msg) {
return Object.assign(new Error(`\nUsage: ${this.usage}`), {
code: 'EUSAGE',
})
}

return Object.assign(new Error(`\nUsage: ${msg}\n\n${this.usage}`), {
usageError (prefix = '') {
if (prefix)
prefix += '\n\n'
return Object.assign(new Error(`\nUsage: ${prefix}${this.usage}`), {
code: 'EUSAGE',
})
}

execWorkspaces (args, filters, cb) {
async execWorkspaces (args, filters) {
throw Object.assign(
new Error('This command does not support workspaces.'),
{ code: 'ENOWORKSPACES' }
Expand Down
17 changes: 9 additions & 8 deletions deps/npm/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = async (process) => {

checkForUnsupportedNode()

const npm = require('../lib/npm.js')
const Npm = require('../lib/npm.js')
const npm = new Npm()
const exitHandler = require('../lib/utils/exit-handler.js')
exitHandler.setNpm(npm)

Expand All @@ -38,6 +39,7 @@ module.exports = async (process) => {

const updateNotifier = require('../lib/utils/update-notifier.js')

let cmd
// now actually fire up npm and run the command.
// this is how to use npm programmatically:
try {
Expand All @@ -55,24 +57,23 @@ module.exports = async (process) => {

updateNotifier(npm)

const cmd = npm.argv.shift()
cmd = npm.argv.shift()
if (!cmd) {
npm.output(npm.usage)
npm.output(await npm.usage)
process.exitCode = 1
return exitHandler()
}

const impl = npm.commands[cmd]
if (!impl) {
await npm.exec(cmd, npm.argv)
exitHandler()
} catch (err) {
if (err.code === 'EUNKNOWNCOMMAND') {
const didYouMean = require('./utils/did-you-mean.js')
const suggestions = await didYouMean(npm, npm.localPrefix, cmd)
npm.output(`Unknown command: "${cmd}"${suggestions}\n\nTo see a list of supported npm commands, run:\n npm help`)
process.exitCode = 1
return exitHandler()
}

impl(npm.argv, exitHandler)
} catch (err) {
return exitHandler(err)
}
}
12 changes: 4 additions & 8 deletions deps/npm/lib/access.js → deps/npm/lib/commands/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const path = require('path')
const libaccess = require('libnpmaccess')
const readPackageJson = require('read-package-json-fast')

const otplease = require('./utils/otplease.js')
const getIdentity = require('./utils/get-identity.js')
const BaseCommand = require('./base-command.js')
const otplease = require('../utils/otplease.js')
const getIdentity = require('../utils/get-identity.js')
const BaseCommand = require('../base-command.js')

const subcommands = [
'public',
Expand Down Expand Up @@ -76,11 +76,7 @@ class Access extends BaseCommand {
}
}

exec (args, cb) {
this.access(args).then(() => cb()).catch(cb)
}

async access ([cmd, ...args]) {
async exec ([cmd, ...args]) {
if (!cmd)
throw this.usageError('Subcommand is required.')

Expand Down
18 changes: 7 additions & 11 deletions deps/npm/lib/adduser.js → deps/npm/lib/commands/adduser.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const log = require('npmlog')
const replaceInfo = require('./utils/replace-info.js')
const BaseCommand = require('./base-command.js')
const replaceInfo = require('../utils/replace-info.js')
const BaseCommand = require('../base-command.js')
const authTypes = {
legacy: require('./auth/legacy.js'),
oauth: require('./auth/oauth.js'),
saml: require('./auth/saml.js'),
sso: require('./auth/sso.js'),
legacy: require('../auth/legacy.js'),
oauth: require('../auth/oauth.js'),
saml: require('../auth/saml.js'),
sso: require('../auth/sso.js'),
}

class AddUser extends BaseCommand {
Expand All @@ -24,11 +24,7 @@ class AddUser extends BaseCommand {
]
}

exec (args, cb) {
this.adduser(args).then(() => cb()).catch(cb)
}

async adduser (args) {
async exec (args) {
const { scope } = this.npm.flatOptions
const registry = this.getRegistry(this.npm.flatOptions)
const auth = this.getAuthType(this.npm.flatOptions)
Expand Down
12 changes: 4 additions & 8 deletions deps/npm/lib/audit.js → deps/npm/lib/commands/audit.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const Arborist = require('@npmcli/arborist')
const auditReport = require('npm-audit-report')
const reifyFinish = require('./utils/reify-finish.js')
const auditError = require('./utils/audit-error.js')
const ArboristWorkspaceCmd = require('./workspaces/arborist-cmd.js')
const reifyFinish = require('../utils/reify-finish.js')
const auditError = require('../utils/audit-error.js')
const ArboristWorkspaceCmd = require('../arborist-cmd.js')

class Audit extends ArboristWorkspaceCmd {
/* istanbul ignore next - see test/lib/load-all-commands.js */
Expand Down Expand Up @@ -47,11 +47,7 @@ class Audit extends ArboristWorkspaceCmd {
}
}

exec (args, cb) {
this.audit(args).then(() => cb()).catch(cb)
}

async audit (args) {
async exec (args) {
const reporter = this.npm.config.get('json') ? 'json' : 'detail'
const opts = {
...this.npm.flatOptions,
Expand Down
10 changes: 3 additions & 7 deletions deps/npm/lib/bin.js → deps/npm/lib/commands/bin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const envPath = require('./utils/path.js')
const BaseCommand = require('./base-command.js')
const envPath = require('../utils/path.js')
const BaseCommand = require('../base-command.js')

class Bin extends BaseCommand {
static get description () {
Expand All @@ -14,11 +14,7 @@ class Bin extends BaseCommand {
return ['global']
}

exec (args, cb) {
this.bin(args).then(() => cb()).catch(cb)
}

async bin (args) {
async exec (args) {
const b = this.npm.bin
this.npm.output(b)
if (this.npm.config.get('global') && !envPath.includes(b))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const BaseCommand = require('./base-command.js')
const BaseCommand = require('../base-command.js')

class Birthday extends BaseCommand {
exec (args, cb) {
async exec () {
this.npm.config.set('package', ['@npmcli/npm-birthday'])
this.npm.config.set('yes', true)
return this.npm.commands.exec(['npm-birthday'], cb)
const exec = await this.npm.cmd('exec')
return exec.exec(['npm-birthday'])
}
}

Expand Down
12 changes: 4 additions & 8 deletions deps/npm/lib/bugs.js → deps/npm/lib/commands/bugs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const log = require('npmlog')
const pacote = require('pacote')
const openUrl = require('./utils/open-url.js')
const hostedFromMani = require('./utils/hosted-git-info-from-manifest.js')
const BaseCommand = require('./base-command.js')
const openUrl = require('../utils/open-url.js')
const hostedFromMani = require('../utils/hosted-git-info-from-manifest.js')
const BaseCommand = require('../base-command.js')

class Bugs extends BaseCommand {
static get description () {
Expand All @@ -22,11 +22,7 @@ class Bugs extends BaseCommand {
return ['browser', 'registry']
}

exec (args, cb) {
this.bugs(args).then(() => cb()).catch(cb)
}

async bugs (args) {
async exec (args) {
if (!args || !args.length)
args = ['.']

Expand Down
17 changes: 4 additions & 13 deletions deps/npm/lib/cache.js → deps/npm/lib/commands/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const pacote = require('pacote')
const path = require('path')
const rimraf = promisify(require('rimraf'))
const semver = require('semver')
const BaseCommand = require('./base-command.js')
const BaseCommand = require('../base-command.js')
const npa = require('npm-package-arg')
const jsonParse = require('json-parse-even-better-errors')
const localeCompare = require('@isaacs/string-locale-compare')('en')
Expand Down Expand Up @@ -104,11 +104,7 @@ class Cache extends BaseCommand {
}
}

exec (args, cb) {
this.cache(args).then(() => cb()).catch(cb)
}

async cache (args) {
async exec (args) {
const cmd = args.shift()
switch (cmd) {
case 'rm': case 'clear': case 'clean':
Expand All @@ -120,7 +116,7 @@ class Cache extends BaseCommand {
case 'ls':
return await this.ls(args)
default:
throw Object.assign(new Error(this.usage), { code: 'EUSAGE' })
throw this.usageError()
}
}

Expand Down Expand Up @@ -165,14 +161,9 @@ class Cache extends BaseCommand {
// npm cache add <tarball>...
// npm cache add <folder>...
async add (args) {
const usage = 'Usage:\n' +
' npm cache add <tarball-url>...\n' +
' npm cache add <pkg>@<ver>...\n' +
' npm cache add <tarball>...\n' +
' npm cache add <folder>...\n'
log.silly('cache add', 'args', args)
if (args.length === 0)
throw Object.assign(new Error(usage), { code: 'EUSAGE' })
throw this.usageError('First argument to `add` is required')

return Promise.all(args.map(spec => {
log.silly('cache add', 'spec', spec)
Expand Down
10 changes: 3 additions & 7 deletions deps/npm/lib/ci.js → deps/npm/lib/commands/ci.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const util = require('util')
const Arborist = require('@npmcli/arborist')
const rimraf = util.promisify(require('rimraf'))
const reifyFinish = require('./utils/reify-finish.js')
const reifyFinish = require('../utils/reify-finish.js')
const runScript = require('@npmcli/run-script')
const fs = require('fs')
const readdir = util.promisify(fs.readdir)
Expand All @@ -17,7 +17,7 @@ const removeNodeModules = async where => {
await Promise.all(entries.map(f => rimraf(`${path}/${f}`, rimrafOpts)))
process.emit('timeEnd', 'npm-ci:rm')
}
const ArboristWorkspaceCmd = require('./workspaces/arborist-cmd.js')
const ArboristWorkspaceCmd = require('../arborist-cmd.js')

class CI extends ArboristWorkspaceCmd {
/* istanbul ignore next - see test/lib/load-all-commands.js */
Expand All @@ -39,11 +39,7 @@ class CI extends ArboristWorkspaceCmd {
]
}

exec (args, cb) {
this.ci().then(() => cb()).catch(cb)
}

async ci () {
async exec () {
if (this.npm.config.get('global')) {
const err = new Error('`npm ci` does not work for global packages')
err.code = 'ECIGLOBAL'
Expand Down
Loading

0 comments on commit 6e16297

Please sign in to comment.