@@ -7,6 +7,8 @@ import {promptAndGenerateChangelog} from './changelog';
77import { GitClient } from './git/git-client' ;
88import { getGithubBranchCommitsUrl } from './git/github-urls' ;
99import { promptForNewVersion } from './prompt/new-version-prompt' ;
10+ import { checkPackageJsonMigrations } from './release-output/output-validations' ;
11+ import { releasePackages } from './release-output/release-packages' ;
1012import { parseVersionName , Version } from './version-name/parse-version' ;
1113
1214/** Default filename for the changelog. */
@@ -51,7 +53,8 @@ class StageReleaseTask extends BaseReleaseTask {
5153 githubApi : OctokitApi ;
5254
5355 constructor (
54- public projectDir : string , public repositoryOwner : string , public repositoryName : string ) {
56+ public projectDir : string , public packagesDir : string , public repositoryOwner : string ,
57+ public repositoryName : string ) {
5558 super ( new GitClient ( projectDir , `https://github.com/${ repositoryOwner } /${ repositoryName } .git` ) ) ;
5659
5760 this . packageJsonPath = join ( projectDir , 'package.json' ) ;
@@ -93,6 +96,7 @@ class StageReleaseTask extends BaseReleaseTask {
9396
9497 this . verifyLocalCommitsMatchUpstream ( publishBranch ) ;
9598 this . _verifyAngularPeerDependencyVersion ( newVersion ) ;
99+ this . _checkUpdateMigrationCollection ( newVersion ) ;
96100 await this . _verifyPassingGithubStatus ( publishBranch ) ;
97101
98102 if ( ! this . git . checkoutNewBranch ( stagingBranch ) ) {
@@ -159,17 +163,19 @@ class StageReleaseTask extends BaseReleaseTask {
159163 */
160164 private _verifyAngularPeerDependencyVersion ( newVersion : Version ) {
161165 const currentVersionRange = this . _getAngularVersionPlaceholderOrExit ( ) ;
162- const isMajorWithPrerelease = newVersion . minor === 0 && newVersion . patch === 0 &&
163- newVersion . prereleaseLabel !== null ;
166+ const isMajorWithPrerelease =
167+ newVersion . minor === 0 && newVersion . patch === 0 && newVersion . prereleaseLabel !== null ;
164168 const requiredRange = isMajorWithPrerelease ?
165- `^${ newVersion . major } .0.0-0 || ^${ newVersion . major + 1 } .0.0-0` :
166- `^${ newVersion . major } .0.0 || ^${ newVersion . major + 1 } .0.0-0` ;
169+ `^${ newVersion . major } .0.0-0 || ^${ newVersion . major + 1 } .0.0-0` :
170+ `^${ newVersion . major } .0.0 || ^${ newVersion . major + 1 } .0.0-0` ;
167171
168172 if ( requiredRange !== currentVersionRange ) {
169- console . error ( chalk . red ( ` ✘ Cannot stage release. The required Angular version range ` +
170- `is invalid. The version range should be: ${ requiredRange } ` ) ) ;
171- console . error ( chalk . red ( ` Please manually update the version range ` +
172- `in: ${ BAZEL_RELEASE_CONFIG_PATH } ` ) ) ;
173+ console . error ( chalk . red (
174+ ` ✘ Cannot stage release. The required Angular version range ` +
175+ `is invalid. The version range should be: ${ requiredRange } ` ) ) ;
176+ console . error ( chalk . red (
177+ ` Please manually update the version range ` +
178+ `in: ${ BAZEL_RELEASE_CONFIG_PATH } ` ) ) ;
173179 return process . exit ( 1 ) ;
174180 }
175181 }
@@ -181,17 +187,19 @@ class StageReleaseTask extends BaseReleaseTask {
181187 private _getAngularVersionPlaceholderOrExit ( ) : string {
182188 const bzlConfigPath = join ( this . projectDir , BAZEL_RELEASE_CONFIG_PATH ) ;
183189 if ( ! existsSync ( bzlConfigPath ) ) {
184- console . error ( chalk . red ( ` ✘ Cannot stage release. Could not find the file which sets ` +
185- `the Angular peerDependency placeholder value. Looked for: ${ bzlConfigPath } ` ) ) ;
190+ console . error ( chalk . red (
191+ ` ✘ Cannot stage release. Could not find the file which sets ` +
192+ `the Angular peerDependency placeholder value. Looked for: ${ bzlConfigPath } ` ) ) ;
186193 return process . exit ( 1 ) ;
187194 }
188195
189196 const configFileContent = readFileSync ( bzlConfigPath , 'utf8' ) ;
190197 const matches = configFileContent . match ( / A N G U L A R _ P A C K A G E _ V E R S I O N = [ " ' ] ( [ ^ " ' ] + ) / ) ;
191198 if ( ! matches || ! matches [ 1 ] ) {
192- console . error ( chalk . red ( ` ✘ Cannot stage release. Could not find the ` +
193- `"ANGULAR_PACKAGE_VERSION" variable. Please ensure this variable exists. ` +
194- `Looked in: ${ bzlConfigPath } ` ) ) ;
199+ console . error ( chalk . red (
200+ ` ✘ Cannot stage release. Could not find the ` +
201+ `"ANGULAR_PACKAGE_VERSION" variable. Please ensure this variable exists. ` +
202+ `Looked in: ${ bzlConfigPath } ` ) ) ;
195203 return process . exit ( 1 ) ;
196204 }
197205 return matches [ 1 ] ;
@@ -236,9 +244,28 @@ class StageReleaseTask extends BaseReleaseTask {
236244
237245 console . info ( chalk . green ( ` ✓ Upstream commit is passing all github status checks.` ) ) ;
238246 }
247+
248+ /**
249+ * Checks if the update migration collections are set up to properly
250+ * handle the given new version.
251+ */
252+ private _checkUpdateMigrationCollection ( newVersion : Version ) {
253+ const failures : string [ ] = [ ] ;
254+ releasePackages . forEach ( packageName => {
255+ failures . push ( ...checkPackageJsonMigrations (
256+ join ( this . packagesDir , packageName , 'package.json' ) , newVersion )
257+ . map ( f => chalk . yellow ( ` ⮑ ${ chalk . bold ( packageName ) } : ${ f } ` ) ) ) ;
258+ } ) ;
259+ if ( failures . length ) {
260+ console . error ( chalk . red ( ` ✘ Failures in ng-update migration collection detected:` ) ) ;
261+ failures . forEach ( f => console . error ( f ) ) ;
262+ process . exit ( 1 ) ;
263+ }
264+ }
239265}
240266
241267/** Entry-point for the release staging script. */
242268if ( require . main === module ) {
243- new StageReleaseTask ( join ( __dirname , '../../' ) , 'angular' , 'components' ) . run ( ) ;
269+ const projectDir = join ( __dirname , '../../' ) ;
270+ new StageReleaseTask ( projectDir , join ( projectDir , 'src/' ) , 'angular' , 'components' ) . run ( ) ;
244271}
0 commit comments