@@ -6,7 +6,7 @@ const Arborist = require('@npmcli/arborist')
66const path = require ( 'node:path' )
77const fs = require ( 'node:fs' )
88
9- const pkg = 'test-package'
9+ const pkg = '@npmcli/ test-package'
1010const token = 'test-auth-token'
1111const auth = { '//registry.npmjs.org/:_authToken' : token }
1212const alternateRegistry = 'https://other.registry.npmjs.org'
@@ -238,8 +238,7 @@ t.test('throws when invalid tag when not url encodable', async t => {
238238 await t . rejects (
239239 npm . exec ( 'publish' , [ ] ) ,
240240 {
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.` ,
243242 }
244243 )
245244} )
@@ -857,15 +856,16 @@ t.test('prerelease dist tag', (t) => {
857856 t . end ( )
858857} )
859858
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 = { } } ) => ( {
862861 config : {
863862 loglevel : 'silent' ,
864863 ...auth ,
865864 } ,
866865 prefixDir : {
867866 'package.json' : JSON . stringify ( {
868867 ...pkgJson ,
868+ ...pkgExtra ,
869869 version,
870870 } , null , 2 ) ,
871871 } ,
@@ -879,46 +879,57 @@ t.test('latest dist tag', (t) => {
879879 { version : '105.0.0-pre' } ,
880880 ]
881881
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 => {
883883 const version = '99.0.0'
884- const { npm, registry } = await loadNpmWithRegistry ( t , init ( version ) )
884+ const { npm, registry } = await loadNpmWithRegistry ( t , init ( { version } ) )
885885 registry . publish ( pkg , { noPut : true , packuments } )
886886 await t . rejects ( async ( ) => {
887887 await npm . exec ( 'publish' , [ ] )
888- /* eslint-disable-next-line max-len */
889888 } , 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.' ) )
890889 } )
891890
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 => {
893892 const version = '99.0.0'
894893 const { npm, registry } = await loadNpmWithRegistry ( t , {
895- ...init ( version ) ,
894+ ...init ( { version } ) ,
896895 argv : [ '--tag' , 'latest' ] ,
897896 } )
898897 registry . publish ( pkg , { packuments } )
899898 await npm . exec ( 'publish' , [ ] )
900899 } )
901900
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 => {
903902 const version = '101.0.0'
904- const { npm, registry } = await loadNpmWithRegistry ( t , init ( version ) )
903+ const { npm, registry } = await loadNpmWithRegistry ( t , init ( { version } ) )
905904 registry . publish ( pkg , { packuments } )
906905 await npm . exec ( 'publish' , [ ] )
907906 } )
908907
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 => {
910909 const version = '1.0.0'
911- const { npm, registry } = await loadNpmWithRegistry ( t , init ( version ) )
910+ const { npm, registry } = await loadNpmWithRegistry ( t , init ( { version } ) )
912911 registry . publish ( pkg , { manifest : { versions : { } } } )
913912 await npm . exec ( 'publish' , [ ] )
914913 } )
915914
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 => {
917916 const version = '1.0.0'
918- const { npm, registry } = await loadNpmWithRegistry ( t , init ( version ) )
917+ const { npm, registry } = await loadNpmWithRegistry ( t , init ( { version } ) )
919918 registry . publish ( pkg , { manifest : { } } )
920919 await npm . exec ( 'publish' , [ ] )
921920 } )
922921
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+ } )
924935} )
0 commit comments