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
|
|
|
|
*/
|
|
|
|
|
2021-01-22 17:05:28 -05:00
|
|
|
import {Arguments, Argv, CommandModule} from 'yargs';
|
2020-05-20 17:48:50 -04:00
|
|
|
|
2020-09-01 04:39:35 -04:00
|
|
|
import {addGithubTokenOption} from '../../utils/git/github-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;
|
2021-01-22 17:05:28 -05:00
|
|
|
pr: number;
|
|
|
|
branchPrompt: boolean;
|
2020-08-14 15:20:55 -04:00
|
|
|
}
|
|
|
|
|
2021-01-22 17:05:28 -05:00
|
|
|
/** Builds the command. */
|
|
|
|
function builder(yargs: Argv) {
|
|
|
|
return addGithubTokenOption(yargs)
|
|
|
|
.help()
|
|
|
|
.strict()
|
|
|
|
.positional('pr', {
|
|
|
|
demandOption: true,
|
|
|
|
type: 'number',
|
|
|
|
description: 'The PR to be merged.',
|
|
|
|
})
|
|
|
|
.option('branch-prompt' as 'branchPrompt', {
|
|
|
|
type: 'boolean',
|
|
|
|
default: true,
|
|
|
|
description: 'Whether to prompt to confirm the branches a PR will merge into.',
|
|
|
|
});
|
2020-05-15 11:21:01 -04:00
|
|
|
}
|
|
|
|
|
2021-01-22 17:05:28 -05:00
|
|
|
/** Handles the command. */
|
|
|
|
async function handler({pr, githubToken, branchPrompt}: Arguments<MergeCommandOptions>) {
|
|
|
|
await mergePullRequest(pr, githubToken, {branchPrompt});
|
2020-05-15 11:21:01 -04:00
|
|
|
}
|
2021-01-22 17:05:28 -05:00
|
|
|
|
|
|
|
/** yargs command module describing the command. */
|
|
|
|
export const MergeCommandModule: CommandModule<{}, MergeCommandOptions> = {
|
|
|
|
handler,
|
|
|
|
builder,
|
|
|
|
command: 'merge <pr>',
|
|
|
|
describe: 'Merge a PR into its targeted branches.',
|
|
|
|
};
|