@@ -42,22 +42,30 @@ task(':publish:whoami', execTask('npm', ['whoami'], {
42
42
task ( ':publish:logout' , execTask ( 'npm' , [ 'logout' ] ) ) ;
43
43
44
44
task ( ':publish' , async ( ) => {
45
- const label = argv [ 'tag' ] ;
45
+ const tag = argv [ 'tag' ] ;
46
46
const version = buildConfig . projectVersion ;
47
47
const currentDir = process . cwd ( ) ;
48
48
49
49
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...` ) ) ;
53
53
} else {
54
- console . log ( yellow ( `Publishing version "${ version } " using the ${ label } tag...` ) ) ;
54
+ console . log ( yellow ( `Publishing version "${ version } " to the ${ tag } tag...` ) ) ;
55
55
}
56
56
console . log ( '' ) ;
57
57
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
+
58
66
if ( releasePackages . length > 1 ) {
59
67
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 ( ', ' ) ) ) ;
61
69
console . log ( ) ;
62
70
}
63
71
@@ -67,13 +75,13 @@ task(':publish', async () => {
67
75
68
76
// Iterate over every declared release package and publish it on NPM.
69
77
for ( const packageName of releasePackages ) {
70
- await _execNpmPublish ( label , packageName ) ;
78
+ await _execNpmPublish ( tag , packageName ) ;
71
79
}
72
80
73
81
process . chdir ( currentDir ) ;
74
82
} ) ;
75
83
76
- function _execNpmPublish ( label : string , packageName : string ) : Promise < { } > | undefined {
84
+ function _execNpmPublish ( tag : string , packageName : string ) : Promise < { } > | undefined {
77
85
const packageDir = join ( buildConfig . outputDir , 'releases' , packageName ) ;
78
86
79
87
if ( ! statSync ( packageDir ) . isDirectory ( ) ) {
@@ -94,8 +102,8 @@ function _execNpmPublish(label: string, packageName: string): Promise<{}> | unde
94
102
const command = 'npm' ;
95
103
const args = [ 'publish' , '--access' , 'public' ] ;
96
104
97
- if ( label ) {
98
- args . push ( '--tag' , label ) ;
105
+ if ( tag ) {
106
+ args . push ( '--tag' , tag ) ;
99
107
}
100
108
101
109
return new Promise ( ( resolve , reject ) => {
0 commit comments