Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git: add --commit-msg option #27363

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cli/jhipster-command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ export default class JHipsterCommand extends Command {
if (optionDefinition.choices && optionDefinition.choices.length > 0) {
option.choices(optionDefinition.choices);
}
if (optionDefinition.implies) {
option.implies(optionDefinition.implies);
}
return this.addOption(option);
}
}
1 change: 1 addition & 0 deletions generators/app/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Options:
--client-root-dir <value> Client root
--skip-git Skip git repository initialization
--force-git Force commit to git repository
--commit-msg <value> Commit changes (implies forceGit)
--cypress-coverage Enable Cypress code coverage report generation
--cypress-audit Enable cypress-audit/lighthouse report generation
--enable-translation Enable translation
Expand Down
10 changes: 10 additions & 0 deletions generators/git/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ const command = {
},
scope: 'generator',
},
commitMsg: {
description: 'Commit changes (implies forceGit)',
cli: {
type: String,
implies: {
forceGit: true,
},
},
scope: 'generator',
},
monorepository: {
description: 'Use monorepository',
cli: {
Expand Down
17 changes: 10 additions & 7 deletions generators/git/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ import { files } from './files.js';
* @extends {BaseGenerator}
*/
export default class GitGenerator extends BaseGenerator {
gitInitialized;
skipGit;
forceGit;
existingRepository;
gitInitialized!: boolean;
skipGit!: boolean;
forceGit!: boolean;
existingRepository!: boolean;
commitMsg!: string;

async beforeQueue() {
if (!this.fromBlueprint) {
Expand Down Expand Up @@ -134,9 +135,11 @@ export default class GitGenerator extends BaseGenerator {
}
}
try {
let commitMsg = existingApplication
? `Regenerated ${this.jhipsterConfig.baseName} using generator-jhipster@${this.jhipsterConfig.jhipsterVersion}`
: `Initial version of ${this.jhipsterConfig.baseName} generated by generator-jhipster@${this.jhipsterConfig.jhipsterVersion}`;
let commitMsg =
this.commitMsg ??
(existingApplication
? `Regenerated ${this.jhipsterConfig.baseName} using generator-jhipster@${this.jhipsterConfig.jhipsterVersion}`
: `Initial version of ${this.jhipsterConfig.baseName} generated by generator-jhipster@${this.jhipsterConfig.jhipsterVersion}`);
if (this.jhipsterConfig.blueprints && this.jhipsterConfig.blueprints.length > 0) {
const bpInfo = this.jhipsterConfig.blueprints.map(bp => `${bp.name}@${bp.version}`).join(', ');
commitMsg += ` with blueprints ${bpInfo}`;
Expand Down
5 changes: 4 additions & 1 deletion generators/init/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ Options:
--skip-install Do not automatically install dependencies (default: false)
--force-install Fail on install dependencies error (default: false)
--ask-answered Show prompts for already configured options (default: false)
--skip-git Skip git repository initialization
--force-git Force commit to git repository
--commit-msg <value> Commit changes (implies forceGit)
--monorepository Use monorepository
--base-name <value> Application base name
--prettier-tab-width <value> Default tab width for prettier
--monorepository Use monorepository
--skip-commit-hook Skip adding husky commit hooks
-h, --help display help for command
"
Expand Down
6 changes: 3 additions & 3 deletions generators/init/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import type { JHipsterCommandDefinition } from '../../lib/command/index.js';
import { GENERATOR_PROJECT_NAME } from '../generator-list.js';

const command: JHipsterCommandDefinition = {
const command = {
options: {},
import: [GENERATOR_PROJECT_NAME, 'jhipster:javascript:prettier', 'jhipster:javascript:husky'],
};
import: ['jhipster:git', GENERATOR_PROJECT_NAME, 'jhipster:javascript:prettier', 'jhipster:javascript:husky'],
} as const satisfies JHipsterCommandDefinition;

export default command;
1 change: 1 addition & 0 deletions generators/jdl/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Options:
--workspaces Generate workspaces for multiples applications
--skip-git Skip git repository initialization
--force-git Force commit to git repository
--commit-msg <value> Commit changes (implies forceGit)
--monorepository Use monorepository
--defaults Execute jhipster with default config
--skip-client Skip the client-side application generation
Expand Down
11 changes: 9 additions & 2 deletions lib/command/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ export type PromptSpec = {

type JHipsterArgumentConfig = SetOptional<ArgumentSpec, 'name'> & { scope?: CommandConfigScope };

type CliSpec = SetOptional<CliOptionSpec, 'name'> & {
env?: string;
/**
* Imply other options.
*/
implies?: Record<string, any>;
};

export type ConfigSpec<ConfigContext> = {
readonly description?: string;
readonly choices?: JHispterChoices;

readonly cli?: SetOptional<CliOptionSpec, 'name'> & { env?: string };
readonly cli?: CliSpec;
readonly argument?: JHipsterArgumentConfig;
readonly prompt?:
| PromptSpec
Expand Down
Loading