1
+ import { green , grey , red , yellow } from 'chalk' ;
1
2
import { spawn } from 'child_process' ;
2
3
import { existsSync , statSync } from 'fs-extra' ;
3
- import { join } from 'path' ;
4
4
import { task } from 'gulp' ;
5
- import { execTask } from '../util/task_helpers' ;
6
5
import { buildConfig , sequenceTask } from 'material2-build-tools' ;
7
- import { yellow , green , red , grey } from 'chalk' ;
8
6
import * as minimist from 'minimist' ;
7
+ import { join } from 'path' ;
8
+ import { execTask } from '../../util/task_helpers' ;
9
+ import { checkPublishBranch , versionNameRegex } from './branch-check' ;
9
10
10
11
/** Packages that will be published to NPM by the release task. */
11
12
export const releasePackages = [
@@ -16,9 +17,6 @@ export const releasePackages = [
16
17
'material-moment-adapter'
17
18
] ;
18
19
19
- /** Regular Expression that matches valid version numbers of Angular Material. */
20
- export const validVersionRegex = / ^ \d + \. \d + \. \d + ( - ( a l p h a | b e t a | r c ) \. \d + ) ? $ / ;
21
-
22
20
/** Parse command-line arguments for release task. */
23
21
const argv = minimist ( process . argv . slice ( 3 ) ) ;
24
22
@@ -50,38 +48,39 @@ task(':publish', async () => {
50
48
const version = buildConfig . projectVersion ;
51
49
const currentDir = process . cwd ( ) ;
52
50
53
- if ( ! version . match ( validVersionRegex ) ) {
54
- console . log ( red ( `Error: Cannot publish due to an invalid version name. Version " ${ version } " ` +
55
- ` is not following our semver format.`) ) ;
56
- console . log ( yellow ( `A version should follow this format: X.X.X, X.X.X-beta.X, X.X.X-alpha .X, ` +
57
- `X.X.X-rc.X` ) ) ;
51
+ if ( ! version . match ( versionNameRegex ) ) {
52
+ console . error ( red ( `Error: Cannot publish due to an invalid version name. Version ` +
53
+ `" ${ version } " is not following our semver format.`) ) ;
54
+ console . error ( yellow ( `A version should follow this format: X.X.X, X.X.X-beta.X, ` +
55
+ `X.X.X-alpha.X, X.X.X- rc.X` ) ) ;
58
56
return ;
59
57
}
60
58
61
- console . log ( '' ) ;
59
+ console . log ( ) ;
62
60
if ( ! tag ) {
63
61
console . log ( grey ( '> You can specify the tag by passing --tag=labelName.\n' ) ) ;
64
62
console . log ( green ( `Publishing version "${ version } " to the latest tag...` ) ) ;
65
63
} else {
66
64
console . log ( yellow ( `Publishing version "${ version } " to the ${ tag } tag...` ) ) ;
67
65
}
68
- console . log ( '' ) ;
69
-
66
+ console . log ( ) ;
70
67
71
68
if ( version . match ( / ( a l p h a | b e t a | r c ) / ) && ( ! tag || tag === 'latest' ) ) {
72
- console . log ( red ( `Publishing ${ version } to the "latest" tag is not allowed.` ) ) ;
73
- console . log ( red ( `Alpha, Beta or RC versions shouldn't be published to "latest".` ) ) ;
74
- console . log ( ) ;
69
+ console . error ( red ( `Publishing ${ version } to the "latest" tag is not allowed.` ) ) ;
70
+ console . error ( red ( `Alpha, Beta or RC versions shouldn't be published to "latest".` ) ) ;
71
+ console . error ( ) ;
75
72
return ;
76
73
}
77
74
78
75
if ( releasePackages . length > 1 ) {
79
- console . warn ( red ( 'Warning: Multiple packages will be released if proceeding .' ) ) ;
80
- console . warn ( red ( 'Warning: Packages to be released:' , releasePackages . join ( ', ' ) ) ) ;
81
- console . log ( ) ;
76
+ console . warn ( yellow ( 'Warning: Multiple packages will be released.' ) ) ;
77
+ console . warn ( yellow ( 'Warning: Packages to be released:' , releasePackages . join ( ', ' ) ) ) ;
78
+ console . warn ( ) ;
82
79
}
83
80
84
- console . log ( yellow ( '> Make sure to check the "angularVersion" in the build config.' ) ) ;
81
+ checkPublishBranch ( version ) ;
82
+
83
+ console . log ( yellow ( '> Make sure to check the "requiredAngularVersion" in the package.json.' ) ) ;
85
84
console . log ( yellow ( '> The version in the config defines the peer dependency of Angular.' ) ) ;
86
85
console . log ( ) ;
87
86
0 commit comments