Skip to content
Open
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
1 change: 0 additions & 1 deletion generators/base-application/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ export type Application<E extends Entity> = BaseSimpleApplicationApplication &

skipClient?: boolean;
skipServer?: boolean;
monorepository?: boolean;

blueprints?: { name: string; version: string }[];
testFrameworks?: string[];
Expand Down
1 change: 0 additions & 1 deletion generators/base-core/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export type Options = YeomanOptions & {
generateApplications?: boolean | (() => Promise<void>);
generateWorkspaces?: boolean;
generateWith?: string;
monorepository?: boolean;
workspaces?: boolean;
workspacesFolders?: string[];
};
Expand Down
26 changes: 9 additions & 17 deletions generators/git/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ import type { Config as GitConfig, Options as GitOptions } from './types.js';

export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> {
gitInitialized!: boolean;
skipGit!: boolean;
forceGit!: boolean;
existingRepository!: boolean;
commitMsg!: string;

async beforeQueue() {
if (!this.fromBlueprint) {
Expand All @@ -40,19 +37,14 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> {
get initializing() {
return this.asInitializingTaskGroup({
async checkGit() {
if (!this.skipGit) {
if (!this.options.skipGit) {
const gitInstalled = (await this.createGit().version()).installed;
if (!gitInstalled) {
this.log.warn('Git repository will not be created, as Git is not installed on your system');
this.skipGit = true;
this.gitInitialized = false;
}
}
},
async initializeMonorepository() {
if (!this.skipGit && this.jhipsterConfig.monorepository) {
await this.initializeGitRepository();
}
},
Comment on lines -51 to -55
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Monorepository is very hard to handle.
This looks to be wrong.

Monorepository is initialized before composing with applications generators, so generators will detect they are inside a monorepository.

Copy link
Contributor Author

@Tcharl Tcharl Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen that, but is there a need to have git repo initialized twice?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, initializeGitRepository will not be executed later in this case.

});
}

Expand All @@ -63,7 +55,7 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> {
get preparing() {
return this.asPreparingTaskGroup({
async preparing() {
if (!this.skipGit) {
if (!this.options.skipGit) {
// Force write .yo-rc.json to disk, it's used to check if the application is regenerated
this.jhipsterConfig.monorepository ??= undefined;
}
Expand Down Expand Up @@ -91,7 +83,7 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> {
return this.asPostWritingTaskGroup({
/** Husky commit hook install at install priority requires git to be initialized */
async initGitRepo() {
if (!this.skipGit && !this.jhipsterConfig.monorepository) {
if (!this.options.skipGit && !this.jhipsterConfig.monorepository) {
await this.initializeGitRepository();
}
},
Expand All @@ -106,25 +98,25 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> {
return this.asEndTaskGroup({
/** Initial commit to git repository after package manager install for package-lock.json */
async gitCommit() {
if (this.skipGit) return;
if (this.options.skipGit) return;
if (!this.gitInitialized) {
this.log.warn('The generated application could not be committed to Git, as a Git repository could not be initialized.');
return;
}

const commitFiles = async () => {
this.debug('Committing files to git');
this.log.debug('Committing files to git');
const git = this.createGit();
const repositoryRoot = await git.revparse(['--show-toplevel']);
const result = await git.log(['-n', '1', '--', '.yo-rc.json']).catch(() => ({ total: 0 }));
const existingApplication = result.total > 0;
if (existingApplication && !this.forceGit) {
if (existingApplication && !this.options.forceGit) {
this.log.info(
`Found .yo-rc.json in Git from ${repositoryRoot}. So we assume this is application regeneration. Therefore automatic Git commit is not done. You can do Git commit manually.`,
);
return;
}
if (!this.forceGit) {
if (!this.options.forceGit) {
const statusResult = await git.status();
if (statusResult.staged.length > 0) {
this.log.verboseInfo(`The repository ${repositoryRoot} has staged files, skipping commit.`);
Expand All @@ -133,7 +125,7 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> {
}
try {
let commitMsg =
this.commitMsg ??
this.options.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}`);
Expand Down
13 changes: 10 additions & 3 deletions generators/git/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { HandleCommandTypes } from '../../lib/command/types.js';
import type { Simplify } from 'type-fest';
import type { ExportGeneratorOptionsFromCommand, ExportStoragePropertiesFromCommand, HandleCommandTypes } from '../../lib/command/types.js';
import type { Config as ProjectNameConfig, Options as ProjectNameOptions, Source as ProjectNameSource } from '../project-name/types.js';
import type { Application as BaseApplicationApplication, Entity as BaseApplicationEntity } from '../base-application/types.js';
import type command from './command.ts';

type Command = HandleCommandTypes<typeof command>;

export type Config = Command['Config'] & ProjectNameConfig;
export type Config = Command['Config'] &
ProjectNameConfig &
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
Simplify<ExportStoragePropertiesFromCommand<typeof import('./command.ts').default>>;

export type Options = Command['Options'] & ProjectNameOptions;
export type Options = Command['Options'] &
ProjectNameOptions &
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
Simplify<ExportGeneratorOptionsFromCommand<typeof import('./command.ts').default>>;

export { ProjectNameSource as Source, BaseApplicationEntity as Entity };

Expand Down
3 changes: 2 additions & 1 deletion generators/jdl/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { HandleCommandTypes } from '../../lib/command/types.js';
import type { ApplicationType } from '../../lib/core/application-types.ts';
import type { Config as BaseConfig, Options as BaseOptions } from '../base/types.js';
import type { Options as WorkspaceOptions } from '../workspaces/types.js';
import type command from './command.js';

type Command = HandleCommandTypes<typeof command>;
Expand All @@ -13,4 +14,4 @@ type JdlOptions = {

export type Config = BaseConfig & JdlOptions & Command['Config'];

export type Options = BaseOptions & JdlOptions & Command['Options'];
export type Options = BaseOptions & JdlOptions & Command['Options'] & WorkspaceOptions;
4 changes: 2 additions & 2 deletions generators/workspaces/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator<any, Wo
return this.asInitializingTaskGroup({
loadConfig() {
// Generate workspaces file if workspace option is passed, or if workspace option is ommitted and monorepository is enabled, or if regenerating.
this.generateWorkspaces = (this.workspaces ?? this.jhipsterConfig.monorepository) || Boolean(this.packageJson?.get('workspaces'));
this.generateWorkspaces = (this.workspaces ?? this.options.monorepository) || Boolean(this.packageJson?.get('workspaces'));

// When generating workspaces, save to .yo-rc.json. Use a dummy config otherwise.
this.workspacesConfig = this.generateWorkspaces ? this.jhipsterConfig : {};
Expand Down Expand Up @@ -122,7 +122,7 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator<any, Wo
get loading() {
return this.asLoadingTaskGroup({
checkWorkspaces() {
if (this.generateWorkspaces && !this.jhipsterConfig.monorepository) {
if (this.generateWorkspaces && !this.options.monorepository) {
throw new Error('Workspaces option is only supported with monorepositories.');
}
},
Expand Down
6 changes: 4 additions & 2 deletions generators/workspaces/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { Simplify } from 'type-fest';
import type { Config as BaseWorkspacesConfig, Options as BaseWorkspacesOptions } from '../base-workspaces/types.d.ts';
import type { Config as GitConfig, Options as GitOptions } from '../git/types.d.ts';
export type { WorkspacesApplication } from '../base-workspaces/types.js';

export type Config = BaseWorkspacesConfig & { baseName: string; monorepository: boolean };
export type Options = BaseWorkspacesOptions & { monorepository: boolean };
export type Config = BaseWorkspacesConfig & { baseName: string } & Simplify<GitConfig>;
export type Options = BaseWorkspacesOptions & GitOptions;
1 change: 0 additions & 1 deletion lib/types/application-config-all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export type ConfigAll = Simplify<
microfrontends?: { baseName: string }[];
} & ExportStoragePropertiesFromCommand<typeof import('../../generators/app/command.ts').default> &
ExportStoragePropertiesFromCommand<typeof import('../../generators/bootstrap-application-base/command.ts').default> &
ExportStoragePropertiesFromCommand<typeof import('../../generators/git/command.ts').default> &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to remove git from configAll

Copy link
Contributor Author

@Tcharl Tcharl Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not used anymore in other generators than git (has been move to git options) (considered as resolved: better being part of workspaceoptions) : played with inheritance to have workspaceoptions & config in the inheritance chain

Copy link
Member

@mshima mshima Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All config/properties/application is only used by BaseApplicationGeneratorAll and testing helpers.
helpers.run().withJHipsterConfig() should use ConfigAll.

ExportStoragePropertiesFromCommand<typeof import('../../generators/jdl/command.ts').default> &
ExportStoragePropertiesFromCommand<typeof import('../../generators/languages/command.ts').default> &
ExportStoragePropertiesFromCommand<typeof import('../../generators/liquibase/command.ts').default> &
Expand Down
1 change: 0 additions & 1 deletion lib/types/application-options-all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type OptionsAll = Simplify<
ExportGeneratorOptionsFromCommand<typeof import('../../generators/base/command.ts').default> &
ExportGeneratorOptionsFromCommand<typeof import('../../generators/bootstrap-application-base/command.ts').default> &
ExportGeneratorOptionsFromCommand<typeof import('../../generators/client/command.ts').default> &
ExportGeneratorOptionsFromCommand<typeof import('../../generators/git/command.ts').default> &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to remove git from optionsAll

Copy link
Contributor Author

@Tcharl Tcharl Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not used anymore in other generators than git (has been move) (considered as resolved: better being part of workspaceoptions)

ExportGeneratorOptionsFromCommand<typeof import('../../generators/java/generators/bootstrap/command.ts').default> &
ExportGeneratorOptionsFromCommand<typeof import('../../generators/java/generators/build-tool/command.ts').default> &
ExportGeneratorOptionsFromCommand<typeof import('../../generators/java/generators/graalvm/command.ts').default> &
Expand Down
1 change: 0 additions & 1 deletion lib/types/application-properties-all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ export type ApplicationAll<E extends EntityAll = EntityAll> = BaseApplication<E>
ClientApplication<E> &
DockerApplication &
LiqbuibaseApplication<E> &
ExportApplicationPropertiesFromCommand<typeof import('../../generators/git/command.ts').default> &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to remove git from propertiesAll

Copy link
Contributor Author

@Tcharl Tcharl Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not used anymore in other generators than git (has been move) (considered as resolved: better being part of workspaceoptions)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All config/properties/application is only used by BaseApplicationGeneratorAll and testing helpers.
helpers.run().withJHipsterConfig() should use ConfigAll.

ExportApplicationPropertiesFromCommand<typeof import('../../generators/project-name/command.ts').default> &
ExportApplicationPropertiesFromCommand<typeof import('../../generators/spring-boot/command.ts').default>;