@@ -26,28 +26,31 @@ wombatDressingRoomTokens.forEach((token, pkg) => {
2626
2727const packagesToPublish = filteredLernaList . map ( ( lerna ) => {
2828 const useVersionFromRef = versionFromRef && lerna . name . endsWith ( packageFromRef ) ;
29- if ( useVersionFromRef && versionFromRef && versionFromRef . split ( "-" ) [ 0 ] !== lerna . version ) {
29+ if ( useVersionFromRef && versionFromRef . split ( "-" ) [ 0 ] !== lerna . version ) {
3030 throw new Error (
3131 `Cowardly refusing to publish ${ lerna . name } @${ versionFromRef } from ${ lerna . version } , version needs to be bumped in source.` ,
3232 ) ;
3333 }
34- const version = ( useVersionFromRef && versionFromRef ) || `${ lerna . version } -canary.${ shortSHA } ` ;
34+ const newVersion = useVersionFromRef ? versionFromRef : `${ lerna . version } -canary.${ shortSHA } ` ;
35+ const registry = wombatDressingRoomTokens . get ( lerna . name )
36+ ? `https://wombat-dressing-room.appspot.com/${ lerna . name } /_ns`
37+ : "https://registry.npmjs.org" ;
38+ const tag = useVersionFromRef ? ( prerelease ? "next" : "latest" ) : "canary" ;
3539 const packageJsonPath = join ( lerna . location , "package.json" ) ;
3640 const packageJson = JSON . parse ( readFileSync ( packageJsonPath ) . toString ( ) ) ;
37- packageJson . version = version ;
41+ packageJson . version = newVersion ;
42+ packageJson . publishConfig = { tag, registry, provenance : true , access : "public" } ;
3843 return packageJson ;
3944} ) ;
4045
4146for ( const packageJson of packagesToPublish ) {
42- const usedVersionFromRef = packageJson . version === versionFromRef ;
43- const tag = usedVersionFromRef ? ( prerelease ? "next" : "latest" ) : "canary" ;
4447 for ( const dependency in packageJson . dependencies ) {
4548 if ( dependency ) {
4649 const lernaPackage = lernaList . find ( ( it ) => it . name === dependency ) ;
4750 if ( lernaPackage ) {
4851 const changedPackage = packagesToPublish . find ( ( it ) => it . name === dependency ) ;
4952 const version = changedPackage ?. version || lernaPackage . version ;
50- if ( tag === "latest" && version . includes ( "-" ) ) {
53+ if ( packageJson . publishConfig . tag === "latest" && version . includes ( "-" ) ) {
5154 throw new Error (
5255 `Cowardly refusing to publish ${ packageJson . name } @${ packageJson . version } with dependency on a pre-release ${ dependency } @${ version } ` ,
5356 ) ;
@@ -59,9 +62,6 @@ for (const packageJson of packagesToPublish) {
5962 const lerna = lernaList . find ( ( it ) => it . name === packageJson . name ) ;
6063 const packageJsonPath = join ( lerna . location , "package.json" ) ;
6164 writeFileSync ( packageJsonPath , JSON . stringify ( packageJson , undefined , 2 ) ) ;
62- const registry = wombatDressingRoomTokens . get ( lerna . name )
63- ? `https://wombat-dressing-room.appspot.com/${ lerna . name } /_ns`
64- : "https://registry.npmjs.org" ;
6565 const cwd = lerna . location ;
66- execSync ( `npm publish --registry ${ registry } --access public --tag ${ tag } --provenance ` , { cwd } ) ;
66+ execSync ( `npm publish` , { cwd } ) ;
6767}
0 commit comments