From 014bf01efc11f7ac9ad41d2cfc28ee964bfc922f Mon Sep 17 00:00:00 2001
From: Aviv Keller <38299977+RedYetiDev@users.noreply.github.com>
Date: Thu, 11 Apr 2024 17:46:46 -0400
Subject: [PATCH 01/98] lib: replace string prototype usage with alternatives
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
PR-URL: https://github.com/nodejs/node/pull/52440
Reviewed-By: Matteo Collina
Reviewed-By: Moshe Atlow
Reviewed-By: Vinícius Lourenço Claro Cardoso
Reviewed-By: Benjamin Gruenbaum
Reviewed-By: Rafael Gonzaga
Reviewed-By: Antoine du Hamel
---
lib/internal/options.js | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/internal/options.js b/lib/internal/options.js
index effe3249888efd..5cecdc00e5ce95 100644
--- a/lib/internal/options.js
+++ b/lib/internal/options.js
@@ -5,6 +5,10 @@ const {
getEmbedderOptions: getEmbedderOptionsFromBinding,
} = internalBinding('options');
+const {
+ StringPrototypeSlice,
+} = primordials;
+
let warnOnAllowUnauthorized = true;
let optionsMap;
@@ -43,8 +47,15 @@ function refreshOptions() {
function getOptionValue(optionName) {
const options = getCLIOptionsFromBinding();
- if (optionName.startsWith('--no-')) {
- const option = options.get('--' + optionName.slice(5));
+ if (
+ optionName.length > 5 &&
+ optionName[0] === '-' &&
+ optionName[1] === '-' &&
+ optionName[2] === 'n' &&
+ optionName[3] === 'o' &&
+ optionName[4] === '-'
+ ) {
+ const option = options.get('--' + StringPrototypeSlice(optionName, 5));
return option && !option.value;
}
return options.get(optionName)?.value;
From 61e1ac0b8c9a48a5bfea4f937e3e80274a3f42b7 Mon Sep 17 00:00:00 2001
From: Shelley Vohr
Date: Fri, 12 Apr 2024 01:29:55 +0200
Subject: [PATCH 02/98] crypto: enable NODE_EXTRA_CA_CERTS with BoringSSL
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
PR-URL: https://github.com/nodejs/node/pull/52217
Reviewed-By: Tobias Nießen
Reviewed-By: Richard Lau
Reviewed-By: Anna Henningsen
Reviewed-By: Yagiz Nizipli
Reviewed-By: Luigi Pinca
---
src/node.cc | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/node.cc b/src/node.cc
index 64ade90dfa7e86..5d730985bfea4a 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -1084,7 +1084,8 @@ InitializeOncePerProcessInternal(const std::vector& args,
}
if (!(flags & ProcessInitializationFlags::kNoInitOpenSSL)) {
-#if HAVE_OPENSSL && !defined(OPENSSL_IS_BORINGSSL)
+#if HAVE_OPENSSL
+#ifndef OPENSSL_IS_BORINGSSL
auto GetOpenSSLErrorString = []() -> std::string {
std::string ret;
ERR_print_errors_cb(
@@ -1184,13 +1185,13 @@ InitializeOncePerProcessInternal(const std::vector& args,
CHECK(crypto::CSPRNG(buffer, length).is_ok());
return true;
});
-
+#endif // !defined(OPENSSL_IS_BORINGSSL)
{
std::string extra_ca_certs;
if (credentials::SafeGetenv("NODE_EXTRA_CA_CERTS", &extra_ca_certs))
crypto::UseExtraCaCerts(extra_ca_certs);
}
-#endif // HAVE_OPENSSL && !defined(OPENSSL_IS_BORINGSSL)
+#endif // HAVE_OPENSSL
}
if (!(flags & ProcessInitializationFlags::kNoInitializeNodeV8Platform)) {
From 8738b89971d5591160ac8785aa15cd266ac723ce Mon Sep 17 00:00:00 2001
From: npm CLI robot
Date: Thu, 11 Apr 2024 18:24:57 -0700
Subject: [PATCH 03/98] deps: upgrade npm to 10.5.2
PR-URL: https://github.com/nodejs/node/pull/52458
Reviewed-By: Luigi Pinca
Reviewed-By: Marco Ippolito
Reviewed-By: Mohammed Keyvanzadeh
---
deps/npm/docs/content/commands/npm-audit.md | 2 +-
deps/npm/docs/content/commands/npm-ls.md | 2 +-
deps/npm/docs/content/commands/npm.md | 2 +-
deps/npm/docs/output/commands/npm-audit.html | 2 +-
deps/npm/docs/output/commands/npm-ls.html | 2 +-
deps/npm/docs/output/commands/npm.html | 2 +-
deps/npm/lib/base-command.js | 2 +-
deps/npm/lib/commands/owner.js | 3 +-
deps/npm/lib/commands/ping.js | 4 +-
deps/npm/lib/commands/publish.js | 7 +-
deps/npm/lib/commands/unpublish.js | 7 +-
deps/npm/lib/utils/error-message.js | 2 +-
deps/npm/lib/utils/log-file.js | 42 +-
deps/npm/lib/utils/update-notifier.js | 12 +-
deps/npm/man/man1/npm-audit.1 | 2 +-
deps/npm/man/man1/npm-ls.1 | 2 +-
deps/npm/man/man1/npm.1 | 2 +-
.../node_modules/@npmcli/agent/lib/agents.js | 5 +-
.../node_modules/@npmcli/agent/package.json | 4 +-
.../arborist/lib/arborist/build-ideal-tree.js | 4 +-
.../@npmcli/arborist/lib/place-dep.js | 4 +-
.../@npmcli/arborist/package.json | 3 +-
.../config/lib/definitions/definitions.js | 4321 ++++++++---------
.../node_modules/@npmcli/config/lib/index.js | 49 +-
.../@npmcli/config/lib/nerf-dart.js | 2 +-
.../@npmcli/config/lib/parse-field.js | 2 +-
.../@npmcli/config/lib/type-defs.js | 10 +-
.../node_modules/@npmcli/config/lib/umask.js | 3 +-
.../node_modules/@npmcli/config/package.json | 2 +-
deps/npm/node_modules/@npmcli/git/lib/is.js | 4 +-
.../npm/node_modules/@npmcli/git/package.json | 2 +-
.../@npmcli/map-workspaces/lib/index.js | 143 +-
.../@npmcli/map-workspaces/package.json | 8 +-
.../@npmcli/package-json/lib/normalize.js | 53 +-
.../@npmcli/package-json/package.json | 18 +-
.../@sigstore/bundle/dist/build.js | 28 +-
.../@sigstore/bundle/dist/bundle.js | 5 +-
.../@sigstore/bundle/dist/index.js | 3 +-
.../@sigstore/bundle/dist/validate.js | 3 +-
.../@sigstore/bundle/package.json | 4 +-
.../@sigstore/core/dist/crypto.js | 4 +-
.../node_modules/@sigstore/core/package.json | 2 +-
.../dist/__generated__/sigstore_trustroot.js | 54 +-
.../@sigstore/protobuf-specs/package.json | 6 +-
.../@sigstore/sign/dist/bundler/bundle.js | 3 +-
.../@sigstore/sign/dist/bundler/dsse.js | 3 +-
.../node_modules/@sigstore/sign/package.json | 8 +-
.../@sigstore/verify/dist/tlog/intoto.js | 3 +-
.../@sigstore/verify/dist/trust/index.js | 11 +-
.../@sigstore/verify/package.json | 8 +-
deps/npm/node_modules/builtins/index.js | 6 +-
deps/npm/node_modules/builtins/package.json | 9 +-
deps/npm/node_modules/cidr-regex/package.json | 15 +-
deps/npm/node_modules/hasown/package.json | 7 +-
deps/npm/node_modules/hasown/tsconfig.json | 49 +-
deps/npm/node_modules/is-cidr/LICENSE | 22 -
deps/npm/node_modules/is-cidr/package.json | 17 +-
deps/npm/node_modules/libnpmdiff/package.json | 2 +-
deps/npm/node_modules/libnpmexec/package.json | 2 +-
deps/npm/node_modules/libnpmfund/package.json | 2 +-
deps/npm/node_modules/libnpmpack/package.json | 2 +-
.../postcss-selector-parser/package.json | 5 +-
deps/npm/node_modules/sigstore/package.json | 12 +-
.../node_modules/socks-proxy-agent/LICENSE | 22 +
.../socks-proxy-agent/dist/index.js | 4 +
.../socks-proxy-agent/package.json | 4 +-
.../socks/build/common/helpers.js | 6 +-
deps/npm/node_modules/socks/package.json | 7 +-
.../spdx-expression-parse/AUTHORS | 4 +
.../spdx-expression-parse/LICENSE | 22 +
.../spdx-expression-parse/index.js | 8 +
.../spdx-expression-parse/package.json | 39 +
.../spdx-expression-parse/parse.js | 138 +
.../spdx-expression-parse/scan.js | 131 +
.../spdx-expression-parse/package.json | 2 +-
.../spdx-expression-parse/scan.js | 4 +-
.../spdx-expression-parse/AUTHORS | 4 +
.../spdx-expression-parse/LICENSE | 22 +
.../spdx-expression-parse/index.js | 8 +
.../spdx-expression-parse/package.json | 39 +
.../spdx-expression-parse/parse.js | 138 +
.../spdx-expression-parse/scan.js | 131 +
deps/npm/package.json | 12 +-
.../test/lib/commands/config.js.test.cjs | 10 +-
.../test/lib/commands/publish.js.test.cjs | 4 +
.../tap-snapshots/test/lib/docs.js.test.cjs | 20 +-
deps/npm/test/lib/commands/publish.js | 52 +
deps/npm/test/lib/commands/unpublish.js | 30 +
deps/npm/test/lib/utils/log-file.js | 52 +-
89 files changed, 3333 insertions(+), 2609 deletions(-)
delete mode 100644 deps/npm/node_modules/is-cidr/LICENSE
create mode 100644 deps/npm/node_modules/socks-proxy-agent/LICENSE
create mode 100644 deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/AUTHORS
create mode 100644 deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/LICENSE
create mode 100644 deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/index.js
create mode 100644 deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/package.json
create mode 100644 deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/parse.js
create mode 100644 deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/scan.js
create mode 100644 deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/AUTHORS
create mode 100644 deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/LICENSE
create mode 100644 deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/index.js
create mode 100644 deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/package.json
create mode 100644 deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/parse.js
create mode 100644 deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/scan.js
diff --git a/deps/npm/docs/content/commands/npm-audit.md b/deps/npm/docs/content/commands/npm-audit.md
index 7ab0c182d2db96..a7e0db7474315a 100644
--- a/deps/npm/docs/content/commands/npm-audit.md
+++ b/deps/npm/docs/content/commands/npm-audit.md
@@ -90,7 +90,7 @@ The `sig` is generated using the following template: `${package.name}@${package.
Keys response:
-- `expires`: null or a simplified extended [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601"): `YYYY-MM-DDTHH:mm:ss.sssZ`
+- `expires`: null or a simplified extended [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDTHH:mm:ss.sssZ`
- `keydid`: sha256 fingerprint of the public key
- `keytype`: only `ecdsa-sha2-nistp256` is currently supported by the npm CLI
- `scheme`: only `ecdsa-sha2-nistp256` is currently supported by the npm CLI
diff --git a/deps/npm/docs/content/commands/npm-ls.md b/deps/npm/docs/content/commands/npm-ls.md
index 0c6bfe1bf8ac26..9c761e13fa34f0 100644
--- a/deps/npm/docs/content/commands/npm-ls.md
+++ b/deps/npm/docs/content/commands/npm-ls.md
@@ -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
-npm@10.5.1 /path/to/npm
+npm@10.5.2 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
```
diff --git a/deps/npm/docs/content/commands/npm.md b/deps/npm/docs/content/commands/npm.md
index d69d753e245b27..0e44e3e35e73f6 100644
--- a/deps/npm/docs/content/commands/npm.md
+++ b/deps/npm/docs/content/commands/npm.md
@@ -14,7 +14,7 @@ Note: This command is unaware of workspaces.
### Version
-10.5.1
+10.5.2
### Description
diff --git a/deps/npm/docs/output/commands/npm-audit.html b/deps/npm/docs/output/commands/npm-audit.html
index ab20ea72c65208..5e8e9d66bb2e59 100644
--- a/deps/npm/docs/output/commands/npm-audit.html
+++ b/deps/npm/docs/output/commands/npm-audit.html
@@ -209,7 +209,7 @@ Audit Signatures
Keys response:
-expires
: null or a simplified extended ISO 8601 format: YYYY-MM-DDTHH:mm:ss.sssZ
+expires
: null or a simplified extended ISO 8601 format: YYYY-MM-DDTHH:mm:ss.sssZ
keydid
: sha256 fingerprint of the public key
keytype
: only ecdsa-sha2-nistp256
is currently supported by the npm CLI
scheme
: only ecdsa-sha2-nistp256
is currently supported by the npm CLI
diff --git a/deps/npm/docs/output/commands/npm-ls.html b/deps/npm/docs/output/commands/npm-ls.html
index 0f4beb45d09397..7449728edf37fe 100644
--- a/deps/npm/docs/output/commands/npm-ls.html
+++ b/deps/npm/docs/output/commands/npm-ls.html
@@ -160,7 +160,7 @@ Description
the results to only the paths to the packages named. Note that nested
packages will also show the paths to the specified packages. For
example, running npm ls promzard
in npm's source tree will show:
-npm@10.5.1 /path/to/npm
+npm@10.5.2 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
diff --git a/deps/npm/docs/output/commands/npm.html b/deps/npm/docs/output/commands/npm.html
index 4be373a7159e9f..d79ded11c70ba2 100644
--- a/deps/npm/docs/output/commands/npm.html
+++ b/deps/npm/docs/output/commands/npm.html
@@ -150,7 +150,7 @@ Table of contents
Note: This command is unaware of workspaces.
Version
-10.5.1
+10.5.2
Description
npm is the package manager for the Node JavaScript platform. It puts
modules in place so that node can find them, and manages dependency
diff --git a/deps/npm/lib/base-command.js b/deps/npm/lib/base-command.js
index e4a7bbbec724a6..cdf7971b5aaf92 100644
--- a/deps/npm/lib/base-command.js
+++ b/deps/npm/lib/base-command.js
@@ -3,7 +3,6 @@
const { relative } = require('path')
const { definitions } = require('@npmcli/config/lib/definitions')
-const getWorkspaces = require('./workspaces/get-workspaces.js')
const { aliases: cmdAliases } = require('./utils/cmd-list')
const log = require('./utils/log-shim.js')
@@ -170,6 +169,7 @@ class BaseCommand {
const relativeFrom = prefixInsideCwd ? this.npm.localPrefix : process.cwd()
const filters = this.npm.config.get('workspace')
+ const getWorkspaces = require('./workspaces/get-workspaces.js')
const ws = await getWorkspaces(filters, {
path: this.npm.localPrefix,
includeWorkspaceRoot,
diff --git a/deps/npm/lib/commands/owner.js b/deps/npm/lib/commands/owner.js
index 5b54dd41f3d607..e530e1c51c8e1f 100644
--- a/deps/npm/lib/commands/owner.js
+++ b/deps/npm/lib/commands/owner.js
@@ -5,6 +5,7 @@ const log = require('../utils/log-shim')
const otplease = require('../utils/otplease.js')
const pkgJson = require('@npmcli/package-json')
const BaseCommand = require('../base-command.js')
+const { redact } = require('@npmcli/redact')
const readJson = async (path) => {
try {
@@ -119,7 +120,7 @@ class Owner extends BaseCommand {
this.npm.output(maintainers.map(m => `${m.name} <${m.email}>`).join('\n'))
}
} catch (err) {
- log.error('owner ls', "Couldn't get owner data", npmFetch.cleanUrl(pkg))
+ log.error('owner ls', "Couldn't get owner data", redact(pkg))
throw err
}
}
diff --git a/deps/npm/lib/commands/ping.js b/deps/npm/lib/commands/ping.js
index c79e6a96cee405..2d60f5d69a8da6 100644
--- a/deps/npm/lib/commands/ping.js
+++ b/deps/npm/lib/commands/ping.js
@@ -1,4 +1,4 @@
-const { cleanUrl } = require('npm-registry-fetch')
+const { redact } = require('@npmcli/redact')
const log = require('../utils/log-shim')
const pingUtil = require('../utils/ping.js')
const BaseCommand = require('../base-command.js')
@@ -9,7 +9,7 @@ class Ping extends BaseCommand {
static name = 'ping'
async exec (args) {
- const cleanRegistry = cleanUrl(this.npm.config.get('registry'))
+ const cleanRegistry = redact(this.npm.config.get('registry'))
log.notice('PING', cleanRegistry)
const start = Date.now()
const details = await pingUtil({ ...this.npm.flatOptions })
diff --git a/deps/npm/lib/commands/publish.js b/deps/npm/lib/commands/publish.js
index 0456fd7e8320e6..cf6b50cce3c21c 100644
--- a/deps/npm/lib/commands/publish.js
+++ b/deps/npm/lib/commands/publish.js
@@ -220,7 +220,12 @@ class Publish extends BaseCommand {
})
}
if (manifest.publishConfig) {
- flatten(manifest.publishConfig, opts)
+ const cliFlags = this.npm.config.data.get('cli').raw
+ // Filter out properties set in CLI flags to prioritize them over
+ // corresponding `publishConfig` settings
+ const filteredPublishConfig = Object.fromEntries(
+ Object.entries(manifest.publishConfig).filter(([key]) => !(key in cliFlags)))
+ flatten(filteredPublishConfig, opts)
}
return manifest
}
diff --git a/deps/npm/lib/commands/unpublish.js b/deps/npm/lib/commands/unpublish.js
index a9c20900534c3a..a4d445a035b622 100644
--- a/deps/npm/lib/commands/unpublish.js
+++ b/deps/npm/lib/commands/unpublish.js
@@ -141,7 +141,12 @@ class Unpublish extends BaseCommand {
// If localPrefix has a package.json with a name that matches the package
// being unpublished, load up the publishConfig
if (manifest?.name === spec.name && manifest.publishConfig) {
- flatten(manifest.publishConfig, opts)
+ const cliFlags = this.npm.config.data.get('cli').raw
+ // Filter out properties set in CLI flags to prioritize them over
+ // corresponding `publishConfig` settings
+ const filteredPublishConfig = Object.fromEntries(
+ Object.entries(manifest.publishConfig).filter(([key]) => !(key in cliFlags)))
+ flatten(filteredPublishConfig, opts)
}
const versions = await Unpublish.getKeysOfVersions(spec.name, opts)
diff --git a/deps/npm/lib/utils/error-message.js b/deps/npm/lib/utils/error-message.js
index fc7be8301662e1..348bb63e2d5abd 100644
--- a/deps/npm/lib/utils/error-message.js
+++ b/deps/npm/lib/utils/error-message.js
@@ -1,6 +1,5 @@
const { format } = require('util')
const { resolve } = require('path')
-const nameValidator = require('validate-npm-package-name')
const { redactLog: replaceInfo } = require('@npmcli/redact')
const { report } = require('./explain-eresolve.js')
const log = require('./log-shim')
@@ -215,6 +214,7 @@ const errorMessage = (er, npm) => {
detail.push(['404', ''])
detail.push(['404', '', `'${replaceInfo(er.pkgid)}' is not in this registry.`])
+ const nameValidator = require('validate-npm-package-name')
const valResult = nameValidator(pkg)
if (!valResult.validForNewPackages) {
diff --git a/deps/npm/lib/utils/log-file.js b/deps/npm/lib/utils/log-file.js
index 8c06f5647e761e..1a46b7da0d6604 100644
--- a/deps/npm/lib/utils/log-file.js
+++ b/deps/npm/lib/utils/log-file.js
@@ -1,7 +1,6 @@
const os = require('os')
const { join, dirname, basename } = require('path')
const { format } = require('util')
-const { glob } = require('glob')
const { Minipass } = require('minipass')
const fsMiniPass = require('fs-minipass')
const fs = require('fs/promises')
@@ -9,7 +8,6 @@ const log = require('./log-shim')
const Display = require('./display')
const padZero = (n, length) => n.toString().padStart(length.toString().length, '0')
-const globify = pattern => pattern.split('\\').join('/')
class LogFiles {
// Default to a plain minipass stream so we can buffer
@@ -199,17 +197,41 @@ class LogFiles {
try {
const logPath = this.#getLogFilePath()
- const logGlob = join(dirname(logPath), basename(logPath)
+ const patternFileName = basename(logPath)
// tell glob to only match digits
- .replace(/\d/g, '[0123456789]')
+ .replace(/\d/g, 'd')
// Handle the old (prior to 8.2.0) log file names which did not have a
// counter suffix
- .replace(/-\.log$/, '*.log')
- )
+ .replace('-.log', '')
+
+ let files = await fs.readdir(
+ dirname(logPath), {
+ withFileTypes: true,
+ encoding: 'utf-8',
+ })
+ files = files.sort((a, b) => basename(a.name).localeCompare(basename(b.name), 'en'))
+
+ const logFiles = []
+
+ for (const file of files) {
+ if (!file.isFile()) {
+ continue
+ }
+
+ const genericFileName = file.name.replace(/\d/g, 'd')
+ const filePath = join(dirname(logPath), basename(file.name))
+
+ // Always ignore the currently written files
+ if (
+ genericFileName.includes(patternFileName)
+ && genericFileName.endsWith('.log')
+ && !this.#files.includes(filePath)
+ ) {
+ logFiles.push(filePath)
+ }
+ }
- // Always ignore the currently written files
- const files = await glob(globify(logGlob), { ignore: this.#files.map(globify), silent: true })
- const toDelete = files.length - this.#logsMax
+ const toDelete = logFiles.length - this.#logsMax
if (toDelete <= 0) {
return
@@ -217,7 +239,7 @@ class LogFiles {
log.silly('logfile', `start cleaning logs, removing ${toDelete} files`)
- for (const file of files.slice(0, toDelete)) {
+ for (const file of logFiles.slice(0, toDelete)) {
try {
await fs.rm(file, { force: true })
} catch (e) {
diff --git a/deps/npm/lib/utils/update-notifier.js b/deps/npm/lib/utils/update-notifier.js
index 7c9611e4773f97..7481b65d562217 100644
--- a/deps/npm/lib/utils/update-notifier.js
+++ b/deps/npm/lib/utils/update-notifier.js
@@ -3,7 +3,9 @@
// Check daily for betas, and weekly otherwise.
const ciInfo = require('ci-info')
-const semver = require('semver')
+const gt = require('semver/functions/gt')
+const gte = require('semver/functions/gte')
+const parse = require('semver/functions/parse')
const { stat, writeFile } = require('fs/promises')
const { resolve } = require('path')
@@ -38,12 +40,12 @@ const updateCheck = async (npm, spec, version, current) => {
// and should get the updates from that release train.
// Note that this isn't another http request over the network, because
// the packument will be cached by pacote from previous request.
- if (semver.gt(version, latest) && spec === 'latest') {
+ if (gt(version, latest) && spec === 'latest') {
return updateNotifier(npm, `^${version}`)
}
// if we already have something >= the desired spec, then we're done
- if (semver.gte(version, latest)) {
+ if (gte(version, latest)) {
return null
}
@@ -53,7 +55,7 @@ const updateCheck = async (npm, spec, version, current) => {
// 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.
- const update = semver.parse(mani.version)
+ const update = parse(mani.version)
const type = update.major !== current.major ? 'major'
: update.minor !== current.minor ? 'minor'
: update.patch !== current.patch ? 'patch'
@@ -79,7 +81,7 @@ const updateNotifier = async (npm, spec = 'latest') => {
// if we're on a prerelease train, then updates are coming fast
// check for a new one daily. otherwise, weekly.
const { version } = npm
- const current = semver.parse(version)
+ const current = parse(version)
// if we're on a beta train, always get the next beta
if (current.prerelease.length) {
diff --git a/deps/npm/man/man1/npm-audit.1 b/deps/npm/man/man1/npm-audit.1
index e8d71147400c45..5832cb09ff9980 100644
--- a/deps/npm/man/man1/npm-audit.1
+++ b/deps/npm/man/man1/npm-audit.1
@@ -80,7 +80,7 @@ Public signing keys are provided at \fBregistry-host.tld/-/npm/v1/keys\fR in the
Keys response:
.RS 0
.IP \(bu 4
-\fBexpires\fR: null or a simplified extended \fBISO 8601 format\fR \fI\(lahttps://en.wikipedia.org/wiki/ISO_8601"\(ra\fR: \fBYYYY-MM-DDTHH:mm:ss.sssZ\fR
+\fBexpires\fR: null or a simplified extended \fBISO 8601 format\fR \fI\(lahttps://en.wikipedia.org/wiki/ISO_8601\(ra\fR: \fBYYYY-MM-DDTHH:mm:ss.sssZ\fR
.IP \(bu 4
\fBkeydid\fR: sha256 fingerprint of the public key
.IP \(bu 4
diff --git a/deps/npm/man/man1/npm-ls.1 b/deps/npm/man/man1/npm-ls.1
index a9f7e4af68b87b..9c8a25d0c9237a 100644
--- a/deps/npm/man/man1/npm-ls.1
+++ b/deps/npm/man/man1/npm-ls.1
@@ -20,7 +20,7 @@ Positional arguments are \fBname@version-range\fR identifiers, which will limit
.P
.RS 2
.nf
-npm@10.5.1 /path/to/npm
+npm@10.5.2 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
.fi
diff --git a/deps/npm/man/man1/npm.1 b/deps/npm/man/man1/npm.1
index 6ac1a88baf121d..0df8bb7e2a1962 100644
--- a/deps/npm/man/man1/npm.1
+++ b/deps/npm/man/man1/npm.1
@@ -12,7 +12,7 @@ npm
Note: This command is unaware of workspaces.
.SS "Version"
.P
-10.5.1
+10.5.2
.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.
diff --git a/deps/npm/node_modules/@npmcli/agent/lib/agents.js b/deps/npm/node_modules/@npmcli/agent/lib/agents.js
index ffd299f3d2ba69..c541b93001517e 100644
--- a/deps/npm/node_modules/@npmcli/agent/lib/agents.js
+++ b/deps/npm/node_modules/@npmcli/agent/lib/agents.js
@@ -65,7 +65,10 @@ module.exports = class Agent extends AgentBase {
ProxyAgent = this.isSecureEndpoint(options) ? ProxyAgent[1] : ProxyAgent[0]
}
- const proxyAgent = new ProxyAgent(proxy, this.#options)
+ const proxyAgent = new ProxyAgent(proxy, {
+ ...this.#options,
+ socketOptions: { family: this.#options.family },
+ })
proxyCache.set(cacheKey, proxyAgent)
return proxyAgent
diff --git a/deps/npm/node_modules/@npmcli/agent/package.json b/deps/npm/node_modules/@npmcli/agent/package.json
index ce240b283a42c9..ef5b4e3228cc46 100644
--- a/deps/npm/node_modules/@npmcli/agent/package.json
+++ b/deps/npm/node_modules/@npmcli/agent/package.json
@@ -1,6 +1,6 @@
{
"name": "@npmcli/agent",
- "version": "2.2.1",
+ "version": "2.2.2",
"description": "the http/https agent used by the npm cli",
"main": "lib/index.js",
"scripts": {
@@ -36,7 +36,7 @@
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.1",
"lru-cache": "^10.0.1",
- "socks-proxy-agent": "^8.0.1"
+ "socks-proxy-agent": "^8.0.3"
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
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 8ceb6b72123f68..75e4d373259a09 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
@@ -12,7 +12,7 @@ const { readdirScoped } = require('@npmcli/fs')
const { lstat, readlink } = require('fs/promises')
const { depth } = require('treeverse')
const log = require('proc-log')
-const { cleanUrl } = require('npm-registry-fetch')
+const { redact } = require('@npmcli/redact')
const {
OK,
@@ -1213,7 +1213,7 @@ This is a one-time fix-up, please be patient...
if (this.#manifests.has(spec.raw)) {
return this.#manifests.get(spec.raw)
} else {
- const cleanRawSpec = cleanUrl(spec.rawSpec)
+ const cleanRawSpec = redact(spec.rawSpec)
log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, cleanRawSpec))
const o = {
...options,
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/place-dep.js b/deps/npm/node_modules/@npmcli/arborist/lib/place-dep.js
index e757d0c38a6d70..bf0fef6525343a 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/place-dep.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/place-dep.js
@@ -9,7 +9,7 @@
const localeCompare = require('@isaacs/string-locale-compare')('en')
const log = require('proc-log')
-const { cleanUrl } = require('npm-registry-fetch')
+const { redact } = require('@npmcli/redact')
const deepestNestingTarget = require('./deepest-nesting-target.js')
const CanPlaceDep = require('./can-place-dep.js')
const {
@@ -188,7 +188,7 @@ class PlaceDep {
`${this.dep.name}@${this.dep.version}`,
this.canPlace.description,
`for: ${this.edge.from.package._id || this.edge.from.location}`,
- `want: ${cleanUrl(this.edge.spec || '*')}`
+ `want: ${redact(this.edge.spec || '*')}`
)
const placementType = this.canPlace.canPlace === CONFLICT
diff --git a/deps/npm/node_modules/@npmcli/arborist/package.json b/deps/npm/node_modules/@npmcli/arborist/package.json
index d7c393d99dfa57..3a92e669d4bb68 100644
--- a/deps/npm/node_modules/@npmcli/arborist/package.json
+++ b/deps/npm/node_modules/@npmcli/arborist/package.json
@@ -1,6 +1,6 @@
{
"name": "@npmcli/arborist",
- "version": "7.4.1",
+ "version": "7.4.2",
"description": "Manage node_modules trees",
"dependencies": {
"@isaacs/string-locale-compare": "^1.1.0",
@@ -12,6 +12,7 @@
"@npmcli/node-gyp": "^3.0.0",
"@npmcli/package-json": "^5.0.0",
"@npmcli/query": "^3.1.0",
+ "@npmcli/redact": "^1.1.0",
"@npmcli/run-script": "^7.0.2",
"bin-links": "^4.0.1",
"cacache": "^18.0.0",
diff --git a/deps/npm/node_modules/@npmcli/config/lib/definitions/definitions.js b/deps/npm/node_modules/@npmcli/config/lib/definitions/definitions.js
index 09b0eceeea6b21..3565cdb4feb44b 100644
--- a/deps/npm/node_modules/@npmcli/config/lib/definitions/definitions.js
+++ b/deps/npm/node_modules/@npmcli/config/lib/definitions/definitions.js
@@ -1,11 +1,8 @@
-const definitions = {}
-module.exports = definitions
-
const Definition = require('./definition.js')
const ciInfo = require('ci-info')
-const querystring = require('querystring')
-const { join } = require('path')
+const querystring = require('node:querystring')
+const { join } = require('node:path')
const isWindows = process.platform === 'win32'
@@ -91,20 +88,12 @@ const cache = `${cacheRoot}/${cacheExtra}`
// weird to pull out of the config module.
// TODO: use better type definition/validation API, nopt's is so weird.
const {
- semver: { type: semver },
+ semver: { type: Semver },
Umask: { type: Umask },
url: { type: url },
path: { type: path },
} = require('../type-defs.js')
-const define = (key, def) => {
- /* istanbul ignore if - this should never happen, prevents mistakes below */
- if (definitions[key]) {
- throw new Error(`defining key more than once: ${key}`)
- }
- definitions[key] = new Definition(key, def)
-}
-
// basic flattening function, just copy it over camelCase
const flatten = (key, obj, flatOptions) => {
const camel = key.replace(/-([a-z])/g, (_0, _1) => _1.toUpperCase())
@@ -135,12 +124,20 @@ const flatten = (key, obj, flatOptions) => {
// while fixing some Arborist bug, we won't have to hunt through too
// many places.
-// Define all config keys we know about
+// XXX: We should really deprecate all these `--save-blah` switches
+// in favor of a single `--save-type` option. The unfortunate shortcut
+// we took for `--save-peer --save-optional` being `--save-type=peerOptional`
+// makes this tricky, and likely a breaking change.
+
+// Define all config keys we know about. They are indexed by their own key for
+// ease of lookup later. This duplication is an optimization so that we don't
+// have to do an extra function call just to "reuse" the key in both places.
-define('_auth', {
- default: null,
- type: [null, String],
- description: `
+const definitions = {
+ _auth: new Definition('_auth', {
+ default: null,
+ type: [null, String],
+ description: `
A basic-auth string to use when authenticating against the npm registry.
This will ONLY be used to authenticate against the npm registry. For other
registries you will need to scope it like "//other-registry.tld/:_auth"
@@ -149,16 +146,15 @@ define('_auth', {
is safer to use a registry-provided authentication bearer token stored in
the ~/.npmrc file by running \`npm login\`.
`,
- flatten,
-})
-
-define('access', {
- default: null,
- defaultDescription: `
+ flatten,
+ }),
+ access: new Definition('access', {
+ default: null,
+ defaultDescription: `
'public' for new packages, existing packages it will not change the current level
`,
- type: [null, 'restricted', 'public'],
- description: `
+ type: [null, 'restricted', 'public'],
+ description: `
If you do not want your scoped package to be publicly viewable (and
installable) set \`--access=restricted\`.
@@ -169,131 +165,121 @@ define('access', {
publish will change the access for an existing package the same way that
\`npm access set status\` would.
`,
- flatten,
-})
-
-define('all', {
- default: false,
- type: Boolean,
- short: 'a',
- description: `
+ flatten,
+ }),
+ all: new Definition('all', {
+ default: false,
+ type: Boolean,
+ short: 'a',
+ description: `
When running \`npm outdated\` and \`npm ls\`, setting \`--all\` will show
all outdated or installed packages, rather than only those directly
depended upon by the current project.
`,
- flatten,
-})
-
-define('allow-same-version', {
- default: false,
- type: Boolean,
- description: `
+ flatten,
+ }),
+ 'allow-same-version': new Definition('allow-same-version', {
+ default: false,
+ type: Boolean,
+ description: `
Prevents throwing an error when \`npm version\` is used to set the new
version to the same value as the current version.
`,
- flatten,
-})
-
-define('also', {
- default: null,
- type: [null, 'dev', 'development'],
- description: `
- When set to \`dev\` or \`development\`, this is an alias for
- \`--include=dev\`.
- `,
- deprecated: 'Please use --include=dev instead.',
- flatten (key, obj, flatOptions) {
- definitions.omit.flatten('omit', obj, flatOptions)
- },
-})
-
-define('audit', {
- default: true,
- type: Boolean,
- description: `
- When "true" submit audit reports alongside the current npm command to the
- default registry and all registries configured for scopes. See the
- documentation for [\`npm audit\`](/commands/npm-audit) for details on what
- is submitted.
- `,
- flatten,
-})
-
-define('audit-level', {
- default: null,
- type: [null, 'info', 'low', 'moderate', 'high', 'critical', 'none'],
- description: `
+ flatten,
+ }),
+ also: new Definition('also', {
+ default: null,
+ type: [null, 'dev', 'development'],
+ description: `
+ When set to \`dev\` or \`development\`, this is an alias for
+ \`--include=dev\`.
+ `,
+ deprecated: 'Please use --include=dev instead.',
+ flatten (key, obj, flatOptions) {
+ definitions.omit.flatten('omit', obj, flatOptions)
+ },
+ }),
+ audit: new Definition('audit', {
+ default: true,
+ type: Boolean,
+ description: `
+ When "true" submit audit reports alongside the current npm command to the
+ default registry and all registries configured for scopes. See the
+ documentation for [\`npm audit\`](/commands/npm-audit) for details on what
+ is submitted.
+ `,
+ flatten,
+ }),
+ 'audit-level': new Definition('audit-level', {
+ default: null,
+ type: [null, 'info', 'low', 'moderate', 'high', 'critical', 'none'],
+ description: `
The minimum level of vulnerability for \`npm audit\` to exit with
a non-zero exit code.
- `,
- flatten,
-})
-
-define('auth-type', {
- default: 'web',
- type: ['legacy', 'web'],
- description: `
- What authentication strategy to use with \`login\`.
- Note that if an \`otp\` config is given, this value will always be set to \`legacy\`.
- `,
- flatten,
-})
-
-define('before', {
- default: null,
- type: [null, Date],
- description: `
- If passed to \`npm install\`, will rebuild the npm tree such that only
- versions that were available **on or before** the \`--before\` time get
- installed. If there's no versions available for the current set of
- direct dependencies, the command will error.
-
- If the requested version is a \`dist-tag\` and the given tag does not
- pass the \`--before\` filter, the most recent version less than or equal
- to that tag will be used. For example, \`foo@latest\` might install
- \`foo@1.2\` even though \`latest\` is \`2.0\`.
- `,
- flatten,
-})
-
-define('bin-links', {
- default: true,
- type: Boolean,
- description: `
- Tells npm to create symlinks (or \`.cmd\` shims on Windows) for package
- executables.
-
- Set to false to have it not do this. This can be used to work around the
- fact that some file systems don't support symlinks, even on ostensibly
- Unix systems.
- `,
- flatten,
-})
-
-define('browser', {
- default: null,
- defaultDescription: `
+ `,
+ flatten,
+ }),
+ 'auth-type': new Definition('auth-type', {
+ default: 'web',
+ type: ['legacy', 'web'],
+ description: `
+ What authentication strategy to use with \`login\`.
+ Note that if an \`otp\` config is given, this value will always be set to \`legacy\`.
+ `,
+ flatten,
+ }),
+ before: new Definition('before', {
+ default: null,
+ type: [null, Date],
+ description: `
+ If passed to \`npm install\`, will rebuild the npm tree such that only
+ versions that were available **on or before** the \`--before\` time get
+ installed. If there's no versions available for the current set of
+ direct dependencies, the command will error.
+
+ If the requested version is a \`dist-tag\` and the given tag does not
+ pass the \`--before\` filter, the most recent version less than or equal
+ to that tag will be used. For example, \`foo@latest\` might install
+ \`foo@1.2\` even though \`latest\` is \`2.0\`.
+ `,
+ flatten,
+ }),
+ 'bin-links': new Definition('bin-links', {
+ default: true,
+ type: Boolean,
+ description: `
+ Tells npm to create symlinks (or \`.cmd\` shims on Windows) for package
+ executables.
+
+ Set to false to have it not do this. This can be used to work around the
+ fact that some file systems don't support symlinks, even on ostensibly
+ Unix systems.
+ `,
+ flatten,
+ }),
+ browser: new Definition('browser', {
+ default: null,
+ defaultDescription: `
OS X: \`"open"\`, Windows: \`"start"\`, Others: \`"xdg-open"\`
- `,
- type: [null, Boolean, String],
- description: `
+ `,
+ type: [null, Boolean, String],
+ description: `
The browser that is called by npm commands to open websites.
Set to \`false\` to suppress browser behavior and instead print urls to
terminal.
Set to \`true\` to use default system URL opener.
- `,
- flatten,
-})
-
-define('ca', {
- default: null,
- type: [null, String, Array],
- description: `
+ `,
+ flatten,
+ }),
+ ca: new Definition('ca', {
+ default: null,
+ type: [null, String, Array],
+ description: `
The Certificate Authority signing certificate that is trusted for SSL
connections to the registry. Values should be in PEM format (Windows
- calls it "Base-64 encoded X.509 (.CER)") with newlines replaced by the
+ calls it "Base-64 encoded X.509 (.CER)") with newlines replaced by the
string "\\n". For example:
\`\`\`ini
@@ -312,2124 +298,1979 @@ define('ca', {
See also the \`strict-ssl\` config.
`,
- flatten,
-})
-
-define('cache', {
- default: cache,
- defaultDescription: `
- Windows: \`%LocalAppData%\\npm-cache\`, Posix: \`~/.npm\`
- `,
- type: path,
- description: `
- The location of npm's cache directory.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.cache = join(obj.cache, '_cacache')
- flatOptions.npxCache = join(obj.cache, '_npx')
- flatOptions.tufCache = join(obj.cache, '_tuf')
- },
-})
-
-define('cache-max', {
- default: Infinity,
- type: Number,
- description: `
- \`--cache-max=0\` is an alias for \`--prefer-online\`
- `,
- deprecated: `
- This option has been deprecated in favor of \`--prefer-online\`
- `,
- flatten (key, obj, flatOptions) {
- if (obj[key] <= 0) {
- flatOptions.preferOnline = true
- }
- },
-})
-
-define('cache-min', {
- default: 0,
- type: Number,
- description: `
- \`--cache-min=9999 (or bigger)\` is an alias for \`--prefer-offline\`.
- `,
- deprecated: `
- This option has been deprecated in favor of \`--prefer-offline\`.
- `,
- flatten (key, obj, flatOptions) {
- if (obj[key] >= 9999) {
- flatOptions.preferOffline = true
- }
- },
-})
-
-define('cafile', {
- default: null,
- type: path,
- description: `
- A path to a file containing one or multiple Certificate Authority signing
- certificates. Similar to the \`ca\` setting, but allows for multiple
- CA's, as well as for the CA information to be stored in a file on disk.
- `,
- flatten (key, obj, flatOptions) {
- // always set to null in defaults
- if (!obj.cafile) {
- return
- }
-
- const raw = maybeReadFile(obj.cafile)
- if (!raw) {
- return
- }
-
- const delim = '-----END CERTIFICATE-----'
- flatOptions.ca = raw.replace(/\r\n/g, '\n').split(delim)
- .filter(section => section.trim())
- .map(section => section.trimLeft() + delim)
- },
-})
-
-define('call', {
- default: '',
- type: String,
- short: 'c',
- description: `
- Optional companion option for \`npm exec\`, \`npx\` that allows for
- specifying a custom command to be run along with the installed packages.
-
- \`\`\`bash
- npm exec --package yo --package generator-node --call "yo node"
- \`\`\`
- `,
- flatten,
-})
-
-define('cert', {
- default: null,
- type: [null, String],
- description: `
- A client certificate to pass when accessing the registry. Values should
- be in PEM format (Windows calls it "Base-64 encoded X.509 (.CER)") with
- newlines replaced by the string "\\n". For example:
-
- \`\`\`ini
- cert="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----"
- \`\`\`
-
- It is _not_ the path to a certificate file, though you can set a registry-scoped
- "certfile" path like "//other-registry.tld/:certfile=/path/to/cert.pem".
- `,
- deprecated: `
- \`key\` and \`cert\` are no longer used for most registry operations.
- Use registry scoped \`keyfile\` and \`certfile\` instead.
- Example:
- //other-registry.tld/:keyfile=/path/to/key.pem
- //other-registry.tld/:certfile=/path/to/cert.crt
- `,
- flatten,
-})
-
-define('cidr', {
- default: null,
- type: [null, String, Array],
- description: `
- This is a list of CIDR address to be used when configuring limited access
- tokens with the \`npm token create\` command.
- `,
- flatten,
-})
-
-// This should never be directly used, the flattened value is the derived value
-// and is sent to other modules, and is also exposed as `npm.color` for use
-// inside npm itself.
-define('color', {
- default: !process.env.NO_COLOR || process.env.NO_COLOR === '0',
- usage: '--color|--no-color|--color always',
- defaultDescription: `
- true unless the NO_COLOR environ is set to something other than '0'
- `,
- type: ['always', Boolean],
- description: `
- If false, never shows colors. If \`"always"\` then always shows colors.
- If true, then only prints color codes for tty file descriptors.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.color = !obj.color ? false
- : obj.color === 'always' ? true
- : !!process.stdout.isTTY
- flatOptions.logColor = !obj.color ? false
- : obj.color === 'always' ? true
- : !!process.stderr.isTTY
- },
-})
-
-define('commit-hooks', {
- default: true,
- type: Boolean,
- description: `
- Run git commit hooks when using the \`npm version\` command.
- `,
- flatten,
-})
-
-define('cpu', {
- default: null,
- type: [null, String],
- description: `
- Override CPU architecture of native modules to install.
- Acceptable values are same as \`cpu\` field of package.json,
- which comes from \`process.arch\`.
- `,
- flatten,
-})
-
-define('os', {
- default: null,
- type: [null, String],
- description: `
- Override OS of native modules to install.
- Acceptable values are same as \`os\` field of package.json,
- which comes from \`process.platform\`.
- `,
- flatten,
-})
-
-define('libc', {
- default: null,
- type: [null, String],
- description: `
- Override libc of native modules to install.
- Acceptable values are same as \`libc\` field of package.json
- `,
- flatten,
-})
-
-define('depth', {
- default: null,
- defaultDescription: `
- \`Infinity\` if \`--all\` is set, otherwise \`1\`
- `,
- type: [null, Number],
- description: `
- The depth to go when recursing packages for \`npm ls\`.
-
- If not set, \`npm ls\` will show only the immediate dependencies of the
- root project. If \`--all\` is set, then npm will show all dependencies
- by default.
- `,
- flatten,
-})
-
-define('description', {
- default: true,
- type: Boolean,
- usage: '--no-description',
- description: `
- Show the description in \`npm search\`
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.search = flatOptions.search || { limit: 20 }
- flatOptions.search[key] = obj[key]
- },
-})
-
-define('dev', {
- default: false,
- type: Boolean,
- description: `
- Alias for \`--include=dev\`.
- `,
- deprecated: 'Please use --include=dev instead.',
- flatten (key, obj, flatOptions) {
- definitions.omit.flatten('omit', obj, flatOptions)
- },
-})
-
-define('diff', {
- default: [],
- hint: '',
- type: [String, Array],
- description: `
- Define arguments to compare in \`npm diff\`.
- `,
- flatten,
-})
-
-define('diff-ignore-all-space', {
- default: false,
- type: Boolean,
- description: `
- Ignore whitespace when comparing lines in \`npm diff\`.
- `,
- flatten,
-})
-
-define('diff-name-only', {
- default: false,
- type: Boolean,
- description: `
- Prints only filenames when using \`npm diff\`.
- `,
- flatten,
-})
-
-define('diff-no-prefix', {
- default: false,
- type: Boolean,
- description: `
- Do not show any source or destination prefix in \`npm diff\` output.
-
- Note: this causes \`npm diff\` to ignore the \`--diff-src-prefix\` and
- \`--diff-dst-prefix\` configs.
- `,
- flatten,
-})
-
-define('diff-dst-prefix', {
- default: 'b/',
- hint: '',
- type: String,
- description: `
- Destination prefix to be used in \`npm diff\` output.
- `,
- flatten,
-})
-
-define('diff-src-prefix', {
- default: 'a/',
- hint: '',
- type: String,
- description: `
- Source prefix to be used in \`npm diff\` output.
- `,
- flatten,
-})
-
-define('diff-text', {
- default: false,
- type: Boolean,
- description: `
- Treat all files as text in \`npm diff\`.
- `,
- flatten,
-})
-
-define('diff-unified', {
- default: 3,
- type: Number,
- description: `
- The number of lines of context to print in \`npm diff\`.
- `,
- flatten,
-})
-
-define('dry-run', {
- default: false,
- type: Boolean,
- description: `
- Indicates that you don't want npm to make any changes and that it should
- only report what it would have done. This can be passed into any of the
- commands that modify your local installation, eg, \`install\`,
- \`update\`, \`dedupe\`, \`uninstall\`, as well as \`pack\` and
- \`publish\`.
-
- Note: This is NOT honored by other network related commands, eg
- \`dist-tags\`, \`owner\`, etc.
- `,
- flatten,
-})
-
-define('editor', {
- default: editor,
- defaultDescription: `
- The EDITOR or VISUAL environment variables, or '%SYSTEMROOT%\\notepad.exe' on Windows,
- or 'vi' on Unix systems
- `,
- type: String,
- description: `
- The command to run for \`npm edit\` and \`npm config edit\`.
- `,
- flatten,
-})
-
-define('engine-strict', {
- default: false,
- type: Boolean,
- description: `
- If set to true, then npm will stubbornly refuse to install (or even
- consider installing) any package that claims to not be compatible with
- the current Node.js version.
-
- This can be overridden by setting the \`--force\` flag.
- `,
- flatten,
-})
-
-define('expect-results', {
- default: null,
- type: [null, Boolean],
- exclusive: ['expect-result-count'],
- description: `
- Tells npm whether or not to expect results from the command.
- Can be either true (expect some results) or false (expect no results).
- `,
-})
-
-define('expect-result-count', {
- default: null,
- type: [null, Number],
- hint: '',
- exclusive: ['expect-results'],
- description: `
- Tells to expect a specific number of results from the command.
- `,
-})
-
-define('fetch-retries', {
- default: 2,
- type: Number,
- description: `
- The "retries" config for the \`retry\` module to use when fetching
- packages from the registry.
-
- npm will retry idempotent read requests to the registry in the case
- of network failures or 5xx HTTP errors.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.retry = flatOptions.retry || {}
- flatOptions.retry.retries = obj[key]
- },
-})
-
-define('fetch-retry-factor', {
- default: 10,
- type: Number,
- description: `
- The "factor" config for the \`retry\` module to use when fetching
- packages.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.retry = flatOptions.retry || {}
- flatOptions.retry.factor = obj[key]
- },
-})
-
-define('fetch-retry-maxtimeout', {
- default: 60000,
- defaultDescription: '60000 (1 minute)',
- type: Number,
- description: `
- The "maxTimeout" config for the \`retry\` module to use when fetching
- packages.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.retry = flatOptions.retry || {}
- flatOptions.retry.maxTimeout = obj[key]
- },
-})
-
-define('fetch-retry-mintimeout', {
- default: 10000,
- defaultDescription: '10000 (10 seconds)',
- type: Number,
- description: `
- The "minTimeout" config for the \`retry\` module to use when fetching
- packages.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.retry = flatOptions.retry || {}
- flatOptions.retry.minTimeout = obj[key]
- },
-})
-
-define('fetch-timeout', {
- default: 5 * 60 * 1000,
- defaultDescription: `${5 * 60 * 1000} (5 minutes)`,
- type: Number,
- description: `
- The maximum amount of time to wait for HTTP requests to complete.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.timeout = obj[key]
- },
-})
-
-define('force', {
- default: false,
- type: Boolean,
- short: 'f',
- description: `
- Removes various protections against unfortunate side effects, common
- mistakes, unnecessary performance degradation, and malicious input.
-
- * Allow clobbering non-npm files in global installs.
- * Allow the \`npm version\` command to work on an unclean git repository.
- * Allow deleting the cache folder with \`npm cache clean\`.
- * Allow installing packages that have an \`engines\` declaration
- requiring a different version of npm.
- * Allow installing packages that have an \`engines\` declaration
- requiring a different version of \`node\`, even if \`--engine-strict\`
- is enabled.
- * Allow \`npm audit fix\` to install modules outside your stated
- dependency range (including SemVer-major changes).
- * Allow unpublishing all versions of a published package.
- * Allow conflicting peerDependencies to be installed in the root project.
- * Implicitly set \`--yes\` during \`npm init\`.
- * Allow clobbering existing values in \`npm pkg\`
- * Allow unpublishing of entire packages (not just a single version).
-
- If you don't have a clear idea of what you want to do, it is strongly
- recommended that you do not use this option!
- `,
- flatten,
-})
-
-define('foreground-scripts', {
- default: false,
- defaultDescription: `\`false\` unless when using \`npm pack\` or \`npm publish\` where it
- defaults to \`true\``,
- type: Boolean,
- description: `
- Run all build scripts (ie, \`preinstall\`, \`install\`, and
- \`postinstall\`) scripts for installed packages in the foreground
- process, sharing standard input, output, and error with the main npm
- process.
-
- Note that this will generally make installs run slower, and be much
- noisier, but can be useful for debugging.
- `,
- flatten,
-})
-
-define('format-package-lock', {
- default: true,
- type: Boolean,
- description: `
- Format \`package-lock.json\` or \`npm-shrinkwrap.json\` as a human
- readable file.
- `,
- flatten,
-})
-
-define('fund', {
- default: true,
- type: Boolean,
- description: `
- When "true" displays the message at the end of each \`npm install\`
- acknowledging the number of dependencies looking for funding.
- See [\`npm fund\`](/commands/npm-fund) for details.
- `,
- flatten,
-})
-
-define('git', {
- default: 'git',
- type: String,
- description: `
- The command to use for git commands. If git is installed on the
- computer, but is not in the \`PATH\`, then set this to the full path to
- the git binary.
- `,
- flatten,
-})
-
-define('git-tag-version', {
- default: true,
- type: Boolean,
- description: `
- Tag the commit when using the \`npm version\` command. Setting this to
- false results in no commit being made at all.
- `,
- flatten,
-})
-
-define('global', {
- default: false,
- type: Boolean,
- short: 'g',
- description: `
- Operates in "global" mode, so that packages are installed into the
- \`prefix\` folder instead of the current working directory. See
- [folders](/configuring-npm/folders) for more on the differences in
- behavior.
-
- * packages are installed into the \`{prefix}/lib/node_modules\` folder,
- instead of the current working directory.
- * bin files are linked to \`{prefix}/bin\`
- * man pages are linked to \`{prefix}/share/man\`
- `,
- flatten: (key, obj, flatOptions) => {
- flatten(key, obj, flatOptions)
- if (flatOptions.global) {
- flatOptions.location = 'global'
- }
- },
-})
-
-// the globalconfig has its default defined outside of this module
-define('globalconfig', {
- type: path,
- default: '',
- defaultDescription: `
- The global --prefix setting plus 'etc/npmrc'. For example,
- '/usr/local/etc/npmrc'
- `,
- description: `
- The config file to read for global config options.
- `,
- flatten,
-})
-
-define('global-style', {
- default: false,
- type: Boolean,
- description: `
- Only install direct dependencies in the top level \`node_modules\`,
- but hoist on deeper dependencies.
- Sets \`--install-strategy=shallow\`.
- `,
- deprecated: `
- This option has been deprecated in favor of \`--install-strategy=shallow\`
- `,
- flatten (key, obj, flatOptions) {
- if (obj[key]) {
- obj['install-strategy'] = 'shallow'
- flatOptions.installStrategy = 'shallow'
- }
- },
-})
-
-define('heading', {
- default: 'npm',
- type: String,
- description: `
- The string that starts all the debugging log output.
- `,
- flatten,
-})
-
-define('https-proxy', {
- default: null,
- type: [null, url],
- description: `
- A proxy to use for outgoing https requests. If the \`HTTPS_PROXY\` or
- \`https_proxy\` or \`HTTP_PROXY\` or \`http_proxy\` environment variables
- are set, proxy settings will be honored by the underlying
- \`make-fetch-happen\` library.
- `,
- flatten,
-})
-
-define('if-present', {
- default: false,
- type: Boolean,
- envExport: false,
- description: `
- If true, npm will not exit with an error code when \`run-script\` is
- invoked for a script that isn't defined in the \`scripts\` section of
- \`package.json\`. This option can be used when it's desirable to
- optionally run a script when it's present and fail if the script fails.
- This is useful, for example, when running scripts that may only apply for
- some builds in an otherwise generic CI setup.
- `,
- flatten,
-})
-
-define('ignore-scripts', {
- default: false,
- type: Boolean,
- description: `
- If true, npm does not run scripts specified in package.json files.
-
- Note that commands explicitly intended to run a particular script, such
- as \`npm start\`, \`npm stop\`, \`npm restart\`, \`npm test\`, and \`npm
- run-script\` will still run their intended script if \`ignore-scripts\` is
- set, but they will *not* run any pre- or post-scripts.
- `,
- flatten,
-})
-
-define('include', {
- default: [],
- type: [Array, 'prod', 'dev', 'optional', 'peer'],
- description: `
- Option that allows for defining which types of dependencies to install.
-
- This is the inverse of \`--omit=\`.
-
- Dependency types specified in \`--include\` will not be omitted,
- regardless of the order in which omit/include are specified on the
- command-line.
- `,
- flatten (key, obj, flatOptions) {
- // just call the omit flattener, it reads from obj.include
- definitions.omit.flatten('omit', obj, flatOptions)
- },
-})
-
-define('include-staged', {
- default: false,
- type: Boolean,
- description: `
- Allow installing "staged" published packages, as defined by [npm RFC PR
- #92](https://github.com/npm/rfcs/pull/92).
-
- This is experimental, and not implemented by the npm public registry.
- `,
- flatten,
-})
-
-define('include-workspace-root', {
- default: false,
- type: Boolean,
- envExport: false,
- description: `
- Include the workspace root when workspaces are enabled for a command.
-
- When false, specifying individual workspaces via the \`workspace\` config,
- or all workspaces via the \`workspaces\` flag, will cause npm to operate only
- on the specified workspaces, and not on the root project.
- `,
- flatten,
-})
-
-define('init-author-email', {
- default: '',
- hint: '',
- type: String,
- description: `
- The value \`npm init\` should use by default for the package author's
- email.
- `,
-})
-
-define('init-author-name', {
- default: '',
- hint: '',
- type: String,
- description: `
- The value \`npm init\` should use by default for the package author's name.
- `,
-})
-
-define('init-author-url', {
- default: '',
- type: ['', url],
- hint: '',
- description: `
- The value \`npm init\` should use by default for the package author's homepage.
- `,
-})
-
-define('init-license', {
- default: 'ISC',
- hint: '',
- type: String,
- description: `
- The value \`npm init\` should use by default for the package license.
- `,
-})
-
-define('init-module', {
- default: '~/.npm-init.js',
- type: path,
- hint: '',
- description: `
- A module that will be loaded by the \`npm init\` command. See the
- documentation for the
- [init-package-json](https://github.com/npm/init-package-json) module for
- more information, or [npm init](/commands/npm-init).
- `,
-})
-
-define('init-version', {
- default: '1.0.0',
- type: semver,
- hint: '',
- description: `
- The value that \`npm init\` should use by default for the package
- version number, if not already set in package.json.
- `,
-})
-
-// these "aliases" are historically supported in .npmrc files, unfortunately
-// They should be removed in a future npm version.
-define('init.author.email', {
- default: '',
- type: String,
- deprecated: `
- Use \`--init-author-email\` instead.`,
- description: `
- Alias for \`--init-author-email\`
- `,
-})
-
-define('init.author.name', {
- default: '',
- type: String,
- deprecated: `
- Use \`--init-author-name\` instead.
- `,
- description: `
- Alias for \`--init-author-name\`
- `,
-})
-
-define('init.author.url', {
- default: '',
- type: ['', url],
- deprecated: `
- Use \`--init-author-url\` instead.
- `,
- description: `
- Alias for \`--init-author-url\`
- `,
-})
-
-define('init.license', {
- default: 'ISC',
- type: String,
- deprecated: `
- Use \`--init-license\` instead.
- `,
- description: `
- Alias for \`--init-license\`
- `,
-})
-
-define('init.module', {
- default: '~/.npm-init.js',
- type: path,
- deprecated: `
- Use \`--init-module\` instead.
- `,
- description: `
- Alias for \`--init-module\`
- `,
-})
-
-define('init.version', {
- default: '1.0.0',
- type: semver,
- deprecated: `
- Use \`--init-version\` instead.
- `,
- description: `
- Alias for \`--init-version\`
- `,
-})
-
-define('install-links', {
- default: false,
- type: Boolean,
- description: `
- When set file: protocol dependencies will be packed and installed as
- regular dependencies instead of creating a symlink. This option has
- no effect on workspaces.
- `,
- flatten,
-})
-
-define('install-strategy', {
- default: 'hoisted',
- type: ['hoisted', 'nested', 'shallow', 'linked'],
- description: `
- Sets the strategy for installing packages in node_modules.
- hoisted (default): Install non-duplicated in top-level, and duplicated as
- necessary within directory structure.
- nested: (formerly --legacy-bundling) install in place, no hoisting.
- shallow (formerly --global-style) only install direct deps at top-level.
- linked: (experimental) install in node_modules/.store, link in place,
- unhoisted.
- `,
- flatten,
-})
-
-define('json', {
- default: false,
- type: Boolean,
- description: `
- Whether or not to output JSON data, rather than the normal output.
-
- * In \`npm pkg set\` it enables parsing set values with JSON.parse()
- before saving them to your \`package.json\`.
-
- Not supported by all npm commands.
- `,
- flatten,
-})
-
-define('key', {
- default: null,
- type: [null, String],
- description: `
- A client key to pass when accessing the registry. Values should be in
- PEM format with newlines replaced by the string "\\n". For example:
-
- \`\`\`ini
- key="-----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY-----"
- \`\`\`
-
- It is _not_ the path to a key file, though you can set a registry-scoped
- "keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem".
- `,
- deprecated: `
- \`key\` and \`cert\` are no longer used for most registry operations.
- Use registry scoped \`keyfile\` and \`certfile\` instead.
- Example:
- //other-registry.tld/:keyfile=/path/to/key.pem
- //other-registry.tld/:certfile=/path/to/cert.crt
- `,
- flatten,
-})
-
-define('legacy-bundling', {
- default: false,
- type: Boolean,
- description: `
- Instead of hoisting package installs in \`node_modules\`, install packages
- in the same manner that they are depended on. This may cause very deep
- directory structures and duplicate package installs as there is no
- de-duplicating.
- Sets \`--install-strategy=nested\`.
- `,
- deprecated: `
- This option has been deprecated in favor of \`--install-strategy=nested\`
- `,
- flatten (key, obj, flatOptions) {
- if (obj[key]) {
- obj['install-strategy'] = 'nested'
- flatOptions.installStrategy = 'nested'
- }
- },
-})
-
-define('legacy-peer-deps', {
- default: false,
- type: Boolean,
- description: `
- Causes npm to completely ignore \`peerDependencies\` when building a
- package tree, as in npm versions 3 through 6.
-
- If a package cannot be installed because of overly strict
- \`peerDependencies\` that collide, it provides a way to move forward
- resolving the situation.
-
- This differs from \`--omit=peer\`, in that \`--omit=peer\` will avoid
- unpacking \`peerDependencies\` on disk, but will still design a tree such
- that \`peerDependencies\` _could_ be unpacked in a correct place.
-
- Use of \`legacy-peer-deps\` is not recommended, as it will not enforce
- the \`peerDependencies\` contract that meta-dependencies may rely on.
- `,
- flatten,
-})
-
-define('link', {
- default: false,
- type: Boolean,
- description: `
- Used with \`npm ls\`, limiting output to only those packages that are
- linked.
- `,
-})
-
-define('local-address', {
- default: null,
- type: getLocalAddresses(),
- typeDescription: 'IP Address',
- description: `
- The IP address of the local interface to use when making connections to
- the npm registry. Must be IPv4 in versions of Node prior to 0.12.
- `,
- flatten,
-})
-
-define('sbom-format', {
- default: null,
- type: [
- 'cyclonedx',
- 'spdx',
- ],
- description: `
- SBOM format to use when generating SBOMs.
- `,
- flatten,
-})
-
-define('sbom-type', {
- default: 'library',
- type: [
- 'library',
- 'application',
- 'framework',
- ],
- description: `
- The type of package described by the generated SBOM. For SPDX, this is the
- value for the \`primaryPackagePurpose\` field. For CycloneDX, this is the
- value for the \`type\` field.
- `,
- flatten,
-})
-
-define('location', {
- default: 'user',
- short: 'L',
- type: [
- 'global',
- 'user',
- 'project',
- ],
- defaultDescription: `
- "user" unless \`--global\` is passed, which will also set this value to "global"
- `,
- description: `
- When passed to \`npm config\` this refers to which config file to use.
-
- When set to "global" mode, packages are installed into the \`prefix\` folder
- instead of the current working directory. See
- [folders](/configuring-npm/folders) for more on the differences in behavior.
-
- * packages are installed into the \`{prefix}/lib/node_modules\` folder,
- instead of the current working directory.
- * bin files are linked to \`{prefix}/bin\`
- * man pages are linked to \`{prefix}/share/man\`
- `,
- flatten: (key, obj, flatOptions) => {
- flatten(key, obj, flatOptions)
- if (flatOptions.global) {
- flatOptions.location = 'global'
- }
- if (obj.location === 'global') {
- flatOptions.global = true
- }
- },
-})
-
-define('lockfile-version', {
- default: null,
- type: [null, 1, 2, 3, '1', '2', '3'],
- defaultDescription: `
- Version 3 if no lockfile, auto-converting v1 lockfiles to v3, otherwise
- maintain current lockfile version.`,
- description: `
- Set the lockfile format version to be used in package-lock.json and
- npm-shrinkwrap-json files. Possible options are:
-
- 1: The lockfile version used by npm versions 5 and 6. Lacks some data that
- is used during the install, resulting in slower and possibly less
- deterministic installs. Prevents lockfile churn when interoperating with
- older npm versions.
-
- 2: The default lockfile version used by npm version 7 and 8. Includes both
- the version 1 lockfile data and version 3 lockfile data, for maximum
- determinism and interoperability, at the expense of more bytes on disk.
-
- 3: Only the new lockfile information introduced in npm version 7. Smaller
- on disk than lockfile version 2, but not interoperable with older npm
- versions. Ideal if all users are on npm version 7 and higher.
- `,
- flatten: (key, obj, flatOptions) => {
- flatOptions.lockfileVersion = obj[key] && parseInt(obj[key], 10)
- },
-})
-
-define('loglevel', {
- default: 'notice',
- type: [
- 'silent',
- 'error',
- 'warn',
- 'notice',
- 'http',
- 'info',
- 'verbose',
- 'silly',
- ],
- description: `
- What level of logs to report. All logs are written to a debug log,
- with the path to that file printed if the execution of a command fails.
-
- Any logs of a higher level than the setting are shown. The default is
- "notice".
-
- See also the \`foreground-scripts\` config.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.silent = obj[key] === 'silent'
- },
-})
-
-define('logs-dir', {
- default: null,
- type: [null, path],
- defaultDescription: `
- A directory named \`_logs\` inside the cache
-`,
- description: `
- The location of npm's log directory. See [\`npm
- logging\`](/using-npm/logging) for more information.
- `,
-})
-
-define('logs-max', {
- default: 10,
- type: Number,
- description: `
- The maximum number of log files to store.
-
- If set to 0, no log files will be written for the current run.
- `,
-})
-
-define('long', {
- default: false,
- type: Boolean,
- short: 'l',
- description: `
- Show extended information in \`ls\`, \`search\`, and \`help-search\`.
- `,
-})
-
-define('maxsockets', {
- default: 15,
- type: Number,
- description: `
- The maximum number of connections to use per origin (protocol/host/port
- combination).
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.maxSockets = obj[key]
- },
-})
-
-define('message', {
- default: '%s',
- type: String,
- short: 'm',
- description: `
- Commit message which is used by \`npm version\` when creating version commit.
-
- Any "%s" in the message will be replaced with the version number.
- `,
- flatten,
-})
-
-define('node-options', {
- default: null,
- type: [null, String],
- description: `
- Options to pass through to Node.js via the \`NODE_OPTIONS\` environment
- variable. This does not impact how npm itself is executed but it does
- impact how lifecycle scripts are called.
- `,
-})
-
-define('noproxy', {
- default: '',
- defaultDescription: `
- The value of the NO_PROXY environment variable
- `,
- type: [String, Array],
- description: `
- Domain extensions that should bypass any proxies.
-
- Also accepts a comma-delimited string.
- `,
- flatten (key, obj, flatOptions) {
- if (Array.isArray(obj[key])) {
- flatOptions.noProxy = obj[key].join(',')
- } else {
- flatOptions.noProxy = obj[key]
- }
- },
-})
-
-define('offline', {
- default: false,
- type: Boolean,
- description: `
- Force offline mode: no network requests will be done during install. To allow
- the CLI to fill in missing cache data, see \`--prefer-offline\`.
- `,
- flatten,
-})
-
-define('omit', {
- default: process.env.NODE_ENV === 'production' ? ['dev'] : [],
- defaultDescription: `
- 'dev' if the \`NODE_ENV\` environment variable is set to 'production',
- otherwise empty.
- `,
- type: [Array, 'dev', 'optional', 'peer'],
- description: `
- Dependency types to omit from the installation tree on disk.
-
- Note that these dependencies _are_ still resolved and added to the
- \`package-lock.json\` or \`npm-shrinkwrap.json\` file. They are just
- not physically installed on disk.
-
- If a package type appears in both the \`--include\` and \`--omit\`
- lists, then it will be included.
-
- If the resulting omit list includes \`'dev'\`, then the \`NODE_ENV\`
- environment variable will be set to \`'production'\` for all lifecycle
- scripts.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.omit = buildOmitList(obj)
- },
-})
-
-define('omit-lockfile-registry-resolved', {
- default: false,
- type: Boolean,
- description: `
- This option causes npm to create lock files without a \`resolved\` key for
- registry dependencies. Subsequent installs will need to resolve tarball
- endpoints with the configured registry, likely resulting in a longer install
- time.
- `,
- flatten,
-})
-
-define('only', {
- default: null,
- type: [null, 'prod', 'production'],
- deprecated: `
- Use \`--omit=dev\` to omit dev dependencies from the install.
- `,
- description: `
- When set to \`prod\` or \`production\`, this is an alias for
- \`--omit=dev\`.
- `,
- flatten (key, obj, flatOptions) {
- definitions.omit.flatten('omit', obj, flatOptions)
- },
-})
-
-define('optional', {
- default: null,
- type: [null, Boolean],
- deprecated: `
- Use \`--omit=optional\` to exclude optional dependencies, or
- \`--include=optional\` to include them.
-
- Default value does install optional deps unless otherwise omitted.
- `,
- description: `
- Alias for --include=optional or --omit=optional
- `,
- flatten (key, obj, flatOptions) {
- definitions.omit.flatten('omit', obj, flatOptions)
- },
-})
-
-define('otp', {
- default: null,
- type: [null, String],
- description: `
- This is a one-time password from a two-factor authenticator. It's needed
- when publishing or changing package permissions with \`npm access\`.
-
- If not set, and a registry response fails with a challenge for a one-time
- password, npm will prompt on the command line for one.
- `,
- flatten (key, obj, flatOptions) {
- flatten(key, obj, flatOptions)
- if (obj.otp) {
- obj['auth-type'] = 'legacy'
- flatten('auth-type', obj, flatOptions)
- }
- },
-})
-
-define('package', {
- default: [],
- hint: '',
- type: [String, Array],
- description: `
- The package or packages to install for [\`npm exec\`](/commands/npm-exec)
- `,
- flatten,
-})
-
-define('package-lock', {
- default: true,
- type: Boolean,
- description: `
- If set to false, then ignore \`package-lock.json\` files when installing.
- This will also prevent _writing_ \`package-lock.json\` if \`save\` is
- true.
- `,
- flatten: (key, obj, flatOptions) => {
- flatten(key, obj, flatOptions)
- if (flatOptions.packageLockOnly) {
- flatOptions.packageLock = true
- }
- },
-})
-
-define('package-lock-only', {
- default: false,
- type: Boolean,
- description: `
- If set to true, the current operation will only use the \`package-lock.json\`,
- ignoring \`node_modules\`.
-
- For \`update\` this means only the \`package-lock.json\` will be updated,
- instead of checking \`node_modules\` and downloading dependencies.
-
- For \`list\` this means the output will be based on the tree described by the
- \`package-lock.json\`, rather than the contents of \`node_modules\`.
- `,
- flatten: (key, obj, flatOptions) => {
- flatten(key, obj, flatOptions)
- if (flatOptions.packageLockOnly) {
- flatOptions.packageLock = true
- }
- },
-})
-
-define('pack-destination', {
- default: '.',
- type: String,
- description: `
- Directory in which \`npm pack\` will save tarballs.
- `,
- flatten,
-})
-
-define('parseable', {
- default: false,
- type: Boolean,
- short: 'p',
- description: `
- Output parseable results from commands that write to standard output. For
- \`npm search\`, this will be tab-separated table format.
- `,
- flatten,
-})
-
-define('prefer-dedupe', {
- default: false,
- type: Boolean,
- description: `
- Prefer to deduplicate packages if possible, rather than
- choosing a newer version of a dependency.
- `,
- flatten,
-})
-
-define('prefer-offline', {
- default: false,
- type: Boolean,
- description: `
- If true, staleness checks for cached data will be bypassed, but missing
- data will be requested from the server. To force full offline mode, use
- \`--offline\`.
- `,
- flatten,
-})
-
-define('prefer-online', {
- default: false,
- type: Boolean,
- description: `
- If true, staleness checks for cached data will be forced, making the CLI
- look for updates immediately even for fresh package data.
- `,
- flatten,
-})
-
-// `prefix` has its default defined outside of this module
-define('prefix', {
- type: path,
- short: 'C',
- default: '',
- defaultDescription: `
- In global mode, the folder where the node executable is installed.
- Otherwise, the nearest parent folder containing either a package.json
- file or a node_modules folder.
- `,
- description: `
- The location to install global items. If set on the command line, then
- it forces non-global commands to run in the specified folder.
- `,
-})
-
-define('preid', {
- default: '',
- hint: 'prerelease-id',
- type: String,
- description: `
- The "prerelease identifier" to use as a prefix for the "prerelease" part
- of a semver. Like the \`rc\` in \`1.2.0-rc.8\`.
- `,
- flatten,
-})
-
-define('production', {
- default: null,
- type: [null, Boolean],
- deprecated: 'Use `--omit=dev` instead.',
- description: 'Alias for `--omit=dev`',
- flatten (key, obj, flatOptions) {
- definitions.omit.flatten('omit', obj, flatOptions)
- },
-})
-
-define('progress', {
- default: !ciInfo.isCI,
- defaultDescription: `
- \`true\` unless running in a known CI system
- `,
- type: Boolean,
- description: `
- When set to \`true\`, npm will display a progress bar during time
- intensive operations, if \`process.stderr\` is a TTY.
-
- Set to \`false\` to suppress the progress bar.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.progress = !obj.progress ? false
- : !!process.stderr.isTTY && process.env.TERM !== 'dumb'
- },
-})
-
-define('provenance', {
- default: false,
- type: Boolean,
- exclusive: ['provenance-file'],
- description: `
- When publishing from a supported cloud CI/CD system, the package will be
- publicly linked to where it was built and published from.
- `,
- flatten,
-})
-
-define('provenance-file', {
- default: null,
- type: path,
- hint: '',
- exclusive: ['provenance'],
- description: `
- When publishing, the provenance bundle at the given path will be used.
- `,
- flatten,
-})
-
-define('proxy', {
- default: null,
- type: [null, false, url], // allow proxy to be disabled explicitly
- description: `
- A proxy to use for outgoing http requests. If the \`HTTP_PROXY\` or
- \`http_proxy\` environment variables are set, proxy settings will be
- honored by the underlying \`request\` library.
- `,
- flatten,
-})
-
-define('read-only', {
- default: false,
- type: Boolean,
- description: `
- This is used to mark a token as unable to publish when configuring
- limited access tokens with the \`npm token create\` command.
- `,
- flatten,
-})
-
-define('rebuild-bundle', {
- default: true,
- type: Boolean,
- description: `
- Rebuild bundled dependencies after installation.
- `,
- flatten,
-})
-
-define('registry', {
- default: 'https://registry.npmjs.org/',
- type: url,
- description: `
- The base URL of the npm registry.
- `,
- flatten,
-})
-
-define('replace-registry-host', {
- default: 'npmjs',
- hint: ' | hostname',
- type: ['npmjs', 'never', 'always', String],
- description: `
- Defines behavior for replacing the registry host in a lockfile with the
- configured registry.
-
- The default behavior is to replace package dist URLs from the default
- registry (https://registry.npmjs.org) to the configured registry. If set to
- "never", then use the registry value. If set to "always", then replace the
- registry host with the configured host every time.
-
- You may also specify a bare hostname (e.g., "registry.npmjs.org").
- `,
- flatten,
-})
-
-define('save', {
- default: true,
- defaultDescription: `\`true\` unless when using \`npm update\` where it
- defaults to \`false\``,
- usage: '-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle',
- type: Boolean,
- short: 'S',
- description: `
- Save installed packages to a \`package.json\` file as dependencies.
-
- When used with the \`npm rm\` command, removes the dependency from
- \`package.json\`.
-
- Will also prevent writing to \`package-lock.json\` if set to \`false\`.
- `,
- flatten,
-})
-
-define('save-bundle', {
- default: false,
- type: Boolean,
- short: 'B',
- description: `
- If a package would be saved at install time by the use of \`--save\`,
- \`--save-dev\`, or \`--save-optional\`, then also put it in the
- \`bundleDependencies\` list.
-
- Ignored if \`--save-peer\` is set, since peerDependencies cannot be bundled.
- `,
- flatten (key, obj, flatOptions) {
- // XXX update arborist to just ignore it if resulting saveType is peer
- // otherwise this won't have the expected effect:
- //
- // npm config set save-peer true
- // npm i foo --save-bundle --save-prod <-- should bundle
- flatOptions.saveBundle = obj['save-bundle'] && !obj['save-peer']
- },
-})
+ flatten,
+ }),
+ cache: new Definition('cache', {
+ default: cache,
+ defaultDescription: `
+ Windows: \`%LocalAppData%\\npm-cache\`, Posix: \`~/.npm\`
+ `,
+ type: path,
+ description: `
+ The location of npm's cache directory.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.cache = join(obj.cache, '_cacache')
+ flatOptions.npxCache = join(obj.cache, '_npx')
+ flatOptions.tufCache = join(obj.cache, '_tuf')
+ },
+ }),
+ 'cache-max': new Definition('cache-max', {
+ default: Infinity,
+ type: Number,
+ description: `
+ \`--cache-max=0\` is an alias for \`--prefer-online\`
+ `,
+ deprecated: `
+ This option has been deprecated in favor of \`--prefer-online\`
+ `,
+ flatten (key, obj, flatOptions) {
+ if (obj[key] <= 0) {
+ flatOptions.preferOnline = true
+ }
+ },
+ }),
+ 'cache-min': new Definition('cache-min', {
+ default: 0,
+ type: Number,
+ description: `
+ \`--cache-min=9999 (or bigger)\` is an alias for \`--prefer-offline\`.
+ `,
+ deprecated: `
+ This option has been deprecated in favor of \`--prefer-offline\`.
+ `,
+ flatten (key, obj, flatOptions) {
+ if (obj[key] >= 9999) {
+ flatOptions.preferOffline = true
+ }
+ },
+ }),
+ cafile: new Definition('cafile', {
+ default: null,
+ type: path,
+ description: `
+ A path to a file containing one or multiple Certificate Authority signing
+ certificates. Similar to the \`ca\` setting, but allows for multiple
+ CA's, as well as for the CA information to be stored in a file on disk.
+ `,
+ flatten (key, obj, flatOptions) {
+ // always set to null in defaults
+ if (!obj.cafile) {
+ return
+ }
-// XXX: We should really deprecate all these `--save-blah` switches
-// in favor of a single `--save-type` option. The unfortunate shortcut
-// we took for `--save-peer --save-optional` being `--save-type=peerOptional`
-// makes this tricky, and likely a breaking change.
+ const raw = maybeReadFile(obj.cafile)
+ if (!raw) {
+ return
+ }
-define('save-dev', {
- default: false,
- type: Boolean,
- short: 'D',
- description: `
- Save installed packages to a package.json file as \`devDependencies\`.
- `,
- flatten (key, obj, flatOptions) {
- if (!obj[key]) {
- if (flatOptions.saveType === 'dev') {
- delete flatOptions.saveType
+ const delim = '-----END CERTIFICATE-----'
+ flatOptions.ca = raw.replace(/\r\n/g, '\n').split(delim)
+ .filter(section => section.trim())
+ .map(section => section.trimLeft() + delim)
+ },
+ }),
+ call: new Definition('call', {
+ default: '',
+ type: String,
+ short: 'c',
+ description: `
+ Optional companion option for \`npm exec\`, \`npx\` that allows for
+ specifying a custom command to be run along with the installed packages.
+
+ \`\`\`bash
+ npm exec --package yo --package generator-node --call "yo node"
+ \`\`\`
+ `,
+ flatten,
+ }),
+ cert: new Definition('cert', {
+ default: null,
+ type: [null, String],
+ description: `
+ A client certificate to pass when accessing the registry. Values should
+ be in PEM format (Windows calls it "Base-64 encoded X.509 (.CER)") with
+ newlines replaced by the string "\\n". For example:
+
+ \`\`\`ini
+ cert="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----"
+ \`\`\`
+
+ It is _not_ the path to a certificate file, though you can set a registry-scoped
+ "certfile" path like "//other-registry.tld/:certfile=/path/to/cert.pem".
+ `,
+ deprecated: `
+ \`key\` and \`cert\` are no longer used for most registry operations.
+ Use registry scoped \`keyfile\` and \`certfile\` instead.
+ Example:
+ //other-registry.tld/:keyfile=/path/to/key.pem
+ //other-registry.tld/:certfile=/path/to/cert.crt
+ `,
+ flatten,
+ }),
+ cidr: new Definition('cidr', {
+ default: null,
+ type: [null, String, Array],
+ description: `
+ This is a list of CIDR address to be used when configuring limited access
+ tokens with the \`npm token create\` command.
+ `,
+ flatten,
+ }),
+ // This should never be directly used, the flattened value is the derived value
+ // and is sent to other modules, and is also exposed as `npm.color` for use
+ // inside npm itself.
+ color: new Definition('color', {
+ default: !process.env.NO_COLOR || process.env.NO_COLOR === '0',
+ usage: '--color|--no-color|--color always',
+ defaultDescription: `
+ true unless the NO_COLOR environ is set to something other than '0'
+ `,
+ type: ['always', Boolean],
+ description: `
+ If false, never shows colors. If \`"always"\` then always shows colors.
+ If true, then only prints color codes for tty file descriptors.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.color = !obj.color ? false
+ : obj.color === 'always' ? true
+ : !!process.stdout.isTTY
+ flatOptions.logColor = !obj.color ? false
+ : obj.color === 'always' ? true
+ : !!process.stderr.isTTY
+ },
+ }),
+ 'commit-hooks': new Definition('commit-hooks', {
+ default: true,
+ type: Boolean,
+ description: `
+ Run git commit hooks when using the \`npm version\` command.
+ `,
+ flatten,
+ }),
+ cpu: new Definition('cpu', {
+ default: null,
+ type: [null, String],
+ description: `
+ Override CPU architecture of native modules to install.
+ Acceptable values are same as \`cpu\` field of package.json,
+ which comes from \`process.arch\`.
+ `,
+ flatten,
+ }),
+ depth: new Definition('depth', {
+ default: null,
+ defaultDescription: `
+ \`Infinity\` if \`--all\` is set, otherwise \`1\`
+ `,
+ type: [null, Number],
+ description: `
+ The depth to go when recursing packages for \`npm ls\`.
+
+ If not set, \`npm ls\` will show only the immediate dependencies of the
+ root project. If \`--all\` is set, then npm will show all dependencies
+ by default.
+ `,
+ flatten,
+ }),
+ description: new Definition('description', {
+ default: true,
+ type: Boolean,
+ usage: '--no-description',
+ description: `
+ Show the description in \`npm search\`
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.search = flatOptions.search || { limit: 20 }
+ flatOptions.search[key] = obj[key]
+ },
+ }),
+ dev: new Definition('dev', {
+ default: false,
+ type: Boolean,
+ description: `
+ Alias for \`--include=dev\`.
+ `,
+ deprecated: 'Please use --include=dev instead.',
+ flatten (key, obj, flatOptions) {
+ definitions.omit.flatten('omit', obj, flatOptions)
+ },
+ }),
+ diff: new Definition('diff', {
+ default: [],
+ hint: '',
+ type: [String, Array],
+ description: `
+ Define arguments to compare in \`npm diff\`.
+ `,
+ flatten,
+ }),
+ 'diff-ignore-all-space': new Definition('diff-ignore-all-space', {
+ default: false,
+ type: Boolean,
+ description: `
+ Ignore whitespace when comparing lines in \`npm diff\`.
+ `,
+ flatten,
+ }),
+ 'diff-name-only': new Definition('diff-name-only', {
+ default: false,
+ type: Boolean,
+ description: `
+ Prints only filenames when using \`npm diff\`.
+ `,
+ flatten,
+ }),
+ 'diff-no-prefix': new Definition('diff-no-prefix', {
+ default: false,
+ type: Boolean,
+ description: `
+ Do not show any source or destination prefix in \`npm diff\` output.
+
+ Note: this causes \`npm diff\` to ignore the \`--diff-src-prefix\` and
+ \`--diff-dst-prefix\` configs.
+ `,
+ flatten,
+ }),
+ 'diff-dst-prefix': new Definition('diff-dst-prefix', {
+ default: 'b/',
+ hint: '',
+ type: String,
+ description: `
+ Destination prefix to be used in \`npm diff\` output.
+ `,
+ flatten,
+ }),
+ 'diff-src-prefix': new Definition('diff-src-prefix', {
+ default: 'a/',
+ hint: '',
+ type: String,
+ description: `
+ Source prefix to be used in \`npm diff\` output.
+ `,
+ flatten,
+ }),
+ 'diff-text': new Definition('diff-text', {
+ default: false,
+ type: Boolean,
+ description: `
+ Treat all files as text in \`npm diff\`.
+ `,
+ flatten,
+ }),
+ 'diff-unified': new Definition('diff-unified', {
+ default: 3,
+ type: Number,
+ description: `
+ The number of lines of context to print in \`npm diff\`.
+ `,
+ flatten,
+ }),
+ 'dry-run': new Definition('dry-run', {
+ default: false,
+ type: Boolean,
+ description: `
+ Indicates that you don't want npm to make any changes and that it should
+ only report what it would have done. This can be passed into any of the
+ commands that modify your local installation, eg, \`install\`,
+ \`update\`, \`dedupe\`, \`uninstall\`, as well as \`pack\` and
+ \`publish\`.
+
+ Note: This is NOT honored by other network related commands, eg
+ \`dist-tags\`, \`owner\`, etc.
+ `,
+ flatten,
+ }),
+ editor: new Definition('editor', {
+ default: editor,
+ defaultDescription: `
+ The EDITOR or VISUAL environment variables, or '%SYSTEMROOT%\\notepad.exe' on Windows,
+ or 'vi' on Unix systems
+ `,
+ type: String,
+ description: `
+ The command to run for \`npm edit\` and \`npm config edit\`.
+ `,
+ flatten,
+ }),
+ 'engine-strict': new Definition('engine-strict', {
+ default: false,
+ type: Boolean,
+ description: `
+ If set to true, then npm will stubbornly refuse to install (or even
+ consider installing) any package that claims to not be compatible with
+ the current Node.js version.
+
+ This can be overridden by setting the \`--force\` flag.
+ `,
+ flatten,
+ }),
+ 'expect-result-count': new Definition('expect-result-count', {
+ default: null,
+ type: [null, Number],
+ hint: '',
+ exclusive: ['expect-results'],
+ description: `
+ Tells to expect a specific number of results from the command.
+ `,
+ }),
+ 'expect-results': new Definition('expect-results', {
+ default: null,
+ type: [null, Boolean],
+ exclusive: ['expect-result-count'],
+ description: `
+ Tells npm whether or not to expect results from the command.
+ Can be either true (expect some results) or false (expect no results).
+ `,
+ }),
+ 'fetch-retries': new Definition('fetch-retries', {
+ default: 2,
+ type: Number,
+ description: `
+ The "retries" config for the \`retry\` module to use when fetching
+ packages from the registry.
+
+ npm will retry idempotent read requests to the registry in the case
+ of network failures or 5xx HTTP errors.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.retry = flatOptions.retry || {}
+ flatOptions.retry.retries = obj[key]
+ },
+ }),
+ 'fetch-retry-factor': new Definition('fetch-retry-factor', {
+ default: 10,
+ type: Number,
+ description: `
+ The "factor" config for the \`retry\` module to use when fetching
+ packages.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.retry = flatOptions.retry || {}
+ flatOptions.retry.factor = obj[key]
+ },
+ }),
+ 'fetch-retry-maxtimeout': new Definition('fetch-retry-maxtimeout', {
+ default: 60000,
+ defaultDescription: '60000 (1 minute)',
+ type: Number,
+ description: `
+ The "maxTimeout" config for the \`retry\` module to use when fetching
+ packages.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.retry = flatOptions.retry || {}
+ flatOptions.retry.maxTimeout = obj[key]
+ },
+ }),
+ 'fetch-retry-mintimeout': new Definition('fetch-retry-mintimeout', {
+ default: 10000,
+ defaultDescription: '10000 (10 seconds)',
+ type: Number,
+ description: `
+ The "minTimeout" config for the \`retry\` module to use when fetching
+ packages.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.retry = flatOptions.retry || {}
+ flatOptions.retry.minTimeout = obj[key]
+ },
+ }),
+ 'fetch-timeout': new Definition('fetch-timeout', {
+ default: 5 * 60 * 1000,
+ defaultDescription: `${5 * 60 * 1000} (5 minutes)`,
+ type: Number,
+ description: `
+ The maximum amount of time to wait for HTTP requests to complete.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.timeout = obj[key]
+ },
+ }),
+ force: new Definition('force', {
+ default: false,
+ type: Boolean,
+ short: 'f',
+ description: `
+ Removes various protections against unfortunate side effects, common
+ mistakes, unnecessary performance degradation, and malicious input.
+
+ * Allow clobbering non-npm files in global installs.
+ * Allow the \`npm version\` command to work on an unclean git repository.
+ * Allow deleting the cache folder with \`npm cache clean\`.
+ * Allow installing packages that have an \`engines\` declaration
+ requiring a different version of npm.
+ * Allow installing packages that have an \`engines\` declaration
+ requiring a different version of \`node\`, even if \`--engine-strict\`
+ is enabled.
+ * Allow \`npm audit fix\` to install modules outside your stated
+ dependency range (including SemVer-major changes).
+ * Allow unpublishing all versions of a published package.
+ * Allow conflicting peerDependencies to be installed in the root project.
+ * Implicitly set \`--yes\` during \`npm init\`.
+ * Allow clobbering existing values in \`npm pkg\`
+ * Allow unpublishing of entire packages (not just a single version).
+
+ If you don't have a clear idea of what you want to do, it is strongly
+ recommended that you do not use this option!
+ `,
+ flatten,
+ }),
+ 'foreground-scripts': new Definition('foreground-scripts', {
+ default: false,
+ defaultDescription: `\`false\` unless when using \`npm pack\` or \`npm publish\` where it
+ defaults to \`true\``,
+ type: Boolean,
+ description: `
+ Run all build scripts (ie, \`preinstall\`, \`install\`, and
+ \`postinstall\`) scripts for installed packages in the foreground
+ process, sharing standard input, output, and error with the main npm
+ process.
+
+ Note that this will generally make installs run slower, and be much
+ noisier, but can be useful for debugging.
+ `,
+ flatten,
+ }),
+ 'format-package-lock': new Definition('format-package-lock', {
+ default: true,
+ type: Boolean,
+ description: `
+ Format \`package-lock.json\` or \`npm-shrinkwrap.json\` as a human
+ readable file.
+ `,
+ flatten,
+ }),
+ fund: new Definition('fund', {
+ default: true,
+ type: Boolean,
+ description: `
+ When "true" displays the message at the end of each \`npm install\`
+ acknowledging the number of dependencies looking for funding.
+ See [\`npm fund\`](/commands/npm-fund) for details.
+ `,
+ flatten,
+ }),
+ git: new Definition('git', {
+ default: 'git',
+ type: String,
+ description: `
+ The command to use for git commands. If git is installed on the
+ computer, but is not in the \`PATH\`, then set this to the full path to
+ the git binary.
+ `,
+ flatten,
+ }),
+ 'git-tag-version': new Definition('git-tag-version', {
+ default: true,
+ type: Boolean,
+ description: `
+ Tag the commit when using the \`npm version\` command. Setting this to
+ false results in no commit being made at all.
+ `,
+ flatten,
+ }),
+ global: new Definition('global', {
+ default: false,
+ type: Boolean,
+ short: 'g',
+ description: `
+ Operates in "global" mode, so that packages are installed into the
+ \`prefix\` folder instead of the current working directory. See
+ [folders](/configuring-npm/folders) for more on the differences in
+ behavior.
+
+ * packages are installed into the \`{prefix}/lib/node_modules\` folder,
+ instead of the current working directory.
+ * bin files are linked to \`{prefix}/bin\`
+ * man pages are linked to \`{prefix}/share/man\`
+ `,
+ flatten: (key, obj, flatOptions) => {
+ flatten(key, obj, flatOptions)
+ if (flatOptions.global) {
+ flatOptions.location = 'global'
+ }
+ },
+ }),
+ // the globalconfig has its default defined outside of this module
+ globalconfig: new Definition('globalconfig', {
+ type: path,
+ default: '',
+ defaultDescription: `
+ The global --prefix setting plus 'etc/npmrc'. For example,
+ '/usr/local/etc/npmrc'
+ `,
+ description: `
+ The config file to read for global config options.
+ `,
+ flatten,
+ }),
+ 'global-style': new Definition('global-style', {
+ default: false,
+ type: Boolean,
+ description: `
+ Only install direct dependencies in the top level \`node_modules\`,
+ but hoist on deeper dependencies.
+ Sets \`--install-strategy=shallow\`.
+ `,
+ deprecated: `
+ This option has been deprecated in favor of \`--install-strategy=shallow\`
+ `,
+ flatten (key, obj, flatOptions) {
+ if (obj[key]) {
+ obj['install-strategy'] = 'shallow'
+ flatOptions.installStrategy = 'shallow'
+ }
+ },
+ }),
+ heading: new Definition('heading', {
+ default: 'npm',
+ type: String,
+ description: `
+ The string that starts all the debugging log output.
+ `,
+ flatten,
+ }),
+ 'https-proxy': new Definition('https-proxy', {
+ default: null,
+ type: [null, url],
+ description: `
+ A proxy to use for outgoing https requests. If the \`HTTPS_PROXY\` or
+ \`https_proxy\` or \`HTTP_PROXY\` or \`http_proxy\` environment variables
+ are set, proxy settings will be honored by the underlying
+ \`make-fetch-happen\` library.
+ `,
+ flatten,
+ }),
+ 'if-present': new Definition('if-present', {
+ default: false,
+ type: Boolean,
+ envExport: false,
+ description: `
+ If true, npm will not exit with an error code when \`run-script\` is
+ invoked for a script that isn't defined in the \`scripts\` section of
+ \`package.json\`. This option can be used when it's desirable to
+ optionally run a script when it's present and fail if the script fails.
+ This is useful, for example, when running scripts that may only apply for
+ some builds in an otherwise generic CI setup.
+ `,
+ flatten,
+ }),
+ 'ignore-scripts': new Definition('ignore-scripts', {
+ default: false,
+ type: Boolean,
+ description: `
+ If true, npm does not run scripts specified in package.json files.
+
+ Note that commands explicitly intended to run a particular script, such
+ as \`npm start\`, \`npm stop\`, \`npm restart\`, \`npm test\`, and \`npm
+ run-script\` will still run their intended script if \`ignore-scripts\` is
+ set, but they will *not* run any pre- or post-scripts.
+ `,
+ flatten,
+ }),
+ include: new Definition('include', {
+ default: [],
+ type: [Array, 'prod', 'dev', 'optional', 'peer'],
+ description: `
+ Option that allows for defining which types of dependencies to install.
+
+ This is the inverse of \`--omit=\`.
+
+ Dependency types specified in \`--include\` will not be omitted,
+ regardless of the order in which omit/include are specified on the
+ command-line.
+ `,
+ flatten (key, obj, flatOptions) {
+ // just call the omit flattener, it reads from obj.include
+ definitions.omit.flatten('omit', obj, flatOptions)
+ },
+ }),
+ 'include-staged': new Definition('include-staged', {
+ default: false,
+ type: Boolean,
+ description: `
+ Allow installing "staged" published packages, as defined by [npm RFC PR
+ #92](https://github.com/npm/rfcs/pull/92).
+
+ This is experimental, and not implemented by the npm public registry.
+ `,
+ flatten,
+ }),
+ 'include-workspace-root': new Definition('include-workspace-root', {
+ default: false,
+ type: Boolean,
+ envExport: false,
+ description: `
+ Include the workspace root when workspaces are enabled for a command.
+
+ When false, specifying individual workspaces via the \`workspace\` config,
+ or all workspaces via the \`workspaces\` flag, will cause npm to operate only
+ on the specified workspaces, and not on the root project.
+ `,
+ flatten,
+ }),
+ 'init-author-email': new Definition('init-author-email', {
+ default: '',
+ hint: '',
+ type: String,
+ description: `
+ The value \`npm init\` should use by default for the package author's
+ email.
+ `,
+ }),
+ 'init-author-name': new Definition('init-author-name', {
+ default: '',
+ hint: '',
+ type: String,
+ description: `
+ The value \`npm init\` should use by default for the package author's name.
+ `,
+ }),
+ 'init-author-url': new Definition('init-author-url', {
+ default: '',
+ type: ['', url],
+ hint: '',
+ description: `
+ The value \`npm init\` should use by default for the package author's homepage.
+ `,
+ }),
+ 'init-license': new Definition('init-license', {
+ default: 'ISC',
+ hint: '',
+ type: String,
+ description: `
+ The value \`npm init\` should use by default for the package license.
+ `,
+ }),
+ 'init-module': new Definition('init-module', {
+ default: '~/.npm-init.js',
+ type: path,
+ hint: '',
+ description: `
+ A module that will be loaded by the \`npm init\` command. See the
+ documentation for the
+ [init-package-json](https://github.com/npm/init-package-json) module for
+ more information, or [npm init](/commands/npm-init).
+ `,
+ }),
+ 'init-version': new Definition('init-version', {
+ default: '1.0.0',
+ type: Semver,
+ hint: '',
+ description: `
+ The value that \`npm init\` should use by default for the package
+ version number, if not already set in package.json.
+ `,
+ }),
+ // these "aliases" are historically supported in .npmrc files, unfortunately
+ // They should be removed in a future npm version.
+ 'init.author.email': new Definition('init.author.email', {
+ default: '',
+ type: String,
+ deprecated: `
+ Use \`--init-author-email\` instead.`,
+ description: `
+ Alias for \`--init-author-email\`
+ `,
+ }),
+ 'init.author.name': new Definition('init.author.name', {
+ default: '',
+ type: String,
+ deprecated: `
+ Use \`--init-author-name\` instead.
+ `,
+ description: `
+ Alias for \`--init-author-name\`
+ `,
+ }),
+ 'init.author.url': new Definition('init.author.url', {
+ default: '',
+ type: ['', url],
+ deprecated: `
+ Use \`--init-author-url\` instead.
+ `,
+ description: `
+ Alias for \`--init-author-url\`
+ `,
+ }),
+ 'init.license': new Definition('init.license', {
+ default: 'ISC',
+ type: String,
+ deprecated: `
+ Use \`--init-license\` instead.
+ `,
+ description: `
+ Alias for \`--init-license\`
+ `,
+ }),
+ 'init.module': new Definition('init.module', {
+ default: '~/.npm-init.js',
+ type: path,
+ deprecated: `
+ Use \`--init-module\` instead.
+ `,
+ description: `
+ Alias for \`--init-module\`
+ `,
+ }),
+ 'init.version': new Definition('init.version', {
+ default: '1.0.0',
+ type: Semver,
+ deprecated: `
+ Use \`--init-version\` instead.
+ `,
+ description: `
+ Alias for \`--init-version\`
+ `,
+ }),
+ 'install-links': new Definition('install-links', {
+ default: false,
+ type: Boolean,
+ description: `
+ When set file: protocol dependencies will be packed and installed as
+ regular dependencies instead of creating a symlink. This option has
+ no effect on workspaces.
+ `,
+ flatten,
+ }),
+ 'install-strategy': new Definition('install-strategy', {
+ default: 'hoisted',
+ type: ['hoisted', 'nested', 'shallow', 'linked'],
+ description: `
+ Sets the strategy for installing packages in node_modules.
+ hoisted (default): Install non-duplicated in top-level, and duplicated as
+ necessary within directory structure.
+ nested: (formerly --legacy-bundling) install in place, no hoisting.
+ shallow (formerly --global-style) only install direct deps at top-level.
+ linked: (experimental) install in node_modules/.store, link in place,
+ unhoisted.
+ `,
+ flatten,
+ }),
+ json: new Definition('json', {
+ default: false,
+ type: Boolean,
+ description: `
+ Whether or not to output JSON data, rather than the normal output.
+
+ * In \`npm pkg set\` it enables parsing set values with JSON.parse()
+ before saving them to your \`package.json\`.
+
+ Not supported by all npm commands.
+ `,
+ flatten,
+ }),
+ key: new Definition('key', {
+ default: null,
+ type: [null, String],
+ description: `
+ A client key to pass when accessing the registry. Values should be in
+ PEM format with newlines replaced by the string "\\n". For example:
+
+ \`\`\`ini
+ key="-----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY-----"
+ \`\`\`
+
+ It is _not_ the path to a key file, though you can set a registry-scoped
+ "keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem".
+ `,
+ deprecated: `
+ \`key\` and \`cert\` are no longer used for most registry operations.
+ Use registry scoped \`keyfile\` and \`certfile\` instead.
+ Example:
+ //other-registry.tld/:keyfile=/path/to/key.pem
+ //other-registry.tld/:certfile=/path/to/cert.crt
+ `,
+ flatten,
+ }),
+ 'legacy-bundling': new Definition('legacy-bundling', {
+ default: false,
+ type: Boolean,
+ description: `
+ Instead of hoisting package installs in \`node_modules\`, install packages
+ in the same manner that they are depended on. This may cause very deep
+ directory structures and duplicate package installs as there is no
+ de-duplicating.
+ Sets \`--install-strategy=nested\`.
+ `,
+ deprecated: `
+ This option has been deprecated in favor of \`--install-strategy=nested\`
+ `,
+ flatten (key, obj, flatOptions) {
+ if (obj[key]) {
+ obj['install-strategy'] = 'nested'
+ flatOptions.installStrategy = 'nested'
+ }
+ },
+ }),
+ 'legacy-peer-deps': new Definition('legacy-peer-deps', {
+ default: false,
+ type: Boolean,
+ description: `
+ Causes npm to completely ignore \`peerDependencies\` when building a
+ package tree, as in npm versions 3 through 6.
+
+ If a package cannot be installed because of overly strict
+ \`peerDependencies\` that collide, it provides a way to move forward
+ resolving the situation.
+
+ This differs from \`--omit=peer\`, in that \`--omit=peer\` will avoid
+ unpacking \`peerDependencies\` on disk, but will still design a tree such
+ that \`peerDependencies\` _could_ be unpacked in a correct place.
+
+ Use of \`legacy-peer-deps\` is not recommended, as it will not enforce
+ the \`peerDependencies\` contract that meta-dependencies may rely on.
+ `,
+ flatten,
+ }),
+ libc: new Definition('libc', {
+ default: null,
+ type: [null, String],
+ description: `
+ Override libc of native modules to install.
+ Acceptable values are same as \`libc\` field of package.json
+ `,
+ flatten,
+ }),
+ link: new Definition('link', {
+ default: false,
+ type: Boolean,
+ description: `
+ Used with \`npm ls\`, limiting output to only those packages that are
+ linked.
+ `,
+ }),
+ 'local-address': new Definition('local-address', {
+ default: null,
+ type: getLocalAddresses(),
+ typeDescription: 'IP Address',
+ description: `
+ The IP address of the local interface to use when making connections to
+ the npm registry. Must be IPv4 in versions of Node prior to 0.12.
+ `,
+ flatten,
+ }),
+ location: new Definition('location', {
+ default: 'user',
+ short: 'L',
+ type: [
+ 'global',
+ 'user',
+ 'project',
+ ],
+ defaultDescription: `
+ "user" unless \`--global\` is passed, which will also set this value to "global"
+ `,
+ description: `
+ When passed to \`npm config\` this refers to which config file to use.
+
+ When set to "global" mode, packages are installed into the \`prefix\` folder
+ instead of the current working directory. See
+ [folders](/configuring-npm/folders) for more on the differences in behavior.
+
+ * packages are installed into the \`{prefix}/lib/node_modules\` folder,
+ instead of the current working directory.
+ * bin files are linked to \`{prefix}/bin\`
+ * man pages are linked to \`{prefix}/share/man\`
+ `,
+ flatten: (key, obj, flatOptions) => {
+ flatten(key, obj, flatOptions)
+ if (flatOptions.global) {
+ flatOptions.location = 'global'
+ }
+ if (obj.location === 'global') {
+ flatOptions.global = true
+ }
+ },
+ }),
+ 'lockfile-version': new Definition('lockfile-version', {
+ default: null,
+ type: [null, 1, 2, 3, '1', '2', '3'],
+ defaultDescription: `
+ Version 3 if no lockfile, auto-converting v1 lockfiles to v3, otherwise
+ maintain current lockfile version.`,
+ description: `
+ Set the lockfile format version to be used in package-lock.json and
+ npm-shrinkwrap-json files. Possible options are:
+
+ 1: The lockfile version used by npm versions 5 and 6. Lacks some data that
+ is used during the install, resulting in slower and possibly less
+ deterministic installs. Prevents lockfile churn when interoperating with
+ older npm versions.
+
+ 2: The default lockfile version used by npm version 7 and 8. Includes both
+ the version 1 lockfile data and version 3 lockfile data, for maximum
+ determinism and interoperability, at the expense of more bytes on disk.
+
+ 3: Only the new lockfile information introduced in npm version 7. Smaller
+ on disk than lockfile version 2, but not interoperable with older npm
+ versions. Ideal if all users are on npm version 7 and higher.
+ `,
+ flatten: (key, obj, flatOptions) => {
+ flatOptions.lockfileVersion = obj[key] && parseInt(obj[key], 10)
+ },
+ }),
+ loglevel: new Definition('loglevel', {
+ default: 'notice',
+ type: [
+ 'silent',
+ 'error',
+ 'warn',
+ 'notice',
+ 'http',
+ 'info',
+ 'verbose',
+ 'silly',
+ ],
+ description: `
+ What level of logs to report. All logs are written to a debug log,
+ with the path to that file printed if the execution of a command fails.
+
+ Any logs of a higher level than the setting are shown. The default is
+ "notice".
+
+ See also the \`foreground-scripts\` config.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.silent = obj[key] === 'silent'
+ },
+ }),
+ 'logs-dir': new Definition('logs-dir', {
+ default: null,
+ type: [null, path],
+ defaultDescription: `
+ A directory named \`_logs\` inside the cache
+ `,
+ description: `
+ The location of npm's log directory. See [\`npm
+ logging\`](/using-npm/logging) for more information.
+ `,
+ }),
+ 'logs-max': new Definition('logs-max', {
+ default: 10,
+ type: Number,
+ description: `
+ The maximum number of log files to store.
+
+ If set to 0, no log files will be written for the current run.
+ `,
+ }),
+ long: new Definition('long', {
+ default: false,
+ type: Boolean,
+ short: 'l',
+ description: `
+ Show extended information in \`ls\`, \`search\`, and \`help-search\`.
+ `,
+ }),
+ maxsockets: new Definition('maxsockets', {
+ default: 15,
+ type: Number,
+ description: `
+ The maximum number of connections to use per origin (protocol/host/port
+ combination).
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.maxSockets = obj[key]
+ },
+ }),
+ message: new Definition('message', {
+ default: '%s',
+ type: String,
+ short: 'm',
+ description: `
+ Commit message which is used by \`npm version\` when creating version commit.
+
+ Any "%s" in the message will be replaced with the version number.
+ `,
+ flatten,
+ }),
+ 'node-options': new Definition('node-options', {
+ default: null,
+ type: [null, String],
+ description: `
+ Options to pass through to Node.js via the \`NODE_OPTIONS\` environment
+ variable. This does not impact how npm itself is executed but it does
+ impact how lifecycle scripts are called.
+ `,
+ }),
+ noproxy: new Definition('noproxy', {
+ default: '',
+ defaultDescription: `
+ The value of the NO_PROXY environment variable
+ `,
+ type: [String, Array],
+ description: `
+ Domain extensions that should bypass any proxies.
+
+ Also accepts a comma-delimited string.
+ `,
+ flatten (key, obj, flatOptions) {
+ if (Array.isArray(obj[key])) {
+ flatOptions.noProxy = obj[key].join(',')
+ } else {
+ flatOptions.noProxy = obj[key]
+ }
+ },
+ }),
+ offline: new Definition('offline', {
+ default: false,
+ type: Boolean,
+ description: `
+ Force offline mode: no network requests will be done during install. To allow
+ the CLI to fill in missing cache data, see \`--prefer-offline\`.
+ `,
+ flatten,
+ }),
+ omit: new Definition('omit', {
+ default: process.env.NODE_ENV === 'production' ? ['dev'] : [],
+ defaultDescription: `
+ 'dev' if the \`NODE_ENV\` environment variable is set to 'production',
+ otherwise empty.
+ `,
+ type: [Array, 'dev', 'optional', 'peer'],
+ description: `
+ Dependency types to omit from the installation tree on disk.
+
+ Note that these dependencies _are_ still resolved and added to the
+ \`package-lock.json\` or \`npm-shrinkwrap.json\` file. They are just
+ not physically installed on disk.
+
+ If a package type appears in both the \`--include\` and \`--omit\`
+ lists, then it will be included.
+
+ If the resulting omit list includes \`'dev'\`, then the \`NODE_ENV\`
+ environment variable will be set to \`'production'\` for all lifecycle
+ scripts.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.omit = buildOmitList(obj)
+ },
+ }),
+ 'omit-lockfile-registry-resolved': new Definition('omit-lockfile-registry-resolved', {
+ default: false,
+ type: Boolean,
+ description: `
+ This option causes npm to create lock files without a \`resolved\` key for
+ registry dependencies. Subsequent installs will need to resolve tarball
+ endpoints with the configured registry, likely resulting in a longer install
+ time.
+ `,
+ flatten,
+ }),
+ only: new Definition('only', {
+ default: null,
+ type: [null, 'prod', 'production'],
+ deprecated: `
+ Use \`--omit=dev\` to omit dev dependencies from the install.
+ `,
+ description: `
+ When set to \`prod\` or \`production\`, this is an alias for
+ \`--omit=dev\`.
+ `,
+ flatten (key, obj, flatOptions) {
+ definitions.omit.flatten('omit', obj, flatOptions)
+ },
+ }),
+ optional: new Definition('optional', {
+ default: null,
+ type: [null, Boolean],
+ deprecated: `
+ Use \`--omit=optional\` to exclude optional dependencies, or
+ \`--include=optional\` to include them.
+
+ Default value does install optional deps unless otherwise omitted.
+ `,
+ description: `
+ Alias for --include=optional or --omit=optional
+ `,
+ flatten (key, obj, flatOptions) {
+ definitions.omit.flatten('omit', obj, flatOptions)
+ },
+ }),
+ os: new Definition('os', {
+ default: null,
+ type: [null, String],
+ description: `
+ Override OS of native modules to install.
+ Acceptable values are same as \`os\` field of package.json,
+ which comes from \`process.platform\`.
+ `,
+ flatten,
+ }),
+ otp: new Definition('otp', {
+ default: null,
+ type: [null, String],
+ description: `
+ This is a one-time password from a two-factor authenticator. It's needed
+ when publishing or changing package permissions with \`npm access\`.
+
+ If not set, and a registry response fails with a challenge for a one-time
+ password, npm will prompt on the command line for one.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatten(key, obj, flatOptions)
+ if (obj.otp) {
+ obj['auth-type'] = 'legacy'
+ flatten('auth-type', obj, flatOptions)
+ }
+ },
+ }),
+ package: new Definition('package', {
+ default: [],
+ hint: '',
+ type: [String, Array],
+ description: `
+ The package or packages to install for [\`npm exec\`](/commands/npm-exec)
+ `,
+ flatten,
+ }),
+ 'package-lock': new Definition('package-lock', {
+ default: true,
+ type: Boolean,
+ description: `
+ If set to false, then ignore \`package-lock.json\` files when installing.
+ This will also prevent _writing_ \`package-lock.json\` if \`save\` is
+ true.
+ `,
+ flatten: (key, obj, flatOptions) => {
+ flatten(key, obj, flatOptions)
+ if (flatOptions.packageLockOnly) {
+ flatOptions.packageLock = true
+ }
+ },
+ }),
+ 'package-lock-only': new Definition('package-lock-only', {
+ default: false,
+ type: Boolean,
+ description: `
+ If set to true, the current operation will only use the \`package-lock.json\`,
+ ignoring \`node_modules\`.
+
+ For \`update\` this means only the \`package-lock.json\` will be updated,
+ instead of checking \`node_modules\` and downloading dependencies.
+
+ For \`list\` this means the output will be based on the tree described by the
+ \`package-lock.json\`, rather than the contents of \`node_modules\`.
+ `,
+ flatten: (key, obj, flatOptions) => {
+ flatten(key, obj, flatOptions)
+ if (flatOptions.packageLockOnly) {
+ flatOptions.packageLock = true
+ }
+ },
+ }),
+ 'pack-destination': new Definition('pack-destination', {
+ default: '.',
+ type: String,
+ description: `
+ Directory in which \`npm pack\` will save tarballs.
+ `,
+ flatten,
+ }),
+ parseable: new Definition('parseable', {
+ default: false,
+ type: Boolean,
+ short: 'p',
+ description: `
+ Output parseable results from commands that write to standard output. For
+ \`npm search\`, this will be tab-separated table format.
+ `,
+ flatten,
+ }),
+ 'prefer-dedupe': new Definition('prefer-dedupe', {
+ default: false,
+ type: Boolean,
+ description: `
+ Prefer to deduplicate packages if possible, rather than
+ choosing a newer version of a dependency.
+ `,
+ flatten,
+ }),
+ 'prefer-offline': new Definition('prefer-offline', {
+ default: false,
+ type: Boolean,
+ description: `
+ If true, staleness checks for cached data will be bypassed, but missing
+ data will be requested from the server. To force full offline mode, use
+ \`--offline\`.
+ `,
+ flatten,
+ }),
+ 'prefer-online': new Definition('prefer-online', {
+ default: false,
+ type: Boolean,
+ description: `
+ If true, staleness checks for cached data will be forced, making the CLI
+ look for updates immediately even for fresh package data.
+ `,
+ flatten,
+ }),
+ // `prefix` has its default defined outside of this module
+ prefix: new Definition('prefix', {
+ type: path,
+ short: 'C',
+ default: '',
+ defaultDescription: `
+ In global mode, the folder where the node executable is installed.
+ Otherwise, the nearest parent folder containing either a package.json
+ file or a node_modules folder.
+ `,
+ description: `
+ The location to install global items. If set on the command line, then
+ it forces non-global commands to run in the specified folder.
+ `,
+ }),
+ preid: new Definition('preid', {
+ default: '',
+ hint: 'prerelease-id',
+ type: String,
+ description: `
+ The "prerelease identifier" to use as a prefix for the "prerelease" part
+ of a semver. Like the \`rc\` in \`1.2.0-rc.8\`.
+ `,
+ flatten,
+ }),
+ production: new Definition('production', {
+ default: null,
+ type: [null, Boolean],
+ deprecated: 'Use `--omit=dev` instead.',
+ description: 'Alias for `--omit=dev`',
+ flatten (key, obj, flatOptions) {
+ definitions.omit.flatten('omit', obj, flatOptions)
+ },
+ }),
+ progress: new Definition('progress', {
+ default: !ciInfo.isCI,
+ defaultDescription: `
+ \`true\` unless running in a known CI system
+ `,
+ type: Boolean,
+ description: `
+ When set to \`true\`, npm will display a progress bar during time
+ intensive operations, if \`process.stderr\` is a TTY.
+
+ Set to \`false\` to suppress the progress bar.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.progress = !obj.progress ? false
+ : !!process.stderr.isTTY && process.env.TERM !== 'dumb'
+ },
+ }),
+ provenance: new Definition('provenance', {
+ default: false,
+ type: Boolean,
+ exclusive: ['provenance-file'],
+ description: `
+ When publishing from a supported cloud CI/CD system, the package will be
+ publicly linked to where it was built and published from.
+ `,
+ flatten,
+ }),
+ 'provenance-file': new Definition('provenance-file', {
+ default: null,
+ type: path,
+ hint: '',
+ exclusive: ['provenance'],
+ description: `
+ When publishing, the provenance bundle at the given path will be used.
+ `,
+ flatten,
+ }),
+ proxy: new Definition('proxy', {
+ default: null,
+ type: [null, false, url], // allow proxy to be disabled explicitly
+ description: `
+ A proxy to use for outgoing http requests. If the \`HTTP_PROXY\` or
+ \`http_proxy\` environment variables are set, proxy settings will be
+ honored by the underlying \`request\` library.
+ `,
+ flatten,
+ }),
+ 'read-only': new Definition('read-only', {
+ default: false,
+ type: Boolean,
+ description: `
+ This is used to mark a token as unable to publish when configuring
+ limited access tokens with the \`npm token create\` command.
+ `,
+ flatten,
+ }),
+ 'rebuild-bundle': new Definition('rebuild-bundle', {
+ default: true,
+ type: Boolean,
+ description: `
+ Rebuild bundled dependencies after installation.
+ `,
+ flatten,
+ }),
+ registry: new Definition('registry', {
+ default: 'https://registry.npmjs.org/',
+ type: url,
+ description: `
+ The base URL of the npm registry.
+ `,
+ flatten,
+ }),
+ 'replace-registry-host': new Definition('replace-registry-host', {
+ default: 'npmjs',
+ hint: ' | hostname',
+ type: ['npmjs', 'never', 'always', String],
+ description: `
+ Defines behavior for replacing the registry host in a lockfile with the
+ configured registry.
+
+ The default behavior is to replace package dist URLs from the default
+ registry (https://registry.npmjs.org) to the configured registry. If set to
+ "never", then use the registry value. If set to "always", then replace the
+ registry host with the configured host every time.
+
+ You may also specify a bare hostname (e.g., "registry.npmjs.org").
+ `,
+ flatten,
+ }),
+ save: new Definition('save', {
+ default: true,
+ defaultDescription: `\`true\` unless when using \`npm update\` where it
+ defaults to \`false\``,
+ usage: '-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle',
+ type: Boolean,
+ short: 'S',
+ description: `
+ Save installed packages to a \`package.json\` file as dependencies.
+
+ When used with the \`npm rm\` command, removes the dependency from
+ \`package.json\`.
+
+ Will also prevent writing to \`package-lock.json\` if set to \`false\`.
+ `,
+ flatten,
+ }),
+ 'save-bundle': new Definition('save-bundle', {
+ default: false,
+ type: Boolean,
+ short: 'B',
+ description: `
+ If a package would be saved at install time by the use of \`--save\`,
+ \`--save-dev\`, or \`--save-optional\`, then also put it in the
+ \`bundleDependencies\` list.
+
+ Ignored if \`--save-peer\` is set, since peerDependencies cannot be bundled.
+ `,
+ flatten (key, obj, flatOptions) {
+ // XXX update arborist to just ignore it if resulting saveType is peer
+ // otherwise this won't have the expected effect:
+ //
+ // npm config set save-peer true
+ // npm i foo --save-bundle --save-prod <-- should bundle
+ flatOptions.saveBundle = obj['save-bundle'] && !obj['save-peer']
+ },
+ }),
+ 'save-dev': new Definition('save-dev', {
+ default: false,
+ type: Boolean,
+ short: 'D',
+ description: `
+ Save installed packages to a package.json file as \`devDependencies\`.
+ `,
+ flatten (key, obj, flatOptions) {
+ if (!obj[key]) {
+ if (flatOptions.saveType === 'dev') {
+ delete flatOptions.saveType
+ }
+ return
}
- return
- }
- flatOptions.saveType = 'dev'
- },
-})
-
-define('save-exact', {
- default: false,
- type: Boolean,
- short: 'E',
- description: `
- Dependencies saved to package.json will be configured with an exact
- version rather than using npm's default semver range operator.
- `,
- flatten (key, obj, flatOptions) {
- // just call the save-prefix flattener, it reads from obj['save-exact']
- definitions['save-prefix'].flatten('save-prefix', obj, flatOptions)
- },
-})
-
-define('save-optional', {
- default: false,
- type: Boolean,
- short: 'O',
- description: `
- Save installed packages to a package.json file as
- \`optionalDependencies\`.
- `,
- flatten (key, obj, flatOptions) {
- if (!obj[key]) {
- if (flatOptions.saveType === 'optional') {
- delete flatOptions.saveType
- } else if (flatOptions.saveType === 'peerOptional') {
- flatOptions.saveType = 'peer'
+ flatOptions.saveType = 'dev'
+ },
+ }),
+ 'save-exact': new Definition('save-exact', {
+ default: false,
+ type: Boolean,
+ short: 'E',
+ description: `
+ Dependencies saved to package.json will be configured with an exact
+ version rather than using npm's default semver range operator.
+ `,
+ flatten (key, obj, flatOptions) {
+ // just call the save-prefix flattener, it reads from obj['save-exact']
+ definitions['save-prefix'].flatten('save-prefix', obj, flatOptions)
+ },
+ }),
+ 'save-optional': new Definition('save-optional', {
+ default: false,
+ type: Boolean,
+ short: 'O',
+ description: `
+ Save installed packages to a package.json file as
+ \`optionalDependencies\`.
+ `,
+ flatten (key, obj, flatOptions) {
+ if (!obj[key]) {
+ if (flatOptions.saveType === 'optional') {
+ delete flatOptions.saveType
+ } else if (flatOptions.saveType === 'peerOptional') {
+ flatOptions.saveType = 'peer'
+ }
+ return
}
- return
- }
- if (flatOptions.saveType === 'peerOptional') {
- return
- }
+ if (flatOptions.saveType === 'peerOptional') {
+ return
+ }
- if (flatOptions.saveType === 'peer') {
- flatOptions.saveType = 'peerOptional'
- } else {
- flatOptions.saveType = 'optional'
- }
- },
-})
-
-define('save-peer', {
- default: false,
- type: Boolean,
- description: `
- Save installed packages to a package.json file as \`peerDependencies\`
- `,
- flatten (key, obj, flatOptions) {
- if (!obj[key]) {
if (flatOptions.saveType === 'peer') {
- delete flatOptions.saveType
- } else if (flatOptions.saveType === 'peerOptional') {
+ flatOptions.saveType = 'peerOptional'
+ } else {
flatOptions.saveType = 'optional'
}
- return
- }
-
- if (flatOptions.saveType === 'peerOptional') {
- return
- }
-
- if (flatOptions.saveType === 'optional') {
- flatOptions.saveType = 'peerOptional'
- } else {
- flatOptions.saveType = 'peer'
- }
- },
-})
-
-define('save-prefix', {
- default: '^',
- type: String,
- description: `
- Configure how versions of packages installed to a package.json file via
- \`--save\` or \`--save-dev\` get prefixed.
-
- For example if a package has version \`1.2.3\`, by default its version is
- set to \`^1.2.3\` which allows minor upgrades for that package, but after
- \`npm config set save-prefix='~'\` it would be set to \`~1.2.3\` which
- only allows patch upgrades.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.savePrefix = obj['save-exact'] ? '' : obj['save-prefix']
- obj['save-prefix'] = flatOptions.savePrefix
- },
-})
-
-define('save-prod', {
- default: false,
- type: Boolean,
- short: 'P',
- description: `
- Save installed packages into \`dependencies\` specifically. This is
- useful if a package already exists in \`devDependencies\` or
- \`optionalDependencies\`, but you want to move it to be a non-optional
- production dependency.
-
- This is the default behavior if \`--save\` is true, and neither
- \`--save-dev\` or \`--save-optional\` are true.
- `,
- flatten (key, obj, flatOptions) {
- if (!obj[key]) {
- if (flatOptions.saveType === 'prod') {
- delete flatOptions.saveType
+ },
+ }),
+ 'save-peer': new Definition('save-peer', {
+ default: false,
+ type: Boolean,
+ description: `
+ Save installed packages to a package.json file as \`peerDependencies\`
+ `,
+ flatten (key, obj, flatOptions) {
+ if (!obj[key]) {
+ if (flatOptions.saveType === 'peer') {
+ delete flatOptions.saveType
+ } else if (flatOptions.saveType === 'peerOptional') {
+ flatOptions.saveType = 'optional'
+ }
+ return
}
- return
- }
-
- flatOptions.saveType = 'prod'
- },
-})
-
-define('scope', {
- default: '',
- defaultDescription: `
- the scope of the current project, if any, or ""
- `,
- type: String,
- hint: '<@scope>',
- description: `
- Associate an operation with a scope for a scoped registry.
-
- Useful when logging in to or out of a private registry:
-
- \`\`\`
- # log in, linking the scope to the custom registry
- npm login --scope=@mycorp --registry=https://registry.mycorp.com
- # log out, removing the link and the auth token
- npm logout --scope=@mycorp
- \`\`\`
-
- This will cause \`@mycorp\` to be mapped to the registry for future
- installation of packages specified according to the pattern
- \`@mycorp/package\`.
-
- This will also cause \`npm init\` to create a scoped package.
-
- \`\`\`
- # accept all defaults, and create a package named "@foo/whatever",
- # instead of just named "whatever"
- npm init --scope=@foo --yes
- \`\`\`
- `,
- flatten (key, obj, flatOptions) {
- const value = obj[key]
- const scope = value && !/^@/.test(value) ? `@${value}` : value
- flatOptions.scope = scope
- // projectScope is kept for compatibility with npm-registry-fetch
- flatOptions.projectScope = scope
- },
-})
-
-define('script-shell', {
- default: null,
- defaultDescription: `
- '/bin/sh' on POSIX systems, 'cmd.exe' on Windows
- `,
- type: [null, String],
- description: `
- The shell to use for scripts run with the \`npm exec\`,
- \`npm run\` and \`npm init \` commands.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.scriptShell = obj[key] || undefined
- },
-})
-
-define('searchexclude', {
- default: '',
- type: String,
- description: `
- Space-separated options that limit the results from search.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.search = flatOptions.search || { limit: 20 }
- flatOptions.search.exclude = obj[key].toLowerCase()
- },
-})
-
-define('searchlimit', {
- default: 20,
- type: Number,
- description: `
- Number of items to limit search results to. Will not apply at all to
- legacy searches.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.search = flatOptions.search || {}
- flatOptions.search.limit = obj[key]
- },
-})
-
-define('searchopts', {
- default: '',
- type: String,
- description: `
- Space-separated options that are always passed to search.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.search = flatOptions.search || { limit: 20 }
- flatOptions.search.opts = querystring.parse(obj[key])
- },
-})
-
-define('searchstaleness', {
- default: 15 * 60,
- type: Number,
- description: `
- The age of the cache, in seconds, before another registry request is made
- if using legacy search endpoint.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.search = flatOptions.search || { limit: 20 }
- flatOptions.search.staleness = obj[key]
- },
-})
-
-define('shell', {
- default: shell,
- defaultDescription: `
- SHELL environment variable, or "bash" on Posix, or "cmd.exe" on Windows
- `,
- type: String,
- description: `
- The shell to run for the \`npm explore\` command.
- `,
- flatten,
-})
-
-define('shrinkwrap', {
- default: true,
- type: Boolean,
- deprecated: `
- Use the --package-lock setting instead.
- `,
- description: `
- Alias for --package-lock
- `,
- flatten (key, obj, flatOptions) {
- obj['package-lock'] = obj.shrinkwrap
- definitions['package-lock'].flatten('package-lock', obj, flatOptions)
- },
-})
-
-define('sign-git-commit', {
- default: false,
- type: Boolean,
- description: `
- If set to true, then the \`npm version\` command will commit the new
- package version using \`-S\` to add a signature.
-
- Note that git requires you to have set up GPG keys in your git configs
- for this to work properly.
- `,
- flatten,
-})
-
-define('sign-git-tag', {
- default: false,
- type: Boolean,
- description: `
- If set to true, then the \`npm version\` command will tag the version
- using \`-s\` to add a signature.
-
- Note that git requires you to have set up GPG keys in your git configs
- for this to work properly.
- `,
- flatten,
-})
-
-define('strict-peer-deps', {
- default: false,
- type: Boolean,
- description: `
- If set to \`true\`, and \`--legacy-peer-deps\` is not set, then _any_
- conflicting \`peerDependencies\` will be treated as an install failure,
- even if npm could reasonably guess the appropriate resolution based on
- non-peer dependency relationships.
-
- By default, conflicting \`peerDependencies\` deep in the dependency graph
- will be resolved using the nearest non-peer dependency specification,
- even if doing so will result in some packages receiving a peer dependency
- outside the range set in their package's \`peerDependencies\` object.
-
- When such an override is performed, a warning is printed, explaining the
- conflict and the packages involved. If \`--strict-peer-deps\` is set,
- then this warning is treated as a failure.
- `,
- flatten,
-})
-
-define('strict-ssl', {
- default: true,
- type: Boolean,
- description: `
- Whether or not to do SSL key validation when making requests to the
- registry via https.
-
- See also the \`ca\` config.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.strictSSL = obj[key]
- },
-})
-
-define('tag', {
- default: 'latest',
- type: String,
- description: `
- If you ask npm to install a package and don't tell it a specific version,
- then it will install the specified tag.
-
- Also the tag that is added to the package@version specified by the \`npm
- tag\` command, if no explicit tag is given.
-
- When used by the \`npm diff\` command, this is the tag used to fetch the
- tarball that will be compared with the local files by default.
- `,
- flatten (key, obj, flatOptions) {
- flatOptions.defaultTag = obj[key]
- },
-})
-
-define('tag-version-prefix', {
- default: 'v',
- type: String,
- description: `
- If set, alters the prefix used when tagging a new version when performing
- a version increment using \`npm version\`. To remove the prefix
- altogether, set it to the empty string: \`""\`.
-
- Because other tools may rely on the convention that npm version tags look
- like \`v1.0.0\`, _only use this property if it is absolutely necessary_.
- In particular, use care when overriding this setting for public packages.
- `,
- flatten,
-})
-
-define('timing', {
- default: false,
- type: Boolean,
- description: `
- If true, writes timing information to a process specific json file in
- the cache or \`logs-dir\`. The file name ends with \`-timing.json\`.
-
- You can quickly view it with this [json](https://npm.im/json) command
- line: \`cat ~/.npm/_logs/*-timing.json | npm exec -- json -g\`.
-
- Timing information will also be reported in the terminal. To suppress this
- while still writing the timing file, use \`--silent\`.
- `,
-})
-
-define('umask', {
- default: 0,
- type: Umask,
- description: `
- The "umask" value to use when setting the file creation mode on files and
- folders.
-
- Folders and executables are given a mode which is \`0o777\` masked
- against this value. Other files are given a mode which is \`0o666\`
- masked against this value.
-
- Note that the underlying system will _also_ apply its own umask value to
- files and folders that are created, and npm does not circumvent this, but
- rather adds the \`--umask\` config to it.
-
- Thus, the effective default umask value on most POSIX systems is 0o22,
- meaning that folders and executables are created with a mode of 0o755 and
- other files are created with a mode of 0o644.
- `,
- flatten,
-})
-
-define('unicode', {
- default: unicode,
- defaultDescription: `
- false on windows, true on mac/unix systems with a unicode locale, as
- defined by the \`LC_ALL\`, \`LC_CTYPE\`, or \`LANG\` environment variables.
- `,
- type: Boolean,
- description: `
- When set to true, npm uses unicode characters in the tree output. When
- false, it uses ascii characters instead of unicode glyphs.
- `,
- flatten,
-})
-
-define('update-notifier', {
- default: true,
- type: Boolean,
- description: `
- Set to false to suppress the update notification when using an older
- version of npm than the latest.
- `,
-})
-
-define('usage', {
- default: false,
- type: Boolean,
- short: ['?', 'H', 'h'],
- description: `
- Show short usage output about the command specified.
- `,
-})
-
-define('user-agent', {
- default: 'npm/{npm-version} ' +
- 'node/{node-version} ' +
- '{platform} ' +
- '{arch} ' +
- 'workspaces/{workspaces} ' +
- '{ci}',
- type: String,
- description: `
- Sets the User-Agent request header. The following fields are replaced
- with their actual counterparts:
-
- * \`{npm-version}\` - The npm version in use
- * \`{node-version}\` - The Node.js version in use
- * \`{platform}\` - The value of \`process.platform\`
- * \`{arch}\` - The value of \`process.arch\`
- * \`{workspaces}\` - Set to \`true\` if the \`workspaces\` or \`workspace\`
- options are set.
- * \`{ci}\` - The value of the \`ci-name\` config, if set, prefixed with
- \`ci/\`, or an empty string if \`ci-name\` is empty.
- `,
- flatten (key, obj, flatOptions) {
- const value = obj[key]
- const ciName = ciInfo.name?.toLowerCase().split(' ').join('-') || null
- let inWorkspaces = false
- if (obj.workspaces || obj.workspace && obj.workspace.length) {
- inWorkspaces = true
- }
- flatOptions.userAgent =
- value.replace(/\{node-version\}/gi, process.version)
- .replace(/\{npm-version\}/gi, obj['npm-version'])
- .replace(/\{platform\}/gi, process.platform)
- .replace(/\{arch\}/gi, process.arch)
- .replace(/\{workspaces\}/gi, inWorkspaces)
- .replace(/\{ci\}/gi, ciName ? `ci/${ciName}` : '')
- .trim()
-
- // We can't clobber the original or else subsequent flattening will fail
- // (i.e. when we change the underlying config values)
- // obj[key] = flatOptions.userAgent
-
- // user-agent is a unique kind of config item that gets set from a template
- // and ends up translated. Because of this, the normal "should we set this
- // to process.env also doesn't work
- process.env.npm_config_user_agent = flatOptions.userAgent
- },
-})
-
-define('userconfig', {
- default: '~/.npmrc',
- type: path,
- description: `
- The location of user-level configuration settings.
-
- This may be overridden by the \`npm_config_userconfig\` environment
- variable or the \`--userconfig\` command line option, but may _not_
- be overridden by settings in the \`globalconfig\` file.
- `,
-})
-
-define('version', {
- default: false,
- type: Boolean,
- short: 'v',
- description: `
- If true, output the npm version and exit successfully.
-
- Only relevant when specified explicitly on the command line.
- `,
-})
-
-define('versions', {
- default: false,
- type: Boolean,
- description: `
- If true, output the npm version as well as node's \`process.versions\`
- map and the version in the current working directory's \`package.json\`
- file if one exists, and exit successfully.
+ if (flatOptions.saveType === 'peerOptional') {
+ return
+ }
- Only relevant when specified explicitly on the command line.
- `,
-})
+ if (flatOptions.saveType === 'optional') {
+ flatOptions.saveType = 'peerOptional'
+ } else {
+ flatOptions.saveType = 'peer'
+ }
+ },
+ }),
+ 'save-prefix': new Definition('save-prefix', {
+ default: '^',
+ type: String,
+ description: `
+ Configure how versions of packages installed to a package.json file via
+ \`--save\` or \`--save-dev\` get prefixed.
+
+ For example if a package has version \`1.2.3\`, by default its version is
+ set to \`^1.2.3\` which allows minor upgrades for that package, but after
+ \`npm config set save-prefix='~'\` it would be set to \`~1.2.3\` which
+ only allows patch upgrades.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.savePrefix = obj['save-exact'] ? '' : obj['save-prefix']
+ obj['save-prefix'] = flatOptions.savePrefix
+ },
+ }),
+ 'save-prod': new Definition('save-prod', {
+ default: false,
+ type: Boolean,
+ short: 'P',
+ description: `
+ Save installed packages into \`dependencies\` specifically. This is
+ useful if a package already exists in \`devDependencies\` or
+ \`optionalDependencies\`, but you want to move it to be a non-optional
+ production dependency.
+
+ This is the default behavior if \`--save\` is true, and neither
+ \`--save-dev\` or \`--save-optional\` are true.
+ `,
+ flatten (key, obj, flatOptions) {
+ if (!obj[key]) {
+ if (flatOptions.saveType === 'prod') {
+ delete flatOptions.saveType
+ }
+ return
+ }
-define('viewer', {
- default: isWindows ? 'browser' : 'man',
- defaultDescription: `
- "man" on Posix, "browser" on Windows
- `,
- type: String,
- description: `
- The program to use to view help content.
+ flatOptions.saveType = 'prod'
+ },
+ }),
+ 'sbom-format': new Definition('sbom-format', {
+ default: null,
+ type: [
+ 'cyclonedx',
+ 'spdx',
+ ],
+ description: `
+ SBOM format to use when generating SBOMs.
+ `,
+ flatten,
+ }),
+ 'sbom-type': new Definition('sbom-type', {
+ default: 'library',
+ type: [
+ 'library',
+ 'application',
+ 'framework',
+ ],
+ description: `
+ The type of package described by the generated SBOM. For SPDX, this is the
+ value for the \`primaryPackagePurpose\` field. For CycloneDX, this is the
+ value for the \`type\` field.
+ `,
+ flatten,
+ }),
+ scope: new Definition('scope', {
+ default: '',
+ defaultDescription: `
+ the scope of the current project, if any, or ""
+ `,
+ type: String,
+ hint: '<@scope>',
+ description: `
+ Associate an operation with a scope for a scoped registry.
+
+ Useful when logging in to or out of a private registry:
+
+ \`\`\`
+ # log in, linking the scope to the custom registry
+ npm login --scope=@mycorp --registry=https://registry.mycorp.com
+
+ # log out, removing the link and the auth token
+ npm logout --scope=@mycorp
+ \`\`\`
+
+ This will cause \`@mycorp\` to be mapped to the registry for future
+ installation of packages specified according to the pattern
+ \`@mycorp/package\`.
+
+ This will also cause \`npm init\` to create a scoped package.
+
+ \`\`\`
+ # accept all defaults, and create a package named "@foo/whatever",
+ # instead of just named "whatever"
+ npm init --scope=@foo --yes
+ \`\`\`
+ `,
+ flatten (key, obj, flatOptions) {
+ const value = obj[key]
+ const scope = value && !/^@/.test(value) ? `@${value}` : value
+ flatOptions.scope = scope
+ // projectScope is kept for compatibility with npm-registry-fetch
+ flatOptions.projectScope = scope
+ },
+ }),
+ 'script-shell': new Definition('script-shell', {
+ default: null,
+ defaultDescription: `
+ '/bin/sh' on POSIX systems, 'cmd.exe' on Windows
+ `,
+ type: [null, String],
+ description: `
+ The shell to use for scripts run with the \`npm exec\`,
+ \`npm run\` and \`npm init \` commands.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.scriptShell = obj[key] || undefined
+ },
+ }),
+ searchexclude: new Definition('searchexclude', {
+ default: '',
+ type: String,
+ description: `
+ Space-separated options that limit the results from search.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.search = flatOptions.search || { limit: 20 }
+ flatOptions.search.exclude = obj[key].toLowerCase()
+ },
+ }),
+ searchlimit: new Definition('searchlimit', {
+ default: 20,
+ type: Number,
+ description: `
+ Number of items to limit search results to. Will not apply at all to
+ legacy searches.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.search = flatOptions.search || {}
+ flatOptions.search.limit = obj[key]
+ },
+ }),
+ searchopts: new Definition('searchopts', {
+ default: '',
+ type: String,
+ description: `
+ Space-separated options that are always passed to search.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.search = flatOptions.search || { limit: 20 }
+ flatOptions.search.opts = querystring.parse(obj[key])
+ },
+ }),
+ searchstaleness: new Definition('searchstaleness', {
+ default: 15 * 60,
+ type: Number,
+ description: `
+ The age of the cache, in seconds, before another registry request is made
+ if using legacy search endpoint.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.search = flatOptions.search || { limit: 20 }
+ flatOptions.search.staleness = obj[key]
+ },
+ }),
+ shell: new Definition('shell', {
+ default: shell,
+ defaultDescription: `
+ SHELL environment variable, or "bash" on Posix, or "cmd.exe" on Windows
+ `,
+ type: String,
+ description: `
+ The shell to run for the \`npm explore\` command.
+ `,
+ flatten,
+ }),
+ shrinkwrap: new Definition('shrinkwrap', {
+ default: true,
+ type: Boolean,
+ deprecated: `
+ Use the --package-lock setting instead.
+ `,
+ description: `
+ Alias for --package-lock
+ `,
+ flatten (key, obj, flatOptions) {
+ obj['package-lock'] = obj.shrinkwrap
+ definitions['package-lock'].flatten('package-lock', obj, flatOptions)
+ },
+ }),
+ 'sign-git-commit': new Definition('sign-git-commit', {
+ default: false,
+ type: Boolean,
+ description: `
+ If set to true, then the \`npm version\` command will commit the new
+ package version using \`-S\` to add a signature.
+
+ Note that git requires you to have set up GPG keys in your git configs
+ for this to work properly.
+ `,
+ flatten,
+ }),
+ 'sign-git-tag': new Definition('sign-git-tag', {
+ default: false,
+ type: Boolean,
+ description: `
+ If set to true, then the \`npm version\` command will tag the version
+ using \`-s\` to add a signature.
+
+ Note that git requires you to have set up GPG keys in your git configs
+ for this to work properly.
+ `,
+ flatten,
+ }),
+ 'strict-peer-deps': new Definition('strict-peer-deps', {
+ default: false,
+ type: Boolean,
+ description: `
+ If set to \`true\`, and \`--legacy-peer-deps\` is not set, then _any_
+ conflicting \`peerDependencies\` will be treated as an install failure,
+ even if npm could reasonably guess the appropriate resolution based on
+ non-peer dependency relationships.
+
+ By default, conflicting \`peerDependencies\` deep in the dependency graph
+ will be resolved using the nearest non-peer dependency specification,
+ even if doing so will result in some packages receiving a peer dependency
+ outside the range set in their package's \`peerDependencies\` object.
+
+ When such an override is performed, a warning is printed, explaining the
+ conflict and the packages involved. If \`--strict-peer-deps\` is set,
+ then this warning is treated as a failure.
+ `,
+ flatten,
+ }),
+ 'strict-ssl': new Definition('strict-ssl', {
+ default: true,
+ type: Boolean,
+ description: `
+ Whether or not to do SSL key validation when making requests to the
+ registry via https.
+
+ See also the \`ca\` config.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.strictSSL = obj[key]
+ },
+ }),
+ tag: new Definition('tag', {
+ default: 'latest',
+ type: String,
+ description: `
+ If you ask npm to install a package and don't tell it a specific version,
+ then it will install the specified tag.
+
+ Also the tag that is added to the package@version specified by the \`npm
+ tag\` command, if no explicit tag is given.
+
+ When used by the \`npm diff\` command, this is the tag used to fetch the
+ tarball that will be compared with the local files by default.
+ `,
+ flatten (key, obj, flatOptions) {
+ flatOptions.defaultTag = obj[key]
+ },
+ }),
+ 'tag-version-prefix': new Definition('tag-version-prefix', {
+ default: 'v',
+ type: String,
+ description: `
+ If set, alters the prefix used when tagging a new version when performing
+ a version increment using \`npm version\`. To remove the prefix
+ altogether, set it to the empty string: \`""\`.
+
+ Because other tools may rely on the convention that npm version tags look
+ like \`v1.0.0\`, _only use this property if it is absolutely necessary_.
+ In particular, use care when overriding this setting for public packages.
+ `,
+ flatten,
+ }),
+ timing: new Definition('timing', {
+ default: false,
+ type: Boolean,
+ description: `
+ If true, writes timing information to a process specific json file in
+ the cache or \`logs-dir\`. The file name ends with \`-timing.json\`.
+
+ You can quickly view it with this [json](https://npm.im/json) command
+ line: \`cat ~/.npm/_logs/*-timing.json | npm exec -- json -g\`.
+
+ Timing information will also be reported in the terminal. To suppress this
+ while still writing the timing file, use \`--silent\`.
+ `,
+ }),
+ umask: new Definition('umask', {
+ default: 0,
+ type: Umask,
+ description: `
+ The "umask" value to use when setting the file creation mode on files and
+ folders.
+
+ Folders and executables are given a mode which is \`0o777\` masked
+ against this value. Other files are given a mode which is \`0o666\`
+ masked against this value.
+
+ Note that the underlying system will _also_ apply its own umask value to
+ files and folders that are created, and npm does not circumvent this, but
+ rather adds the \`--umask\` config to it.
+
+ Thus, the effective default umask value on most POSIX systems is 0o22,
+ meaning that folders and executables are created with a mode of 0o755 and
+ other files are created with a mode of 0o644.
+ `,
+ flatten,
+ }),
+ unicode: new Definition('unicode', {
+ default: unicode,
+ defaultDescription: `
+ false on windows, true on mac/unix systems with a unicode locale, as
+ defined by the \`LC_ALL\`, \`LC_CTYPE\`, or \`LANG\` environment variables.
+ `,
+ type: Boolean,
+ description: `
+ When set to true, npm uses unicode characters in the tree output. When
+ false, it uses ascii characters instead of unicode glyphs.
+ `,
+ flatten,
+ }),
+ 'update-notifier': new Definition('update-notifier', {
+ default: true,
+ type: Boolean,
+ description: `
+ Set to false to suppress the update notification when using an older
+ version of npm than the latest.
+ `,
+ }),
+ usage: new Definition('usage', {
+ default: false,
+ type: Boolean,
+ short: ['?', 'H', 'h'],
+ description: `
+ Show short usage output about the command specified.
+ `,
+ }),
+ 'user-agent': new Definition('user-agent', {
+ default: 'npm/{npm-version} ' +
+ 'node/{node-version} ' +
+ '{platform} ' +
+ '{arch} ' +
+ 'workspaces/{workspaces} ' +
+ '{ci}',
+ type: String,
+ description: `
+ Sets the User-Agent request header. The following fields are replaced
+ with their actual counterparts:
+
+ * \`{npm-version}\` - The npm version in use
+ * \`{node-version}\` - The Node.js version in use
+ * \`{platform}\` - The value of \`process.platform\`
+ * \`{arch}\` - The value of \`process.arch\`
+ * \`{workspaces}\` - Set to \`true\` if the \`workspaces\` or \`workspace\`
+ options are set.
+ * \`{ci}\` - The value of the \`ci-name\` config, if set, prefixed with
+ \`ci/\`, or an empty string if \`ci-name\` is empty.
+ `,
+ flatten (key, obj, flatOptions) {
+ const value = obj[key]
+ const ciName = ciInfo.name?.toLowerCase().split(' ').join('-') || null
+ let inWorkspaces = false
+ if (obj.workspaces || obj.workspace && obj.workspace.length) {
+ inWorkspaces = true
+ }
+ flatOptions.userAgent =
+ value.replace(/\{node-version\}/gi, process.version)
+ .replace(/\{npm-version\}/gi, obj['npm-version'])
+ .replace(/\{platform\}/gi, process.platform)
+ .replace(/\{arch\}/gi, process.arch)
+ .replace(/\{workspaces\}/gi, inWorkspaces)
+ .replace(/\{ci\}/gi, ciName ? `ci/${ciName}` : '')
+ .trim()
+
+ // We can't clobber the original or else subsequent flattening will fail
+ // (i.e. when we change the underlying config values)
+ // obj[key] = flatOptions.userAgent
+
+ // user-agent is a unique kind of config item that gets set from a template
+ // and ends up translated. Because of this, the normal "should we set this
+ // to process.env also doesn't work
+ process.env.npm_config_user_agent = flatOptions.userAgent
+ },
+ }),
+ userconfig: new Definition('userconfig', {
+ default: '~/.npmrc',
+ type: path,
+ description: `
+ The location of user-level configuration settings.
+
+ This may be overridden by the \`npm_config_userconfig\` environment
+ variable or the \`--userconfig\` command line option, but may _not_
+ be overridden by settings in the \`globalconfig\` file.
+ `,
+ }),
+ version: new Definition('version', {
+ default: false,
+ type: Boolean,
+ short: 'v',
+ description: `
+ If true, output the npm version and exit successfully.
+
+ Only relevant when specified explicitly on the command line.
+ `,
+ }),
+ versions: new Definition('versions', {
+ default: false,
+ type: Boolean,
+ description: `
+ If true, output the npm version as well as node's \`process.versions\`
+ map and the version in the current working directory's \`package.json\`
+ file if one exists, and exit successfully.
+
+ Only relevant when specified explicitly on the command line.
+ `,
+ }),
+ viewer: new Definition('viewer', {
+ default: isWindows ? 'browser' : 'man',
+ defaultDescription: `
+ "man" on Posix, "browser" on Windows
+ `,
+ type: String,
+ description: `
+ The program to use to view help content.
+
+ Set to \`"browser"\` to view html help content in the default web browser.
+ `,
+ }),
+ which: new Definition('which', {
+ default: null,
+ hint: '',
+ type: [null, Number],
+ description: `
+ If there are multiple funding sources, which 1-indexed source URL to open.
+ `,
+ }),
+ workspace: new Definition('workspace', {
+ default: [],
+ type: [String, Array],
+ hint: '',
+ short: 'w',
+ envExport: false,
+ description: `
+ Enable running a command in the context of the configured workspaces of the
+ current project while filtering by running only the workspaces defined by
+ this configuration option.
+
+ Valid values for the \`workspace\` config are either:
+
+ * Workspace names
+ * Path to a workspace directory
+ * Path to a parent workspace directory (will result in selecting all
+ workspaces within that folder)
+
+ When set for the \`npm init\` command, this may be set to the folder of
+ a workspace which does not yet exist, to create the folder and set it
+ up as a brand new workspace within the project.
+ `,
+ flatten: (key, obj, flatOptions) => {
+ definitions['user-agent'].flatten('user-agent', obj, flatOptions)
+ },
+ }),
+ workspaces: new Definition('workspaces', {
+ default: null,
+ type: [null, Boolean],
+ short: 'ws',
+ envExport: false,
+ description: `
+ Set to true to run the command in the context of **all** configured
+ workspaces.
+
+ Explicitly setting this to false will cause commands like \`install\` to
+ ignore workspaces altogether.
+ When not set explicitly:
+
+ - Commands that operate on the \`node_modules\` tree (install, update,
+ etc.) will link workspaces into the \`node_modules\` folder.
+ - Commands that do other things (test, exec, publish, etc.) will operate
+ on the root project, _unless_ one or more workspaces are specified in
+ the \`workspace\` config.
+ `,
+ flatten: (key, obj, flatOptions) => {
+ definitions['user-agent'].flatten('user-agent', obj, flatOptions)
+
+ // TODO: this is a derived value, and should be reworked when we have a
+ // pattern for derived value
+
+ // workspacesEnabled is true whether workspaces is null or true
+ // commands contextually work with workspaces or not regardless of
+ // configuration, so we need an option specifically to disable workspaces
+ flatOptions.workspacesEnabled = obj[key] !== false
+ },
+ }),
+ 'workspaces-update': new Definition('workspaces-update', {
+ default: true,
+ type: Boolean,
+ description: `
+ If set to true, the npm cli will run an update after operations that may
+ possibly change the workspaces installed to the \`node_modules\` folder.
+ `,
+ flatten,
+ }),
+ yes: new Definition('yes', {
+ default: null,
+ type: [null, Boolean],
+ short: 'y',
+ description: `
+ Automatically answer "yes" to any prompts that npm might print on
+ the command line.
+ `,
+ }),
+}
- Set to \`"browser"\` to view html help content in the default web browser.
- `,
-})
-
-define('which', {
- default: null,
- hint: '',
- type: [null, Number],
- description: `
- If there are multiple funding sources, which 1-indexed source URL to open.
- `,
-})
-
-define('workspace', {
- default: [],
- type: [String, Array],
- hint: '',
- short: 'w',
- envExport: false,
- description: `
- Enable running a command in the context of the configured workspaces of the
- current project while filtering by running only the workspaces defined by
- this configuration option.
-
- Valid values for the \`workspace\` config are either:
-
- * Workspace names
- * Path to a workspace directory
- * Path to a parent workspace directory (will result in selecting all
- workspaces within that folder)
-
- When set for the \`npm init\` command, this may be set to the folder of
- a workspace which does not yet exist, to create the folder and set it
- up as a brand new workspace within the project.
- `,
- flatten: (key, obj, flatOptions) => {
- definitions['user-agent'].flatten('user-agent', obj, flatOptions)
- },
-})
-
-define('workspaces', {
- default: null,
- type: [null, Boolean],
- short: 'ws',
- envExport: false,
- description: `
- Set to true to run the command in the context of **all** configured
- workspaces.
-
- Explicitly setting this to false will cause commands like \`install\` to
- ignore workspaces altogether.
- When not set explicitly:
-
- - Commands that operate on the \`node_modules\` tree (install, update,
- etc.) will link workspaces into the \`node_modules\` folder.
- - Commands that do other things (test, exec, publish, etc.) will operate
- on the root project, _unless_ one or more workspaces are specified in
- the \`workspace\` config.
- `,
- flatten: (key, obj, flatOptions) => {
- definitions['user-agent'].flatten('user-agent', obj, flatOptions)
-
- // TODO: this is a derived value, and should be reworked when we have a
- // pattern for derived value
-
- // workspacesEnabled is true whether workspaces is null or true
- // commands contextually work with workspaces or not regardless of
- // configuration, so we need an option specifically to disable workspaces
- flatOptions.workspacesEnabled = obj[key] !== false
- },
-})
-
-define('workspaces-update', {
- default: true,
- type: Boolean,
- description: `
- If set to true, the npm cli will run an update after operations that may
- possibly change the workspaces installed to the \`node_modules\` folder.
- `,
- flatten,
-})
-
-define('yes', {
- default: null,
- type: [null, Boolean],
- short: 'y',
- description: `
- Automatically answer "yes" to any prompts that npm might print on
- the command line.
- `,
-})
+module.exports = definitions
diff --git a/deps/npm/node_modules/@npmcli/config/lib/index.js b/deps/npm/node_modules/@npmcli/config/lib/index.js
index b09ecc478f64fd..1ff19c128696ca 100644
--- a/deps/npm/node_modules/@npmcli/config/lib/index.js
+++ b/deps/npm/node_modules/@npmcli/config/lib/index.js
@@ -2,12 +2,10 @@
const { walkUp } = require('walk-up-path')
const ini = require('ini')
const nopt = require('nopt')
-const mapWorkspaces = require('@npmcli/map-workspaces')
-const rpj = require('read-package-json-fast')
const log = require('proc-log')
-const { resolve, dirname, join } = require('path')
-const { homedir } = require('os')
+const { resolve, dirname, join } = require('node:path')
+const { homedir } = require('node:os')
const {
readFile,
writeFile,
@@ -28,35 +26,12 @@ const dirExists = (...p) => stat(resolve(...p))
const hasOwnProperty = (obj, key) =>
Object.prototype.hasOwnProperty.call(obj, key)
-// define a custom getter, but turn into a normal prop
-// if we set it. otherwise it can't be set on child objects
-const settableGetter = (obj, key, get) => {
- Object.defineProperty(obj, key, {
- get,
- set (value) {
- Object.defineProperty(obj, key, {
- value,
- configurable: true,
- writable: true,
- enumerable: true,
- })
- },
- configurable: true,
- enumerable: true,
- })
-}
-
const typeDefs = require('./type-defs.js')
const nerfDart = require('./nerf-dart.js')
const envReplace = require('./env-replace.js')
const parseField = require('./parse-field.js')
-const typeDescription = require('./type-description.js')
const setEnvs = require('./set-envs.js')
-const {
- ErrInvalidAuth,
-} = require('./errors.js')
-
// types that can be saved back to
const confFileTypes = new Set([
'global',
@@ -329,7 +304,21 @@ class Config {
// default the globalconfig file to that location, instead of the default
// global prefix. It's weird that `npm get globalconfig --prefix=/foo`
// returns `/foo/etc/npmrc`, but better to not change it at this point.
- settableGetter(data, 'globalconfig', () => resolve(this.#get('prefix'), 'etc/npmrc'))
+ // define a custom getter, but turn into a normal prop
+ // if we set it. otherwise it can't be set on child objects
+ Object.defineProperty(data, 'globalconfig', {
+ get: () => resolve(this.#get('prefix'), 'etc/npmrc'),
+ set (value) {
+ Object.defineProperty(data, 'globalconfig', {
+ value,
+ configurable: true,
+ writable: true,
+ enumerable: true,
+ })
+ },
+ configurable: true,
+ enumerable: true,
+ })
}
loadHome () {
@@ -444,6 +433,7 @@ class Config {
}
if (authProblems.length) {
+ const { ErrInvalidAuth } = require('./errors.js')
throw new ErrInvalidAuth(authProblems)
}
@@ -512,6 +502,7 @@ class Config {
}
invalidHandler (k, val, type, source, where) {
+ const typeDescription = require('./type-description.js')
log.warn(
'invalid config',
k + '=' + JSON.stringify(val),
@@ -696,6 +687,7 @@ class Config {
}
if (this.localPrefix && hasPackageJson) {
+ const rpj = require('read-package-json-fast')
// if we already set localPrefix but this dir has a package.json
// then we need to see if `p` is a workspace root by reading its package.json
// however, if reading it fails then we should just move on
@@ -704,6 +696,7 @@ class Config {
continue
}
+ const mapWorkspaces = require('@npmcli/map-workspaces')
const workspaces = await mapWorkspaces({ cwd: p, pkg })
for (const w of workspaces.values()) {
if (w === this.localPrefix) {
diff --git a/deps/npm/node_modules/@npmcli/config/lib/nerf-dart.js b/deps/npm/node_modules/@npmcli/config/lib/nerf-dart.js
index d6ae4aa2aa7e2a..030d92a82270d2 100644
--- a/deps/npm/node_modules/@npmcli/config/lib/nerf-dart.js
+++ b/deps/npm/node_modules/@npmcli/config/lib/nerf-dart.js
@@ -1,4 +1,4 @@
-const { URL } = require('url')
+const { URL } = require('node:url')
/**
* Maps a URL to an identifier.
diff --git a/deps/npm/node_modules/@npmcli/config/lib/parse-field.js b/deps/npm/node_modules/@npmcli/config/lib/parse-field.js
index 099b0b4eaf1a83..9ac3d21cae8b71 100644
--- a/deps/npm/node_modules/@npmcli/config/lib/parse-field.js
+++ b/deps/npm/node_modules/@npmcli/config/lib/parse-field.js
@@ -1,7 +1,7 @@
// Parse a field, coercing it to the best type available.
const typeDefs = require('./type-defs.js')
const envReplace = require('./env-replace.js')
-const { resolve } = require('path')
+const { resolve } = require('node:path')
const { parse: umaskParse } = require('./umask.js')
diff --git a/deps/npm/node_modules/@npmcli/config/lib/type-defs.js b/deps/npm/node_modules/@npmcli/config/lib/type-defs.js
index 20a827c3d164e9..3c9dfe19ded113 100644
--- a/deps/npm/node_modules/@npmcli/config/lib/type-defs.js
+++ b/deps/npm/node_modules/@npmcli/config/lib/type-defs.js
@@ -1,10 +1,12 @@
const nopt = require('nopt')
-const { Umask, validate: validateUmask } = require('./umask.js')
+const { validate: validateUmask } = require('./umask.js')
-const semver = require('semver')
+class Umask {}
+class Semver {}
+const semverValid = require('semver/functions/valid')
const validateSemver = (data, k, val) => {
- const valid = semver.valid(val)
+ const valid = semverValid(val)
if (!valid) {
return false
}
@@ -23,7 +25,7 @@ const validatePath = (data, k, val) => {
module.exports = {
...nopt.typeDefs,
semver: {
- type: semver,
+ type: Semver,
validate: validateSemver,
description: 'full valid SemVer string',
},
diff --git a/deps/npm/node_modules/@npmcli/config/lib/umask.js b/deps/npm/node_modules/@npmcli/config/lib/umask.js
index 4d9ebbdc965451..2ddc5ca7822326 100644
--- a/deps/npm/node_modules/@npmcli/config/lib/umask.js
+++ b/deps/npm/node_modules/@npmcli/config/lib/umask.js
@@ -1,4 +1,3 @@
-class Umask {}
const parse = val => {
// this is run via nopt and parse field where everything is
// converted to a string first, ignoring coverage for now
@@ -33,4 +32,4 @@ const validate = (data, k, val) => {
}
}
-module.exports = { Umask, parse, validate }
+module.exports = { parse, validate }
diff --git a/deps/npm/node_modules/@npmcli/config/package.json b/deps/npm/node_modules/@npmcli/config/package.json
index b5c73e1b13a9b1..797c32f7ee4a63 100644
--- a/deps/npm/node_modules/@npmcli/config/package.json
+++ b/deps/npm/node_modules/@npmcli/config/package.json
@@ -1,6 +1,6 @@
{
"name": "@npmcli/config",
- "version": "8.2.1",
+ "version": "8.2.2",
"files": [
"bin/",
"lib/"
diff --git a/deps/npm/node_modules/@npmcli/git/lib/is.js b/deps/npm/node_modules/@npmcli/git/lib/is.js
index e2542f21577272..f5a0e8754f10dc 100644
--- a/deps/npm/node_modules/@npmcli/git/lib/is.js
+++ b/deps/npm/node_modules/@npmcli/git/lib/is.js
@@ -1,6 +1,4 @@
// not an airtight indicator, but a good gut-check to even bother trying
-const { promisify } = require('util')
-const fs = require('fs')
-const stat = promisify(fs.stat)
+const { stat } = require('fs/promises')
module.exports = ({ cwd = process.cwd() } = {}) =>
stat(cwd + '/.git').then(() => true, () => false)
diff --git a/deps/npm/node_modules/@npmcli/git/package.json b/deps/npm/node_modules/@npmcli/git/package.json
index 485c1f43dddb90..7493ec7fb0effb 100644
--- a/deps/npm/node_modules/@npmcli/git/package.json
+++ b/deps/npm/node_modules/@npmcli/git/package.json
@@ -1,6 +1,6 @@
{
"name": "@npmcli/git",
- "version": "5.0.4",
+ "version": "5.0.5",
"main": "lib/index.js",
"files": [
"bin/",
diff --git a/deps/npm/node_modules/@npmcli/map-workspaces/lib/index.js b/deps/npm/node_modules/@npmcli/map-workspaces/lib/index.js
index 501dad870a2b75..b20bf5de5d631e 100644
--- a/deps/npm/node_modules/@npmcli/map-workspaces/lib/index.js
+++ b/deps/npm/node_modules/@npmcli/map-workspaces/lib/index.js
@@ -5,23 +5,49 @@ const { minimatch } = require('minimatch')
const rpj = require('read-package-json-fast')
const { glob } = require('glob')
-function appendNegatedPatterns (patterns) {
- const results = []
- for (let pattern of patterns) {
+function appendNegatedPatterns (allPatterns) {
+ const patterns = []
+ const negatedPatterns = []
+ for (let pattern of allPatterns) {
const excl = pattern.match(/^!+/)
if (excl) {
pattern = pattern.slice(excl[0].length)
}
- // strip off any / from the start of the pattern. /foo => foo
- pattern = pattern.replace(/^\/+/, '')
+ // strip off any / or ./ from the start of the pattern. /foo => foo
+ pattern = pattern.replace(/^\.?\/+/, '')
// an odd number of ! means a negated pattern. !!foo ==> foo
const negate = excl && excl[0].length % 2 === 1
- results.push({ pattern, negate })
+ if (negate) {
+ negatedPatterns.push(pattern)
+ } else {
+ // remove negated patterns that appeared before this pattern to avoid
+ // ignoring paths that were matched afterwards
+ // e.g: ['packages/**', '!packages/b/**', 'packages/b/a']
+ // in the above list, the last pattern overrides the negated pattern
+ // right before it. In effect, the above list would become:
+ // ['packages/**', 'packages/b/a']
+ // The order matters here which is why we must do it inside the loop
+ // as opposed to doing it all together at the end.
+ for (let i = 0; i < negatedPatterns.length; ++i) {
+ const negatedPattern = negatedPatterns[i]
+ if (minimatch(pattern, negatedPattern)) {
+ negatedPatterns.splice(i, 1)
+ }
+ }
+ patterns.push(pattern)
+ }
}
- return results
+ // use the negated patterns to eagerly remove all the patterns that
+ // can be removed to avoid unnecessary crawling
+ for (const negated of negatedPatterns) {
+ for (const pattern of minimatch.match(patterns, negated)) {
+ patterns.splice(patterns.indexOf(pattern), 1)
+ }
+ }
+ return { patterns, negatedPatterns }
}
function getPatterns (workspaces) {
@@ -77,11 +103,11 @@ async function mapWorkspaces (opts = {}) {
}
const { workspaces = [] } = opts.pkg
- const patterns = getPatterns(workspaces)
+ const { patterns, negatedPatterns } = getPatterns(workspaces)
const results = new Map()
const seen = new Map()
- if (!patterns.length) {
+ if (!patterns.length && !negatedPatterns.length) {
return results
}
@@ -89,52 +115,54 @@ async function mapWorkspaces (opts = {}) {
...opts,
ignore: [
...opts.ignore || [],
- ...['**/node_modules/**'],
+ '**/node_modules/**',
+ // just ignore the negated patterns to avoid unnecessary crawling
+ ...negatedPatterns,
],
})
const getPackagePathname = pkgPathmame(opts)
- for (const item of patterns) {
- let matches = await glob(getGlobPattern(item.pattern), getGlobOpts())
- // preserves glob@8 behavior
- matches = matches.sort((a, b) => a.localeCompare(b, 'en'))
-
- for (const match of matches) {
- let pkg
- const packageJsonPathname = getPackagePathname(match, 'package.json')
- const packagePathname = path.dirname(packageJsonPathname)
-
- try {
- pkg = await rpj(packageJsonPathname)
- } catch (err) {
- if (err.code === 'ENOENT') {
- continue
- } else {
- throw err
- }
- }
+ let matches = await glob(patterns.map((p) => getGlobPattern(p)), getGlobOpts())
+ // preserves glob@8 behavior
+ matches = matches.sort((a, b) => a.localeCompare(b, 'en'))
+
+ // we must preserve the order of results according to the given list of
+ // workspace patterns
+ const orderedMatches = []
+ for (const pattern of patterns) {
+ orderedMatches.push(...matches.filter((m) => {
+ return minimatch(m, pattern, { partial: true, windowsPathsNoEscape: true })
+ }))
+ }
- const name = getPackageName(pkg, packagePathname)
+ for (const match of orderedMatches) {
+ let pkg
+ const packageJsonPathname = getPackagePathname(match, 'package.json')
- let seenPackagePathnames = seen.get(name)
- if (!seenPackagePathnames) {
- seenPackagePathnames = new Set()
- seen.set(name, seenPackagePathnames)
- }
- if (item.negate) {
- seenPackagePathnames.delete(packagePathname)
+ try {
+ pkg = await rpj(packageJsonPathname)
+ } catch (err) {
+ if (err.code === 'ENOENT') {
+ continue
} else {
- seenPackagePathnames.add(packagePathname)
+ throw err
}
}
+
+ const packagePathname = path.dirname(packageJsonPathname)
+ const name = getPackageName(pkg, packagePathname)
+
+ let seenPackagePathnames = seen.get(name)
+ if (!seenPackagePathnames) {
+ seenPackagePathnames = new Set()
+ seen.set(name, seenPackagePathnames)
+ }
+ seenPackagePathnames.add(packagePathname)
}
const errorMessageArray = ['must not have multiple workspaces with the same name']
for (const [packageName, seenPackagePathnames] of seen) {
- if (seenPackagePathnames.size === 0) {
- continue
- }
if (seenPackagePathnames.size > 1) {
addDuplicateErrorMessages(errorMessageArray, packageName, seenPackagePathnames)
} else {
@@ -177,30 +205,25 @@ mapWorkspaces.virtual = function (opts = {}) {
const { workspaces = [] } = packages[''] || {}
// uses a pathname-keyed map in order to negate the exact items
const results = new Map()
- const patterns = getPatterns(workspaces)
- if (!patterns.length) {
+ const { patterns, negatedPatterns } = getPatterns(workspaces)
+ if (!patterns.length && !negatedPatterns.length) {
return results
}
- patterns.push({ pattern: '**/node_modules/**', negate: true })
-
- const getPackagePathname = pkgPathmame(opts)
+ negatedPatterns.push('**/node_modules/**')
- for (const packageKey of Object.keys(packages)) {
- if (packageKey === '') {
- continue
+ const packageKeys = Object.keys(packages)
+ for (const pattern of negatedPatterns) {
+ for (const packageKey of minimatch.match(packageKeys, pattern)) {
+ packageKeys.splice(packageKeys.indexOf(packageKey), 1)
}
+ }
- for (const item of patterns) {
- if (minimatch(packageKey, item.pattern)) {
- const packagePathname = getPackagePathname(packageKey)
- const name = getPackageName(packages[packageKey], packagePathname)
-
- if (item.negate) {
- results.delete(packagePathname)
- } else {
- results.set(packagePathname, name)
- }
- }
+ const getPackagePathname = pkgPathmame(opts)
+ for (const pattern of patterns) {
+ for (const packageKey of minimatch.match(packageKeys, pattern)) {
+ const packagePathname = getPackagePathname(packageKey)
+ const name = getPackageName(packages[packageKey], packagePathname)
+ results.set(packagePathname, name)
}
}
diff --git a/deps/npm/node_modules/@npmcli/map-workspaces/package.json b/deps/npm/node_modules/@npmcli/map-workspaces/package.json
index 64cb7f9d3f1177..e6292b06bd2b43 100644
--- a/deps/npm/node_modules/@npmcli/map-workspaces/package.json
+++ b/deps/npm/node_modules/@npmcli/map-workspaces/package.json
@@ -1,6 +1,6 @@
{
"name": "@npmcli/map-workspaces",
- "version": "3.0.4",
+ "version": "3.0.6",
"main": "lib/index.js",
"files": [
"bin/",
@@ -25,7 +25,7 @@
"author": "GitHub Inc.",
"license": "ISC",
"scripts": {
- "lint": "eslint \"**/*.js\"",
+ "lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"pretest": "npm run lint",
"test": "tap",
"snap": "tap",
@@ -43,7 +43,7 @@
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
- "@npmcli/template-oss": "4.14.1",
+ "@npmcli/template-oss": "4.21.3",
"tap": "^16.0.1"
},
"dependencies": {
@@ -54,7 +54,7 @@
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
- "version": "4.14.1",
+ "version": "4.21.3",
"publish": "true"
}
}
diff --git a/deps/npm/node_modules/@npmcli/package-json/lib/normalize.js b/deps/npm/node_modules/@npmcli/package-json/lib/normalize.js
index 204d4d8a8e7dd6..350b3f3d7cb8f0 100644
--- a/deps/npm/node_modules/@npmcli/package-json/lib/normalize.js
+++ b/deps/npm/node_modules/@npmcli/package-json/lib/normalize.js
@@ -1,12 +1,30 @@
-const semver = require('semver')
+const valid = require('semver/functions/valid')
+const clean = require('semver/functions/clean')
const fs = require('fs/promises')
-const { glob } = require('glob')
-const legacyFixer = require('normalize-package-data/lib/fixer.js')
-const legacyMakeWarning = require('normalize-package-data/lib/make_warning.js')
const path = require('path')
const log = require('proc-log')
-const git = require('@npmcli/git')
-const hostedGitInfo = require('hosted-git-info')
+
+/**
+ * @type {import('hosted-git-info')}
+ */
+let _hostedGitInfo
+function lazyHostedGitInfo () {
+ if (!_hostedGitInfo) {
+ _hostedGitInfo = require('hosted-git-info')
+ }
+ return _hostedGitInfo
+}
+
+/**
+ * @type {import('glob').glob}
+ */
+let _glob
+function lazyLoadGlob () {
+ if (!_glob) {
+ _glob = require('glob').glob
+ }
+ return _glob
+}
// used to be npm-normalize-package-bin
function normalizePackageBin (pkg, changes) {
@@ -130,10 +148,10 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
if (!data.version) {
data.version = ''
} else {
- if (!semver.valid(data.version, loose)) {
+ if (!valid(data.version, loose)) {
throw new Error(`Invalid version: "${data.version}"`)
}
- const version = semver.clean(data.version, loose)
+ const version = clean(data.version, loose)
if (version !== data.version) {
changes?.push(`"version" was cleaned and set to "${version}"`)
data.version = version
@@ -208,7 +226,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
// add "install" attribute if any "*.gyp" files exist
if (steps.includes('gypfile')) {
if (!scripts.install && !scripts.preinstall && data.gypfile !== false) {
- const files = await glob('*.gyp', { cwd: pkg.path })
+ const files = await lazyLoadGlob()('*.gyp', { cwd: pkg.path })
if (files.length) {
scripts.install = 'node-gyp rebuild'
data.scripts = scripts
@@ -275,7 +293,11 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
// populate "readme" attribute
if (steps.includes('readme') && !data.readme) {
const mdre = /\.m?a?r?k?d?o?w?n?$/i
- const files = await glob('{README,README.*}', { cwd: pkg.path, nocase: true, mark: true })
+ const files = await lazyLoadGlob()('{README,README.*}', {
+ cwd: pkg.path,
+ nocase: true,
+ mark: true,
+ })
let readmeFile
for (const file of files) {
// don't accept directories.
@@ -306,7 +328,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
if (steps.includes('mans') && !data.man && data.directories?.man) {
const manDir = data.directories.man
const cwd = path.resolve(pkg.path, manDir)
- const files = await glob('**/*.[0-9]', { cwd })
+ const files = await lazyLoadGlob()('**/*.[0-9]', { cwd })
data.man = files.map(man =>
path.relative(pkg.path, path.join(cwd, man)).split(path.sep).join('/')
)
@@ -319,7 +341,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
// expand "directories.bin"
if (steps.includes('binDir') && data.directories?.bin && !data.bin) {
const binsDir = path.resolve(pkg.path, path.join('.', path.join('/', data.directories.bin)))
- const bins = await glob('**', { cwd: binsDir })
+ const bins = await lazyLoadGlob()('**', { cwd: binsDir })
data.bin = bins.reduce((acc, binFile) => {
if (binFile && !binFile.startsWith('.')) {
const binName = path.basename(binFile)
@@ -333,6 +355,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
// populate "gitHead" attribute
if (steps.includes('gitHead') && !data.gitHead) {
+ const git = require('@npmcli/git')
const gitRoot = await git.find({ cwd: pkg.path, root })
let head
if (gitRoot) {
@@ -446,7 +469,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
}
}
if (data.repository.url) {
- const hosted = hostedGitInfo.fromUrl(data.repository.url)
+ const hosted = lazyHostedGitInfo().fromUrl(data.repository.url)
let r
if (hosted) {
if (hosted.getDefaultRepresentation() === 'shortcut') {
@@ -506,7 +529,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
changes?.push(`Removed invalid "${deps}.${d}"`)
delete data[deps][d]
}
- const hosted = hostedGitInfo.fromUrl(data[deps][d])?.toString()
+ const hosted = lazyHostedGitInfo().fromUrl(data[deps][d])?.toString()
if (hosted && hosted !== data[deps][d]) {
changes?.push(`Normalized git reference to "${deps}.${d}"`)
data[deps][d] = hosted.toString()
@@ -518,6 +541,8 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
}
if (steps.includes('normalizeData')) {
+ const legacyFixer = require('normalize-package-data/lib/fixer.js')
+ const legacyMakeWarning = require('normalize-package-data/lib/make_warning.js')
legacyFixer.warn = function () {
changes?.push(legacyMakeWarning.apply(null, arguments))
}
diff --git a/deps/npm/node_modules/@npmcli/package-json/package.json b/deps/npm/node_modules/@npmcli/package-json/package.json
index ab320e8695ca3d..4f7a29d2e4c597 100644
--- a/deps/npm/node_modules/@npmcli/package-json/package.json
+++ b/deps/npm/node_modules/@npmcli/package-json/package.json
@@ -1,6 +1,6 @@
{
"name": "@npmcli/package-json",
- "version": "5.0.0",
+ "version": "5.0.2",
"description": "Programmatic API to update package.json",
"main": "lib/index.js",
"files": [
@@ -10,7 +10,7 @@
"scripts": {
"snap": "tap",
"test": "tap",
- "lint": "eslint \"**/*.js\"",
+ "lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"lintfix": "npm run lint -- --fix",
"posttest": "npm run lint",
"postsnap": "npm run lintfix --",
@@ -25,8 +25,8 @@
"license": "ISC",
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
- "@npmcli/template-oss": "4.18.0",
- "read-package-json": "^6.0.4",
+ "@npmcli/template-oss": "4.21.3",
+ "read-package-json": "^7.0.0",
"read-package-json-fast": "^3.0.2",
"tap": "^16.0.1"
},
@@ -48,14 +48,8 @@
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
- "version": "4.18.0",
- "publish": "true",
- "ciVersions": [
- "16.14.0",
- "16.x",
- "18.0.0",
- "18.x"
- ]
+ "version": "4.21.3",
+ "publish": "true"
},
"tap": {
"nyc-arg": [
diff --git a/deps/npm/node_modules/@sigstore/bundle/dist/build.js b/deps/npm/node_modules/@sigstore/bundle/dist/build.js
index 6990f5451a2d33..65c71b100ad58f 100644
--- a/deps/npm/node_modules/@sigstore/bundle/dist/build.js
+++ b/deps/npm/node_modules/@sigstore/bundle/dist/build.js
@@ -21,7 +21,9 @@ const bundle_1 = require("./bundle");
// Message signature bundle - $case: 'messageSignature'
function toMessageSignatureBundle(options) {
return {
- mediaType: bundle_1.BUNDLE_V02_MEDIA_TYPE,
+ mediaType: options.singleCertificate
+ ? bundle_1.BUNDLE_V03_MEDIA_TYPE
+ : bundle_1.BUNDLE_V02_MEDIA_TYPE,
content: {
$case: 'messageSignature',
messageSignature: {
@@ -39,7 +41,9 @@ exports.toMessageSignatureBundle = toMessageSignatureBundle;
// DSSE envelope bundle - $case: 'dsseEnvelope'
function toDSSEBundle(options) {
return {
- mediaType: bundle_1.BUNDLE_V02_MEDIA_TYPE,
+ mediaType: options.singleCertificate
+ ? bundle_1.BUNDLE_V03_MEDIA_TYPE
+ : bundle_1.BUNDLE_V02_MEDIA_TYPE,
content: {
$case: 'dsseEnvelope',
dsseEnvelope: toEnvelope(options),
@@ -71,12 +75,20 @@ function toVerificationMaterial(options) {
}
function toKeyContent(options) {
if (options.certificate) {
- return {
- $case: 'x509CertificateChain',
- x509CertificateChain: {
- certificates: [{ rawBytes: options.certificate }],
- },
- };
+ if (options.singleCertificate) {
+ return {
+ $case: 'certificate',
+ certificate: { rawBytes: options.certificate },
+ };
+ }
+ else {
+ return {
+ $case: 'x509CertificateChain',
+ x509CertificateChain: {
+ certificates: [{ rawBytes: options.certificate }],
+ },
+ };
+ }
}
else {
return {
diff --git a/deps/npm/node_modules/@sigstore/bundle/dist/bundle.js b/deps/npm/node_modules/@sigstore/bundle/dist/bundle.js
index 60574b309c09cb..dbd35df2ca2bb3 100644
--- a/deps/npm/node_modules/@sigstore/bundle/dist/bundle.js
+++ b/deps/npm/node_modules/@sigstore/bundle/dist/bundle.js
@@ -1,9 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.isBundleWithDsseEnvelope = exports.isBundleWithMessageSignature = exports.isBundleWithPublicKey = exports.isBundleWithCertificateChain = exports.BUNDLE_V03_MEDIA_TYPE = exports.BUNDLE_V02_MEDIA_TYPE = exports.BUNDLE_V01_MEDIA_TYPE = void 0;
+exports.isBundleWithDsseEnvelope = exports.isBundleWithMessageSignature = exports.isBundleWithPublicKey = exports.isBundleWithCertificateChain = exports.BUNDLE_V03_MEDIA_TYPE = exports.BUNDLE_V03_LEGACY_MEDIA_TYPE = exports.BUNDLE_V02_MEDIA_TYPE = exports.BUNDLE_V01_MEDIA_TYPE = void 0;
exports.BUNDLE_V01_MEDIA_TYPE = 'application/vnd.dev.sigstore.bundle+json;version=0.1';
exports.BUNDLE_V02_MEDIA_TYPE = 'application/vnd.dev.sigstore.bundle+json;version=0.2';
-exports.BUNDLE_V03_MEDIA_TYPE = 'application/vnd.dev.sigstore.bundle+json;version=0.3';
+exports.BUNDLE_V03_LEGACY_MEDIA_TYPE = 'application/vnd.dev.sigstore.bundle+json;version=0.3';
+exports.BUNDLE_V03_MEDIA_TYPE = 'application/vnd.dev.sigstore.bundle.v0.3+json';
// Type guards for bundle variants.
function isBundleWithCertificateChain(b) {
return b.verificationMaterial.content.$case === 'x509CertificateChain';
diff --git a/deps/npm/node_modules/@sigstore/bundle/dist/index.js b/deps/npm/node_modules/@sigstore/bundle/dist/index.js
index f2b50994e9b1f5..1b012acad4d85b 100644
--- a/deps/npm/node_modules/@sigstore/bundle/dist/index.js
+++ b/deps/npm/node_modules/@sigstore/bundle/dist/index.js
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.isBundleV01 = exports.assertBundleV02 = exports.assertBundleV01 = exports.assertBundleLatest = exports.assertBundle = exports.envelopeToJSON = exports.envelopeFromJSON = exports.bundleToJSON = exports.bundleFromJSON = exports.ValidationError = exports.isBundleWithPublicKey = exports.isBundleWithMessageSignature = exports.isBundleWithDsseEnvelope = exports.isBundleWithCertificateChain = exports.BUNDLE_V03_MEDIA_TYPE = exports.BUNDLE_V02_MEDIA_TYPE = exports.BUNDLE_V01_MEDIA_TYPE = exports.toMessageSignatureBundle = exports.toDSSEBundle = void 0;
+exports.isBundleV01 = exports.assertBundleV02 = exports.assertBundleV01 = exports.assertBundleLatest = exports.assertBundle = exports.envelopeToJSON = exports.envelopeFromJSON = exports.bundleToJSON = exports.bundleFromJSON = exports.ValidationError = exports.isBundleWithPublicKey = exports.isBundleWithMessageSignature = exports.isBundleWithDsseEnvelope = exports.isBundleWithCertificateChain = exports.BUNDLE_V03_MEDIA_TYPE = exports.BUNDLE_V03_LEGACY_MEDIA_TYPE = exports.BUNDLE_V02_MEDIA_TYPE = exports.BUNDLE_V01_MEDIA_TYPE = exports.toMessageSignatureBundle = exports.toDSSEBundle = void 0;
/*
Copyright 2023 The Sigstore Authors.
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "toMessageSignatureBundle", { enumerable: true, g
var bundle_1 = require("./bundle");
Object.defineProperty(exports, "BUNDLE_V01_MEDIA_TYPE", { enumerable: true, get: function () { return bundle_1.BUNDLE_V01_MEDIA_TYPE; } });
Object.defineProperty(exports, "BUNDLE_V02_MEDIA_TYPE", { enumerable: true, get: function () { return bundle_1.BUNDLE_V02_MEDIA_TYPE; } });
+Object.defineProperty(exports, "BUNDLE_V03_LEGACY_MEDIA_TYPE", { enumerable: true, get: function () { return bundle_1.BUNDLE_V03_LEGACY_MEDIA_TYPE; } });
Object.defineProperty(exports, "BUNDLE_V03_MEDIA_TYPE", { enumerable: true, get: function () { return bundle_1.BUNDLE_V03_MEDIA_TYPE; } });
Object.defineProperty(exports, "isBundleWithCertificateChain", { enumerable: true, get: function () { return bundle_1.isBundleWithCertificateChain; } });
Object.defineProperty(exports, "isBundleWithDsseEnvelope", { enumerable: true, get: function () { return bundle_1.isBundleWithDsseEnvelope; } });
diff --git a/deps/npm/node_modules/@sigstore/bundle/dist/validate.js b/deps/npm/node_modules/@sigstore/bundle/dist/validate.js
index 6a59ecc230f4ac..67079cd1f680a9 100644
--- a/deps/npm/node_modules/@sigstore/bundle/dist/validate.js
+++ b/deps/npm/node_modules/@sigstore/bundle/dist/validate.js
@@ -74,7 +74,8 @@ function validateBundleBase(b) {
const invalidValues = [];
// Media type validation
if (b.mediaType === undefined ||
- !b.mediaType.startsWith('application/vnd.dev.sigstore.bundle+json;version=')) {
+ (!b.mediaType.match(/^application\/vnd\.dev\.sigstore\.bundle\+json;version=\d\.\d/) &&
+ !b.mediaType.match(/^application\/vnd\.dev\.sigstore\.bundle\.v\d\.\d\+json/))) {
invalidValues.push('mediaType');
}
// Content-related validation
diff --git a/deps/npm/node_modules/@sigstore/bundle/package.json b/deps/npm/node_modules/@sigstore/bundle/package.json
index 2cac185f73895b..ab96ba7e8b2ca6 100644
--- a/deps/npm/node_modules/@sigstore/bundle/package.json
+++ b/deps/npm/node_modules/@sigstore/bundle/package.json
@@ -1,6 +1,6 @@
{
"name": "@sigstore/bundle",
- "version": "2.2.0",
+ "version": "2.3.1",
"description": "Sigstore bundle type",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -27,7 +27,7 @@
"provenance": true
},
"dependencies": {
- "@sigstore/protobuf-specs": "^0.3.0"
+ "@sigstore/protobuf-specs": "^0.3.1"
},
"engines": {
"node": "^16.14.0 || >=18.0.0"
diff --git a/deps/npm/node_modules/@sigstore/core/dist/crypto.js b/deps/npm/node_modules/@sigstore/core/dist/crypto.js
index c5d899d003e1d4..dbe65b165d3574 100644
--- a/deps/npm/node_modules/@sigstore/core/dist/crypto.js
+++ b/deps/npm/node_modules/@sigstore/core/dist/crypto.js
@@ -21,12 +21,12 @@ limitations under the License.
*/
const crypto_1 = __importDefault(require("crypto"));
const SHA256_ALGORITHM = 'sha256';
-function createPublicKey(key) {
+function createPublicKey(key, type = 'spki') {
if (typeof key === 'string') {
return crypto_1.default.createPublicKey(key);
}
else {
- return crypto_1.default.createPublicKey({ key, format: 'der', type: 'spki' });
+ return crypto_1.default.createPublicKey({ key, format: 'der', type: type });
}
}
exports.createPublicKey = createPublicKey;
diff --git a/deps/npm/node_modules/@sigstore/core/package.json b/deps/npm/node_modules/@sigstore/core/package.json
index b9f901652ef0fd..621ff1715bcd1c 100644
--- a/deps/npm/node_modules/@sigstore/core/package.json
+++ b/deps/npm/node_modules/@sigstore/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@sigstore/core",
- "version": "1.0.0",
+ "version": "1.1.0",
"description": "Base library for Sigstore",
"main": "dist/index.js",
"types": "dist/index.d.ts",
diff --git a/deps/npm/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_trustroot.js b/deps/npm/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_trustroot.js
index 05e566767cdb24..9984f7879c73f1 100644
--- a/deps/npm/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_trustroot.js
+++ b/deps/npm/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_trustroot.js
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.TrustedRoot = exports.CertificateAuthority = exports.TransparencyLogInstance = void 0;
+exports.ClientTrustConfig = exports.SigningConfig = exports.TrustedRoot = exports.CertificateAuthority = exports.TransparencyLogInstance = void 0;
/* eslint-disable */
const sigstore_common_1 = require("./sigstore_common");
function createBaseTransparencyLogInstance() {
@@ -98,6 +98,58 @@ exports.TrustedRoot = {
return obj;
},
};
+function createBaseSigningConfig() {
+ return { caUrl: "", oidcUrl: "", tlogUrls: [], tsaUrls: [] };
+}
+exports.SigningConfig = {
+ fromJSON(object) {
+ return {
+ caUrl: isSet(object.caUrl) ? String(object.caUrl) : "",
+ oidcUrl: isSet(object.oidcUrl) ? String(object.oidcUrl) : "",
+ tlogUrls: Array.isArray(object?.tlogUrls) ? object.tlogUrls.map((e) => String(e)) : [],
+ tsaUrls: Array.isArray(object?.tsaUrls) ? object.tsaUrls.map((e) => String(e)) : [],
+ };
+ },
+ toJSON(message) {
+ const obj = {};
+ message.caUrl !== undefined && (obj.caUrl = message.caUrl);
+ message.oidcUrl !== undefined && (obj.oidcUrl = message.oidcUrl);
+ if (message.tlogUrls) {
+ obj.tlogUrls = message.tlogUrls.map((e) => e);
+ }
+ else {
+ obj.tlogUrls = [];
+ }
+ if (message.tsaUrls) {
+ obj.tsaUrls = message.tsaUrls.map((e) => e);
+ }
+ else {
+ obj.tsaUrls = [];
+ }
+ return obj;
+ },
+};
+function createBaseClientTrustConfig() {
+ return { mediaType: "", trustedRoot: undefined, signingConfig: undefined };
+}
+exports.ClientTrustConfig = {
+ fromJSON(object) {
+ return {
+ mediaType: isSet(object.mediaType) ? String(object.mediaType) : "",
+ trustedRoot: isSet(object.trustedRoot) ? exports.TrustedRoot.fromJSON(object.trustedRoot) : undefined,
+ signingConfig: isSet(object.signingConfig) ? exports.SigningConfig.fromJSON(object.signingConfig) : undefined,
+ };
+ },
+ toJSON(message) {
+ const obj = {};
+ message.mediaType !== undefined && (obj.mediaType = message.mediaType);
+ message.trustedRoot !== undefined &&
+ (obj.trustedRoot = message.trustedRoot ? exports.TrustedRoot.toJSON(message.trustedRoot) : undefined);
+ message.signingConfig !== undefined &&
+ (obj.signingConfig = message.signingConfig ? exports.SigningConfig.toJSON(message.signingConfig) : undefined);
+ return obj;
+ },
+};
function isSet(value) {
return value !== null && value !== undefined;
}
diff --git a/deps/npm/node_modules/@sigstore/protobuf-specs/package.json b/deps/npm/node_modules/@sigstore/protobuf-specs/package.json
index 047a67a7a2e208..4fefe51c761fd8 100644
--- a/deps/npm/node_modules/@sigstore/protobuf-specs/package.json
+++ b/deps/npm/node_modules/@sigstore/protobuf-specs/package.json
@@ -1,6 +1,6 @@
{
"name": "@sigstore/protobuf-specs",
- "version": "0.3.0",
+ "version": "0.3.1",
"description": "code-signing for npm packages",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -21,11 +21,11 @@
},
"homepage": "https://github.com/sigstore/protobuf-specs#readme",
"devDependencies": {
- "@tsconfig/node14": "^1.0.3",
+ "@tsconfig/node16": "^16.1.1",
"@types/node": "^18.14.0",
"typescript": "^4.9.5"
},
"engines": {
- "node": "^14.17.0 || ^16.13.0 || >=18.0.0"
+ "node": "^16.14.0 || >=18.0.0"
}
}
diff --git a/deps/npm/node_modules/@sigstore/sign/dist/bundler/bundle.js b/deps/npm/node_modules/@sigstore/sign/dist/bundler/bundle.js
index f01aac252b304a..7c2ca9164f0dfe 100644
--- a/deps/npm/node_modules/@sigstore/sign/dist/bundler/bundle.js
+++ b/deps/npm/node_modules/@sigstore/sign/dist/bundler/bundle.js
@@ -56,7 +56,7 @@ function toMessageSignatureBundle(artifact, signature) {
}
exports.toMessageSignatureBundle = toMessageSignatureBundle;
// DSSE envelope bundle - $case: 'dsseEnvelope'
-function toDSSEBundle(artifact, signature) {
+function toDSSEBundle(artifact, signature, singleCertificate) {
return sigstore.toDSSEBundle({
artifact: artifact.data,
artifactType: artifact.type,
@@ -65,6 +65,7 @@ function toDSSEBundle(artifact, signature) {
? util_1.pem.toDER(signature.key.certificate)
: undefined,
keyHint: signature.key.$case === 'publicKey' ? signature.key.hint : undefined,
+ singleCertificate,
});
}
exports.toDSSEBundle = toDSSEBundle;
diff --git a/deps/npm/node_modules/@sigstore/sign/dist/bundler/dsse.js b/deps/npm/node_modules/@sigstore/sign/dist/bundler/dsse.js
index 486d289aea38cb..621700df93842a 100644
--- a/deps/npm/node_modules/@sigstore/sign/dist/bundler/dsse.js
+++ b/deps/npm/node_modules/@sigstore/sign/dist/bundler/dsse.js
@@ -23,6 +23,7 @@ const bundle_1 = require("./bundle");
class DSSEBundleBuilder extends base_1.BaseBundleBuilder {
constructor(options) {
super(options);
+ this.singleCertificate = options.singleCertificate ?? false;
}
// DSSE requires the artifact to be pre-encoded with the payload type
// before the signature is generated.
@@ -32,7 +33,7 @@ class DSSEBundleBuilder extends base_1.BaseBundleBuilder {
}
// Packages the artifact and signature into a DSSE bundle
async package(artifact, signature) {
- return (0, bundle_1.toDSSEBundle)(artifactDefaults(artifact), signature);
+ return (0, bundle_1.toDSSEBundle)(artifactDefaults(artifact), signature, this.singleCertificate);
}
}
exports.DSSEBundleBuilder = DSSEBundleBuilder;
diff --git a/deps/npm/node_modules/@sigstore/sign/package.json b/deps/npm/node_modules/@sigstore/sign/package.json
index 4302f6e07a2a82..09eea0a39e8771 100644
--- a/deps/npm/node_modules/@sigstore/sign/package.json
+++ b/deps/npm/node_modules/@sigstore/sign/package.json
@@ -1,6 +1,6 @@
{
"name": "@sigstore/sign",
- "version": "2.2.3",
+ "version": "2.3.0",
"description": "Sigstore signing library",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -27,14 +27,14 @@
},
"devDependencies": {
"@sigstore/jest": "^0.0.0",
- "@sigstore/mock": "^0.6.5",
+ "@sigstore/mock": "^0.7.0",
"@sigstore/rekor-types": "^2.0.0",
"@types/make-fetch-happen": "^10.0.4"
},
"dependencies": {
- "@sigstore/bundle": "^2.2.0",
+ "@sigstore/bundle": "^2.3.0",
"@sigstore/core": "^1.0.0",
- "@sigstore/protobuf-specs": "^0.3.0",
+ "@sigstore/protobuf-specs": "^0.3.1",
"make-fetch-happen": "^13.0.0"
},
"engines": {
diff --git a/deps/npm/node_modules/@sigstore/verify/dist/tlog/intoto.js b/deps/npm/node_modules/@sigstore/verify/dist/tlog/intoto.js
index e706887a95043a..74c7f50d763e1d 100644
--- a/deps/npm/node_modules/@sigstore/verify/dist/tlog/intoto.js
+++ b/deps/npm/node_modules/@sigstore/verify/dist/tlog/intoto.js
@@ -42,11 +42,12 @@ function verifyIntoto002TLogBody(tlogEntry, content) {
// Signature is double-base64-encoded in the tlog entry
const tlogSig = base64Decode(tlogEntry.spec.content.envelope.signatures[0].sig);
// Ensure that the signature in the bundle's DSSE matches tlog entry
- if (!content.compareSignature(Buffer.from(tlogSig, 'base64')))
+ if (!content.compareSignature(Buffer.from(tlogSig, 'base64'))) {
throw new error_1.VerificationError({
code: 'TLOG_BODY_ERROR',
message: 'tlog entry signature mismatch',
});
+ }
// Ensure the digest of the bundle's DSSE payload matches the digest in the
// tlog entry
const tlogHash = tlogEntry.spec.content.payloadHash?.value || '';
diff --git a/deps/npm/node_modules/@sigstore/verify/dist/trust/index.js b/deps/npm/node_modules/@sigstore/verify/dist/trust/index.js
index 7991f351949a00..954de558415902 100644
--- a/deps/npm/node_modules/@sigstore/verify/dist/trust/index.js
+++ b/deps/npm/node_modules/@sigstore/verify/dist/trust/index.js
@@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
const core_1 = require("@sigstore/core");
+const protobuf_specs_1 = require("@sigstore/protobuf-specs");
const error_1 = require("../error");
const BEGINNING_OF_TIME = new Date(0);
const END_OF_TIME = new Date(8640000000000000);
@@ -35,9 +36,17 @@ function toTrustMaterial(root, keys) {
}
exports.toTrustMaterial = toTrustMaterial;
function createTLogAuthority(tlogInstance) {
+ const keyDetails = tlogInstance.publicKey.keyDetails;
+ const keyType = keyDetails === protobuf_specs_1.PublicKeyDetails.PKCS1_RSA_PKCS1V5 ||
+ keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V5 ||
+ keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V15_2048_SHA256 ||
+ keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V15_3072_SHA256 ||
+ keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V15_4096_SHA256
+ ? 'pkcs1'
+ : 'spki';
return {
logID: tlogInstance.logId.keyId,
- publicKey: core_1.crypto.createPublicKey(tlogInstance.publicKey.rawBytes),
+ publicKey: core_1.crypto.createPublicKey(tlogInstance.publicKey.rawBytes, keyType),
validFor: {
start: tlogInstance.publicKey.validFor?.start || BEGINNING_OF_TIME,
end: tlogInstance.publicKey.validFor?.end || END_OF_TIME,
diff --git a/deps/npm/node_modules/@sigstore/verify/package.json b/deps/npm/node_modules/@sigstore/verify/package.json
index dcfb587e084a6c..edd6566e10ece7 100644
--- a/deps/npm/node_modules/@sigstore/verify/package.json
+++ b/deps/npm/node_modules/@sigstore/verify/package.json
@@ -1,6 +1,6 @@
{
"name": "@sigstore/verify",
- "version": "1.1.0",
+ "version": "1.2.0",
"description": "Verification of Sigstore signatures",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -26,9 +26,9 @@
"provenance": true
},
"dependencies": {
- "@sigstore/protobuf-specs": "^0.3.0",
- "@sigstore/bundle": "^2.2.0",
- "@sigstore/core": "^1.0.0"
+ "@sigstore/protobuf-specs": "^0.3.1",
+ "@sigstore/bundle": "^2.3.1",
+ "@sigstore/core": "^1.1.0"
},
"engines": {
"node": "^16.14.0 || >=18.0.0"
diff --git a/deps/npm/node_modules/builtins/index.js b/deps/npm/node_modules/builtins/index.js
index b715278437cbcf..01d23876aae325 100644
--- a/deps/npm/node_modules/builtins/index.js
+++ b/deps/npm/node_modules/builtins/index.js
@@ -1,6 +1,6 @@
'use strict'
-const semver = require('semver')
+const satisfies = require('semver/functions/satisfies')
const permanentModules = [
'assert',
@@ -60,7 +60,7 @@ module.exports = ({ version = process.version, experimental = false } = {}) => {
const builtins = [...permanentModules]
for (const [name, semverRange] of Object.entries(versionLockedModules)) {
- if (version === '*' || semver.satisfies(version, semverRange)) {
+ if (version === '*' || satisfies(version, semverRange)) {
builtins.push(name)
}
}
@@ -69,7 +69,7 @@ module.exports = ({ version = process.version, experimental = false } = {}) => {
for (const [name, semverRange] of Object.entries(experimentalModules)) {
if (
!builtins.includes(name) &&
- (version === '*' || semver.satisfies(version, semverRange))
+ (version === '*' || satisfies(version, semverRange))
) {
builtins.push(name)
}
diff --git a/deps/npm/node_modules/builtins/package.json b/deps/npm/node_modules/builtins/package.json
index 1c43660c7483fe..d37e02e0768180 100644
--- a/deps/npm/node_modules/builtins/package.json
+++ b/deps/npm/node_modules/builtins/package.json
@@ -1,20 +1,19 @@
{
"name": "builtins",
- "version": "5.0.1",
+ "version": "5.1.0",
"description": "List of node.js builtin modules",
"repository": "juliangruber/builtins",
"license": "MIT",
"main": "index.js",
"files": [],
"scripts": {
- "test": "prettier-standard && standard && node-core-test"
+ "test": "standard --fix && node--test"
},
"dependencies": {
"semver": "^7.0.0"
},
"devDependencies": {
- "node-core-test": "^1.4.0",
- "prettier-standard": "^15.0.1",
- "standard": "^14.3.4"
+ "standard": "^17.0.0",
+ "test": "^3.0.0"
}
}
diff --git a/deps/npm/node_modules/cidr-regex/package.json b/deps/npm/node_modules/cidr-regex/package.json
index 4f743464075e3e..262da56e2ee676 100644
--- a/deps/npm/node_modules/cidr-regex/package.json
+++ b/deps/npm/node_modules/cidr-regex/package.json
@@ -1,6 +1,6 @@
{
"name": "cidr-regex",
- "version": "4.0.3",
+ "version": "4.0.5",
"description": "Regular expression for matching IP addresses in CIDR notation",
"author": "silverwind ",
"contributors": [
@@ -22,11 +22,12 @@
"ip-regex": "^5.0.0"
},
"devDependencies": {
- "eslint": "8.37.0",
- "eslint-config-silverwind": "65.1.3",
- "tsd": "0.28.1",
- "updates": "13.2.9",
- "versions": "10.4.2",
- "vitest": "0.29.8"
+ "eslint": "8.57.0",
+ "eslint-config-silverwind": "83.0.1",
+ "tsd": "0.31.0",
+ "updates": "16.0.0",
+ "versions": "12.0.1",
+ "vitest": "1.4.0",
+ "vitest-config-silverwind": "7.0.3"
}
}
diff --git a/deps/npm/node_modules/hasown/package.json b/deps/npm/node_modules/hasown/package.json
index 1b03e9d3018bde..8502e13dd5c835 100644
--- a/deps/npm/node_modules/hasown/package.json
+++ b/deps/npm/node_modules/hasown/package.json
@@ -1,6 +1,6 @@
{
"name": "hasown",
- "version": "2.0.1",
+ "version": "2.0.2",
"description": "A robust, ES3 compatible, \"has own property\" predicate.",
"main": "index.js",
"exports": {
@@ -18,6 +18,7 @@
"postlint": "npm run tsc",
"pretest": "npm run lint",
"tsc": "tsc -p .",
+ "posttsc": "attw -P",
"tests-only": "nyc tape 'test/**/*.js'",
"test": "npm run tests-only",
"posttest": "aud --production",
@@ -50,7 +51,9 @@
"function-bind": "^1.1.2"
},
"devDependencies": {
+ "@arethetypeswrong/cli": "^0.15.1",
"@ljharb/eslint-config": "^21.1.0",
+ "@ljharb/tsconfig": "^0.2.0",
"@types/function-bind": "^1.1.10",
"@types/mock-property": "^1.0.2",
"@types/tape": "^5.6.4",
@@ -63,7 +66,7 @@
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"safe-publish-latest": "^2.0.0",
- "tape": "^5.7.4",
+ "tape": "^5.7.5",
"typescript": "next"
},
"engines": {
diff --git a/deps/npm/node_modules/hasown/tsconfig.json b/deps/npm/node_modules/hasown/tsconfig.json
index fdab34fe311577..0930c565850326 100644
--- a/deps/npm/node_modules/hasown/tsconfig.json
+++ b/deps/npm/node_modules/hasown/tsconfig.json
@@ -1,49 +1,6 @@
{
- "compilerOptions": {
- /* Visit https://aka.ms/tsconfig to read more about this file */
-
- /* Projects */
-
- /* Language and Environment */
- "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
- "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
- // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
-
- /* Modules */
- "module": "commonjs", /* Specify what module code is generated. */
- // "rootDir": "./", /* Specify the root folder within your source files. */
- // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
- "typeRoots": ["types"], /* Specify multiple folders that act like './node_modules/@types'. */
- "resolveJsonModule": true, /* Enable importing .json files. */
- // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
-
- /* JavaScript Support */
- "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
- "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
- "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
-
- /* Emit */
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
- "declarationMap": true, /* Create sourcemaps for d.ts files. */
- "noEmit": true, /* Disable emitting files from a compilation. */
-
- /* Interop Constraints */
- "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
-
- /* Type Checking */
- "strict": true, /* Enable all strict type-checking options. */
-
- /* Completeness */
- //"skipLibCheck": true /* Skip type checking all .d.ts files. */
- },
+ "extends": "@ljharb/tsconfig",
"exclude": [
- "coverage"
- ]
+ "coverage",
+ ],
}
diff --git a/deps/npm/node_modules/is-cidr/LICENSE b/deps/npm/node_modules/is-cidr/LICENSE
deleted file mode 100644
index 9669c20f85511d..00000000000000
--- a/deps/npm/node_modules/is-cidr/LICENSE
+++ /dev/null
@@ -1,22 +0,0 @@
-Copyright (c) silverwind
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/deps/npm/node_modules/is-cidr/package.json b/deps/npm/node_modules/is-cidr/package.json
index d6971b3b33bd83..baf6fa55fe4522 100644
--- a/deps/npm/node_modules/is-cidr/package.json
+++ b/deps/npm/node_modules/is-cidr/package.json
@@ -1,6 +1,6 @@
{
"name": "is-cidr",
- "version": "5.0.3",
+ "version": "5.0.5",
"description": "Check if a string is an IP address in CIDR notation",
"author": "silverwind ",
"contributors": [
@@ -19,14 +19,15 @@
"index.d.ts"
],
"dependencies": {
- "cidr-regex": "4.0.3"
+ "cidr-regex": "^4.0.4"
},
"devDependencies": {
- "eslint": "8.37.0",
- "eslint-config-silverwind": "65.1.3",
- "tsd": "0.28.1",
- "updates": "13.2.9",
- "versions": "10.4.2",
- "vitest": "0.29.8"
+ "eslint": "8.57.0",
+ "eslint-config-silverwind": "83.0.1",
+ "tsd": "0.31.0",
+ "updates": "16.0.0",
+ "versions": "12.0.1",
+ "vitest": "1.4.0",
+ "vitest-config-silverwind": "7.0.3"
}
}
diff --git a/deps/npm/node_modules/libnpmdiff/package.json b/deps/npm/node_modules/libnpmdiff/package.json
index f6ad40b482a934..98229e99bd5618 100644
--- a/deps/npm/node_modules/libnpmdiff/package.json
+++ b/deps/npm/node_modules/libnpmdiff/package.json
@@ -1,6 +1,6 @@
{
"name": "libnpmdiff",
- "version": "6.0.8",
+ "version": "6.0.9",
"description": "The registry diff",
"repository": {
"type": "git",
diff --git a/deps/npm/node_modules/libnpmexec/package.json b/deps/npm/node_modules/libnpmexec/package.json
index 8b6a9d217a00d0..39f12270e35a7e 100644
--- a/deps/npm/node_modules/libnpmexec/package.json
+++ b/deps/npm/node_modules/libnpmexec/package.json
@@ -1,6 +1,6 @@
{
"name": "libnpmexec",
- "version": "7.0.9",
+ "version": "7.0.10",
"files": [
"bin/",
"lib/"
diff --git a/deps/npm/node_modules/libnpmfund/package.json b/deps/npm/node_modules/libnpmfund/package.json
index 994538c89fce17..978252999e92eb 100644
--- a/deps/npm/node_modules/libnpmfund/package.json
+++ b/deps/npm/node_modules/libnpmfund/package.json
@@ -1,6 +1,6 @@
{
"name": "libnpmfund",
- "version": "5.0.6",
+ "version": "5.0.7",
"main": "lib/index.js",
"files": [
"bin/",
diff --git a/deps/npm/node_modules/libnpmpack/package.json b/deps/npm/node_modules/libnpmpack/package.json
index d49a17aa39f838..1782ab7143186a 100644
--- a/deps/npm/node_modules/libnpmpack/package.json
+++ b/deps/npm/node_modules/libnpmpack/package.json
@@ -1,6 +1,6 @@
{
"name": "libnpmpack",
- "version": "6.0.8",
+ "version": "6.0.9",
"description": "Programmatic API for the bits behind npm pack",
"author": "GitHub Inc.",
"main": "lib/index.js",
diff --git a/deps/npm/node_modules/postcss-selector-parser/package.json b/deps/npm/node_modules/postcss-selector-parser/package.json
index d1f6be84cc5c77..0d1af5d373f20e 100644
--- a/deps/npm/node_modules/postcss-selector-parser/package.json
+++ b/deps/npm/node_modules/postcss-selector-parser/package.json
@@ -1,6 +1,6 @@
{
"name": "postcss-selector-parser",
- "version": "6.0.15",
+ "version": "6.0.16",
"devDependencies": {
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
@@ -33,7 +33,8 @@
"!**/__tests__"
],
"scripts": {
- "pretest": "eslint src && tsc --noEmit postcss-selector-parser.d.ts",
+ "typecheck": "tsc --noEmit --strict postcss-selector-parser.d.ts postcss-selector-parser.test.ts",
+ "pretest": "eslint src && npm run typecheck",
"prepare": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
"lintfix": "eslint --fix src",
"report": "nyc report --reporter=html",
diff --git a/deps/npm/node_modules/sigstore/package.json b/deps/npm/node_modules/sigstore/package.json
index 3dca00636b8d9d..f39fc63b5a91de 100644
--- a/deps/npm/node_modules/sigstore/package.json
+++ b/deps/npm/node_modules/sigstore/package.json
@@ -1,6 +1,6 @@
{
"name": "sigstore",
- "version": "2.2.2",
+ "version": "2.3.0",
"description": "code-signing for npm packages",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -29,17 +29,17 @@
"devDependencies": {
"@sigstore/rekor-types": "^2.0.0",
"@sigstore/jest": "^0.0.0",
- "@sigstore/mock": "^0.6.5",
+ "@sigstore/mock": "^0.7.0",
"@tufjs/repo-mock": "^2.0.0",
"@types/make-fetch-happen": "^10.0.4"
},
"dependencies": {
- "@sigstore/bundle": "^2.2.0",
+ "@sigstore/bundle": "^2.3.1",
"@sigstore/core": "^1.0.0",
- "@sigstore/protobuf-specs": "^0.3.0",
- "@sigstore/sign": "^2.2.3",
+ "@sigstore/protobuf-specs": "^0.3.1",
+ "@sigstore/sign": "^2.3.0",
"@sigstore/tuf": "^2.3.1",
- "@sigstore/verify": "^1.1.0"
+ "@sigstore/verify": "^1.2.0"
},
"engines": {
"node": "^16.14.0 || >=18.0.0"
diff --git a/deps/npm/node_modules/socks-proxy-agent/LICENSE b/deps/npm/node_modules/socks-proxy-agent/LICENSE
new file mode 100644
index 00000000000000..008728cb51847d
--- /dev/null
+++ b/deps/npm/node_modules/socks-proxy-agent/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2013 Nathan Rajlich
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/deps/npm/node_modules/socks-proxy-agent/dist/index.js b/deps/npm/node_modules/socks-proxy-agent/dist/index.js
index 102ecd64c0b9d6..efd03ec9a7fe76 100644
--- a/deps/npm/node_modules/socks-proxy-agent/dist/index.js
+++ b/deps/npm/node_modules/socks-proxy-agent/dist/index.js
@@ -94,6 +94,7 @@ class SocksProxyAgent extends agent_base_1.Agent {
this.shouldLookup = lookup;
this.proxy = proxy;
this.timeout = opts?.timeout ?? null;
+ this.socketOptions = opts?.socketOptions ?? null;
}
/**
* Initiates a SOCKS connection to the specified SOCKS proxy server,
@@ -128,6 +129,9 @@ class SocksProxyAgent extends agent_base_1.Agent {
},
command: 'connect',
timeout: timeout ?? undefined,
+ // @ts-expect-error the type supplied by socks for socket_options is wider
+ // than necessary since socks will always override the host and port
+ socket_options: this.socketOptions ?? undefined,
};
const cleanup = (tlsSocket) => {
req.destroy();
diff --git a/deps/npm/node_modules/socks-proxy-agent/package.json b/deps/npm/node_modules/socks-proxy-agent/package.json
index 6e1c2c12de3674..090ec3e46b2798 100644
--- a/deps/npm/node_modules/socks-proxy-agent/package.json
+++ b/deps/npm/node_modules/socks-proxy-agent/package.json
@@ -1,6 +1,6 @@
{
"name": "socks-proxy-agent",
- "version": "8.0.2",
+ "version": "8.0.3",
"description": "A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -107,7 +107,7 @@
"socks5h"
],
"dependencies": {
- "agent-base": "^7.0.2",
+ "agent-base": "^7.1.1",
"debug": "^4.3.4",
"socks": "^2.7.1"
},
diff --git a/deps/npm/node_modules/socks/build/common/helpers.js b/deps/npm/node_modules/socks/build/common/helpers.js
index 65bd95bdc62215..1ae44e4159a155 100644
--- a/deps/npm/node_modules/socks/build/common/helpers.js
+++ b/deps/npm/node_modules/socks/build/common/helpers.js
@@ -152,7 +152,11 @@ function ipToBuffer(ip) {
else if (net.isIPv6(ip)) {
// Handle IPv6 addresses
const address = new ip_address_1.Address6(ip);
- return Buffer.from(address.toByteArray());
+ return Buffer.from(address
+ .canonicalForm()
+ .split(':')
+ .map((segment) => segment.padStart(4, '0'))
+ .join(''), 'hex');
}
else {
throw new Error('Invalid IP address format');
diff --git a/deps/npm/node_modules/socks/package.json b/deps/npm/node_modules/socks/package.json
index dbda909fd0787c..5cc2a6836072e5 100644
--- a/deps/npm/node_modules/socks/package.json
+++ b/deps/npm/node_modules/socks/package.json
@@ -1,7 +1,7 @@
{
"name": "socks",
"private": false,
- "version": "2.8.0",
+ "version": "2.8.3",
"description": "Fully featured SOCKS proxy client supporting SOCKSv4, SOCKSv4a, and SOCKSv5. Includes Bind and Associate functionality.",
"main": "build/index.js",
"typings": "typings/index.d.ts",
@@ -23,7 +23,7 @@
"socks5"
],
"engines": {
- "node": ">= 16.0.0",
+ "node": ">= 10.0.0",
"npm": ">= 3.0.0"
},
"author": "Josh Glazebrook",
@@ -52,6 +52,7 @@
"test": "NODE_ENV=test mocha --recursive --require ts-node/register test/**/*.ts",
"prettier": "prettier --write ./src/**/*.ts --config .prettierrc.yaml",
"lint": "eslint 'src/**/*.ts'",
- "build": "rm -rf build typings && prettier --write ./src/**/*.ts --config .prettierrc.yaml && tsc -p ."
+ "build": "rm -rf build typings && prettier --write ./src/**/*.ts --config .prettierrc.yaml && tsc -p .",
+ "build-raw": "rm -rf build typings && tsc -p ."
}
}
diff --git a/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/AUTHORS b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/AUTHORS
new file mode 100644
index 00000000000000..257a76b9484c12
--- /dev/null
+++ b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/AUTHORS
@@ -0,0 +1,4 @@
+C. Scott Ananian (http://cscott.net)
+Kyle E. Mitchell (https://kemitchell.com)
+Shinnosuke Watanabe
+Antoine Motet
diff --git a/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/LICENSE b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/LICENSE
new file mode 100644
index 00000000000000..831618eaba6c89
--- /dev/null
+++ b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/LICENSE
@@ -0,0 +1,22 @@
+The MIT License
+
+Copyright (c) 2015 Kyle E. Mitchell & other authors listed in AUTHORS
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/index.js b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/index.js
new file mode 100644
index 00000000000000..52fab560aea707
--- /dev/null
+++ b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/index.js
@@ -0,0 +1,8 @@
+'use strict'
+
+var scan = require('./scan')
+var parse = require('./parse')
+
+module.exports = function (source) {
+ return parse(scan(source))
+}
diff --git a/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/package.json b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/package.json
new file mode 100644
index 00000000000000..c9edc9f939cdf6
--- /dev/null
+++ b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/package.json
@@ -0,0 +1,39 @@
+{
+ "name": "spdx-expression-parse",
+ "description": "parse SPDX license expressions",
+ "version": "3.0.1",
+ "author": "Kyle E. Mitchell (https://kemitchell.com)",
+ "files": [
+ "AUTHORS",
+ "index.js",
+ "parse.js",
+ "scan.js"
+ ],
+ "dependencies": {
+ "spdx-exceptions": "^2.1.0",
+ "spdx-license-ids": "^3.0.0"
+ },
+ "devDependencies": {
+ "defence-cli": "^3.0.1",
+ "replace-require-self": "^1.0.0",
+ "standard": "^14.1.0"
+ },
+ "keywords": [
+ "SPDX",
+ "law",
+ "legal",
+ "license",
+ "metadata",
+ "package",
+ "package.json",
+ "standards"
+ ],
+ "license": "MIT",
+ "repository": "jslicense/spdx-expression-parse.js",
+ "scripts": {
+ "lint": "standard",
+ "test:readme": "defence -i javascript README.md | replace-require-self | node",
+ "test:suite": "node test.js",
+ "test": "npm run test:suite && npm run test:readme"
+ }
+}
diff --git a/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/parse.js b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/parse.js
new file mode 100644
index 00000000000000..5a00b45c5799c4
--- /dev/null
+++ b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/parse.js
@@ -0,0 +1,138 @@
+'use strict'
+
+// The ABNF grammar in the spec is totally ambiguous.
+//
+// This parser follows the operator precedence defined in the
+// `Order of Precedence and Parentheses` section.
+
+module.exports = function (tokens) {
+ var index = 0
+
+ function hasMore () {
+ return index < tokens.length
+ }
+
+ function token () {
+ return hasMore() ? tokens[index] : null
+ }
+
+ function next () {
+ if (!hasMore()) {
+ throw new Error()
+ }
+ index++
+ }
+
+ function parseOperator (operator) {
+ var t = token()
+ if (t && t.type === 'OPERATOR' && operator === t.string) {
+ next()
+ return t.string
+ }
+ }
+
+ function parseWith () {
+ if (parseOperator('WITH')) {
+ var t = token()
+ if (t && t.type === 'EXCEPTION') {
+ next()
+ return t.string
+ }
+ throw new Error('Expected exception after `WITH`')
+ }
+ }
+
+ function parseLicenseRef () {
+ // TODO: Actually, everything is concatenated into one string
+ // for backward-compatibility but it could be better to return
+ // a nice structure.
+ var begin = index
+ var string = ''
+ var t = token()
+ if (t.type === 'DOCUMENTREF') {
+ next()
+ string += 'DocumentRef-' + t.string + ':'
+ if (!parseOperator(':')) {
+ throw new Error('Expected `:` after `DocumentRef-...`')
+ }
+ }
+ t = token()
+ if (t.type === 'LICENSEREF') {
+ next()
+ string += 'LicenseRef-' + t.string
+ return { license: string }
+ }
+ index = begin
+ }
+
+ function parseLicense () {
+ var t = token()
+ if (t && t.type === 'LICENSE') {
+ next()
+ var node = { license: t.string }
+ if (parseOperator('+')) {
+ node.plus = true
+ }
+ var exception = parseWith()
+ if (exception) {
+ node.exception = exception
+ }
+ return node
+ }
+ }
+
+ function parseParenthesizedExpression () {
+ var left = parseOperator('(')
+ if (!left) {
+ return
+ }
+
+ var expr = parseExpression()
+
+ if (!parseOperator(')')) {
+ throw new Error('Expected `)`')
+ }
+
+ return expr
+ }
+
+ function parseAtom () {
+ return (
+ parseParenthesizedExpression() ||
+ parseLicenseRef() ||
+ parseLicense()
+ )
+ }
+
+ function makeBinaryOpParser (operator, nextParser) {
+ return function parseBinaryOp () {
+ var left = nextParser()
+ if (!left) {
+ return
+ }
+
+ if (!parseOperator(operator)) {
+ return left
+ }
+
+ var right = parseBinaryOp()
+ if (!right) {
+ throw new Error('Expected expression')
+ }
+ return {
+ left: left,
+ conjunction: operator.toLowerCase(),
+ right: right
+ }
+ }
+ }
+
+ var parseAnd = makeBinaryOpParser('AND', parseAtom)
+ var parseExpression = makeBinaryOpParser('OR', parseAnd)
+
+ var node = parseExpression()
+ if (!node || hasMore()) {
+ throw new Error('Syntax error')
+ }
+ return node
+}
diff --git a/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/scan.js b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/scan.js
new file mode 100644
index 00000000000000..b74fce2e2c6632
--- /dev/null
+++ b/deps/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse/scan.js
@@ -0,0 +1,131 @@
+'use strict'
+
+var licenses = []
+ .concat(require('spdx-license-ids'))
+ .concat(require('spdx-license-ids/deprecated'))
+var exceptions = require('spdx-exceptions')
+
+module.exports = function (source) {
+ var index = 0
+
+ function hasMore () {
+ return index < source.length
+ }
+
+ // `value` can be a regexp or a string.
+ // If it is recognized, the matching source string is returned and
+ // the index is incremented. Otherwise `undefined` is returned.
+ function read (value) {
+ if (value instanceof RegExp) {
+ var chars = source.slice(index)
+ var match = chars.match(value)
+ if (match) {
+ index += match[0].length
+ return match[0]
+ }
+ } else {
+ if (source.indexOf(value, index) === index) {
+ index += value.length
+ return value
+ }
+ }
+ }
+
+ function skipWhitespace () {
+ read(/[ ]*/)
+ }
+
+ function operator () {
+ var string
+ var possibilities = ['WITH', 'AND', 'OR', '(', ')', ':', '+']
+ for (var i = 0; i < possibilities.length; i++) {
+ string = read(possibilities[i])
+ if (string) {
+ break
+ }
+ }
+
+ if (string === '+' && index > 1 && source[index - 2] === ' ') {
+ throw new Error('Space before `+`')
+ }
+
+ return string && {
+ type: 'OPERATOR',
+ string: string
+ }
+ }
+
+ function idstring () {
+ return read(/[A-Za-z0-9-.]+/)
+ }
+
+ function expectIdstring () {
+ var string = idstring()
+ if (!string) {
+ throw new Error('Expected idstring at offset ' + index)
+ }
+ return string
+ }
+
+ function documentRef () {
+ if (read('DocumentRef-')) {
+ var string = expectIdstring()
+ return { type: 'DOCUMENTREF', string: string }
+ }
+ }
+
+ function licenseRef () {
+ if (read('LicenseRef-')) {
+ var string = expectIdstring()
+ return { type: 'LICENSEREF', string: string }
+ }
+ }
+
+ function identifier () {
+ var begin = index
+ var string = idstring()
+
+ if (licenses.indexOf(string) !== -1) {
+ return {
+ type: 'LICENSE',
+ string: string
+ }
+ } else if (exceptions.indexOf(string) !== -1) {
+ return {
+ type: 'EXCEPTION',
+ string: string
+ }
+ }
+
+ index = begin
+ }
+
+ // Tries to read the next token. Returns `undefined` if no token is
+ // recognized.
+ function parseToken () {
+ // Ordering matters
+ return (
+ operator() ||
+ documentRef() ||
+ licenseRef() ||
+ identifier()
+ )
+ }
+
+ var tokens = []
+ while (hasMore()) {
+ skipWhitespace()
+ if (!hasMore()) {
+ break
+ }
+
+ var token = parseToken()
+ if (!token) {
+ throw new Error('Unexpected `' + source[index] +
+ '` at offset ' + index)
+ }
+
+ tokens.push(token)
+ }
+ return tokens
+}
diff --git a/deps/npm/node_modules/spdx-expression-parse/package.json b/deps/npm/node_modules/spdx-expression-parse/package.json
index c9edc9f939cdf6..c3a22afcf7dfcb 100644
--- a/deps/npm/node_modules/spdx-expression-parse/package.json
+++ b/deps/npm/node_modules/spdx-expression-parse/package.json
@@ -1,7 +1,7 @@
{
"name": "spdx-expression-parse",
"description": "parse SPDX license expressions",
- "version": "3.0.1",
+ "version": "4.0.0",
"author": "Kyle E. Mitchell (https://kemitchell.com)",
"files": [
"AUTHORS",
diff --git a/deps/npm/node_modules/spdx-expression-parse/scan.js b/deps/npm/node_modules/spdx-expression-parse/scan.js
index b74fce2e2c6632..528522282703c6 100644
--- a/deps/npm/node_modules/spdx-expression-parse/scan.js
+++ b/deps/npm/node_modules/spdx-expression-parse/scan.js
@@ -37,7 +37,7 @@ module.exports = function (source) {
function operator () {
var string
- var possibilities = ['WITH', 'AND', 'OR', '(', ')', ':', '+']
+ var possibilities = [/^WITH/i, /^AND/i, /^OR/i, '(', ')', ':', '+']
for (var i = 0; i < possibilities.length; i++) {
string = read(possibilities[i])
if (string) {
@@ -51,7 +51,7 @@ module.exports = function (source) {
return string && {
type: 'OPERATOR',
- string: string
+ string: string.toUpperCase()
}
}
diff --git a/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/AUTHORS b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/AUTHORS
new file mode 100644
index 00000000000000..257a76b9484c12
--- /dev/null
+++ b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/AUTHORS
@@ -0,0 +1,4 @@
+C. Scott Ananian (http://cscott.net)
+Kyle E. Mitchell (https://kemitchell.com)
+Shinnosuke Watanabe
+Antoine Motet
diff --git a/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/LICENSE b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/LICENSE
new file mode 100644
index 00000000000000..831618eaba6c89
--- /dev/null
+++ b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/LICENSE
@@ -0,0 +1,22 @@
+The MIT License
+
+Copyright (c) 2015 Kyle E. Mitchell & other authors listed in AUTHORS
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/index.js b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/index.js
new file mode 100644
index 00000000000000..52fab560aea707
--- /dev/null
+++ b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/index.js
@@ -0,0 +1,8 @@
+'use strict'
+
+var scan = require('./scan')
+var parse = require('./parse')
+
+module.exports = function (source) {
+ return parse(scan(source))
+}
diff --git a/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/package.json b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/package.json
new file mode 100644
index 00000000000000..c9edc9f939cdf6
--- /dev/null
+++ b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/package.json
@@ -0,0 +1,39 @@
+{
+ "name": "spdx-expression-parse",
+ "description": "parse SPDX license expressions",
+ "version": "3.0.1",
+ "author": "Kyle E. Mitchell (https://kemitchell.com)",
+ "files": [
+ "AUTHORS",
+ "index.js",
+ "parse.js",
+ "scan.js"
+ ],
+ "dependencies": {
+ "spdx-exceptions": "^2.1.0",
+ "spdx-license-ids": "^3.0.0"
+ },
+ "devDependencies": {
+ "defence-cli": "^3.0.1",
+ "replace-require-self": "^1.0.0",
+ "standard": "^14.1.0"
+ },
+ "keywords": [
+ "SPDX",
+ "law",
+ "legal",
+ "license",
+ "metadata",
+ "package",
+ "package.json",
+ "standards"
+ ],
+ "license": "MIT",
+ "repository": "jslicense/spdx-expression-parse.js",
+ "scripts": {
+ "lint": "standard",
+ "test:readme": "defence -i javascript README.md | replace-require-self | node",
+ "test:suite": "node test.js",
+ "test": "npm run test:suite && npm run test:readme"
+ }
+}
diff --git a/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/parse.js b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/parse.js
new file mode 100644
index 00000000000000..5a00b45c5799c4
--- /dev/null
+++ b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/parse.js
@@ -0,0 +1,138 @@
+'use strict'
+
+// The ABNF grammar in the spec is totally ambiguous.
+//
+// This parser follows the operator precedence defined in the
+// `Order of Precedence and Parentheses` section.
+
+module.exports = function (tokens) {
+ var index = 0
+
+ function hasMore () {
+ return index < tokens.length
+ }
+
+ function token () {
+ return hasMore() ? tokens[index] : null
+ }
+
+ function next () {
+ if (!hasMore()) {
+ throw new Error()
+ }
+ index++
+ }
+
+ function parseOperator (operator) {
+ var t = token()
+ if (t && t.type === 'OPERATOR' && operator === t.string) {
+ next()
+ return t.string
+ }
+ }
+
+ function parseWith () {
+ if (parseOperator('WITH')) {
+ var t = token()
+ if (t && t.type === 'EXCEPTION') {
+ next()
+ return t.string
+ }
+ throw new Error('Expected exception after `WITH`')
+ }
+ }
+
+ function parseLicenseRef () {
+ // TODO: Actually, everything is concatenated into one string
+ // for backward-compatibility but it could be better to return
+ // a nice structure.
+ var begin = index
+ var string = ''
+ var t = token()
+ if (t.type === 'DOCUMENTREF') {
+ next()
+ string += 'DocumentRef-' + t.string + ':'
+ if (!parseOperator(':')) {
+ throw new Error('Expected `:` after `DocumentRef-...`')
+ }
+ }
+ t = token()
+ if (t.type === 'LICENSEREF') {
+ next()
+ string += 'LicenseRef-' + t.string
+ return { license: string }
+ }
+ index = begin
+ }
+
+ function parseLicense () {
+ var t = token()
+ if (t && t.type === 'LICENSE') {
+ next()
+ var node = { license: t.string }
+ if (parseOperator('+')) {
+ node.plus = true
+ }
+ var exception = parseWith()
+ if (exception) {
+ node.exception = exception
+ }
+ return node
+ }
+ }
+
+ function parseParenthesizedExpression () {
+ var left = parseOperator('(')
+ if (!left) {
+ return
+ }
+
+ var expr = parseExpression()
+
+ if (!parseOperator(')')) {
+ throw new Error('Expected `)`')
+ }
+
+ return expr
+ }
+
+ function parseAtom () {
+ return (
+ parseParenthesizedExpression() ||
+ parseLicenseRef() ||
+ parseLicense()
+ )
+ }
+
+ function makeBinaryOpParser (operator, nextParser) {
+ return function parseBinaryOp () {
+ var left = nextParser()
+ if (!left) {
+ return
+ }
+
+ if (!parseOperator(operator)) {
+ return left
+ }
+
+ var right = parseBinaryOp()
+ if (!right) {
+ throw new Error('Expected expression')
+ }
+ return {
+ left: left,
+ conjunction: operator.toLowerCase(),
+ right: right
+ }
+ }
+ }
+
+ var parseAnd = makeBinaryOpParser('AND', parseAtom)
+ var parseExpression = makeBinaryOpParser('OR', parseAnd)
+
+ var node = parseExpression()
+ if (!node || hasMore()) {
+ throw new Error('Syntax error')
+ }
+ return node
+}
diff --git a/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/scan.js b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/scan.js
new file mode 100644
index 00000000000000..b74fce2e2c6632
--- /dev/null
+++ b/deps/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse/scan.js
@@ -0,0 +1,131 @@
+'use strict'
+
+var licenses = []
+ .concat(require('spdx-license-ids'))
+ .concat(require('spdx-license-ids/deprecated'))
+var exceptions = require('spdx-exceptions')
+
+module.exports = function (source) {
+ var index = 0
+
+ function hasMore () {
+ return index < source.length
+ }
+
+ // `value` can be a regexp or a string.
+ // If it is recognized, the matching source string is returned and
+ // the index is incremented. Otherwise `undefined` is returned.
+ function read (value) {
+ if (value instanceof RegExp) {
+ var chars = source.slice(index)
+ var match = chars.match(value)
+ if (match) {
+ index += match[0].length
+ return match[0]
+ }
+ } else {
+ if (source.indexOf(value, index) === index) {
+ index += value.length
+ return value
+ }
+ }
+ }
+
+ function skipWhitespace () {
+ read(/[ ]*/)
+ }
+
+ function operator () {
+ var string
+ var possibilities = ['WITH', 'AND', 'OR', '(', ')', ':', '+']
+ for (var i = 0; i < possibilities.length; i++) {
+ string = read(possibilities[i])
+ if (string) {
+ break
+ }
+ }
+
+ if (string === '+' && index > 1 && source[index - 2] === ' ') {
+ throw new Error('Space before `+`')
+ }
+
+ return string && {
+ type: 'OPERATOR',
+ string: string
+ }
+ }
+
+ function idstring () {
+ return read(/[A-Za-z0-9-.]+/)
+ }
+
+ function expectIdstring () {
+ var string = idstring()
+ if (!string) {
+ throw new Error('Expected idstring at offset ' + index)
+ }
+ return string
+ }
+
+ function documentRef () {
+ if (read('DocumentRef-')) {
+ var string = expectIdstring()
+ return { type: 'DOCUMENTREF', string: string }
+ }
+ }
+
+ function licenseRef () {
+ if (read('LicenseRef-')) {
+ var string = expectIdstring()
+ return { type: 'LICENSEREF', string: string }
+ }
+ }
+
+ function identifier () {
+ var begin = index
+ var string = idstring()
+
+ if (licenses.indexOf(string) !== -1) {
+ return {
+ type: 'LICENSE',
+ string: string
+ }
+ } else if (exceptions.indexOf(string) !== -1) {
+ return {
+ type: 'EXCEPTION',
+ string: string
+ }
+ }
+
+ index = begin
+ }
+
+ // Tries to read the next token. Returns `undefined` if no token is
+ // recognized.
+ function parseToken () {
+ // Ordering matters
+ return (
+ operator() ||
+ documentRef() ||
+ licenseRef() ||
+ identifier()
+ )
+ }
+
+ var tokens = []
+ while (hasMore()) {
+ skipWhitespace()
+ if (!hasMore()) {
+ break
+ }
+
+ var token = parseToken()
+ if (!token) {
+ throw new Error('Unexpected `' + source[index] +
+ '` at offset ' + index)
+ }
+
+ tokens.push(token)
+ }
+ return tokens
+}
diff --git a/deps/npm/package.json b/deps/npm/package.json
index 5fcd785d31bffd..d157883a10bbc7 100644
--- a/deps/npm/package.json
+++ b/deps/npm/package.json
@@ -1,5 +1,5 @@
{
- "version": "10.5.1",
+ "version": "10.5.2",
"name": "npm",
"description": "a package manager for JavaScript",
"workspaces": [
@@ -55,8 +55,8 @@
"@npmcli/arborist": "^7.2.1",
"@npmcli/config": "^8.0.2",
"@npmcli/fs": "^3.1.0",
- "@npmcli/map-workspaces": "^3.0.4",
- "@npmcli/package-json": "^5.0.0",
+ "@npmcli/map-workspaces": "^3.0.6",
+ "@npmcli/package-json": "^5.0.2",
"@npmcli/promise-spawn": "^7.0.1",
"@npmcli/redact": "^1.1.0",
"@npmcli/run-script": "^7.0.4",
@@ -76,7 +76,7 @@
"hosted-git-info": "^7.0.1",
"ini": "^4.1.2",
"init-package-json": "^6.0.2",
- "is-cidr": "^5.0.3",
+ "is-cidr": "^5.0.5",
"json-parse-even-better-errors": "^3.0.1",
"libnpmaccess": "^8.0.1",
"libnpmdiff": "^6.0.3",
@@ -112,7 +112,7 @@
"qrcode-terminal": "^0.12.0",
"read": "^3.0.1",
"semver": "^7.6.0",
- "spdx-expression-parse": "^3.0.1",
+ "spdx-expression-parse": "^4.0.0",
"ssri": "^10.0.5",
"supports-color": "^9.4.0",
"tar": "^6.2.1",
@@ -199,7 +199,7 @@
"devDependencies": {
"@npmcli/docs": "^1.0.0",
"@npmcli/eslint-config": "^4.0.2",
- "@npmcli/git": "^5.0.4",
+ "@npmcli/git": "^5.0.5",
"@npmcli/mock-globals": "^1.0.0",
"@npmcli/mock-registry": "^1.0.0",
"@npmcli/template-oss": "4.21.3",
diff --git a/deps/npm/tap-snapshots/test/lib/commands/config.js.test.cjs b/deps/npm/tap-snapshots/test/lib/commands/config.js.test.cjs
index 79518c2b8c8670..9d67091f7a0d4e 100644
--- a/deps/npm/tap-snapshots/test/lib/commands/config.js.test.cjs
+++ b/deps/npm/tap-snapshots/test/lib/commands/config.js.test.cjs
@@ -34,8 +34,6 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"color": true,
"commit-hooks": true,
"cpu": null,
- "os": null,
- "libc": null,
"depth": null,
"description": true,
"dev": false,
@@ -50,8 +48,8 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"dry-run": false,
"editor": "{EDITOR}",
"engine-strict": false,
- "expect-results": null,
"expect-result-count": null,
+ "expect-results": null,
"fetch-retries": 2,
"fetch-retry-factor": 10,
"fetch-retry-maxtimeout": 60000,
@@ -90,10 +88,9 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"key": null,
"legacy-bundling": false,
"legacy-peer-deps": false,
+ "libc": null,
"link": false,
"local-address": null,
- "sbom-format": null,
- "sbom-type": "library",
"location": "user",
"lockfile-version": null,
"loglevel": "notice",
@@ -111,6 +108,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"omit-lockfile-registry-resolved": false,
"only": null,
"optional": null,
+ "os": null,
"otp": null,
"package": [],
"package-lock": true,
@@ -138,6 +136,8 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"save-peer": false,
"save-prefix": "^",
"save-prod": false,
+ "sbom-format": null,
+ "sbom-type": "library",
"scope": "",
"script-shell": null,
"searchexclude": "",
diff --git a/deps/npm/tap-snapshots/test/lib/commands/publish.js.test.cjs b/deps/npm/tap-snapshots/test/lib/commands/publish.js.test.cjs
index 45406c994002aa..4f947be5cf5dec 100644
--- a/deps/npm/tap-snapshots/test/lib/commands/publish.js.test.cjs
+++ b/deps/npm/tap-snapshots/test/lib/commands/publish.js.test.cjs
@@ -350,6 +350,10 @@ Array [
]
`
+exports[`test/lib/commands/publish.js TAP prioritize CLI flags over publishConfig > new package version 1`] = `
++ test-package@1.0.0
+`
+
exports[`test/lib/commands/publish.js TAP public access > must match snapshot 1`] = `
Array [
Array [
diff --git a/deps/npm/tap-snapshots/test/lib/docs.js.test.cjs b/deps/npm/tap-snapshots/test/lib/docs.js.test.cjs
index e396fce2475ea3..64dad96903ec32 100644
--- a/deps/npm/tap-snapshots/test/lib/docs.js.test.cjs
+++ b/deps/npm/tap-snapshots/test/lib/docs.js.test.cjs
@@ -2078,8 +2078,6 @@ Array [
"color",
"commit-hooks",
"cpu",
- "os",
- "libc",
"depth",
"description",
"dev",
@@ -2094,8 +2092,8 @@ Array [
"dry-run",
"editor",
"engine-strict",
- "expect-results",
"expect-result-count",
+ "expect-results",
"fetch-retries",
"fetch-retry-factor",
"fetch-retry-maxtimeout",
@@ -2135,10 +2133,9 @@ Array [
"key",
"legacy-bundling",
"legacy-peer-deps",
+ "libc",
"link",
"local-address",
- "sbom-format",
- "sbom-type",
"location",
"lockfile-version",
"loglevel",
@@ -2154,6 +2151,7 @@ Array [
"omit-lockfile-registry-resolved",
"only",
"optional",
+ "os",
"otp",
"package",
"package-lock",
@@ -2182,6 +2180,8 @@ Array [
"save-peer",
"save-prefix",
"save-prod",
+ "sbom-format",
+ "sbom-type",
"scope",
"script-shell",
"searchexclude",
@@ -2238,8 +2238,6 @@ Array [
"color",
"commit-hooks",
"cpu",
- "os",
- "libc",
"depth",
"description",
"dev",
@@ -2281,9 +2279,8 @@ Array [
"key",
"legacy-bundling",
"legacy-peer-deps",
+ "libc",
"local-address",
- "sbom-format",
- "sbom-type",
"location",
"lockfile-version",
"loglevel",
@@ -2295,6 +2292,7 @@ Array [
"omit-lockfile-registry-resolved",
"only",
"optional",
+ "os",
"otp",
"package",
"package-lock",
@@ -2322,6 +2320,8 @@ Array [
"save-peer",
"save-prefix",
"save-prod",
+ "sbom-format",
+ "sbom-type",
"scope",
"script-shell",
"searchexclude",
@@ -2347,8 +2347,8 @@ Array [
exports[`test/lib/docs.js TAP config > keys that are not flattened 1`] = `
Array [
- "expect-results",
"expect-result-count",
+ "expect-results",
"init-author-email",
"init-author-name",
"init-author-url",
diff --git a/deps/npm/test/lib/commands/publish.js b/deps/npm/test/lib/commands/publish.js
index ec7299e9eec530..751cd97d8acf6e 100644
--- a/deps/npm/test/lib/commands/publish.js
+++ b/deps/npm/test/lib/commands/publish.js
@@ -131,6 +131,58 @@ t.test('re-loads publishConfig.registry if added during script process', async t
t.matchSnapshot(joinedOutput(), 'new package version')
})
+t.test('prioritize CLI flags over publishConfig', async t => {
+ const publishConfig = { registry: 'http://publishconfig' }
+ const { joinedOutput, npm } = await loadMockNpm(t, {
+ config: {
+ [`${alternateRegistry.slice(6)}/:_authToken`]: 'test-other-token',
+ },
+ prefixDir: {
+ 'package.json': JSON.stringify({
+ ...pkgJson,
+ scripts: {
+ prepare: 'cp new.json package.json',
+ },
+ }, null, 2),
+ 'new.json': JSON.stringify({
+ ...pkgJson,
+ publishConfig,
+ }),
+ },
+ argv: ['--registry', alternateRegistry],
+ })
+ const registry = new MockRegistry({
+ tap: t,
+ registry: alternateRegistry,
+ authorization: 'test-other-token',
+ })
+ registry.nock.put(`/${pkg}`, body => {
+ return t.match(body, {
+ _id: pkg,
+ name: pkg,
+ 'dist-tags': { latest: '1.0.0' },
+ access: null,
+ versions: {
+ '1.0.0': {
+ name: pkg,
+ version: '1.0.0',
+ _id: `${pkg}@1.0.0`,
+ dist: {
+ shasum: /\.*/,
+ tarball: `http:${alternateRegistry.slice(6)}/test-package/-/test-package-1.0.0.tgz`,
+ },
+ publishConfig,
+ },
+ },
+ _attachments: {
+ [`${pkg}-1.0.0.tgz`]: {},
+ },
+ })
+ }).reply(200, {})
+ await npm.exec('publish', [])
+ t.matchSnapshot(joinedOutput(), 'new package version')
+})
+
t.test('json', async t => {
const { joinedOutput, npm, logs } = await loadMockNpm(t, {
config: {
diff --git a/deps/npm/test/lib/commands/unpublish.js b/deps/npm/test/lib/commands/unpublish.js
index 097309393a2585..31dc77ea46cd0c 100644
--- a/deps/npm/test/lib/commands/unpublish.js
+++ b/deps/npm/test/lib/commands/unpublish.js
@@ -408,6 +408,36 @@ t.test('publishConfig no spec', async t => {
t.equal(joinedOutput(), '- test-package')
})
+t.test('prioritize CLI flags over publishConfig no spec', async t => {
+ const alternateRegistry = 'https://other.registry.npmjs.org'
+ const publishConfig = { registry: 'http://publishconfig' }
+ const { joinedOutput, npm } = await loadMockNpm(t, {
+ config: {
+ force: true,
+ '//other.registry.npmjs.org/:_authToken': 'test-other-token',
+ },
+ prefixDir: {
+ 'package.json': JSON.stringify({
+ name: pkg,
+ version: '1.0.0',
+ publishConfig,
+ }, null, 2),
+ },
+ argv: ['--registry', alternateRegistry],
+ })
+
+ const registry = new MockRegistry({
+ tap: t,
+ registry: alternateRegistry,
+ authorization: 'test-other-token',
+ })
+ const manifest = registry.manifest({ name: pkg })
+ await registry.package({ manifest, query: { write: true }, times: 2 })
+ registry.unpublish({ manifest })
+ await npm.exec('unpublish', [])
+ t.equal(joinedOutput(), '- test-package')
+})
+
t.test('publishConfig with spec', async t => {
const alternateRegistry = 'https://other.registry.npmjs.org'
const { joinedOutput, npm } = await loadMockNpm(t, {
diff --git a/deps/npm/test/lib/utils/log-file.js b/deps/npm/test/lib/utils/log-file.js
index c02f338a84ee01..f34dda8f524337 100644
--- a/deps/npm/test/lib/utils/log-file.js
+++ b/deps/npm/test/lib/utils/log-file.js
@@ -57,8 +57,10 @@ const loadLogFile = async (t, { buffer = [], mocks, testdir = {}, ...options } =
logFile,
LogFile,
readLogs: async () => {
- const logDir = await fs.readdir(root)
- const logFiles = logDir.map((f) => path.join(root, f))
+ const logDir = await fs.readdir(root, { withFileTypes: true })
+ const logFiles = logDir
+ .filter(f => f.isFile())
+ .map((f) => path.join(root, f.name))
.filter((f) => _fs.existsSync(f))
return Promise.all(logFiles.map(async (f) => {
const content = await fs.readFile(f, 'utf8')
@@ -202,6 +204,22 @@ t.test('cleans logs', async t => {
t.equal(logs.length, logsMax + 1)
})
+t.test('cleans logs even when find folder inside logs folder', async t => {
+ const logsMax = 5
+ const { readLogs } = await loadLogFile(t, {
+ logsMax,
+ testdir: {
+ ...makeOldLogs(10),
+ ignore_folder: {
+ 'ignored-file.txt': 'hello',
+ },
+ },
+ })
+
+ const logs = await readLogs()
+ t.equal(logs.length, logsMax + 1)
+})
+
t.test('doesnt clean current log by default', async t => {
const logsMax = 1
const { readLogs, logFile } = await loadLogFile(t, {
@@ -240,35 +258,6 @@ t.test('doesnt need to clean', async t => {
t.equal(logs.length, oldLogs + 1)
})
-t.test('glob error', async t => {
- const { readLogs } = await loadLogFile(t, {
- logsMax: 5,
- mocks: {
- glob: { glob: () => {
- throw new Error('bad glob')
- } },
- },
- })
-
- const logs = await readLogs()
- t.equal(logs.length, 1)
- t.match(last(logs).content, /error cleaning log files .* bad glob/)
-})
-
-t.test('do not log cleaning errors when logging is disabled', async t => {
- const { readLogs } = await loadLogFile(t, {
- logsMax: 0,
- mocks: {
- glob: () => {
- throw new Error('should not be logged')
- },
- },
- })
-
- const logs = await readLogs()
- t.equal(logs.length, 0)
-})
-
t.test('cleans old style logs too', async t => {
const logsMax = 5
const oldLogs = 10
@@ -290,6 +279,7 @@ t.test('rimraf error', async t => {
testdir: makeOldLogs(oldLogs),
mocks: {
'fs/promises': {
+ readdir: fs.readdir,
rm: async (...args) => {
if (count >= 3) {
throw new Error('bad rimraf')
From 44ee04cf9fc08d3a1bdde737e02a7ff033b2d430 Mon Sep 17 00:00:00 2001
From: Yagiz Nizipli
Date: Thu, 11 Apr 2024 22:50:25 -0400
Subject: [PATCH 04/98] buffer: improve `base64` and `base64url` performance
Co-authored-by: Daniel Lemire
PR-URL: https://github.com/nodejs/node/pull/52428
Reviewed-By: Matteo Collina
Reviewed-By: Benjamin Gruenbaum
Reviewed-By: James M Snell
---
src/string_bytes.cc | 133 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 119 insertions(+), 14 deletions(-)
diff --git a/src/string_bytes.cc b/src/string_bytes.cc
index b3c0a90b548c70..c6ebcf89c4058b 100644
--- a/src/string_bytes.cc
+++ b/src/string_bytes.cc
@@ -346,17 +346,113 @@ size_t StringBytes::Write(Isolate* isolate,
}
case BASE64URL:
- // Fall through
- case BASE64:
- if (str->IsExternalOneByte()) {
+ if (str->IsExternalOneByte()) { // 8-bit case
auto ext = str->GetExternalOneByteStringResource();
- nbytes = base64_decode(buf, buflen, ext->data(), ext->length());
+ size_t written_len = buflen;
+ auto result = simdutf::base64_to_binary_safe(
+ ext->data(), ext->length(), buf, written_len, simdutf::base64_url);
+ if (result.error == simdutf::error_code::SUCCESS) {
+ nbytes = written_len;
+ } else {
+ // The input does not follow the WHATWG forgiving-base64 specification
+ // adapted for base64url
+ // https://infra.spec.whatwg.org/#forgiving-base64-decode
+ nbytes = base64_decode(buf, buflen, ext->data(), ext->length());
+ }
+ } else if (str->IsOneByte()) {
+ MaybeStackBuffer stack_buf(str->Length());
+ str->WriteOneByte(isolate,
+ stack_buf.out(),
+ 0,
+ str->Length(),
+ String::NO_NULL_TERMINATION);
+ size_t written_len = buflen;
+ auto result = simdutf::base64_to_binary_safe(
+ reinterpret_cast(*stack_buf),
+ stack_buf.length(),
+ buf,
+ written_len,
+ simdutf::base64_url);
+ if (result.error == simdutf::error_code::SUCCESS) {
+ nbytes = written_len;
+ } else {
+ // The input does not follow the WHATWG forgiving-base64 specification
+ // (adapted for base64url with + and / replaced by - and _).
+ // https://infra.spec.whatwg.org/#forgiving-base64-decode
+ nbytes = base64_decode(buf, buflen, *stack_buf, stack_buf.length());
+ }
} else {
String::Value value(isolate, str);
- nbytes = base64_decode(buf, buflen, *value, value.length());
+ size_t written_len = buflen;
+ auto result = simdutf::base64_to_binary_safe(
+ reinterpret_cast(*value),
+ value.length(),
+ buf,
+ written_len,
+ simdutf::base64_url);
+ if (result.error == simdutf::error_code::SUCCESS) {
+ nbytes = written_len;
+ } else {
+ // The input does not follow the WHATWG forgiving-base64 specification
+ // (adapted for base64url with + and / replaced by - and _).
+ // https://infra.spec.whatwg.org/#forgiving-base64-decode
+ nbytes = base64_decode(buf, buflen, *value, value.length());
+ }
}
break;
+ case BASE64: {
+ if (str->IsExternalOneByte()) { // 8-bit case
+ auto ext = str->GetExternalOneByteStringResource();
+ size_t written_len = buflen;
+ auto result = simdutf::base64_to_binary_safe(
+ ext->data(), ext->length(), buf, written_len);
+ if (result.error == simdutf::error_code::SUCCESS) {
+ nbytes = written_len;
+ } else {
+ // The input does not follow the WHATWG forgiving-base64 specification
+ // https://infra.spec.whatwg.org/#forgiving-base64-decode
+ nbytes = base64_decode(buf, buflen, ext->data(), ext->length());
+ }
+ } else if (str->IsOneByte()) {
+ MaybeStackBuffer stack_buf(str->Length());
+ str->WriteOneByte(isolate,
+ stack_buf.out(),
+ 0,
+ str->Length(),
+ String::NO_NULL_TERMINATION);
+ size_t written_len = buflen;
+ auto result = simdutf::base64_to_binary_safe(
+ reinterpret_cast(*stack_buf),
+ stack_buf.length(),
+ buf,
+ written_len);
+ if (result.error == simdutf::error_code::SUCCESS) {
+ nbytes = written_len;
+ } else {
+ // The input does not follow the WHATWG forgiving-base64 specification
+ // (adapted for base64url with + and / replaced by - and _).
+ // https://infra.spec.whatwg.org/#forgiving-base64-decode
+ nbytes = base64_decode(buf, buflen, *stack_buf, stack_buf.length());
+ }
+ } else {
+ String::Value value(isolate, str);
+ size_t written_len = buflen;
+ auto result = simdutf::base64_to_binary_safe(
+ reinterpret_cast(*value),
+ value.length(),
+ buf,
+ written_len);
+ if (result.error == simdutf::error_code::SUCCESS) {
+ nbytes = written_len;
+ } else {
+ // The input does not follow the WHATWG base64 specification
+ // https://infra.spec.whatwg.org/#forgiving-base64-decode
+ nbytes = base64_decode(buf, buflen, *value, value.length());
+ }
+ }
+ break;
+ }
case HEX:
if (str->IsExternalOneByte()) {
auto ext = str->GetExternalOneByteStringResource();
@@ -411,9 +507,12 @@ Maybe StringBytes::StorageSize(Isolate* isolate,
break;
case BASE64URL:
- // Fall through
+ data_size = simdutf::base64_length_from_binary(str->Length(),
+ simdutf::base64_url);
+ break;
+
case BASE64:
- data_size = base64_decoded_size_fast(str->Length());
+ data_size = simdutf::base64_length_from_binary(str->Length());
break;
case HEX:
@@ -452,11 +551,15 @@ Maybe StringBytes::Size(Isolate* isolate,
case UCS2:
return Just(str->Length() * sizeof(uint16_t));
- case BASE64URL:
- // Fall through
+ case BASE64URL: {
+ String::Value value(isolate, str);
+ return Just(simdutf::base64_length_from_binary(value.length(),
+ simdutf::base64_url));
+ }
+
case BASE64: {
String::Value value(isolate, str);
- return Just(base64_decoded_size(*value, value.length()));
+ return Just(simdutf::base64_length_from_binary(value.length()));
}
case HEX:
@@ -609,28 +712,30 @@ MaybeLocal StringBytes::Encode(Isolate* isolate,
return ExternOneByteString::NewFromCopy(isolate, buf, buflen, error);
case BASE64: {
- size_t dlen = base64_encoded_size(buflen);
+ size_t dlen = simdutf::base64_length_from_binary(buflen);
char* dst = node::UncheckedMalloc(dlen);
if (dst == nullptr) {
*error = node::ERR_MEMORY_ALLOCATION_FAILED(isolate);
return MaybeLocal();
}
- size_t written = base64_encode(buf, buflen, dst, dlen);
+ size_t written = simdutf::binary_to_base64(buf, buflen, dst);
CHECK_EQ(written, dlen);
return ExternOneByteString::New(isolate, dst, dlen, error);
}
case BASE64URL: {
- size_t dlen = base64_encoded_size(buflen, Base64Mode::URL);
+ size_t dlen =
+ simdutf::base64_length_from_binary(buflen, simdutf::base64_url);
char* dst = node::UncheckedMalloc(dlen);
if (dst == nullptr) {
*error = node::ERR_MEMORY_ALLOCATION_FAILED(isolate);
return MaybeLocal();
}
- size_t written = base64_encode(buf, buflen, dst, dlen, Base64Mode::URL);
+ size_t written =
+ simdutf::binary_to_base64(buf, buflen, dst, simdutf::base64_url);
CHECK_EQ(written, dlen);
return ExternOneByteString::New(isolate, dst, dlen, error);
From f6145aa2ca3fa34a2fad2318b41f7284c2c76af4 Mon Sep 17 00:00:00 2001
From: Chengzhong Wu
Date: Fri, 12 Apr 2024 15:39:56 +0100
Subject: [PATCH 05/98] lib: convert WeakMaps in cjs loader with private symbol
properties
Symbol properties are typically more GC-efficient than using WeakMaps,
since WeakMap requires ephemeron GC. `module[kModuleExportNames]`
would be easier to read than `importedCJSCache.get(module).exportNames`
as well.
PR-URL: https://github.com/nodejs/node/pull/52095
Reviewed-By: Geoffrey Booth
Reviewed-By: Joyee Cheung
Reviewed-By: Antoine du Hamel
---
lib/internal/modules/cjs/loader.js | 107 ++++++++++++++----------
lib/internal/modules/esm/translators.js | 21 +++--
src/env_properties.h | 5 ++
3 files changed, 79 insertions(+), 54 deletions(-)
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index cacabb771f7115..a81f180958aebf 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -50,7 +50,6 @@ const {
ReflectSet,
RegExpPrototypeExec,
SafeMap,
- SafeWeakMap,
String,
StringPrototypeCharAt,
StringPrototypeCharCodeAt,
@@ -62,16 +61,39 @@ const {
StringPrototypeStartsWith,
Symbol,
} = primordials;
+const {
+ privateSymbols: {
+ module_source_private_symbol,
+ module_export_names_private_symbol,
+ module_circular_visited_private_symbol,
+ module_export_private_symbol,
+ module_parent_private_symbol,
+ },
+} = internalBinding('util');
const { kEvaluated } = internalBinding('module_wrap');
-// Map used to store CJS parsing data or for ESM loading.
-const importedCJSCache = new SafeWeakMap();
+// Internal properties for Module instances.
+/**
+ * Cached {@link Module} source string.
+ */
+const kModuleSource = module_source_private_symbol;
+/**
+ * Cached {@link Module} export names for ESM loader.
+ */
+const kModuleExportNames = module_export_names_private_symbol;
+/**
+ * {@link Module} circular dependency visited flag.
+ */
+const kModuleCircularVisited = module_circular_visited_private_symbol;
/**
- * Map of already-loaded CJS modules to use.
+ * {@link Module} export object snapshot for ESM loader.
*/
-const cjsExportsCache = new SafeWeakMap();
-const requiredESMSourceCache = new SafeWeakMap();
+const kModuleExport = module_export_private_symbol;
+/**
+ * {@link Module} parent module.
+ */
+const kModuleParent = module_parent_private_symbol;
const kIsMainSymbol = Symbol('kIsMainSymbol');
const kIsCachedByESMLoader = Symbol('kIsCachedByESMLoader');
@@ -79,8 +101,10 @@ const kRequiredModuleSymbol = Symbol('kRequiredModuleSymbol');
const kIsExecuting = Symbol('kIsExecuting');
// Set first due to cycle with ESM loader functions.
module.exports = {
- cjsExportsCache,
- importedCJSCache,
+ kModuleSource,
+ kModuleExport,
+ kModuleExportNames,
+ kModuleCircularVisited,
initializeCJS,
entryPointSource: undefined, // Set below.
Module,
@@ -257,8 +281,6 @@ function reportModuleNotFoundToWatchMode(basePath, extensions) {
}
}
-/** @type {Map} */
-const moduleParentCache = new SafeWeakMap();
/**
* Create a new module instance.
* @param {string} id
@@ -268,7 +290,7 @@ function Module(id = '', parent) {
this.id = id;
this.path = path.dirname(id);
setOwnProperty(this, 'exports', {});
- moduleParentCache.set(this, parent);
+ this[kModuleParent] = parent;
updateChildren(parent, this, false);
this.filename = null;
this.loaded = false;
@@ -356,17 +378,19 @@ ObjectDefineProperty(BuiltinModule.prototype, 'isPreloading', isPreloadingDesc);
/**
* Get the parent of the current module from our cache.
+ * @this {Module}
*/
function getModuleParent() {
- return moduleParentCache.get(this);
+ return this[kModuleParent];
}
/**
* Set the parent of the current module in our cache.
+ * @this {Module}
* @param {Module} value
*/
function setModuleParent(value) {
- moduleParentCache.set(this, value);
+ this[kModuleParent] = value;
}
let debug = require('internal/util/debuglog').debuglog('module', (fn) => {
@@ -955,7 +979,7 @@ function getExportsForCircularRequire(module) {
const requiredESM = module[kRequiredModuleSymbol];
if (requiredESM && requiredESM.getStatus() !== kEvaluated) {
let message = `Cannot require() ES Module ${module.id} in a cycle.`;
- const parent = moduleParentCache.get(module);
+ const parent = module[kModuleParent];
if (parent) {
message += ` (from ${parent.filename})`;
}
@@ -1028,25 +1052,24 @@ Module._load = function(request, parent, isMain) {
const cachedModule = Module._cache[filename];
if (cachedModule !== undefined) {
updateChildren(parent, cachedModule, true);
- if (!cachedModule.loaded) {
- // If it's not cached by the ESM loader, the loading request
- // comes from required CJS, and we can consider it a circular
- // dependency when it's cached.
- if (!cachedModule[kIsCachedByESMLoader]) {
- return getExportsForCircularRequire(cachedModule);
- }
- // If it's cached by the ESM loader as a way to indirectly pass
- // the module in to avoid creating it twice, the loading request
- // come from imported CJS. In that case use the importedCJSCache
- // to determine if it's loading or not.
- const importedCJSMetadata = importedCJSCache.get(cachedModule);
- if (importedCJSMetadata.loading) {
- return getExportsForCircularRequire(cachedModule);
- }
- importedCJSMetadata.loading = true;
- } else {
+ if (cachedModule.loaded) {
return cachedModule.exports;
}
+ // If it's not cached by the ESM loader, the loading request
+ // comes from required CJS, and we can consider it a circular
+ // dependency when it's cached.
+ if (!cachedModule[kIsCachedByESMLoader]) {
+ return getExportsForCircularRequire(cachedModule);
+ }
+ // If it's cached by the ESM loader as a way to indirectly pass
+ // the module in to avoid creating it twice, the loading request
+ // come from imported CJS. In that case use the kModuleCircularVisited
+ // to determine if it's loading or not.
+ if (cachedModule[kModuleCircularVisited]) {
+ return getExportsForCircularRequire(cachedModule);
+ }
+ // This is an ESM loader created cache entry, mark it as visited and fallthrough to loading the module.
+ cachedModule[kModuleCircularVisited] = true;
}
if (BuiltinModule.canBeRequiredWithoutScheme(filename)) {
@@ -1190,7 +1213,7 @@ Module._resolveFilename = function(request, parent, isMain, options) {
const requireStack = [];
for (let cursor = parent;
cursor;
- cursor = moduleParentCache.get(cursor)) {
+ cursor = cursor[kModuleParent]) {
ArrayPrototypePush(requireStack, cursor.filename || cursor.id);
}
let message = `Cannot find module '${request}'`;
@@ -1268,9 +1291,7 @@ Module.prototype.load = function(filename) {
// Create module entry at load time to snapshot exports correctly
const exports = this.exports;
// Preemptively cache for ESM loader.
- if (!cjsExportsCache.has(this)) {
- cjsExportsCache.set(this, exports);
- }
+ this[kModuleExport] = exports;
};
/**
@@ -1313,7 +1334,7 @@ function loadESMFromCJS(mod, filename) {
const isMain = mod[kIsMainSymbol];
// TODO(joyeecheung): we may want to invent optional special handling for default exports here.
// For now, it's good enough to be identical to what `import()` returns.
- mod.exports = cascadedLoader.importSyncForRequire(mod, filename, source, isMain, moduleParentCache.get(mod));
+ mod.exports = cascadedLoader.importSyncForRequire(mod, filename, source, isMain, mod[kModuleParent]);
}
/**
@@ -1406,7 +1427,7 @@ Module.prototype._compile = function(content, filename, loadAsESM = false) {
// Only modules being require()'d really need to avoid TLA.
if (loadAsESM) {
// Pass the source into the .mjs extension handler indirectly through the cache.
- requiredESMSourceCache.set(this, content);
+ this[kModuleSource] = content;
loadESMFromCJS(this, filename);
return;
}
@@ -1467,15 +1488,15 @@ Module.prototype._compile = function(content, filename, loadAsESM = false) {
* @returns {string}
*/
function getMaybeCachedSource(mod, filename) {
- const cached = importedCJSCache.get(mod);
+ // If already analyzed the source, then it will be cached.
let content;
- if (cached?.source) {
- content = cached.source;
- cached.source = undefined;
+ if (mod[kModuleSource] !== undefined) {
+ content = mod[kModuleSource];
+ mod[kModuleSource] = undefined;
} else {
// TODO(joyeecheung): we can read a buffer instead to speed up
// compilation.
- content = requiredESMSourceCache.get(mod) ?? fs.readFileSync(filename, 'utf8');
+ content = fs.readFileSync(filename, 'utf8');
}
return content;
}
@@ -1499,7 +1520,7 @@ Module._extensions['.js'] = function(module, filename) {
}
// This is an error path because `require` of a `.js` file in a `"type": "module"` scope is not allowed.
- const parent = moduleParentCache.get(module);
+ const parent = module[kModuleParent];
const parentPath = parent?.filename;
const packageJsonPath = path.resolve(pkg.path, 'package.json');
const usesEsm = containsModuleSyntax(content, filename);
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index 7cb4350b675ba9..4bdee1b843fbd5 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -43,10 +43,11 @@ const {
stripBOM,
} = require('internal/modules/helpers');
const {
- cjsExportsCache,
- importedCJSCache,
kIsCachedByESMLoader,
Module: CJSModule,
+ kModuleSource,
+ kModuleExport,
+ kModuleExportNames,
} = require('internal/modules/cjs/loader');
const { fileURLToPath, pathToFileURL, URL } = require('internal/url');
let debug = require('internal/util/debuglog').debuglog('esm', (fn) => {
@@ -285,9 +286,9 @@ function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
}
let exports;
- if (cjsExportsCache.has(module)) {
- exports = cjsExportsCache.get(module);
- cjsExportsCache.delete(module);
+ if (module[kModuleExport] !== undefined) {
+ exports = module[kModuleExport];
+ module[kModuleExport] = undefined;
} else {
({ exports } = module);
}
@@ -366,11 +367,8 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
function cjsPreparseModuleExports(filename, source) {
// TODO: Do we want to keep hitting the user mutable CJS loader here?
let module = CJSModule._cache[filename];
- if (module) {
- const cached = importedCJSCache.get(module);
- if (cached) {
- return { module, exportNames: cached.exportNames };
- }
+ if (module && module[kModuleExportNames] !== undefined) {
+ return { module, exportNames: module[kModuleExportNames] };
}
const loaded = Boolean(module);
if (!loaded) {
@@ -378,6 +376,7 @@ function cjsPreparseModuleExports(filename, source) {
module.filename = filename;
module.paths = CJSModule._nodeModulePaths(module.path);
module[kIsCachedByESMLoader] = true;
+ module[kModuleSource] = source;
CJSModule._cache[filename] = module;
}
@@ -392,7 +391,7 @@ function cjsPreparseModuleExports(filename, source) {
const exportNames = new SafeSet(new SafeArrayIterator(exports));
// Set first for cycles.
- importedCJSCache.set(module, { source, exportNames });
+ module[kModuleExportNames] = exportNames;
if (reexports.length) {
module.filename = filename;
diff --git a/src/env_properties.h b/src/env_properties.h
index 55ca60d9f4992b..c28878486e4ac2 100644
--- a/src/env_properties.h
+++ b/src/env_properties.h
@@ -26,6 +26,11 @@
V(js_transferable_wrapper_private_symbol, "node:js_transferable_wrapper") \
V(entry_point_module_private_symbol, "node:entry_point_module") \
V(entry_point_promise_private_symbol, "node:entry_point_promise") \
+ V(module_source_private_symbol, "node:module_source") \
+ V(module_export_names_private_symbol, "node:module_export_names") \
+ V(module_circular_visited_private_symbol, "node:module_circular_visited") \
+ V(module_export_private_symbol, "node:module_export") \
+ V(module_parent_private_symbol, "node:module_parent") \
V(napi_type_tag, "node:napi:type_tag") \
V(napi_wrapper, "node:napi:wrapper") \
V(untransferable_object_private_symbol, "node:untransferableObject") \
From fdcde845ee0f9fbfd3624ef6bea229c37755a29c Mon Sep 17 00:00:00 2001
From: Victor Chen
Date: Sat, 13 Apr 2024 01:54:42 +0800
Subject: [PATCH 06/98] lib: refactor lazy loading of undici for fetch method
Object.defineProperty is updated to lazily load the undici dependency
for the fetch method. This change allows for simpler and more reliable
mocking of the fetch method for testing purposes, resolving issues
encountered with premature method invocation during testing.
Fixes: https://github.com/nodejs/node/issues/52015
PR-URL: https://github.com/nodejs/node/pull/52275
Reviewed-By: Moshe Atlow
Reviewed-By: Matteo Collina
Reviewed-By: Chemi Atlow
Reviewed-By: James M Snell
Reviewed-By: Joyee Cheung
---
.../bootstrap/web/exposed-window-or-worker.js | 41 +++++++------------
test/parallel/test-fetch-mock.js | 20 +++++++++
2 files changed, 35 insertions(+), 26 deletions(-)
create mode 100644 test/parallel/test-fetch-mock.js
diff --git a/lib/internal/bootstrap/web/exposed-window-or-worker.js b/lib/internal/bootstrap/web/exposed-window-or-worker.js
index 2459bee85bb8b0..82888b3cd9512e 100644
--- a/lib/internal/bootstrap/web/exposed-window-or-worker.js
+++ b/lib/internal/bootstrap/web/exposed-window-or-worker.js
@@ -57,32 +57,21 @@ defineReplaceableLazyAttribute(globalThis, 'perf_hooks', ['performance']);
const { installObjectURLMethods } = require('internal/url');
installObjectURLMethods();
-{
- // https://fetch.spec.whatwg.org/#fetch-method
- function set(value) {
- ObjectDefineProperty(globalThis, 'fetch', {
- __proto__: null,
- writable: true,
- value,
- });
- }
- ObjectDefineProperty(globalThis, 'fetch', {
- __proto__: null,
- configurable: true,
- enumerable: true,
- set,
- get() {
- function fetch(input, init = undefined) {
- // Loading undici alone lead to promises which breaks lots of tests so we
- // have to load it really lazily for now.
- const { fetch: impl } = require('internal/deps/undici/undici');
- return impl(input, init);
- }
- set(fetch);
- return fetch;
- },
- });
-}
+let fetchImpl;
+// https://fetch.spec.whatwg.org/#fetch-method
+ObjectDefineProperty(globalThis, 'fetch', {
+ __proto__: null,
+ configurable: true,
+ enumerable: true,
+ writable: true,
+ value: function value(input, init = undefined) {
+ if (!fetchImpl) { // Implement lazy loading of undici module for fetch function
+ const undiciModule = require('internal/deps/undici/undici');
+ fetchImpl = undiciModule.fetch;
+ }
+ return fetchImpl(input, init);
+ },
+});
// https://xhr.spec.whatwg.org/#interface-formdata
// https://fetch.spec.whatwg.org/#headers-class
diff --git a/test/parallel/test-fetch-mock.js b/test/parallel/test-fetch-mock.js
new file mode 100644
index 00000000000000..b457745f1c4c90
--- /dev/null
+++ b/test/parallel/test-fetch-mock.js
@@ -0,0 +1,20 @@
+'use strict';
+require('../common');
+const { mock, test } = require('node:test');
+const assert = require('node:assert');
+
+test('should correctly stub globalThis.fetch', async () => {
+ const customFetch = async (url) => {
+ return {
+ text: async () => 'foo',
+ };
+ };
+
+ mock.method(globalThis, 'fetch', customFetch);
+
+ const response = await globalThis.fetch('some-url');
+ const text = await response.text();
+
+ assert.strictEqual(text, 'foo');
+ mock.restoreAll();
+});
From 9b18df9dcbfcc9307812427619c8f3a9c6f34f31 Mon Sep 17 00:00:00 2001
From: Ali Hassan <24819103+thisalihassan@users.noreply.github.com>
Date: Sat, 13 Apr 2024 17:57:12 +0500
Subject: [PATCH 07/98] url: implement parse method for safer URL parsing
Implement the static parse method as per the WHATWG URL specification.
Unlike the URL constructor, URL.parse does not throw on invalid input,
instead returning null. This behavior allows safer parsing of URLs
without the need for try-catch blocks around constructor calls. The
implementation follows the steps outlined in the WHATWG URL standard,
ensuring compatibility and consistency with web platform URL parsing
APIs.
Fixes: https://github.com/nodejs/node/issues/52208
Refs: https://github.com/whatwg/url/pull/825
PR-URL: https://github.com/nodejs/node/pull/52280
Reviewed-By: Yagiz Nizipli
Reviewed-By: Matteo Collina
Reviewed-By: Daniel Lemire
Reviewed-By: Benjamin Gruenbaum
---
lib/internal/url.js | 24 ++-
src/node_url.cc | 11 +-
test/fixtures/wpt/README.md | 2 +-
.../wpt/url/resources/urltestdata.json | 185 ++++++++++++++++++
.../fixtures/wpt/url/url-statics-parse.any.js | 50 +++++
test/fixtures/wpt/versions.json | 2 +-
6 files changed, 268 insertions(+), 6 deletions(-)
create mode 100644 test/fixtures/wpt/url/url-statics-parse.any.js
diff --git a/lib/internal/url.js b/lib/internal/url.js
index 0e69ff52b5edef..39d79392bd86bc 100644
--- a/lib/internal/url.js
+++ b/lib/internal/url.js
@@ -769,6 +769,14 @@ function isURL(self) {
return Boolean(self?.href && self.protocol && self.auth === undefined && self.path === undefined);
}
+/**
+ * A unique symbol used as a private identifier to safely invoke the URL constructor
+ * with a special parsing behavior. When passed as the third argument to the URL
+ * constructor, it signals that the constructor should not throw an exception
+ * for invalid URL inputs.
+ */
+const kParseURLSymbol = Symbol('kParseURL');
+
class URL {
#context = new URLContext();
#searchParams;
@@ -787,7 +795,7 @@ class URL {
};
}
- constructor(input, base = undefined) {
+ constructor(input, base = undefined, parseSymbol = undefined) {
markTransferMode(this, false, false);
if (arguments.length === 0) {
@@ -801,7 +809,19 @@ class URL {
base = `${base}`;
}
- this.#updateContext(bindingUrl.parse(input, base));
+ const raiseException = parseSymbol !== kParseURLSymbol;
+ const href = bindingUrl.parse(input, base, raiseException);
+ if (href) {
+ this.#updateContext(href);
+ }
+ }
+
+ static parse(input, base = undefined) {
+ if (arguments.length === 0) {
+ throw new ERR_MISSING_ARGS('url');
+ }
+ const parsedURLObject = new URL(input, base, kParseURLSymbol);
+ return parsedURLObject.href ? parsedURLObject : null;
}
[inspect.custom](depth, opts) {
diff --git a/src/node_url.cc b/src/node_url.cc
index 95d15c78407359..74b639c23084b5 100644
--- a/src/node_url.cc
+++ b/src/node_url.cc
@@ -233,6 +233,9 @@ void BindingData::Parse(const FunctionCallbackInfo& args) {
CHECK_GE(args.Length(), 1);
CHECK(args[0]->IsString()); // input
// args[1] // base url
+ // args[2] // raise Exception
+
+ const bool raise_exception = args.Length() > 2 && args[2]->IsTrue();
Realm* realm = Realm::GetCurrent(args);
BindingData* binding_data = realm->GetBindingData();
@@ -245,16 +248,20 @@ void BindingData::Parse(const FunctionCallbackInfo& args) {
if (args[1]->IsString()) {
base_ = Utf8Value(isolate, args[1]).ToString();
base = ada::parse(*base_);
- if (!base) {
+ if (!base && raise_exception) {
return ThrowInvalidURL(realm->env(), input.ToStringView(), base_);
+ } else if (!base) {
+ return;
}
base_pointer = &base.value();
}
auto out =
ada::parse(input.ToStringView(), base_pointer);
- if (!out) {
+ if (!out && raise_exception) {
return ThrowInvalidURL(realm->env(), input.ToStringView(), base_);
+ } else if (!out) {
+ return;
}
binding_data->UpdateComponents(out->get_components(), out->type);
diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md
index a4ca98dc7ffa4f..3a2bb782480ef6 100644
--- a/test/fixtures/wpt/README.md
+++ b/test/fixtures/wpt/README.md
@@ -28,7 +28,7 @@ Last update:
- resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
- resources: https://github.com/web-platform-tests/wpt/tree/1e140d63ec/resources
- streams: https://github.com/web-platform-tests/wpt/tree/3df6d94318/streams
-- url: https://github.com/web-platform-tests/wpt/tree/c2d7e70b52/url
+- url: https://github.com/web-platform-tests/wpt/tree/0f550ab9f5/url
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
diff --git a/test/fixtures/wpt/url/resources/urltestdata.json b/test/fixtures/wpt/url/resources/urltestdata.json
index 287a84b467a48b..9f1be0449c63d3 100644
--- a/test/fixtures/wpt/url/resources/urltestdata.json
+++ b/test/fixtures/wpt/url/resources/urltestdata.json
@@ -734,6 +734,36 @@
"search": "",
"hash": ""
},
+ {
+ "input": "http://a:b@c\\",
+ "base": null,
+ "href": "http://a:b@c/",
+ "origin": "http://c",
+ "protocol": "http:",
+ "username": "a",
+ "password": "b",
+ "host": "c",
+ "hostname": "c",
+ "port": "",
+ "pathname": "/",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "ws://a@b\\c",
+ "base": null,
+ "href": "ws://a@b/c",
+ "origin": "ws://b",
+ "protocol": "ws:",
+ "username": "a",
+ "password": "",
+ "host": "b",
+ "hostname": "b",
+ "port": "",
+ "pathname": "/c",
+ "search": "",
+ "hash": ""
+ },
{
"input": "foo:/",
"base": "http://example.org/foo/bar",
@@ -9529,5 +9559,160 @@
"pathname": "",
"search": "",
"hash": ""
+ },
+ "Scheme relative path starting with multiple slashes",
+ {
+ "input": "///test",
+ "base": "http://example.org/",
+ "href": "http://test/",
+ "protocol": "http:",
+ "username": "",
+ "password": "",
+ "host": "test",
+ "hostname": "test",
+ "port": "",
+ "pathname": "/",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "///\\//\\//test",
+ "base": "http://example.org/",
+ "href": "http://test/",
+ "protocol": "http:",
+ "username": "",
+ "password": "",
+ "host": "test",
+ "hostname": "test",
+ "port": "",
+ "pathname": "/",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "///example.org/path",
+ "base": "http://example.org/",
+ "href": "http://example.org/path",
+ "protocol": "http:",
+ "username": "",
+ "password": "",
+ "host": "example.org",
+ "hostname": "example.org",
+ "port": "",
+ "pathname": "/path",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "///example.org/../path",
+ "base": "http://example.org/",
+ "href": "http://example.org/path",
+ "protocol": "http:",
+ "username": "",
+ "password": "",
+ "host": "example.org",
+ "hostname": "example.org",
+ "port": "",
+ "pathname": "/path",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "///example.org/../../",
+ "base": "http://example.org/",
+ "href": "http://example.org/",
+ "protocol": "http:",
+ "username": "",
+ "password": "",
+ "host": "example.org",
+ "hostname": "example.org",
+ "port": "",
+ "pathname": "/",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "///example.org/../path/../../",
+ "base": "http://example.org/",
+ "href": "http://example.org/",
+ "protocol": "http:",
+ "username": "",
+ "password": "",
+ "host": "example.org",
+ "hostname": "example.org",
+ "port": "",
+ "pathname": "/",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "///example.org/../path/../../path",
+ "base": "http://example.org/",
+ "href": "http://example.org/path",
+ "protocol": "http:",
+ "username": "",
+ "password": "",
+ "host": "example.org",
+ "hostname": "example.org",
+ "port": "",
+ "pathname": "/path",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "/\\/\\//example.org/../path",
+ "base": "http://example.org/",
+ "href": "http://example.org/path",
+ "protocol": "http:",
+ "username": "",
+ "password": "",
+ "host": "example.org",
+ "hostname": "example.org",
+ "port": "",
+ "pathname": "/path",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "///abcdef/../",
+ "base": "file:///",
+ "href": "file:///",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "/",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "/\\//\\/a/../",
+ "base": "file:///",
+ "href": "file://////",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "////",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "//a/../",
+ "base": "file:///",
+ "href": "file://a/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "a",
+ "hostname": "a",
+ "port": "",
+ "pathname": "/",
+ "search": "",
+ "hash": ""
}
]
diff --git a/test/fixtures/wpt/url/url-statics-parse.any.js b/test/fixtures/wpt/url/url-statics-parse.any.js
new file mode 100644
index 00000000000000..0822e9da07af6a
--- /dev/null
+++ b/test/fixtures/wpt/url/url-statics-parse.any.js
@@ -0,0 +1,50 @@
+// This intentionally does not use resources/urltestdata.json to preserve resources.
+[
+ {
+ "url": undefined,
+ "base": undefined,
+ "expected": false
+ },
+ {
+ "url": "aaa:b",
+ "base": undefined,
+ "expected": true
+ },
+ {
+ "url": undefined,
+ "base": "aaa:b",
+ "expected": false
+ },
+ {
+ "url": "aaa:/b",
+ "base": undefined,
+ "expected": true
+ },
+ {
+ "url": undefined,
+ "base": "aaa:/b",
+ "expected": true
+ },
+ {
+ "url": "https://test:test",
+ "base": undefined,
+ "expected": false
+ },
+ {
+ "url": "a",
+ "base": "https://b/",
+ "expected": true
+ }
+].forEach(({ url, base, expected }) => {
+ test(() => {
+ if (expected == false) {
+ assert_equals(URL.parse(url, base), null);
+ } else {
+ assert_equals(URL.parse(url, base).href, new URL(url, base).href);
+ }
+ }, `URL.parse(${url}, ${base})`);
+});
+
+test(() => {
+ assert_not_equals(URL.parse("https://example/"), URL.parse("https://example/"));
+}, `URL.parse() should return a unique object`);
diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json
index a7c655125b5c22..5f65dd1a829c58 100644
--- a/test/fixtures/wpt/versions.json
+++ b/test/fixtures/wpt/versions.json
@@ -72,7 +72,7 @@
"path": "streams"
},
"url": {
- "commit": "c2d7e70b52cbd9a5b938aa32f37078d7a71e0b21",
+ "commit": "0f550ab9f5a07ed293926a306e914866164b346b",
"path": "url"
},
"user-timing": {
From 8ae1507ae10e9316d43a0e3edaec56bdbe3e2bff Mon Sep 17 00:00:00 2001
From: Antoine du Hamel
Date: Sat, 13 Apr 2024 17:03:43 +0200
Subject: [PATCH 08/98] tools: add a linter for README lists
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
PR-URL: https://github.com/nodejs/node/pull/52476
Reviewed-By: Moshe Atlow
Reviewed-By: Benjamin Gruenbaum
Reviewed-By: Yagiz Nizipli
Reviewed-By: Chengzhong Wu
Reviewed-By: Marco Ippolito
Reviewed-By: Tobias Nießen
Reviewed-By: Michael Dawson
Reviewed-By: Rafael Gonzaga
Reviewed-By: Ulises Gascón
---
.github/workflows/linters.yml | 7 +++++
README.md | 20 +++++++--------
tools/lint-readme-lists.mjs | 48 +++++++++++++++++++++++++++++++++++
3 files changed, 65 insertions(+), 10 deletions(-)
create mode 100755 tools/lint-readme-lists.mjs
diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml
index bfc1cd66785863..dd1f9ee1ae6533 100644
--- a/.github/workflows/linters.yml
+++ b/.github/workflows/linters.yml
@@ -179,3 +179,10 @@ jobs:
persist-credentials: false
# GH Actions squashes all PR commits, HEAD^ refers to the base branch.
- run: git diff HEAD^ HEAD -G"pr-url:" -- "*.md" | ./tools/lint-pr-url.mjs ${{ github.event.pull_request.html_url }}
+ lint-readme:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ persist-credentials: false
+ - run: tools/lint-readme-lists.mjs
diff --git a/README.md b/README.md
index a3ee8b7444bfb4..04df77247f8867 100644
--- a/README.md
+++ b/README.md
@@ -343,10 +343,10 @@ For information about the governance of the Node.js project, see
**Erick Wendel** <> (he/him)
* [Ethan-Arrowood](https://github.com/Ethan-Arrowood) -
**Ethan Arrowood** <> (he/him)
-* [fhinkel](https://github.com/fhinkel) -
- **Franziska Hinkelmann** <> (she/her)
* [F3n67u](https://github.com/F3n67u) -
**Feng Yu** <> (he/him)
+* [fhinkel](https://github.com/fhinkel) -
+ **Franziska Hinkelmann** <> (she/her)
* [Flarna](https://github.com/Flarna) -
**Gerhard Stöbich** <> (he/they)
* [gabrielschulhof](https://github.com/gabrielschulhof) -
@@ -429,12 +429,12 @@ For information about the governance of the Node.js project, see
**Stephen Belanger** <> (he/him)
* [RafaelGSS](https://github.com/RafaelGSS) -
**Rafael Gonzaga** <> (he/him)
-* [rluvaton](https://github.com/rluvaton) -
- **Raz Luvaton** <> (he/him)
* [richardlau](https://github.com/richardlau) -
**Richard Lau** <>
* [rickyes](https://github.com/rickyes) -
**Ricky Zhou** <<0x19951125@gmail.com>> (he/him)
+* [rluvaton](https://github.com/rluvaton) -
+ **Raz Luvaton** <> (he/him)
* [ronag](https://github.com/ronag) -
**Robert Nagy** <>
* [ruyadorno](https://github.com/ruyadorno) -
@@ -477,10 +477,10 @@ For information about the governance of the Node.js project, see
**Khaidi Chu** <> (he/him)
* [yashLadha](https://github.com/yashLadha) -
**Yash Ladha** <> (he/him)
-* [ZYSzys](https://github.com/ZYSzys) -
- **Yongsheng Zhang** <> (he/him)
* [zcbenz](https://github.com/zcbenz) -
**Cheng Zhao** <> (he/him)
+* [ZYSzys](https://github.com/ZYSzys) -
+ **Yongsheng Zhang** <> (he/him)
@@ -495,10 +495,10 @@ For information about the governance of the Node.js project, see
**Aleksei Koziatinskii** <>
* [andrasq](https://github.com/andrasq) -
**Andras** <>
-* [AnnaMag](https://github.com/AnnaMag) -
- **Anna M. Kedzierska** <>
* [AndreasMadsen](https://github.com/AndreasMadsen) -
**Andreas Madsen** <> (he/him)
+* [AnnaMag](https://github.com/AnnaMag) -
+ **Anna M. Kedzierska** <>
* [aqrln](https://github.com/aqrln) -
**Alexey Orlenko** <> (he/him)
* [bcoe](https://github.com/bcoe) -
@@ -741,10 +741,10 @@ maintaining the Node.js project.
**Mert Can Altin** <>
* [Mesteery](https://github.com/Mesteery) -
**Mestery** <> (he/him)
-* [preveen-stack](https://github.com/preveen-stack) -
- **Preveen Padmanabhan** <> (he/him)
* [PoojaDurgad](https://github.com/PoojaDurgad) -
**Pooja Durgad** <>
+* [preveen-stack](https://github.com/preveen-stack) -
+ **Preveen Padmanabhan** <> (he/him)
* [VoltrexKeyva](https://github.com/VoltrexKeyva) -
**Mohammed Keyvanzadeh** <> (he/him)
diff --git a/tools/lint-readme-lists.mjs b/tools/lint-readme-lists.mjs
new file mode 100755
index 00000000000000..8859d2097c4e79
--- /dev/null
+++ b/tools/lint-readme-lists.mjs
@@ -0,0 +1,48 @@
+#!/usr/bin/env node
+
+// Validates the list in the README are in the correct order.
+
+import { open } from 'node:fs/promises';
+
+const lists = [
+ 'TSC voting members',
+ 'TSC regular members',
+ 'TSC emeriti members',
+ 'Collaborators',
+ 'Collaborator emeriti',
+ 'Triagers',
+];
+const tscMembers = new Set();
+
+const readme = await open(new URL('../README.md', import.meta.url), 'r');
+
+let currentList = null;
+let previousGithubHandle;
+let lineNumber = 0;
+
+for await (const line of readme.readLines()) {
+ lineNumber++;
+ if (line.startsWith('### ')) {
+ currentList = lists[lists.indexOf(line.slice(4))];
+ previousGithubHandle = null;
+ } else if (line.startsWith('#### ')) {
+ currentList = lists[lists.indexOf(line.slice(5))];
+ previousGithubHandle = null;
+ } else if (currentList && line.startsWith('* [')) {
+ const currentGithubHandle = line.slice(3, line.indexOf(']')).toLowerCase();
+ if (previousGithubHandle && previousGithubHandle >= currentGithubHandle) {
+ throw new Error(`${currentGithubHandle} should be listed before ${previousGithubHandle} in the ${currentList} list (README.md:${lineNumber})`);
+ }
+
+ if (currentList === 'TSC voting members' || currentList === 'TSC regular members') {
+ tscMembers.add(currentGithubHandle);
+ } else if (currentList === 'Collaborators') {
+ tscMembers.delete(currentGithubHandle);
+ }
+ previousGithubHandle = currentGithubHandle;
+ }
+}
+
+if (tscMembers.size !== 0) {
+ throw new Error(`Some TSC members are not listed as Collaborators: ${Array.from(tscMembers)}`);
+}
From dfda6fed61ccd90fc96a06e722cd570f3bd71f53 Mon Sep 17 00:00:00 2001
From: Jungku Lee
Date: Sun, 14 Apr 2024 01:04:48 +0900
Subject: [PATCH 09/98] buffer: add missing ARG_TYPE(ArrayBuffer) for isUtf8
PR-URL: https://github.com/nodejs/node/pull/52477
Reviewed-By: Benjamin Gruenbaum
Reviewed-By: Deokjin Kim
Reviewed-By: Yagiz Nizipli
Reviewed-By: Luigi Pinca
---
lib/buffer.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/buffer.js b/lib/buffer.js
index d66d5650f30e73..fb0697d69adf79 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -1284,7 +1284,7 @@ function isUtf8(input) {
return bindingIsUtf8(input);
}
- throw new ERR_INVALID_ARG_TYPE('input', ['TypedArray', 'Buffer'], input);
+ throw new ERR_INVALID_ARG_TYPE('input', ['ArrayBuffer', 'Buffer', 'TypedArray'], input);
}
function isAscii(input) {
From 7b82c17f226a7245d1dd8878564f0688c847fbec Mon Sep 17 00:00:00 2001
From: Ali Hassan
Date: Thu, 11 Apr 2024 00:41:37 +0500
Subject: [PATCH 10/98] benchmark: add ipc support to spawn stdio config
Enabled inter-process communication (ipc) in the stdio configuration
of the spawn function within the benchmark subsystem.
This change allows for improved data exchange between parent
and benchmarked child processes, addressing limitations in performance
testing scenarios.
Fixes: https://github.com/nodejs/node/issues/52233
Refs: https://github.com/nodejs/performance/pull/161
PR-URL: https://github.com/nodejs/node/pull/52456
Reviewed-By: Matteo Collina
Reviewed-By: Raz Luvaton
---
benchmark/compare.js | 2 +-
benchmark/run.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/benchmark/compare.js b/benchmark/compare.js
index 1efff9e85c072f..0c53d90def371b 100644
--- a/benchmark/compare.js
+++ b/benchmark/compare.js
@@ -83,7 +83,7 @@ if (showProgress) {
const spawnArgs = ['-c', cpuCore, cli.optional[job.binary], resolvedPath, ...cli.optional.set];
child = spawn('taskset', spawnArgs, {
env: process.env,
- stdio: ['inherit', 'pipe', 'pipe'],
+ stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
});
child.stdout.pipe(process.stdout);
diff --git a/benchmark/run.js b/benchmark/run.js
index 11f95d8e71f035..ff2d41e6056aa2 100644
--- a/benchmark/run.js
+++ b/benchmark/run.js
@@ -54,7 +54,7 @@ if (format === 'csv') {
let child;
if (cpuCore !== null) {
child = spawn('taskset', ['-c', cpuCore, 'node', scriptPath, ...args], {
- stdio: ['inherit', 'pipe', 'pipe'],
+ stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
});
child.stdout.pipe(process.stdout);
From 7cdfe8a3fcb68a4e73f0dd4966cb12e8f86628d7 Mon Sep 17 00:00:00 2001
From: Ali Hassan
Date: Thu, 11 Apr 2024 01:35:58 +0500
Subject: [PATCH 11/98] benchmark: inherit stdio/stderr instead of pipe
PR-URL: https://github.com/nodejs/node/pull/52456
Fixes: https://github.com/nodejs/node/issues/52233
Refs: https://github.com/nodejs/performance/pull/161
Reviewed-By: Matteo Collina
Reviewed-By: Raz Luvaton
---
benchmark/compare.js | 5 +----
benchmark/run.js | 5 +----
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/benchmark/compare.js b/benchmark/compare.js
index 0c53d90def371b..ad3084db390414 100644
--- a/benchmark/compare.js
+++ b/benchmark/compare.js
@@ -83,11 +83,8 @@ if (showProgress) {
const spawnArgs = ['-c', cpuCore, cli.optional[job.binary], resolvedPath, ...cli.optional.set];
child = spawn('taskset', spawnArgs, {
env: process.env,
- stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
+ stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
});
-
- child.stdout.pipe(process.stdout);
- child.stderr.pipe(process.stderr);
} else {
child = fork(resolvedPath, cli.optional.set, {
execPath: cli.optional[job.binary],
diff --git a/benchmark/run.js b/benchmark/run.js
index ff2d41e6056aa2..6a61df71221710 100644
--- a/benchmark/run.js
+++ b/benchmark/run.js
@@ -54,11 +54,8 @@ if (format === 'csv') {
let child;
if (cpuCore !== null) {
child = spawn('taskset', ['-c', cpuCore, 'node', scriptPath, ...args], {
- stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
+ stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
});
-
- child.stdout.pipe(process.stdout);
- child.stderr.pipe(process.stderr);
} else {
child = fork(
scriptPath,
From b00766d9e74c4c75bd7723bacbb163a446713cdf Mon Sep 17 00:00:00 2001
From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com>
Date: Sat, 13 Apr 2024 21:41:20 +0200
Subject: [PATCH 12/98] module: tidy code and comments
PR-URL: https://github.com/nodejs/node/pull/52437
Reviewed-By: Geoffrey Booth
Reviewed-By: Yagiz Nizipli
Reviewed-By: Joyee Cheung
Reviewed-By: Luigi Pinca
Reviewed-By: Moshe Atlow
Reviewed-By: Antoine du Hamel
Reviewed-By: Feng Yu
---
doc/api/errors.md | 2 +-
lib/internal/modules/cjs/loader.js | 2 +-
lib/internal/modules/esm/loader.js | 28 ++++++++++++++++++-------
lib/internal/modules/esm/translators.js | 5 +++--
4 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/doc/api/errors.md b/doc/api/errors.md
index e4a6e953a21174..d2a74b230db60d 100644
--- a/doc/api/errors.md
+++ b/doc/api/errors.md
@@ -2501,7 +2501,7 @@ This is not allowed because ES Modules cannot be evaluated while they are
already being evaluated.
To avoid the cycle, the `require()` call involved in a cycle should not happen
-at the top-level of either a ES Module (via `createRequire()`) or a CommonJS
+at the top-level of either an ES Module (via `createRequire()`) or a CommonJS
module, and should be done lazily in an inner function.
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index a81f180958aebf..b8263a793578f4 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -1063,7 +1063,7 @@ Module._load = function(request, parent, isMain) {
}
// If it's cached by the ESM loader as a way to indirectly pass
// the module in to avoid creating it twice, the loading request
- // come from imported CJS. In that case use the kModuleCircularVisited
+ // came from imported CJS. In that case use the kModuleCircularVisited
// to determine if it's loading or not.
if (cachedModule[kModuleCircularVisited]) {
return getExportsForCircularRequire(cachedModule);
diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js
index df7a26c9337c39..5af25d28ea8a40 100644
--- a/lib/internal/modules/esm/loader.js
+++ b/lib/internal/modules/esm/loader.js
@@ -42,6 +42,10 @@ const {
} = require('internal/modules/helpers');
let defaultResolve, defaultLoad, defaultLoadSync, importMetaInitializer;
+/**
+ * @typedef {import('url').URL} URL
+ */
+
/**
* Lazy loads the module_map module and returns a new instance of ResolveCache.
* @returns {import('./module_map.js').ResolveCache')}
@@ -77,6 +81,10 @@ function getTranslators() {
*/
let hooksProxy;
+/**
+ * @typedef {import('../cjs/loader.js').Module} CJSModule
+ */
+
/**
* @typedef {Record} ModuleExports
*/
@@ -257,11 +265,11 @@ class ModuleLoader {
/**
* This constructs (creates, instantiates and evaluates) a module graph that
* is require()'d.
- * @param {import('../cjs/loader.js').Module} mod CJS module wrapper of the ESM.
+ * @param {CJSModule} mod CJS module wrapper of the ESM.
* @param {string} filename Resolved filename of the module being require()'d
* @param {string} source Source code. TODO(joyeecheung): pass the raw buffer.
* @param {string} isMain Whether this module is a main module.
- * @param {import('../cjs/loader.js').Module|undefined} parent Parent module, if any.
+ * @param {CJSModule|undefined} parent Parent module, if any.
* @returns {{ModuleWrap}}
*/
importSyncForRequire(mod, filename, source, isMain, parent) {
@@ -343,7 +351,7 @@ class ModuleLoader {
}
throw new ERR_REQUIRE_CYCLE_MODULE(message);
}
- // Othersie the module could be imported before but the evaluation may be already
+ // Otherwise the module could be imported before but the evaluation may be already
// completed (e.g. the require call is lazy) so it's okay. We will return the
// module now and check asynchronicity of the entire graph later, after the
// graph is instantiated.
@@ -352,8 +360,12 @@ class ModuleLoader {
defaultLoadSync ??= require('internal/modules/esm/load').defaultLoadSync;
const loadResult = defaultLoadSync(url, { format, importAttributes });
- const { responseURL, source } = loadResult;
- const { format: finalFormat } = loadResult;
+ const {
+ format: finalFormat,
+ responseURL,
+ source,
+ } = loadResult;
+
this.validateLoadResult(url, finalFormat);
if (finalFormat === 'wasm') {
assert.fail('WASM is currently unsupported by require(esm)');
@@ -725,11 +737,11 @@ function getOrInitializeCascadedLoader() {
/**
* Register a single loader programmatically.
- * @param {string|import('url').URL} specifier
- * @param {string|import('url').URL} [parentURL] Base to use when resolving `specifier`; optional if
+ * @param {string|URL} specifier
+ * @param {string|URL} [parentURL] Base to use when resolving `specifier`; optional if
* `specifier` is absolute. Same as `options.parentUrl`, just inline
* @param {object} [options] Additional options to apply, described below.
- * @param {string|import('url').URL} [options.parentURL] Base to use when resolving `specifier`
+ * @param {string|URL} [options.parentURL] Base to use when resolving `specifier`
* @param {any} [options.data] Arbitrary data passed to the loader's `initialize` hook
* @param {any[]} [options.transferList] Objects in `data` that are changing ownership
* @returns {void} We want to reserve the return value for potential future extension of the API.
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
index 4bdee1b843fbd5..8f4b6b25d88896 100644
--- a/lib/internal/modules/esm/translators.js
+++ b/lib/internal/modules/esm/translators.js
@@ -41,6 +41,7 @@ const { dirname, extname, isAbsolute } = require('path');
const {
loadBuiltinModule,
stripBOM,
+ urlToFilename,
} = require('internal/modules/helpers');
const {
kIsCachedByESMLoader,
@@ -243,7 +244,7 @@ function loadCJSModule(module, source, url, filename) {
}
}
const { url: resolvedURL } = cascadedLoader.resolveSync(specifier, url, kEmptyObject);
- return StringPrototypeStartsWith(resolvedURL, 'file://') ? fileURLToPath(resolvedURL) : resolvedURL;
+ return urlToFilename(resolvedURL);
});
setOwnProperty(requireFn, 'main', process.mainModule);
@@ -265,7 +266,7 @@ const cjsCache = new SafeMap();
function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
debug(`Translating CJSModule ${url}`);
- const filename = StringPrototypeStartsWith(url, 'file://') ? fileURLToPath(url) : url;
+ const filename = urlToFilename(url);
// In case the source was not provided by the `load` step, we need fetch it now.
source = stringify(source ?? getSource(new URL(url)).source);
From b4ccb6c626256c0abc29b67427460a51c8b68595 Mon Sep 17 00:00:00 2001
From: cjihrig
Date: Thu, 11 Apr 2024 20:52:20 -0400
Subject: [PATCH 13/98] test_runner: move end of work check to finalize()
This commit moves the end of work check from postRun() to
finalize(). The reasoning is that finalize() is guaranteed to
run in the order that the tests are defined, while postRun() is
not. This makes the check a little simpler.
PR-URL: https://github.com/nodejs/node/pull/52488
Reviewed-By: Yagiz Nizipli
Reviewed-By: Chemi Atlow
Reviewed-By: Benjamin Gruenbaum
Reviewed-By: Marco Ippolito
Reviewed-By: Moshe Atlow
---
lib/internal/test_runner/test.js | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)
diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js
index 9c7d95f9420de5..8bf63654bf1f21 100644
--- a/lib/internal/test_runner/test.js
+++ b/lib/internal/test_runner/test.js
@@ -829,29 +829,9 @@ class Test extends AsyncResource {
this.parent.activeSubtests--;
}
- // The call to processPendingSubtests() below can change the number of
- // pending subtests. When detecting if we are done running tests, we want
- // to check if there are no pending subtests both before and after
- // calling processPendingSubtests(). Otherwise, it is possible to call
- // root.run() multiple times (which is harmless but can trigger an
- // EventEmitter leak warning).
- const pendingSiblingCount = this.parent.pendingSubtests.length;
-
this.parent.addReadySubtest(this);
this.parent.processReadySubtestRange(false);
this.parent.processPendingSubtests();
-
- if (this.parent === this.root &&
- pendingSiblingCount === 0 &&
- this.root.activeSubtests === 0 &&
- this.root.pendingSubtests.length === 0 &&
- this.root.readySubtests.size === 0) {
- // At this point all of the tests have finished running. However, there
- // might be ref'ed handles keeping the event loop alive. This gives the
- // global after() hook a chance to clean them up. The user may also
- // want to force the test runner to exit despite ref'ed handles.
- this.root.run();
- }
} else if (!this.reported) {
const {
diagnostics,
@@ -914,6 +894,15 @@ class Test extends AsyncResource {
this.report();
this.parent.waitingOn++;
this.finished = true;
+
+ if (this.parent === this.root &&
+ this.root.waitingOn > this.root.subtests.length) {
+ // At this point all of the tests have finished running. However, there
+ // might be ref'ed handles keeping the event loop alive. This gives the
+ // global after() hook a chance to clean them up. The user may also
+ // want to force the test runner to exit despite ref'ed handles.
+ this.root.run();
+ }
}
duration() {
From 328755341db9df3ec1740c9801971454aaf8d9c1 Mon Sep 17 00:00:00 2001
From: cjihrig
Date: Thu, 11 Apr 2024 21:05:33 -0400
Subject: [PATCH 14/98] test_runner: don't exceed call stack when filtering
This commit updates filteredRun() to call postRun() after a
microtask instead of synchronously. Currently, if approximately
1,545 subtests are filtered, enough synchronous calls can be
made to cause a call stack exceeded exception.
PR-URL: https://github.com/nodejs/node/pull/52488
Reviewed-By: Yagiz Nizipli
Reviewed-By: Chemi Atlow
Reviewed-By: Benjamin Gruenbaum
Reviewed-By: Marco Ippolito
Reviewed-By: Moshe Atlow
---
lib/internal/test_runner/test.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js
index 8bf63654bf1f21..9e8851bb55e62c 100644
--- a/lib/internal/test_runner/test.js
+++ b/lib/internal/test_runner/test.js
@@ -29,6 +29,7 @@ const {
} = primordials;
const { getCallerLocation } = internalBinding('util');
const { addAbortListener } = require('internal/events/abort_listener');
+const { queueMicrotask } = require('internal/process/task_queues');
const { AsyncResource } = require('async_hooks');
const { AbortController } = require('internal/abort_controller');
const {
@@ -673,7 +674,7 @@ class Test extends AsyncResource {
this.pass();
this.subtests = [];
this.report = noop;
- this.postRun();
+ queueMicrotask(() => this.postRun());
}
async run() {
From e70d8a4fa9714bcbcaf37f1dc8603c88cc202292 Mon Sep 17 00:00:00 2001
From: "Node.js GitHub Bot"
Date: Sun, 14 Apr 2024 12:02:30 +0300
Subject: [PATCH 15/98] meta: move one or more collaborators to emeritus
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
PR-URL: https://github.com/nodejs/node/pull/52457
Reviewed-By: Michaël Zasso
Reviewed-By: Michael Dawson
Reviewed-By: Yagiz Nizipli
Reviewed-By: Trivikram Kamat
Reviewed-By: Luigi Pinca
Reviewed-By: Paolo Insogna
Reviewed-By: Moshe Atlow
Reviewed-By: Benjamin Gruenbaum
Reviewed-By: Antoine du Hamel
Reviewed-By: Ash Cripps
Reviewed-By: Masashi Hirano
Reviewed-By: Zeyu "Alex" Yang
---
README.md | 48 ++++++++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/README.md b/README.md
index 04df77247f8867..c8931ebcb2ae2f 100644
--- a/README.md
+++ b/README.md
@@ -209,8 +209,6 @@ For information about the governance of the Node.js project, see
**Beth Griggs** <> (she/her)
* [bnoordhuis](https://github.com/bnoordhuis) -
**Ben Noordhuis** <>
-* [ChALkeR](https://github.com/ChALkeR) -
- **Сковорода Никита Андреевич** <> (he/him)
* [cjihrig](https://github.com/cjihrig) -
**Colin Ihrig** <> (he/him)
* [codebytere](https://github.com/codebytere) -
@@ -232,6 +230,8 @@ For information about the governance of the Node.js project, see
* [addaleax](https://github.com/addaleax) -
**Anna Henningsen** <> (she/her)
+* [ChALkeR](https://github.com/ChALkeR) -
+ **Сковорода Никита Андреевич** <> (he/him)
* [chrisdickinson](https://github.com/chrisdickinson) -
**Chris Dickinson** <>
* [danbev](https://github.com/danbev) -
@@ -291,12 +291,8 @@ For information about the governance of the Node.js project, see
**Antoine du Hamel** <> (he/him)
* [anonrig](https://github.com/anonrig) -
**Yagiz Nizipli** <> (he/him)
-* [antsmartian](https://github.com/antsmartian) -
- **Anto Aravinth** <> (he/him)
* [apapirovski](https://github.com/apapirovski) -
**Anatoli Papirovski** <> (he/him)
-* [AshCripps](https://github.com/AshCripps) -
- **Ash Cripps** <>
* [atlowChemi](https://github.com/atlowChemi) -
**Chemi Atlow** <> (he/him)
* [Ayase-252](https://github.com/Ayase-252) -
@@ -307,8 +303,6 @@ For information about the governance of the Node.js project, see
**Benjamin Gruenbaum** <>
* [BethGriggs](https://github.com/BethGriggs) -
**Beth Griggs** <> (she/her)
-* [bmeck](https://github.com/bmeck) -
- **Bradley Farias** <>
* [bnb](https://github.com/bnb) -
**Tierney Cyren** <> (they/them)
* [bnoordhuis](https://github.com/bnoordhuis) -
@@ -317,8 +311,6 @@ For information about the governance of the Node.js project, see
**Ruben Bridgewater** <> (he/him)
* [cclauss](https://github.com/cclauss) -
**Christian Clauss** <> (he/him)
-* [ChALkeR](https://github.com/ChALkeR) -
- **Сковорода Никита Андреевич** <> (he/him)
* [cjihrig](https://github.com/cjihrig) -
**Colin Ihrig** <> (he/him)
* [codebytere](https://github.com/codebytere) -
@@ -327,16 +319,12 @@ For information about the governance of the Node.js project, see
**Kohei Ueno** <> (he/him)
* [daeyeon](https://github.com/daeyeon) -
**Daeyeon Jeong** <> (he/him)
-* [danbev](https://github.com/danbev) -
- **Daniel Bevenius** <> (he/him)
* [danielleadams](https://github.com/danielleadams) -
**Danielle Adams** <> (she/her)
* [debadree25](https://github.com/debadree25) -
**Debadree Chatterjee** <> (he/him)
* [deokjinkim](https://github.com/deokjinkim) -
**Deokjin Kim** <> (he/him)
-* [devsnek](https://github.com/devsnek) -
- **Gus Caplan** <> (they/them)
* [edsadr](https://github.com/edsadr) -
**Adrian Estrada** <> (he/him)
* [erickwendel](https://github.com/erickwendel) -
@@ -417,8 +405,6 @@ For information about the governance of the Node.js project, see
**Moshe Atlow** <> (he/him)
* [MrJithil](https://github.com/MrJithil) -
**Jithil P Ponnan** <> (he/him)
-* [mscdex](https://github.com/mscdex) -
- **Brian White** <>
* [MylesBorins](https://github.com/MylesBorins) -
**Myles Borins** <> (he/him)
* [ovflowd](https://github.com/ovflowd) -
@@ -431,20 +417,14 @@ For information about the governance of the Node.js project, see
**Rafael Gonzaga** <> (he/him)
* [richardlau](https://github.com/richardlau) -
**Richard Lau** <>
-* [rickyes](https://github.com/rickyes) -
- **Ricky Zhou** <<0x19951125@gmail.com>> (he/him)
* [rluvaton](https://github.com/rluvaton) -
**Raz Luvaton** <> (he/him)
* [ronag](https://github.com/ronag) -
**Robert Nagy** <>
* [ruyadorno](https://github.com/ruyadorno) -
**Ruy Adorno** <> (he/him)
-* [ryzokuken](https://github.com/ryzokuken) -
- **Ujjwal Sharma** <> (he/him)
* [santigimeno](https://github.com/santigimeno) -
**Santiago Gimeno** <>
-* [shisama](https://github.com/shisama) -
- **Masashi Hirano** <> (he/him)
* [ShogunPanda](https://github.com/ShogunPanda) -
**Paolo Insogna** <> (he/him)
* [srl295](https://github.com/srl295) -
@@ -465,8 +445,6 @@ For information about the governance of the Node.js project, see
**Rich Trott** <> (he/him)
* [UlisesGascon](https://github.com/ulisesgascon) -
**Ulises Gascón** <> (he/him)
-* [vdeturckheim](https://github.com/vdeturckheim) -
- **Vladimir de Turckheim** <> (he/him)
* [vmoroz](https://github.com/vmoroz) -
**Vladimir Morozov** <> (he/him)
* [VoltrexKeyva](https://github.com/VoltrexKeyva) -
@@ -499,10 +477,16 @@ For information about the governance of the Node.js project, see
**Andreas Madsen** <> (he/him)
* [AnnaMag](https://github.com/AnnaMag) -
**Anna M. Kedzierska** <>
+* [antsmartian](https://github.com/antsmartian) -
+ **Anto Aravinth** <> (he/him)
* [aqrln](https://github.com/aqrln) -
**Alexey Orlenko** <> (he/him)
+* [AshCripps](https://github.com/AshCripps) -
+ **Ash Cripps** <>
* [bcoe](https://github.com/bcoe) -
**Ben Coe** <> (he/him)
+* [bmeck](https://github.com/bmeck) -
+ **Bradley Farias** <>
* [bmeurer](https://github.com/bmeurer) -
**Benedikt Meurer** <>
* [boneskull](https://github.com/boneskull) -
@@ -513,16 +497,22 @@ For information about the governance of the Node.js project, see
**Bartosz Sosnowski** <>
* [calvinmetcalf](https://github.com/calvinmetcalf) -
**Calvin Metcalf** <>
+* [ChALkeR](https://github.com/ChALkeR) -
+ **Сковорода Никита Андреевич** <> (he/him)
* [chrisdickinson](https://github.com/chrisdickinson) -
**Chris Dickinson** <>
* [claudiorodriguez](https://github.com/claudiorodriguez) -
**Claudio Rodriguez** <>
+* [danbev](https://github.com/danbev) -
+ **Daniel Bevenius** <> (he/him)
* [DavidCai1993](https://github.com/DavidCai1993) -
**David Cai** <> (he/him)
* [davisjam](https://github.com/davisjam) -
**Jamie Davis** <> (he/him)
* [devnexen](https://github.com/devnexen) -
**David Carlier** <>
+* [devsnek](https://github.com/devsnek) -
+ **Gus Caplan** <> (they/them)
* [digitalinfinity](https://github.com/digitalinfinity) -
**Hitesh Kanwathirtha** <> (he/him)
* [dmabupt](https://github.com/dmabupt) -
@@ -617,6 +607,8 @@ For information about the governance of the Node.js project, see
**Christopher Monsanto** <>
* [MoonBall](https://github.com/MoonBall) -
**Chen Gang** <>
+* [mscdex](https://github.com/mscdex) -
+ **Brian White** <>
* [not-an-aardvark](https://github.com/not-an-aardvark) -
**Teddy Katz** <> (he/him)
* [ofrobots](https://github.com/ofrobots) -
@@ -651,6 +643,8 @@ For information about the governance of the Node.js project, see
**Refael Ackermann (רפאל פלחי)** <> (he/him/הוא/אתה)
* [rexagod](https://github.com/rexagod) -
**Pranshu Srivastava** <> (he/him)
+* [rickyes](https://github.com/rickyes) -
+ **Ricky Zhou** <<0x19951125@gmail.com>> (he/him)
* [rlidwka](https://github.com/rlidwka) -
**Alex Kocharin** <>
* [rmg](https://github.com/rmg) -
@@ -667,6 +661,8 @@ For information about the governance of the Node.js project, see
**Sam Ruby** <>
* [rvagg](https://github.com/rvagg) -
**Rod Vagg** <>
+* [ryzokuken](https://github.com/ryzokuken) -
+ **Ujjwal Sharma** <> (he/him)
* [saghul](https://github.com/saghul) -
**Saúl Ibarra Corretgé** <>
* [sam-github](https://github.com/sam-github) -
@@ -677,6 +673,8 @@ For information about the governance of the Node.js project, see
**Nikolai Vavilov** <>
* [shigeki](https://github.com/shigeki) -
**Shigeki Ohtsu** <> (he/him)
+* [shisama](https://github.com/shisama) -
+ **Masashi Hirano** <> (he/him)
* [silverwind](https://github.com/silverwind) -
**Roman Reiss** <>
* [starkwang](https://github.com/starkwang) -
@@ -693,6 +691,8 @@ For information about the governance of the Node.js project, see
**Trevor Norris** <>
* [tunniclm](https://github.com/tunniclm) -
**Mike Tunnicliffe** <>
+* [vdeturckheim](https://github.com/vdeturckheim) -
+ **Vladimir de Turckheim** <> (he/him)
* [vkurchatkin](https://github.com/vkurchatkin) -
**Vladimir Kurchatkin** <>
* [vsemozhetbyt](https://github.com/vsemozhetbyt) -
From dc399ddd037e2f197fcca22a3ba4ba13872afaf4 Mon Sep 17 00:00:00 2001
From: Aviv Keller <38299977+RedYetiDev@users.noreply.github.com>
Date: Sun, 14 Apr 2024 06:30:31 -0400
Subject: [PATCH 16/98] lib, doc: rename readme.md to README.md
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
PR-URL: https://github.com/nodejs/node/pull/52471
Reviewed-By: Antoine du Hamel