async run()

in ng-dev/release/publish/index.ts [43:99]


  async run(): Promise<CompletionState> {
    log();
    log(yellow('--------------------------------------------'));
    log(yellow('  Angular Dev-Infra release staging script'));
    log(yellow('--------------------------------------------'));
    log();

    const {owner, name} = this._github;
    const nextBranchName = getNextBranchName(this._github);

    if (
      !(await this._verifyNoUncommittedChanges()) ||
      !(await this._verifyRunningFromNextBranch(nextBranchName)) ||
      !(await this._verifyNoShallowRepository()) ||
      !(await verifyNgDevToolIsUpToDate(this._projectRoot))
    ) {
      return CompletionState.FATAL_ERROR;
    }

    if (!(await this._verifyNpmLoginState())) {
      return CompletionState.MANUALLY_ABORTED;
    }

    // Set the environment variable to skip all git commit hooks triggered by husky. We are unable to
    // rely on `--no-verify` as some hooks still run, notably the `prepare-commit-msg` hook.
    // Running hooks has the downside of potentially running code (like the `ng-dev` tool) when a version
    // branch is checked out, but the node modules are not re-installed. The tool switches branches
    // multiple times per execution, and it is not desirable re-running Yarn all the time.
    process.env['HUSKY'] = '0';

    const repo: ReleaseRepoWithApi = {owner, name, api: this._git.github, nextBranchName};
    const releaseTrains = await fetchActiveReleaseTrains(repo);

    // Print the active release trains so that the caretaker can access
    // the current project branching state without switching context.
    await printActiveReleaseTrains(releaseTrains, this._config);

    const action = await this._promptForReleaseAction(releaseTrains);

    try {
      await action.perform();
    } catch (e) {
      if (e instanceof UserAbortedReleaseActionError) {
        return CompletionState.MANUALLY_ABORTED;
      }
      // Only print the error message and stack if the error is not a known fatal release
      // action error (for which we print the error gracefully to the console with colors).
      if (!(e instanceof FatalReleaseActionError) && e instanceof Error) {
        console.error(e);
      }
      return CompletionState.FATAL_ERROR;
    } finally {
      await this.cleanup();
    }

    return CompletionState.SUCCESS;
  }