From 794b5cb87ceb878cf5eec6fa6e6e90b2c97b570c Mon Sep 17 00:00:00 2001 From: Marc Bernard <59966492+mbtools@users.noreply.github.com> Date: Sun, 5 May 2024 22:43:16 +0200 Subject: [PATCH 1/4] chore: log if `npm deprecate` does not match any version If the package specification does not match any existing version, a verbose message is added to the log. ## References Ref https://github.com/npm/cli/pull/7472 Closes https://github.com/npm/cli/issues/7180 --- lib/commands/deprecate.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/commands/deprecate.js b/lib/commands/deprecate.js index 38925804f1137..a0e94915a3841 100644 --- a/lib/commands/deprecate.js +++ b/lib/commands/deprecate.js @@ -1,6 +1,7 @@ const fetch = require('npm-registry-fetch') const { otplease } = require('../utils/auth.js') const npa = require('npm-package-arg') +const { log } = require('proc-log') const semver = require('semver') const getIdentity = require('../utils/get-identity.js') const libaccess = require('libnpmaccess') @@ -66,6 +67,8 @@ class Deprecate extends BaseCommand { body: packument, ignoreBody: true, })) + } else { + log.warn('deprecate', 'No version found for', p) } } } From 4e27c34cd2a2e98c72125a0520b1f2165b1e6cb1 Mon Sep 17 00:00:00 2001 From: Marc Bernard <59966492+mbtools@users.noreply.github.com> Date: Mon, 6 May 2024 09:16:18 +0200 Subject: [PATCH 2/4] log output --- lib/commands/deprecate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/deprecate.js b/lib/commands/deprecate.js index a0e94915a3841..977fd9fce11da 100644 --- a/lib/commands/deprecate.js +++ b/lib/commands/deprecate.js @@ -68,7 +68,7 @@ class Deprecate extends BaseCommand { ignoreBody: true, })) } else { - log.warn('deprecate', 'No version found for', p) + log.warn('deprecate', 'No version found for', p.rawSpec) } } } From 56f2820212aed11a291a2a71faf2a8b6784dfd4a Mon Sep 17 00:00:00 2001 From: Marc Bernard <59966492+mbtools@users.noreply.github.com> Date: Mon, 6 May 2024 09:18:02 +0200 Subject: [PATCH 3/4] Add log to test --- test/lib/commands/deprecate.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/lib/commands/deprecate.js b/test/lib/commands/deprecate.js index 4ae146fd3aee0..b5caa425042b3 100644 --- a/test/lib/commands/deprecate.js +++ b/test/lib/commands/deprecate.js @@ -155,7 +155,7 @@ t.test('deprecates all versions when no range is specified', async t => { }) t.test('does nothing if version does not actually exist', async t => { - const { npm, joinedOutput } = await loadMockNpm(t, { config: { ...auth } }) + const { npm, logs, joinedOutput } = await loadMockNpm(t, { config: { ...auth } }) const registry = new MockRegistry({ tap: t, registry: npm.config.get('registry'), @@ -168,4 +168,5 @@ t.test('does nothing if version does not actually exist', async t => { await registry.package({ manifest, query: { write: true } }) await npm.exec('deprecate', ['foo@1.0.99', 'this should be ignored']) t.match(joinedOutput(), '') + t.equal(logs.warn[0], 'deprecate No version found for 1.0.99') }) From 0fd0e8db8352a04d6f7e2e4ae16d23112bba9871 Mon Sep 17 00:00:00 2001 From: Marc Bernard <59966492+mbtools@users.noreply.github.com> Date: Mon, 6 May 2024 09:19:53 +0200 Subject: [PATCH 4/4] lint --- test/lib/commands/deprecate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/commands/deprecate.js b/test/lib/commands/deprecate.js index b5caa425042b3..09aaeacfe8563 100644 --- a/test/lib/commands/deprecate.js +++ b/test/lib/commands/deprecate.js @@ -168,5 +168,5 @@ t.test('does nothing if version does not actually exist', async t => { await registry.package({ manifest, query: { write: true } }) await npm.exec('deprecate', ['foo@1.0.99', 'this should be ignored']) t.match(joinedOutput(), '') - t.equal(logs.warn[0], 'deprecate No version found for 1.0.99') + t.equal(logs.warn[0], 'deprecate No version found for 1.0.99') })