@@ -42,22 +42,30 @@ task(':publish:whoami', execTask('npm', ['whoami'], {
4242task ( ':publish:logout' , execTask ( 'npm' , [ 'logout' ] ) ) ;
4343
4444task ( ':publish' , async ( ) => {
45- const label = argv [ 'tag' ] ;
45+ const tag = argv [ 'tag' ] ;
4646 const version = buildConfig . projectVersion ;
4747 const currentDir = process . cwd ( ) ;
4848
4949 console . log ( '' ) ;
50- if ( ! label ) {
51- console . log ( grey ( '> You can use a label with --tag=labelName.\n' ) ) ;
52- console . log ( green ( `Publishing version "${ version } " using the latest tag...` ) ) ;
50+ if ( ! tag ) {
51+ console . log ( grey ( '> You can specify the tag by passing --tag=labelName.\n' ) ) ;
52+ console . log ( green ( `Publishing version "${ version } " to the latest tag...` ) ) ;
5353 } else {
54- console . log ( yellow ( `Publishing version "${ version } " using the ${ label } tag...` ) ) ;
54+ console . log ( yellow ( `Publishing version "${ version } " to the ${ tag } tag...` ) ) ;
5555 }
5656 console . log ( '' ) ;
5757
58+
59+ if ( version . match ( / ( a l p h a | b e t a | r c ) / ) && ( ! tag || tag === 'latest' ) ) {
60+ console . log ( red ( `Publishing ${ version } to the "latest" tag is not allowed.` ) ) ;
61+ console . log ( red ( `Alpha, Beta or RC versions shouldn't be published to "latest".` ) ) ;
62+ console . log ( ) ;
63+ return ;
64+ }
65+
5866 if ( releasePackages . length > 1 ) {
5967 console . warn ( red ( 'Warning: Multiple packages will be released if proceeding.' ) ) ;
60- console . warn ( red ( 'Warning: Packages to be released: ' , releasePackages . join ( ', ' ) ) ) ;
68+ console . warn ( red ( 'Warning: Packages to be released:' , releasePackages . join ( ', ' ) ) ) ;
6169 console . log ( ) ;
6270 }
6371
@@ -67,13 +75,13 @@ task(':publish', async () => {
6775
6876 // Iterate over every declared release package and publish it on NPM.
6977 for ( const packageName of releasePackages ) {
70- await _execNpmPublish ( label , packageName ) ;
78+ await _execNpmPublish ( tag , packageName ) ;
7179 }
7280
7381 process . chdir ( currentDir ) ;
7482} ) ;
7583
76- function _execNpmPublish ( label : string , packageName : string ) : Promise < { } > | undefined {
84+ function _execNpmPublish ( tag : string , packageName : string ) : Promise < { } > | undefined {
7785 const packageDir = join ( buildConfig . outputDir , 'releases' , packageName ) ;
7886
7987 if ( ! statSync ( packageDir ) . isDirectory ( ) ) {
@@ -94,8 +102,8 @@ function _execNpmPublish(label: string, packageName: string): Promise<{}> | unde
94102 const command = 'npm' ;
95103 const args = [ 'publish' , '--access' , 'public' ] ;
96104
97- if ( label ) {
98- args . push ( '--tag' , label ) ;
105+ if ( tag ) {
106+ args . push ( '--tag' , tag ) ;
99107 }
100108
101109 return new Promise ( ( resolve , reject ) => {
0 commit comments