99 * the primary `cdk` and `material` packages, and also don't run for pull requests.
1010 */
1111
12- const { join} = require ( 'path' ) ;
13- const { rm , mkdir , test , ls , set , exec , cd } = require ( 'shelljs' ) ;
14- const { red , green } = require ( 'chalk' ) ;
15- const yargs = require ( 'yargs' ) ;
12+ import { join } from 'path' ;
13+ import sh from 'shelljs' ;
14+ import chalk from 'chalk' ;
15+ import yargs from 'yargs' ;
1616
17- const projectDir = join ( __dirname , '../' ) ;
1817const archivesDir = 'dist/release-archives' ;
1918const releasesDir = 'dist/releases' ;
2019const { suffix} = yargs ( process . argv . slice ( 2 ) )
@@ -23,34 +22,35 @@ const {suffix} = yargs(process.argv.slice(2))
2322 . parseSync ( ) ;
2423
2524// Fail if any ShellJS command fails.
26- set ( '-e' ) ;
25+ sh . set ( '-e' ) ;
2726
28- cd ( projectDir ) ;
29-
30- if ( ! test ( '-e' , releasesDir ) ) {
31- console . error ( red ( 'The release output has not been built.' ) ) ;
27+ if ( ! sh . test ( '-e' , releasesDir ) ) {
28+ console . error ( chalk . red ( 'The release output has not been built.' ) ) ;
3229 process . exit ( 1 ) ;
3330}
3431
35- rm ( '-Rf' , archivesDir ) ;
36- mkdir ( '-p' , archivesDir ) ;
32+ sh . rm ( '-Rf' , archivesDir ) ;
33+ sh . mkdir ( '-p' , archivesDir ) ;
3734
38- const builtPackages = ls ( releasesDir )
35+ const builtPackages = sh
36+ . ls ( releasesDir )
3937 . map ( name => ( { name, path : join ( releasesDir , name ) } ) )
40- . filter ( pkg => test ( '-d' , pkg . path ) ) ;
38+ . filter ( pkg => sh . test ( '-d' , pkg . path ) ) ;
4139
4240// If multiple packages should be archived, we also generate a single archive that
4341// contains all packages. This makes it easier to transfer the release packages.
4442if ( builtPackages . length > 1 ) {
4543 console . info ( 'Creating archive with all packages..' ) ;
46- exec ( `tar --create --gzip --directory ${ releasesDir } --file ${ archivesDir } /all-${ suffix } .tgz .` ) ;
44+ sh . exec (
45+ `tar --create --gzip --directory ${ releasesDir } --file ${ archivesDir } /all-${ suffix } .tgz .` ,
46+ ) ;
4747}
4848
4949for ( const pkg of builtPackages ) {
5050 console . info ( `Creating archive for package: ${ pkg . name } ` ) ;
51- exec (
51+ sh . exec (
5252 `tar --create --gzip --directory ${ pkg . path } --file ${ archivesDir } /${ pkg . name } -${ suffix } .tgz .` ,
5353 ) ;
5454}
5555
56- console . info ( green ( `Created package archives in: ${ archivesDir } ` ) ) ;
56+ console . info ( chalk . green ( `Created package archives in: ${ archivesDir } ` ) ) ;
0 commit comments