| 41 | } |
| 42 | |
| 43 | export class ReleaseTool { |
| 44 | /** The previous git commit to return back to after the release tool runs. */ |
| 45 | private previousGitBranchOrRevision = this._git.getCurrentBranchOrRevision(); |
| 46 | /** The release configuration for the release tool run. */ |
| 47 | protected _config: ReleaseConfig; |
| 48 | |
| 49 | constructor( |
| 50 | protected _git: AuthenticatedGitClient, |
| 51 | config: ReleaseConfig, |
| 52 | protected _github: GithubConfig, |
| 53 | protected _projectRoot: string, |
| 54 | protected _flags: ReleaseToolFlags, |
| 55 | ) { |
| 56 | this._config = { |
| 57 | ...config, |
| 58 | // Replace publishRegistry in the config with one provided via flag, if provided |
| 59 | publishRegistry: _flags.publishRegistry ?? config.publishRegistry, |
| 60 | }; |
| 61 | } |
| 62 | |
| 63 | /** Runs the interactive release tool. */ |
| 64 | async run(): Promise<CompletionState> { |
| 65 | Log.info(); |
| 66 | Log.info(yellow('--------------------------------------------')); |
| 67 | Log.info(yellow(' Angular Dev-Infra release staging script')); |
| 68 | Log.info(yellow('--------------------------------------------')); |
| 69 | Log.info(); |
| 70 | |
| 71 | const {owner, name} = this._github; |
| 72 | const nextBranchName = getNextBranchName(this._github); |
| 73 | |
| 74 | if ( |
| 75 | !(await this._verifyNoUncommittedChanges()) || |
| 76 | !(await this._verifyRunningFromNextBranch(nextBranchName)) || |
| 77 | !(await this._verifyNoShallowRepository()) || |
| 78 | !(await verifyNgDevToolIsUpToDate(this._projectRoot)) || |
| 79 | !(await this._verifyInReleaseMergeMode()) |
| 80 | ) { |
| 81 | return CompletionState.FATAL_ERROR; |
| 82 | } |
| 83 | |
| 84 | if (!(await this._verifyNpmLoginState())) { |
| 85 | return CompletionState.MANUALLY_ABORTED; |
| 86 | } |
| 87 | |
| 88 | // Set the environment variable to skip all git commit hooks triggered by husky. We are unable to |
| 89 | // rely on `--no-verify` as some hooks still run, notably the `prepare-commit-msg` hook. |
| 90 | // Running hooks has the downside of potentially running code (like the `ng-dev` tool) when a version |
| 91 | // branch is checked out, but the node modules are not re-installed. The tool switches branches |
| 92 | // multiple times per execution, and it is not desirable re-running Yarn all the time. |
| 93 | process.env['HUSKY'] = '0'; |
| 94 | |
| 95 | const repo: ReleaseRepoWithApi = {owner, name, api: this._git.github, nextBranchName}; |
| 96 | const releaseTrains = await ActiveReleaseTrains.fetch(repo); |
| 97 | |
| 98 | // Print the active release trains so that the caretaker can access |
| 99 | // the current project branching state without switching context. |
| 100 | await printActiveReleaseTrains(releaseTrains, this._config); |
nothing calls this directly
no test coverage detected