Skip to content

Commit 1764a37

Browse files
committed
feat: add npm undeprecate command
1 parent ab9ddc0 commit 1764a37

File tree

11 files changed

+175
-27
lines changed

11 files changed

+175
-27
lines changed

docs/lib/check-nav.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ function ensureNavigationComplete (nav, fsPaths, ext) {
2929
const errors = []
3030

3131
if (missingNav.length) {
32-
errors.push('The following path(s) exist on disk but are not present in nav.yml:')
32+
errors.push('The following path(s) exist on disk but are not present in /lib/content/nav.yml:')
3333
errors.push(...missingNav.map(n => ` ${n}`))
3434
}
3535

3636
if (missingFs.length) {
37-
errors.push('The following path(s) exist in nav.yml but are not present on disk:')
37+
errors.push('The following path(s) exist in lib/content/nav.yml but are not present on disk:')
3838
errors.push(...missingFs.map(n => ` ${n}`))
3939
}
4040

4141
if (errors.length) {
42-
errors.unshift('Documentation navigation (nav.yml) does not match filesystem.')
42+
errors.unshift('Documentation navigation (lib/content/nav.yml) does not match filesystem.')
4343
errors.push('Update nav.yml to ensure that all files are listed in the appropriate place.')
4444
throw new Error(errors.join('\n'))
4545
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: npm-undeprecate
3+
section: 1
4+
description: Undeprecate a version of a package
5+
---
6+
7+
### Synopsis
8+
9+
<!-- AUTOGENERATED USAGE DESCRIPTIONS -->
10+
11+
### Description
12+
13+
This command will update the npm registry entry for a package, removing any
14+
deprecation warnings that currently exist.
15+
16+
It works in the same way as [npm deprecate](/commands/npm-deprecate), except
17+
that this command removes deprecation warnings instead of adding them.
18+
19+
### Configuration
20+
21+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS -->
22+
### See Also
23+
24+
* [npm deprecate](/commands/npm-deprecate)

docs/lib/content/nav.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@
177177
- title: npm token
178178
url: /commands/npm-token
179179
description: Manage your authentication tokens
180+
- title: npm undeprecate
181+
url: /commands/npm-undeprecate
182+
description: Undeprecate a version of a package
180183
- title: npm uninstall
181184
url: /commands/npm-uninstall
182185
description: Remove a package

lib/commands/undeprecate.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const Deprecate = require('./deprecate.js')
2+
3+
class Undeprecate extends Deprecate {
4+
static description = 'Undeprecate a version of a package'
5+
static name = 'undeprecate'
6+
static usage = ['<package-spec>']
7+
8+
async exec ([pkg]) {
9+
return super.exec([pkg, ''])
10+
}
11+
}
12+
13+
module.exports = Undeprecate

lib/utils/cmd-list.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const commands = [
6262
'team',
6363
'test',
6464
'token',
65+
'undeprecate',
6566
'uninstall',
6667
'unpublish',
6768
'unstar',

smoke-tests/tap-snapshots/test/index.js.test.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ All commands:
2929
ping, pkg, prefix, profile, prune, publish, query, rebuild,
3030
repo, restart, root, run-script, sbom, search, set,
3131
shrinkwrap, star, stars, start, stop, team, test, token,
32-
uninstall, unpublish, unstar, update, version, view, whoami
32+
undeprecate, uninstall, unpublish, unstar, update, version,
33+
view, whoami
3334
3435
Specify configs in the ini-formatted file:
3536
{NPM}/{TESTDIR}/home/.npmrc

tap-snapshots/test/lib/commands/completion.js.test.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ Array [
100100
team
101101
test
102102
token
103+
undeprecate
103104
uninstall
104105
unpublish
105106
unstar

tap-snapshots/test/lib/commands/publish.js.test.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ Object {
208208
"man/man1/npm-team.1",
209209
"man/man1/npm-test.1",
210210
"man/man1/npm-token.1",
211+
"man/man1/npm-undeprecate.1",
211212
"man/man1/npm-uninstall.1",
212213
"man/man1/npm-unpublish.1",
213214
"man/man1/npm-unstar.1",

tap-snapshots/test/lib/docs.js.test.cjs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ Array [
155155
"team",
156156
"test",
157157
"token",
158+
"undeprecate",
158159
"uninstall",
159160
"unpublish",
160161
"unstar",
@@ -2850,7 +2851,7 @@ Usage:
28502851
npm deprecate <package-spec> <message>
28512852
28522853
Options:
2853-
[--registry <registry>] [--otp <otp>]
2854+
[--registry <registry>] [--otp <otp>] [--dry-run]
28542855
28552856
Run "npm help deprecate" for more info
28562857
@@ -2862,6 +2863,7 @@ Note: This command is unaware of workspaces.
28622863
28632864
#### \`registry\`
28642865
#### \`otp\`
2866+
#### \`dry-run\`
28652867
`
28662868

28672869
exports[`test/lib/docs.js TAP usage diff > must match snapshot 1`] = `
@@ -4274,6 +4276,28 @@ Note: This command is unaware of workspaces.
42744276
#### \`otp\`
42754277
`
42764278

4279+
exports[`test/lib/docs.js TAP usage undeprecate > must match snapshot 1`] = `
4280+
Undeprecate a version of a package
4281+
4282+
Usage:
4283+
npm undeprecate <package-spec>
4284+
4285+
Options:
4286+
[--registry <registry>] [--otp <otp>] [--dry-run]
4287+
4288+
Run "npm help undeprecate" for more info
4289+
4290+
\`\`\`bash
4291+
npm undeprecate <package-spec>
4292+
\`\`\`
4293+
4294+
Note: This command is unaware of workspaces.
4295+
4296+
#### \`registry\`
4297+
#### \`otp\`
4298+
#### \`dry-run\`
4299+
`
4300+
42774301
exports[`test/lib/docs.js TAP usage uninstall > must match snapshot 1`] = `
42784302
Remove a package
42794303

tap-snapshots/test/lib/npm.js.test.cjs

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ All commands:
3939
ping, pkg, prefix, profile, prune, publish, query, rebuild,
4040
repo, restart, root, run-script, sbom, search, set,
4141
shrinkwrap, star, stars, start, stop, team, test, token,
42-
uninstall, unpublish, unstar, update, version, view, whoami
42+
undeprecate, uninstall, unpublish, unstar, update, version,
43+
view, whoami
4344
4445
Specify configs in the ini-formatted file:
4546
{USERCONFIG}
@@ -89,9 +90,10 @@ All commands:
8990
search, set, shrinkwrap,
9091
star, stars, start,
9192
stop, team, test, token,
92-
uninstall, unpublish,
93-
unstar, update, version,
94-
view, whoami
93+
undeprecate, uninstall,
94+
unpublish, unstar,
95+
update, version, view,
96+
whoami
9597
9698
Specify configs in the ini-formatted file:
9799
{USERCONFIG}
@@ -141,9 +143,10 @@ All commands:
141143
search, set, shrinkwrap,
142144
star, stars, start,
143145
stop, team, test, token,
144-
uninstall, unpublish,
145-
unstar, update, version,
146-
view, whoami
146+
undeprecate, uninstall,
147+
unpublish, unstar,
148+
update, version, view,
149+
whoami
147150
148151
Specify configs in the ini-formatted file:
149152
{USERCONFIG}
@@ -179,7 +182,8 @@ All commands:
179182
ping, pkg, prefix, profile, prune, publish, query, rebuild,
180183
repo, restart, root, run-script, sbom, search, set,
181184
shrinkwrap, star, stars, start, stop, team, test, token,
182-
uninstall, unpublish, unstar, update, version, view, whoami
185+
undeprecate, uninstall, unpublish, unstar, update, version,
186+
view, whoami
183187
184188
Specify configs in the ini-formatted file:
185189
{USERCONFIG}
@@ -229,9 +233,10 @@ All commands:
229233
search, set, shrinkwrap,
230234
star, stars, start,
231235
stop, team, test, token,
232-
uninstall, unpublish,
233-
unstar, update, version,
234-
view, whoami
236+
undeprecate, uninstall,
237+
unpublish, unstar,
238+
update, version, view,
239+
whoami
235240
236241
Specify configs in the ini-formatted file:
237242
{USERCONFIG}
@@ -281,9 +286,10 @@ All commands:
281286
search, set, shrinkwrap,
282287
star, stars, start,
283288
stop, team, test, token,
284-
uninstall, unpublish,
285-
unstar, update, version,
286-
view, whoami
289+
undeprecate, uninstall,
290+
unpublish, unstar,
291+
update, version, view,
292+
whoami
287293
288294
Specify configs in the ini-formatted file:
289295
{USERCONFIG}
@@ -331,10 +337,10 @@ All commands:
331337
run-script, sbom, search,
332338
set, shrinkwrap, star,
333339
stars, start, stop, team,
334-
test, token, uninstall,
335-
unpublish, unstar,
336-
update, version, view,
337-
whoami
340+
test, token, undeprecate,
341+
uninstall, unpublish,
342+
unstar, update, version,
343+
view, whoami
338344
339345
Specify configs in the ini-formatted file:
340346
{USERCONFIG}
@@ -370,8 +376,8 @@ All commands:
370376
ping, pkg, prefix, profile, prune, publish, query, rebuild,
371377
repo, restart, root, run-script, sbom, search, set,
372378
shrinkwrap, star, stars, start, stop, team, test, token,
373-
uninstall, unpublish, unstar, update, version, view,
374-
whoami
379+
undeprecate, uninstall, unpublish, unstar, update, version,
380+
view, whoami
375381
376382
Specify configs in the ini-formatted file:
377383
{USERCONFIG}
@@ -407,7 +413,8 @@ All commands:
407413
ping, pkg, prefix, profile, prune, publish, query, rebuild,
408414
repo, restart, root, run-script, sbom, search, set,
409415
shrinkwrap, star, stars, start, stop, team, test, token,
410-
uninstall, unpublish, unstar, update, version, view, whoami
416+
undeprecate, uninstall, unpublish, unstar, update, version,
417+
view, whoami
411418
412419
Specify configs in the ini-formatted file:
413420
{USERCONFIG}
@@ -443,7 +450,8 @@ All commands:
443450
ping, pkg, prefix, profile, prune, publish, query, rebuild,
444451
repo, restart, root, run-script, sbom, search, set,
445452
shrinkwrap, star, stars, start, stop, team, test, token,
446-
uninstall, unpublish, unstar, update, version, view, whoami
453+
undeprecate, uninstall, unpublish, unstar, update, version,
454+
view, whoami
447455
448456
Specify configs in the ini-formatted file:
449457
{USERCONFIG}

test/lib/commands/undeprecate.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
const t = require('tap')
2+
const { load: loadMockNpm } = require('../../fixtures/mock-npm')
3+
4+
const MockRegistry = require('@npmcli/mock-registry')
5+
6+
const token = 'test-auth-token'
7+
const auth = { '//registry.npmjs.org/:_authToken': token }
8+
const versions = ['1.0.0', '1.0.1', '1.0.1-pre']
9+
10+
t.test('no args', async t => {
11+
const { npm } = await loadMockNpm(t)
12+
await t.rejects(
13+
npm.exec('undeprecate', []),
14+
{ code: 'EUSAGE' },
15+
'logs usage'
16+
)
17+
})
18+
19+
t.test('undeprecate', async t => {
20+
const { npm, logs, joinedOutput } = await loadMockNpm(t, { config: { ...auth } })
21+
const registry = new MockRegistry({
22+
tap: t,
23+
registry: npm.config.get('registry'),
24+
authorization: token,
25+
})
26+
const manifest = registry.manifest({
27+
name: 'foo',
28+
versions,
29+
})
30+
await registry.package({ manifest, query: { write: true } })
31+
registry.nock.put('/foo', body => {
32+
for (const version of versions) {
33+
if (body.versions[version].deprecated !== '') {
34+
return false
35+
}
36+
}
37+
return true
38+
}).reply(200, {})
39+
40+
await npm.exec('undeprecate', ['foo'])
41+
t.match(logs.notice, [
42+
'undeprecating foo@1.0.0',
43+
'undeprecating foo@1.0.1',
44+
'undeprecating foo@1.0.1-pre',
45+
])
46+
t.match(joinedOutput(), '')
47+
})
48+
49+
t.test('dry-run', async t => {
50+
const { npm, logs, joinedOutput } = await loadMockNpm(t, { config: {
51+
'dry-run': true,
52+
...auth,
53+
} })
54+
const registry = new MockRegistry({
55+
tap: t,
56+
registry: npm.config.get('registry'),
57+
authorization: token,
58+
})
59+
const manifest = registry.manifest({
60+
name: 'foo',
61+
versions,
62+
})
63+
await registry.package({ manifest, query: { write: true } })
64+
65+
await npm.exec('undeprecate', ['foo'])
66+
t.match(logs.notice, [
67+
'undeprecating foo@1.0.0',
68+
'undeprecating foo@1.0.1',
69+
'undeprecating foo@1.0.1-pre',
70+
])
71+
t.match(joinedOutput(), '')
72+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy