@@ -18,6 +18,7 @@ const {
1818 dry : dryRun ,
1919 publish : doPublish ,
2020 push : doPush ,
21+ registry : registryOverride ,
2122 shortName : shortNameOverride ,
2223 tag : doTag
2324} = argv ;
@@ -27,6 +28,7 @@ const parserOptions = {
2728} ;
2829const reBreaking = new RegExp ( `(${ parserOptions . noteKeywords . join ( ')|(' ) } )` ) ;
2930const NPM_CLI_SPEC = 'npm@11.5.1' ;
31+ const DEFAULT_NPM_REGISTRY = 'https://registry.npmjs.org/' ;
3032
3133type Commit = parser . Commit < string | number | symbol > ;
3234
@@ -147,23 +149,32 @@ const getRepoUrls = async () => {
147149 }
148150} ;
149151
150- const publish = async ( cwd : string ) => {
152+ const publish = async ( cwd : string , registry : string ) => {
151153 if ( dryRun || doPublish === false ) {
152154 log . warn ( chalk `{yellow Skipping Publish}` ) ;
153155 return ;
154156 }
155157
156158 log . info ( chalk `\n{cyan Publishing to NPM}` ) ;
159+ log . info ( chalk `{grey Registry:} ${ registry } ` ) ;
157160
158161 const packDir = mkdtempSync ( join ( tmpdir ( ) , 'versioner-pack-' ) ) ;
159162 try {
160163 await execa ( 'pnpm' , [ 'pack' , '--pack-destination' , packDir ] , { cwd, stdio : 'inherit' } ) ;
161164
162- const tarballs = readdirSync ( packDir ) . filter ( ( file ) => file . endsWith ( '.tgz' ) ) ;
163- const [ tarball ] = tarballs ;
164- if ( ! tarball ) throw new Error ( `Could not find packed tarball in: ${ packDir } ` ) ;
165+ const tarballs = readdirSync ( packDir )
166+ . filter ( ( file ) => file . endsWith ( '.tgz' ) )
167+ . sort ( ) ;
165168
166- const tarballPath = join ( packDir , tarball ) ;
169+ if ( tarballs . length !== 1 ) {
170+ throw new Error (
171+ `Expected exactly 1 packed tarball in: ${ packDir } (found ${
172+ tarballs . length
173+ } ): ${ tarballs . join ( ', ' ) } `
174+ ) ;
175+ }
176+
177+ const tarballPath = join ( packDir , tarballs [ 0 ] ) ;
167178 const hasOidcEnv =
168179 ! ! process . env . ACTIONS_ID_TOKEN_REQUEST_URL && ! ! process . env . ACTIONS_ID_TOKEN_REQUEST_TOKEN ;
169180 const provenanceArgs = hasOidcEnv ? [ '--provenance' ] : [ ] ;
@@ -172,7 +183,15 @@ const publish = async (cwd: string) => {
172183
173184 await execa (
174185 'pnpm' ,
175- [ 'dlx' , NPM_CLI_SPEC , 'publish' , '--no-git-checks' , ...provenanceArgs , tarballPath ] ,
186+ [
187+ 'dlx' ,
188+ NPM_CLI_SPEC ,
189+ 'publish' ,
190+ '--no-git-checks' ,
191+ `--registry=${ registry } ` ,
192+ ...provenanceArgs ,
193+ tarballPath
194+ ] ,
176195 { cwd, stdio : 'inherit' }
177196 ) ;
178197 } finally {
@@ -350,7 +369,7 @@ const updatePackage = async (cwd: string, pkg: RepoPackage, version: string) =>
350369 await commitChanges ( cwd , shortName , newVersion ) ;
351370 // Note: We want to pull here in case there's an error, so nothing gets published
352371 await pull ( ) ;
353- await publish ( cwd ) ;
372+ await publish ( cwd , registryOverride || DEFAULT_NPM_REGISTRY ) ;
354373 await tag ( cwd , shortName , newVersion ) ;
355374 await push ( ) ;
356375 } catch ( e ) {
0 commit comments