diff --git a/generators/java/generators/node/__snapshots__/generator.spec.ts.snap b/generators/java/generators/node/__snapshots__/generator.spec.ts.snap new file mode 100644 index 000000000000..73328fe87f1b --- /dev/null +++ b/generators/java/generators/node/__snapshots__/generator.spec.ts.snap @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`generator - java:node with defaults options should call source snapshot 1`] = `{}`; + +exports[`generator - java:node with defaults options should match files snapshot 1`] = ` +{ + ".yo-rc.json": { + "stateCleared": "modified", + }, + "npmw": { + "stateCleared": "modified", + }, + "npmw.cmd": { + "stateCleared": "modified", + }, +} +`; + +exports[`generator - java:node with gradle build tool should call source snapshot 1`] = `{}`; + +exports[`generator - java:node with gradle build tool should match files snapshot 1`] = ` +{ + ".yo-rc.json": { + "stateCleared": "modified", + }, + "build.gradle": { + "stateCleared": "modified", + }, + "npmw": { + "stateCleared": "modified", + }, + "npmw.cmd": { + "stateCleared": "modified", + }, +} +`; diff --git a/generators/java/generators/node/command.ts b/generators/java/generators/node/command.ts new file mode 100644 index 000000000000..7d3ac0741f15 --- /dev/null +++ b/generators/java/generators/node/command.ts @@ -0,0 +1,26 @@ +/** + * Copyright 2013-2024 the original author or authors from the JHipster project. + * + * This file is part of the JHipster project, see https://www.jhipster.tech/ + * for more information. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import type { JHipsterCommandDefinition } from '../../../base/api.js'; + +const command: JHipsterCommandDefinition = { + configs: {}, + import: [], +}; + +export default command; diff --git a/generators/java/generators/node/generator.spec.ts b/generators/java/generators/node/generator.spec.ts new file mode 100644 index 000000000000..3f0278cca9e9 --- /dev/null +++ b/generators/java/generators/node/generator.spec.ts @@ -0,0 +1,81 @@ +/** + * Copyright 2013-2024 the original author or authors from the JHipster project. + * + * This file is part of the JHipster project, see https://www.jhipster.tech/ + * for more information. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { basename, dirname, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { before, it, describe, expect } from 'esmocha'; + +import { shouldSupportFeatures, testBlueprintSupport } from '../../../../test/support/tests.js'; +import { defaultHelpers as helpers, result } from '../../../../testing/index.js'; +import Generator from './index.js'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = `${basename(resolve(__dirname, '../../'))}:${basename(__dirname)}`; + +describe(`generator - ${generator}`, () => { + shouldSupportFeatures(Generator); + describe('blueprint support', () => testBlueprintSupport(generator)); + + describe('with defaults options', () => { + before(async () => { + await helpers.runJHipster(generator).withJHipsterConfig().withMockedJHipsterGenerators().withMockedSource(); + }); + + it('should match files snapshot', () => { + expect(result.getStateSnapshot()).toMatchSnapshot(); + }); + + it('should call source snapshot', () => { + expect(result.sourceCallsArg).toMatchSnapshot(); + }); + + it('should compose with generators', () => { + expect(result.composedMockedGenerators).toMatchInlineSnapshot(` +[ + "jhipster:java:build-tool", + "jhipster:maven:frontend-plugin", +] +`); + }); + }); + + describe('with gradle build tool', () => { + before(async () => { + await helpers.runJHipster(generator).withJHipsterConfig().withMockedJHipsterGenerators().withMockedSource().withGradleBuildTool(); + }); + + it('should match files snapshot', () => { + expect(result.getStateSnapshot()).toMatchSnapshot(); + }); + + it('should call source snapshot', () => { + expect(result.sourceCallsArg).toMatchSnapshot(); + }); + + it('should compose with generators', () => { + expect(result.composedMockedGenerators).toMatchInlineSnapshot(` +[ + "jhipster:gradle:node-gradle", + "jhipster:java:build-tool", +] +`); + }); + }); +}); diff --git a/generators/java/generators/node/generator.ts b/generators/java/generators/node/generator.ts new file mode 100644 index 000000000000..f066356b578b --- /dev/null +++ b/generators/java/generators/node/generator.ts @@ -0,0 +1,107 @@ +/** + * Copyright 2013-2024 the original author or authors from the JHipster project. + * + * This file is part of the JHipster project, see https://www.jhipster.tech/ + * for more information. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import BaseApplicationGenerator from '../../../base-application/index.js'; + +export default class NodeGenerator extends BaseApplicationGenerator { + async beforeQueue() { + if (!this.fromBlueprint) { + await this.composeWithBlueprints(); + } + + if (!this.delegateToBlueprint) { + await this.dependsOnBootstrapApplication(); + await this.dependsOnJHipster('jhipster:java:build-tool'); + } + } + + get initializing() { + return this.asInitializingTaskGroup({ + async parseCommand() { + await this.parseCurrentJHipsterCommand(); + }, + }); + } + + get [BaseApplicationGenerator.INITIALIZING]() { + return this.delegateTasksToBlueprint(() => this.initializing); + } + + get prompting() { + return this.asPromptingTaskGroup({ + async promptCommand({ control }) { + if (control.existingProject && this.options.askAnswered !== true) return; + await this.promptCurrentJHipsterCommand(); + }, + }); + } + + get [BaseApplicationGenerator.PROMPTING]() { + return this.delegateTasksToBlueprint(() => this.prompting); + } + + get composing() { + return this.asComposingTaskGroup({ + async compose() { + const { buildTool } = this.jhipsterConfigWithDefaults; + if (buildTool === 'maven') { + await this.composeWithJHipster('jhipster:maven:frontend-plugin'); + } else if (buildTool === 'gradle') { + await this.composeWithJHipster('jhipster:gradle:node-gradle'); + } + }, + }); + } + + get [BaseApplicationGenerator.COMPOSING]() { + return this.delegateTasksToBlueprint(() => this.composing); + } + + get loading() { + return this.asLoadingTaskGroup({ + async loadConfig({ application }) { + await this.loadCurrentJHipsterCommandConfig(application); + }, + }); + } + + get [BaseApplicationGenerator.LOADING]() { + return this.delegateTasksToBlueprint(() => this.loading); + } + + get writing() { + return this.asWritingTaskGroup({ + async writing({ application }) { + await this.writeFiles({ + blocks: [ + { + condition: (ctx: any) => ctx.useNpmWrapper, + transform: false, + templates: ['npmw', 'npmw.cmd'], + }, + ], + context: application, + }); + }, + }); + } + + get [BaseApplicationGenerator.WRITING]() { + return this.delegateTasksToBlueprint(() => this.writing); + } +} diff --git a/generators/java/generators/node/index.ts b/generators/java/generators/node/index.ts new file mode 100644 index 000000000000..1cfadd692bb6 --- /dev/null +++ b/generators/java/generators/node/index.ts @@ -0,0 +1,20 @@ +/** + * Copyright 2013-2024 the original author or authors from the JHipster project. + * + * This file is part of the JHipster project, see https://www.jhipster.tech/ + * for more information. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export { default } from './generator.js'; +export { default as command } from './command.js'; diff --git a/generators/server/templates/npmw b/generators/java/generators/node/templates/npmw similarity index 100% rename from generators/server/templates/npmw rename to generators/java/generators/node/templates/npmw diff --git a/generators/server/templates/npmw.cmd b/generators/java/generators/node/templates/npmw.cmd similarity index 100% rename from generators/server/templates/npmw.cmd rename to generators/java/generators/node/templates/npmw.cmd diff --git a/generators/maven/generators/frontend-plugin/__snapshots__/generator.spec.ts.snap b/generators/maven/generators/frontend-plugin/__snapshots__/generator.spec.ts.snap new file mode 100644 index 000000000000..c5d974c2d0a8 --- /dev/null +++ b/generators/maven/generators/frontend-plugin/__snapshots__/generator.spec.ts.snap @@ -0,0 +1,224 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`generator - maven:frontend-plugin with defaults options should call source snapshot 1`] = ` +{ + "addMavenDefinition": [ + { + "pluginManagement": [ + { + "additionalContent": " + target + \${node.version} + \${npm.version} +", + "artifactId": "frontend-maven-plugin", + "groupId": "com.github.eirslett", + "version": "\${frontend-maven-plugin.version}", + }, + { + "artifactId": "checksum-maven-plugin", + "groupId": "net.nicoulaj.maven.plugins", + "version": "\${checksum-maven-plugin.version}", + }, + { + "artifactId": "maven-antrun-plugin", + "groupId": "org.apache.maven.plugins", + "version": "\${maven-antrun-plugin.version}", + }, + ], + "plugins": [ + { + "additionalContent": " + + + create-pre-compiled-webapp-checksum + + files + + generate-resources + + + create-compiled-webapp-checksum + + files + + compile + + checksums.csv.old + + + + + + + \${project.basedir} + + src/main/webapp/**/*.* + target/classes/static/**/*.* + package-lock.json + package.json + tsconfig.json + tsconfig.app.json + webpack/*.* + + + **/app/**/service-worker.js + **/app/**/vendor.css + + + + false + false + false + + SHA-1 + + true + true + ", + "artifactId": "checksum-maven-plugin", + "groupId": "net.nicoulaj.maven.plugins", + "inProfile": "webapp", + }, + { + "additionalContent": " + + + eval-frontend-checksum + generate-resources + + run + + + + + + + + + + + + true + + + +", + "artifactId": "maven-antrun-plugin", + "groupId": "org.apache.maven.plugins", + "inProfile": "webapp", + }, + { + "additionalContent": " + + + install-node-and-npm + + install-node-and-npm + + + + npm install + + npm + + + + webapp build dev + + npm + + generate-resources + + run webapp:build + + \${project.version} + + false + + + ", + "artifactId": "frontend-maven-plugin", + "groupId": "com.github.eirslett", + "inProfile": "webapp", + }, + { + "additionalContent": " + + + install-node-and-npm + + install-node-and-npm + + + + npm install + + npm + + + + webapp build test + + npm + + test + + run webapp:test + false + + + + webapp build prod + + npm + + generate-resources + + run webapp:prod + + \${project.version} + + false + + + ", + "artifactId": "frontend-maven-plugin", + "groupId": "com.github.eirslett", + "inProfile": "prod", + }, + ], + "properties": [ + { + "property": "node.version", + "value": "vNODE_VERSION", + }, + { + "property": "npm.version", + "value": "NPM_VERSION", + }, + { + "property": "frontend-maven-plugin.version", + "value": "'FRONTEND-MAVEN-PLUGIN-VERSION'", + }, + { + "property": "checksum-maven-plugin.version", + "value": "'CHECKSUM-MAVEN-PLUGIN-VERSION'", + }, + { + "property": "maven-antrun-plugin.version", + "value": "'MAVEN-ANTRUN-PLUGIN-VERSION'", + }, + ], + }, + ], +} +`; + +exports[`generator - maven:frontend-plugin with defaults options should match files snapshot 1`] = ` +{ + ".yo-rc.json": { + "stateCleared": "modified", + }, +} +`; diff --git a/generators/maven/generators/frontend-plugin/command.ts b/generators/maven/generators/frontend-plugin/command.ts new file mode 100644 index 000000000000..7d3ac0741f15 --- /dev/null +++ b/generators/maven/generators/frontend-plugin/command.ts @@ -0,0 +1,26 @@ +/** + * Copyright 2013-2024 the original author or authors from the JHipster project. + * + * This file is part of the JHipster project, see https://www.jhipster.tech/ + * for more information. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import type { JHipsterCommandDefinition } from '../../../base/api.js'; + +const command: JHipsterCommandDefinition = { + configs: {}, + import: [], +}; + +export default command; diff --git a/generators/maven/generators/frontend-plugin/generator.spec.ts b/generators/maven/generators/frontend-plugin/generator.spec.ts new file mode 100644 index 000000000000..67446df55f0b --- /dev/null +++ b/generators/maven/generators/frontend-plugin/generator.spec.ts @@ -0,0 +1,57 @@ +/** + * Copyright 2013-2024 the original author or authors from the JHipster project. + * + * This file is part of the JHipster project, see https://www.jhipster.tech/ + * for more information. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { basename, dirname, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { before, it, describe, expect } from 'esmocha'; + +import { shouldSupportFeatures, testBlueprintSupport } from '../../../../test/support/tests.js'; +import { defaultHelpers as helpers, result } from '../../../../testing/index.js'; +import Generator from './index.js'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = `${basename(resolve(__dirname, '../../'))}:${basename(__dirname)}`; + +describe(`generator - ${generator}`, () => { + shouldSupportFeatures(Generator); + describe('blueprint support', () => testBlueprintSupport(generator)); + + describe('with defaults options', () => { + before(async () => { + await helpers.runJHipster(generator).withJHipsterConfig().withMockedJHipsterGenerators().withMockedSource(); + }); + + it('should match files snapshot', () => { + expect(result.getStateSnapshot()).toMatchSnapshot(); + }); + + it('should call source snapshot', () => { + expect(result.sourceCallsArg).toMatchSnapshot(); + }); + + it('should compose with generators', () => { + expect(result.composedMockedGenerators).toMatchInlineSnapshot(` +[ + "jhipster:maven", +] +`); + }); + }); +}); diff --git a/generators/maven/generators/frontend-plugin/generator.ts b/generators/maven/generators/frontend-plugin/generator.ts new file mode 100644 index 000000000000..ac5e23a2eb78 --- /dev/null +++ b/generators/maven/generators/frontend-plugin/generator.ts @@ -0,0 +1,313 @@ +/** + * Copyright 2013-2024 the original author or authors from the JHipster project. + * + * This file is part of the JHipster project, see https://www.jhipster.tech/ + * for more information. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import BaseApplicationGenerator from '../../../base-application/index.js'; + +export default class FrontendPluginGenerator extends BaseApplicationGenerator { + async beforeQueue() { + if (!this.fromBlueprint) { + await this.composeWithBlueprints(); + } + + if (!this.delegateToBlueprint) { + await this.dependsOnBootstrapApplication(); + await this.dependsOnJHipster('maven'); + } + } + + get initializing() { + return this.asInitializingTaskGroup({ + async parseCommand() { + await this.parseCurrentJHipsterCommand(); + }, + }); + } + + get [BaseApplicationGenerator.INITIALIZING]() { + return this.delegateTasksToBlueprint(() => this.initializing); + } + + get prompting() { + return this.asPromptingTaskGroup({ + async promptCommand({ control }) { + if (control.existingProject && this.options.askAnswered !== true) return; + await this.promptCurrentJHipsterCommand(); + }, + }); + } + + get [BaseApplicationGenerator.PROMPTING]() { + return this.delegateTasksToBlueprint(() => this.prompting); + } + + get loading() { + return this.asLoadingTaskGroup({ + async loadConfig({ application }) { + await this.loadCurrentJHipsterCommandConfig(application); + }, + }); + } + + get [BaseApplicationGenerator.LOADING]() { + return this.delegateTasksToBlueprint(() => this.loading); + } + + get postWriting() { + return this.asPostWritingTaskGroup({ + customize({ application, source }) { + const { + javaDependencies, + nodeDependencies, + nodeVersion, + clientFrameworkAngular, + clientFrameworkReact, + clientFrameworkVue, + microfrontend, + srcMainWebapp, + } = application; + + const checksumIncludedFiles = [ + `${srcMainWebapp}**/*.*`, + 'target/classes/static/**/*.*', + 'package-lock.json', + 'package.json', + 'tsconfig.json', + ]; + if (clientFrameworkAngular) { + checksumIncludedFiles.push('tsconfig.app.json', 'webpack/*.*'); + } else if (clientFrameworkReact) { + checksumIncludedFiles.push('.postcss.config.js', 'webpack/*.*'); + } else if (clientFrameworkVue) { + checksumIncludedFiles.push('.postcssrc.js', 'tsconfig.app.json'); + if (microfrontend) { + checksumIncludedFiles.push('webpack/*.*'); + } else { + checksumIncludedFiles.push('vite.config.ts'); + } + } + source.addMavenDefinition!({ + properties: [ + { property: 'node.version', value: `v${nodeVersion}` }, + { property: 'npm.version', value: nodeDependencies.npm }, + { + property: 'frontend-maven-plugin.version', + value: javaDependencies!['frontend-maven-plugin'], + }, + { + property: 'checksum-maven-plugin.version', + value: javaDependencies!['checksum-maven-plugin'], + }, + { + property: 'maven-antrun-plugin.version', + value: javaDependencies!['maven-antrun-plugin'], + }, + ], + pluginManagement: [ + { + groupId: 'com.github.eirslett', + artifactId: 'frontend-maven-plugin', + // eslint-disable-next-line no-template-curly-in-string + version: '${frontend-maven-plugin.version}', + additionalContent: ` + target + \${node.version} + \${npm.version} +`, + }, + { + groupId: 'net.nicoulaj.maven.plugins', + artifactId: 'checksum-maven-plugin', + // eslint-disable-next-line no-template-curly-in-string + version: '${checksum-maven-plugin.version}', + }, + { + groupId: 'org.apache.maven.plugins', + artifactId: 'maven-antrun-plugin', + // eslint-disable-next-line no-template-curly-in-string + version: '${maven-antrun-plugin.version}', + }, + ], + plugins: [ + { + inProfile: 'webapp', + groupId: 'net.nicoulaj.maven.plugins', + artifactId: 'checksum-maven-plugin', + additionalContent: ` + + + create-pre-compiled-webapp-checksum + + files + + generate-resources + + + create-compiled-webapp-checksum + + files + + compile + + checksums.csv.old + + + + + + + \${project.basedir} + ${checksumIncludedFiles + .map( + file => ` + ${file}`, + ) + .join('')} + + + **/app/**/service-worker.js + **/app/**/vendor.css + + + + false + false + false + + SHA-1 + + true + true + `, + }, + { + inProfile: 'webapp', + groupId: 'org.apache.maven.plugins', + artifactId: 'maven-antrun-plugin', + additionalContent: ` + + + eval-frontend-checksum + generate-resources + + run + + + + + + + + + + + + true + + + +`, + }, + { + inProfile: 'webapp', + groupId: 'com.github.eirslett', + artifactId: 'frontend-maven-plugin', + additionalContent: ` + + + install-node-and-npm + + install-node-and-npm + + + + npm install + + npm + + + + webapp build dev + + npm + + generate-resources + + run webapp:build + + \${project.version} + + false + + + `, + }, + { + inProfile: 'prod', + groupId: 'com.github.eirslett', + artifactId: 'frontend-maven-plugin', + additionalContent: ` + + + install-node-and-npm + + install-node-and-npm + + + + npm install + + npm + + + + webapp build test + + npm + + test + + run webapp:test + false + + + + webapp build prod + + npm + + generate-resources + + run webapp:prod + + \${project.version} + + false + + + `, + }, + ], + }); + }, + }); + } + + get [BaseApplicationGenerator.POST_WRITING]() { + return this.delegateTasksToBlueprint(() => this.postWriting); + } +} diff --git a/generators/maven/generators/frontend-plugin/index.ts b/generators/maven/generators/frontend-plugin/index.ts new file mode 100644 index 000000000000..1cfadd692bb6 --- /dev/null +++ b/generators/maven/generators/frontend-plugin/index.ts @@ -0,0 +1,20 @@ +/** + * Copyright 2013-2024 the original author or authors from the JHipster project. + * + * This file is part of the JHipster project, see https://www.jhipster.tech/ + * for more information. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export { default } from './generator.js'; +export { default as command } from './command.js'; diff --git a/generators/server/__snapshots__/generator.spec.js.snap b/generators/server/__snapshots__/generator.spec.js.snap index ed5f3296ad22..094754abd209 100644 --- a/generators/server/__snapshots__/generator.spec.js.snap +++ b/generators/server/__snapshots__/generator.spec.js.snap @@ -14,12 +14,6 @@ exports[`generator - server composing databaseType option no with jwt should mat "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -259,12 +253,6 @@ exports[`generator - server composing databaseType option no with oauth2 should "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -507,12 +495,6 @@ exports[`generator - server composing databaseType option no with session should "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, diff --git a/generators/server/__test-support/index.ts b/generators/server/__test-support/index.ts index 0f4b995617ca..31752174a401 100644 --- a/generators/server/__test-support/index.ts +++ b/generators/server/__test-support/index.ts @@ -18,6 +18,7 @@ import { GENERATOR_GRADLE, GENERATOR_DOCKER, GENERATOR_COMMON, + GENERATOR_JAVA, } from '../../generator-list.js'; const { KAFKA, PULSAR } = messageBrokerTypes; @@ -34,9 +35,16 @@ export const mockedGenerators = [ `jhipster:${GENERATOR_GRADLE}:jib`, `jhipster:${GENERATOR_GRADLE}:node-gradle`, `jhipster:${GENERATOR_SPRING_CLOUD_STREAM}`, + // `jhipster:${GENERATOR_JAVA}`, + // `jhipster:${GENERATOR_JAVA}:domain`, + // `jhipster:${GENERATOR_JAVA}:bootstrap`, + `jhipster:${GENERATOR_JAVA}:build-tool`, + `jhipster:${GENERATOR_JAVA}:node`, `jhipster:${GENERATOR_LANGUAGES}`, `jhipster:${GENERATOR_LIQUIBASE}`, `jhipster:${GENERATOR_MAVEN}`, + `jhipster:${GENERATOR_MAVEN}:jib`, + `jhipster:${GENERATOR_MAVEN}:node`, `jhipster:${GENERATOR_SPRING_DATA_CASSANDRA}`, `jhipster:${GENERATOR_SPRING_DATA_MONGODB}`, `jhipster:${GENERATOR_SPRING_DATA_RELATIONAL}`, diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index c91cdfbad27f..d350fb4fee16 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -44,11 +44,6 @@ --> 3.2.5 <%= JAVA_VERSION %> -<%_ if (!skipClient) { _%> - v<%= nodeVersion %> - <%= nodeDependencies.npm %> - -<%_ } _%> UTF-8 UTF-8 yyyyMMddHHmmss @@ -73,16 +68,9 @@ <%- javaDependencies['jackson-databind-nullable'] %> <%_ } _%> <%- javaDependencies.checkstyle %> -<%_ if (!skipClient) { _%> - <%- javaDependencies['checksum-maven-plugin'] %> - <%- javaDependencies['frontend-maven-plugin'] %> -<%_ } _%> <%- javaDependencies['git-commit-id-maven-plugin'] %> <%- javaDependencies['jacoco-maven-plugin'] %> <%- javaDependencies['lifecycle-mapping'] %> -<%_ if (!skipClient) { _%> - <%- javaDependencies['maven-antrun-plugin'] %> -<%_ } _%> <%- javaDependencies['maven-checkstyle-plugin'] %> <%- javaDependencies['maven-clean-plugin'] %> <%- javaDependencies['maven-compiler-plugin'] %> @@ -498,18 +486,6 @@ <%_ } _%> -<%_ if (!skipClient) { _%> - - com.github.eirslett - frontend-maven-plugin - ${frontend-maven-plugin.version} - - target - ${node.version} - ${npm.version} - - -<%_ } _%> org.codehaus.mojo properties-maven-plugin @@ -850,135 +826,6 @@ true - - - - net.nicoulaj.maven.plugins - checksum-maven-plugin - ${checksum-maven-plugin.version} - - - create-pre-compiled-webapp-checksum - - files - - generate-resources - - - create-compiled-webapp-checksum - - files - - compile - - checksums.csv.old - - - - - - - ${project.basedir} - - <%= MAIN_DIR %>webapp/**/*.* - target/classes/static/**/*.* - package-lock.json - package.json - tsconfig.json - <%_ if (clientFrameworkAngular) { _%> - tsconfig.app.json - webpack/*.* - <%_ } _%> - <%_ if (clientFrameworkReact) { _%> - .postcss.config.js - webpack/*.* - <%_ } _%> - <%_ if (clientFrameworkVue) { _%> - tsconfig.app.json - .postcssrc.js - <%_ if (microfrontend) { _%> - webpack/*.* - <%_ } else { _%> - vite.config.ts - <%_ } _%> - <%_ } _%> - - - **/app/**/service-worker.js - **/app/**/vendor.css - - - - false - false - false - - SHA-1 - - true - true - - - - org.apache.maven.plugins - maven-antrun-plugin - ${maven-antrun-plugin.version} - - - eval-frontend-checksum - generate-resources - - run - - - - - - - - - - - - true - - - - - - com.github.eirslett - frontend-maven-plugin - - - install-node-and-npm - - install-node-and-npm - - - - npm install - - npm - - - - webapp build dev - - npm - - generate-resources - - run webapp:build - - ${project.version} - - false - - - - - - dev<%_ if (databaseMigrationLiquibase) { _%>${profile.no-liquibase}<%_ } _%> @@ -1034,51 +881,6 @@ -<%_ if (!skipClient) { _%> - - com.github.eirslett - frontend-maven-plugin - - - install-node-and-npm - - install-node-and-npm - - - - npm install - - npm - - - - webapp build test - - npm - - test - - run webapp:test - false - - - - webapp build prod - - npm - - generate-resources - - run webapp:prod - - ${project.version} - - false - - - - -<%_ } _%> io.github.git-commit-id git-commit-id-maven-plugin diff --git a/generators/spring-boot/__snapshots__/generator.spec.ts.snap b/generators/spring-boot/__snapshots__/generator.spec.ts.snap index a4922f619090..f3ce5b7108a0 100644 --- a/generators/spring-boot/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-boot/__snapshots__/generator.spec.ts.snap @@ -14,12 +14,6 @@ exports[`generator - spring-boot with jwt should match generated files snapshot "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -397,12 +391,6 @@ exports[`generator - spring-boot with oauth2 should match generated files snapsh "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, diff --git a/generators/spring-boot/files.ts b/generators/spring-boot/files.ts index fdfe3127c478..d88d8a5a99a7 100644 --- a/generators/spring-boot/files.ts +++ b/generators/spring-boot/files.ts @@ -312,11 +312,6 @@ export const baseServerFiles = { condition: generator => generator.buildToolMaven, templates: ['pom.xml'], }, - { - condition: generator => generator.useNpmWrapper, - transform: false, - templates: ['npmw', 'npmw.cmd'], - }, ], serverResource: [ { diff --git a/generators/spring-boot/generator.ts b/generators/spring-boot/generator.ts index b2612ba79269..6c2c916e2369 100644 --- a/generators/spring-boot/generator.ts +++ b/generators/spring-boot/generator.ts @@ -188,10 +188,8 @@ export default class SpringBootGenerator extends BaseApplicationGenerator { if (buildTool === 'gradle') { await this.composeWithJHipster('jhipster:gradle:code-quality'); } - if (buildTool === 'gradle') { - if (!skipClient && clientFramework !== 'no') { - await this.composeWithJHipster('jhipster:gradle:node-gradle'); - } + if (!skipClient && clientFramework !== 'no') { + await this.composeWithJHipster('jhipster:java:node'); } if (enableTranslation) { diff --git a/generators/spring-data-cassandra/__snapshots__/generator.spec.ts.snap b/generators/spring-data-cassandra/__snapshots__/generator.spec.ts.snap index 936f5cc8cee4..39a346412692 100644 --- a/generators/spring-data-cassandra/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-cassandra/__snapshots__/generator.spec.ts.snap @@ -38,12 +38,6 @@ exports[`generator - cassandra gateway-jwt-gradle-enableTranslation(true)-com.my "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -1537,12 +1531,6 @@ exports[`generator - cassandra monolith-jwt-reactive(false)-maven-enableTranslat "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2037,12 +2025,6 @@ exports[`generator - cassandra monolith-jwt-reactive(true)-gradle-enableTranslat "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2393,12 +2375,6 @@ exports[`generator - cassandra monolith-oauth2-reactive(false)-maven-enableTrans "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2779,12 +2755,6 @@ exports[`generator - cassandra monolith-oauth2-reactive(true)-gradle-enableTrans "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -3147,12 +3117,6 @@ exports[`generator - cassandra monolith-session-reactive(false)-maven-enableTran "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -3614,12 +3578,6 @@ exports[`generator - cassandra monolith-session-reactive(true)-gradle-enableTran "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, diff --git a/generators/spring-data-couchbase/__snapshots__/generator.spec.ts.snap b/generators/spring-data-couchbase/__snapshots__/generator.spec.ts.snap index c42fef3ad5d4..0a3228ef8370 100644 --- a/generators/spring-data-couchbase/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-couchbase/__snapshots__/generator.spec.ts.snap @@ -38,12 +38,6 @@ exports[`generator - couchbase gateway-jwt-gradle-enableTranslation(true)-com.my "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -1579,12 +1573,6 @@ exports[`generator - couchbase monolith-jwt-reactive(false)-maven-enableTranslat "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2109,12 +2097,6 @@ exports[`generator - couchbase monolith-jwt-reactive(true)-gradle-enableTranslat "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2474,12 +2456,6 @@ exports[`generator - couchbase monolith-oauth2-reactive(false)-maven-enableTrans "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2857,12 +2833,6 @@ exports[`generator - couchbase monolith-oauth2-reactive(true)-gradle-enableTrans "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -3231,12 +3201,6 @@ exports[`generator - couchbase monolith-session-reactive(false)-maven-enableTran "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -3728,12 +3692,6 @@ exports[`generator - couchbase monolith-session-reactive(true)-gradle-enableTran "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, diff --git a/generators/spring-data-elasticsearch/__snapshots__/generator.spec.ts.snap b/generators/spring-data-elasticsearch/__snapshots__/generator.spec.ts.snap index 4b81ebb309c5..cef2fd63f3b4 100644 --- a/generators/spring-data-elasticsearch/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-elasticsearch/__snapshots__/generator.spec.ts.snap @@ -44,12 +44,6 @@ exports[`generator - elasticsearch gateway-jwt-gradle-enableTranslation(true)-co "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -1750,12 +1744,6 @@ exports[`generator - elasticsearch monolith-jwt-reactive(false)-maven-enableTran "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2295,12 +2283,6 @@ exports[`generator - elasticsearch monolith-jwt-reactive(true)-gradle-enableTran "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2705,12 +2687,6 @@ exports[`generator - elasticsearch monolith-oauth2-reactive(false)-maven-enableT "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -3157,12 +3133,6 @@ exports[`generator - elasticsearch monolith-oauth2-reactive(true)-gradle-enableT "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -3606,12 +3576,6 @@ exports[`generator - elasticsearch monolith-session-reactive(false)-maven-enable "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -4157,12 +4121,6 @@ exports[`generator - elasticsearch monolith-session-reactive(true)-gradle-enable "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, diff --git a/generators/spring-data-mongodb/__snapshots__/generator.spec.ts.snap b/generators/spring-data-mongodb/__snapshots__/generator.spec.ts.snap index 45dae13d0a35..aa2b7b45043c 100644 --- a/generators/spring-data-mongodb/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-mongodb/__snapshots__/generator.spec.ts.snap @@ -38,12 +38,6 @@ exports[`generator - mongodb gateway-jwt-gradle-enableTranslation(true)-com.myco "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -1507,12 +1501,6 @@ exports[`generator - mongodb monolith-jwt-reactive(false)-maven-enableTranslatio "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2016,12 +2004,6 @@ exports[`generator - mongodb monolith-jwt-reactive(true)-gradle-enableTranslatio "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2360,12 +2342,6 @@ exports[`generator - mongodb monolith-oauth2-reactive(false)-maven-enableTransla "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2734,12 +2710,6 @@ exports[`generator - mongodb monolith-oauth2-reactive(true)-gradle-enableTransla "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -3087,12 +3057,6 @@ exports[`generator - mongodb monolith-session-reactive(false)-maven-enableTransl "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -3563,12 +3527,6 @@ exports[`generator - mongodb monolith-session-reactive(true)-gradle-enableTransl "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, diff --git a/generators/spring-data-neo4j/__snapshots__/generator.spec.ts.snap b/generators/spring-data-neo4j/__snapshots__/generator.spec.ts.snap index b66f4d01071a..cdf17fe27992 100644 --- a/generators/spring-data-neo4j/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-neo4j/__snapshots__/generator.spec.ts.snap @@ -38,12 +38,6 @@ exports[`generator - neo4j gateway-jwt-gradle-enableTranslation(true)-com.mycomp "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -1504,12 +1498,6 @@ exports[`generator - neo4j monolith-jwt-reactive(false)-maven-enableTranslation( "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2016,12 +2004,6 @@ exports[`generator - neo4j monolith-jwt-reactive(true)-gradle-enableTranslation( "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2357,12 +2339,6 @@ exports[`generator - neo4j monolith-oauth2-reactive(false)-maven-enableTranslati "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -2728,12 +2704,6 @@ exports[`generator - neo4j monolith-oauth2-reactive(true)-gradle-enableTranslati "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -3081,12 +3051,6 @@ exports[`generator - neo4j monolith-session-reactive(false)-maven-enableTranslat "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -3560,12 +3524,6 @@ exports[`generator - neo4j monolith-session-reactive(true)-gradle-enableTranslat "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, diff --git a/generators/spring-data-relational/__snapshots__/generator.spec.ts.snap b/generators/spring-data-relational/__snapshots__/generator.spec.ts.snap index 164e92fa4a28..7859c1afb01e 100644 --- a/generators/spring-data-relational/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-relational/__snapshots__/generator.spec.ts.snap @@ -32,12 +32,6 @@ exports[`generator - sql gateway-jwt-mysql-gradle-enableTranslation(true)-com.my "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -496,12 +490,6 @@ exports[`generator - sql gateway-jwt-oracle-gradle-enableTranslation(true)-com.m "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -960,12 +948,6 @@ exports[`generator - sql gateway-jwt-postgresql-gradle-enableTranslation(true)-c "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -1403,12 +1385,6 @@ exports[`generator - sql gateway-oauth2-mariadb-gradle-enableTranslation(true)-c "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -1795,12 +1771,6 @@ exports[`generator - sql gateway-oauth2-mssql-gradle-enableTranslation(true)-com "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -6093,12 +6063,6 @@ exports[`generator - sql monolith-jwt-mariadb-reactive(false)-maven-enableTransl "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -6536,12 +6500,6 @@ exports[`generator - sql monolith-jwt-mariadb-reactive(true)-gradle-enableTransl "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -6826,12 +6784,6 @@ exports[`generator - sql monolith-jwt-mssql-reactive(false)-maven-enableTranslat "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -7281,12 +7233,6 @@ exports[`generator - sql monolith-jwt-mssql-reactive(true)-gradle-enableTranslat "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -7568,12 +7514,6 @@ exports[`generator - sql monolith-jwt-mysql-reactive(false)-maven-enableTranslat "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -8020,12 +7960,6 @@ exports[`generator - sql monolith-jwt-mysql-reactive(true)-gradle-enableTranslat "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -8298,12 +8232,6 @@ exports[`generator - sql monolith-jwt-oracle-reactive(false)-maven-enableTransla "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -8738,12 +8666,6 @@ exports[`generator - sql monolith-jwt-oracle-reactive(true)-gradle-enableTransla "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -9025,12 +8947,6 @@ exports[`generator - sql monolith-jwt-postgresql-reactive(false)-maven-enableTra "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -9480,12 +9396,6 @@ exports[`generator - sql monolith-jwt-postgresql-reactive(true)-gradle-enableTra "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -9767,12 +9677,6 @@ exports[`generator - sql monolith-oauth2-mariadb-reactive(false)-maven-enableTra "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -10084,12 +9988,6 @@ exports[`generator - sql monolith-oauth2-mariadb-reactive(true)-gradle-enableTra "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -10362,12 +10260,6 @@ exports[`generator - sql monolith-oauth2-mssql-reactive(false)-maven-enableTrans "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -10670,12 +10562,6 @@ exports[`generator - sql monolith-oauth2-mssql-reactive(true)-gradle-enableTrans "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -10960,12 +10846,6 @@ exports[`generator - sql monolith-oauth2-mysql-reactive(false)-maven-enableTrans "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -11280,12 +11160,6 @@ exports[`generator - sql monolith-oauth2-mysql-reactive(true)-gradle-enableTrans "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -11567,12 +11441,6 @@ exports[`generator - sql monolith-oauth2-oracle-reactive(false)-maven-enableTran "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -11881,12 +11749,6 @@ exports[`generator - sql monolith-oauth2-oracle-reactive(true)-gradle-enableTran "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -12156,12 +12018,6 @@ exports[`generator - sql monolith-oauth2-postgresql-reactive(false)-maven-enable "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -12464,12 +12320,6 @@ exports[`generator - sql monolith-oauth2-postgresql-reactive(true)-gradle-enable "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -12754,12 +12604,6 @@ exports[`generator - sql monolith-session-mariadb-reactive(false)-maven-enableTr "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -13173,12 +13017,6 @@ exports[`generator - sql monolith-session-mariadb-reactive(true)-gradle-enableTr "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -13427,12 +13265,6 @@ exports[`generator - sql monolith-session-mssql-reactive(false)-maven-enableTran "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -13846,12 +13678,6 @@ exports[`generator - sql monolith-session-mssql-reactive(true)-gradle-enableTran "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -14100,12 +13926,6 @@ exports[`generator - sql monolith-session-mysql-reactive(false)-maven-enableTran "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -14519,12 +14339,6 @@ exports[`generator - sql monolith-session-mysql-reactive(true)-gradle-enableTran "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -14773,12 +14587,6 @@ exports[`generator - sql monolith-session-oracle-reactive(false)-maven-enableTra "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -15189,12 +14997,6 @@ exports[`generator - sql monolith-session-oracle-reactive(true)-gradle-enableTra "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -15440,12 +15242,6 @@ exports[`generator - sql monolith-session-postgresql-reactive(false)-maven-enabl "checkstyle.xml": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, @@ -15859,12 +15655,6 @@ exports[`generator - sql monolith-session-postgresql-reactive(true)-gradle-enabl "gradle/zipkin.gradle": { "stateCleared": "modified", }, - "npmw": { - "stateCleared": "modified", - }, - "npmw.cmd": { - "stateCleared": "modified", - }, "package.json": { "stateCleared": "modified", }, diff --git a/testing/helpers.ts b/testing/helpers.ts index 84f64656dd0d..f2618f0d6c70 100644 --- a/testing/helpers.ts +++ b/testing/helpers.ts @@ -2,8 +2,10 @@ import type { BaseEnvironmentOptions, GetGeneratorConstructor, BaseGenerator as YeomanGenerator } from '@yeoman/types'; import { YeomanTest, RunContext, RunContextSettings, RunResult, result } from 'yeoman-test'; import { merge, set } from 'lodash-es'; +import { globSync } from 'glob'; -import { basename, join } from 'path'; +import { basename, dirname, join } from 'path'; +import { fileURLToPath } from 'url'; import EnvironmentBuilder from '../cli/environment-builder.mjs'; import { JHIPSTER_CONFIG_DIR } from '../generators/generator-constants.js'; import { GENERATOR_WORKSPACES } from '../generators/generator-list.js'; @@ -22,6 +24,11 @@ type JHipsterRunResult * First argument of mocked source calls. */ sourceCallsArg: Record; + + /** + * Composed generators that were mocked. + */ + composedMockedGenerators: string[]; }; const runResult = result as JHipsterRunResult; @@ -32,6 +39,17 @@ const DEFAULT_TEST_SETTINGS = { forwardCwd: true }; const DEFAULT_TEST_OPTIONS = { skipInstall: true }; const DEFAULT_TEST_ENV_OPTIONS = { skipInstall: true, dryRun: false }; +const generatorsDir = join(fileURLToPath(import.meta.url), '../../generators'); +const mockedGenerators = [ + ...globSync('*/index.{j,t}s', { cwd: generatorsDir, posix: true }).map(file => dirname(file)), + ...globSync('*/generators/*/index.{j,t}s', { cwd: generatorsDir, posix: true }).map(file => dirname(file).replace('/generators/', ':')), +] + .filter(gen => !gen.startsWith('bootstrap-')) + .map(gen => `jhipster:${gen}`) + .sort(); + +const defaultSharedApplication = Object.fromEntries(['CLIENT_WEBPACK_DIR'].map(key => [key, undefined])); + let defaultMockFactory; export const defineDefaults = async ({ mockFactory }: { mockFactory?: any } = {}) => { @@ -214,11 +232,15 @@ class JHipsterRunContext extends RunContext { } withSharedApplication(sharedApplication: Record): this { - this.sharedApplication = this.sharedApplication ?? {}; + this.sharedApplication = this.sharedApplication ?? { ...defaultSharedApplication }; merge(this.sharedApplication, sharedApplication); return this.withSharedData({ sharedApplication: this.sharedApplication }); } + withMockedJHipsterGenerators(exceptList: string[] = []): this { + return this.withMockedGenerators(mockedGenerators.filter(gen => !exceptList.includes(gen) && (this as any).Generator !== gen)); + } + withGradleBuildTool(): this { return this.withFiles({ 'build.gradle': ` @@ -246,7 +268,7 @@ plugins { } async run(): Promise> { - const runResult = await super.run(); + const runResult = (await super.run()) as unknown as JHipsterRunResult; if (this.sharedSource) { const sourceCallsArg = Object.fromEntries( Object.entries(this.sharedSource).map(([name, fn]) => [name, fn.mock.calls.map(args => args[0])]), @@ -263,10 +285,14 @@ plugins { relationships: relationships.map(rel => `Relationship[${rel.relationshipName}]`), })); } - const jhipsterRunResult = runResult as unknown as JHipsterRunResult; - jhipsterRunResult.sourceCallsArg = sourceCallsArg; + runResult.sourceCallsArg = sourceCallsArg; } - return runResult; + + runResult.composedMockedGenerators = mockedGenerators.filter( + gen => runResult.mockedGenerators[gen]?.called && !['jhipster:bootstrap', 'jhipster:project-name'].includes(gen), + ); + + return runResult as any; } }