Skip to content

Commit f0c8708

Browse files
authored
drop bootstrap-* generators and add proxy generators (#31555)
1 parent 94c073c commit f0c8708

File tree

34 files changed

+87
-745
lines changed

34 files changed

+87
-745
lines changed

cli/environment-builder.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@
1818
*/
1919
import assert from 'node:assert';
2020
import { existsSync } from 'node:fs';
21-
import path, { resolve } from 'node:path';
21+
import path, { join, resolve } from 'node:path';
2222
import { pathToFileURL } from 'node:url';
2323

2424
import { QueuedAdapter } from '@yeoman/adapter';
2525
import chalk from 'chalk';
2626
import { cloneDeep, mergeWith } from 'lodash-es';
2727
import Environment from 'yeoman-environment';
2828

29+
import BaseGenerator from '../generators/base/index.ts';
2930
import { type Blueprint, mergeBlueprints, parseBlueprintInfo } from '../generators/base/internal/index.ts';
30-
import { getPackageRoot, isDistFolder } from '../lib/index.ts';
31+
import { getPackageRoot, getSourceRoot, isDistFolder } from '../lib/index.ts';
3132
import { createJHipsterLogger, packageNameToNamespace } from '../lib/utils/index.ts';
3233
import { readCurrentPathYoRcFile } from '../lib/utils/yo-rc.ts';
3334

@@ -179,13 +180,43 @@ export default class EnvironmentBuilder {
179180
packagePaths: [getPackageRoot()],
180181
lookups: jhipsterGeneratorsLookup,
181182
});
183+
182184
generators.forEach(generator => {
183185
// Verify jhipster generators namespace.
184186
assert(
185187
generator.namespace.startsWith(`${CLI_NAME}:`),
186188
`Error on the registered namespace ${generator.namespace}, make sure your folder is called generator-jhipster.`,
187189
);
188190
});
191+
192+
// TODO: remove aliases in JHipster 10
193+
for (const [alias, gen] of [
194+
['bootstrap-application', 'app:bootstrap'],
195+
['bootstrap-application-base', 'base-application:bootstrap'],
196+
['bootstrap-application-client', 'client:bootstrap'],
197+
['bootstrap-application-server', 'server:bootstrap'],
198+
['bootstrap-workspaces', 'base-workspaces:bootstrap'],
199+
]) {
200+
this.env.register(
201+
class extends BaseGenerator {
202+
customLifecycle = true;
203+
204+
async beforeQueue() {
205+
if (!this.fromBlueprint) {
206+
await this.composeWithBlueprints();
207+
}
208+
209+
await this.dependsOnJHipster(`jhipster:${gen}`);
210+
}
211+
},
212+
{
213+
namespace: `jhipster:${alias}`,
214+
resolved: join(getSourceRoot(), `generators/${gen.replaceAll(':', '/generators/')}/index.${isDistFolder() ? 'j' : 't'}s`),
215+
packagePath: getPackageRoot(),
216+
},
217+
);
218+
}
219+
189220
return this;
190221
}
191222

generators/app/__snapshots__/generator.spec.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ Options:
2323
--node-package-manager <value> Force an unsupported client package manager
2424
--ignore-errors Don't fail on prettier errors.
2525
--creation-timestamp <value> Project creation timestamp (used for reproducible builds)
26+
--skip-jhipster-dependencies Don't write jhipster dependencies to package.json. (env: JHI_SKIP_JHIPSTER_DEPENDENCIES)
27+
--base-name <value> Application base name
2628
--jdl-store <value> JDL store
2729
--skip-client Skip the client-side application generation
2830
--skip-server Skip the server-side application generation
2931
--skip-user-management Skip the user management module during app generation
3032
--application-type <value> Application type to generate (choices: "monolith", "gateway", "microservice")
31-
--skip-jhipster-dependencies Don't write jhipster dependencies to package.json. (env: JHI_SKIP_JHIPSTER_DEPENDENCIES)
32-
--base-name <value> Application base name
3333
--prettier-tab-width <value> Default tab width for prettier (default: 2)
3434
--monorepository Use monorepository
3535
--skip-commit-hook Skip adding husky commit hooks

generators/app/command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const command = {
7171
import: [
7272
'base',
7373
'bootstrap',
74-
'bootstrap-application-base',
74+
'jhipster:base-application:bootstrap',
7575
'jhipster:jdl:bootstrap',
7676
'common',
7777
'server',

generators/app/generators/bootstrap/generator.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ describe(`generator - ${generator}`, () => {
7171
shouldSupportFeatures(Generator);
7272
// describe('blueprint support', () => testBlueprintSupport(generator, { bootstrapGenerator: true }));
7373

74+
it('bootstrap migration', async () => {
75+
await helpers.runJHipster('jhipster:bootstrap-application').prepareEnvironment().withMockedGenerators(['jhipster:app:bootstrap']);
76+
expect(runResult.getComposedGenerators()).toContain('jhipster:app:bootstrap');
77+
});
78+
7479
describe('with', () => {
7580
describe('default config', () => {
7681
before(async () => {

generators/base-application/generator.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe(`generator - ${generator}`, () => {
6868

6969
class CustomGenerator extends Generator {
7070
async beforeQueue() {
71-
await this.dependsOnJHipster('bootstrap-application');
71+
await this.dependsOnBootstrap('app');
7272
}
7373

7474
get [Generator.INITIALIZING]() {
@@ -313,7 +313,7 @@ describe(`generator - ${generator}`, () => {
313313

314314
class CustomGenerator extends Generator {
315315
async beforeQueue() {
316-
await this.dependsOnJHipster('bootstrap-application');
316+
await this.dependsOnBootstrap('app');
317317
}
318318

319319
get [Generator.INITIALIZING]() {

generators/base-application/generators/bootstrap/generator.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ describe(`generator - ${generator}`, () => {
3030
shouldSupportFeatures(Generator);
3131
// describe('blueprint support', () => testBlueprintSupport(generator, { bootstrapGenerator: true }));
3232

33+
it('bootstrap migration', async () => {
34+
await helpers
35+
.runJHipster('jhipster:bootstrap-application-base')
36+
.prepareEnvironment()
37+
.withMockedGenerators(['jhipster:base-application:bootstrap']);
38+
expect(result.getComposedGenerators()).toContain('jhipster:base-application:bootstrap');
39+
});
40+
3341
describe('with defaults options', () => {
3442
before(async () => {
3543
await helpers.runJHipster(generator).withMockedJHipsterGenerators().withMockedSource().withSharedApplication({}).withJHipsterConfig();

generators/base-simple-application/generator.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe(`generator - ${generator}`, () => {
5959

6060
class CustomGenerator extends Generator {
6161
async beforeQueue() {
62-
await this.dependsOnJHipster('bootstrap-application');
62+
await this.dependsOnBootstrap('app');
6363
}
6464

6565
get [Generator.INITIALIZING]() {
@@ -193,7 +193,7 @@ describe(`generator - ${generator}`, () => {
193193

194194
class CustomGenerator extends Generator {
195195
async beforeQueue() {
196-
await this.dependsOnJHipster('bootstrap-application');
196+
await this.dependsOnBootstrap('app');
197197
}
198198

199199
get [Generator.INITIALIZING]() {

generators/bootstrap-application-base/generator.spec.ts

Lines changed: 0 additions & 175 deletions
This file was deleted.

generators/bootstrap-application-base/generator.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

generators/bootstrap-application-base/index.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)