+49
-8
lines changedFilter options
+49
-8
lines changed Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ class Deprecate extends BaseCommand {
14
14
static params = [
15
15
'registry',
16
16
'otp',
17
+
'dry-run',
17
18
]
18
19
19
20
static ignoreImplicitWorkspace = true
@@ -56,17 +57,26 @@ class Deprecate extends BaseCommand {
56
57
const versions = Object.keys(packument.versions)
57
58
.filter(v => semver.satisfies(v, spec, { includePrerelease: true }))
58
59
60
+
const dryRun = this.npm.config.get('dry-run')
61
+
59
62
if (versions.length) {
60
63
for (const v of versions) {
61
64
packument.versions[v].deprecated = msg
65
+
if (msg) {
66
+
log.notice(`deprecating ${packument.name}@${v} with message "${msg}"`)
67
+
} else {
68
+
log.notice(`undeprecating ${packument.name}@${v}`)
69
+
}
70
+
}
71
+
if (!dryRun) {
72
+
return otplease(this.npm, this.npm.flatOptions, opts => npmFetch(uri, {
73
+
...opts,
74
+
spec: p,
75
+
method: 'PUT',
76
+
body: packument,
77
+
ignoreBody: true,
78
+
}))
62
79
}
63
-
return otplease(this.npm, this.npm.flatOptions, opts => npmFetch(uri, {
64
-
...opts,
65
-
spec: p,
66
-
method: 'PUT',
67
-
body: packument,
68
-
ignoreBody: true,
69
-
}))
70
80
} else {
71
81
log.warn('deprecate', 'No version found for', p.rawSpec)
72
82
}
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ t.test('deprecates given range', async t => {
129
129
})
130
130
131
131
t.test('deprecates all versions when no range is specified', async t => {
132
-
const { npm, joinedOutput } = await loadMockNpm(t, { config: { ...auth } })
132
+
const { npm, logs, joinedOutput } = await loadMockNpm(t, { config: { ...auth } })
133
133
const registry = new MockRegistry({
134
134
tap: t,
135
135
registry: npm.config.get('registry'),
@@ -151,6 +151,37 @@ t.test('deprecates all versions when no range is specified', async t => {
151
151
}).reply(200, {})
152
152
153
153
await npm.exec('deprecate', ['foo', message])
154
+
t.match(logs.notice, [
155
+
`deprecating foo@1.0.0 with message "${message}"`,
156
+
`deprecating foo@1.0.1 with message "${message}"`,
157
+
`deprecating foo@1.0.1-pre with message "${message}"`,
158
+
])
159
+
t.match(joinedOutput(), '')
160
+
})
161
+
162
+
t.test('dry-run', async t => {
163
+
const { npm, logs, joinedOutput } = await loadMockNpm(t, { config: {
164
+
'dry-run': true,
165
+
...auth,
166
+
} })
167
+
const registry = new MockRegistry({
168
+
tap: t,
169
+
registry: npm.config.get('registry'),
170
+
authorization: token,
171
+
})
172
+
const manifest = registry.manifest({
173
+
name: 'foo',
174
+
versions,
175
+
})
176
+
await registry.package({ manifest, query: { write: true } })
177
+
const message = 'test deprecation message'
178
+
179
+
await npm.exec('deprecate', ['foo', message])
180
+
t.match(logs.notice, [
181
+
`deprecating foo@1.0.0 with message "${message}"`,
182
+
`deprecating foo@1.0.1 with message "${message}"`,
183
+
`deprecating foo@1.0.1-pre with message "${message}"`,
184
+
])
154
185
t.match(joinedOutput(), '')
155
186
})
156
187
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4