-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
175 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: npm-undeprecate | ||
section: 1 | ||
description: Undeprecate a version of a package | ||
--- | ||
|
||
### Synopsis | ||
|
||
<!-- AUTOGENERATED USAGE DESCRIPTIONS --> | ||
|
||
### Description | ||
|
||
This command will update the npm registry entry for a package, removing any | ||
deprecation warnings that currently exist. | ||
|
||
It works in the same way as [npm deprecate](/commands/npm-deprecate), except | ||
that this command removes deprecation warnings instead of adding them. | ||
|
||
### Configuration | ||
|
||
<!-- AUTOGENERATED CONFIG DESCRIPTIONS --> | ||
### See Also | ||
|
||
* [npm deprecate](/commands/npm-deprecate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const Deprecate = require('./deprecate.js') | ||
|
||
class Undeprecate extends Deprecate { | ||
static description = 'Undeprecate a version of a package' | ||
static name = 'undeprecate' | ||
static usage = ['<package-spec>'] | ||
|
||
async exec ([pkg]) { | ||
return super.exec([pkg, '']) | ||
} | ||
} | ||
|
||
module.exports = Undeprecate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ const commands = [ | |
'team', | ||
'test', | ||
'token', | ||
'undeprecate', | ||
'uninstall', | ||
'unpublish', | ||
'unstar', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,7 @@ Array [ | |
team | ||
test | ||
token | ||
undeprecate | ||
uninstall | ||
unpublish | ||
unstar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const t = require('tap') | ||
const { load: loadMockNpm } = require('../../fixtures/mock-npm') | ||
|
||
const MockRegistry = require('@npmcli/mock-registry') | ||
|
||
const token = 'test-auth-token' | ||
const auth = { '//registry.npmjs.org/:_authToken': token } | ||
const versions = ['1.0.0', '1.0.1', '1.0.1-pre'] | ||
|
||
t.test('no args', async t => { | ||
const { npm } = await loadMockNpm(t) | ||
await t.rejects( | ||
npm.exec('undeprecate', []), | ||
{ code: 'EUSAGE' }, | ||
'logs usage' | ||
) | ||
}) | ||
|
||
t.test('undeprecate', async t => { | ||
const { npm, logs, joinedOutput } = await loadMockNpm(t, { config: { ...auth } }) | ||
const registry = new MockRegistry({ | ||
tap: t, | ||
registry: npm.config.get('registry'), | ||
authorization: token, | ||
}) | ||
const manifest = registry.manifest({ | ||
name: 'foo', | ||
versions, | ||
}) | ||
await registry.package({ manifest, query: { write: true } }) | ||
registry.nock.put('/foo', body => { | ||
for (const version of versions) { | ||
if (body.versions[version].deprecated !== '') { | ||
return false | ||
} | ||
} | ||
return true | ||
}).reply(200, {}) | ||
|
||
await npm.exec('undeprecate', ['foo']) | ||
t.match(logs.notice, [ | ||
'undeprecating [email protected]', | ||
'undeprecating [email protected]', | ||
'undeprecating [email protected]', | ||
]) | ||
t.match(joinedOutput(), '') | ||
}) | ||
|
||
t.test('dry-run', async t => { | ||
const { npm, logs, joinedOutput } = await loadMockNpm(t, { config: { | ||
'dry-run': true, | ||
...auth, | ||
} }) | ||
const registry = new MockRegistry({ | ||
tap: t, | ||
registry: npm.config.get('registry'), | ||
authorization: token, | ||
}) | ||
const manifest = registry.manifest({ | ||
name: 'foo', | ||
versions, | ||
}) | ||
await registry.package({ manifest, query: { write: true } }) | ||
|
||
await npm.exec('undeprecate', ['foo']) | ||
t.match(logs.notice, [ | ||
'undeprecating [email protected]', | ||
'undeprecating [email protected]', | ||
'undeprecating [email protected]', | ||
]) | ||
t.match(joinedOutput(), '') | ||
}) |