Skip to content

Commit

Permalink
deps: upgrade npm to 9.6.3
Browse files Browse the repository at this point in the history
PR-URL: #47325
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Luke Karrys <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
npm-cli-bot authored and RafaelGSS committed Apr 8, 2023
1 parent 1c21fbf commit 4b09222
Showing 321 changed files with 12,274 additions and 15,792 deletions.
12 changes: 1 addition & 11 deletions deps/npm/README.md
Original file line number Diff line number Diff line change
@@ -27,17 +27,7 @@ curl -qL https://www.npmjs.com/install.sh | sh

#### Node Version Managers

If you're looking to manage multiple versions of **`node`** &/or **`npm`**, consider using a "Node Version Manager" such as:

* [**`nvm`**](https://github.com/nvm-sh/nvm)
* [**`nvs`**](https://github.com/jasongin/nvs)
* [**`nave`**](https://github.com/isaacs/nave)
* [**`n`**](https://github.com/tj/n)
* [**`volta`**](https://github.com/volta-cli/volta)
* [**`nodenv`**](https://github.com/nodenv/nodenv)
* [**`asdf-nodejs`**](https://github.com/asdf-vm/asdf-nodejs)
* [**`nvm-windows`**](https://github.com/coreybutler/nvm-windows)
* [**`fnm`**](https://github.com/Schniz/fnm)
If you're looking to manage multiple versions of **`Node.js`** &/or **`npm`**, consider using a [node version manager](https://github.com/search?q=node%20version%20manager&type=repositories)

### Usage

2 changes: 1 addition & 1 deletion deps/npm/docs/content/commands/npm-ls.md
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ packages will *also* show the paths to the specified packages. For
example, running `npm ls promzard` in npm's source tree will show:

```bash
[email protected].2 /path/to/npm
[email protected].3 /path/to/npm
└─┬ [email protected]
└── [email protected]
```
1 change: 0 additions & 1 deletion deps/npm/docs/content/commands/npm-prefix.md
Original file line number Diff line number Diff line change
@@ -52,7 +52,6 @@ folder instead of the current working directory. See
### See Also

* [npm root](/commands/npm-root)
* [npm bin](/commands/npm-bin)
* [npm folders](/configuring-npm/folders)
* [npm config](/commands/npm-config)
* [npmrc](/configuring-npm/npmrc)
1 change: 0 additions & 1 deletion deps/npm/docs/content/commands/npm-root.md
Original file line number Diff line number Diff line change
@@ -44,7 +44,6 @@ folder instead of the current working directory. See
### See Also

* [npm prefix](/commands/npm-prefix)
* [npm bin](/commands/npm-bin)
* [npm folders](/configuring-npm/folders)
* [npm config](/commands/npm-config)
* [npmrc](/configuring-npm/npmrc)
2 changes: 1 addition & 1 deletion deps/npm/docs/content/commands/npm.md
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ Note: This command is unaware of workspaces.

### Version

9.6.2
9.6.3

### Description

13 changes: 2 additions & 11 deletions deps/npm/docs/content/configuring-npm/install.md
Original file line number Diff line number Diff line change
@@ -38,17 +38,8 @@ npm -v
Node version managers allow you to install and switch between multiple
versions of Node.js and npm on your system so you can test your
applications on multiple versions of npm to ensure they work for users on
different versions.

#### OSX or Linux Node version managers

* [nvm](https://github.com/creationix/nvm)
* [n](https://github.com/tj/n)

#### Windows Node version managers

* [nodist](https://github.com/marcelklehr/nodist)
* [nvm-windows](https://github.com/coreybutler/nvm-windows)
different versions. You can
[search for them on GitHub](https://github.com/search?q=node%20version%20manager&type=repositories).

### Using a Node installer to install Node.js and npm

2 changes: 1 addition & 1 deletion deps/npm/docs/output/commands/npm-ls.html
Original file line number Diff line number Diff line change
@@ -160,7 +160,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><code class="language-bash">[email protected].2 /path/to/npm
<pre><code class="language-bash">[email protected].3 /path/to/npm
└─┬ [email protected]
└── [email protected]
</code></pre>
1 change: 0 additions & 1 deletion deps/npm/docs/output/commands/npm-prefix.html
Original file line number Diff line number Diff line change
@@ -180,7 +180,6 @@ <h4 id="global"><code>global</code></h4>
<h3 id="see-also">See Also</h3>
<ul>
<li><a href="../commands/npm-root.html">npm root</a></li>
<li><a href="../commands/npm-bin.html">npm bin</a></li>
<li><a href="../configuring-npm/folders.html">npm folders</a></li>
<li><a href="../commands/npm-config.html">npm config</a></li>
<li><a href="../configuring-npm/npmrc.html">npmrc</a></li>
1 change: 0 additions & 1 deletion deps/npm/docs/output/commands/npm-root.html
Original file line number Diff line number Diff line change
@@ -175,7 +175,6 @@ <h4 id="global"><code>global</code></h4>
<h3 id="see-also">See Also</h3>
<ul>
<li><a href="../commands/npm-prefix.html">npm prefix</a></li>
<li><a href="../commands/npm-bin.html">npm bin</a></li>
<li><a href="../configuring-npm/folders.html">npm folders</a></li>
<li><a href="../commands/npm-config.html">npm config</a></li>
<li><a href="../configuring-npm/npmrc.html">npmrc</a></li>
2 changes: 1 addition & 1 deletion deps/npm/docs/output/commands/npm.html
Original file line number Diff line number Diff line change
@@ -150,7 +150,7 @@ <h2 id="table-of-contents">Table of contents</h2>
</code></pre>
<p>Note: This command is unaware of workspaces.</p>
<h3 id="version">Version</h3>
<p>9.6.2</p>
<p>9.6.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
15 changes: 3 additions & 12 deletions deps/npm/docs/output/configuring-npm/install.html
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@ <h1 id="install">install</h1>

<section id="table_of_contents">
<h2 id="table-of-contents">Table of contents</h2>
<div id="_table_of_contents"><ul><li><a href="#description">Description</a></li><li><a href="#overview">Overview</a></li><li><a href="#checking-your-version-of-npm-and-nodejs">Checking your version of npm and Node.js</a></li><li><a href="#using-a-node-version-manager-to-install-nodejs-and-npm">Using a Node version manager to install Node.js and npm</a></li><ul><li><a href="#osx-or-linux-node-version-managers">OSX or Linux Node version managers</a></li><li><a href="#windows-node-version-managers">Windows Node version managers</a></li></ul><li><a href="#using-a-node-installer-to-install-nodejs-and-npm">Using a Node installer to install Node.js and npm</a></li><ul><li><a href="#os-x-or-windows-node-installers">OS X or Windows Node installers</a></li><li><a href="#linux-or-other-operating-systems-node-installers">Linux or other operating systems Node installers</a></li><li><a href="#less-common-operating-systems">Less-common operating systems</a></li></ul></ul></div>
<div id="_table_of_contents"><ul><li><a href="#description">Description</a></li><li><a href="#overview">Overview</a></li><li><a href="#checking-your-version-of-npm-and-nodejs">Checking your version of npm and Node.js</a></li><li><a href="#using-a-node-version-manager-to-install-nodejs-and-npm">Using a Node version manager to install Node.js and npm</a></li><li><a href="#using-a-node-installer-to-install-nodejs-and-npm">Using a Node installer to install Node.js and npm</a></li><ul><li><a href="#os-x-or-windows-node-installers">OS X or Windows Node installers</a></li><li><a href="#linux-or-other-operating-systems-node-installers">Linux or other operating systems Node installers</a></li><li><a href="#less-common-operating-systems">Less-common operating systems</a></li></ul></ul></div>
</section>

<div id="_content"><h3 id="description">Description</h3>
@@ -172,17 +172,8 @@ <h3 id="using-a-node-version-manager-to-install-nodejs-and-npm">Using a Node ver
<p>Node version managers allow you to install and switch between multiple
versions of Node.js and npm on your system so you can test your
applications on multiple versions of npm to ensure they work for users on
different versions.</p>
<h4 id="osx-or-linux-node-version-managers">OSX or Linux Node version managers</h4>
<ul>
<li><a href="https://github.com/creationix/nvm">nvm</a></li>
<li><a href="https://github.com/tj/n">n</a></li>
</ul>
<h4 id="windows-node-version-managers">Windows Node version managers</h4>
<ul>
<li><a href="https://github.com/marcelklehr/nodist">nodist</a></li>
<li><a href="https://github.com/coreybutler/nvm-windows">nvm-windows</a></li>
</ul>
different versions. You can
<a href="https://github.com/search?q=node%20version%20manager&amp;type=repositories">search for them on GitHub</a>.</p>
<h3 id="using-a-node-installer-to-install-nodejs-and-npm">Using a Node installer to install Node.js and npm</h3>
<p>If you are unable to use a Node version manager, you can use a Node
installer to install both Node.js and npm on your system.</p>
113 changes: 34 additions & 79 deletions deps/npm/lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,28 @@
// This is separate to indicate that it should contain code we expect to work in
// all conceivably runnable versions of node. This is a best effort to catch
// syntax errors to give users a good error message if they are using a node
// version that doesn't allow syntax we are using such as private properties, etc
const createEnginesValidation = () => {
const node = process.version.replace(/-.*$/, '')
/* eslint-disable max-len */
// Code in this file should work in all conceivably runnable versions of node.
// A best effort is made to catch syntax errors to give users a good error message if they are using a node version that doesn't allow syntax we are using in other files such as private properties, etc

// Separated out for easier unit testing
module.exports = async process => {
// set it here so that regardless of what happens later, we don't
// leak any private CLI configs to other programs
process.title = 'npm'

// if npm is called as "npmg" or "npm_g", then run in global mode.
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}

const nodeVersion = process.version.replace(/-.*$/, '')
const pkg = require('../package.json')
const engines = pkg.engines.node
const npm = `v${pkg.version}`

const cols = Math.min(Math.max(20, process.stdout.columns) || 80, 80)
const wrap = (lines) => lines
.join(' ')
.split(/[ \n]+/)
.reduce((left, right) => {
const last = left.split('\n').pop()
const join = last.length && last.length + right.length > cols ? '\n' : ' '
return left + join + right
})
.trim()

const unsupportedMessage = wrap([
`npm ${npm} does not support Node.js ${node}.`,
`You should probably upgrade to a newer version of node as we can't make any`,
`promises that npm will work with this version.`,
`This version of npm supports the following node versions: \`${engines}\`.`,
'You can find the latest version at https://nodejs.org/.',
])

const brokenMessage = wrap([
`ERROR: npm ${npm} is known not to run on Node.js ${node}.`,
`You'll need to upgrade to a newer Node.js version in order to use this version of npm.`,
`This version of npm supports the following node versions: \`${engines}\`.`,
'You can find the latest version at https://nodejs.org/.',
])

// coverage ignored because this is only hit in very unsupported node versions
// and it's a best effort attempt to show something nice in those cases
const npmVersion = `v${pkg.version}`

const unsupportedMessage = `npm ${npmVersion} does not support Node.js ${nodeVersion}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`

const brokenMessage = `ERROR: npm ${npmVersion} is known not to run on Node.js ${nodeVersion}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`

// Coverage ignored because this is only hit in very unsupported node versions and it's a best effort attempt to show something nice in those cases
/* istanbul ignore next */
const syntaxErrorHandler = (err) => {
if (err instanceof SyntaxError) {
@@ -51,74 +38,42 @@ const createEnginesValidation = () => {
process.on('uncaughtException', syntaxErrorHandler)
process.on('unhandledRejection', syntaxErrorHandler)

return {
node,
engines,
unsupportedMessage,
off: () => {
process.off('uncaughtException', syntaxErrorHandler)
process.off('unhandledRejection', syntaxErrorHandler)
},
}
}

// Separated out for easier unit testing
module.exports = async process => {
// set it here so that regardless of what happens later, we don't
// leak any private CLI configs to other programs
process.title = 'npm'

// if npm is called as "npmg" or "npm_g", then run in global mode.
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}

// Nothing should happen before this line if we can't guarantee it will
// not have syntax errors in some version of node
const validateEngines = createEnginesValidation()

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

// only log node and npm paths in argv initially since argv can contain
// sensitive info. a cleaned version will be logged later
// only log node and npm paths in argv initially since argv can contain sensitive info. a cleaned version will be logged later
const log = require('./utils/log-shim.js')
log.verbose('cli', process.argv.slice(0, 2).join(' '))
log.info('using', 'npm@%s', npm.version)
log.info('using', 'node@%s', process.version)

// At this point we've required a few files and can be pretty sure
// we dont contain invalid syntax for this version of node. It's
// possible a lazy require would, but that's unlikely enough that
// it's not worth catching anymore and we attach the more important
// exit handlers.
validateEngines.off()
// At this point we've required a few files and can be pretty sure we dont contain invalid syntax for this version of node. It's possible a lazy require would, but that's unlikely enough that it's not worth catching anymore and we attach the more important exit handlers.
process.off('uncaughtException', syntaxErrorHandler)
process.off('unhandledRejection', syntaxErrorHandler)
process.on('uncaughtException', exitHandler)
process.on('unhandledRejection', exitHandler)

// It is now safe to log a warning if they are using a version of node
// that is not going to fail on syntax errors but is still unsupported
// and untested and might not work reliably. This is safe to use the logger
// now which we want since this will show up in the error log too.
if (!satisfies(validateEngines.node, validateEngines.engines)) {
log.warn('cli', validateEngines.unsupportedMessage)
// It is now safe to log a warning if they are using a version of node that is not going to fail on syntax errors but is still unsupported and untested and might not work reliably. This is safe to use the logger now which we want since this will show up in the error log too.
if (!satisfies(nodeVersion, engines)) {
log.warn('cli', unsupportedMessage)
}

let cmd
// now actually fire up npm and run the command.
// this is how to use npm programmatically:
// Now actually fire up npm and run the command.
// This is how to use npm programmatically:
try {
await npm.load()

// npm -v
if (npm.config.get('version', 'cli')) {
npm.output(npm.version)
return exitHandler()
}

// npm --versions=cli
// npm --versions
if (npm.config.get('versions', 'cli')) {
npm.argv = ['version']
npm.config.set('usage', false, 'cli')
9 changes: 4 additions & 5 deletions deps/npm/lib/commands/completion.js
Original file line number Diff line number Diff line change
@@ -34,9 +34,7 @@ const nopt = require('nopt')
const { resolve } = require('path')

const { definitions, shorthands } = require('../utils/config/index.js')
const { aliases, commands, plumbing } = require('../utils/cmd-list.js')
const aliasNames = Object.keys(aliases)
const fullList = commands.concat(aliasNames).filter(c => !plumbing.includes(c))
const { commands, aliases } = require('../utils/cmd-list.js')
const configNames = Object.keys(definitions)
const shorthandNames = Object.keys(shorthands)
const allConfs = configNames.concat(shorthandNames)
@@ -263,7 +261,8 @@ const isFlag = word => {
// complete against the npm commands
// if they all resolve to the same thing, just return the thing it already is
const cmdCompl = (opts, npm) => {
const matches = fullList.filter(c => c.startsWith(opts.partialWord))
const allCommands = commands.concat(Object.keys(aliases))
const matches = allCommands.filter(c => c.startsWith(opts.partialWord))
if (!matches.length) {
return matches
}
@@ -273,7 +272,7 @@ const cmdCompl = (opts, npm) => {
return [...derefs]
}

return fullList
return allCommands
}

module.exports = Completion
2 changes: 1 addition & 1 deletion deps/npm/lib/commands/explain.js
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ class Explain extends ArboristWorkspaceCmd {
this.npm.output(JSON.stringify(expls, null, 2))
} else {
this.npm.output(expls.map(expl => {
return explainNode(expl, Infinity, this.npm.color)
return explainNode(expl, Infinity, this.npm.chalk)
}).join('\n\n'))
}
}
6 changes: 2 additions & 4 deletions deps/npm/lib/commands/fund.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const archy = require('archy')
const Arborist = require('@npmcli/arborist')
const chalk = require('chalk')
const pacote = require('pacote')
const semver = require('semver')
const npa = require('npm-package-arg')
@@ -96,7 +95,6 @@ class Fund extends ArboristWorkspaceCmd {
}

printHuman (fundingInfo) {
const color = this.npm.color
const unicode = this.npm.config.get('unicode')
const seenUrls = new Map()

@@ -117,7 +115,7 @@ class Fund extends ArboristWorkspaceCmd {

if (url) {
item.label = tree({
label: color ? chalk.bgBlack.white(url) : url,
label: this.npm.chalk.bgBlack.white(url),
nodes: [pkgRef],
}).trim()

@@ -154,7 +152,7 @@ class Fund extends ArboristWorkspaceCmd {
})

const res = tree(result)
return color ? chalk.reset(res) : res
return this.npm.chalk.reset(res)
}

async openFundingUrl ({ path, tree, spec, fundingSourceNumber }) {
17 changes: 6 additions & 11 deletions deps/npm/lib/commands/help-search.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const fs = require('fs')
const { readFile } = require('fs/promises')
const path = require('path')
const chalk = require('chalk')
const { promisify } = require('util')
const glob = promisify(require('glob'))
const readFile = promisify(fs.readFile)
const glob = require('glob')
const BaseCommand = require('../base-command.js')

const globify = pattern => pattern.split('\\').join('/')
@@ -20,7 +17,9 @@ class HelpSearch extends BaseCommand {
}

const docPath = path.resolve(this.npm.npmRoot, 'docs/content')
const files = await glob(`${globify(docPath)}/*/*.md`)
let files = await glob(`${globify(docPath)}/*/*.md`)
// preserve glob@8 behavior
files = files.sort((a, b) => a.localeCompare(b, 'en'))
const data = await this.readFiles(files)
const results = await this.searchFiles(args, data, files)
const formatted = this.formatResults(args, results)
@@ -163,18 +162,14 @@ class HelpSearch extends BaseCommand {
return
}

if (!this.npm.color) {
out.push(line + '\n')
return
}
const hilitLine = []
for (const arg of args) {
const finder = line.toLowerCase().split(arg.toLowerCase())
let p = 0
for (const f of finder) {
hilitLine.push(line.slice(p, p + f.length))
const word = line.slice(p + f.length, p + f.length + arg.length)
const hilit = chalk.bgBlack.red(word)
const hilit = this.npm.chalk.bgBlack.red(word)
hilitLine.push(hilit)
p += f.length + arg.length
}
35 changes: 8 additions & 27 deletions deps/npm/lib/commands/help.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const spawn = require('@npmcli/promise-spawn')
const path = require('path')
const openUrl = require('../utils/open-url.js')
const { promisify } = require('util')
const glob = promisify(require('glob'))
const glob = require('glob')
const localeCompare = require('@isaacs/string-locale-compare')('en')

const globify = pattern => pattern.split('\\').join('/')
@@ -12,8 +11,6 @@ const BaseCommand = require('../base-command.js')
// We don't currently compress our man pages but if we ever did this would
// seamlessly continue supporting it
const manNumberRegex = /\.(\d+)(\.[^/\\]*)?$/
// Searches for the "npm-" prefix in page names, to prefer those.
const manNpmPrefixRegex = /\/npm-/
// hardcoded names for mansections
// XXX: these are used in the docs workspace and should be exported
// from npm so section names can changed more easily
@@ -34,7 +31,9 @@ class Help extends BaseCommand {
return []
}
const g = path.resolve(this.npm.npmRoot, 'man/man[0-9]/*.[0-9]')
const files = await glob(globify(g))
let files = await glob(globify(g))
// preserve glob@8 behavior
files = files.sort((a, b) => a.localeCompare(b, 'en'))

return Object.keys(files.reduce(function (acc, file) {
file = path.basename(file).replace(/\.[0-9]+$/, '')
@@ -65,31 +64,13 @@ class Help extends BaseCommand {
const f = globify(path.resolve(this.npm.npmRoot, `man/${manSearch}/?(npm-)${arg}.[0-9]*`))

const [man] = await glob(f).then(r => r.sort((a, b) => {
// Prefer the page with an npm prefix, if there's only one.
const aHasPrefix = manNpmPrefixRegex.test(a)
const bHasPrefix = manNpmPrefixRegex.test(b)
if (aHasPrefix !== bHasPrefix) {
/* istanbul ignore next */
return aHasPrefix ? -1 : 1
}

// Because the glob is (subtly) different from manNumberRegex,
// we can't rely on it passing.
const aManNumberMatch = a.match(manNumberRegex)
const bManNumberMatch = b.match(manNumberRegex)
if (aManNumberMatch) {
/* istanbul ignore next */
if (!bManNumberMatch) {
return -1
}
// man number sort first so that 1 aka commands are preferred
if (aManNumberMatch[1] !== bManNumberMatch[1]) {
return aManNumberMatch[1] - bManNumberMatch[1]
}
} else if (bManNumberMatch) {
return 1
const aManNumberMatch = a.match(manNumberRegex)?.[1] || 999
const bManNumberMatch = b.match(manNumberRegex)?.[1] || 999
if (aManNumberMatch !== bManNumberMatch) {
return aManNumberMatch - bManNumberMatch
}

return localeCompare(a, b)
}))

28 changes: 13 additions & 15 deletions deps/npm/lib/commands/ls.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ const relativePrefix = `.${sep}`
const { EOL } = require('os')

const archy = require('archy')
const chalk = require('chalk')
const Arborist = require('@npmcli/arborist')
const { breadth } = require('treeverse')
const npa = require('npm-package-arg')
@@ -50,7 +49,7 @@ class LS extends ArboristWorkspaceCmd {

async exec (args) {
const all = this.npm.config.get('all')
const color = this.npm.color
const chalk = this.npm.chalk
const depth = this.npm.config.get('depth')
const global = this.npm.global
const json = this.npm.config.get('json')
@@ -157,7 +156,7 @@ class LS extends ArboristWorkspaceCmd {
? getJsonOutputItem(node, { global, long })
: parseable
? null
: getHumanOutputItem(node, { args, color, global, long })
: getHumanOutputItem(node, { args, chalk, global, long })

// loop through list of node problems to add them to global list
if (node[_include]) {
@@ -180,7 +179,7 @@ class LS extends ArboristWorkspaceCmd {
this.npm.outputBuffer(
json ? jsonOutput({ path, problems, result, rootError, seenItems }) :
parseable ? parseableOutput({ seenNodes, global, long }) :
humanOutput({ color, result, seenItems, unicode })
humanOutput({ chalk, result, seenItems, unicode })
)

// if filtering items, should exit with error code on no results
@@ -278,9 +277,9 @@ const augmentItemWithIncludeMetadata = (node, item) => {
return item
}

const getHumanOutputItem = (node, { args, color, global, long }) => {
const getHumanOutputItem = (node, { args, chalk, global, long }) => {
const { pkgid, path } = node
const workspacePkgId = color ? chalk.green(pkgid) : pkgid
const workspacePkgId = chalk.green(pkgid)
let printable = node.isWorkspace ? workspacePkgId : pkgid

// special formatting for top-level package name
@@ -293,8 +292,7 @@ const getHumanOutputItem = (node, { args, color, global, long }) => {
}
}

const highlightDepName =
color && args.length && node[_filteredBy]
const highlightDepName = args.length && node[_filteredBy]
const missingColor = isOptional(node)
? chalk.yellow.bgBlack
: chalk.red.bgBlack
@@ -308,28 +306,28 @@ const getHumanOutputItem = (node, { args, color, global, long }) => {
const label =
(
node[_missing]
? (color ? missingColor(missingMsg) : missingMsg) + ' '
? missingColor(missingMsg) + ' '
: ''
) +
`${highlightDepName ? chalk.yellow.bgBlack(printable) : printable}` +
(
node[_dedupe]
? ' ' + (color ? chalk.gray('deduped') : 'deduped')
? ' ' + chalk.gray('deduped')
: ''
) +
(
invalid
? ' ' + (color ? chalk.red.bgBlack(invalid) : invalid)
? ' ' + chalk.red.bgBlack(invalid)
: ''
) +
(
isExtraneous(node, { global })
? ' ' + (color ? chalk.green.bgBlack('extraneous') : 'extraneous')
? ' ' + chalk.green.bgBlack('extraneous')
: ''
) +
(
node.overridden
? ' ' + (color ? chalk.gray('overridden') : 'overridden')
? ' ' + chalk.gray('overridden')
: ''
) +
(isGitNode(node) ? ` (${node.resolved})` : '') +
@@ -504,7 +502,7 @@ const augmentNodesWithMetadata = ({

const sortAlphabetically = ({ pkgid: a }, { pkgid: b }) => localeCompare(a, b)

const humanOutput = ({ color, result, seenItems, unicode }) => {
const humanOutput = ({ chalk, result, seenItems, unicode }) => {
// we need to traverse the entire tree in order to determine which items
// should be included (since a nested transitive included dep will make it
// so that all its ancestors should be displayed)
@@ -520,7 +518,7 @@ const humanOutput = ({ color, result, seenItems, unicode }) => {
}

const archyOutput = archy(result, '', { unicode })
return color ? chalk.reset(archyOutput) : archyOutput
return chalk.reset(archyOutput)
}

const jsonOutput = ({ path, problems, result, rootError, seenItems }) => {
17 changes: 6 additions & 11 deletions deps/npm/lib/commands/outdated.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ const os = require('os')
const { resolve } = require('path')
const pacote = require('pacote')
const table = require('text-table')
const chalk = require('chalk')
const npa = require('npm-package-arg')
const pickManifest = require('npm-pick-manifest')
const localeCompare = require('@isaacs/string-locale-compare')('en')
@@ -104,9 +103,7 @@ class Outdated extends ArboristWorkspaceCmd {
}
const outTable = [outHead].concat(outList)

if (this.npm.color) {
outTable[0] = outTable[0].map(heading => chalk.underline(heading))
}
outTable[0] = outTable[0].map(heading => this.npm.chalk.underline(heading))

const tableOpts = {
align: ['l', 'r', 'r', 'r', 'l'],
@@ -281,8 +278,8 @@ class Outdated extends ArboristWorkspaceCmd {
? node.pkgid
: node.name

return this.npm.color && humanOutput
? chalk.green(workspaceName)
return humanOutput
? this.npm.chalk.green(workspaceName)
: workspaceName
}

@@ -306,11 +303,9 @@ class Outdated extends ArboristWorkspaceCmd {
columns[7] = homepage
}

if (this.npm.color) {
columns[0] = chalk[current === wanted ? 'yellow' : 'red'](columns[0]) // current
columns[2] = chalk.green(columns[2]) // wanted
columns[3] = chalk.magenta(columns[3]) // latest
}
columns[0] = this.npm.chalk[current === wanted ? 'yellow' : 'red'](columns[0]) // current
columns[2] = this.npm.chalk.green(columns[2]) // wanted
columns[3] = this.npm.chalk.magenta(columns[3]) // latest

return columns
}
3 changes: 1 addition & 2 deletions deps/npm/lib/commands/profile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const inspect = require('util').inspect
const { URL } = require('url')
const chalk = require('chalk')
const log = require('../utils/log-shim.js')
const npmProfile = require('npm-profile')
const qrcodeTerminal = require('qrcode-terminal')
@@ -161,7 +160,7 @@ class Profile extends BaseCommand {
} else {
const table = new Table()
for (const key of Object.keys(cleaned)) {
table.push({ [chalk.bold(key)]: cleaned[key] })
table.push({ [this.npm.chalk.bold(key)]: cleaned[key] })
}

this.npm.output(table.toString())
12 changes: 1 addition & 11 deletions deps/npm/lib/commands/run-script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { resolve } = require('path')
const chalk = require('chalk')
const runScript = require('@npmcli/run-script')
const { isServerPackage } = runScript
const rpj = require('read-package-json-fast')
@@ -18,14 +17,6 @@ const cmdList = [
'version',
].reduce((l, p) => l.concat(['pre' + p, p, 'post' + p]), [])

const nocolor = {
reset: s => s,
bold: s => s,
dim: s => s,
blue: s => s,
green: s => s,
}

const BaseCommand = require('../base-command.js')
class RunScript extends BaseCommand {
static description = 'Run arbitrary package scripts'
@@ -138,7 +129,6 @@ class RunScript extends BaseCommand {
path = path || this.npm.localPrefix
const { scripts, name, _id } = await rpj(`${path}/package.json`)
const pkgid = _id || name
const color = this.npm.color

if (!scripts) {
return []
@@ -170,7 +160,7 @@ class RunScript extends BaseCommand {
const list = cmdList.includes(script) ? cmds : runScripts
list.push(script)
}
const colorize = color ? chalk : nocolor
const colorize = this.npm.chalk

if (cmds.length) {
this.npm.output(
3 changes: 1 addition & 2 deletions deps/npm/lib/commands/token.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const Table = require('cli-table3')
const chalk = require('chalk')
const { v4: isCidrV4, v6: isCidrV6 } = require('is-cidr')
const log = require('../utils/log-shim.js')
const profile = require('npm-profile')
@@ -152,7 +151,7 @@ class Token extends BaseCommand {
} else {
const table = new Table()
for (const k of Object.keys(result)) {
table.push({ [chalk.bold(k)]: String(result[k]) })
table.push({ [this.npm.chalk.bold(k)]: String(result[k]) })
}
this.npm.output(table.toString())
}
2 changes: 1 addition & 1 deletion deps/npm/lib/commands/view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const chalk = require('chalk')
const columns = require('cli-columns')
const fs = require('fs')
const jsonParse = require('json-parse-even-better-errors')
@@ -315,6 +314,7 @@ class View extends BaseCommand {
prettyView (packu, manifest) {
// More modern, pretty printing of default view
const unicode = this.npm.config.get('unicode')
const chalk = this.npm.chalk
const tags = []

Object.keys(packu['dist-tags']).forEach((t) => {
47 changes: 37 additions & 10 deletions deps/npm/lib/npm.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ const Config = require('@npmcli/config')
const chalk = require('chalk')
const which = require('which')
const fs = require('fs/promises')
const abbrev = require('abbrev')

// Patch the global fs module here at the app level
require('graceful-fs').gracefulify(require('fs'))
@@ -18,7 +19,7 @@ const log = require('./utils/log-shim')
const replaceInfo = require('./utils/replace-info.js')
const updateNotifier = require('./utils/update-notifier.js')
const pkg = require('../package.json')
const cmdList = require('./utils/cmd-list.js')
const { commands, aliases } = require('./utils/cmd-list.js')

class Npm extends EventEmitter {
static get version () {
@@ -36,6 +37,8 @@ class Npm extends EventEmitter {
#title = 'npm'
#argvClean = []
#chalk = null
#logChalk = null
#noColorChalk = new chalk.Instance({ level: 0 })
#npmRoot = null
#warnedNonDashArg = false

@@ -84,18 +87,30 @@ class Npm extends EventEmitter {
if (!c) {
return
}

// Translate camelCase to snake-case (i.e. installTest to install-test)
if (c.match(/[A-Z]/)) {
c = c.replace(/([A-Z])/g, m => '-' + m.toLowerCase())
}
if (cmdList.plumbing.indexOf(c) !== -1) {

// if they asked for something exactly we are done
if (commands.includes(c)) {
return c
}

// if they asked for a direct alias
if (aliases[c]) {
return aliases[c]
}

const abbrevs = abbrev(commands.concat(Object.keys(aliases)))

// first deref the abbrev, if there is one
// then resolve any aliases
// so `npm install-cl` will resolve to `install-clean` then to `ci`
let a = cmdList.abbrevs[c]
while (cmdList.aliases[a]) {
a = cmdList.aliases[a]
let a = abbrevs[c]
while (aliases[a]) {
a = aliases[a]
}
return a
}
@@ -248,6 +263,7 @@ class Npm extends EventEmitter {
this.#display.load({
// Use logColor since that is based on stderr
color: this.logColor,
chalk: this.logChalk,
progress: this.flatOptions.progress,
silent: this.silent,
timing: this.config.get('timing'),
@@ -317,17 +333,28 @@ class Npm extends EventEmitter {
return this.flatOptions.logColor
}

get noColorChalk () {
return this.#noColorChalk
}

get chalk () {
if (!this.#chalk) {
let level = chalk.level
if (!this.color) {
level = 0
}
this.#chalk = new chalk.Instance({ level })
this.#chalk = new chalk.Instance({
level: this.color ? chalk.level : 0,
})
}
return this.#chalk
}

get logChalk () {
if (!this.#logChalk) {
this.#logChalk = new chalk.Instance({
level: this.logColor ? chalk.stderr.level : 0,
})
}
return this.#logChalk
}

get global () {
return this.config.get('global') || this.config.get('location') === 'global'
}
150 changes: 71 additions & 79 deletions deps/npm/lib/utils/cmd-list.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,5 @@
const abbrev = require('abbrev')
const localeCompare = require('@isaacs/string-locale-compare')('en')

// plumbing should not have any aliases
const aliases = {

// aliases
author: 'owner',
home: 'docs',
issues: 'bugs',
info: 'view',
show: 'view',
find: 'search',
add: 'install',
unlink: 'uninstall',
remove: 'uninstall',
rm: 'uninstall',
r: 'uninstall',

// short names for common things
un: 'uninstall',
rb: 'rebuild',
list: 'ls',
ln: 'link',
create: 'init',
i: 'install',
it: 'install-test',
cit: 'install-ci-test',
up: 'update',
c: 'config',
s: 'search',
se: 'search',
tst: 'test',
t: 'test',
ddp: 'dedupe',
v: 'view',
run: 'run-script',
'clean-install': 'ci',
'clean-install-test': 'install-ci-test',
x: 'exec',
why: 'explain',
la: 'll',
verison: 'version',
ic: 'ci',

// typos
innit: 'init',
// manually abbrev so that install-test doesn't make insta stop working
in: 'install',
ins: 'install',
inst: 'install',
insta: 'install',
instal: 'install',
isnt: 'install',
isnta: 'install',
isntal: 'install',
isntall: 'install',
'install-clean': 'ci',
'isntall-clean': 'ci',
hlep: 'help',
'dist-tags': 'dist-tag',
upgrade: 'update',
udpate: 'update',
rum: 'run-script',
sit: 'install-ci-test',
urn: 'run-script',
ogr: 'org',
'add-user': 'adduser',
}

// these are filenames in .
// These correspond to filenames in lib/commands
// Please keep this list sorted alphabetically
const commands = [
'access',
'adduser',
@@ -92,14 +23,15 @@ const commands = [
'fund',
'get',
'help',
'help-search',
'hook',
'init',
'install',
'install-ci-test',
'install-test',
'link',
'll',
'login', // This is an alias for `adduser` but it can be confusing
'login',
'logout',
'ls',
'org',
@@ -135,16 +67,76 @@ const commands = [
'version',
'view',
'whoami',
].sort(localeCompare)
]

// These must resolve to an entry in commands
const aliases = {

// aliases
author: 'owner',
home: 'docs',
issues: 'bugs',
info: 'view',
show: 'view',
find: 'search',
add: 'install',
unlink: 'uninstall',
remove: 'uninstall',
rm: 'uninstall',
r: 'uninstall',

// short names for common things
un: 'uninstall',
rb: 'rebuild',
list: 'ls',
ln: 'link',
create: 'init',
i: 'install',
it: 'install-test',
cit: 'install-ci-test',
up: 'update',
c: 'config',
s: 'search',
se: 'search',
tst: 'test',
t: 'test',
ddp: 'dedupe',
v: 'view',
run: 'run-script',
'clean-install': 'ci',
'clean-install-test': 'install-ci-test',
x: 'exec',
why: 'explain',
la: 'll',
verison: 'version',
ic: 'ci',

const plumbing = ['help-search']
const allCommands = [...commands, ...plumbing].sort(localeCompare)
const abbrevs = abbrev(commands.concat(Object.keys(aliases)))
// typos
innit: 'init',
// manually abbrev so that install-test doesn't make insta stop working
in: 'install',
ins: 'install',
inst: 'install',
insta: 'install',
instal: 'install',
isnt: 'install',
isnta: 'install',
isntal: 'install',
isntall: 'install',
'install-clean': 'ci',
'isntall-clean': 'ci',
hlep: 'help',
'dist-tags': 'dist-tag',
upgrade: 'update',
udpate: 'update',
rum: 'run-script',
sit: 'install-ci-test',
urn: 'run-script',
ogr: 'org',
'add-user': 'adduser',
}

module.exports = {
abbrevs,
aliases,
commands,
plumbing,
allCommands,
}
7 changes: 6 additions & 1 deletion deps/npm/lib/utils/display.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ const log = require('./log-shim.js')
const { explain } = require('./explain-eresolve.js')

class Display {
#chalk = null

constructor () {
// pause by default until config is loaded
this.on()
@@ -26,6 +28,7 @@ class Display {
load (config) {
const {
color,
chalk,
timing,
loglevel,
unicode,
@@ -34,6 +37,8 @@ class Display {
heading = 'npm',
} = config

this.#chalk = chalk

// npmlog is still going away someday, so this is a hack to dynamically
// set the loglevel of timing based on the timing flag, instead of making
// a breaking change to npmlog. The result is that timing logs are never
@@ -111,7 +116,7 @@ class Display {
expl && typeof expl === 'object'
) {
this.#npmlog(level, heading, message)
this.#npmlog(level, '', explain(expl, log.useColor(), 2))
this.#npmlog(level, '', explain(expl, this.#chalk, 2))
// Return true to short circuit other log in chain
return true
}
47 changes: 30 additions & 17 deletions deps/npm/lib/utils/error-message.js
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ const errorMessage = (er, npm) => {
// XXX(display): error messages are logged so we use the logColor since that is based
// on stderr. This should be handled solely by the display layer so it could also be
// printed to stdout if necessary.
const { explanation, file } = report(er, !!npm.logColor)
const { explanation, file } = report(er, npm.logChalk, npm.noColorChalk)
detail.push(['', explanation])
files.push(['eresolve-report.txt', file])
break
@@ -247,16 +247,34 @@ const errorMessage = (er, npm) => {
break

case 'EBADPLATFORM': {
const validOs =
er.required && er.required.os && er.required.os.join
? er.required.os.join(',')
: er.required.os
const validArch =
er.required && er.required.cpu && er.required.cpu.join
? er.required.cpu.join(',')
: er.required.cpu
const expected = { os: validOs, arch: validArch }
const actual = { os: process.platform, arch: process.arch }
const actual = er.current
const expected = { ...er.required }
const checkedKeys = []
for (const key in expected) {
if (Array.isArray(expected[key]) && expected[key].length > 0) {
expected[key] = expected[key].join(',')
checkedKeys.push(key)
} else if (expected[key] === undefined ||
Array.isArray(expected[key]) && expected[key].length === 0) {
delete expected[key]
delete actual[key]
} else {
checkedKeys.push(key)
}
}

const longestKey = Math.max(...checkedKeys.map((key) => key.length))
const detailEntry = []
for (const key of checkedKeys) {
const padding = key.length === longestKey
? 1
: 1 + (longestKey - key.length)

// padding + 1 because 'actual' is longer than 'valid'
detailEntry.push(`Valid ${key}:${' '.repeat(padding + 1)}${expected[key]}`)
detailEntry.push(`Actual ${key}:${' '.repeat(padding)}${actual[key]}`)
}

short.push([
'notsup',
[
@@ -270,12 +288,7 @@ const errorMessage = (er, npm) => {
])
detail.push([
'notsup',
[
'Valid OS: ' + validOs,
'Valid Arch: ' + validArch,
'Actual OS: ' + process.platform,
'Actual Arch: ' + process.arch,
].join('\n'),
detailEntry.join('\n'),
])
break
}
6 changes: 2 additions & 4 deletions deps/npm/lib/utils/exit-handler.js
Original file line number Diff line number Diff line change
@@ -5,8 +5,6 @@ const log = require('./log-shim.js')
const errorMessage = require('./error-message.js')
const replaceInfo = require('./replace-info.js')

const indent = (val) => Array.isArray(val) ? val.map(v => indent(v)) : ` ${val}`

let npm = null // set by the cli
let exitHandlerCalled = false
let showLogFileError = false
@@ -73,15 +71,15 @@ process.on('exit', code => {
const message = []

if (timingFile) {
message.push('Timing info written to:', indent(timingFile))
message.push(`Timing info written to: ${timingFile}`)
} else if (timing) {
message.push(
`The timing file was not written due to an error writing to the directory: ${timingDir}`
)
}

if (logFiles.length) {
message.push('A complete log of this run can be found in:', ...indent(logFiles))
message.push(`A complete log of this run can be found in: ${logFiles}`)
} else if (logsMax <= 0) {
// user specified no log file
message.push(`Log files were not written due to the config logs-max=${logsMax}`)
69 changes: 28 additions & 41 deletions deps/npm/lib/utils/explain-dep.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
const chalk = require('chalk')
const nocolor = {
bold: s => s,
dim: s => s,
red: s => s,
yellow: s => s,
cyan: s => s,
magenta: s => s,
blue: s => s,
green: s => s,
gray: s => s,
}

const { relative } = require('path')

const explainNode = (node, depth, color) =>
printNode(node, color) +
explainDependents(node, depth, color) +
explainLinksIn(node, depth, color)
const explainNode = (node, depth, chalk) =>
printNode(node, chalk) +
explainDependents(node, depth, chalk) +
explainLinksIn(node, depth, chalk)

const colorType = (type, color) => {
const { red, yellow, cyan, magenta, blue, green, gray } = color ? chalk : nocolor
const colorType = (type, chalk) => {
const { red, yellow, cyan, magenta, blue, green, gray } = chalk
const style = type === 'extraneous' ? red
: type === 'dev' ? yellow
: type === 'optional' ? cyan
@@ -31,7 +18,7 @@ const colorType = (type, color) => {
return style(type)
}

const printNode = (node, color) => {
const printNode = (node, chalk) => {
const {
name,
version,
@@ -44,30 +31,30 @@ const printNode = (node, color) => {
isWorkspace,
overridden,
} = node
const { bold, dim, green } = color ? chalk : nocolor
const { bold, dim, green } = chalk
const extra = []
if (extraneous) {
extra.push(' ' + bold(colorType('extraneous', color)))
extra.push(' ' + bold(colorType('extraneous', chalk)))
}

if (dev) {
extra.push(' ' + bold(colorType('dev', color)))
extra.push(' ' + bold(colorType('dev', chalk)))
}

if (optional) {
extra.push(' ' + bold(colorType('optional', color)))
extra.push(' ' + bold(colorType('optional', chalk)))
}

if (peer) {
extra.push(' ' + bold(colorType('peer', color)))
extra.push(' ' + bold(colorType('peer', chalk)))
}

if (bundled) {
extra.push(' ' + bold(colorType('bundled', color)))
extra.push(' ' + bold(colorType('bundled', chalk)))
}

if (overridden) {
extra.push(' ' + bold(colorType('overridden', color)))
extra.push(' ' + bold(colorType('overridden', chalk)))
}

const pkgid = isWorkspace
@@ -78,24 +65,24 @@ const printNode = (node, color) => {
(location ? dim(`\n${location}`) : '')
}

const explainLinksIn = ({ linksIn }, depth, color) => {
const explainLinksIn = ({ linksIn }, depth, chalk) => {
if (!linksIn || !linksIn.length || depth <= 0) {
return ''
}

const messages = linksIn.map(link => explainNode(link, depth - 1, color))
const messages = linksIn.map(link => explainNode(link, depth - 1, chalk))
const str = '\n' + messages.join('\n')
return str.split('\n').join('\n ')
}

const explainDependents = ({ name, dependents }, depth, color) => {
const explainDependents = ({ name, dependents }, depth, chalk) => {
if (!dependents || !dependents.length || depth <= 0) {
return ''
}

const max = Math.ceil(depth / 2)
const messages = dependents.slice(0, max)
.map(edge => explainEdge(edge, depth, color))
.map(edge => explainEdge(edge, depth, chalk))

// show just the names of the first 5 deps that overflowed the list
if (dependents.length > max) {
@@ -119,30 +106,30 @@ const explainDependents = ({ name, dependents }, depth, color) => {
return str.split('\n').join('\n ')
}

const explainEdge = ({ name, type, bundled, from, spec, rawSpec, overridden }, depth, color) => {
const { bold } = color ? chalk : nocolor
const explainEdge = ({ name, type, bundled, from, spec, rawSpec, overridden }, depth, chalk) => {
const { bold } = chalk
let dep = type === 'workspace'
? bold(relative(from.location, spec.slice('file:'.length)))
: `${bold(name)}@"${bold(spec)}"`
if (overridden) {
dep = `${colorType('overridden', color)} ${dep} (was "${rawSpec}")`
dep = `${colorType('overridden', chalk)} ${dep} (was "${rawSpec}")`
}

const fromMsg = ` from ${explainFrom(from, depth, color)}`
const fromMsg = ` from ${explainFrom(from, depth, chalk)}`

return (type === 'prod' ? '' : `${colorType(type, color)} `) +
(bundled ? `${colorType('bundled', color)} ` : '') +
return (type === 'prod' ? '' : `${colorType(type, chalk)} `) +
(bundled ? `${colorType('bundled', chalk)} ` : '') +
`${dep}${fromMsg}`
}

const explainFrom = (from, depth, color) => {
const explainFrom = (from, depth, chalk) => {
if (!from.name && !from.version) {
return 'the root project'
}

return printNode(from, color) +
explainDependents(from, depth - 1, color) +
explainLinksIn(from, depth - 1, color)
return printNode(from, chalk) +
explainDependents(from, depth - 1, chalk) +
explainLinksIn(from, depth - 1, chalk)
}

module.exports = { explainNode, printNode, explainEdge }
22 changes: 11 additions & 11 deletions deps/npm/lib/utils/explain-eresolve.js
Original file line number Diff line number Diff line change
@@ -7,44 +7,44 @@ const { explainEdge, explainNode, printNode } = require('./explain-dep.js')
// Depth is how far we want to want to descend into the object making a report.
// The full report (ie, depth=Infinity) is always written to the cache folder
// at ${cache}/eresolve-report.txt along with full json.
const explain = (expl, color, depth) => {
const explain = (expl, chalk, depth) => {
const { edge, dep, current, peerConflict, currentEdge } = expl

const out = []
const whileInstalling = dep && dep.whileInstalling ||
current && current.whileInstalling ||
edge && edge.from && edge.from.whileInstalling
if (whileInstalling) {
out.push('While resolving: ' + printNode(whileInstalling, color))
out.push('While resolving: ' + printNode(whileInstalling, chalk))
}

// it "should" be impossible for an ERESOLVE explanation to lack both
// current and currentEdge, but better to have a less helpful error
// than a crashing failure.
if (current) {
out.push('Found: ' + explainNode(current, depth, color))
out.push('Found: ' + explainNode(current, depth, chalk))
} else if (peerConflict && peerConflict.current) {
out.push('Found: ' + explainNode(peerConflict.current, depth, color))
out.push('Found: ' + explainNode(peerConflict.current, depth, chalk))
} else if (currentEdge) {
out.push('Found: ' + explainEdge(currentEdge, depth, color))
out.push('Found: ' + explainEdge(currentEdge, depth, chalk))
} else /* istanbul ignore else - should always have one */ if (edge) {
out.push('Found: ' + explainEdge(edge, depth, color))
out.push('Found: ' + explainEdge(edge, depth, chalk))
}

out.push('\nCould not resolve dependency:\n' +
explainEdge(edge, depth, color))
explainEdge(edge, depth, chalk))

if (peerConflict) {
const heading = '\nConflicting peer dependency:'
const pc = explainNode(peerConflict.peer, depth, color)
const pc = explainNode(peerConflict.peer, depth, chalk)
out.push(heading + ' ' + pc)
}

return out.join('\n')
}

// generate a full verbose report and tell the user how to fix it
const report = (expl, color) => {
const report = (expl, chalk, noColor) => {
const flags = [
expl.strictPeerDeps ? '--no-strict-peer-deps' : '',
'--force',
@@ -60,8 +60,8 @@ this command with ${or(flags)}
to accept an incorrect (and potentially broken) dependency resolution.`

return {
explanation: `${explain(expl, color, 4)}\n\n${fix}`,
file: `# npm resolution error report\n\n${explain(expl, false, Infinity)}\n\n${fix}`,
explanation: `${explain(expl, chalk, 4)}\n\n${fix}`,
file: `# npm resolution error report\n\n${explain(expl, noColor, Infinity)}\n\n${fix}`,
}
}

9 changes: 6 additions & 3 deletions deps/npm/lib/utils/log-file.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const os = require('os')
const { join, dirname, basename } = require('path')
const { format, promisify } = require('util')
const glob = promisify(require('glob'))
const { format } = require('util')
const glob = require('glob')
const MiniPass = require('minipass')
const fsMiniPass = require('fs-minipass')
const fs = require('fs/promises')
@@ -223,7 +223,10 @@ class LogFiles {
}
}
} catch (e) {
log.warn('logfile', 'error cleaning log files', e)
// Disable cleanup failure warnings when log writing is disabled
if (this.#logsMax > 0) {
log.warn('logfile', 'error cleaning log files', e)
}
} finally {
log.silly('logfile', 'done cleaning log files')
}
19 changes: 7 additions & 12 deletions deps/npm/lib/utils/update-notifier.js
Original file line number Diff line number Diff line change
@@ -5,10 +5,7 @@
const pacote = require('pacote')
const ciInfo = require('ci-info')
const semver = require('semver')
const chalk = require('chalk')
const { promisify } = require('util')
const stat = promisify(require('fs').stat)
const writeFile = promisify(require('fs').writeFile)
const { stat, writeFile } = require('fs/promises')
const { resolve } = require('path')

const SKIP = Symbol('SKIP')
@@ -61,10 +58,6 @@ const updateNotifier = async (npm, spec = 'latest') => {
return null
}

// if they're currently using a prerelease, nudge to the next prerelease
// otherwise, nudge to latest.
const useColor = npm.logColor

const mani = await pacote.manifest(`npm@${spec}`, {
// always prefer latest, even if doing --tag=whatever on the cmd
defaultTag: 'latest',
@@ -91,6 +84,9 @@ const updateNotifier = async (npm, spec = 'latest') => {
return null
}

const useColor = npm.logColor
const chalk = npm.logChalk

// ok! notify the user about this update they should get.
// The message is saved for printing at process exit so it will not get
// lost in any other messages being printed as part of the command.
@@ -99,12 +95,11 @@ const updateNotifier = async (npm, spec = 'latest') => {
: update.minor !== current.minor ? 'minor'
: update.patch !== current.patch ? 'patch'
: 'prerelease'
const typec = !useColor ? type
: type === 'major' ? chalk.red(type)
const typec = type === 'major' ? chalk.red(type)
: type === 'minor' ? chalk.yellow(type)
: chalk.green(type)
const oldc = !useColor ? current : chalk.red(current)
const latestc = !useColor ? latest : chalk.green(latest)
const oldc = chalk.red(current)
const latestc = chalk.green(latest)
const changelog = `https://github.com/npm/cli/releases/tag/v${latest}`
const changelogc = !useColor ? `<${changelog}>` : chalk.cyan(changelog)
const cmd = `npm install -g npm@${latest}`
2 changes: 1 addition & 1 deletion deps/npm/man/man1/npm-ls.1
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ Positional arguments are \fBname@version-range\fR identifiers, which will limit
.P
.RS 2
.nf
npm@9.6.2 /path/to/npm
npm@9.6.3 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
.fi
2 changes: 0 additions & 2 deletions deps/npm/man/man1/npm-prefix.1
Original file line number Diff line number Diff line change
@@ -55,8 +55,6 @@ man pages are linked to \fB{prefix}/share/man\fR
.IP \(bu 4
npm help root
.IP \(bu 4
npm help bin
.IP \(bu 4
npm help folders
.IP \(bu 4
npm help config
2 changes: 0 additions & 2 deletions deps/npm/man/man1/npm-root.1
Original file line number Diff line number Diff line change
@@ -48,8 +48,6 @@ man pages are linked to \fB{prefix}/share/man\fR
.IP \(bu 4
npm help prefix
.IP \(bu 4
npm help bin
.IP \(bu 4
npm help folders
.IP \(bu 4
npm help config
2 changes: 1 addition & 1 deletion deps/npm/man/man1/npm.1
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ npm
Note: This command is unaware of workspaces.
.SS "Version"
.P
9.6.2
9.6.3
.SS "Description"
.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 conflicts intelligently.
18 changes: 1 addition & 17 deletions deps/npm/man/man5/install.5
Original file line number Diff line number Diff line change
@@ -26,23 +26,7 @@ npm -v
.RE
.SS "Using a Node version manager to install Node.js and npm"
.P
Node version managers allow you to install and switch between multiple versions of Node.js and npm on your system so you can test your applications on multiple versions of npm to ensure they work for users on different versions.
.SS "OSX or Linux Node version managers"
.RS 0
.IP \(bu 4
\fBnvm\fR \fI\(lahttps://github.com/creationix/nvm\(ra\fR
.IP \(bu 4
\fBn\fR \fI\(lahttps://github.com/tj/n\(ra\fR
.RE 0

.SS "Windows Node version managers"
.RS 0
.IP \(bu 4
\fBnodist\fR \fI\(lahttps://github.com/marcelklehr/nodist\(ra\fR
.IP \(bu 4
\fBnvm-windows\fR \fI\(lahttps://github.com/coreybutler/nvm-windows\(ra\fR
.RE 0

Node version managers allow you to install and switch between multiple versions of Node.js and npm on your system so you can test your applications on multiple versions of npm to ensure they work for users on different versions. You can \fBsearch for them on GitHub\fR \fI\(lahttps://github.com/search?q=node%20version%20manager&type=repositories\(ra\fR.
.SS "Using a Node installer to install Node.js and npm"
.P
If you are unable to use a Node version manager, you can use a Node installer to install both Node.js and npm on your system.
136 changes: 0 additions & 136 deletions deps/npm/node_modules/@colors/colors/index.d.ts

This file was deleted.

48 changes: 0 additions & 48 deletions deps/npm/node_modules/@colors/colors/safe.d.ts

This file was deleted.

8 changes: 4 additions & 4 deletions deps/npm/node_modules/@npmcli/arborist/package.json
6 changes: 3 additions & 3 deletions deps/npm/node_modules/@npmcli/config/package.json
35 changes: 18 additions & 17 deletions deps/npm/node_modules/@npmcli/git/lib/clone.js
8 changes: 3 additions & 5 deletions deps/npm/node_modules/@npmcli/git/package.json
6 changes: 3 additions & 3 deletions deps/npm/node_modules/@npmcli/map-workspaces/lib/index.js
10 changes: 5 additions & 5 deletions deps/npm/node_modules/@npmcli/map-workspaces/package.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions deps/npm/node_modules/@tootallnate/once/dist/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion deps/npm/node_modules/@tootallnate/once/dist/index.js.map

This file was deleted.

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions deps/npm/node_modules/@tootallnate/once/dist/types.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion deps/npm/node_modules/@tootallnate/once/dist/types.js.map

This file was deleted.

37 changes: 0 additions & 37 deletions deps/npm/node_modules/@tufjs/models/dist/base.d.ts

This file was deleted.

32 changes: 0 additions & 32 deletions deps/npm/node_modules/@tufjs/models/dist/delegations.d.ts

This file was deleted.

12 changes: 0 additions & 12 deletions deps/npm/node_modules/@tufjs/models/dist/error.d.ts

This file was deleted.

40 changes: 0 additions & 40 deletions deps/npm/node_modules/@tufjs/models/dist/file.d.ts

This file was deleted.

10 changes: 0 additions & 10 deletions deps/npm/node_modules/@tufjs/models/dist/index.d.ts

This file was deleted.

21 changes: 0 additions & 21 deletions deps/npm/node_modules/@tufjs/models/dist/key.d.ts

This file was deleted.

48 changes: 0 additions & 48 deletions deps/npm/node_modules/@tufjs/models/dist/metadata.d.ts

This file was deleted.

Loading

0 comments on commit 4b09222

Please sign in to comment.