Skip to content

Commit

Permalink
Merge pull request #27362 from mshima/blueprint-adjusts
Browse files Browse the repository at this point in the history
generate-blueprint adjusts
  • Loading branch information
DanielFran authored Sep 23, 2024
2 parents d8a538d + 3cb194d commit ef9c7c3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
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 @@ -34,6 +34,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 @@ -50,10 +52,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

0 comments on commit ef9c7c3

Please sign in to comment.