summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/@npmcli/arborist
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/@npmcli/arborist')
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/README.md10
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/actual.js36
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/audit.js49
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/funding.js66
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/ideal.js29
-rwxr-xr-xdeps/npm/node_modules/@npmcli/arborist/bin/index.js155
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/lib/logging.js88
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/lib/options.js170
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/lib/print-tree.js5
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/lib/timers.js32
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/license.js78
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/prune.js43
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/reify.js43
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/shrinkwrap.js15
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/bin/virtual.js26
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js23
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js25
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js4
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js7
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js21
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js13
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/get-workspace-nodes.js5
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js12
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/tracker.js23
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/package.json18
25 files changed, 558 insertions, 438 deletions
diff --git a/deps/npm/node_modules/@npmcli/arborist/README.md b/deps/npm/node_modules/@npmcli/arborist/README.md
index 8722b7a43c..ee79a3bf2f 100644
--- a/deps/npm/node_modules/@npmcli/arborist/README.md
+++ b/deps/npm/node_modules/@npmcli/arborist/README.md
@@ -333,3 +333,13 @@ pruning nodes from the tree.
Note: `devOptional` is only set in the shrinkwrap/package-lock file if
_neither_ `dev` nor `optional` are set, as it would be redundant.
+
+## BIN
+
+Arborist ships with a cli that can be used to run arborist specific commands outside of the context of the npm CLI. This script is currently not part of the public API and is subject to breaking changes outside of major version bumps.
+
+To see the usage run:
+
+```
+npx @npmcli/arborist --help
+```
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/actual.js b/deps/npm/node_modules/@npmcli/arborist/bin/actual.js
index eb0495997a..866b2cd82f 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/actual.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/actual.js
@@ -1,23 +1,19 @@
const Arborist = require('../')
-const print = require('./lib/print-tree.js')
-const options = require('./lib/options.js')
-require('./lib/logging.js')
-require('./lib/timers.js')
-const start = process.hrtime()
-new Arborist(options).loadActual(options).then(tree => {
- const end = process.hrtime(start)
- if (!process.argv.includes('--quiet')) {
- print(tree)
- }
+const printTree = require('./lib/print-tree.js')
- console.error(`read ${tree.inventory.size} deps in ${end[0] * 1000 + end[1] / 1e6}ms`)
- if (options.save) {
- tree.meta.save()
- }
- if (options.saveHidden) {
- tree.meta.hiddenLockfile = true
- tree.meta.filename = options.path + '/node_modules/.package-lock.json'
- tree.meta.save()
- }
-}).catch(er => console.error(er))
+module.exports = (options, time) => new Arborist(options)
+ .loadActual(options)
+ .then(time)
+ .then(async ({ timing, result: tree }) => {
+ printTree(tree)
+ if (options.save) {
+ await tree.meta.save()
+ }
+ if (options.saveHidden) {
+ tree.meta.hiddenLockfile = true
+ tree.meta.filename = options.path + '/node_modules/.package-lock.json'
+ await tree.meta.save()
+ }
+ return `read ${tree.inventory.size} deps in ${timing.ms}`
+ })
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/audit.js b/deps/npm/node_modules/@npmcli/arborist/bin/audit.js
index d9ac532d3e..0e32833d4a 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/audit.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/audit.js
@@ -1,19 +1,17 @@
const Arborist = require('../')
-const print = require('./lib/print-tree.js')
-const options = require('./lib/options.js')
-require('./lib/timers.js')
-require('./lib/logging.js')
+const printTree = require('./lib/print-tree.js')
+const log = require('./lib/logging.js')
const Vuln = require('../lib/vuln.js')
const printReport = report => {
for (const vuln of report.values()) {
- console.log(printVuln(vuln))
+ log.info(printVuln(vuln))
}
if (report.topVulns.size) {
- console.log('\n# top-level vulnerabilities')
+ log.info('\n# top-level vulnerabilities')
for (const vuln of report.topVulns.values()) {
- console.log(printVuln(vuln))
+ log.info(printVuln(vuln))
}
}
}
@@ -33,22 +31,21 @@ const printVuln = vuln => {
const printAdvisory = a => `${a.title}${a.url ? ' ' + a.url : ''}`
-const start = process.hrtime()
-process.emit('time', 'audit script')
-const arb = new Arborist(options)
-arb.audit(options).then(tree => {
- process.emit('timeEnd', 'audit script')
- const end = process.hrtime(start)
- if (options.fix) {
- print(tree)
- }
- if (!options.quiet) {
- printReport(arb.auditReport)
- }
- if (options.fix) {
- console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 1e9}s`)
- }
- if (tree.meta && options.save) {
- tree.meta.save()
- }
-}).catch(er => console.error(er))
+module.exports = (options, time) => {
+ const arb = new Arborist(options)
+ return arb
+ .audit(options)
+ .then(time)
+ .then(async ({ timing, result: tree }) => {
+ if (options.fix) {
+ printTree(tree)
+ }
+ printReport(arb.auditReport)
+ if (tree.meta && options.save) {
+ await tree.meta.save()
+ }
+ return options.fix
+ ? `resolved ${tree.inventory.size} deps in ${timing.seconds}`
+ : `done in ${timing.seconds}`
+ })
+}
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/funding.js b/deps/npm/node_modules/@npmcli/arborist/bin/funding.js
index d0f4f31654..cf25976d94 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/funding.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/funding.js
@@ -1,34 +1,38 @@
-const options = require('./lib/options.js')
-require('./lib/logging.js')
-require('./lib/timers.js')
-
const Arborist = require('../')
-const a = new Arborist(options)
-const query = options._.shift()
-const start = process.hrtime()
-a.loadVirtual().then(tree => {
- // only load the actual tree if the virtual one doesn't have modern metadata
- if (!tree.meta || !(tree.meta.originalLockfileVersion >= 2)) {
- console.error('old metadata, load actual')
- throw 'load actual'
- } else {
- console.error('meta ok, return virtual tree')
- return tree
- }
-}).catch(() => a.loadActual()).then(tree => {
- const end = process.hrtime(start)
- if (!query) {
- for (const node of tree.inventory.values()) {
- if (node.package.funding) {
- console.log(node.name, node.location, node.package.funding)
+
+const log = require('./lib/logging.js')
+
+module.exports = (options, time) => {
+ const query = options._.shift()
+ const a = new Arborist(options)
+ return a
+ .loadVirtual()
+ .then(tree => {
+ // only load the actual tree if the virtual one doesn't have modern metadata
+ if (!tree.meta || !(tree.meta.originalLockfileVersion >= 2)) {
+ log.error('old metadata, load actual')
+ throw 'load actual'
+ } else {
+ log.error('meta ok, return virtual tree')
+ return tree
}
- }
- } else {
- for (const node of tree.inventory.query('name', query)) {
- if (node.package.funding) {
- console.log(node.name, node.location, node.package.funding)
+ })
+ .catch(() => a.loadActual())
+ .then(time)
+ .then(({ timing, result: tree }) => {
+ if (!query) {
+ for (const node of tree.inventory.values()) {
+ if (node.package.funding) {
+ log.info(node.name, node.location, node.package.funding)
+ }
+ }
+ } else {
+ for (const node of tree.inventory.query('name', query)) {
+ if (node.package.funding) {
+ log.info(node.name, node.location, node.package.funding)
+ }
+ }
}
- }
- }
- console.error(`read ${tree.inventory.size} deps in ${end[0] * 1000 + end[1] / 1e6}ms`)
-})
+ return `read ${tree.inventory.size} deps in ${timing.ms}`
+ })
+}
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/ideal.js b/deps/npm/node_modules/@npmcli/arborist/bin/ideal.js
index 5d1ed0dcd9..1dd206e81f 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/ideal.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/ideal.js
@@ -1,21 +1,14 @@
const Arborist = require('../')
-const { inspect } = require('util')
-const options = require('./lib/options.js')
-const print = require('./lib/print-tree.js')
-require('./lib/logging.js')
-require('./lib/timers.js')
+const printTree = require('./lib/print-tree.js')
-const start = process.hrtime()
-new Arborist(options).buildIdealTree(options).then(tree => {
- const end = process.hrtime(start)
- print(tree)
- console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 10e9}s`)
- if (tree.meta && options.save) {
- tree.meta.save()
- }
-}).catch(er => {
- const opt = { depth: Infinity, color: true }
- console.error(er.code === 'ERESOLVE' ? inspect(er, opt) : er)
- process.exitCode = 1
-})
+module.exports = (options, time) => new Arborist(options)
+ .buildIdealTree(options)
+ .then(time)
+ .then(async ({ timing, result: tree }) => {
+ printTree(tree)
+ if (tree.meta && options.save) {
+ await tree.meta.save()
+ }
+ return `resolved ${tree.inventory.size} deps in ${timing.seconds}`
+ })
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/index.js b/deps/npm/node_modules/@npmcli/arborist/bin/index.js
index 5449a50e67..0c1e984453 100755
--- a/deps/npm/node_modules/@npmcli/arborist/bin/index.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/index.js
@@ -1,81 +1,110 @@
#!/usr/bin/env node
-const [cmd] = process.argv.splice(2, 1)
-const usage = () => `Arborist - the npm tree doctor
+const fs = require('fs')
+const path = require('path')
-Version: ${require('../package.json').version}
+const { bin, arb: options } = require('./lib/options')
+const version = require('../package.json').version
+const usage = (message = '') => `Arborist - the npm tree doctor
+
+Version: ${version}
+${message && '\n' + message + '\n'}
# USAGE
arborist <cmd> [path] [options...]
# COMMANDS
-* reify: reify ideal tree to node_modules (install, update, rm, ...)
-* prune: prune the ideal tree and reify (like npm prune)
-* ideal: generate and print the ideal tree
-* actual: read and print the actual tree in node_modules
-* virtual: read and print the virtual tree in the local shrinkwrap file
-* shrinkwrap: load a local shrinkwrap and print its data
-* audit: perform a security audit on project dependencies
-* funding: query funding information in the local package tree. A second
- positional argument after the path name can limit to a package name.
-* license: query license information in the local package tree. A second
- positional argument after the path name can limit to a license type.
-* help: print this text
+ * reify: reify ideal tree to node_modules (install, update, rm, ...)
+ * prune: prune the ideal tree and reify (like npm prune)
+ * ideal: generate and print the ideal tree
+ * actual: read and print the actual tree in node_modules
+ * virtual: read and print the virtual tree in the local shrinkwrap file
+ * shrinkwrap: load a local shrinkwrap and print its data
+ * audit: perform a security audit on project dependencies
+ * funding: query funding information in the local package tree. A second
+ positional argument after the path name can limit to a package name.
+ * license: query license information in the local package tree. A second
+ positional argument after the path name can limit to a license type.
+ * help: print this text
+ * version: print the version
# OPTIONS
-Most npm options are supported, but in camelCase rather than css-case. For
-example, instead of '--dry-run', use '--dryRun'.
+ Most npm options are supported, but in camelCase rather than css-case. For
+ example, instead of '--dry-run', use '--dryRun'.
-Additionally:
+ Additionally:
-* --quiet will supppress the printing of package trees
-* Instead of 'npm install <pkg>', use 'arborist reify --add=<pkg>'.
- The '--add=<pkg>' option can be specified multiple times.
-* Instead of 'npm rm <pkg>', use 'arborist reify --rm=<pkg>'.
- The '--rm=<pkg>' option can be specified multiple times.
-* Instead of 'npm update', use 'arborist reify --update-all'.
-* 'npm audit fix' is 'arborist audit --fix'
+ * --loglevel=warn|--quiet will supppress the printing of package trees
+ * --logfile <file|bool> will output logs to a file
+ * --timing will show timing information
+ * Instead of 'npm install <pkg>', use 'arborist reify --add=<pkg>'.
+ The '--add=<pkg>' option can be specified multiple times.
+ * Instead of 'npm rm <pkg>', use 'arborist reify --rm=<pkg>'.
+ The '--rm=<pkg>' option can be specified multiple times.
+ * Instead of 'npm update', use 'arborist reify --update-all'.
+ * 'npm audit fix' is 'arborist audit --fix'
`
-const help = () => console.log(usage())
-
-switch (cmd) {
- case 'actual':
- require('./actual.js')
- break
- case 'virtual':
- require('./virtual.js')
- break
- case 'ideal':
- require('./ideal.js')
- break
- case 'prune':
- require('./prune.js')
- break
- case 'reify':
- require('./reify.js')
- break
- case 'audit':
- require('./audit.js')
- break
- case 'funding':
- require('./funding.js')
- break
- case 'license':
- require('./license.js')
- break
- case 'shrinkwrap':
- require('./shrinkwrap.js')
- break
- case 'help':
- case '-h':
- case '--help':
- help()
- break
- default:
+const commands = {
+ version: () => console.log(version),
+ help: () => console.log(usage()),
+ exit: () => {
process.exitCode = 1
- console.error(usage())
- break
+ console.error(
+ usage(`Error: command '${bin.command}' does not exist.`)
+ )
+ },
+}
+
+const commandFiles = fs.readdirSync(__dirname).filter((f) => path.extname(f) === '.js' && f !== __filename)
+
+for (const file of commandFiles) {
+ const command = require(`./${file}`)
+ const name = path.basename(file, '.js')
+ const totalTime = `bin:${name}:init`
+ const scriptTime = `bin:${name}:script`
+
+ commands[name] = () => {
+ const timers = require('./lib/timers')
+ const log = require('./lib/logging')
+
+ log.info(name, options)
+
+ process.emit('time', totalTime)
+ process.emit('time', scriptTime)
+
+ return command(options, (result) => {
+ process.emit('timeEnd', scriptTime)
+ return {
+ result,
+ timing: {
+ seconds: `${timers.get(scriptTime) / 1e9}s`,
+ ms: `${timers.get(scriptTime) / 1e6}ms`,
+ },
+ }
+ })
+ .then((result) => {
+ log.info(result)
+ return result
+ })
+ .catch((err) => {
+ process.exitCode = 1
+ log.error(err)
+ return err
+ })
+ .then((r) => {
+ process.emit('timeEnd', totalTime)
+ if (bin.loglevel !== 'silent') {
+ console[process.exitCode ? 'error' : 'log'](r)
+ }
+ })
+ }
+}
+
+if (commands[bin.command]) {
+ commands[bin.command]()
+} else {
+ commands.exit()
}
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/lib/logging.js b/deps/npm/node_modules/@npmcli/arborist/bin/lib/logging.js
index 8183ece1fd..8b04d6370e 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/lib/logging.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/lib/logging.js
@@ -1,42 +1,78 @@
-const options = require('./options.js')
-const { quiet = false } = options
-const { loglevel = quiet ? 'warn' : 'silly' } = options
+const log = require('proc-log')
+const mkdirp = require('mkdirp')
+const fs = require('fs')
+const { dirname } = require('path')
+const os = require('os')
+const { inspect, format } = require('util')
+
+const { bin: options } = require('./options.js')
-const levels = [
+// add a meta method to proc-log for passing optional
+// metadata through to log handlers
+const META = Symbol('meta')
+const parseArgs = (...args) => {
+ const { [META]: isMeta } = args[args.length - 1] || {}
+ return isMeta
+ ? [args[args.length - 1], ...args.slice(0, args.length - 1)]
+ : [{}, ...args]
+}
+log.meta = (meta = {}) => ({ [META]: true, ...meta })
+
+const levels = new Map([
'silly',
'verbose',
'info',
- 'timing',
'http',
'notice',
'warn',
'error',
'silent',
-]
+].map((level, index) => [level, index]))
-const levelMap = new Map(levels.reduce((set, level, index) => {
- set.push([level, index], [index, level])
- return set
-}, []))
+const addLogListener = (write, { eol = os.EOL, loglevel = 'silly', colors = false } = {}) => {
+ const levelIndex = levels.get(loglevel)
-const { inspect, format } = require('util')
-const colors = process.stderr.isTTY
-const magenta = colors ? msg => `\x1B[35m${msg}\x1B[39m` : m => m
-if (loglevel !== 'silent') {
- process.on('log', (level, ...args) => {
- if (levelMap.get(level) < levelMap.get(loglevel)) {
- return
+ const magenta = m => colors ? `\x1B[35m${m}\x1B[39m` : m
+ const dim = m => colors ? `\x1B[2m${m}\x1B[22m` : m
+ const red = m => colors ? `\x1B[31m${m}\x1B[39m` : m
+
+ const formatter = (level, ...args) => {
+ const depth = level === 'error' && args[0] && args[0].code === 'ERESOLVE' ? Infinity : 10
+
+ if (level === 'info' && args[0] === 'timeEnd') {
+ args[1] = dim(args[1])
+ } else if (level === 'error' && args[0] === 'timeError') {
+ args[1] = red(args[1])
}
+
+ const messages = args.map(a => typeof a === 'string' ? a : inspect(a, { depth, colors }))
const pref = `${process.pid} ${magenta(level)} `
- if (level === 'warn' && args[0] === 'ERESOLVE') {
- args[2] = inspect(args[2], { depth: 10, colors })
- } else {
- args = args.map(a => {
- return typeof a === 'string' ? a
- : inspect(a, { depth: 10, colors })
- })
+
+ return pref + format(...messages).trim().split('\n').join(`${eol}${pref}`) + eol
+ }
+
+ process.on('log', (...args) => {
+ const [meta, level, ...logArgs] = parseArgs(...args)
+
+ if (levelIndex <= levels.get(level) || meta.force) {
+ write(formatter(level, ...logArgs))
}
- const msg = pref + format(...args).trim().split('\n').join(`\n${pref}`)
- console.error(msg)
})
}
+
+if (options.loglevel !== 'silent') {
+ addLogListener((v) => process.stderr.write(v), {
+ eol: '\n',
+ colors: options.colors,
+ loglevel: options.loglevel,
+ })
+}
+
+if (options.logfile) {
+ log.silly('logfile', options.logfile)
+ mkdirp.sync(dirname(options.logfile))
+ const fd = fs.openSync(options.logfile, 'a')
+ addLogListener((str) => fs.writeSync(fd, str))
+}
+
+module.exports = log
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/lib/options.js b/deps/npm/node_modules/@npmcli/arborist/bin/lib/options.js
index 23e89ddce6..8dbaf13dac 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/lib/options.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/lib/options.js
@@ -1,59 +1,123 @@
-const options = module.exports = {
- path: undefined,
- cache: `${process.env.HOME}/.npm/_cacache`,
- _: [],
+const nopt = require('nopt')
+const path = require('path')
+
+const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k)
+
+const cleanPath = (val) => {
+ const k = Symbol('key')
+ const data = {}
+ nopt.typeDefs.path.validate(data, k, val)
+ return data[k]
}
-for (const arg of process.argv.slice(2)) {
- if (/^--add=/.test(arg)) {
- options.add = options.add || []
- options.add.push(arg.substr('--add='.length))
- } else if (/^--rm=/.test(arg)) {
- options.rm = options.rm || []
- options.rm.push(arg.substr('--rm='.length))
- } else if (arg === '--global') {
- options.global = true
- } else if (arg === '--global-style') {
- options.globalStyle = true
- } else if (arg === '--prefer-dedupe') {
- options.preferDedupe = true
- } else if (arg === '--legacy-peer-deps') {
- options.legacyPeerDeps = true
- } else if (arg === '--force') {
- options.force = true
- } else if (arg === '--update-all') {
- options.update = options.update || {}
- options.update.all = true
- } else if (/^--update=/.test(arg)) {
- options.update = options.update || {}
- options.update.names = options.update.names || []
- options.update.names.push(arg.substr('--update='.length))
- } else if (/^--omit=/.test(arg)) {
- options.omit = options.omit || []
- options.omit.push(arg.substr('--omit='.length))
- } else if (/^--before=/.test(arg)) {
- options.before = new Date(arg.substr('--before='.length))
- } else if (/^-w.+/.test(arg)) {
- options.workspaces = options.workspaces || []
- options.workspaces.push(arg.replace(/^-w/, ''))
- } else if (/^--workspace=/.test(arg)) {
- options.workspaces = options.workspaces || []
- options.workspaces.push(arg.replace(/^--workspace=/, ''))
- } else if (/^--[^=]+=/.test(arg)) {
- const [key, ...v] = arg.replace(/^--/, '').split('=')
- const val = v.join('=')
- options[key] = val === 'false' ? false : val === 'true' ? true : val
- } else if (/^--.+/.test(arg)) {
- options[arg.replace(/^--/, '')] = true
- } else if (options.path === undefined) {
- options.path = arg
- } else {
- options._.push(arg)
+const parse = (...noptArgs) => {
+ const binOnlyOpts = {
+ command: String,
+ loglevel: String,
+ colors: Boolean,
+ timing: ['always', Boolean],
+ logfile: String,
+ }
+
+ const arbOpts = {
+ add: Array,
+ rm: Array,
+ omit: Array,
+ update: Array,
+ workspaces: Array,
+ global: Boolean,
+ force: Boolean,
+ 'global-style': Boolean,
+ 'prefer-dedupe': Boolean,
+ 'legacy-peer-deps': Boolean,
+ 'update-all': Boolean,
+ before: Date,
+ path: path,
+ cache: path,
+ ...binOnlyOpts,
+ }
+
+ const short = {
+ quiet: ['--loglevel', 'warn'],
+ logs: ['--logfile', 'true'],
+ w: '--workspaces',
+ g: '--global',
+ f: '--force',
+ }
+
+ const defaults = {
+ // key order is important for command and path
+ // since they shift positional args
+ // command is 1st, path is 2nd
+ command: (o) => o.argv.remain.shift(),
+ path: (o) => cleanPath(o.argv.remain.shift() || '.'),
+ colors: has(process.env, 'NO_COLOR') ? false : !!process.stderr.isTTY,
+ loglevel: 'silly',
+ timing: (o) => o.loglevel === 'silly',
+ cache: `${process.env.HOME}/.npm/_cacache`,
+ }
+
+ const derived = [
+ // making update either `all` or an array of names but not both
+ ({ updateAll: all, update: names, ...o }) => {
+ if (all || names) {
+ o.update = all != null ? { all } : { names }
+ }
+ return o
+ },
+ ({ logfile, ...o }) => {
+ // logfile is parsed as a string so if its true or set but empty
+ // then set the default logfile
+ if (logfile === 'true' || logfile === '') {
+ logfile = `arb-log-${new Date().toISOString().replace(/[.:]/g, '_')}.log`
+ }
+ // then parse it the same as nopt parses other paths
+ if (logfile) {
+ o.logfile = cleanPath(logfile)
+ }
+ return o
+ },
+ ]
+
+ const transforms = [
+ // Camelcase all top level keys
+ (o) => {
+ const entries = Object.entries(o).map(([k, v]) => [
+ k.replace(/-./g, s => s[1].toUpperCase()),
+ v,
+ ])
+ return Object.fromEntries(entries)
+ },
+ // Set defaults on unset keys
+ (o) => {
+ for (const [k, v] of Object.entries(defaults)) {
+ if (!has(o, k)) {
+ o[k] = typeof v === 'function' ? v(o) : v
+ }
+ }
+ return o
+ },
+ // Set/unset derived values
+ ...derived.map((derive) => (o) => derive(o) || o),
+ // Separate bin and arborist options
+ ({ argv: { remain: _ }, ...o }) => {
+ const bin = { _ }
+ for (const k of Object.keys(binOnlyOpts)) {
+ if (has(o, k)) {
+ bin[k] = o[k]
+ delete o[k]
+ }
+ }
+ return { bin, arb: o }
+ },
+ ]
+
+ let options = nopt(arbOpts, short, ...noptArgs)
+ for (const t of transforms) {
+ options = t(options)
}
-}
-if (options.path === undefined) {
- options.path = '.'
+ return options
}
-console.error(options)
+module.exports = parse()
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/lib/print-tree.js b/deps/npm/node_modules/@npmcli/arborist/bin/lib/print-tree.js
index 1ea2a72187..55398190b9 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/lib/print-tree.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/lib/print-tree.js
@@ -1,5 +1,4 @@
const { inspect } = require('util')
-const { quiet } = require('./options.js')
+const log = require('./logging.js')
-module.exports = quiet ? () => {}
- : tree => console.log(inspect(tree.toJSON(), { depth: Infinity }))
+module.exports = tree => log.info(inspect(tree.toJSON(), { depth: Infinity }))
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/lib/timers.js b/deps/npm/node_modules/@npmcli/arborist/bin/lib/timers.js
index 242431980e..586dee7806 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/lib/timers.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/lib/timers.js
@@ -1,31 +1,33 @@
-const timers = Object.create(null)
-const { format } = require('util')
-const options = require('./options.js')
+const { bin: options } = require('./options.js')
+const log = require('./logging.js')
+
+const timers = new Map()
+const finished = new Map()
process.on('time', name => {
- if (timers[name]) {
+ if (timers.has(name)) {
throw new Error('conflicting timer! ' + name)
}
- timers[name] = process.hrtime()
+ timers.set(name, process.hrtime.bigint())
})
-const dim = process.stderr.isTTY ? msg => `\x1B[2m${msg}\x1B[22m` : m => m
-const red = process.stderr.isTTY ? msg => `\x1B[31m${msg}\x1B[39m` : m => m
process.on('timeEnd', name => {
- if (!timers[name]) {
+ if (!timers.has(name)) {
throw new Error('timer not started! ' + name)
}
- const res = process.hrtime(timers[name])
- delete timers[name]
- const msg = format(`${process.pid} ${name}`, res[0] * 1e3 + res[1] / 1e6)
- if (options.timers !== false) {
- console.error(dim(msg))
+ const elapsed = Number(process.hrtime.bigint() - timers.get(name))
+ timers.delete(name)
+ finished.set(name, elapsed)
+ if (options.timing) {
+ log.info('timeEnd', `${name} ${elapsed / 1e9}s`, log.meta({ force: options.timing === 'always' }))
}
})
process.on('exit', () => {
- for (const name of Object.keys(timers)) {
- console.error(red('Dangling timer:'), name)
+ for (const name of timers.keys()) {
+ log.error('timeError', 'Dangling timer:', name)
process.exitCode = 1
}
})
+
+module.exports = finished
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/license.js b/deps/npm/node_modules/@npmcli/arborist/bin/license.js
index 7fc08dd83e..77d5796793 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/license.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/license.js
@@ -1,38 +1,48 @@
+const localeCompare = require('@isaacs/string-locale-compare')('en')
const Arborist = require('../')
-const options = require('./lib/options.js')
-require('./lib/logging.js')
-require('./lib/timers.js')
+const log = require('./lib/logging.js')
-const a = new Arborist(options)
-const query = options._.shift()
+module.exports = (options, time) => {
+ const query = options._.shift()
+ const a = new Arborist(options)
+ return a
+ .loadVirtual()
+ .then(tree => {
+ // only load the actual tree if the virtual one doesn't have modern metadata
+ if (!tree.meta || !(tree.meta.originalLockfileVersion >= 2)) {
+ throw 'load actual'
+ } else {
+ return tree
+ }
+ }).catch((er) => {
+ log.error('loading actual tree', er)
+ return a.loadActual()
+ })
+ .then(time)
+ .then(({ result: tree }) => {
+ const output = []
+ if (!query) {
+ const set = []
+ for (const license of tree.inventory.query('license')) {
+ set.push([tree.inventory.query('license', license).size, license])
+ }
-a.loadVirtual().then(tree => {
- // only load the actual tree if the virtual one doesn't have modern metadata
- if (!tree.meta || !(tree.meta.originalLockfileVersion >= 2)) {
- throw 'load actual'
- } else {
- return tree
- }
-}).catch((er) => {
- console.error('loading actual tree', er)
- return a.loadActual()
-}).then(tree => {
- if (!query) {
- const set = []
- for (const license of tree.inventory.query('license')) {
- set.push([tree.inventory.query('license', license).size, license])
- }
+ for (const [count, license] of set.sort((a, b) =>
+ a[1] && b[1] ? b[0] - a[0] || localeCompare(a[1], b[1])
+ : a[1] ? -1
+ : b[1] ? 1
+ : 0)) {
+ output.push(`${count} ${license}`)
+ log.info(count, license)
+ }
+ } else {
+ for (const node of tree.inventory.query('license', query === 'undefined' ? undefined : query)) {
+ const msg = `${node.name} ${node.location} ${node.package.description || ''}`
+ output.push(msg)
+ log.info(msg)
+ }
+ }
- for (const [count, license] of set.sort((a, b) =>
- a[1] && b[1] ? b[0] - a[0] || a[1].localeCompare(b[1], 'en')
- : a[1] ? -1
- : b[1] ? 1
- : 0)) {
- console.log(count, license)
- }
- } else {
- for (const node of tree.inventory.query('license', query === 'undefined' ? undefined : query)) {
- console.log(`${node.name} ${node.location} ${node.package.description || ''}`)
- }
- }
-})
+ return output.join('\n')
+ })
+}
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/prune.js b/deps/npm/node_modules/@npmcli/arborist/bin/prune.js
index e11858c209..3c52bc13af 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/prune.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/prune.js
@@ -1,9 +1,7 @@
const Arborist = require('../')
-const options = require('./lib/options.js')
-const print = require('./lib/print-tree.js')
-require('./lib/logging.js')
-require('./lib/timers.js')
+const printTree = require('./lib/print-tree.js')
+const log = require('./lib/logging.js')
const printDiff = diff => {
const { depth } = require('treeverse')
@@ -15,13 +13,13 @@ const printDiff = diff => {
}
switch (d.action) {
case 'REMOVE':
- console.error('REMOVE', d.actual.location)
+ log.info('REMOVE', d.actual.location)
break
case 'ADD':
- console.error('ADD', d.ideal.location, d.ideal.resolved)
+ log.info('ADD', d.ideal.location, d.ideal.resolved)
break
case 'CHANGE':
- console.error('CHANGE', d.actual.location, {
+ log.info('CHANGE', d.actual.location, {
from: d.actual.resolved,
to: d.ideal.resolved,
})
@@ -32,18 +30,19 @@ const printDiff = diff => {
})
}
-const start = process.hrtime()
-process.emit('time', 'install')
-const arb = new Arborist(options)
-arb.prune(options).then(tree => {
- process.emit('timeEnd', 'install')
- const end = process.hrtime(start)
- print(tree)
- if (options.dryRun) {
- printDiff(arb.diff)
- }
- console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 1e9}s`)
- if (tree.meta && options.save) {
- tree.meta.save()
- }
-}).catch(er => console.error(require('util').inspect(er, { depth: Infinity })))
+module.exports = (options, time) => {
+ const arb = new Arborist(options)
+ return arb
+ .prune(options)
+ .then(time)
+ .then(async ({ timing, result: tree }) => {
+ printTree(tree)
+ if (options.dryRun) {
+ printDiff(arb.diff)
+ }
+ if (tree.meta && options.save) {
+ await tree.meta.save()
+ }
+ return `resolved ${tree.inventory.size} deps in ${timing.seconds}`
+ })
+}
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/reify.js b/deps/npm/node_modules/@npmcli/arborist/bin/reify.js
index 9dc26d2b96..3f3aafe8ab 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/reify.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/reify.js
@@ -1,9 +1,7 @@
const Arborist = require('../')
-const options = require('./lib/options.js')
-const print = require('./lib/print-tree.js')
-require('./lib/logging.js')
-require('./lib/timers.js')
+const printTree = require('./lib/print-tree.js')
+const log = require('./lib/logging.js')
const printDiff = diff => {
const { depth } = require('treeverse')
@@ -15,13 +13,13 @@ const printDiff = diff => {
}
switch (d.action) {
case 'REMOVE':
- console.error('REMOVE', d.actual.location)
+ log.info('REMOVE', d.actual.location)
break
case 'ADD':
- console.error('ADD', d.ideal.location, d.ideal.resolved)
+ log.info('ADD', d.ideal.location, d.ideal.resolved)
break
case 'CHANGE':
- console.error('CHANGE', d.actual.location, {
+ log.info('CHANGE', d.actual.location, {
from: d.actual.resolved,
to: d.ideal.resolved,
})
@@ -32,18 +30,19 @@ const printDiff = diff => {
})
}
-const start = process.hrtime()
-process.emit('time', 'install')
-const arb = new Arborist(options)
-arb.reify(options).then(tree => {
- process.emit('timeEnd', 'install')
- const end = process.hrtime(start)
- print(tree)
- if (options.dryRun) {
- printDiff(arb.diff)
- }
- console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 1e9}s`)
- if (tree.meta && options.save) {
- tree.meta.save()
- }
-}).catch(er => console.error(require('util').inspect(er, { depth: Infinity })))
+module.exports = (options, time) => {
+ const arb = new Arborist(options)
+ return arb
+ .reify(options)
+ .then(time)
+ .then(async ({ timing, result: tree }) => {
+ printTree(tree)
+ if (options.dryRun) {
+ printDiff(arb.diff)
+ }
+ if (tree.meta && options.save) {
+ await tree.meta.save()
+ }
+ return `resolved ${tree.inventory.size} deps in ${timing.seconds}`
+ })
+}
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/shrinkwrap.js b/deps/npm/node_modules/@npmcli/arborist/bin/shrinkwrap.js
index b40416b7b9..56603224e9 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/shrinkwrap.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/shrinkwrap.js
@@ -1,12 +1,7 @@
const Shrinkwrap = require('../lib/shrinkwrap.js')
-const options = require('./lib/options.js')
-require('./lib/logging.js')
-require('./lib/timers.js')
-const { quiet } = options
-Shrinkwrap.load(options)
- .then(s => quiet || console.log(JSON.stringify(s.commit(), 0, 2)))
- .catch(er => {
- console.error('shrinkwrap load failure', er)
- process.exit(1)
- })
+module.exports = (options, time) => Shrinkwrap
+ .load(options)
+ .then((s) => s.commit())
+ .then(time)
+ .then(({ result: s }) => JSON.stringify(s, 0, 2))
diff --git a/deps/npm/node_modules/@npmcli/arborist/bin/virtual.js b/deps/npm/node_modules/@npmcli/arborist/bin/virtual.js
index 457c945e72..95b1de282e 100644
--- a/deps/npm/node_modules/@npmcli/arborist/bin/virtual.js
+++ b/deps/npm/node_modules/@npmcli/arborist/bin/virtual.js
@@ -1,18 +1,14 @@
const Arborist = require('../')
-const print = require('./lib/print-tree.js')
-const options = require('./lib/options.js')
-require('./lib/logging.js')
-require('./lib/timers.js')
+const printTree = require('./lib/print-tree.js')
-const start = process.hrtime()
-new Arborist(options).loadVirtual().then(tree => {
- const end = process.hrtime(start)
- if (!options.quiet) {
- print(tree)
- }
- if (options.save) {
- tree.meta.save()
- }
- console.error(`read ${tree.inventory.size} deps in ${end[0] * 1000 + end[1] / 1e6}ms`)
-}).catch(er => console.error(er))
+module.exports = (options, time) => new Arborist(options)
+ .loadVirtual()
+ .then(time)
+ .then(async ({ timing, result: tree }) => {
+ printTree(tree)
+ if (options.save) {
+ await tree.meta.save()
+ }
+ return `read ${tree.inventory.size} deps in ${timing.ms}`
+ })
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js b/deps/npm/node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js
index ae813186fb..f59df359e9 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js
@@ -1,10 +1,11 @@
// add and remove dependency specs to/from pkg manifest
+const log = require('proc-log')
const localeCompare = require('@isaacs/string-locale-compare')('en')
-const add = ({ pkg, add, saveBundle, saveType, log }) => {
+const add = ({ pkg, add, saveBundle, saveType }) => {
for (const spec of add) {
- addSingle({ pkg, spec, saveBundle, saveType, log })
+ addSingle({ pkg, spec, saveBundle, saveType })
}
return pkg
@@ -20,7 +21,7 @@ const saveTypeMap = new Map([
['peer', 'peerDependencies'],
])
-const addSingle = ({ pkg, spec, saveBundle, saveType, log }) => {
+const addSingle = ({ pkg, spec, saveBundle, saveType }) => {
const { name, rawSpec } = spec
// if the user does not give us a type, we infer which type(s)
@@ -34,19 +35,19 @@ const addSingle = ({ pkg, spec, saveBundle, saveType, log }) => {
if (saveType === 'prod') {
// a production dependency can only exist as production (rpj ensures it
// doesn't coexist w/ optional)
- deleteSubKey(pkg, 'devDependencies', name, 'dependencies', log)
- deleteSubKey(pkg, 'peerDependencies', name, 'dependencies', log)
+ deleteSubKey(pkg, 'devDependencies', name, 'dependencies')
+ deleteSubKey(pkg, 'peerDependencies', name, 'dependencies')
} else if (saveType === 'dev') {
// a dev dependency may co-exist as peer, or optional, but not production
- deleteSubKey(pkg, 'dependencies', name, 'devDependencies', log)
+ deleteSubKey(pkg, 'dependencies', name, 'devDependencies')
} else if (saveType === 'optional') {
// an optional dependency may co-exist as dev (rpj ensures it doesn't
// coexist w/ prod)
- deleteSubKey(pkg, 'peerDependencies', name, 'optionalDependencies', log)
+ deleteSubKey(pkg, 'peerDependencies', name, 'optionalDependencies')
} else { // peer or peerOptional is all that's left
// a peer dependency may coexist as dev
- deleteSubKey(pkg, 'dependencies', name, 'peerDependencies', log)
- deleteSubKey(pkg, 'optionalDependencies', name, 'peerDependencies', log)
+ deleteSubKey(pkg, 'dependencies', name, 'peerDependencies')
+ deleteSubKey(pkg, 'optionalDependencies', name, 'peerDependencies')
}
const depType = saveTypeMap.get(saveType)
@@ -108,9 +109,9 @@ const hasSubKey = (pkg, depType, name) => {
}
// Removes a subkey and warns about it if it's being replaced
-const deleteSubKey = (pkg, depType, name, replacedBy, log) => {
+const deleteSubKey = (pkg, depType, name, replacedBy) => {
if (hasSubKey(pkg, depType, name)) {
- if (replacedBy && log) {
+ if (replacedBy) {
log.warn('idealTree', `Removing ${depType}.${name} in favor of ${replacedBy}.${name}`)
}
delete pkg[depType][name]
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
index b7bc56f3e9..3f001f9e9e 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
@@ -14,6 +14,7 @@ const fs = require('fs')
const lstat = promisify(fs.lstat)
const readlink = promisify(fs.readlink)
const { depth } = require('treeverse')
+const log = require('proc-log')
const {
OK,
@@ -248,7 +249,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
try {
c()
} catch (er) {
- this.log.warn(er.code, er.message, {
+ log.warn(er.code, er.message, {
package: er.pkgid,
required: er.required,
current: er.current,
@@ -532,7 +533,6 @@ Try using the package name instead, e.g:
saveBundle,
saveType,
path: this.path,
- log: this.log,
})
})
}
@@ -602,7 +602,7 @@ Try using the package name instead, e.g:
// be printed by npm-audit-report as if they can be fixed, because
// they can't.
if (bundler) {
- this.log.warn(`audit fix ${node.name}@${node.version}`,
+ log.warn(`audit fix ${node.name}@${node.version}`,
`${node.location}\nis a bundled dependency of\n${
bundler.name}@${bundler.version} at ${bundler.location}\n` +
'It cannot be fixed automatically.\n' +
@@ -637,14 +637,14 @@ Try using the package name instead, e.g:
if (!node.isProjectRoot && !node.isWorkspace) {
// not something we're going to fix, sorry. have to cd into
// that directory and fix it yourself.
- this.log.warn('audit', 'Manual fix required in linked project ' +
+ log.warn('audit', 'Manual fix required in linked project ' +
`at ./${node.location} for ${name}@${simpleRange}.\n` +
`'cd ./${node.location}' and run 'npm audit' for details.`)
continue
}
if (!fixAvailable) {
- this.log.warn('audit', `No fix available for ${name}@${simpleRange}`)
+ log.warn('audit', `No fix available for ${name}@${simpleRange}`)
continue
}
@@ -652,7 +652,7 @@ Try using the package name instead, e.g:
const breakingMessage = isSemVerMajor
? 'a SemVer major change'
: 'outside your stated dependency range'
- this.log.warn('audit', `Updating ${name} to ${version},` +
+ log.warn('audit', `Updating ${name} to ${version},` +
`which is ${breakingMessage}.`)
await this[_add](node, { add: [`${name}@${version}`] })
@@ -727,7 +727,7 @@ Try using the package name instead, e.g:
const heading = ancient ? 'ancient lockfile' : 'old lockfile'
if (ancient || !this.options.lockfileVersion ||
this.options.lockfileVersion >= defaultLockfileVersion) {
- this.log.warn(heading,
+ log.warn(heading,
`
The ${meta.type} file was created with an old version of npm,
so supplemental metadata must be fetched from the registry.
@@ -744,7 +744,7 @@ This is a one-time fix-up, please be patient...
}
queue.push(async () => {
- this.log.silly('inflate', node.location)
+ log.silly('inflate', node.location)
const { resolved, version, path, name, location, integrity } = node
// don't try to hit the registry for linked deps
const useResolved = resolved && (
@@ -753,8 +753,7 @@ This is a one-time fix-up, please be patient...
const id = useResolved ? resolved
: version || `file:${node.path}`
const spec = npa.resolve(name, id, dirname(path))
- const sloc = location.substr('node_modules/'.length)
- const t = `idealTree:inflate:${sloc}`
+ const t = `idealTree:inflate:${location}`
this.addTracker(t)
await pacote.manifest(spec, {
...this.options,
@@ -765,7 +764,7 @@ This is a one-time fix-up, please be patient...
node.package = { ...mani, _id: `${mani.name}@${mani.version}` }
}).catch((er) => {
const warning = `Could not fetch metadata for ${name}@${id}`
- this.log.warn(heading, warning, er)
+ log.warn(heading, warning, er)
})
this.finishTracker(t)
})
@@ -794,7 +793,7 @@ This is a one-time fix-up, please be patient...
this[_depsQueue].push(tree)
// XXX also push anything that depends on a node with a name
// in the override list
- this.log.silly('idealTree', 'buildDeps')
+ log.silly('idealTree', 'buildDeps')
this.addTracker('idealTree', tree.name, '')
return this[_buildDepStep]()
.then(() => process.emit('timeEnd', 'idealTree:buildDeps'))
@@ -1233,7 +1232,7 @@ This is a one-time fix-up, please be patient...
if (this[_manifests].has(spec.raw)) {
return this[_manifests].get(spec.raw)
} else {
- this.log.silly('fetch manifest', spec.raw)
+ log.silly('fetch manifest', spec.raw)
const p = pacote.manifest(spec, options)
.then(mani => {
this[_manifests].set(spec.raw, mani)
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js
index de625e9b76..cb6ef1e0c2 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js
@@ -28,7 +28,6 @@
const { resolve } = require('path')
const { homedir } = require('os')
-const procLog = require('proc-log')
const { depth } = require('treeverse')
const { saveTypeMap } = require('../add-rm-pkg-deps.js')
@@ -74,7 +73,6 @@ class Arborist extends Base {
path: options.path || '.',
cache: options.cache || `${homedir()}/.npm/_cacache`,
packumentCache: options.packumentCache || new Map(),
- log: options.log || procLog,
workspacesEnabled: options.workspacesEnabled !== false,
lockfileVersion: lockfileVersion(options.lockfileVersion),
}
@@ -94,7 +92,7 @@ class Arborist extends Base {
// returns an array of the actual nodes for all the workspaces
workspaceNodes (tree, workspaces) {
- return getWorkspaceNodes(tree, workspaces, this.log)
+ return getWorkspaceNodes(tree, workspaces)
}
// returns a set of workspace nodes and all their deps
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
index 1a05e52735..09b4419f5b 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
@@ -13,6 +13,7 @@ const {
isNodeGypPackage,
defaultGypInstallScript,
} = require('@npmcli/node-gyp')
+const log = require('proc-log')
const boolEnv = b => b ? '1' : ''
const sortNodes = (a, b) =>
@@ -297,7 +298,7 @@ module.exports = cls => class Builder extends cls {
const timer = `build:run:${event}:${location}`
process.emit('time', timer)
- this.log.info('run', pkg._id, event, location, pkg.scripts[event])
+ log.info('run', pkg._id, event, location, pkg.scripts[event])
const env = {
npm_package_resolved: resolved,
npm_package_integrity: integrity,
@@ -319,7 +320,7 @@ module.exports = cls => class Builder extends cls {
}
const p = runScript(runOpts).catch(er => {
const { code, signal } = er
- this.log.info('run', pkg._id, event, { code, signal })
+ log.info('run', pkg._id, event, { code, signal })
throw er
}).then(({ args, code, signal, stdout, stderr }) => {
this.scriptsRun.add({
@@ -333,7 +334,7 @@ module.exports = cls => class Builder extends cls {
stdout,
stderr,
})
- this.log.info('run', pkg._id, event, { code, signal })
+ log.info('run', pkg._id, event, { code, signal })
})
await (this[_doHandleOptionalFailure]
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js
index 91507fd791..4bc1c7ee4e 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js
@@ -8,6 +8,7 @@ const npa = require('npm-package-arg')
const semver = require('semver')
const debug = require('../debug.js')
const walkUp = require('walk-up-path')
+const log = require('proc-log')
const { dirname, resolve, relative } = require('path')
const { depth: dfwalk } = require('treeverse')
@@ -390,7 +391,7 @@ module.exports = cls => class Reifier extends cls {
[_addNodeToTrashList] (node, retire = false) {
const paths = [node.path, ...node.binPaths]
const moves = this[_retiredPaths]
- this.log.silly('reify', 'mark', retire ? 'retired' : 'deleted', paths)
+ log.silly('reify', 'mark', retire ? 'retired' : 'deleted', paths)
for (const path of paths) {
if (retire) {
const retired = retirePath(path)
@@ -413,7 +414,7 @@ module.exports = cls => class Reifier extends cls {
this[_addNodeToTrashList](diff.actual, true)
}
}
- this.log.silly('reify', 'moves', moves)
+ log.silly('reify', 'moves', moves)
const movePromises = Object.entries(moves)
.map(([from, to]) => this[_renamePath](from, to))
return promiseAllRejectLate(movePromises)
@@ -532,7 +533,7 @@ module.exports = cls => class Reifier extends cls {
return promiseAllRejectLate(unlinks)
.then(() => {
if (failures.length) {
- this.log.warn('cleanup', 'Failed to remove some directories', failures)
+ log.warn('cleanup', 'Failed to remove some directories', failures)
}
})
.then(() => process.emit('timeEnd', 'reify:rollback:createSparse'))
@@ -624,7 +625,7 @@ module.exports = cls => class Reifier extends cls {
this[_nmValidated].add(nm)
return
}
- this.log.warn('reify', 'Removing non-directory', nm)
+ log.warn('reify', 'Removing non-directory', nm)
await rimraf(nm)
}
@@ -647,8 +648,8 @@ module.exports = cls => class Reifier extends cls {
'please re-try this operation once it completes\n' +
'so that the damage can be corrected, or perform\n' +
'a fresh install with no lockfile if the problem persists.'
- this.log.warn('reify', warning)
- this.log.verbose('reify', 'unrecognized node in tree', node.path)
+ log.warn('reify', warning)
+ log.verbose('reify', 'unrecognized node in tree', node.path)
node.parent = null
node.fsParent = null
this[_addNodeToTrashList](node)
@@ -691,7 +692,7 @@ module.exports = cls => class Reifier extends cls {
[_warnDeprecated] (node) {
const { _id, deprecated } = node.package
if (deprecated) {
- this.log.warn('deprecated', `${_id}: ${deprecated}`)
+ log.warn('deprecated', `${_id}: ${deprecated}`)
}
}
@@ -701,7 +702,7 @@ module.exports = cls => class Reifier extends cls {
return (node.optional ? p.catch(er => {
const set = optionalSet(node)
for (node of set) {
- this.log.verbose('reify', 'failed optional dependency', node.path)
+ log.verbose('reify', 'failed optional dependency', node.path)
this[_addNodeToTrashList](node)
}
}) : p).then(() => node)
@@ -716,7 +717,7 @@ module.exports = cls => class Reifier extends cls {
// Shrinkwrap and Node classes carefully, so for now, just treat
// the default reg as the magical animal that it has been.
return resolved && resolved
- .replace(/^https?:\/\/registry.npmjs.org\//, this.registry)
+ .replace(/^https?:\/\/registry\.npmjs\.org\//, this.registry)
}
// bundles are *sort of* like shrinkwraps, in that the branch is defined
@@ -1129,7 +1130,7 @@ module.exports = cls => class Reifier extends cls {
return promiseAllRejectLate(promises).then(() => {
if (failures.length) {
- this.log.warn('cleanup', 'Failed to remove some directories', failures)
+ log.warn('cleanup', 'Failed to remove some directories', failures)
}
})
.then(() => process.emit('timeEnd', 'reify:trash'))
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js b/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js
index b7d8249b12..4dc6dd177c 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js
@@ -13,7 +13,7 @@ const _fixAvailable = Symbol('fixAvailable')
const _checkTopNode = Symbol('checkTopNode')
const _init = Symbol('init')
const _omit = Symbol('omit')
-const procLog = require('proc-log')
+const log = require('proc-log')
const fetch = require('npm-registry-fetch')
@@ -98,14 +98,13 @@ class AuditReport extends Map {
this.calculator = new Calculator(opts)
this.error = null
this.options = opts
- this.log = opts.log || procLog
this.tree = tree
this.filterSet = opts.filterSet
}
async run () {
this.report = await this[_getReport]()
- this.log.silly('audit report', this.report)
+ log.silly('audit report', this.report)
if (this.report) {
await this[_init]()
}
@@ -313,7 +312,7 @@ class AuditReport extends Map {
try {
// first try the super fast bulk advisory listing
const body = prepareBulkData(this.tree, this[_omit], this.filterSet)
- this.log.silly('audit', 'bulk request', body)
+ log.silly('audit', 'bulk request', body)
// no sense asking if we don't have anything to audit,
// we know it'll be empty
@@ -331,7 +330,7 @@ class AuditReport extends Map {
return await res.json()
} catch (er) {
- this.log.silly('audit', 'bulk request failed', String(er.body))
+ log.silly('audit', 'bulk request failed', String(er.body))
// that failed, try the quick audit endpoint
const body = prepareData(this.tree, this.options)
const res = await fetch('/-/npm/v1/security/audits/quick', {
@@ -344,8 +343,8 @@ class AuditReport extends Map {
return AuditReport.auditToBulk(await res.json())
}
} catch (er) {
- this.log.verbose('audit error', er)
- this.log.silly('audit error', String(er.body))
+ log.verbose('audit error', er)
+ log.silly('audit error', String(er.body))
this.error = er
return null
} finally {
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/get-workspace-nodes.js b/deps/npm/node_modules/@npmcli/arborist/lib/get-workspace-nodes.js
index 6db489f69c..91002dab57 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/get-workspace-nodes.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/get-workspace-nodes.js
@@ -1,7 +1,10 @@
// Get the actual nodes corresponding to a root node's child workspaces,
// given a list of workspace names.
+
+const log = require('proc-log')
const relpath = require('./relpath.js')
-const getWorkspaceNodes = (tree, workspaces, log) => {
+
+const getWorkspaceNodes = (tree, workspaces) => {
const wsMap = tree.workspaces
if (!wsMap) {
log.warn('workspaces', 'filter set, but no workspaces present')
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js b/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js
index bb6971f7ad..ead9aed364 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js
@@ -33,7 +33,7 @@ const mismatch = (a, b) => a && b && a !== b
// After calling this.commit(), any nodes not present in the tree will have
// been removed from the shrinkwrap data as well.
-const procLog = require('proc-log')
+const log = require('proc-log')
const YarnLock = require('./yarn-lock.js')
const { promisify } = require('util')
const rimraf = promisify(require('rimraf'))
@@ -80,8 +80,8 @@ const swKeyOrder = [
]
// used to rewrite from yarn registry to npm registry
-const yarnRegRe = /^https?:\/\/registry.yarnpkg.com\//
-const npmRegRe = /^https?:\/\/registry.npmjs.org\//
+const yarnRegRe = /^https?:\/\/registry\.yarnpkg\.com\//
+const npmRegRe = /^https?:\/\/registry\.npmjs\.org\//
// sometimes resolved: is weird or broken, or something npa can't handle
const specFromResolved = resolved => {
@@ -329,14 +329,12 @@ class Shrinkwrap {
newline = '\n',
shrinkwrapOnly = false,
hiddenLockfile = false,
- log = procLog,
lockfileVersion,
} = options
this.lockfileVersion = hiddenLockfile ? 3
: lockfileVersion ? parseInt(lockfileVersion, 10)
: null
- this.log = log
this[_awaitingUpdate] = new Map()
this.tree = null
this.path = resolve(path || '.')
@@ -479,9 +477,9 @@ class Shrinkwrap {
/* istanbul ignore else */
if (typeof this.filename === 'string') {
const rel = relpath(this.path, this.filename)
- this.log.verbose('shrinkwrap', `failed to load ${rel}`, er)
+ log.verbose('shrinkwrap', `failed to load ${rel}`, er)
} else {
- this.log.verbose('shrinkwrap', `failed to load ${this.path}`, er)
+ log.verbose('shrinkwrap', `failed to load ${this.path}`, er)
}
this.loadingError = er
this.loadedFromDisk = false
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js b/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js
index b50f06eaa5..c2a456e483 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js
@@ -1,20 +1,14 @@
const _progress = Symbol('_progress')
const _onError = Symbol('_onError')
-const procLog = require('proc-log')
+const npmlog = require('npmlog')
module.exports = cls => class Tracker extends cls {
constructor (options = {}) {
super(options)
- this.log = options.log || procLog
this[_progress] = new Map()
}
addTracker (section, subsection = null, key = null) {
- // TrackerGroup type object not found
- if (!this.log.newGroup) {
- return
- }
-
if (section === null || section === undefined) {
this[_onError](`Tracker can't be null or undefined`)
}
@@ -31,13 +25,13 @@ module.exports = cls => class Tracker extends cls {
this[_onError](`Tracker "${section}" already exists`)
} else if (!hasTracker && subsection === null) {
// 1. no existing tracker, no subsection
- // Create a new tracker from this.log
+ // Create a new tracker from npmlog
// starts progress bar
if (this[_progress].size === 0) {
- this.log.enableProgress()
+ npmlog.enableProgress()
}
- this[_progress].set(section, this.log.newGroup(section))
+ this[_progress].set(section, npmlog.newGroup(section))
} else if (!hasTracker && subsection !== null) {
// 2. no parent tracker and subsection
this[_onError](`Parent tracker "${section}" does not exist`)
@@ -53,11 +47,6 @@ module.exports = cls => class Tracker extends cls {
}
finishTracker (section, subsection = null, key = null) {
- // TrackerGroup type object not found
- if (!this.log.newGroup) {
- return
- }
-
if (section === null || section === undefined) {
this[_onError](`Tracker can't be null or undefined`)
}
@@ -88,7 +77,7 @@ module.exports = cls => class Tracker extends cls {
// remove progress bar if all
// trackers are finished
if (this[_progress].size === 0) {
- this.log.disableProgress()
+ npmlog.disableProgress()
}
} else if (!hasTracker && subsection === null) {
// 1. no existing parent tracker, no subsection
@@ -103,7 +92,7 @@ module.exports = cls => class Tracker extends cls {
}
[_onError] (msg) {
- this.log.disableProgress()
+ npmlog.disableProgress()
throw new Error(msg)
}
}
diff --git a/deps/npm/node_modules/@npmcli/arborist/package.json b/deps/npm/node_modules/@npmcli/arborist/package.json
index a915c9d8b1..520c457487 100644
--- a/deps/npm/node_modules/@npmcli/arborist/package.json
+++ b/deps/npm/node_modules/@npmcli/arborist/package.json
@@ -1,17 +1,17 @@
{
"name": "@npmcli/arborist",
- "version": "4.3.1",
+ "version": "5.0.0",
"description": "Manage node_modules trees",
"dependencies": {
"@isaacs/string-locale-compare": "^1.1.0",
"@npmcli/installed-package-contents": "^1.0.7",
"@npmcli/map-workspaces": "^2.0.0",
- "@npmcli/metavuln-calculator": "^2.0.0",
+ "@npmcli/metavuln-calculator": "^3.0.0",
"@npmcli/move-file": "^1.1.0",
"@npmcli/name-from-folder": "^1.0.1",
"@npmcli/node-gyp": "^1.0.3",
"@npmcli/package-json": "^1.0.1",
- "@npmcli/run-script": "^2.0.0",
+ "@npmcli/run-script": "^3.0.0",
"bin-links": "^3.0.0",
"cacache": "^15.0.3",
"common-ancestor-path": "^1.0.1",
@@ -19,13 +19,15 @@
"json-stringify-nice": "^1.1.4",
"mkdirp": "^1.0.4",
"mkdirp-infer-owner": "^2.0.0",
+ "nopt": "^5.0.0",
"npm-install-checks": "^4.0.0",
- "npm-package-arg": "^8.1.5",
- "npm-pick-manifest": "^6.1.0",
- "npm-registry-fetch": "^12.0.1",
- "pacote": "^12.0.2",
+ "npm-package-arg": "^9.0.0",
+ "npm-pick-manifest": "^7.0.0",
+ "npm-registry-fetch": "^13.0.0",
+ "npmlog": "^6.0.1",
+ "pacote": "^13.0.2",
"parse-conflict-json": "^2.0.1",
- "proc-log": "^1.0.0",
+ "proc-log": "^2.0.0",
"promise-all-reject-late": "^1.0.0",
"promise-call-limit": "^1.0.1",
"read-package-json-fast": "^2.0.2",