+45
-34
lines changedFilter options
+45
-34
lines changed Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ class Publish extends BaseCommand {
117
117
manifest = await this.#getManifest(spec, opts, true)
118
118
119
119
const isPreRelease = Boolean(semver.parse(manifest.version).prerelease.length)
120
-
const isDefaultTag = this.npm.config.isDefault('tag')
120
+
const isDefaultTag = this.npm.config.isDefault('tag') && !manifest.publishConfig?.tag
121
121
122
122
if (isPreRelease && isDefaultTag) {
123
123
throw new Error('You must specify a tag using --tag when publishing a prerelease version.')
@@ -157,7 +157,7 @@ class Publish extends BaseCommand {
157
157
}
158
158
}
159
159
160
-
const latestVersion = await this.#latestPublishedVersion(resolved, registry)
160
+
const latestVersion = await this.#highestPublishedVersion(resolved, registry)
161
161
const latestSemverIsGreater = !!latestVersion && semver.gte(latestVersion, manifest.version)
162
162
163
163
if (latestSemverIsGreater && isDefaultTag) {
@@ -204,7 +204,7 @@ class Publish extends BaseCommand {
204
204
}
205
205
}
206
206
207
-
async #latestPublishedVersion (spec, registry) {
207
+
async #highestPublishedVersion (spec, registry) {
208
208
try {
209
209
const packument = await pacote.packument(spec, {
210
210
...this.npm.flatOptions,
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
6
6
*/
7
7
'use strict'
8
8
exports[`test/lib/commands/publish.js TAP _auth config default registry > new package version 1`] = `
9
-
+ test-package@1.0.0
9
+
+ @npmcli/test-package@1.0.0
10
10
`
11
11
12
12
exports[`test/lib/commands/publish.js TAP bare _auth and registry config > new package version 1`] = `
@@ -15,15 +15,15 @@ exports[`test/lib/commands/publish.js TAP bare _auth and registry config > new p
15
15
16
16
exports[`test/lib/commands/publish.js TAP dry-run > must match snapshot 1`] = `
17
17
Array [
18
-
"package: test-package@1.0.0",
18
+
"package: @npmcli/test-package@1.0.0",
19
19
"Tarball Contents",
20
-
"87B package.json",
20
+
"95B package.json",
21
21
"Tarball Details",
22
-
"name: test-package",
22
+
"name: @npmcli/test-package",
23
23
"version: 1.0.0",
24
-
"filename: test-package-1.0.0.tgz",
24
+
"filename: npmcli-test-package-1.0.0.tgz",
25
25
"package size: {size}",
26
-
"unpacked size: 87 B",
26
+
"unpacked size: 95 B",
27
27
"shasum: {sha}",
28
28
"integrity: {integrity}
29
29
"total files: 1",
@@ -76,7 +76,7 @@ exports[`test/lib/commands/publish.js TAP has token auth for scope configured re
76
76
`
77
77
78
78
exports[`test/lib/commands/publish.js TAP ignore-scripts > new package version 1`] = `
79
-
+ test-package@1.0.0
79
+
+ @npmcli/test-package@1.0.0
80
80
`
81
81
82
82
exports[`test/lib/commands/publish.js TAP json > must match snapshot 1`] = `
@@ -87,14 +87,14 @@ Array [
87
87
88
88
exports[`test/lib/commands/publish.js TAP json > new package json 1`] = `
89
89
{
90
-
"id": "test-package@1.0.0",
91
-
"name": "test-package",
90
+
"id": "@npmcli/test-package@1.0.0",
91
+
"name": "@npmcli/test-package",
92
92
"version": "1.0.0",
93
93
"size": "{size}",
94
-
"unpackedSize": 87,
94
+
"unpackedSize": 95,
95
95
"shasum": "{sha}",
96
96
"integrity": "{integrity}",
97
-
"filename": "test-package-1.0.0.tgz",
97
+
"filename": "npmcli-test-package-1.0.0.tgz",
98
98
"files": [
99
99
{
100
100
"path": "package.json",
@@ -249,7 +249,7 @@ Object {
249
249
`
250
250
251
251
exports[`test/lib/commands/publish.js TAP no auth dry-run > must match snapshot 1`] = `
252
-
+ test-package@1.0.0
252
+
+ @npmcli/test-package@1.0.0
253
253
`
254
254
255
255
exports[`test/lib/commands/publish.js TAP no auth dry-run > warns about auth being needed 1`] = `
@@ -259,7 +259,7 @@ Array [
259
259
`
260
260
261
261
exports[`test/lib/commands/publish.js TAP prioritize CLI flags over publishConfig > new package version 1`] = `
262
-
+ test-package@1.0.0
262
+
+ @npmcli/test-package@1.0.0
263
263
`
264
264
265
265
exports[`test/lib/commands/publish.js TAP public access > must match snapshot 1`] = `
@@ -285,7 +285,7 @@ exports[`test/lib/commands/publish.js TAP public access > new package version 1`
285
285
`
286
286
287
287
exports[`test/lib/commands/publish.js TAP re-loads publishConfig.registry if added during script process > new package version 1`] = `
288
-
+ test-package@1.0.0
288
+
+ @npmcli/test-package@1.0.0
289
289
`
290
290
291
291
exports[`test/lib/commands/publish.js TAP respects publishConfig.registry, runs appropriate scripts > new package version 1`] = `
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ const Arborist = require('@npmcli/arborist')
6
6
const path = require('node:path')
7
7
const fs = require('node:fs')
8
8
9
-
const pkg = 'test-package'
9
+
const pkg = '@npmcli/test-package'
10
10
const token = 'test-auth-token'
11
11
const auth = { '//registry.npmjs.org/:_authToken': token }
12
12
const alternateRegistry = 'https://other.registry.npmjs.org'
@@ -238,8 +238,7 @@ t.test('throws when invalid tag when not url encodable', async t => {
238
238
await t.rejects(
239
239
npm.exec('publish', []),
240
240
{
241
-
/* eslint-disable-next-line max-len */
242
-
message: 'Invalid tag name "@test" of package "test-package@@test": Tags may not have any characters that encodeURIComponent encodes.',
241
+
message: `Invalid tag name "@test" of package "${pkg}@@test": Tags may not have any characters that encodeURIComponent encodes.`,
243
242
}
244
243
)
245
244
})
@@ -857,15 +856,16 @@ t.test('prerelease dist tag', (t) => {
857
856
t.end()
858
857
})
859
858
860
-
t.test('latest dist tag', (t) => {
861
-
const init = (version) => ({
859
+
t.test('semver highest dist tag', async t => {
860
+
const init = ({ version, pkgExtra = {} }) => ({
862
861
config: {
863
862
loglevel: 'silent',
864
863
...auth,
865
864
},
866
865
prefixDir: {
867
866
'package.json': JSON.stringify({
868
867
...pkgJson,
868
+
...pkgExtra,
869
869
version,
870
870
}, null, 2),
871
871
},
@@ -879,46 +879,57 @@ t.test('latest dist tag', (t) => {
879
879
{ version: '105.0.0-pre' },
880
880
]
881
881
882
-
t.test('PREVENTS publish when latest version is HIGHER than publishing version', async t => {
882
+
await t.test('PREVENTS publish when highest version is HIGHER than publishing version', async t => {
883
883
const version = '99.0.0'
884
-
const { npm, registry } = await loadNpmWithRegistry(t, init(version))
884
+
const { npm, registry } = await loadNpmWithRegistry(t, init({ version }))
885
885
registry.publish(pkg, { noPut: true, packuments })
886
886
await t.rejects(async () => {
887
887
await npm.exec('publish', [])
888
-
/* eslint-disable-next-line max-len */
889
888
}, new Error('Cannot implicitly apply the "latest" tag because published version 100.0.0 is higher than the new version 99.0.0. You must specify a tag using --tag.'))
890
889
})
891
890
892
-
t.test('ALLOWS publish when latest is HIGHER than publishing version and flag', async t => {
891
+
await t.test('ALLOWS publish when highest is HIGHER than publishing version and flag', async t => {
893
892
const version = '99.0.0'
894
893
const { npm, registry } = await loadNpmWithRegistry(t, {
895
-
...init(version),
894
+
...init({ version }),
896
895
argv: ['--tag', 'latest'],
897
896
})
898
897
registry.publish(pkg, { packuments })
899
898
await npm.exec('publish', [])
900
899
})
901
900
902
-
t.test('ALLOWS publish when latest versions are LOWER than publishing version', async t => {
901
+
await t.test('ALLOWS publish when highest versions are LOWER than publishing version', async t => {
903
902
const version = '101.0.0'
904
-
const { npm, registry } = await loadNpmWithRegistry(t, init(version))
903
+
const { npm, registry } = await loadNpmWithRegistry(t, init({ version }))
905
904
registry.publish(pkg, { packuments })
906
905
await npm.exec('publish', [])
907
906
})
908
907
909
-
t.test('ALLOWS publish when packument has empty versions (for coverage)', async t => {
908
+
await t.test('ALLOWS publish when packument has empty versions (for coverage)', async t => {
910
909
const version = '1.0.0'
911
-
const { npm, registry } = await loadNpmWithRegistry(t, init(version))
910
+
const { npm, registry } = await loadNpmWithRegistry(t, init({ version }))
912
911
registry.publish(pkg, { manifest: { versions: { } } })
913
912
await npm.exec('publish', [])
914
913
})
915
914
916
-
t.test('ALLOWS publish when packument has empty manifest (for coverage)', async t => {
915
+
await t.test('ALLOWS publish when packument has empty manifest (for coverage)', async t => {
917
916
const version = '1.0.0'
918
-
const { npm, registry } = await loadNpmWithRegistry(t, init(version))
917
+
const { npm, registry } = await loadNpmWithRegistry(t, init({ version }))
919
918
registry.publish(pkg, { manifest: {} })
920
919
await npm.exec('publish', [])
921
920
})
922
921
923
-
t.end()
922
+
await t.test('ALLOWS publish when highest version is HIGHER than publishing version with publishConfig', async t => {
923
+
const version = '99.0.0'
924
+
const { npm, registry } = await loadNpmWithRegistry(t, init({
925
+
version,
926
+
pkgExtra: {
927
+
publishConfig: {
928
+
tag: 'next',
929
+
},
930
+
},
931
+
}))
932
+
registry.publish(pkg, { packuments })
933
+
await npm.exec('publish', [])
934
+
})
924
935
})
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