fix(dev-infra): remove commit message wizard and builder (#41280)
Removing commit message builder and wizard as they are unused and unneeded. PR Close #41280
This commit is contained in:
parent
e8cae22d66
commit
5eb7f3491f
|
@ -7,7 +7,6 @@ var fs = require('fs');
|
|||
var path = require('path');
|
||||
var chalk = _interopDefault(require('chalk'));
|
||||
require('inquirer');
|
||||
require('inquirer-autocomplete-prompt');
|
||||
var shelljs = require('shelljs');
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
/**
|
||||
* @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 * as config from '../utils/config';
|
||||
import * as console from '../utils/console';
|
||||
|
||||
import {buildCommitMessage} from './builder';
|
||||
|
||||
|
||||
describe('commit message building:', () => {
|
||||
beforeEach(() => {
|
||||
// stub logging calls to prevent noise in test log
|
||||
spyOn(console, 'info').and.stub();
|
||||
// provide a configuration for DevInfra when loaded
|
||||
spyOn(config, 'getConfig').and.returnValue({
|
||||
commitMessage: {
|
||||
scopes: ['core'],
|
||||
}
|
||||
} as any);
|
||||
});
|
||||
|
||||
it('creates a commit message with a scope', async () => {
|
||||
buildPromptResponseSpies('fix', 'core', 'This is a summary');
|
||||
|
||||
expect(await buildCommitMessage()).toMatch(/^fix\(core\): This is a summary/);
|
||||
});
|
||||
|
||||
it('creates a commit message without a scope', async () => {
|
||||
buildPromptResponseSpies('build', false, 'This is a summary');
|
||||
|
||||
expect(await buildCommitMessage()).toMatch(/^build: This is a summary/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/** Create spies to return the mocked selections from prompts. */
|
||||
function buildPromptResponseSpies(type: string, scope: string|false, summary: string) {
|
||||
spyOn(console, 'promptAutocomplete')
|
||||
.and.returnValues(Promise.resolve(type), Promise.resolve(scope));
|
||||
spyOn(console, 'promptInput').and.returnValue(Promise.resolve(summary));
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/**
|
||||
* @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 {ListChoiceOptions} from 'inquirer';
|
||||
|
||||
import {info, promptAutocomplete, promptInput} from '../utils/console';
|
||||
|
||||
import {COMMIT_TYPES, CommitType, getCommitMessageConfig, ScopeRequirement} from './config';
|
||||
|
||||
/** Validate commit message at the provided file path. */
|
||||
export async function buildCommitMessage() {
|
||||
// TODO(josephperrott): Add support for skipping wizard with local untracked config file
|
||||
// TODO(josephperrott): Add default commit message information/commenting into generated messages
|
||||
info('Just a few questions to start building the commit message!');
|
||||
|
||||
/** The commit message type. */
|
||||
const type = await promptForCommitMessageType();
|
||||
/** The commit message scope. */
|
||||
const scope = await promptForCommitMessageScopeForType(type);
|
||||
/** The commit message summary. */
|
||||
const summary = await promptForCommitMessageSummary();
|
||||
|
||||
return `${type.name}${scope ? '(' + scope + ')' : ''}: ${summary}\n\n`;
|
||||
}
|
||||
|
||||
/** Prompts in the terminal for the commit message's type. */
|
||||
async function promptForCommitMessageType(): Promise<CommitType> {
|
||||
info('The type of change in the commit. Allows a reader to know the effect of the change,');
|
||||
info('whether it brings a new feature, adds additional testing, documents the `project, etc.');
|
||||
|
||||
/** List of commit type options for the autocomplete prompt. */
|
||||
const typeOptions: ListChoiceOptions[] =
|
||||
Object.values(COMMIT_TYPES).map(({description, name}) => {
|
||||
return {
|
||||
name: `${name} - ${description}`,
|
||||
value: name,
|
||||
short: name,
|
||||
};
|
||||
});
|
||||
/** The key of a commit message type, selected by the user via prompt. */
|
||||
const typeName = await promptAutocomplete('Select a type for the commit:', typeOptions);
|
||||
|
||||
return COMMIT_TYPES[typeName];
|
||||
}
|
||||
|
||||
/** Prompts in the terminal for the commit message's scope. */
|
||||
async function promptForCommitMessageScopeForType(type: CommitType): Promise<string|false> {
|
||||
// If the commit type's scope requirement is forbidden, return early.
|
||||
if (type.scope === ScopeRequirement.Forbidden) {
|
||||
info(`Skipping scope selection as the '${type.name}' type does not allow scopes`);
|
||||
return false;
|
||||
}
|
||||
/** Commit message configuration */
|
||||
const config = getCommitMessageConfig();
|
||||
|
||||
info('The area of the repository the changes in this commit most affects.');
|
||||
return await promptAutocomplete(
|
||||
'Select a scope for the commit:', config.commitMessage.scopes,
|
||||
type.scope === ScopeRequirement.Optional ? '<no scope>' : '');
|
||||
}
|
||||
|
||||
/** Prompts in the terminal for the commit message's summary. */
|
||||
async function promptForCommitMessageSummary(): Promise<string> {
|
||||
info('Provide a short summary of what the changes in the commit do');
|
||||
return await promptInput('Provide a short summary of the commit');
|
||||
}
|
|
@ -10,14 +10,12 @@ import * as yargs from 'yargs';
|
|||
import {RestoreCommitMessageModule} from './restore-commit-message/cli';
|
||||
import {ValidateFileModule} from './validate-file/cli';
|
||||
import {ValidateRangeModule} from './validate-range/cli';
|
||||
import {WizardModule} from './wizard/cli';
|
||||
|
||||
/** Build the parser for the commit-message commands. */
|
||||
export function buildCommitMessageParser(localYargs: yargs.Argv) {
|
||||
return localYargs.help()
|
||||
.strict()
|
||||
.command(RestoreCommitMessageModule)
|
||||
.command(WizardModule)
|
||||
.command(ValidateFileModule)
|
||||
.command(ValidateRangeModule);
|
||||
}
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/**
|
||||
* @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 {CommitMsgSource} from '../commit-message-source';
|
||||
|
||||
import {runWizard} from './wizard';
|
||||
|
||||
|
||||
export interface WizardOptions {
|
||||
filePath: string;
|
||||
commitSha: string|undefined;
|
||||
source: CommitMsgSource|undefined;
|
||||
}
|
||||
|
||||
/** Builds the command. */
|
||||
function builder(yargs: Argv) {
|
||||
return yargs
|
||||
.positional('filePath', {
|
||||
description: 'The file path to write the generated commit message into',
|
||||
type: 'string',
|
||||
demandOption: true,
|
||||
})
|
||||
.positional('source', {
|
||||
choices: ['message', 'template', 'merge', 'squash', 'commit'] as const,
|
||||
description: 'The source of the commit message as described here: ' +
|
||||
'https://git-scm.com/docs/githooks#_prepare_commit_msg'
|
||||
})
|
||||
.positional('commitSha', {
|
||||
description: 'The commit sha if source is set to `commit`',
|
||||
type: 'string',
|
||||
});
|
||||
}
|
||||
|
||||
/** Handles the command. */
|
||||
async function handler(args: Arguments<WizardOptions>) {
|
||||
await runWizard(args);
|
||||
}
|
||||
|
||||
/** yargs command module describing the command. */
|
||||
export const WizardModule: CommandModule<{}, WizardOptions> = {
|
||||
handler,
|
||||
builder,
|
||||
command: 'wizard <filePath> [source] [commitSha]',
|
||||
// Description: Run the wizard to build a base commit message before opening to complete.
|
||||
// No describe is defiend to hide the command from the --help.
|
||||
describe: false,
|
||||
};
|
|
@ -1,45 +0,0 @@
|
|||
/**
|
||||
* @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 {writeFileSync} from 'fs';
|
||||
|
||||
import {getUserConfig} from '../../utils/config';
|
||||
import {debug, info} from '../../utils/console';
|
||||
|
||||
import {buildCommitMessage} from '../builder';
|
||||
import {CommitMsgSource} from '../commit-message-source';
|
||||
|
||||
|
||||
/** The default commit message used if the wizard does not procude a commit message. */
|
||||
const defaultCommitMessage = `<type>(<scope>): <summary>
|
||||
|
||||
# <Describe the motivation behind this change - explain WHY you are making this change. Wrap all
|
||||
# lines at 100 characters.>\n\n`;
|
||||
|
||||
export async function runWizard(
|
||||
args: {filePath: string, source?: CommitMsgSource, commitSha?: string}) {
|
||||
if (getUserConfig().commitMessage?.disableWizard) {
|
||||
debug('Skipping commit message wizard due to enabled `commitMessage.disableWizard` option in');
|
||||
debug('user config.');
|
||||
process.exitCode = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.source !== undefined) {
|
||||
info(`Skipping commit message wizard because the commit was created via '${
|
||||
args.source}' source`);
|
||||
process.exitCode = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the default commit message to be updated if the user cancels out of the wizard in progress
|
||||
writeFileSync(args.filePath, defaultCommitMessage);
|
||||
|
||||
/** The generated commit message. */
|
||||
const commitMessage = await buildCommitMessage();
|
||||
writeFileSync(args.filePath, commitMessage);
|
||||
}
|
|
@ -8,7 +8,6 @@ var tslib = require('tslib');
|
|||
var chalk = _interopDefault(require('chalk'));
|
||||
var fs = require('fs');
|
||||
var inquirer = require('inquirer');
|
||||
var inquirerAutocomplete = require('inquirer-autocomplete-prompt');
|
||||
var path = require('path');
|
||||
var shelljs = require('shelljs');
|
||||
var url = require('url');
|
||||
|
@ -231,53 +230,6 @@ function promptConfirm(message, defaultValue) {
|
|||
});
|
||||
});
|
||||
}
|
||||
function promptAutocomplete(message, choices, noChoiceText) {
|
||||
return tslib.__awaiter(this, void 0, void 0, function () {
|
||||
var prompt, result;
|
||||
return tslib.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
prompt = inquirer.createPromptModule({}).registerPrompt('autocomplete', inquirerAutocomplete);
|
||||
if (noChoiceText) {
|
||||
choices = tslib.__spreadArray([noChoiceText], tslib.__read(choices));
|
||||
}
|
||||
return [4 /*yield*/, prompt({
|
||||
type: 'autocomplete',
|
||||
name: 'result',
|
||||
message: message,
|
||||
source: function (_, input) {
|
||||
if (!input) {
|
||||
return Promise.resolve(choices);
|
||||
}
|
||||
return Promise.resolve(choices.filter(function (choice) {
|
||||
if (typeof choice === 'string') {
|
||||
return choice.includes(input);
|
||||
}
|
||||
return choice.name.includes(input);
|
||||
}));
|
||||
}
|
||||
})];
|
||||
case 1:
|
||||
result = (_a.sent()).result;
|
||||
if (result === noChoiceText) {
|
||||
return [2 /*return*/, false];
|
||||
}
|
||||
return [2 /*return*/, result];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/** Prompts the user for one line of input. */
|
||||
function promptInput(message) {
|
||||
return tslib.__awaiter(this, void 0, void 0, function () {
|
||||
return tslib.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, inquirer.prompt({ type: 'input', name: 'result', message: message })];
|
||||
case 1: return [2 /*return*/, (_a.sent()).result];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Supported levels for logging functions.
|
||||
*
|
||||
|
@ -2125,135 +2077,11 @@ const ValidateRangeModule = {
|
|||
describe: 'Validate a range of commit messages',
|
||||
};
|
||||
|
||||
/** Validate commit message at the provided file path. */
|
||||
function buildCommitMessage() {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
// TODO(josephperrott): Add support for skipping wizard with local untracked config file
|
||||
// TODO(josephperrott): Add default commit message information/commenting into generated messages
|
||||
info('Just a few questions to start building the commit message!');
|
||||
/** The commit message type. */
|
||||
const type = yield promptForCommitMessageType();
|
||||
/** The commit message scope. */
|
||||
const scope = yield promptForCommitMessageScopeForType(type);
|
||||
/** The commit message summary. */
|
||||
const summary = yield promptForCommitMessageSummary();
|
||||
return `${type.name}${scope ? '(' + scope + ')' : ''}: ${summary}\n\n`;
|
||||
});
|
||||
}
|
||||
/** Prompts in the terminal for the commit message's type. */
|
||||
function promptForCommitMessageType() {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
info('The type of change in the commit. Allows a reader to know the effect of the change,');
|
||||
info('whether it brings a new feature, adds additional testing, documents the `project, etc.');
|
||||
/** List of commit type options for the autocomplete prompt. */
|
||||
const typeOptions = Object.values(COMMIT_TYPES).map(({ description, name }) => {
|
||||
return {
|
||||
name: `${name} - ${description}`,
|
||||
value: name,
|
||||
short: name,
|
||||
};
|
||||
});
|
||||
/** The key of a commit message type, selected by the user via prompt. */
|
||||
const typeName = yield promptAutocomplete('Select a type for the commit:', typeOptions);
|
||||
return COMMIT_TYPES[typeName];
|
||||
});
|
||||
}
|
||||
/** Prompts in the terminal for the commit message's scope. */
|
||||
function promptForCommitMessageScopeForType(type) {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
// If the commit type's scope requirement is forbidden, return early.
|
||||
if (type.scope === ScopeRequirement.Forbidden) {
|
||||
info(`Skipping scope selection as the '${type.name}' type does not allow scopes`);
|
||||
return false;
|
||||
}
|
||||
/** Commit message configuration */
|
||||
const config = getCommitMessageConfig();
|
||||
info('The area of the repository the changes in this commit most affects.');
|
||||
return yield promptAutocomplete('Select a scope for the commit:', config.commitMessage.scopes, type.scope === ScopeRequirement.Optional ? '<no scope>' : '');
|
||||
});
|
||||
}
|
||||
/** Prompts in the terminal for the commit message's summary. */
|
||||
function promptForCommitMessageSummary() {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
info('Provide a short summary of what the changes in the commit do');
|
||||
return yield promptInput('Provide a short summary of the commit');
|
||||
});
|
||||
}
|
||||
|
||||
/** The default commit message used if the wizard does not procude a commit message. */
|
||||
const defaultCommitMessage = `<type>(<scope>): <summary>
|
||||
|
||||
# <Describe the motivation behind this change - explain WHY you are making this change. Wrap all
|
||||
# lines at 100 characters.>\n\n`;
|
||||
function runWizard(args) {
|
||||
var _a;
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
if ((_a = getUserConfig().commitMessage) === null || _a === void 0 ? void 0 : _a.disableWizard) {
|
||||
debug('Skipping commit message wizard due to enabled `commitMessage.disableWizard` option in');
|
||||
debug('user config.');
|
||||
process.exitCode = 0;
|
||||
return;
|
||||
}
|
||||
if (args.source !== undefined) {
|
||||
info(`Skipping commit message wizard because the commit was created via '${args.source}' source`);
|
||||
process.exitCode = 0;
|
||||
return;
|
||||
}
|
||||
// Set the default commit message to be updated if the user cancels out of the wizard in progress
|
||||
fs.writeFileSync(args.filePath, defaultCommitMessage);
|
||||
/** The generated commit message. */
|
||||
const commitMessage = yield buildCommitMessage();
|
||||
fs.writeFileSync(args.filePath, commitMessage);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
/** Builds the command. */
|
||||
function builder$4(yargs) {
|
||||
return yargs
|
||||
.positional('filePath', {
|
||||
description: 'The file path to write the generated commit message into',
|
||||
type: 'string',
|
||||
demandOption: true,
|
||||
})
|
||||
.positional('source', {
|
||||
choices: ['message', 'template', 'merge', 'squash', 'commit'],
|
||||
description: 'The source of the commit message as described here: ' +
|
||||
'https://git-scm.com/docs/githooks#_prepare_commit_msg'
|
||||
})
|
||||
.positional('commitSha', {
|
||||
description: 'The commit sha if source is set to `commit`',
|
||||
type: 'string',
|
||||
});
|
||||
}
|
||||
/** Handles the command. */
|
||||
function handler$4(args) {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
yield runWizard(args);
|
||||
});
|
||||
}
|
||||
/** yargs command module describing the command. */
|
||||
const WizardModule = {
|
||||
handler: handler$4,
|
||||
builder: builder$4,
|
||||
command: 'wizard <filePath> [source] [commitSha]',
|
||||
// Description: Run the wizard to build a base commit message before opening to complete.
|
||||
// No describe is defiend to hide the command from the --help.
|
||||
describe: false,
|
||||
};
|
||||
|
||||
/** Build the parser for the commit-message commands. */
|
||||
function buildCommitMessageParser(localYargs) {
|
||||
return localYargs.help()
|
||||
.strict()
|
||||
.command(RestoreCommitMessageModule)
|
||||
.command(WizardModule)
|
||||
.command(ValidateFileModule)
|
||||
.command(ValidateRangeModule);
|
||||
}
|
||||
|
@ -2935,7 +2763,7 @@ function printTargetBranchesForPr(prNumber) {
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
/** Builds the command. */
|
||||
function builder$5(yargs) {
|
||||
function builder$4(yargs) {
|
||||
return yargs.positional('pr', {
|
||||
description: 'The pull request number',
|
||||
type: 'number',
|
||||
|
@ -2943,15 +2771,15 @@ function builder$5(yargs) {
|
|||
});
|
||||
}
|
||||
/** Handles the command. */
|
||||
function handler$5({ pr }) {
|
||||
function handler$4({ pr }) {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
yield printTargetBranchesForPr(pr);
|
||||
});
|
||||
}
|
||||
/** yargs command module describing the command. */
|
||||
const CheckTargetBranchesModule = {
|
||||
handler: handler$5,
|
||||
builder: builder$5,
|
||||
handler: handler$4,
|
||||
builder: builder$4,
|
||||
command: 'check-target-branches <pr>',
|
||||
describe: 'Check a PR to determine what branches it is currently targeting',
|
||||
};
|
||||
|
@ -3156,11 +2984,11 @@ function checkOutPullRequestLocally(prNumber, githubToken, opts = {}) {
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
/** Builds the checkout pull request command. */
|
||||
function builder$6(yargs) {
|
||||
function builder$5(yargs) {
|
||||
return addGithubTokenOption(yargs).positional('prNumber', { type: 'number', demandOption: true });
|
||||
}
|
||||
/** Handles the checkout pull request command. */
|
||||
function handler$6({ prNumber, githubToken }) {
|
||||
function handler$5({ prNumber, githubToken }) {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
const prCheckoutOptions = { allowIfMaintainerCannotModify: true, branchName: `pr-${prNumber}` };
|
||||
yield checkOutPullRequestLocally(prNumber, githubToken, prCheckoutOptions);
|
||||
|
@ -3168,8 +2996,8 @@ function handler$6({ prNumber, githubToken }) {
|
|||
}
|
||||
/** yargs command module for checking out a PR */
|
||||
const CheckoutCommandModule = {
|
||||
handler: handler$6,
|
||||
builder: builder$6,
|
||||
handler: handler$5,
|
||||
builder: builder$5,
|
||||
command: 'checkout <pr-number>',
|
||||
describe: 'Checkout a PR from the upstream repo',
|
||||
};
|
||||
|
@ -4320,7 +4148,7 @@ function createPullRequestMergeTask(githubToken, flags) {
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
/** Builds the command. */
|
||||
function builder$7(yargs) {
|
||||
function builder$6(yargs) {
|
||||
return addGithubTokenOption(yargs)
|
||||
.help()
|
||||
.strict()
|
||||
|
@ -4336,7 +4164,7 @@ function builder$7(yargs) {
|
|||
});
|
||||
}
|
||||
/** Handles the command. */
|
||||
function handler$7(_a) {
|
||||
function handler$6(_a) {
|
||||
var pr = _a.pr, githubToken = _a.githubToken, branchPrompt = _a.branchPrompt;
|
||||
return tslib.__awaiter(this, void 0, void 0, function () {
|
||||
return tslib.__generator(this, function (_b) {
|
||||
|
@ -4351,8 +4179,8 @@ function handler$7(_a) {
|
|||
}
|
||||
/** yargs command module describing the command. */
|
||||
var MergeCommandModule = {
|
||||
handler: handler$7,
|
||||
builder: builder$7,
|
||||
handler: handler$6,
|
||||
builder: builder$6,
|
||||
command: 'merge <pr>',
|
||||
describe: 'Merge a PR into its targeted branches.',
|
||||
};
|
||||
|
@ -4986,7 +4814,7 @@ function buildReleaseOutput() {
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
/** Yargs command builder for configuring the `ng-dev release build` command. */
|
||||
function builder$8(argv) {
|
||||
function builder$7(argv) {
|
||||
return argv.option('json', {
|
||||
type: 'boolean',
|
||||
description: 'Whether the built packages should be printed to stdout as JSON.',
|
||||
|
@ -4994,7 +4822,7 @@ function builder$8(argv) {
|
|||
});
|
||||
}
|
||||
/** Yargs command handler for building a release. */
|
||||
function handler$8(args) {
|
||||
function handler$7(args) {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
const { npmPackages } = getReleaseConfig();
|
||||
let builtPackages = yield buildReleaseOutput();
|
||||
|
@ -5029,8 +4857,8 @@ function handler$8(args) {
|
|||
}
|
||||
/** CLI command module for building release output. */
|
||||
const ReleaseBuildCommandModule = {
|
||||
builder: builder$8,
|
||||
handler: handler$8,
|
||||
builder: builder$7,
|
||||
handler: handler$7,
|
||||
command: 'build',
|
||||
describe: 'Builds the release output for the current branch.',
|
||||
};
|
||||
|
@ -6629,11 +6457,11 @@ class ReleaseTool {
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
/** Yargs command builder for configuring the `ng-dev release publish` command. */
|
||||
function builder$9(argv) {
|
||||
function builder$8(argv) {
|
||||
return addGithubTokenOption(argv);
|
||||
}
|
||||
/** Yargs command handler for staging a release. */
|
||||
function handler$9(args) {
|
||||
function handler$8(args) {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
const config = getConfig();
|
||||
const releaseConfig = getReleaseConfig(config);
|
||||
|
@ -6657,8 +6485,8 @@ function handler$9(args) {
|
|||
}
|
||||
/** CLI command module for publishing a release. */
|
||||
const ReleasePublishCommandModule = {
|
||||
builder: builder$9,
|
||||
handler: handler$9,
|
||||
builder: builder$8,
|
||||
handler: handler$8,
|
||||
command: 'publish',
|
||||
describe: 'Publish new releases and configure version branches.',
|
||||
};
|
||||
|
@ -6670,7 +6498,7 @@ const ReleasePublishCommandModule = {
|
|||
* 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
|
||||
*/
|
||||
function builder$a(args) {
|
||||
function builder$9(args) {
|
||||
return args
|
||||
.positional('tagName', {
|
||||
type: 'string',
|
||||
|
@ -6684,7 +6512,7 @@ function builder$a(args) {
|
|||
});
|
||||
}
|
||||
/** Yargs command handler for building a release. */
|
||||
function handler$a(args) {
|
||||
function handler$9(args) {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
const { targetVersion: rawVersion, tagName } = args;
|
||||
const { npmPackages, publishRegistry } = getReleaseConfig();
|
||||
|
@ -6716,8 +6544,8 @@ function handler$a(args) {
|
|||
}
|
||||
/** CLI command module for setting an NPM dist tag. */
|
||||
const ReleaseSetDistTagCommand = {
|
||||
builder: builder$a,
|
||||
handler: handler$a,
|
||||
builder: builder$9,
|
||||
handler: handler$9,
|
||||
command: 'set-dist-tag <tag-name> <target-version>',
|
||||
describe: 'Sets a given NPM dist tag for all release packages.',
|
||||
};
|
||||
|
@ -6796,22 +6624,22 @@ function getCurrentGitUser() {
|
|||
* 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
|
||||
*/
|
||||
function builder$b(args) {
|
||||
function builder$a(args) {
|
||||
return args.option('mode', {
|
||||
demandOption: true,
|
||||
description: 'Whether the env-stamp should be built for a snapshot or release',
|
||||
choices: ['snapshot', 'release']
|
||||
});
|
||||
}
|
||||
function handler$b({ mode }) {
|
||||
function handler$a({ mode }) {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
buildEnvStamp(mode);
|
||||
});
|
||||
}
|
||||
/** CLI command module for building the environment stamp. */
|
||||
const BuildEnvStampCommand = {
|
||||
builder: builder$b,
|
||||
handler: handler$b,
|
||||
builder: builder$a,
|
||||
handler: handler$a,
|
||||
command: 'build-env-stamp',
|
||||
describe: 'Build the environment stamping information',
|
||||
};
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
"cli-progress": "<from-root>",
|
||||
"glob": "<from-root>",
|
||||
"inquirer": "<from-root>",
|
||||
"inquirer-autocomplete-prompt": "<from-root>",
|
||||
"minimatch": "<from-root>",
|
||||
"multimatch": "<from-root>",
|
||||
"node-fetch": "<from-root>",
|
||||
|
|
|
@ -21,7 +21,6 @@ ts_library(
|
|||
"@npm//@types/yargs",
|
||||
"@npm//chalk",
|
||||
"@npm//inquirer",
|
||||
"@npm//inquirer-autocomplete-prompt",
|
||||
"@npm//shelljs",
|
||||
"@npm//tslib",
|
||||
"@npm//typed-graphqlify",
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
import chalk from 'chalk';
|
||||
import {writeFileSync} from 'fs';
|
||||
import {createPromptModule, ListChoiceOptions, prompt} from 'inquirer';
|
||||
import * as inquirerAutocomplete from 'inquirer-autocomplete-prompt';
|
||||
import {prompt} from 'inquirer';
|
||||
import {join} from 'path';
|
||||
import {Arguments} from 'yargs';
|
||||
|
||||
|
@ -33,47 +32,6 @@ export async function promptConfirm(message: string, defaultValue = false): Prom
|
|||
.result;
|
||||
}
|
||||
|
||||
/** Prompts the user to select an option from a filterable autocomplete list. */
|
||||
export async function promptAutocomplete(
|
||||
message: string, choices: (string|ListChoiceOptions)[]): Promise<string>;
|
||||
/**
|
||||
* Prompts the user to select an option from a filterable autocomplete list, with an option to
|
||||
* choose no value.
|
||||
*/
|
||||
export async function promptAutocomplete(
|
||||
message: string, choices: (string|ListChoiceOptions)[],
|
||||
noChoiceText?: string): Promise<string|false>;
|
||||
export async function promptAutocomplete(
|
||||
message: string, choices: (string|ListChoiceOptions)[],
|
||||
noChoiceText?: string): Promise<string|false> {
|
||||
// Creates a local prompt module with an autocomplete prompt type.
|
||||
const prompt = createPromptModule({}).registerPrompt('autocomplete', inquirerAutocomplete);
|
||||
if (noChoiceText) {
|
||||
choices = [noChoiceText, ...choices];
|
||||
}
|
||||
// `prompt` must be cast as `any` as the autocomplete typings are not available.
|
||||
const result = (await (prompt as any)({
|
||||
type: 'autocomplete',
|
||||
name: 'result',
|
||||
message,
|
||||
source: (_: any, input: string) => {
|
||||
if (!input) {
|
||||
return Promise.resolve(choices);
|
||||
}
|
||||
return Promise.resolve(choices.filter(choice => {
|
||||
if (typeof choice === 'string') {
|
||||
return choice.includes(input);
|
||||
}
|
||||
return choice.name!.includes(input);
|
||||
}));
|
||||
}
|
||||
})).result;
|
||||
if (result === noChoiceText) {
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Prompts the user for one line of input. */
|
||||
export async function promptInput(message: string): Promise<string> {
|
||||
return (await prompt<{result: string}>({type: 'input', name: 'result', message})).result;
|
||||
|
|
|
@ -185,7 +185,6 @@
|
|||
"gulp-conventional-changelog": "^2.0.35",
|
||||
"husky": "5.0.1",
|
||||
"inquirer": "^7.3.3",
|
||||
"inquirer-autocomplete-prompt": "^1.0.2",
|
||||
"karma-browserstack-launcher": "^1.3.0",
|
||||
"karma-sauce-launcher": "^2.0.2",
|
||||
"madge": "^3.6.0",
|
||||
|
|
17
yarn.lock
17
yarn.lock
|
@ -3108,7 +3108,7 @@ ansi-colors@^3.0.0:
|
|||
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.4.tgz#e3a3da4bfbae6c86a9c285625de124a234026fbf"
|
||||
integrity sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==
|
||||
|
||||
ansi-escapes@^3.0.0, ansi-escapes@^3.1.0, ansi-escapes@^3.2.0:
|
||||
ansi-escapes@^3.1.0, ansi-escapes@^3.2.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b"
|
||||
integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==
|
||||
|
@ -8631,16 +8631,6 @@ ini@^1.3.4:
|
|||
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c"
|
||||
integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==
|
||||
|
||||
inquirer-autocomplete-prompt@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/inquirer-autocomplete-prompt/-/inquirer-autocomplete-prompt-1.0.2.tgz#3f2548f73dd12f0a541be055ea9c8c7aedeb42bf"
|
||||
integrity sha512-vNmAhhrOQwPnUm4B9kz1UB7P98rVF1z8txnjp53r40N0PBCuqoRWqjg3Tl0yz0UkDg7rEUtZ2OZpNc7jnOU9Zw==
|
||||
dependencies:
|
||||
ansi-escapes "^3.0.0"
|
||||
chalk "^2.0.0"
|
||||
figures "^2.0.0"
|
||||
run-async "^2.3.0"
|
||||
|
||||
inquirer@7.3.3, inquirer@^7.3.3:
|
||||
version "7.3.3"
|
||||
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003"
|
||||
|
@ -13628,11 +13618,6 @@ run-async@^2.2.0, run-async@^2.4.0:
|
|||
dependencies:
|
||||
is-promise "^2.1.0"
|
||||
|
||||
run-async@^2.3.0:
|
||||
version "2.4.1"
|
||||
resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455"
|
||||
integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==
|
||||
|
||||
run-parallel@^1.1.9:
|
||||
version "1.1.9"
|
||||
resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679"
|
||||
|
|
Loading…
Reference in New Issue