Joey Perrott d331e09b71 refactor(dev-infra): create ng-dev executable locally in the repo ()
Rather than running ng-dev via ts-node, going forward ng-dev is generated and run
locally via node.  Additionally, the generated file is tested on each commit to
ensure that the local generated version stays up to date.

PR Close 
2020-10-22 13:36:14 -07:00

57 lines
1.9 KiB
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Arguments, Argv, CommandModule} from 'yargs';
import {getConfig, getRepoBaseDir} from '../../utils/config';
import {error, green, info, red, yellow} from '../../utils/console';
import {addGithubTokenOption} from '../../utils/git/github-yargs';
import {getReleaseConfig} from '../config/index';
import {CompletionState, ReleaseTool} from './index';
/** Command line options for publishing a release. */
export interface ReleasePublishOptions {
githubToken: string;
}
/** Yargs command builder for configuring the `ng-dev release publish` command. */
function builder(argv: Argv): Argv<ReleasePublishOptions> {
return addGithubTokenOption(argv);
}
/** Yargs command handler for staging a release. */
async function handler(args: Arguments<ReleasePublishOptions>) {
const config = getConfig();
const releaseConfig = getReleaseConfig(config);
const projectDir = getRepoBaseDir();
const task = new ReleaseTool(releaseConfig, config.github, args.githubToken, projectDir);
const result = await task.run();
switch (result) {
case CompletionState.FATAL_ERROR:
error(red(`Release action has been aborted due to fatal errors. See above.`));
process.exitCode = 1;
break;
case CompletionState.MANUALLY_ABORTED:
info(yellow(`Release action has been manually aborted.`));
break;
case CompletionState.SUCCESS:
info(green(`Release action has completed successfully.`));
break;
}
}
/** CLI command module for publishing a release. */
export const ReleasePublishCommandModule: CommandModule<{}, ReleasePublishOptions> = {
builder,
handler,
command: 'publish',
describe: 'Publish new releases and configure version branches.',
};