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

generate-blueprint adjusts #27362

Merged
merged 4 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
2 changes: 1 addition & 1 deletion generators/base-core/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`;
}

const override = resolveCallback(fileSpec.override);
if (override !== undefined && !override && (this as any).fs.exists(destinationFile)) {
if (override !== undefined && !override && (this as any).fs.exists(destinationFile.replace(/\.jhi$/, ''))) {
this.log.debug(`skipping file ${destinationFile}`);
return undefined;
}
Expand Down
6 changes: 2 additions & 4 deletions generators/generate-blueprint/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export const files = asWriteFilesSection<any>({
'.blueprint/generate-sample/command.mjs',
'.blueprint/generate-sample/generator.mjs',
'.blueprint/generate-sample/index.mjs',
// Always write cli for devBlueprint usage
'cli/cli.cjs',
],
},
{
Expand All @@ -51,10 +53,6 @@ export const files = asWriteFilesSection<any>({
condition: ctx => !ctx[LOCAL_BLUEPRINT_OPTION] && !ctx.sampleWritten,
templates: ['.blueprint/generate-sample/templates/samples/sample.jdl'],
},
{
condition: ctx => ctx.cli,
templates: ['cli/cli.cjs'],
},
{
condition: ctx => ctx.commands.length > 0,
templates: ['cli/commands.cjs'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
module.exports = {
<% for (const command of commands) { %>
'<%= command %>': {
description: 'Run <%= command %> sub-generator (<%= baseName %> blueprint)',
desc: 'Run <%= command %> sub-generator (<%= baseName %> blueprint)',
blueprint: 'generator-jhipster-<%= baseName %>',
},
<% } %>
Expand Down
10 changes: 8 additions & 2 deletions lib/testing/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,21 @@ class JHipsterRunContext extends RunContext<GeneratorTestType> {
}

withJHipsterLookup(): this {
return this.withLookups([{ packagePaths: [getPackageRoot()], lookups: [`${isDistFolder() ? 'dist/' : ''}generators`] }] as any);
return this.withLookups([
{
packagePaths: [getPackageRoot()],
// @ts-expect-error lookups is not exported
lookups: [`${isDistFolder() ? 'dist/' : ''}generators`, `${isDistFolder() ? 'dist/' : ''}generators/*/generators`],
},
]);
}

/**
* Lookup generators at generator-jhipster's parent at a npm repository
* @param lookups generators relative folder
* @returns
*/
withParentBlueprintLookup(lookups = ['generators']): this {
withParentBlueprintLookup(lookups = ['generators', 'generators/*/generators']): this {
const packageRootParent = join(getPackageRoot(), '..');
if (basename(packageRootParent) === 'node_modules') {
this.withLookups([{ packagePaths: [join(packageRootParent, '..')], lookups }] as any);
Expand Down
Loading