Skip to content

Commit

Permalink
generate-blueprint: migrate tests to blueprint as array (#27385)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Sep 23, 2024
1 parent 2253efa commit 78c8875
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion generators/base/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,11 @@ export default class JHipsterBaseBlueprintGenerator<TaskTypes extends BaseTaskTy
private async _configureBlueprints() {
let argvBlueprints = this.options.blueprints || '';
// check for old single blueprint declaration
const { blueprint } = this.options;
let { blueprint } = this.options;
if (blueprint) {
if (typeof blueprint === 'string') {
blueprint = [blueprint];
}
this.log.warn('--blueprint option is deprecated. Please use --blueprints instead');
argvBlueprints = union(blueprint, argvBlueprints.split(',')).join(',');
}
Expand Down
9 changes: 9 additions & 0 deletions generators/generate-blueprint/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,15 @@ export default class extends BaseGenerator {

get postWriting() {
return this.asPostWritingTaskGroup({
upgrade() {
if (!this.application[GENERATORS]) return;
if (!this.isJhipsterVersionLessThan('8.7.2')) return;
for (const generator of Object.keys(this.application[GENERATORS])) {
const extension = this.application.js ? 'js' : 'mjs';
const generatorSpec = `${this.application.blueprintsPath}${generator}/generator.spec.${extension}`;
this.editFile(generatorSpec, content => content.replaceAll(/blueprint: '([\w-]*)'/g, "blueprint: ['$1']"));
}
},
packageJson() {
if (this.jhipsterConfig[LOCAL_BLUEPRINT_OPTION]) return;
const { packagejs } = this.application;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('SubGenerator <%= subGenerator %> of <%= application.baseName %> JHipst
.withOptions({
ignoreNeedlesError: true,
<%_ if (!customGenerator) { _%>
blueprint: '<%= application.baseName %>',
blueprint: ['<%= application.baseName %>'],
<%_ } _%>
<%_ if (subGenerator === 'jdl') { _%>
inline: 'application { }',
Expand Down

0 comments on commit 78c8875

Please sign in to comment.