1+ import { green , grey , red , yellow } from 'chalk' ;
12import { spawn } from 'child_process' ;
23import { existsSync , statSync } from 'fs-extra' ;
3- import { join } from 'path' ;
44import { task } from 'gulp' ;
5- import { execTask } from '../util/task_helpers' ;
65import { buildConfig , sequenceTask } from 'material2-build-tools' ;
7- import { yellow , green , red , grey } from 'chalk' ;
86import * as minimist from 'minimist' ;
7+ import { join } from 'path' ;
8+ import { execTask } from '../../util/task_helpers' ;
9+ import { checkPublishBranch , versionNameRegex } from './branch-check' ;
910
1011/** Packages that will be published to NPM by the release task. */
1112export const releasePackages = [
@@ -16,9 +17,6 @@ export const releasePackages = [
1617 'material-moment-adapter'
1718] ;
1819
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-
2220/** Parse command-line arguments for release task. */
2321const argv = minimist ( process . argv . slice ( 3 ) ) ;
2422
@@ -50,38 +48,39 @@ task(':publish', async () => {
5048 const version = buildConfig . projectVersion ;
5149 const currentDir = process . cwd ( ) ;
5250
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` ) ) ;
5856 return ;
5957 }
6058
61- console . log ( '' ) ;
59+ console . log ( ) ;
6260 if ( ! tag ) {
6361 console . log ( grey ( '> You can specify the tag by passing --tag=labelName.\n' ) ) ;
6462 console . log ( green ( `Publishing version "${ version } " to the latest tag...` ) ) ;
6563 } else {
6664 console . log ( yellow ( `Publishing version "${ version } " to the ${ tag } tag...` ) ) ;
6765 }
68- console . log ( '' ) ;
69-
66+ console . log ( ) ;
7067
7168 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 ( ) ;
7572 return ;
7673 }
7774
7875 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 ( ) ;
8279 }
8380
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.' ) ) ;
8584 console . log ( yellow ( '> The version in the config defines the peer dependency of Angular.' ) ) ;
8685 console . log ( ) ;
8786
0 commit comments