2020-05-15 11:21:01 -04:00
|
|
|
/**
|
|
|
|
* @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} from 'yargs';
|
2020-05-20 17:48:50 -04:00
|
|
|
|
2020-08-28 14:45:01 -04:00
|
|
|
import {addGithubTokenFlag} from '../../utils/yargs';
|
2020-05-20 17:48:50 -04:00
|
|
|
|
2020-08-28 14:45:01 -04:00
|
|
|
import {mergePullRequest} from './index';
|
2020-05-15 11:21:01 -04:00
|
|
|
|
2020-08-14 15:20:55 -04:00
|
|
|
/** The options available to the merge command via CLI. */
|
|
|
|
export interface MergeCommandOptions {
|
2020-08-28 14:45:01 -04:00
|
|
|
githubToken: string;
|
2020-08-14 15:20:55 -04:00
|
|
|
'pr-number': number;
|
|
|
|
}
|
|
|
|
|
2020-05-15 11:21:01 -04:00
|
|
|
/** Builds the options for the merge command. */
|
2020-08-14 15:20:55 -04:00
|
|
|
export function buildMergeCommand(yargs: Argv): Argv<MergeCommandOptions> {
|
2020-08-28 14:45:01 -04:00
|
|
|
return addGithubTokenFlag(yargs).help().strict().positional(
|
|
|
|
'pr-number', {demandOption: true, type: 'number'});
|
2020-05-15 11:21:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Handles the merge command. i.e. performs the merge of a specified pull request. */
|
2020-08-28 14:45:01 -04:00
|
|
|
export async function handleMergeCommand(
|
|
|
|
{'pr-number': pr, githubToken}: Arguments<MergeCommandOptions>) {
|
|
|
|
await mergePullRequest(pr, githubToken);
|
2020-05-15 11:21:01 -04:00
|
|
|
}
|