Skip to content

Commit c8876d7

Browse files
npm-cli-botrichardlau
authored andcommitted
deps: upgrade npm to 10.3.0
PR-URL: #51431 Reviewed-By: Luke Karrys <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Marco Ippolito <[email protected]>
1 parent 8fdea67 commit c8876d7

File tree

290 files changed

+1856
-17295
lines changed

Some content is hidden

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

290 files changed

+1856
-17295
lines changed

deps/npm/docs/README.md

-5
This file was deleted.

deps/npm/docs/content/commands/npm-install-test.md

+10
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,16 @@ field of package.json, which comes from `process.platform`.
290290

291291

292292

293+
#### `libc`
294+
295+
* Default: null
296+
* Type: null or String
297+
298+
Override libc of native modules to install. Acceptable values are same as
299+
`libc` field of package.json
300+
301+
302+
293303
#### `workspace`
294304

295305
* Default:

deps/npm/docs/content/commands/npm-install.md

+10
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,16 @@ field of package.json, which comes from `process.platform`.
680680
681681
682682
683+
#### `libc`
684+
685+
* Default: null
686+
* Type: null or String
687+
688+
Override libc of native modules to install. Acceptable values are same as
689+
`libc` field of package.json
690+
691+
692+
683693
#### `workspace`
684694
685695
* Default:

deps/npm/docs/content/commands/npm-ls.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ packages will *also* show the paths to the specified packages. For
2727
example, running `npm ls promzard` in npm's source tree will show:
2828

2929
```bash
30-
npm@10.2.4 /path/to/npm
30+
npm@10.3.0 /path/to/npm
3131
3232
3333
```

deps/npm/docs/content/commands/npm-publish.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ scope-configured registry (see
2222

2323

2424
A `package` is interpreted the same way as other commands (like
25-
`npm install` and can be:
25+
`npm install`) and can be:
2626

2727
* a) a folder containing a program described by a
2828
[`package.json`](/configuring-npm/package-json) file

deps/npm/docs/content/commands/npm-sbom.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ SBOM format to use when generating SBOMs.
266266
* Type: "library", "application", or "framework"
267267

268268
The type of package described by the generated SBOM. For SPDX, this is the
269-
value for the `primaryPackagePurpose` fieled. For CycloneDX, this is the
269+
value for the `primaryPackagePurpose` field. For CycloneDX, this is the
270270
value for the `type` field.
271271

272272

deps/npm/docs/content/commands/npm-unpublish.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ removing the tarball.
2727
The npm registry will return an error if you are not [logged
2828
in](/commands/npm-adduser).
2929

30-
If you do not specify a version or if you remove all of a package's
31-
versions then the registry will remove the root package entry entirely.
30+
If you do not specify a package name at all, the name and version to be
31+
unpublished will be pulled from the project in the current directory.
32+
33+
If you specify a package name but do not specify a version or if you
34+
remove all of a package's versions then the registry will remove the
35+
root package entry entirely.
3236

3337
Even if you unpublish a package version, that specific name and version
3438
combination can never be reused. In order to publish the package again,

deps/npm/docs/content/commands/npm.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Note: This command is unaware of workspaces.
1414

1515
### Version
1616

17-
10.2.4
17+
10.3.0
1818

1919
### Description
2020

deps/npm/docs/content/commands/npx.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ This resulted in some shifts in its functionality:
150150
always present in the executed process `PATH`.
151151
- The `--npm` option is removed. `npx` will always use the `npm` it ships
152152
with.
153-
- The `--node-arg` and `-n` options are removed.
153+
- The `--node-arg` and `-n` options have been removed. Use [`NODE_OPTIONS`](https://nodejs.org/api/cli.html#node_optionsoptions) instead: e.g.,
154+
`NODE_OPTIONS="--trace-warnings --trace-exit" npx foo --random=true`
154155
- The `--always-spawn` option is redundant, and thus removed.
155156
- The `--shell` option is replaced with `--script-shell`, but maintained
156157
in the `npx` executable for backwards compatibility.

deps/npm/docs/content/configuring-npm/npmrc.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ For a list of available configuration options, see
1919

2020
The four relevant files are:
2121

22-
* per-project config file (/path/to/my/project/.npmrc)
23-
* per-user config file (~/.npmrc)
24-
* global config file ($PREFIX/etc/npmrc)
25-
* npm builtin config file (/path/to/npm/npmrc)
22+
* per-project config file (`/path/to/my/project/.npmrc`)
23+
* per-user config file (`~/.npmrc`)
24+
* global config file (`$PREFIX/etc/npmrc`)
25+
* npm builtin config file (`/path/to/npm/npmrc`)
2626

2727
All npm config files are an ini-formatted list of `key = value` parameters.
2828
Environment variables can be replaced using `${VARIABLE_NAME}`. For

deps/npm/docs/content/configuring-npm/package-json.md

+25-11
Original file line numberDiff line numberDiff line change
@@ -291,25 +291,39 @@ Certain files are always included, regardless of settings:
291291

292292
`README` & `LICENSE` can have any case and extension.
293293

294-
Conversely, some files are always ignored:
294+
Some files are always ignored by default:
295295

296+
* `*.orig`
297+
* `.*.swp`
298+
* `.DS_Store`
299+
* `._*`
296300
* `.git`
297-
* `CVS`
298-
* `.svn`
299301
* `.hg`
300302
* `.lock-wscript`
303+
* `.npmrc`
304+
* `.svn`
301305
* `.wafpickle-N`
302-
* `.*.swp`
303-
* `.DS_Store`
304-
* `._*`
306+
* `CVS`
307+
* `config.gypi`
308+
* `node_modules`
305309
* `npm-debug.log`
310+
* `package-lock.json` (use
311+
[`npm-shrinkwrap.json`](/configuring-npm/npm-shrinkwrap-json)
312+
if you wish it to be published)
313+
* `pnpm-lock.yaml`
314+
* `yarn.lock`
315+
316+
Most of these ignored files can be included specifically if included in
317+
the `files` globs. Exceptions to this are:
318+
319+
* `.git`
306320
* `.npmrc`
307321
* `node_modules`
308-
* `config.gypi`
309-
* `*.orig`
310-
* `package-lock.json` (use
311-
[`npm-shrinkwrap.json`](/configuring-npm/npm-shrinkwrap-json) if you wish
312-
it to be published)
322+
* `package-lock.json`
323+
* `pnpm-lock.yaml`
324+
* `yarn.lock`
325+
326+
These can not be included.
313327

314328
### main
315329

deps/npm/docs/content/using-npm/config.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,16 @@ Use of `legacy-peer-deps` is not recommended, as it will not enforce the
855855

856856

857857

858+
#### `libc`
859+
860+
* Default: null
861+
* Type: null or String
862+
863+
Override libc of native modules to install. Acceptable values are same as
864+
`libc` field of package.json
865+
866+
867+
858868
#### `link`
859869

860870
* Default: false
@@ -1373,7 +1383,7 @@ SBOM format to use when generating SBOMs.
13731383
* Type: "library", "application", or "framework"
13741384

13751385
The type of package described by the generated SBOM. For SPDX, this is the
1376-
value for the `primaryPackagePurpose` fieled. For CycloneDX, this is the
1386+
value for the `primaryPackagePurpose` field. For CycloneDX, this is the
13771387
value for the `type` field.
13781388

13791389

deps/npm/docs/lib/index.js

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
const localeCompare = require('@isaacs/string-locale-compare')('en')
2+
const { join, basename, resolve } = require('path')
3+
const transformHTML = require('./transform-html.js')
4+
const { version } = require('../../lib/npm.js')
5+
const { aliases } = require('../../lib/utils/cmd-list')
6+
const { shorthands, definitions } = require('@npmcli/config/lib/definitions')
7+
8+
const DOC_EXT = '.md'
9+
10+
const TAGS = {
11+
CONFIG: '<!-- AUTOGENERATED CONFIG DESCRIPTIONS -->',
12+
USAGE: '<!-- AUTOGENERATED USAGE DESCRIPTIONS -->',
13+
SHORTHANDS: '<!-- AUTOGENERATED CONFIG SHORTHANDS -->',
14+
}
15+
16+
const assertPlaceholder = (src, path, placeholder) => {
17+
if (!src.includes(placeholder)) {
18+
throw new Error(
19+
`Cannot replace ${placeholder} in ${path} due to missing placeholder`
20+
)
21+
}
22+
return placeholder
23+
}
24+
25+
const getCommandByDoc = (docFile, docExt) => {
26+
// Grab the command name from the *.md filename
27+
// NOTE: We cannot use the name property command file because in the case of
28+
// `npx` the file being used is `lib/commands/exec.js`
29+
const name = basename(docFile, docExt).replace('npm-', '')
30+
31+
if (name === 'npm') {
32+
return {
33+
name,
34+
params: null,
35+
usage: 'npm',
36+
}
37+
}
38+
39+
// special case for `npx`:
40+
// `npx` is not technically a command in and of itself,
41+
// so it just needs the usage of npm exex
42+
const srcName = name === 'npx' ? 'exec' : name
43+
const { params, usage = [''], workspaces } = require(`../../lib/commands/${srcName}`)
44+
const usagePrefix = name === 'npx' ? 'npx' : `npm ${name}`
45+
if (params) {
46+
for (const param of params) {
47+
if (definitions[param].exclusive) {
48+
for (const e of definitions[param].exclusive) {
49+
if (!params.includes(e)) {
50+
params.splice(params.indexOf(param) + 1, 0, e)
51+
}
52+
}
53+
}
54+
}
55+
}
56+
57+
return {
58+
name,
59+
workspaces,
60+
params: name === 'npx' ? null : params,
61+
usage: usage.map(u => `${usagePrefix} ${u}`.trim()).join('\n'),
62+
}
63+
}
64+
65+
const replaceVersion = (src) => src.replace(/@VERSION@/g, version)
66+
67+
const replaceUsage = (src, { path }) => {
68+
const replacer = assertPlaceholder(src, path, TAGS.USAGE)
69+
const { usage, name, workspaces } = getCommandByDoc(path, DOC_EXT)
70+
71+
const synopsis = ['```bash', usage]
72+
73+
const cmdAliases = Object.keys(aliases).reduce((p, c) => {
74+
if (aliases[c] === name) {
75+
p.push(c)
76+
}
77+
return p
78+
}, [])
79+
80+
if (cmdAliases.length === 1) {
81+
synopsis.push('', `alias: ${cmdAliases[0]}`)
82+
} else if (cmdAliases.length > 1) {
83+
synopsis.push('', `aliases: ${cmdAliases.join(', ')}`)
84+
}
85+
86+
synopsis.push('```')
87+
88+
if (!workspaces) {
89+
synopsis.push('', 'Note: This command is unaware of workspaces.')
90+
}
91+
92+
return src.replace(replacer, synopsis.join('\n'))
93+
}
94+
95+
const replaceParams = (src, { path }) => {
96+
const { params } = getCommandByDoc(path, DOC_EXT)
97+
const replacer = params && assertPlaceholder(src, path, TAGS.CONFIG)
98+
99+
if (!params) {
100+
return src
101+
}
102+
103+
const paramsConfig = params.map((n) => definitions[n].describe())
104+
105+
return src.replace(replacer, paramsConfig.join('\n\n'))
106+
}
107+
108+
const replaceConfig = (src, { path }) => {
109+
const replacer = assertPlaceholder(src, path, TAGS.CONFIG)
110+
111+
// sort not-deprecated ones to the top
112+
/* istanbul ignore next - typically already sorted in the definitions file,
113+
* but this is here so that our help doc will stay consistent if we decide
114+
* to move them around. */
115+
const sort = ([keya, { deprecated: depa }], [keyb, { deprecated: depb }]) => {
116+
return depa && !depb ? 1
117+
: !depa && depb ? -1
118+
: localeCompare(keya, keyb)
119+
}
120+
121+
const allConfig = Object.entries(definitions).sort(sort)
122+
.map(([_, def]) => def.describe())
123+
.join('\n\n')
124+
125+
return src.replace(replacer, allConfig)
126+
}
127+
128+
const replaceShorthands = (src, { path }) => {
129+
const replacer = assertPlaceholder(src, path, TAGS.SHORTHANDS)
130+
131+
const sh = Object.entries(shorthands)
132+
.sort(([shorta, expansiona], [shortb, expansionb]) =>
133+
// sort by what they're short FOR
134+
localeCompare(expansiona.join(' '), expansionb.join(' ')) || localeCompare(shorta, shortb)
135+
)
136+
.map(([short, expansion]) => {
137+
// XXX: this is incorrect. we have multicharacter flags like `-iwr` that
138+
// can only be set with a single dash
139+
const dash = short.length === 1 ? '-' : '--'
140+
return `* \`${dash}${short}\`: \`${expansion.join(' ')}\``
141+
})
142+
143+
return src.replace(replacer, sh.join('\n'))
144+
}
145+
146+
const replaceHelpLinks = (src) => {
147+
// replaces markdown links with equivalent-ish npm help commands
148+
return src.replace(
149+
/\[`?([\w\s-]+)`?\]\(\/(?:commands|configuring-npm|using-npm)\/(?:[\w\s-]+)\)/g,
150+
(_, p1) => {
151+
const term = p1.replace(/npm\s/g, '').replace(/\s+/g, ' ').trim()
152+
const help = `npm help ${term.includes(' ') ? `"${term}"` : term}`
153+
return help
154+
}
155+
)
156+
}
157+
158+
const transformMan = (src, { data, unified, remarkParse, remarkMan }) => unified()
159+
.use(remarkParse)
160+
.use(remarkMan)
161+
.processSync(`# ${data.title}(${data.section}) - ${data.description}\n\n${src}`)
162+
.toString()
163+
164+
const manPath = (name, { data }) => join(`man${data.section}`, `${name}.${data.section}`)
165+
166+
const transformMd = (src, { frontmatter }) => ['---', frontmatter, '---', '', src].join('\n')
167+
168+
module.exports = {
169+
DOC_EXT,
170+
TAGS,
171+
paths: {
172+
content: resolve(__dirname, 'content'),
173+
nav: resolve(__dirname, 'content', 'nav.yml'),
174+
template: resolve(__dirname, 'template.html'),
175+
man: resolve(__dirname, '..', '..', 'man'),
176+
html: resolve(__dirname, '..', 'output'),
177+
md: resolve(__dirname, '..', 'content'),
178+
},
179+
usage: replaceUsage,
180+
params: replaceParams,
181+
config: replaceConfig,
182+
shorthands: replaceShorthands,
183+
version: replaceVersion,
184+
helpLinks: replaceHelpLinks,
185+
man: transformMan,
186+
manPath: manPath,
187+
md: transformMd,
188+
html: transformHTML,
189+
}

0 commit comments

Comments
 (0)