@@ -7,6 +7,8 @@ import {promptAndGenerateChangelog} from './changelog';
7
7
import { GitClient } from './git/git-client' ;
8
8
import { getGithubBranchCommitsUrl } from './git/github-urls' ;
9
9
import { promptForNewVersion } from './prompt/new-version-prompt' ;
10
+ import { checkMigrationCollection } from './release-output/output-validations' ;
11
+ import { packagesWithMigrations } from './release-output/release-packages' ;
10
12
import { parseVersionName , Version } from './version-name/parse-version' ;
11
13
12
14
/** Default filename for the changelog. */
@@ -51,7 +53,8 @@ class StageReleaseTask extends BaseReleaseTask {
51
53
githubApi : OctokitApi ;
52
54
53
55
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 ) {
55
58
super ( new GitClient ( projectDir , `https://github.com/${ repositoryOwner } /${ repositoryName } .git` ) ) ;
56
59
57
60
this . packageJsonPath = join ( projectDir , 'package.json' ) ;
@@ -93,6 +96,7 @@ class StageReleaseTask extends BaseReleaseTask {
93
96
94
97
this . verifyLocalCommitsMatchUpstream ( publishBranch ) ;
95
98
this . _verifyAngularPeerDependencyVersion ( newVersion ) ;
99
+ this . _checkUpdateMigrationCollection ( newVersion ) ;
96
100
await this . _verifyPassingGithubStatus ( publishBranch ) ;
97
101
98
102
if ( ! this . git . checkoutNewBranch ( stagingBranch ) ) {
@@ -159,17 +163,19 @@ class StageReleaseTask extends BaseReleaseTask {
159
163
*/
160
164
private _verifyAngularPeerDependencyVersion ( newVersion : Version ) {
161
165
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 ;
164
168
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` ;
167
171
168
172
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 } ` ) ) ;
173
179
return process . exit ( 1 ) ;
174
180
}
175
181
}
@@ -181,17 +187,19 @@ class StageReleaseTask extends BaseReleaseTask {
181
187
private _getAngularVersionPlaceholderOrExit ( ) : string {
182
188
const bzlConfigPath = join ( this . projectDir , BAZEL_RELEASE_CONFIG_PATH ) ;
183
189
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 } ` ) ) ;
186
193
return process . exit ( 1 ) ;
187
194
}
188
195
189
196
const configFileContent = readFileSync ( bzlConfigPath , 'utf8' ) ;
190
197
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 = [ " ' ] ( [ ^ " ' ] + ) / ) ;
191
198
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 } ` ) ) ;
195
203
return process . exit ( 1 ) ;
196
204
}
197
205
return matches [ 1 ] ;
@@ -236,9 +244,28 @@ class StageReleaseTask extends BaseReleaseTask {
236
244
237
245
console . info ( chalk . green ( ` ✓ Upstream commit is passing all github status checks.` ) ) ;
238
246
}
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
+ packagesWithMigrations . forEach ( pkgName => {
255
+ failures . push (
256
+ ...checkMigrationCollection ( join ( this . packagesDir , pkgName , 'package.json' ) , newVersion )
257
+ . map ( f => chalk . yellow ( ` ⮑ ${ chalk . bold ( pkgName ) } : ${ 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
+ }
239
265
}
240
266
241
267
/** Entry-point for the release staging script. */
242
268
if ( 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 ( ) ;
244
271
}
0 commit comments