MCPcopy Create free account
hub / github.com/angular/dev-infra / run

Method run

ng-dev/release/publish/index.ts:64–125  ·  view source on GitHub ↗

Runs the interactive release tool.

()

Source from the content-addressed store, hash-verified

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);
101
102 const action = await this._promptForReleaseAction(releaseTrains);
103
104 try {
105 await action.perform();
106 } catch (e) {
107 if (e instanceof StageOnlySuccessError) {
108 Log.info(green(`✓ Staging completed successfully. PR URL: ${e.pullRequest.url}`));
109 return CompletionState.SUCCESS;
110 }
111 if (e instanceof UserAbortedReleaseActionError) {
112 return CompletionState.MANUALLY_ABORTED;
113 }
114 // Only print the error message and stack if the error is not a known fatal release
115 // action error (for which we print the error gracefully to the console with colors).
116 if (!(e instanceof FatalReleaseActionError) && e instanceof Error) {
117 console.error(e);
118 }
119 return CompletionState.FATAL_ERROR;
120 } finally {
121 await this.cleanup();

Callers 11

handlerFunction · 0.95
pushHeadToRemoteBranchFunction · 0.45
_pushHeadToForkFunction · 0.45
checkoutUpstreamBranchFunction · 0.45
createCommitFunction · 0.45

Calls 13

_verifyNpmLoginStateMethod · 0.95
cleanupMethod · 0.95
getNextBranchNameFunction · 0.85
printActiveReleaseTrainsFunction · 0.85
fetchMethod · 0.80
performMethod · 0.45

Tested by

no test coverage detected