@@ -17,26 +17,28 @@ if (!semver.satisfies(process.versions.node, '>= 10.12.0')) {
1717
1818commander
1919 . requiredOption ( '-T, --tag <tag>' , 'NPM published tag' )
20- . arguments ( '<dist_tar_file >' )
20+ . arguments ( '<artifact_zip_file >' )
2121 . option ( '--dry-run' , 'Dry run mode for npm publish' )
2222 . parse ( process . argv ) ;
2323
24- const distTarFile = verifyFile ( commander . args [ 0 ] , '<dist_tar_file >' ) ;
24+ const artifactZipFile = verifyFile ( commander . args [ 0 ] , '<artifact_zip_file >' ) ;
2525const rootDir = path . dirname ( __dirname ) ;
2626const workDir = path . join ( rootDir , 'build' , 'publish' ) ;
2727const distDir = path . join ( rootDir , 'dist' ) ;
28- if ( ! fs . existsSync ( workDir ) ) {
29- fs . mkdirSync ( workDir , { recursive : true } ) ;
28+ if ( fs . existsSync ( workDir ) ) {
29+ rimraf . sync ( workDir ) ;
3030}
31+ fs . mkdirSync ( workDir , { recursive : true } ) ;
32+
33+ child_process . execFileSync ( 'unzip' , [ artifactZipFile , '-d' , workDir ] ) ;
3134
3235// Publish standard package
3336console . log ( '\n\n========== Publish standard package ==========' ) ;
3437createPatchedContext ( rootDir , '' , ( ) => {
3538 if ( fs . existsSync ( distDir ) ) {
3639 rimraf . sync ( distDir ) ;
3740 }
38- child_process . execFileSync ( 'tar' , [ '-xf' , distTarFile , '-C' , workDir ] ) ;
39- fs . renameSync ( path . join ( workDir , 'dist' ) , distDir ) ;
41+ fs . renameSync ( path . join ( workDir , 'archive' , 'dist' ) , distDir ) ;
4042 const publishArgs = [ 'publish' , '--tag' , commander . tag ] ;
4143 if ( commander . dryRun ) {
4244 publishArgs . push ( '--dry-run' ) ;
@@ -47,14 +49,13 @@ createPatchedContext(rootDir, '', () => {
4749// Publish unstripped package
4850// 1. Add suffix in version, e.g. 245459.0.0-unstripped
4951// 2. Add suffix in tag, e.g. latest-unstripped
50- // 3. Get unstripped distribution from dist.unstripped/ in CI dist.tgz
52+ // 3. Get unstripped distribution from dist.unstripped/ in CI archive.zip
5153console . log ( '\n\n========== Publish unstripped package ==========' ) ;
5254createPatchedContext ( rootDir , 'unstripped' , ( ) => {
5355 if ( fs . existsSync ( distDir ) ) {
5456 rimraf . sync ( distDir ) ;
5557 }
56- child_process . execFileSync ( 'tar' , [ '-xf' , distTarFile , '-C' , workDir ] ) ;
57- fs . renameSync ( path . join ( workDir , 'dist.unstripped' ) , distDir ) ;
58+ fs . renameSync ( path . join ( workDir , 'archive' , 'dist.unstripped' ) , distDir ) ;
5859 const publishArgs = [ 'publish' , '--tag' , `${ commander . tag } -unstripped` ] ;
5960 if ( commander . dryRun ) {
6061 publishArgs . push ( '--dry-run' ) ;
0 commit comments