Skip to content

Commit

Permalink
Merge pull request #26697 from mshima/generate-sample
Browse files Browse the repository at this point in the history
adjusts to generate-sample command
  • Loading branch information
DanielFran authored Jul 11, 2024
2 parents 62aabd8 + 85c713c commit 159f303
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions .blueprint/generate-sample/generator.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extname } from 'path';
import { basename, extname, resolve } from 'path';
import { transform } from '@yeoman/transform';
import BaseGenerator from '../../generators/base/index.js';
import { packageJson } from '../../lib/index.js';
Expand Down Expand Up @@ -31,6 +31,18 @@ export default class extends BaseGenerator {
async promptOptions() {
if (this.global) {
await promptSamplesFolder.call(this);
} else if (!process.env.CI && !this.projectFolder && basename(process.cwd()) !== this.sampleName) {
const answers = await this.prompt([
{
type: 'confirm',
name: 'confirmProjectFolder',
message: `Do you wan't to generate the sample in a folder named ${this.sampleName}?`,
default: true,
},
]);
if (answers.confirmProjectFolder) {
this.projectFolder = resolve(this.sampleName);
}
}
},
});
Expand All @@ -43,7 +55,7 @@ export default class extends BaseGenerator {

await this.composeWithJHipster(GENERATOR_JDL, {
generatorArgs: [this.templatePath('samples', this.sampleName)],
generatorOptions: { projectVersion: this.projectVersion, destinationPath: this.projectFolder },
generatorOptions: { projectVersion: this.projectVersion, destinationRoot: this.projectFolder },
});
},
async generateSample() {
Expand All @@ -62,7 +74,7 @@ export default class extends BaseGenerator {

let generatorOptions = {
projectVersion: this.projectVersion,
destinationPath: this.projectFolder,
destinationRoot: this.projectFolder,
...sample.sample.generatorOptions,
};
if (sample.sample.workspaces && sample.sample.workspaces !== 'false') {
Expand All @@ -77,7 +89,7 @@ export default class extends BaseGenerator {
if (sample.jdlFiles) {
await this.composeWithJHipster(GENERATOR_JDL, {
generatorArgs: sample.jdlFiles,
generatorOptions: { jsonOnly: true, destinationPath: this.projectFolder },
generatorOptions: { jsonOnly: true, destinationRoot: this.projectFolder },
});
}
await this.composeWithJHipster(GENERATOR_APP, { generatorOptions });
Expand All @@ -104,7 +116,7 @@ export default class extends BaseGenerator {
),
);
}
await this.composeWithJHipster(GENERATOR_APP, { generatorOptions: { destinationPath: this.projectFolder } });
await this.composeWithJHipster(GENERATOR_APP, { generatorOptions: { destinationRoot: this.projectFolder } });
},
async updateVscodeWorkspace() {
if (this.global) {
Expand All @@ -116,7 +128,7 @@ export default class extends BaseGenerator {
}
},
async info() {
await this.composeWithJHipster(GENERATOR_INFO, { generatorOptions: { destinationPath: this.projectFolder } });
await this.composeWithJHipster(GENERATOR_INFO, { generatorOptions: { destinationRoot: this.projectFolder } });
},
});
}
Expand Down

0 comments on commit 159f303

Please sign in to comment.