mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
Misko Hevery
parent
e8cae22d66
commit
5eb7f3491f
+28
-200
@@ -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',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user