@@ -32,7 +32,6 @@ export const CHANGELOG_FILE_NAME = 'CHANGELOG.md';
32
32
* 11) Create a commit that includes all changes in the staging branch.
33
33
*/
34
34
class StageReleaseTask extends BaseReleaseTask {
35
-
36
35
/** Path to the project package JSON. */
37
36
packageJsonPath : string ;
38
37
@@ -48,19 +47,18 @@ class StageReleaseTask extends BaseReleaseTask {
48
47
/** Octokit API instance that can be used to make Github API calls. */
49
48
githubApi : OctokitApi ;
50
49
51
- constructor ( public projectDir : string ,
52
- public repositoryOwner : string ,
53
- public repositoryName : string ) {
54
- super ( new GitClient ( projectDir ,
55
- `https://github.com/${ repositoryOwner } /${ repositoryName } .git` ) ) ;
50
+ constructor (
51
+ public projectDir : string , public repositoryOwner : string , public repositoryName : string ) {
52
+ super ( new GitClient ( projectDir , `https://github.com/${ repositoryOwner } /${ repositoryName } .git` ) ) ;
56
53
57
54
this . packageJsonPath = join ( projectDir , 'package.json' ) ;
58
55
this . packageJson = JSON . parse ( readFileSync ( this . packageJsonPath , 'utf-8' ) ) ;
59
- this . currentVersion = parseVersionName ( this . packageJson . version ) ;
56
+ this . currentVersion = parseVersionName ( this . packageJson . version ) ! ;
60
57
61
58
if ( ! this . currentVersion ) {
62
- console . error ( red ( `Cannot parse current version in ${ italic ( 'package.json' ) } . Please ` +
63
- `make sure "${ this . packageJson . version } " is a valid Semver version.` ) ) ;
59
+ console . error (
60
+ red ( `Cannot parse current version in ${ italic ( 'package.json' ) } . Please ` +
61
+ `make sure "${ this . packageJson . version } " is a valid Semver version.` ) ) ;
64
62
process . exit ( 1 ) ;
65
63
}
66
64
@@ -101,18 +99,21 @@ class StageReleaseTask extends BaseReleaseTask {
101
99
if ( needsVersionBump ) {
102
100
this . _updatePackageJsonVersion ( newVersionName ) ;
103
101
104
- console . log ( green ( ` ✓ Updated the version to "${ bold ( newVersionName ) } " inside of the ` +
105
- `${ italic ( 'package.json' ) } ` ) ) ;
102
+ console . log ( green (
103
+ ` ✓ Updated the version to "${ bold ( newVersionName ) } " inside of the ` +
104
+ `${ italic ( 'package.json' ) } ` ) ) ;
106
105
console . log ( ) ;
107
106
}
108
107
109
108
await promptAndGenerateChangelog ( join ( this . projectDir , CHANGELOG_FILE_NAME ) ) ;
110
109
111
110
console . log ( ) ;
112
- console . log ( green ( ` ✓ Updated the changelog in ` +
113
- `"${ bold ( CHANGELOG_FILE_NAME ) } "` ) ) ;
114
- console . log ( yellow ( ` ⚠ Please review CHANGELOG.md and ensure that the log contains only ` +
115
- `changes that apply to the public library release. When done, proceed to the prompt below.` ) ) ;
111
+ console . log ( green (
112
+ ` ✓ Updated the changelog in ` +
113
+ `"${ bold ( CHANGELOG_FILE_NAME ) } "` ) ) ;
114
+ console . log ( yellow (
115
+ ` ⚠ Please review CHANGELOG.md and ensure that the log contains only changes ` +
116
+ `that apply to the public library release. When done, proceed to the prompt below.` ) ) ;
116
117
console . log ( ) ;
117
118
118
119
if ( ! await this . promptConfirm ( 'Do you want to proceed and commit the changes?' ) ) {
@@ -148,23 +149,37 @@ class StageReleaseTask extends BaseReleaseTask {
148
149
/** Verifies that the latest commit of the current branch is passing all Github statuses. */
149
150
private async _verifyPassingGithubStatus ( expectedPublishBranch : string ) {
150
151
const commitRef = this . git . getLocalCommitSha ( 'HEAD' ) ;
151
- const githubCommitsUrl = getGithubBranchCommitsUrl ( this . repositoryOwner , this . repositoryName ,
152
- expectedPublishBranch ) ;
152
+ const githubCommitsUrl =
153
+ getGithubBranchCommitsUrl ( this . repositoryOwner , this . repositoryName , expectedPublishBranch ) ;
153
154
const { state} = ( await this . githubApi . repos . getCombinedStatusForRef ( {
154
- owner : this . repositoryOwner ,
155
- repo : this . repositoryName ,
156
- ref : commitRef ,
157
- } ) ) . data ;
155
+ owner : this . repositoryOwner ,
156
+ repo : this . repositoryName ,
157
+ ref : commitRef ,
158
+ } ) ) . data ;
158
159
159
160
if ( state === 'failure' ) {
160
- console . error ( red ( ` ✘ Cannot stage release. Commit "${ commitRef } " does not pass all ` +
161
- `github status checks. Please make sure this commit passes all checks before re-running.` ) ) ;
161
+ console . error (
162
+ red ( ` ✘ Cannot stage release. Commit "${ commitRef } " does not pass all github ` +
163
+ `status checks. Please make sure this commit passes all checks before re-running.` ) ) ;
162
164
console . error ( red ( ` Please have a look at: ${ githubCommitsUrl } ` ) ) ;
165
+ if ( await this . promptConfirm ( 'Do you want to ignore the Github status and proceed?' ) ) {
166
+ console . info ( green (
167
+ ` ⚠ Upstream commit is failing CI checks, but status has been ` +
168
+ `forcibly ignored.` ) ) ;
169
+ return ;
170
+ }
163
171
process . exit ( 1 ) ;
164
172
} else if ( state === 'pending' ) {
165
- console . error ( red ( ` ✘ Commit "${ commitRef } " still has pending github statuses that ` +
166
- `need to succeed before staging a release.` ) ) ;
173
+ console . error (
174
+ red ( ` ✘ Commit "${ commitRef } " still has pending github statuses that ` +
175
+ `need to succeed before staging a release.` ) ) ;
167
176
console . error ( red ( ` Please have a look at: ${ githubCommitsUrl } ` ) ) ;
177
+ if ( await this . promptConfirm ( 'Do you want to ignore the Github status and proceed?' ) ) {
178
+ console . info ( green (
179
+ ` ⚠ Upstream commit is pending CI, but status has been ` +
180
+ `forcibly ignored.` ) ) ;
181
+ return ;
182
+ }
168
183
process . exit ( 0 ) ;
169
184
}
170
185
@@ -176,4 +191,3 @@ class StageReleaseTask extends BaseReleaseTask {
176
191
if ( require . main === module ) {
177
192
new StageReleaseTask ( join ( __dirname , '../../' ) , 'angular' , 'components' ) . run ( ) ;
178
193
}
179
-
0 commit comments