Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2022-10-12 22:57:00 +0300
committerGar <gar+gh@danger.computer>2022-10-12 22:57:00 +0300
commita22168ee4f73398263009f6789ae25d7e1cb5d46 (patch)
treea15744598068509efaeab5626e0401cf5ce185e9
parent37bf6d31bd2f68e661928744833b57dcabbb0d1a (diff)
fix(config): remove `node-version` and `npm-version`gar/rm-node-npm-version
BREAKING CHANGE: the `node-version` and `npm-version` configs have been removed. These are only used sparingly by arborist to determine if optional dependencies should be installed, and during engines checks (which are only warnings unless `engine-strict` is true.
-rw-r--r--lib/npm.js7
-rw-r--r--lib/utils/config/definitions.js26
-rw-r--r--tap-snapshots/test/lib/commands/config.js.test.cjs18
-rw-r--r--tap-snapshots/test/lib/utils/config/definitions.js.test.cjs22
-rw-r--r--tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs22
-rw-r--r--test/lib/commands/config.js14
-rw-r--r--test/lib/utils/config/definitions.js7
7 files changed, 25 insertions, 91 deletions
diff --git a/lib/npm.js b/lib/npm.js
index fe2ce5c6b..a922aafaf 100644
--- a/lib/npm.js
+++ b/lib/npm.js
@@ -311,9 +311,12 @@ class Npm extends EventEmitter {
get flatOptions () {
const { flat } = this.config
- // the Arborist constructor is used almost everywhere we call pacote, it's easiest
- // to attach it to flatOptions so it goes everywhere without having to touch every call
+ // the Arborist constructor is used almost everywhere we call pacote, it's
+ // easiest to attach it to flatOptions so it goes everywhere without having
+ // to touch every call
flat.Arborist = Arborist
+ flat.nodeVersion = process.version
+ flat.npmVersion = pkg.version
if (this.command) {
flat.npmCommand = this.command
}
diff --git a/lib/utils/config/definitions.js b/lib/utils/config/definitions.js
index 6d92651eb..c9d76249c 100644
--- a/lib/utils/config/definitions.js
+++ b/lib/utils/config/definitions.js
@@ -1314,16 +1314,6 @@ define('node-options', {
`,
})
-define('node-version', {
- default: process.version,
- defaultDescription: 'Node.js `process.version` value',
- type: semver,
- description: `
- The node version to use when checking a package's \`engines\` setting.
- `,
- flatten,
-})
-
define('noproxy', {
default: '',
defaultDescription: `
@@ -1344,16 +1334,6 @@ define('noproxy', {
},
})
-define('npm-version', {
- default: npmVersion,
- defaultDescription: 'Output of `npm --version`',
- type: semver,
- description: `
- The npm version to use when checking a package's \`engines\` setting.
- `,
- flatten,
-})
-
define('offline', {
default: false,
type: Boolean,
@@ -2044,7 +2024,7 @@ define('tag-version-prefix', {
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
+ 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
@@ -2166,8 +2146,8 @@ define('user-agent', {
inWorkspaces = true
}
flatOptions.userAgent =
- value.replace(/\{node-version\}/gi, obj['node-version'])
- .replace(/\{npm-version\}/gi, obj['npm-version'])
+ value.replace(/\{node-version\}/gi, process.version)
+ .replace(/\{npm-version\}/gi, npmVersion)
.replace(/\{platform\}/gi, process.platform)
.replace(/\{arch\}/gi, process.arch)
.replace(/\{workspaces\}/gi, inWorkspaces)
diff --git a/tap-snapshots/test/lib/commands/config.js.test.cjs b/tap-snapshots/test/lib/commands/config.js.test.cjs
index 116ccea3a..5ae375cb9 100644
--- a/tap-snapshots/test/lib/commands/config.js.test.cjs
+++ b/tap-snapshots/test/lib/commands/config.js.test.cjs
@@ -96,11 +96,9 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"maxsockets": 15,
"message": "%s",
"node-options": null,
- "node-version": "{NODE-VERSION}",
"noproxy": [
""
],
- "npm-version": "{NPM-VERSION}",
"offline": false,
"omit": [],
"omit-lockfile-registry-resolved": false,
@@ -252,9 +250,7 @@ maxsockets = 15
message = "%s"
metrics-registry = "https://registry.npmjs.org/"
node-options = null
-node-version = "{NODE-VERSION}"
noproxy = [""]
-npm-version = "{NPM-VERSION}"
offline = false
omit = []
omit-lockfile-registry-resolved = false
@@ -344,9 +340,9 @@ prefix = "{LOCALPREFIX}"
userconfig = "{HOME}/.npmrc"
; node bin location = {EXECPATH}
-; node version = {NODE-VERSION}
+; node version = v18.10.0
; npm local prefix = {LOCALPREFIX}
-; npm version = {NPM-VERSION}
+; npm version = 9.0.0-pre.4
; cwd = {NPMDIR}
; HOME = {HOME}
; Run \`npm config ls -l\` to show all defaults.
@@ -360,9 +356,9 @@ prefix = "{LOCALPREFIX}"
userconfig = "{HOME}/.npmrc"
; node bin location = {EXECPATH}
-; node version = {NODE-VERSION}
+; node version = v18.10.0
; npm local prefix = {LOCALPREFIX}
-; npm version = {NPM-VERSION}
+; npm version = 9.0.0-pre.4
; cwd = {NPMDIR}
; HOME = {HOME}
; Run \`npm config ls -l\` to show all defaults.
@@ -380,7 +376,7 @@ globalconfig = "{GLOBALPREFIX}/npmrc"
init-module = "{HOME}/.npm-init.js"
local-prefix = "{LOCALPREFIX}"
; prefix = "{LOCALPREFIX}" ; overridden by cli
-user-agent = "npm/{NPM-VERSION} node/{NODE-VERSION} {PLATFORM} {ARCH} workspaces/false"
+user-agent = "npm/9.0.0-pre.4 node/v18.10.0 {PLATFORM} {ARCH} workspaces/false"
; userconfig = "{HOME}/.npmrc" ; overridden by cli
; "cli" config from command line options
@@ -391,9 +387,9 @@ prefix = "{LOCALPREFIX}"
userconfig = "{HOME}/.npmrc"
; node bin location = {EXECPATH}
-; node version = {NODE-VERSION}
+; node version = v18.10.0
; npm local prefix = {LOCALPREFIX}
-; npm version = {NPM-VERSION}
+; npm version = 9.0.0-pre.4
; cwd = {NPMDIR}
; HOME = {HOME}
; Run \`npm config ls -l\` to show all defaults.
diff --git a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs b/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs
index 92a8e6222..f6eaf9e71 100644
--- a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs
+++ b/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs
@@ -92,9 +92,7 @@ Array [
"maxsockets",
"message",
"node-options",
- "node-version",
"noproxy",
- "npm-version",
"offline",
"omit",
"omit-lockfile-registry-resolved",
@@ -1188,15 +1186,6 @@ variable. This does not impact how npm itself is executed but it does impact
how lifecycle scripts are called.
`
-exports[`test/lib/utils/config/definitions.js TAP > config description for node-version 1`] = `
-#### \`node-version\`
-
-* Default: Node.js \`process.version\` value
-* Type: SemVer string
-
-The node version to use when checking a package's \`engines\` setting.
-`
-
exports[`test/lib/utils/config/definitions.js TAP > config description for noproxy 1`] = `
#### \`noproxy\`
@@ -1208,15 +1197,6 @@ Domain extensions that should bypass any proxies.
Also accepts a comma-delimited string.
`
-exports[`test/lib/utils/config/definitions.js TAP > config description for npm-version 1`] = `
-#### \`npm-version\`
-
-* Default: Output of \`npm --version\`
-* Type: SemVer string
-
-The npm version to use when checking a package's \`engines\` setting.
-`
-
exports[`test/lib/utils/config/definitions.js TAP > config description for offline 1`] = `
#### \`offline\`
@@ -1747,7 +1727,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for tag-v
* Type: String
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
+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
diff --git a/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs b/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs
index 999b3859f..d97f527c4 100644
--- a/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs
+++ b/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs
@@ -1007,16 +1007,6 @@ how lifecycle scripts are called.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
-#### \`node-version\`
-
-* Default: Node.js \`process.version\` value
-* Type: SemVer string
-
-The node version to use when checking a package's \`engines\` setting.
-
-<!-- automatically generated, do not edit manually -->
-<!-- see lib/utils/config/definitions.js -->
-
#### \`noproxy\`
* Default: The value of the NO_PROXY environment variable
@@ -1029,16 +1019,6 @@ Also accepts a comma-delimited string.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
-#### \`npm-version\`
-
-* Default: Output of \`npm --version\`
-* Type: SemVer string
-
-The npm version to use when checking a package's \`engines\` setting.
-
-<!-- automatically generated, do not edit manually -->
-<!-- see lib/utils/config/definitions.js -->
-
#### \`offline\`
* Default: false
@@ -1564,7 +1544,7 @@ tarball that will be compared with the local files by default.
* Type: String
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
+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
diff --git a/test/lib/commands/config.js b/test/lib/commands/config.js
index 42df8b52d..61e47244e 100644
--- a/test/lib/commands/config.js
+++ b/test/lib/commands/config.js
@@ -330,21 +330,21 @@ t.test('config get no args', async t => {
t.test('config get single key', async t => {
const sandbox = new Sandbox(t)
- await sandbox.run('config', ['get', 'node-version'])
- t.equal(sandbox.output, sandbox.config.get('node-version'), 'should get the value')
+ await sandbox.run('config', ['get', 'all'])
+ t.equal(sandbox.output, `${sandbox.config.get('all')}`, 'should get the value')
})
t.test('config get multiple keys', async t => {
const sandbox = new Sandbox(t)
- await sandbox.run('config', ['get', 'node-version', 'npm-version'])
+ await sandbox.run('config', ['get', 'yes', 'all'])
t.ok(
- sandbox.output.includes(`node-version=${sandbox.config.get('node-version')}`),
- 'outputs node-version'
+ sandbox.output.includes(`yes=${sandbox.config.get('yes')}`),
+ 'outputs yes'
)
t.ok(
- sandbox.output.includes(`npm-version=${sandbox.config.get('npm-version')}`),
- 'outputs npm-version'
+ sandbox.output.includes(`all=${sandbox.config.get('all')}`),
+ 'outputs all'
)
})
diff --git a/test/lib/utils/config/definitions.js b/test/lib/utils/config/definitions.js
index 200ee9e55..4925238ad 100644
--- a/test/lib/utils/config/definitions.js
+++ b/test/lib/utils/config/definitions.js
@@ -26,9 +26,6 @@ t.matchSnapshot(Object.keys(definitions), 'all config keys')
t.matchSnapshot(Object.keys(definitions).filter(d => d.flatten),
'all config keys that are shared to flatOptions')
-t.equal(definitions['npm-version'].default, pkg.version, 'npm-version default')
-t.equal(definitions['node-version'].default, process.version, 'node-version default')
-
t.test('basic flattening function camelCases from css-case', t => {
const flat = {}
const obj = { 'prefer-online': true }
@@ -774,11 +771,9 @@ t.test('detect CI', t => {
t.test('user-agent', t => {
const obj = {
'user-agent': definitions['user-agent'].default,
- 'npm-version': '1.2.3',
- 'node-version': '9.8.7',
}
const flat = {}
- const expectNoCI = `npm/1.2.3 node/9.8.7 ` +
+ const expectNoCI = `npm/${pkg.version} node/${process.version} ` +
`${process.platform} ${process.arch} workspaces/false`
definitions['user-agent'].flatten('user-agent', obj, flat)
t.equal(flat.userAgent, expectNoCI)