From 35a60a13abde65a2095529c786c9baf8a8b19bf7 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 1 Sep 2023 09:40:41 -0300 Subject: [PATCH 01/27] drop unused docker-cli --- generators/base-docker/docker-cli.mjs | 148 -------------------------- 1 file changed, 148 deletions(-) delete mode 100644 generators/base-docker/docker-cli.mjs diff --git a/generators/base-docker/docker-cli.mjs b/generators/base-docker/docker-cli.mjs deleted file mode 100644 index 1a37f6c30525..000000000000 --- a/generators/base-docker/docker-cli.mjs +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Copyright 2013-2023 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 { exec } from 'child_process'; -import _ from 'lodash'; - -/** - * This is the DockerCli object. it allows Yeoman to interact with Docker via Docker CLI. - * NB: It is vital that these functions are bound to the generator context. - */ -export default { - setOutputs, - command, - getImageID, - tagImage, - loginToAws, - pushImage, -}; - -let stdOut = data => console.log(data.toString().trim()); // eslint-disable-line -let stdErr = data => console.error(data.toString().trim()); // eslint-disable-line -export function setOutputs(stdout, stderr) { - stdOut = stdout; - stdErr = stderr; -} - -/** - * Execute the shell command given as a parameter and execute the callback at the end. Callback has profile: - * `function(err, stdout, stderr)` - * @param cmd the command to execute - * @param cb the callback that will be called after the function is executed. - * @param opts additional options - * @attr silent flag to deactivate the live stderr and stdout. Default to false - * @attr maxBuffer value of the buffer to store the live outputs. Default to 10240000 - */ -export function command(cmd, cb, opts = {}) { - const options = { - silent: false, - maxBuffer: 10240000, - ...opts, - }; - const command = exec(`${cmd}`, { maxBuffer: options.maxBuffer }, cb); - - if (!options.silent) { - command.stdout.on('data', stdOut); - command.stderr.on('data', stdErr); - } -} - -/** - * - * @param imageName the image name - * @param tag the image tag (optional) - * @returns {Promise} returns the image ID on success, an error message on failure (exception or noId). - */ -export function getImageID(imageName, tag) { - const dockerNameTag = `${imageName}${_.isNil(tag) ? '' : `:${tag}`}`; - const commandLine = `docker image ls --quiet ${dockerNameTag}`; - - return new Promise((resolve, reject) => - command( - commandLine, - (err, stdout) => { - if (err) { - reject(err); - } - const dockerID = _.trim(stdout); - if (_.isEmpty(dockerID)) { - reject(new Error(`No Docker ID found for ${dockerNameTag}`)); - } else { - resolve(dockerID); - } - }, - { silent: true }, - ), - ); -} - -export function tagImage(from, to) { - const commandLine = `docker tag ${from} ${to}`; - - return new Promise((resolve, reject) => - command( - commandLine, - (err, stdout) => { - if (err) { - reject(err); - } - resolve(stdout); - }, - { silent: true }, - ), - ); -} - -/** - * Log docker to AWS. - * @param region - * @param accountId - * @param username - * @param password - * @returns {Promise} - */ -export function loginToAws(region, accountId, username, password) { - const commandLine = `docker login --username AWS --password ${password} https://${accountId}.dkr.ecr.${region}.amazonaws.com`; - return new Promise( - (resolve, reject) => - command(commandLine, (err, stdout) => { - if (err) { - reject(err); - } - resolve(stdout); - }), - { silent: true }, - ); -} - -/** - * Pushes the locally constructed Docker image to the supplied respository - * @param repository tag, for example: 111111111.dkr.ecr.us-east-1.amazonaws.com/sample - * @returns {Promise} - */ -export function pushImage(repository) { - const commandLine = `docker push ${repository}`; - return new Promise((resolve, reject) => - command(commandLine, (err, stdout) => { - if (err) { - reject(err); - } - resolve(stdout); - }), - ); -} From 94f9a80e19cd74e23a973e20aece714b4a61c34f Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 31 Aug 2023 10:41:01 -0300 Subject: [PATCH 02/27] implement base-workspaces --- generators/base-application/generator.mts | 4 +- generators/base-core/generator.mts | 15 +++-- generators/base-workspaces/generator.mts | 67 +++++++++++++++++++ generators/base-workspaces/index.mts | 23 +++++++ generators/base/shared-data.mts | 4 +- generators/workspaces/command.mts | 3 +- generators/workspaces/generator.mjs | 78 +++++++++-------------- test/support/helpers.mts | 2 +- 8 files changed, 136 insertions(+), 60 deletions(-) create mode 100644 generators/base-workspaces/generator.mts create mode 100644 generators/base-workspaces/index.mts diff --git a/generators/base-application/generator.mts b/generators/base-application/generator.mts index f566e3357d4b..7e3d7389f33f 100644 --- a/generators/base-application/generator.mts +++ b/generators/base-application/generator.mts @@ -313,13 +313,13 @@ export default class BaseApplicationGenerator< }); } - getArgsForPriority(priorityName) { + getArgsForPriority(priorityName): any[] { const args = super.getArgsForPriority(priorityName); let firstArg = this.getTaskFirstArgForPriority(priorityName); if (args.length > 0) { firstArg = { ...args[0], ...firstArg }; } - return [firstArg] as any; + return [firstArg]; } /** diff --git a/generators/base-core/generator.mts b/generators/base-core/generator.mts index 126e10f7d197..80019915073a 100644 --- a/generators/base-core/generator.mts +++ b/generators/base-core/generator.mts @@ -982,6 +982,15 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; }); } + private calculateApplicationId(applicationPath: string) { + const dirname = basename(applicationPath); + return `${createHash('shake256', { outputLength: 1 }).update(applicationPath, 'utf8').digest('hex')}-${dirname}`; + } + + protected getApplication(applicationFolder: string) { + return this.options.sharedData.applications?.[this.calculateApplicationId(applicationFolder)]; + } + private createSharedData({ jhipsterOldVersion, help, @@ -989,11 +998,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; jhipsterOldVersion: string | null; help?: boolean; }): SharedData { - const destinationPath = this.destinationPath(); - const dirname = basename(destinationPath); - const applicationId = - this.options.applicationId ?? - `${createHash('shake256', { outputLength: 1 }).update(destinationPath, 'utf8').digest('hex')}-${dirname}`; + const applicationId = this.options.applicationId ?? this.calculateApplicationId(this.destinationPath()); if (this.options.sharedData.applications === undefined) { this.options.sharedData.applications = {}; } diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts new file mode 100644 index 000000000000..5589c583f8ed --- /dev/null +++ b/generators/base-workspaces/generator.mts @@ -0,0 +1,67 @@ +/** + * Copyright 2013-2021 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 { readdir } from 'fs/promises'; +import { existsSync } from 'fs'; +import BaseGenerator from '../base/index.mjs'; +import { PRIORITY_NAMES } from '../base/priorities.mjs'; +import { YO_RC_FILE } from '../generator-constants.mjs'; +import { GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs'; + +const { DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END } = PRIORITY_NAMES; + +/** + * This is the base class for a generator that generates entities. + */ +export default class BaseWorkspacesGenerator extends BaseGenerator { + applicationFolders?: string[]; + directoryPath!: string; + + protected async findApplicationFolders() { + const directoryPath = this.directoryPath ?? '.'; + return (await readdir(this.destinationPath(directoryPath), { withFileTypes: true })) + .filter(dirent => dirent.isDirectory()) + .map(dirent => dirent.name) + .filter( + folder => + existsSync(this.destinationPath(directoryPath, folder, 'package.json')) && + existsSync(this.destinationPath(directoryPath, folder, YO_RC_FILE)), + ); + } + + protected async resolveApplicationFolders() { + return (this.applicationFolders ?? []).map(appFolder => this.destinationPath(this.directoryPath ?? '.', appFolder)); + } + + async bootstrapApplications() { + for (const resolvedApplicationFolder of await this.resolveApplicationFolders()) { + await this.composeWithJHipster(GENERATOR_BOOTSTRAP_APPLICATION, { generatorOptions: { destinationRoot: resolvedApplicationFolder } }); + } + } + + getArgsForPriority(priorityName): any { + const args = super.getArgsForPriority(priorityName); + if (![DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END].includes(priorityName)) { + return args; + } + + const [first, ...others] = args ?? []; + return [{ ...first, applications: (this.applicationFolders ?? []).map(appFolder => this.getApplication(appFolder)) }, ...others]; + } +} diff --git a/generators/base-workspaces/index.mts b/generators/base-workspaces/index.mts new file mode 100644 index 000000000000..6556e074f61c --- /dev/null +++ b/generators/base-workspaces/index.mts @@ -0,0 +1,23 @@ +/** + * Copyright 2013-2023 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. + */ + +/* + * Register generator-base at yeoman-environment + */ +export { default } from './generator.mjs'; diff --git a/generators/base/shared-data.mts b/generators/base/shared-data.mts index e31eb08307b7..fef63c624cd0 100644 --- a/generators/base/shared-data.mts +++ b/generators/base/shared-data.mts @@ -33,7 +33,7 @@ export default class SharedData this.initializing); } get configuring() { - return { + return this.asConfiguringTaskGroup({ async configure() { this.jhipsterConfig.baseName = this.jhipsterConfig.baseName || 'workspaces'; }, - }; + }); } - get [BaseGenerator.CONFIGURING]() { + get [BaseWorkspacesGenerator.CONFIGURING]() { return this.delegateTasksToBlueprint(() => this.configuring); } get composing() { - return { + return this.asComposingTaskGroup({ async composeGit() { if (this.options.monorepository || this.jhipsterConfig.monorepository) { await this.composeWithJHipster(GENERATOR_GIT); } }, - }; - } - - get [BaseGenerator.COMPOSING]() { - return this.delegateTasksToBlueprint(() => this.composing); - } - - get default() { - return { async generateApplications() { if (!this.generateApplications) { return; @@ -102,36 +91,27 @@ export default class WorkspacesGenerator extends BaseGenerator { if (typeof this.generateApplications === 'function') { await this.generateApplications.call(this); } else { - for (const appName of this.workspacesFolders) { + for (const appName of this.applicationFolders) { await this.composeWithJHipster(this.generateWith, { generatorOptions: { destinationRoot: this.destinationPath(appName) } }); } } }, + }); + } + + get [BaseWorkspacesGenerator.COMPOSING]() { + return this.delegateTasksToBlueprint(() => this.composing); + } + + get default() { + return this.asDefaultTaskGroup({ async configureUsingFiles() { if (!this.generateWorkspaces) return; - const packages = [...(this.workspacesConfig.packages ?? [])]; - this.workspacesFolders.forEach(workspace => !packages.includes(workspace) && packages.push(workspace)); - let dockerCompose; - - const dir = fs.opendirSync('./'); - let dirent = await dir.read(); - while (dirent) { - if (dirent.isDirectory()) { - if (dirent.name === 'docker-compose') { - dockerCompose = true; - } else if (fs.existsSync(path.join(dir.path, dirent.name, 'package.json'))) { - if (!packages.includes(dirent.name)) { - packages.push(dirent.name); - } - } - } - dirent = await dir.read(); + if (existsSync(this.destinationPath('docker-compose'))) { + this.workspacesConfig.dockerCompose = true; } - dir.closeSync(); - - this.workspacesConfig.dockerCompose = dockerCompose; - this.workspacesConfig.packages = packages; + this.workspacesConfig.packages = [...new Set([...(this.workspacesConfig.packages ?? []), ...this.applicationFolders])]; }, configurePackageManager() { @@ -147,15 +127,15 @@ export default class WorkspacesGenerator extends BaseGenerator { this.packages = this.workspacesConfig.packages; this.env.options.nodePackageManager = this.workspacesConfig.clientPackageManager; }, - }; + }); } - get [BaseGenerator.DEFAULT]() { + get [BaseWorkspacesGenerator.DEFAULT]() { return this.delegateTasksToBlueprint(() => this.default); } get postWriting() { - return { + return this.asPostWritingTaskGroup({ generatePackageJson() { if (!this.generateWorkspaces) return; @@ -196,10 +176,10 @@ export default class WorkspacesGenerator extends BaseGenerator { }); } }, - }; + }); } - get [BaseGenerator.POST_WRITING]() { + get [BaseWorkspacesGenerator.POST_WRITING]() { return this.delegateTasksToBlueprint(() => this.postWriting); } diff --git a/test/support/helpers.mts b/test/support/helpers.mts index 8873bc554617..3cf4ac7ef844 100644 --- a/test/support/helpers.mts +++ b/test/support/helpers.mts @@ -163,7 +163,7 @@ class JHipsterRunContext withControl(sharedControl: Record): this { this.sharedControl = {}; Object.assign(this.sharedControl, sharedControl); - return this.withSharedApplication({ sharedData: this.sharedControl }); + return this.withSharedApplication({ control: this.sharedControl }); } private withSharedApplication(sharedApplication: Record): this { From 678604fedd64b5984ea61288f5f0c67f649ba4a7 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 1 Sep 2023 16:27:16 -0300 Subject: [PATCH 03/27] use base-workspaces apis at workspaces --- generators/base-core/generator.mts | 2 +- generators/base-workspaces/generator.mts | 27 ++++++++++- generators/jdl/generator.mts | 4 ++ generators/workspaces/generator.mjs | 62 ++++-------------------- 4 files changed, 40 insertions(+), 55 deletions(-) diff --git a/generators/base-core/generator.mts b/generators/base-core/generator.mts index 80019915073a..6af94a01b400 100644 --- a/generators/base-core/generator.mts +++ b/generators/base-core/generator.mts @@ -987,7 +987,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; return `${createHash('shake256', { outputLength: 1 }).update(applicationPath, 'utf8').digest('hex')}-${dirname}`; } - protected getApplication(applicationFolder: string) { + protected getSharedApplication(applicationFolder: string) { return this.options.sharedData.applications?.[this.calculateApplicationId(applicationFolder)]; } diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts index 5589c583f8ed..2125023c6f4a 100644 --- a/generators/base-workspaces/generator.mts +++ b/generators/base-workspaces/generator.mts @@ -20,7 +20,7 @@ import { readdir } from 'fs/promises'; import { existsSync } from 'fs'; import BaseGenerator from '../base/index.mjs'; -import { PRIORITY_NAMES } from '../base/priorities.mjs'; +import { PRIORITY_NAMES, QUEUES } from '../base/priorities.mjs'; import { YO_RC_FILE } from '../generator-constants.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs'; @@ -33,6 +33,21 @@ export default class BaseWorkspacesGenerator extends BaseGenerator { applicationFolders?: string[]; directoryPath!: string; + constructor(args, options, features) { + super(args, options, features); + + if (!this.options.help) { + this.queueTask({ + async method() { + await (this as any).bootstrapApplications(); + }, + taskName: 'bootstrapApplications', + cancellable: true, + queueName: QUEUES.PREPARING_QUEUE, + }); + } + } + protected async findApplicationFolders() { const directoryPath = this.directoryPath ?? '.'; return (await readdir(this.destinationPath(directoryPath), { withFileTypes: true })) @@ -62,6 +77,14 @@ export default class BaseWorkspacesGenerator extends BaseGenerator { } const [first, ...others] = args ?? []; - return [{ ...first, applications: (this.applicationFolders ?? []).map(appFolder => this.getApplication(appFolder)) }, ...others]; + return [ + { + ...first, + applications: (this.applicationFolders ?? []).map( + appFolder => this.getSharedApplication(this.destinationPath(this.directoryPath ?? '.', appFolder))?.sharedApplication, + ), + }, + ...others, + ]; } } diff --git a/generators/jdl/generator.mts b/generators/jdl/generator.mts index 3d4b5a9c39be..0f2bf7504968 100644 --- a/generators/jdl/generator.mts +++ b/generators/jdl/generator.mts @@ -283,6 +283,10 @@ export default class JdlGenerator extends BaseGenerator { const adapter = (this.env.adapter as QueuedAdapter).newAdapter(); const envOptions: any = { cwd, logCwd: rootCwd, sharedFs: application.sharedFs, adapter }; const generatorOptions = { ...this.options, ...options, skipPriorities: ['prompting'] }; + + // We should not reuse sharedData at non interactive runs + delete generatorOptions.sharedData; + // Install should happen at the root of the monorepository. Force skip install at childs. if (this.options.monorepository) { generatorOptions.skipInstall = true; diff --git a/generators/workspaces/generator.mjs b/generators/workspaces/generator.mjs index f2cfc7ab3eb6..d7d03b219ef2 100644 --- a/generators/workspaces/generator.mjs +++ b/generators/workspaces/generator.mjs @@ -21,10 +21,7 @@ import { existsSync } from 'fs'; import { GENERATOR_ANGULAR, GENERATOR_COMMON, GENERATOR_GIT, GENERATOR_WORKSPACES } from '../generator-list.mjs'; -import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; -import { getConfigWithDefaults } from '../../jdl/jhipster/index.mjs'; -import { removeFieldsWithNullishValues } from '../base/support/config.mjs'; import command from './command.mjs'; /** @@ -114,10 +111,11 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { this.workspacesConfig.packages = [...new Set([...(this.workspacesConfig.packages ?? []), ...this.applicationFolders])]; }, - configurePackageManager() { + configurePackageManager({ applications }) { if (this.workspacesConfig.clientPackageManager || !this.generateWorkspaces) return; - this.workspacesConfig.clientPackageManager = this._detectNodePackageManager(); + this.workspacesConfig.clientPackageManager = + this.options.clientPackageManager ?? applications.find(app => app.clientPackageManager)?.clientPackageManager ?? 'npm'; }, async loadConfig() { @@ -136,7 +134,7 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { get postWriting() { return this.asPostWritingTaskGroup({ - generatePackageJson() { + generatePackageJson({ applications }) { if (!this.generateWorkspaces) return; const { @@ -158,13 +156,12 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { scripts: { 'ci:e2e:package': 'npm run ci:docker:build --workspaces --if-present && npm run java:docker --workspaces --if-present', 'ci:e2e:run': 'npm run e2e:headless --workspaces --if-present', - ...this._getOtherScripts(), - ...this._createConcurrentlyScript('watch', 'backend:build-cache', 'java:docker', 'java:docker:arm64'), - ...this._createWorkspacesScript('ci:backend:test', 'ci:frontend:test', 'webapp:test'), + ...this.getOtherScripts(), + ...this.createConcurrentlyScript('watch', 'backend:build-cache', 'java:docker', 'java:docker:arm64'), + ...this.createWorkspacesScript('ci:backend:test', 'ci:frontend:test', 'webapp:test'), }, }); - const applications = this.loadApplications(); if (applications.some(app => app.clientFrameworkAngular)) { this.packageJson.merge({ devDependencies: { @@ -183,24 +180,7 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { return this.delegateTasksToBlueprint(() => this.postWriting); } - _detectNodePackageManager() { - if (this.options.clientPackageManager !== undefined) { - return this.options.clientPackageManager; - } - - if (this.workspacesConfig.packages && this.workspacesConfig.packages.length > 0) { - const appPackageJson = this.readDestinationJSON(`${this.workspacesConfig.packages[0]}/.yo-rc.json`); - const nodePackageManager = - appPackageJson && appPackageJson[GENERATOR_JHIPSTER] && appPackageJson[GENERATOR_JHIPSTER].clientPackageManager; - if (nodePackageManager) { - return nodePackageManager; - } - } - - return 'npm'; - } - - _getOtherScripts() { + getOtherScripts() { if (this.dockerCompose) { return { 'docker-compose': 'docker compose -f docker-compose/docker-compose.yml up --wait', @@ -211,7 +191,7 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { return {}; } - _createConcurrentlyScript(...scripts) { + createConcurrentlyScript(...scripts) { const scriptsList = scripts .map(script => { const packageScripts = this.packages.map(packageName => [ @@ -225,29 +205,7 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { return Object.fromEntries(scriptsList); } - _createWorkspacesScript(...scripts) { + createWorkspacesScript(...scripts) { return Object.fromEntries(scripts.map(script => [`${script}`, `npm run ${script} --workspaces --if-present`])); } - - loadApplications() { - return this.workspacesConfig.packages - .map(appPath => { - const appConfig = this.readDestinationJSON(`${appPath}/.yo-rc.json`)[GENERATOR_JHIPSTER]; - if (!appConfig) return undefined; - - const app = getConfigWithDefaults(removeFieldsWithNullishValues(appConfig)); - - this.loadAppConfig(app, app); - this.loadServerConfig(app, app); - this.loadClientConfig(app, app); - this.loadPlatformConfig(app, app); - - this.loadDerivedAppConfig(app); - this.loadDerivedClientConfig(app); - this.loadDerivedServerConfig(app); - this.loadDerivedPlatformConfig(app); - return app; - }) - .filter(app => app); - } } From b5c220fffdf77e48a1c69cea74f9a9f2e4b6a2bc Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 1 Sep 2023 17:34:07 -0300 Subject: [PATCH 04/27] rename applicationFolders to appsFolders to match deployments --- generators/base-workspaces/generator.mts | 6 +++--- generators/workspaces/command.mts | 2 +- generators/workspaces/generator.mjs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts index 2125023c6f4a..e8e34be8e236 100644 --- a/generators/base-workspaces/generator.mts +++ b/generators/base-workspaces/generator.mts @@ -30,7 +30,7 @@ const { DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END } = PRIORITY * This is the base class for a generator that generates entities. */ export default class BaseWorkspacesGenerator extends BaseGenerator { - applicationFolders?: string[]; + appsFolders?: string[]; directoryPath!: string; constructor(args, options, features) { @@ -61,7 +61,7 @@ export default class BaseWorkspacesGenerator extends BaseGenerator { } protected async resolveApplicationFolders() { - return (this.applicationFolders ?? []).map(appFolder => this.destinationPath(this.directoryPath ?? '.', appFolder)); + return (this.appsFolders ?? []).map(appFolder => this.destinationPath(this.directoryPath ?? '.', appFolder)); } async bootstrapApplications() { @@ -80,7 +80,7 @@ export default class BaseWorkspacesGenerator extends BaseGenerator { return [ { ...first, - applications: (this.applicationFolders ?? []).map( + applications: (this.appsFolders ?? []).map( appFolder => this.getSharedApplication(this.destinationPath(this.directoryPath ?? '.', appFolder))?.sharedApplication, ), }, diff --git a/generators/workspaces/command.mts b/generators/workspaces/command.mts index 9101d30325c9..dc04e3aea13f 100644 --- a/generators/workspaces/command.mts +++ b/generators/workspaces/command.mts @@ -3,7 +3,7 @@ import { GENERATOR_APP, GENERATOR_GIT } from '../generator-list.mjs'; const command: JHipsterCommandDefinition = { options: { - applicationFolders: { + appsFolders: { name: 'workspacesFolders', type: Array, description: 'Folders to use as monorepository workspace', diff --git a/generators/workspaces/generator.mjs b/generators/workspaces/generator.mjs index d7d03b219ef2..c3c70a32ce96 100644 --- a/generators/workspaces/generator.mjs +++ b/generators/workspaces/generator.mjs @@ -88,7 +88,7 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { if (typeof this.generateApplications === 'function') { await this.generateApplications.call(this); } else { - for (const appName of this.applicationFolders) { + for (const appName of this.appsFolders) { await this.composeWithJHipster(this.generateWith, { generatorOptions: { destinationRoot: this.destinationPath(appName) } }); } } @@ -108,7 +108,7 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { if (existsSync(this.destinationPath('docker-compose'))) { this.workspacesConfig.dockerCompose = true; } - this.workspacesConfig.packages = [...new Set([...(this.workspacesConfig.packages ?? []), ...this.applicationFolders])]; + this.workspacesConfig.packages = [...new Set([...(this.workspacesConfig.packages ?? []), ...this.appsFolders])]; }, configurePackageManager({ applications }) { From 912361e28c484b5ec6d6d7f74fc3dbb63e8e72aa Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 1 Sep 2023 18:23:46 -0300 Subject: [PATCH 05/27] cleanup base-docker and deployments --- generators/base-docker/docker-base.mjs | 14 +- generators/base-docker/generator.mjs | 30 +- .../internal/docker-dependencies.mts | 31 ++ generators/base-workspaces/internal/index.mts | 19 + .../docker-compose.spec.mts.snap | 522 ++++++++++++++++++ .../support/check-docker.mjs} | 0 generators/docker/support/index.mts | 19 + .../kubernetes.helm.spec.mts.snap | 234 ++++++++ generators/kubernetes-helm/generator.mjs | 26 +- .../__snapshots__/knative.spec.mts.snap | 421 ++++++++++++++ generators/kubernetes-knative/generator.mjs | 26 +- .../__snapshots__/kubernetes.spec.mts.snap | 376 +++++++++++++ generators/kubernetes/generator.mjs | 26 +- .../__snapshots__/openshift.spec.mts.snap | 175 ++++++ generators/openshift/generator.mjs | 28 +- 15 files changed, 1861 insertions(+), 86 deletions(-) create mode 100644 generators/base-workspaces/internal/docker-dependencies.mts create mode 100644 generators/base-workspaces/internal/index.mts rename generators/{base-docker/docker-utils.mjs => docker/support/check-docker.mjs} (100%) create mode 100644 generators/docker/support/index.mts diff --git a/generators/base-docker/docker-base.mjs b/generators/base-docker/docker-base.mjs index 6507492948ee..cd769ca16ff4 100644 --- a/generators/base-docker/docker-base.mjs +++ b/generators/base-docker/docker-base.mjs @@ -26,7 +26,7 @@ import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; const { MAVEN } = buildToolTypes; const { MONOLITH, MICROSERVICE, GATEWAY } = applicationTypes; -export { checkDocker } from './docker-utils.mjs'; +export { checkDocker } from '../docker/support/index.mjs'; /** * Check Images @@ -74,18 +74,6 @@ export function configureImageNames() { } } -/** - * Set Apps Folder Paths - */ -export function setAppsFolderPaths() { - if (this.applicationType) return; - this.appsFolderPaths = []; - for (let i = 0; i < this.appsFolders.length; i++) { - const path = this.destinationPath(this.directoryPath + this.appsFolders[i]); - this.appsFolderPaths.push(path); - } -} - /** * Load config from this.appFolders */ diff --git a/generators/base-docker/generator.mjs b/generators/base-docker/generator.mjs index feec17b8b28c..ce1ef553d533 100644 --- a/generators/base-docker/generator.mjs +++ b/generators/base-docker/generator.mjs @@ -19,14 +19,12 @@ import _ from 'lodash'; import prompts from './docker-prompts.mjs'; -import BlueprintBaseGenerator from '../base/index.mjs'; +import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; -import { loadFromYoRc, checkDocker, checkImages, generateJwtSecret, setAppsFolderPaths } from './docker-base.mjs'; +import { loadFromYoRc, checkDocker, checkImages, generateJwtSecret } from './docker-base.mjs'; import statistics from '../statistics.mjs'; import { applicationOptions, deploymentOptions } from '../../jdl/jhipster/index.mjs'; - -import { dockerContainers as elasticDockerContainer } from '../generator-constants.mjs'; -import { dockerPlaceholderGenerator, getDockerfileContainers } from '../docker/utils.mjs'; +import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; const { OptionNames } = applicationOptions; const { Options: DeploymentOptions } = deploymentOptions; @@ -35,9 +33,9 @@ const { JWT_SECRET_KEY } = OptionNames; /** * @class - * @extends {BlueprintBaseGenerator} + * @extends {BaseWorkspacesGenerator} */ -export default class BaseDockerGenerator extends BlueprintBaseGenerator { +export default class BaseDockerGenerator extends BaseWorkspacesGenerator { constructor(args, options, features) { super(args, options, features); @@ -52,22 +50,9 @@ export default class BaseDockerGenerator extends BlueprintBaseGenerator { get initializing() { return { - async setupServerConsts() { - const dockerfile = this.readTemplate(this.jhipsterTemplatePath('../../server/resources/Dockerfile')); - this.dockerContainers = this.prepareDependencies( - { - ...elasticDockerContainer, - ...getDockerfileContainers(dockerfile), - }, - dockerPlaceholderGenerator, - ); - }, - + loadDockerDependenciesTask, checkDocker, - - loadConfig() { - loadFromYoRc.call(this); - }, + loadFromYoRc, }; } @@ -93,7 +78,6 @@ export default class BaseDockerGenerator extends BlueprintBaseGenerator { checkImages, generateJwtSecret, - setAppsFolderPaths, }; } diff --git a/generators/base-workspaces/internal/docker-dependencies.mts b/generators/base-workspaces/internal/docker-dependencies.mts new file mode 100644 index 000000000000..5a0d0629b88e --- /dev/null +++ b/generators/base-workspaces/internal/docker-dependencies.mts @@ -0,0 +1,31 @@ +/** + * Copyright 2013-2021 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 { dockerContainers as elasticDockerContainer } from '../../generator-constants.mjs'; +import { dockerPlaceholderGenerator, getDockerfileContainers } from '../../docker/utils.mjs'; + +export async function loadDockerDependenciesTask(this: any) { + const dockerfile = this.readTemplate(this.jhipsterTemplatePath('../../server/resources/Dockerfile')); + this.dockerContainers = this.prepareDependencies( + { + ...elasticDockerContainer, + ...getDockerfileContainers(dockerfile), + }, + dockerPlaceholderGenerator, + ); +} diff --git a/generators/base-workspaces/internal/index.mts b/generators/base-workspaces/internal/index.mts new file mode 100644 index 000000000000..213a6044416e --- /dev/null +++ b/generators/base-workspaces/internal/index.mts @@ -0,0 +1,19 @@ +/** + * Copyright 2013-2021 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 * from './docker-dependencies.mjs'; diff --git a/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap b/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap index e1b688181d28..0356b2f6a680 100644 --- a/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap +++ b/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap @@ -25,6 +25,35 @@ exports[`generator - Docker Compose gateway and 1 microservice, with 1 couchbase "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "10-couchbase/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mscouchbase", + "databaseType": "couchbase", + "entities": [], + "prodDatabaseType": "couchbase", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -195,6 +224,34 @@ exports[`generator - Docker Compose gateway and 1 microservice, with Cassandra s "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "05-cassandra/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mscassandra", + "databaseType": "cassandra", + "entities": [], + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -376,6 +433,78 @@ exports[`generator - Docker Compose gateway and multi microservices should match "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "04-mongo/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmongodb", + "databaseType": "mongodb", + "entities": [], + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "07-mariadb/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmariadb", + "entities": [], + "prodDatabaseType": "mariadb", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -689,6 +818,79 @@ exports[`generator - Docker Compose gateway and multi microservices using oauth2 "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "authenticationType": "oauth2", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080 + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "authenticationType": "oauth2", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081 + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "authenticationType": "oauth2", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081 + } +} +", + "stateCleared": "modified", + }, + "07-mariadb/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "authenticationType": "oauth2", + "baseName": "msmariadb", + "entities": [], + "prodDatabaseType": "mariadb", + "serverPort": 8081 + } +} +", + "stateCleared": "modified", + }, + "10-couchbase/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "authenticationType": "oauth2", + "baseName": "mscouchbase", + "databaseType": "couchbase", + "entities": [], + "prodDatabaseType": "couchbase", + "serverPort": 8081 + } +} ", "stateCleared": "modified", }, @@ -1073,6 +1275,64 @@ exports[`generator - Docker Compose gateway and multi microservices, with 1 mong "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "04-mongo/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmongodb", + "databaseType": "mongodb", + "entities": [], + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -1342,6 +1602,79 @@ exports[`generator - Docker Compose gateway and multi microservices, with couchb "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "07-mariadb/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmariadb", + "entities": [], + "prodDatabaseType": "mariadb", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "10-couchbase/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mscouchbase", + "databaseType": "couchbase", + "entities": [], + "prodDatabaseType": "couchbase", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -1652,6 +1985,35 @@ exports[`generator - Docker Compose gateway and one microservice should match fi "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -1822,6 +2184,35 @@ exports[`generator - Docker Compose gateway and one microservice, with curator s "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -1992,6 +2383,35 @@ exports[`generator - Docker Compose gateway and one microservice, with prometheu "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -2276,6 +2696,35 @@ exports[`generator - Docker Compose gateway and one microservice, without monito "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -2444,6 +2893,22 @@ exports[`generator - Docker Compose monolith should match files snapshot 1`] = ` "serviceDiscoveryType": false } } +", + "stateCleared": "modified", + }, + "08-monolith/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "monolith", + "authenticationType": "session", + "baseName": "sampleMysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "searchEngine": "elasticsearch", + "serverPort": 8080 + } +} ", "stateCleared": "modified", }, @@ -2553,6 +3018,20 @@ exports[`generator - Docker Compose one microservice and a directory path withou "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081 + } +} ", "stateCleared": "modified", }, @@ -2677,6 +3156,20 @@ exports[`generator - Docker Compose only gateway should match files snapshot 1`] "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -2803,6 +3296,20 @@ exports[`generator - Docker Compose only one microservice should match files sna "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081 + } +} ", "stateCleared": "modified", }, @@ -2927,6 +3434,21 @@ exports[`generator - Docker Compose oracle monolith should match files snapshot "serviceDiscoveryType": false } } +", + "stateCleared": "modified", + }, + "12-oracle/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "monolith", + "baseName": "oracle-mono", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "oracle", + "serverPort": 8080, + "skipClient": true + } +} ", "stateCleared": "modified", }, diff --git a/generators/base-docker/docker-utils.mjs b/generators/docker/support/check-docker.mjs similarity index 100% rename from generators/base-docker/docker-utils.mjs rename to generators/docker/support/check-docker.mjs diff --git a/generators/docker/support/index.mts b/generators/docker/support/index.mts new file mode 100644 index 000000000000..e1a435e304c8 --- /dev/null +++ b/generators/docker/support/index.mts @@ -0,0 +1,19 @@ +/** + * Copyright 2013-2023 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 * from './check-docker.mjs'; diff --git a/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap b/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap index 9ac6866b65ca..991acf7b283d 100644 --- a/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap +++ b/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap @@ -22,6 +22,21 @@ exports[`generator - Kubernetes Helm Kafka application should match files snapsh "serviceDiscoveryType": false } } +", + "stateCleared": "modified", + }, + "09-kafka/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "monolith", + "authenticationType": "session", + "baseName": "sampleKafka", + "entities": [], + "messageBroker": "kafka", + "prodDatabaseType": "mysql", + "serverPort": 8080 + } +} ", "stateCleared": "modified", }, @@ -411,6 +426,36 @@ exports[`generator - Kubernetes Helm MySQL and PostgreSQL microservices without "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -1300,6 +1345,20 @@ exports[`generator - Kubernetes Helm gateway and ingress should match files snap "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -1949,6 +2008,35 @@ exports[`generator - Kubernetes Helm gateway and mysql microservice should match "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -2762,6 +2850,20 @@ exports[`generator - Kubernetes Helm gateway with istio should match files snaps "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -3644,6 +3746,78 @@ exports[`generator - Kubernetes Helm gateway, mysql, psql, mongodb, mariadb micr "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "04-mongo/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmongodb", + "databaseType": "mongodb", + "entities": [], + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "07-mariadb/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmariadb", + "entities": [], + "prodDatabaseType": "mariadb", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -5089,6 +5263,22 @@ exports[`generator - Kubernetes Helm monolith application should match files sna "serviceDiscoveryType": false } } +", + "stateCleared": "modified", + }, + "08-monolith/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "monolith", + "authenticationType": "session", + "baseName": "sampleMysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "searchEngine": "elasticsearch", + "serverPort": 8080 + } +} ", "stateCleared": "modified", }, @@ -5463,6 +5653,21 @@ exports[`generator - Kubernetes Helm mysql microservice with custom namespace an "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -8444,6 +8649,21 @@ exports[`generator - Kubernetes Helm mysql microservice with custom namespace sh "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -9078,6 +9298,20 @@ exports[`generator - Kubernetes Helm only gateway should match files snapshot 1` "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, diff --git a/generators/kubernetes-helm/generator.mjs b/generators/kubernetes-helm/generator.mjs index 2dd18a475d79..f233377bcd0a 100644 --- a/generators/kubernetes-helm/generator.mjs +++ b/generators/kubernetes-helm/generator.mjs @@ -20,12 +20,12 @@ import fs from 'fs'; import chalk from 'chalk'; -import BaseDockerGenerator from '../base-docker/index.mjs'; +import BaseWorkspacesGenerator from '../base-docker/index.mjs'; import prompts from '../kubernetes/prompts.mjs'; import { writeFiles } from './files.mjs'; import { GENERATOR_KUBERNETES_HELM } from '../generator-list.mjs'; -import { checkImages, generateJwtSecret, configureImageNames, setAppsFolderPaths } from '../base-docker/docker-base.mjs'; +import { checkImages, generateJwtSecret, configureImageNames } from '../base-docker/docker-base.mjs'; import { checkKubernetes, checkHelm, @@ -38,14 +38,16 @@ import { import statistics from '../statistics.mjs'; import { messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; import { getJdbcUrl, getR2dbcUrl } from '../spring-data-relational/support/index.mjs'; +import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; +import { checkDocker } from '../docker/support/index.mjs'; const { KAFKA } = messageBrokerTypes; /** * @class - * @extends {BaseDockerGenerator} + * @extends {BaseWorkspacesGenerator} */ -export default class KubernetesHelmGenerator extends BaseDockerGenerator { +export default class KubernetesHelmGenerator extends BaseWorkspacesGenerator { async beforeQueue() { if (!this.fromBlueprint) { await this.composeWithBlueprints(GENERATOR_KUBERNETES_HELM); @@ -58,7 +60,8 @@ export default class KubernetesHelmGenerator extends BaseDockerGenerator { this.log.log(chalk.white(`${chalk.bold('⎈')} Welcome to the JHipster Kubernetes Helm Generator ${chalk.bold('⎈')}`)); this.log.log(chalk.white(`Files will be generated in folder: ${chalk.yellow(this.destinationRoot())}`)); }, - ...super.initializing, + loadDockerDependenciesTask, + checkDocker, checkKubernetes, checkHelm, loadConfig, @@ -67,7 +70,7 @@ export default class KubernetesHelmGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.INITIALIZING]() { + get [BaseWorkspacesGenerator.INITIALIZING]() { return this.delegateTasksToBlueprint(() => this.initializing); } @@ -90,7 +93,7 @@ export default class KubernetesHelmGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.PROMPTING]() { + get [BaseWorkspacesGenerator.PROMPTING]() { return this.delegateTasksToBlueprint(() => this.prompting); } @@ -103,7 +106,6 @@ export default class KubernetesHelmGenerator extends BaseDockerGenerator { checkImages, generateJwtSecret, configureImageNames, - setAppsFolderPaths, setPostPromptProp() { this.appConfigs.forEach(element => { @@ -118,7 +120,7 @@ export default class KubernetesHelmGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.CONFIGURING]() { + get [BaseWorkspacesGenerator.CONFIGURING]() { return this.delegateTasksToBlueprint(() => this.configuring); } @@ -138,7 +140,7 @@ export default class KubernetesHelmGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.LOADING]() { + get [BaseWorkspacesGenerator.LOADING]() { return this.delegateTasksToBlueprint(() => this.loading); } @@ -146,7 +148,7 @@ export default class KubernetesHelmGenerator extends BaseDockerGenerator { return writeFiles(); } - get [BaseDockerGenerator.WRITING]() { + get [BaseWorkspacesGenerator.WRITING]() { return this.delegateTasksToBlueprint(() => this.writing); } @@ -188,7 +190,7 @@ export default class KubernetesHelmGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.END]() { + get [BaseWorkspacesGenerator.END]() { return this.delegateTasksToBlueprint(() => this.end); } diff --git a/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap b/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap index f76372160e6a..faac690a6dac 100644 --- a/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap +++ b/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap @@ -23,6 +23,36 @@ exports[`generator - Knative Using Helm generator type MySQL and PostgreSQL micr "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -1094,6 +1124,20 @@ exports[`generator - Knative Using Helm generator type gateway and ingress shoul "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -1921,6 +1965,35 @@ exports[`generator - Knative Using Helm generator type gateway and mysql microse "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -2961,6 +3034,20 @@ exports[`generator - Knative Using Helm generator type gateway with istio routin "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -3794,6 +3881,78 @@ exports[`generator - Knative Using Helm generator type gateway, mysql, psql, mon "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "04-mongo/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmongodb", + "databaseType": "mongodb", + "entities": [], + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "07-mariadb/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmariadb", + "entities": [], + "prodDatabaseType": "mariadb", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -5562,6 +5721,21 @@ exports[`generator - Knative Using Helm generator type mysql microservice with c "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -8742,6 +8916,21 @@ exports[`generator - Knative Using Helm generator type mysql microservice with c "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -9525,6 +9714,20 @@ exports[`generator - Knative Using Helm generator type only gateway should match "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -10361,6 +10564,36 @@ exports[`generator - Knative Using K8s generator type MySQL and PostgreSQL micro "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -11354,6 +11587,20 @@ exports[`generator - Knative Using K8s generator type gateway and ingress should "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -12110,6 +12357,35 @@ exports[`generator - Knative Using K8s generator type gateway and mysql microser "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -13064,6 +13340,20 @@ exports[`generator - Knative Using K8s generator type gateway with istio routing "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -13834,6 +14124,93 @@ exports[`generator - Knative Using K8s generator type gateway, mysql, psql, mong "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "04-mongo/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmongodb", + "databaseType": "mongodb", + "entities": [], + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "07-mariadb/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmariadb", + "entities": [], + "prodDatabaseType": "mariadb", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "11-mssql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmssqldb", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mssql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -15972,6 +16349,21 @@ exports[`generator - Knative Using K8s generator type mysql microservice with cu "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -19375,6 +19767,21 @@ exports[`generator - Knative Using K8s generator type mysql microservice with cu "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -20086,6 +20493,20 @@ exports[`generator - Knative Using K8s generator type only gateway should match "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, diff --git a/generators/kubernetes-knative/generator.mjs b/generators/kubernetes-knative/generator.mjs index 32d3c01b7dab..133721bf6fe1 100644 --- a/generators/kubernetes-knative/generator.mjs +++ b/generators/kubernetes-knative/generator.mjs @@ -22,12 +22,12 @@ import chalk from 'chalk'; import shelljs from 'shelljs'; import runAsync from 'run-async'; -import BaseDockerGenerator from '../base-docker/index.mjs'; +import BaseWorkspacesGenerator from '../base-docker/index.mjs'; import prompts from './prompts.mjs'; import { writeFiles } from './files.mjs'; import { GENERATOR_KUBERNETES_KNATIVE } from '../generator-list.mjs'; -import { checkImages, generateJwtSecret, configureImageNames, setAppsFolderPaths } from '../base-docker/docker-base.mjs'; +import { checkImages, generateJwtSecret, configureImageNames } from '../base-docker/docker-base.mjs'; import { checkHelm, checkKubernetes, @@ -40,6 +40,8 @@ import { import statistics from '../statistics.mjs'; import { kubernetesPlatformTypes, buildToolTypes, messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; import { getJdbcUrl } from '../spring-data-relational/support/index.mjs'; +import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; +import { checkDocker } from '../docker/support/index.mjs'; const { GeneratorTypes } = kubernetesPlatformTypes; const { MAVEN } = buildToolTypes; @@ -49,9 +51,9 @@ const { K8S } = GeneratorTypes; /** * @class - * @extends {BaseDockerGenerator} + * @extends {BaseWorkspacesGenerator} */ -export default class KubernetesKnativeGenerator extends BaseDockerGenerator { +export default class KubernetesKnativeGenerator extends BaseWorkspacesGenerator { async beforeQueue() { if (!this.fromBlueprint) { await this.composeWithBlueprints(GENERATOR_KUBERNETES_KNATIVE); @@ -64,7 +66,8 @@ export default class KubernetesKnativeGenerator extends BaseDockerGenerator { this.log.log(chalk.white(`${chalk.bold('☸')} Welcome to the JHipster Kubernetes Knative Generator ${chalk.bold('☸')}`)); this.log.log(chalk.white(`Files will be generated in the folder: ${chalk.yellow(this.destinationRoot())}`)); }, - ...super.initializing, + loadDockerDependenciesTask, + checkDocker, checkKubernetes, checkHelm, checkKnative: runAsync(function () { @@ -94,7 +97,7 @@ export default class KubernetesKnativeGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.INITIALIZING]() { + get [BaseWorkspacesGenerator.INITIALIZING]() { return this.delegateTasksToBlueprint(() => this.initializing); } @@ -114,7 +117,7 @@ export default class KubernetesKnativeGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.PROMPTING]() { + get [BaseWorkspacesGenerator.PROMPTING]() { return this.delegateTasksToBlueprint(() => this.prompting); } @@ -127,7 +130,6 @@ export default class KubernetesKnativeGenerator extends BaseDockerGenerator { checkImages, generateJwtSecret, configureImageNames, - setAppsFolderPaths, setPostPromptProp() { this.appConfigs.forEach(element => { @@ -142,7 +144,7 @@ export default class KubernetesKnativeGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.CONFIGURING]() { + get [BaseWorkspacesGenerator.CONFIGURING]() { return this.delegateTasksToBlueprint(() => this.configuring); } @@ -162,7 +164,7 @@ export default class KubernetesKnativeGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.LOADING]() { + get [BaseWorkspacesGenerator.LOADING]() { return this.delegateTasksToBlueprint(() => this.loading); } @@ -170,7 +172,7 @@ export default class KubernetesKnativeGenerator extends BaseDockerGenerator { return writeFiles(); } - get [BaseDockerGenerator.WRITING]() { + get [BaseWorkspacesGenerator.WRITING]() { return this.delegateTasksToBlueprint(() => this.writing); } @@ -239,7 +241,7 @@ export default class KubernetesKnativeGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.END]() { + get [BaseWorkspacesGenerator.END]() { return this.delegateTasksToBlueprint(() => this.end); } diff --git a/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap b/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap index cd93bcf584ba..20ce860232cb 100644 --- a/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap +++ b/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap @@ -24,6 +24,21 @@ exports[`generator - Kubernetes Kafka application should match files snapshot 1` "serviceDiscoveryType": false } } +", + "stateCleared": "modified", + }, + "09-kafka/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "monolith", + "authenticationType": "session", + "baseName": "sampleKafka", + "entities": [], + "messageBroker": "kafka", + "prodDatabaseType": "mysql", + "serverPort": 8080 + } +} ", "stateCleared": "modified", }, @@ -508,6 +523,36 @@ exports[`generator - Kubernetes MySQL and PostgreSQL microservices without gatew "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -1468,6 +1513,20 @@ exports[`generator - Kubernetes gateway and ingress should match files snapshot "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -2159,6 +2218,20 @@ exports[`generator - Kubernetes gateway and ingressType gke should match files s "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "authenticationType": "oauth2", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080 + } +} ", "stateCleared": "modified", }, @@ -5686,6 +5759,20 @@ exports[`generator - Kubernetes gateway and ingressType nginx should match files "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "authenticationType": "oauth2", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080 + } +} ", "stateCleared": "modified", }, @@ -9124,6 +9211,35 @@ exports[`generator - Kubernetes gateway and mysql microservice should match file "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -9976,6 +10092,20 @@ exports[`generator - Kubernetes gateway with istio routing should match files sn "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -10972,6 +11102,93 @@ exports[`generator - Kubernetes gateway, mysql, psql, mongodb, mariadb, mssql mi "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "04-mongo/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmongodb", + "databaseType": "mongodb", + "entities": [], + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "07-mariadb/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmariadb", + "entities": [], + "prodDatabaseType": "mariadb", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "11-mssql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmssqldb", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mssql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -12972,6 +13189,22 @@ exports[`generator - Kubernetes monolith application should match files snapshot "serviceDiscoveryType": false } } +", + "stateCleared": "modified", + }, + "08-monolith/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "monolith", + "authenticationType": "session", + "baseName": "sampleMysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "searchEngine": "elasticsearch", + "serverPort": 8080 + } +} ", "stateCleared": "modified", }, @@ -13428,6 +13661,21 @@ exports[`generator - Kubernetes mysql microservice with custom namespace and jhi "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -16782,6 +17030,20 @@ exports[`generator - Kubernetes mysql microservice with custom namespace should "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081 + } +} ", "stateCleared": "modified", }, @@ -17473,6 +17735,93 @@ exports[`generator - Kubernetes mysql, psql, mongodb, mariadb, mssql microservic "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "04-mongo/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmongodb", + "databaseType": "mongodb", + "entities": [], + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "07-mariadb/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmariadb", + "entities": [], + "prodDatabaseType": "mariadb", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "11-mssql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmssqldb", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mssql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -19473,6 +19822,19 @@ exports[`generator - Kubernetes only gateway should match files snapshot 1`] = ` "serviceDiscoveryType": "consul" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080 + } +} ", "stateCleared": "modified", }, @@ -20146,6 +20508,20 @@ exports[`generator - Kubernetes only gateway with eureka should match files snap "serviceDiscoveryType": "eureka" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "eureka" + } +} ", "stateCleared": "modified", }, diff --git a/generators/kubernetes/generator.mjs b/generators/kubernetes/generator.mjs index 9ee89088eef6..65fc4f0e924b 100644 --- a/generators/kubernetes/generator.mjs +++ b/generators/kubernetes/generator.mjs @@ -20,7 +20,7 @@ import fs from 'fs'; import chalk from 'chalk'; -import BaseDockerGenerator from '../base-docker/index.mjs'; +import BaseWorkspacesGenerator from '../base-docker/index.mjs'; import prompts from './prompts.mjs'; import { writeFiles } from './files.mjs'; @@ -28,7 +28,7 @@ import { buildToolTypes, messageBrokerTypes } from '../../jdl/jhipster/index.mjs import { GENERATOR_KUBERNETES } from '../generator-list.mjs'; import statistics from '../statistics.mjs'; -import { checkImages, generateJwtSecret, configureImageNames, setAppsFolderPaths } from '../base-docker/docker-base.mjs'; +import { checkImages, generateJwtSecret, configureImageNames } from '../base-docker/docker-base.mjs'; import { checkKubernetes, loadConfig, @@ -37,15 +37,17 @@ import { derivedKubernetesPlatformProperties, } from './kubernetes-base.mjs'; import { getJdbcUrl, getR2dbcUrl } from '../spring-data-relational/support/index.mjs'; +import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; +import { checkDocker } from '../docker/support/index.mjs'; const { KAFKA } = messageBrokerTypes; const { MAVEN } = buildToolTypes; /** * @class - * @extends {BaseDockerGenerator} + * @extends {BaseWorkspacesGenerator} */ -export default class KubernetesGenerator extends BaseDockerGenerator { +export default class KubernetesGenerator extends BaseWorkspacesGenerator { async beforeQueue() { if (!this.fromBlueprint) { await this.composeWithBlueprints(GENERATOR_KUBERNETES); @@ -58,14 +60,15 @@ export default class KubernetesGenerator extends BaseDockerGenerator { this.log.log(chalk.white(`${chalk.bold('⎈')} Welcome to the JHipster Kubernetes Generator ${chalk.bold('⎈')}`)); this.log.log(chalk.white(`Files will be generated in folder: ${chalk.yellow(this.destinationRoot())}`)); }, - ...super.initializing, + loadDockerDependenciesTask, + checkDocker, checkKubernetes, loadConfig, setupKubernetesConstants, }; } - get [BaseDockerGenerator.INITIALIZING]() { + get [BaseWorkspacesGenerator.INITIALIZING]() { return this.delegateTasksToBlueprint(() => this.initializing); } @@ -90,7 +93,7 @@ export default class KubernetesGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.PROMPTING]() { + get [BaseWorkspacesGenerator.PROMPTING]() { return this.delegateTasksToBlueprint(() => this.prompting); } @@ -103,7 +106,6 @@ export default class KubernetesGenerator extends BaseDockerGenerator { checkImages, generateJwtSecret, configureImageNames, - setAppsFolderPaths, setPostPromptProp() { this.appConfigs.forEach(element => { @@ -120,7 +122,7 @@ export default class KubernetesGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.CONFIGURING]() { + get [BaseWorkspacesGenerator.CONFIGURING]() { return this.delegateTasksToBlueprint(() => this.configuring); } @@ -140,7 +142,7 @@ export default class KubernetesGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.LOADING]() { + get [BaseWorkspacesGenerator.LOADING]() { return this.delegateTasksToBlueprint(() => this.loading); } @@ -148,7 +150,7 @@ export default class KubernetesGenerator extends BaseDockerGenerator { return writeFiles(); } - get [BaseDockerGenerator.WRITING]() { + get [BaseWorkspacesGenerator.WRITING]() { return this.delegateTasksToBlueprint(() => this.writing); } @@ -217,7 +219,7 @@ export default class KubernetesGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.END]() { + get [BaseWorkspacesGenerator.END]() { return this.delegateTasksToBlueprint(() => this.end); } diff --git a/generators/openshift/__snapshots__/openshift.spec.mts.snap b/generators/openshift/__snapshots__/openshift.spec.mts.snap index 0e1f612584b4..f3931ac21472 100644 --- a/generators/openshift/__snapshots__/openshift.spec.mts.snap +++ b/generators/openshift/__snapshots__/openshift.spec.mts.snap @@ -21,6 +21,35 @@ exports[`generator - OpenShift gateway and one microservice with mysql should ma "storageType": "ephemeral" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -1052,6 +1081,92 @@ exports[`generator - OpenShift gateway with multiple microservices backed by mys "storageType": "ephemeral" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "04-mongo/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmongodb", + "databaseType": "mongodb", + "entities": [], + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "05-cassandra/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mscassandra", + "databaseType": "cassandra", + "entities": [], + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "07-mariadb/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmariadb", + "entities": [], + "prodDatabaseType": "mariadb", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -3389,6 +3504,22 @@ exports[`generator - OpenShift monolith application should match files snapshot "storageType": "ephemeral" } } +", + "stateCleared": "modified", + }, + "08-monolith/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "monolith", + "authenticationType": "session", + "baseName": "sampleMysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "searchEngine": "elasticsearch", + "serverPort": 8080 + } +} ", "stateCleared": "modified", }, @@ -3911,6 +4042,20 @@ exports[`generator - OpenShift only gateway should match files snapshot 1`] = ` "storageType": "ephemeral" } } +", + "stateCleared": "modified", + }, + "01-gateway/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "gateway", + "baseName": "jhgate", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8080, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, @@ -4608,6 +4753,36 @@ exports[`generator - OpenShift two microservices backed by mysql and postgres wi "storageType": "ephemeral" } } +", + "stateCleared": "modified", + }, + "02-mysql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "msmysql", + "databaseType": "sql", + "entities": [], + "prodDatabaseType": "mysql", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} +", + "stateCleared": "modified", + }, + "03-psql/.yo-rc.json": { + "contents": "{ + "generator-jhipster": { + "applicationType": "microservice", + "baseName": "mspsql", + "entities": [], + "prodDatabaseType": "postgresql", + "searchEngine": "elasticsearch", + "serverPort": 8081, + "serviceDiscoveryType": "consul" + } +} ", "stateCleared": "modified", }, diff --git a/generators/openshift/generator.mjs b/generators/openshift/generator.mjs index b2867e3d1077..c59e12a167c6 100644 --- a/generators/openshift/generator.mjs +++ b/generators/openshift/generator.mjs @@ -21,11 +21,11 @@ import chalk from 'chalk'; import shelljs from 'shelljs'; import runAsync from 'run-async'; -import BaseDockerGenerator from '../base-docker/index.mjs'; +import BaseWorkspacesGenerator from '../base-docker/index.mjs'; import prompts from './prompts.mjs'; import { GENERATOR_OPENSHIFT } from '../generator-list.mjs'; -import { loadFromYoRc, checkImages, generateJwtSecret, configureImageNames, setAppsFolderPaths } from '../base-docker/docker-base.mjs'; +import { loadFromYoRc, checkImages, generateJwtSecret, configureImageNames } from '../base-docker/docker-base.mjs'; import { setupKubernetesConstants } from '../kubernetes/kubernetes-base.mjs'; import statistics from '../statistics.mjs'; @@ -40,6 +40,8 @@ import { } from '../../jdl/jhipster/index.mjs'; import { writeFiles } from './files.mjs'; import { getJdbcUrl } from '../spring-data-relational/support/index.mjs'; +import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; +import { checkDocker } from '../docker/support/index.mjs'; const { KAFKA } = messageBrokerTypes; const { PROMETHEUS } = monitoringTypes; @@ -55,9 +57,9 @@ const { EPHEMERAL, PERSISTENT } = StorageTypes; /* eslint-disable consistent-return */ /** * @class - * @extends {BaseDockerGenerator} + * @extends {BaseWorkspacesGenerator} */ -export default class OpenshiftGenerator extends BaseDockerGenerator { +export default class OpenshiftGenerator extends BaseWorkspacesGenerator { async beforeQueue() { if (!this.fromBlueprint) { await this.composeWithBlueprints(GENERATOR_OPENSHIFT); @@ -76,9 +78,8 @@ export default class OpenshiftGenerator extends BaseDockerGenerator { ), ); }, - - ...super.initializing, - + loadDockerDependenciesTask, + checkDocker, checkOpenShift: runAsync(function () { if (this.skipChecks) return; const done = this.async(); @@ -106,7 +107,7 @@ export default class OpenshiftGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.INITIALIZING]() { + get [BaseWorkspacesGenerator.INITIALIZING]() { return this.delegateTasksToBlueprint(() => this.initializing); } @@ -125,7 +126,7 @@ export default class OpenshiftGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.PROMPTING]() { + get [BaseWorkspacesGenerator.PROMPTING]() { return this.delegateTasksToBlueprint(() => this.prompting); } @@ -138,7 +139,6 @@ export default class OpenshiftGenerator extends BaseDockerGenerator { checkImages, generateJwtSecret, configureImageNames, - setAppsFolderPaths, // place holder for future changes (may be prompt or something else) setRegistryReplicas() { @@ -173,7 +173,7 @@ export default class OpenshiftGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.CONFIGURING]() { + get [BaseWorkspacesGenerator.CONFIGURING]() { return this.delegateTasksToBlueprint(() => this.configuring); } @@ -193,7 +193,7 @@ export default class OpenshiftGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.LOADING]() { + get [BaseWorkspacesGenerator.LOADING]() { return this.delegateTasksToBlueprint(() => this.loading); } @@ -201,7 +201,7 @@ export default class OpenshiftGenerator extends BaseDockerGenerator { return writeFiles(); } - get [BaseDockerGenerator.WRITING]() { + get [BaseWorkspacesGenerator.WRITING]() { return this.delegateTasksToBlueprint(() => this.writing); } @@ -281,7 +281,7 @@ export default class OpenshiftGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.END]() { + get [BaseWorkspacesGenerator.END]() { return this.delegateTasksToBlueprint(() => this.end); } From 2ca8d8e8ef54e4decc51cd57e32f68846dfe36db Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 1 Sep 2023 18:30:21 -0300 Subject: [PATCH 06/27] reorganize base-docker --- generators/base-docker/utils.mjs | 27 ------------ generators/docker/generator.mjs | 2 +- .../docker/support/docker-compose-file.mjs | 44 +++++++++++++++++++ .../support/docker-compose-file.spec.mts} | 2 +- generators/docker/support/index.mts | 1 + 5 files changed, 47 insertions(+), 29 deletions(-) create mode 100644 generators/docker/support/docker-compose-file.mjs rename generators/{base-docker/utils.spec.mts => docker/support/docker-compose-file.spec.mts} (91%) diff --git a/generators/base-docker/utils.mjs b/generators/base-docker/utils.mjs index f91ea0db7272..a669729f2acc 100644 --- a/generators/base-docker/utils.mjs +++ b/generators/base-docker/utils.mjs @@ -5,33 +5,6 @@ import { buildToolTypes } from '../../jdl/index.js'; const { GRADLE } = buildToolTypes; const isWin32 = os.platform() === 'win32'; -/** - * Creates EditFileCallback that creates a base docker compose yml file if empty. - * - * @param {string} name Docker compose v2 project name - * @returns {import('../../generators/generator-base.js').EditFileCallback} - */ -export const createDockerComposeFile = ( - name = 'jhipster', -) => `# This configuration is intended for development purpose, it's **your** responsibility to harden it for production -name: ${name} -`; - -export const createDockerExtendedServices = (...services) => ({ - services: Object.fromEntries( - services.map(({ serviceName, serviceFile = `./${serviceName}.yml`, extendedServiceName = serviceName, additionalConfig = {} }) => [ - serviceName, - { - extends: { - file: serviceFile, - service: extendedServiceName, - }, - ...additionalConfig, - }, - ]), - ), -}); - /** * build a generated application. * diff --git a/generators/docker/generator.mjs b/generators/docker/generator.mjs index 4c3a345fa3c8..5933ef364f3a 100644 --- a/generators/docker/generator.mjs +++ b/generators/docker/generator.mjs @@ -18,7 +18,7 @@ */ /* eslint-disable camelcase */ import BaseApplicationGenerator from '../base-application/index.mjs'; -import { createDockerComposeFile, createDockerExtendedServices } from '../base-docker/utils.mjs'; +import { createDockerComposeFile, createDockerExtendedServices } from '../docker/support/index.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION_SERVER, GENERATOR_DOCKER } from '../generator-list.mjs'; import { dockerFiles } from './files.mjs'; import { SERVICE_COMPLETED_SUCCESSFULLY, SERVICE_HEALTHY } from './constants.mjs'; diff --git a/generators/docker/support/docker-compose-file.mjs b/generators/docker/support/docker-compose-file.mjs new file mode 100644 index 000000000000..f069afea73bb --- /dev/null +++ b/generators/docker/support/docker-compose-file.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2023 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. + */ +/** + * Creates EditFileCallback that creates a base docker compose yml file if empty. + * + * @param {string} name Docker compose v2 project name + * @returns {import('../../generators/generator-base.js').EditFileCallback} + */ +export const createDockerComposeFile = ( + name = 'jhipster', +) => `# This configuration is intended for development purpose, it's **your** responsibility to harden it for production +name: ${name} +`; + +export const createDockerExtendedServices = (...services) => ({ + services: Object.fromEntries( + services.map(({ serviceName, serviceFile = `./${serviceName}.yml`, extendedServiceName = serviceName, additionalConfig = {} }) => [ + serviceName, + { + extends: { + file: serviceFile, + service: extendedServiceName, + }, + ...additionalConfig, + }, + ]), + ), +}); diff --git a/generators/base-docker/utils.spec.mts b/generators/docker/support/docker-compose-file.spec.mts similarity index 91% rename from generators/base-docker/utils.spec.mts rename to generators/docker/support/docker-compose-file.spec.mts index 9361a447c2e2..923b38e23a8a 100644 --- a/generators/base-docker/utils.spec.mts +++ b/generators/docker/support/docker-compose-file.spec.mts @@ -1,5 +1,5 @@ import { expect } from 'esmocha'; -import { createDockerComposeFile } from './utils.mjs'; +import { createDockerComposeFile } from './docker-compose-file.mjs'; describe('generator - base-docker - utils', () => { describe('createDockerComposeFile', () => { diff --git a/generators/docker/support/index.mts b/generators/docker/support/index.mts index e1a435e304c8..01834fe61c79 100644 --- a/generators/docker/support/index.mts +++ b/generators/docker/support/index.mts @@ -17,3 +17,4 @@ * limitations under the License. */ export * from './check-docker.mjs'; +export * from './docker-compose-file.mjs'; From e079bd2bdf64a86b87650b86c59eaf235d5fd1b9 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 1 Sep 2023 18:33:36 -0300 Subject: [PATCH 07/27] rework base-docker apis --- generators/aws/generator.mjs | 2 +- generators/azure-app-service/generator.mjs | 2 +- generators/azure-spring-cloud/generator.mjs | 2 +- generators/cloudfoundry/generator.mjs | 2 +- generators/heroku/generator.mjs | 2 +- .../internal/build-application.mjs} | 20 ++++++++++++++++++- generators/server/internal/index.mts | 19 ++++++++++++++++++ 7 files changed, 43 insertions(+), 6 deletions(-) rename generators/{base-docker/utils.mjs => server/internal/build-application.mjs} (53%) create mode 100644 generators/server/internal/index.mts diff --git a/generators/aws/generator.mjs b/generators/aws/generator.mjs index f02bdde579ea..2842a9eb7d8c 100644 --- a/generators/aws/generator.mjs +++ b/generators/aws/generator.mjs @@ -25,7 +25,7 @@ import AwsFactory from './lib/aws.mjs'; import statistics from '../statistics.mjs'; import { GENERATOR_AWS } from '../generator-list.mjs'; import { databaseTypes } from '../../jdl/jhipster/index.mjs'; -import { buildApplication } from '../base-docker/utils.mjs'; +import { buildApplication } from '../server/internal/index.mjs'; const { MYSQL, POSTGRESQL, MARIADB } = databaseTypes; diff --git a/generators/azure-app-service/generator.mjs b/generators/azure-app-service/generator.mjs index 489deb6df1db..d8f7796b5e8d 100644 --- a/generators/azure-app-service/generator.mjs +++ b/generators/azure-app-service/generator.mjs @@ -32,7 +32,7 @@ import { JAVA_VERSION, SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; import { GENERATOR_AZURE_APP_SERVICE } from '../generator-list.mjs'; import { buildToolTypes } from '../../jdl/jhipster/index.mjs'; import { mavenPluginConfiguration } from './templates.mjs'; -import { buildApplication } from '../base-docker/utils.mjs'; +import { buildApplication } from '../server/internal/index.mjs'; const isWin32 = os.platform() === 'win32'; diff --git a/generators/azure-spring-cloud/generator.mjs b/generators/azure-spring-cloud/generator.mjs index 742d9f7ff46c..386896e6d7a6 100644 --- a/generators/azure-spring-cloud/generator.mjs +++ b/generators/azure-spring-cloud/generator.mjs @@ -32,7 +32,7 @@ import { GENERATOR_AZURE_SPRING_CLOUD } from '../generator-list.mjs'; import { mavenProfile } from './templates.mjs'; import { createPomStorage } from '../maven/support/pom-store.mjs'; import { getFrontendAppName } from '../base/support/index.mjs'; -import { buildApplication } from '../base-docker/utils.mjs'; +import { buildApplication } from '../server/internal/index.mjs'; const { MEMCACHED } = cacheTypes; diff --git a/generators/cloudfoundry/generator.mjs b/generators/cloudfoundry/generator.mjs index ac3bddd13c12..a8d34c9a3b51 100644 --- a/generators/cloudfoundry/generator.mjs +++ b/generators/cloudfoundry/generator.mjs @@ -30,7 +30,7 @@ import { CLIENT_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR } from '../generator-constants import { GENERATOR_CLOUDFOUNDRY } from '../generator-list.mjs'; import { cacheTypes, buildToolTypes, databaseTypes } from '../../jdl/jhipster/index.mjs'; import { getFrontendAppName } from '../base/support/index.mjs'; -import { buildApplication } from '../base-docker/utils.mjs'; +import { buildApplication } from '../server/internal/index.mjs'; const { MEMCACHED } = cacheTypes; const { GRADLE, MAVEN } = buildToolTypes; diff --git a/generators/heroku/generator.mjs b/generators/heroku/generator.mjs index 787fdebf5fb0..9a68fe77e7e9 100644 --- a/generators/heroku/generator.mjs +++ b/generators/heroku/generator.mjs @@ -43,7 +43,7 @@ import { mavenProfileContent } from './templates.mjs'; import { createPomStorage } from '../maven/support/pom-store.mjs'; import { addGradlePluginCallback, applyFromGradleCallback } from '../gradle/internal/needles.mjs'; import { getFrontendAppName } from '../base/support/index.mjs'; -import { buildApplication } from '../base-docker/utils.mjs'; +import { buildApplication } from '../server/internal/index.mjs'; const cacheProviderOptions = cacheTypes; const { MEMCACHED, REDIS } = cacheTypes; diff --git a/generators/base-docker/utils.mjs b/generators/server/internal/build-application.mjs similarity index 53% rename from generators/base-docker/utils.mjs rename to generators/server/internal/build-application.mjs index a669729f2acc..b1a0e22dd99e 100644 --- a/generators/base-docker/utils.mjs +++ b/generators/server/internal/build-application.mjs @@ -1,6 +1,24 @@ +/** + * Copyright 2013-2023 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 os from 'os'; import { exec } from 'child_process'; -import { buildToolTypes } from '../../jdl/index.js'; +import { buildToolTypes } from '../../../jdl/index.js'; const { GRADLE } = buildToolTypes; const isWin32 = os.platform() === 'win32'; diff --git a/generators/server/internal/index.mts b/generators/server/internal/index.mts new file mode 100644 index 000000000000..561117944595 --- /dev/null +++ b/generators/server/internal/index.mts @@ -0,0 +1,19 @@ +/** + * Copyright 2013-2023 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 * from './build-application.mjs'; From 7c3de0a941774bc0aab6d64c8741ef65532d49e2 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 1 Sep 2023 23:28:32 -0300 Subject: [PATCH 08/27] continue base-docker removal --- generators/base-docker/docker-base.mjs | 3 +- generators/base-docker/docker-prompts.mjs | 22 ++++----- generators/base-docker/generator.mjs | 22 --------- .../base-workspaces/internal/deployments.mts | 47 +++++++++++++++++++ generators/base-workspaces/internal/index.mts | 1 + .../docker-compose.spec.mts.snap | 35 ++++++++++---- generators/docker-compose/generator.mjs | 3 +- .../kubernetes.helm.spec.mts.snap | 28 +++++++---- generators/kubernetes-helm/generator.mjs | 4 +- .../__snapshots__/knative.spec.mts.snap | 28 +++++------ generators/kubernetes-knative/generator.mjs | 4 +- .../__snapshots__/kubernetes.spec.mts.snap | 39 ++++++++++----- generators/kubernetes/generator.mjs | 4 +- .../__snapshots__/openshift.spec.mts.snap | 15 ++++-- generators/openshift/generator.mjs | 4 +- jdl/jhipster/deployment-options.spec.ts | 12 ++--- jdl/jhipster/deployment-options.ts | 12 ++--- 17 files changed, 178 insertions(+), 105 deletions(-) create mode 100644 generators/base-workspaces/internal/deployments.mts diff --git a/generators/base-docker/docker-base.mjs b/generators/base-docker/docker-base.mjs index cd769ca16ff4..57ff83c2bacb 100644 --- a/generators/base-docker/docker-base.mjs +++ b/generators/base-docker/docker-base.mjs @@ -22,6 +22,7 @@ import chalk from 'chalk'; import { convertSecretToBase64, createBase64Secret, removeFieldsWithNullishValues } from '../base/support/index.mjs'; import { applicationTypes, buildToolTypes, getConfigWithDefaults } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; +import { loadDeploymentConfig } from '../base-workspaces/internal/index.mjs'; const { MAVEN } = buildToolTypes; const { MONOLITH, MICROSERVICE, GATEWAY } = applicationTypes; @@ -130,7 +131,7 @@ export function setClusteredApps() { } export function loadFromYoRc() { - this.loadDeploymentConfig(); + loadDeploymentConfig.call(this); this.useKafka = false; this.usePulsar = false; diff --git a/generators/base-docker/docker-prompts.mjs b/generators/base-docker/docker-prompts.mjs index 41d00e4f3746..d46ad81fbe18 100644 --- a/generators/base-docker/docker-prompts.mjs +++ b/generators/base-docker/docker-prompts.mjs @@ -70,7 +70,7 @@ async function askForApplicationType() { }, ]; - const props = await this.prompt(prompts); + const props = await this.prompt(prompts, this.config); this.deploymentApplicationType = props.deploymentApplicationType; } @@ -96,7 +96,7 @@ async function askForGatewayType() { }, ]; - const props = await this.prompt(prompts); + const props = await this.prompt(prompts, this.config); this.gatewayType = props.gatewayType; } @@ -134,7 +134,7 @@ async function askForPath() { }, ]; - const props = await this.prompt(prompts); + const props = await this.prompt(prompts, this.config); this.directoryPath = props.directoryPath; // Patch the path if there is no trailing "/" if (!this.directoryPath.endsWith('/')) { @@ -167,14 +167,14 @@ async function askForApps() { type: 'checkbox', name: 'chosenApps', message: messageAskForApps, - choices: this.appsFolders, + choices: this.appsFolders ?? [], default: this.defaultAppsFolders, validate: input => (input.length === 0 ? 'Please choose at least one application' : true), }, ]; const props = await this.prompt(prompts); - this.appsFolders = props.chosenApps; + this.appsFolders = this.jhipsterConfig.appsFolders = props.chosenApps; loadConfigs.call(this); } @@ -202,7 +202,7 @@ async function askForClustersMode() { }, ]; - const props = await this.prompt(prompts); + const props = await this.prompt(prompts, this.config); this.clusteredDbApps = props.clusteredDbApps; setClusteredApps.call(this); } @@ -232,7 +232,7 @@ async function askForMonitoring() { }, ]; - const props = await this.prompt(prompts); + const props = await this.prompt(prompts, this.config); this.monitoring = props.monitoring; } @@ -295,7 +295,7 @@ async function askForServiceDiscovery() { }, ]; - const props = this.prompt(prompts); + const props = this.prompt(prompts, this.config); this.serviceDiscoveryType = props.serviceDiscoveryType; } } @@ -316,7 +316,7 @@ async function askForAdminPassword() { }, ]; - const props = await this.prompt(prompts); + const props = await this.prompt(prompts, this.config); this.adminPassword = props.adminPassword; this.adminPasswordBase64 = convertSecretToBase64(this.adminPassword); } @@ -336,7 +336,7 @@ async function askForDockerRepositoryName() { }, ]; - const props = await this.prompt(prompts); + const props = await this.prompt(prompts, this.config); this.dockerRepositoryName = props.dockerRepositoryName; } @@ -355,7 +355,7 @@ async function askForDockerPushCommand() { }, ]; - const props = await this.prompt(prompts); + const props = await this.prompt(prompts, this.config); this.dockerPushCommand = props.dockerPushCommand; } diff --git a/generators/base-docker/generator.mjs b/generators/base-docker/generator.mjs index ce1ef553d533..fe929d4480cd 100644 --- a/generators/base-docker/generator.mjs +++ b/generators/base-docker/generator.mjs @@ -16,21 +16,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import _ from 'lodash'; import prompts from './docker-prompts.mjs'; import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; import { loadFromYoRc, checkDocker, checkImages, generateJwtSecret } from './docker-base.mjs'; import statistics from '../statistics.mjs'; -import { applicationOptions, deploymentOptions } from '../../jdl/jhipster/index.mjs'; import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; -const { OptionNames } = applicationOptions; -const { Options: DeploymentOptions } = deploymentOptions; - -const { JWT_SECRET_KEY } = OptionNames; - /** * @class * @extends {BaseWorkspacesGenerator} @@ -80,19 +73,4 @@ export default class BaseDockerGenerator extends BaseWorkspacesGenerator { generateJwtSecret, }; } - - loadDeploymentConfig( - config = _.defaults({}, this.jhipsterConfig, DeploymentOptions.defaults(this.jhipsterConfig.deploymentType)), - dest = this, - ) { - dest.appsFolders = config.appsFolders; - dest.directoryPath = config.directoryPath; - dest.gatewayType = config.gatewayType; - dest.clusteredDbApps = config.clusteredDbApps; - dest.dockerRepositoryName = config.dockerRepositoryName; - dest.dockerPushCommand = config.dockerPushCommand; - dest.adminPassword = config.adminPassword; - dest.jwtSecretKey = config[JWT_SECRET_KEY]; - this.loadPlatformConfig(config, dest); - } } diff --git a/generators/base-workspaces/internal/deployments.mts b/generators/base-workspaces/internal/deployments.mts new file mode 100644 index 000000000000..a7c6ab5938de --- /dev/null +++ b/generators/base-workspaces/internal/deployments.mts @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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 _ from 'lodash'; +import { applicationOptions, deploymentOptions } from '../../../jdl/index.js'; +import { loadDerivedPlatformConfig, loadPlatformConfig, loadServerAndPlatformConfig } from '../../server/support/index.mjs'; +import type { GeneratorBaseCore } from '../../index.js'; + +const { OptionNames } = applicationOptions; +const { Options: DeploymentOptions } = deploymentOptions; + +const { JWT_SECRET_KEY } = OptionNames; + +export function loadDeploymentConfig( + this: GeneratorBaseCore, + { + config = _.defaults({}, this.jhipsterConfig, DeploymentOptions.defaults(this.jhipsterConfig.deploymentType)), + deployment = this, + }: { config?: any; deployment?: any } = {}, +) { + deployment.appsFolders = config.appsFolders; + deployment.directoryPath = config.directoryPath; + deployment.gatewayType = config.gatewayType; + deployment.clusteredDbApps = config.clusteredDbApps; + deployment.dockerRepositoryName = config.dockerRepositoryName; + deployment.dockerPushCommand = config.dockerPushCommand; + deployment.adminPassword = config.adminPassword; + deployment.jwtSecretKey = config[JWT_SECRET_KEY]; + loadPlatformConfig({ config, application: deployment }); + loadDerivedPlatformConfig({ application: deployment }); + loadServerAndPlatformConfig({ application: deployment }); +} diff --git a/generators/base-workspaces/internal/index.mts b/generators/base-workspaces/internal/index.mts index 213a6044416e..de854f32ef34 100644 --- a/generators/base-workspaces/internal/index.mts +++ b/generators/base-workspaces/internal/index.mts @@ -16,4 +16,5 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +export * from './deployments.mjs'; export * from './docker-dependencies.mjs'; diff --git a/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap b/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap index 0356b2f6a680..b0500c311752 100644 --- a/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap +++ b/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap @@ -14,6 +14,7 @@ exports[`generator - Docker Compose gateway and 1 microservice, with 1 couchbase "clusteredDbApps": [ "10-couchbase" ], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -212,7 +213,8 @@ exports[`generator - Docker Compose gateway and 1 microservice, with Cassandra s ], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -419,6 +421,7 @@ exports[`generator - Docker Compose gateway and multi microservices should match "baseName": "workspaces", "clientPackageManager": "npm", "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -804,6 +807,7 @@ exports[`generator - Docker Compose gateway and multi microservices using oauth2 "baseName": "workspaces", "clientPackageManager": "npm", "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -1262,6 +1266,7 @@ exports[`generator - Docker Compose gateway and multi microservices, with 1 mong "clusteredDbApps": [ "04-mongo" ], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -1588,6 +1593,7 @@ exports[`generator - Docker Compose gateway and multi microservices, with couchb "baseName": "workspaces", "clientPackageManager": "npm", "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -1973,7 +1979,8 @@ exports[`generator - Docker Compose gateway and one microservice should match fi ], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -2172,7 +2179,8 @@ exports[`generator - Docker Compose gateway and one microservice, with curator s ], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -2371,7 +2379,8 @@ exports[`generator - Docker Compose gateway and one microservice, with prometheu ], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -2684,7 +2693,8 @@ exports[`generator - Docker Compose gateway and one microservice, without monito ], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -2882,7 +2892,8 @@ exports[`generator - Docker Compose monolith should match files snapshot 1`] = ` ], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "monolith", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -3007,7 +3018,8 @@ exports[`generator - Docker Compose one microservice and a directory path withou ], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -3145,7 +3157,8 @@ exports[`generator - Docker Compose only gateway should match files snapshot 1`] ], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -3285,7 +3298,8 @@ exports[`generator - Docker Compose only one microservice should match files sna ], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", @@ -3423,7 +3437,8 @@ exports[`generator - Docker Compose oracle monolith should match files snapshot ], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "monolith", "directoryPath": "./", "gatewayType": "SpringCloudGateway", "jwtSecretKey": "SECRET--50", diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index e396b40bbf17..ab964bc76517 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -38,6 +38,7 @@ import { } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; import { stringHashCode, createFaker } from '../base/support/index.mjs'; +import { loadDeploymentConfig } from '../base-workspaces/internal/deployments.mjs'; const { GATEWAY, MONOLITH } = applicationTypes; const { PROMETHEUS } = monitoringTypes; @@ -329,7 +330,7 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { get loading() { return { loadPlatformConfig() { - this.loadDeploymentConfig(this); + loadDeploymentConfig.call(this); }, }; } diff --git a/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap b/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap index 991acf7b283d..3709797ea7f6 100644 --- a/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap +++ b/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap @@ -8,7 +8,8 @@ exports[`generator - Kubernetes Helm Kafka application should match files snapsh "appsFolders": ["09-kafka"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "monolith", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -412,7 +413,8 @@ exports[`generator - Kubernetes Helm MySQL and PostgreSQL microservices without "appsFolders": ["02-mysql", "03-psql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -1330,7 +1332,8 @@ exports[`generator - Kubernetes Helm gateway and ingress should match files snap "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -1994,7 +1997,8 @@ exports[`generator - Kubernetes Helm gateway and mysql microservice should match "appsFolders": ["01-gateway", "02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -2836,7 +2840,8 @@ exports[`generator - Kubernetes Helm gateway with istio should match files snaps "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -3733,6 +3738,7 @@ exports[`generator - Kubernetes Helm gateway, mysql, psql, mongodb, mariadb micr "baseName": "workspaces", "clientPackageManager": "npm", "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -5249,7 +5255,8 @@ exports[`generator - Kubernetes Helm monolith application should match files sna "appsFolders": ["08-monolith"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "monolith", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -5639,7 +5646,8 @@ exports[`generator - Kubernetes Helm mysql microservice with custom namespace an "appsFolders": ["02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -8635,7 +8643,8 @@ exports[`generator - Kubernetes Helm mysql microservice with custom namespace sh "appsFolders": ["02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -9284,7 +9293,8 @@ exports[`generator - Kubernetes Helm only gateway should match files snapshot 1` "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipsterrepository", diff --git a/generators/kubernetes-helm/generator.mjs b/generators/kubernetes-helm/generator.mjs index f233377bcd0a..765374fa0d29 100644 --- a/generators/kubernetes-helm/generator.mjs +++ b/generators/kubernetes-helm/generator.mjs @@ -38,7 +38,7 @@ import { import statistics from '../statistics.mjs'; import { messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; import { getJdbcUrl, getR2dbcUrl } from '../spring-data-relational/support/index.mjs'; -import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; +import { loadDeploymentConfig, loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; import { checkDocker } from '../docker/support/index.mjs'; const { KAFKA } = messageBrokerTypes; @@ -134,7 +134,7 @@ export default class KubernetesHelmGenerator extends BaseWorkspacesGenerator { this.loadDerivedAppConfig(element); this.loadDerivedServerConfig(element); }); - this.loadDeploymentConfig(this); + loadDeploymentConfig.call(this); derivedKubernetesPlatformProperties(this); }, }; diff --git a/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap b/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap index faac690a6dac..96ed48935b35 100644 --- a/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap +++ b/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap @@ -8,7 +8,7 @@ exports[`generator - Knative Using Helm generator type MySQL and PostgreSQL micr "appsFolders": ["02-mysql", "03-psql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -1109,7 +1109,7 @@ exports[`generator - Knative Using Helm generator type gateway and ingress shoul "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -1950,7 +1950,7 @@ exports[`generator - Knative Using Helm generator type gateway and mysql microse "appsFolders": ["01-gateway", "02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -3019,7 +3019,7 @@ exports[`generator - Knative Using Helm generator type gateway with istio routin "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -5706,7 +5706,7 @@ exports[`generator - Knative Using Helm generator type mysql microservice with c "appsFolders": ["02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -8901,7 +8901,7 @@ exports[`generator - Knative Using Helm generator type mysql microservice with c "appsFolders": ["02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -9699,7 +9699,7 @@ exports[`generator - Knative Using Helm generator type only gateway should match "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipsterrepository", @@ -10549,7 +10549,7 @@ exports[`generator - Knative Using K8s generator type MySQL and PostgreSQL micro "appsFolders": ["02-mysql", "03-psql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -11572,7 +11572,7 @@ exports[`generator - Knative Using K8s generator type gateway and ingress should "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -12342,7 +12342,7 @@ exports[`generator - Knative Using K8s generator type gateway and mysql microser "appsFolders": ["01-gateway", "02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -13325,7 +13325,7 @@ exports[`generator - Knative Using K8s generator type gateway with istio routing "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -16334,7 +16334,7 @@ exports[`generator - Knative Using K8s generator type mysql microservice with cu "appsFolders": ["02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -19752,7 +19752,7 @@ exports[`generator - Knative Using K8s generator type mysql microservice with cu "appsFolders": ["02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -20478,7 +20478,7 @@ exports[`generator - Knative Using K8s generator type only gateway should match "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipsterrepository", diff --git a/generators/kubernetes-knative/generator.mjs b/generators/kubernetes-knative/generator.mjs index 133721bf6fe1..a251dbd34f7f 100644 --- a/generators/kubernetes-knative/generator.mjs +++ b/generators/kubernetes-knative/generator.mjs @@ -40,7 +40,7 @@ import { import statistics from '../statistics.mjs'; import { kubernetesPlatformTypes, buildToolTypes, messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; import { getJdbcUrl } from '../spring-data-relational/support/index.mjs'; -import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; +import { loadDeploymentConfig, loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; import { checkDocker } from '../docker/support/index.mjs'; const { GeneratorTypes } = kubernetesPlatformTypes; @@ -158,7 +158,7 @@ export default class KubernetesKnativeGenerator extends BaseWorkspacesGenerator this.loadDerivedAppConfig(element); this.loadDerivedServerConfig(element); }); - this.loadDeploymentConfig(this); + loadDeploymentConfig.call(this); derivedKubernetesPlatformProperties(this); }, }; diff --git a/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap b/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap index 20ce860232cb..ffda6bbe34b3 100644 --- a/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap +++ b/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap @@ -8,7 +8,8 @@ exports[`generator - Kubernetes Kafka application should match files snapshot 1` "appsFolders": ["09-kafka"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "monolith", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -507,7 +508,8 @@ exports[`generator - Kubernetes MySQL and PostgreSQL microservices without gatew "appsFolders": ["02-mysql", "03-psql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -1496,7 +1498,8 @@ exports[`generator - Kubernetes gateway and ingress should match files snapshot "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -2201,7 +2204,8 @@ exports[`generator - Kubernetes gateway and ingressType gke should match files s "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -5742,7 +5746,8 @@ exports[`generator - Kubernetes gateway and ingressType nginx should match files "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -9195,7 +9200,8 @@ exports[`generator - Kubernetes gateway and mysql microservice should match file "appsFolders": ["01-gateway", "02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -10076,7 +10082,8 @@ exports[`generator - Kubernetes gateway with istio routing should match files sn "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -11080,6 +11087,7 @@ exports[`generator - Kubernetes gateway, mysql, psql, mongodb, mariadb, mssql mi "baseName": "workspaces", "clientPackageManager": "npm", "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -13173,7 +13181,8 @@ exports[`generator - Kubernetes monolith application should match files snapshot "appsFolders": ["08-monolith"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "monolith", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -13645,7 +13654,8 @@ exports[`generator - Kubernetes mysql microservice with custom namespace and jhi "appsFolders": ["02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -17014,7 +17024,8 @@ exports[`generator - Kubernetes mysql microservice with custom namespace should "appsFolders": ["02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -17713,6 +17724,7 @@ exports[`generator - Kubernetes mysql, psql, mongodb, mariadb, mssql microservic "baseName": "workspaces", "clientPackageManager": "npm", "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipster", @@ -19806,7 +19818,8 @@ exports[`generator - Kubernetes only gateway should match files snapshot 1`] = ` "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "gateway", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipsterrepository", @@ -20489,10 +20502,12 @@ exports[`generator - Kubernetes only gateway with eureka should match files snap ".yo-rc.json": { "contents": "{ "generator-jhipster": { + "adminPassword": "meetup", "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "monolith", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "jhipsterrepository", diff --git a/generators/kubernetes/generator.mjs b/generators/kubernetes/generator.mjs index 65fc4f0e924b..5f102abda38d 100644 --- a/generators/kubernetes/generator.mjs +++ b/generators/kubernetes/generator.mjs @@ -37,7 +37,7 @@ import { derivedKubernetesPlatformProperties, } from './kubernetes-base.mjs'; import { getJdbcUrl, getR2dbcUrl } from '../spring-data-relational/support/index.mjs'; -import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; +import { loadDeploymentConfig, loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; import { checkDocker } from '../docker/support/index.mjs'; const { KAFKA } = messageBrokerTypes; @@ -136,7 +136,7 @@ export default class KubernetesGenerator extends BaseWorkspacesGenerator { this.loadDerivedAppConfig(element); this.loadDerivedServerConfig(element); }); - this.loadDeploymentConfig(this); + loadDeploymentConfig.call(this); derivedKubernetesPlatformProperties(this); }, }; diff --git a/generators/openshift/__snapshots__/openshift.spec.mts.snap b/generators/openshift/__snapshots__/openshift.spec.mts.snap index f3931ac21472..b5202f8ec772 100644 --- a/generators/openshift/__snapshots__/openshift.spec.mts.snap +++ b/generators/openshift/__snapshots__/openshift.spec.mts.snap @@ -8,7 +8,8 @@ exports[`generator - OpenShift gateway and one microservice with mysql should ma "appsFolders": ["01-gateway", "02-mysql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "ocrepo", @@ -1061,7 +1062,8 @@ exports[`generator - OpenShift gateway with multiple microservices backed by mys ], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "ocrepo", @@ -3491,7 +3493,8 @@ exports[`generator - OpenShift monolith application should match files snapshot "appsFolders": ["08-monolith"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "monolith", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "ocrepo", @@ -4029,7 +4032,8 @@ exports[`generator - OpenShift only gateway should match files snapshot 1`] = ` "appsFolders": ["01-gateway"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "ocrepo", @@ -4740,7 +4744,8 @@ exports[`generator - OpenShift two microservices backed by mysql and postgres wi "appsFolders": ["02-mysql", "03-psql"], "baseName": "workspaces", "clientPackageManager": "npm", - "clusteredDbApps": {}, + "clusteredDbApps": [], + "deploymentApplicationType": "microservice", "directoryPath": "./", "dockerPushCommand": "docker push", "dockerRepositoryName": "ocrepo", diff --git a/generators/openshift/generator.mjs b/generators/openshift/generator.mjs index c59e12a167c6..0822ade2b819 100644 --- a/generators/openshift/generator.mjs +++ b/generators/openshift/generator.mjs @@ -40,7 +40,7 @@ import { } from '../../jdl/jhipster/index.mjs'; import { writeFiles } from './files.mjs'; import { getJdbcUrl } from '../spring-data-relational/support/index.mjs'; -import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; +import { loadDeploymentConfig, loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; import { checkDocker } from '../docker/support/index.mjs'; const { KAFKA } = messageBrokerTypes; @@ -187,7 +187,7 @@ export default class OpenshiftGenerator extends BaseWorkspacesGenerator { this.loadDerivedAppConfig(element); this.loadDerivedServerConfig(element); }); - this.loadDeploymentConfig(this); + loadDeploymentConfig.call(this); this._loadDerivedOpenshiftConfig(this); }, }; diff --git a/jdl/jhipster/deployment-options.spec.ts b/jdl/jhipster/deployment-options.spec.ts index fee78f1de439..d21039b0f051 100644 --- a/jdl/jhipster/deployment-options.spec.ts +++ b/jdl/jhipster/deployment-options.spec.ts @@ -52,8 +52,8 @@ describe('jdl - DeploymentOptions', () => { context('when passing no args', () => { it('should return docker deployment config', () => { expect(Options.defaults()).to.eql({ - appsFolders: new Set(), - clusteredDbApps: new Set(), + appsFolders: [], + clusteredDbApps: [], directoryPath: '../', gatewayType: 'SpringCloudGateway', monitoring: 'no', @@ -64,8 +64,8 @@ describe('jdl - DeploymentOptions', () => { context('when passing kubernetes as arg', () => { it('should return kubernetes deployment config', () => { expect(Options.defaults('kubernetes')).to.eql({ - appsFolders: new Set(), - clusteredDbApps: new Set(), + appsFolders: [], + clusteredDbApps: [], directoryPath: '../', dockerPushCommand: 'docker push', dockerRepositoryName: '', @@ -83,8 +83,8 @@ describe('jdl - DeploymentOptions', () => { context('when passing openshift as arg', () => { it('should return openshift deployment config', () => { expect(Options.defaults('openshift')).to.eql({ - appsFolders: new Set(), - clusteredDbApps: new Set(), + appsFolders: [], + clusteredDbApps: [], directoryPath: '../', dockerPushCommand: 'docker push', dockerRepositoryName: '', diff --git a/jdl/jhipster/deployment-options.ts b/jdl/jhipster/deployment-options.ts index 421b398894b4..05829d44c9a0 100644 --- a/jdl/jhipster/deployment-options.ts +++ b/jdl/jhipster/deployment-options.ts @@ -115,9 +115,9 @@ const Options: any = { Options.defaults = (deploymentType = Options.deploymentType.dockerCompose) => { if (deploymentType === Options.deploymentType.kubernetes) { return { - appsFolders: new Set(), + appsFolders: [], directoryPath: Options.directoryPath, - clusteredDbApps: new Set(), + clusteredDbApps: [], serviceDiscoveryType: Options.serviceDiscoveryType.consul, dockerRepositoryName: Options.dockerRepositoryName, dockerPushCommand: Options.dockerPushCommand, @@ -133,19 +133,19 @@ Options.defaults = (deploymentType = Options.deploymentType.dockerCompose) => { if (deploymentType === Options.deploymentType.dockerCompose) { return { - appsFolders: new Set(), + appsFolders: [], directoryPath: Options.directoryPath, gatewayType: Options.gatewayType.springCloudGateway, - clusteredDbApps: new Set(), + clusteredDbApps: [], monitoring: Options.monitoring.no, serviceDiscoveryType: Options.serviceDiscoveryType.consul, }; } return { - appsFolders: new Set(), + appsFolders: [], directoryPath: Options.directoryPath, - clusteredDbApps: new Set(), + clusteredDbApps: [], serviceDiscoveryType: Options.serviceDiscoveryType.consul, monitoring: Options.monitoring.no, dockerRepositoryName: Options.dockerRepositoryName, From 2d4c4942f24de980bb42b9e2b0182b4453d87c2e Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 1 Sep 2023 23:43:14 -0300 Subject: [PATCH 09/27] continue base-docker removal --- generators/base-docker/generator.mjs | 38 ------------------- generators/base-workspaces/generator.mts | 4 +- .../internal}/docker-base.mjs | 10 ++--- .../docker-prompts.mjs | 2 +- generators/docker-compose/generator.mjs | 27 +++++++++++-- generators/gae/generator.mjs | 2 +- generators/kubernetes-helm/generator.mjs | 2 +- generators/kubernetes-knative/generator.mjs | 2 +- generators/kubernetes/generator.mjs | 2 +- generators/kubernetes/kubernetes-base.mjs | 2 +- generators/kubernetes/prompts.mjs | 2 +- generators/openshift/generator.mjs | 2 +- generators/openshift/prompts.mjs | 2 +- 13 files changed, 41 insertions(+), 56 deletions(-) rename generators/{base-docker => base-workspaces/internal}/docker-base.mjs (94%) rename generators/{base-docker => docker-compose}/docker-prompts.mjs (99%) diff --git a/generators/base-docker/generator.mjs b/generators/base-docker/generator.mjs index fe929d4480cd..00d82d83d6bd 100644 --- a/generators/base-docker/generator.mjs +++ b/generators/base-docker/generator.mjs @@ -17,12 +17,7 @@ * limitations under the License. */ -import prompts from './docker-prompts.mjs'; import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; -import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; -import { loadFromYoRc, checkDocker, checkImages, generateJwtSecret } from './docker-base.mjs'; -import statistics from '../statistics.mjs'; -import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; /** * @class @@ -40,37 +35,4 @@ export default class BaseDockerGenerator extends BaseWorkspacesGenerator { this.regenerate = this.options.skipPrompts; } - - get initializing() { - return { - loadDockerDependenciesTask, - checkDocker, - loadFromYoRc, - }; - } - - get prompting() { - return { - askForApplicationType: prompts.askForApplicationType, - askForGatewayType: prompts.askForGatewayType, - askForPath: prompts.askForPath, - askForApps: prompts.askForApps, - askForClustersMode: prompts.askForClustersMode, - askForMonitoring: prompts.askForMonitoring, - askForConsoleOptions: prompts.askForConsoleOptions, - askForServiceDiscovery: prompts.askForServiceDiscovery, - askForAdminPassword: prompts.askForAdminPassword, - }; - } - - get configuring() { - return { - insight() { - statistics.sendSubGenEvent('generator', GENERATOR_DOCKER_COMPOSE); - }, - - checkImages, - generateJwtSecret, - }; - } } diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts index e8e34be8e236..b9dbc510c4f3 100644 --- a/generators/base-workspaces/generator.mts +++ b/generators/base-workspaces/generator.mts @@ -66,7 +66,9 @@ export default class BaseWorkspacesGenerator extends BaseGenerator { async bootstrapApplications() { for (const resolvedApplicationFolder of await this.resolveApplicationFolders()) { - await this.composeWithJHipster(GENERATOR_BOOTSTRAP_APPLICATION, { generatorOptions: { destinationRoot: resolvedApplicationFolder } }); + await this.composeWithJHipster(GENERATOR_BOOTSTRAP_APPLICATION, { + generatorOptions: { destinationRoot: resolvedApplicationFolder }, + } as any); } } diff --git a/generators/base-docker/docker-base.mjs b/generators/base-workspaces/internal/docker-base.mjs similarity index 94% rename from generators/base-docker/docker-base.mjs rename to generators/base-workspaces/internal/docker-base.mjs index 57ff83c2bacb..e261c4a97091 100644 --- a/generators/base-docker/docker-base.mjs +++ b/generators/base-workspaces/internal/docker-base.mjs @@ -19,15 +19,15 @@ import { existsSync } from 'fs'; import chalk from 'chalk'; -import { convertSecretToBase64, createBase64Secret, removeFieldsWithNullishValues } from '../base/support/index.mjs'; -import { applicationTypes, buildToolTypes, getConfigWithDefaults } from '../../jdl/jhipster/index.mjs'; -import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; -import { loadDeploymentConfig } from '../base-workspaces/internal/index.mjs'; +import { convertSecretToBase64, createBase64Secret, removeFieldsWithNullishValues } from '../../base/support/index.mjs'; +import { applicationTypes, buildToolTypes, getConfigWithDefaults } from '../../../jdl/jhipster/index.mjs'; +import { GENERATOR_JHIPSTER } from '../../generator-constants.mjs'; +import { loadDeploymentConfig } from '../../base-workspaces/internal/index.mjs'; const { MAVEN } = buildToolTypes; const { MONOLITH, MICROSERVICE, GATEWAY } = applicationTypes; -export { checkDocker } from '../docker/support/index.mjs'; +export { checkDocker } from '../../docker/support/index.mjs'; /** * Check Images diff --git a/generators/base-docker/docker-prompts.mjs b/generators/docker-compose/docker-prompts.mjs similarity index 99% rename from generators/base-docker/docker-prompts.mjs rename to generators/docker-compose/docker-prompts.mjs index d46ad81fbe18..437d5c2800dd 100644 --- a/generators/base-docker/docker-prompts.mjs +++ b/generators/docker-compose/docker-prompts.mjs @@ -19,7 +19,7 @@ import chalk from 'chalk'; import shelljs from 'shelljs'; -import { loadConfigs, setClusteredApps } from './docker-base.mjs'; +import { loadConfigs, setClusteredApps } from '../base-workspaces/internal/docker-base.mjs'; import { applicationTypes, monitoringTypes, serviceDiscoveryTypes } from '../../jdl/jhipster/index.mjs'; import { convertSecretToBase64 } from '../base/support/index.mjs'; diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index ab964bc76517..ddf9bea83fa4 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -23,6 +23,7 @@ import jsyaml from 'js-yaml'; import normalize from 'normalize-path'; import runAsync from 'run-async'; +import prompts from './docker-prompts.mjs'; import BaseDockerGenerator from '../base-docker/index.mjs'; import { writeFiles } from './files.mjs'; @@ -39,6 +40,9 @@ import { import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; import { stringHashCode, createFaker } from '../base/support/index.mjs'; import { loadDeploymentConfig } from '../base-workspaces/internal/deployments.mjs'; +import { loadFromYoRc, checkDocker, checkImages, generateJwtSecret } from '../base-workspaces/internal/docker-base.mjs'; +import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; +import statistics from '../statistics.mjs'; const { GATEWAY, MONOLITH } = applicationTypes; const { PROMETHEUS } = monitoringTypes; @@ -63,7 +67,9 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { get initializing() { return { - ...super.initializing, + loadDockerDependenciesTask, + checkDocker, + loadFromYoRc, checkDockerCompose: runAsync(function () { if (this.skipChecks) return; @@ -103,7 +109,17 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { } get prompting() { - return super.prompting; + return { + askForApplicationType: prompts.askForApplicationType, + askForGatewayType: prompts.askForGatewayType, + askForPath: prompts.askForPath, + askForApps: prompts.askForApps, + askForClustersMode: prompts.askForClustersMode, + askForMonitoring: prompts.askForMonitoring, + askForConsoleOptions: prompts.askForConsoleOptions, + askForServiceDiscovery: prompts.askForServiceDiscovery, + askForAdminPassword: prompts.askForAdminPassword, + }; } get [BaseDockerGenerator.PROMPTING]() { @@ -117,7 +133,12 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { this.log.log(chalk.white(`Files will be generated in folder: ${chalk.yellow(this.destinationRoot())}`)); }, - ...super.configuring, + insight() { + statistics.sendSubGenEvent('generator', GENERATOR_DOCKER_COMPOSE); + }, + + checkImages, + generateJwtSecret, saveConfig() { this.config.set({ diff --git a/generators/gae/generator.mjs b/generators/gae/generator.mjs index 0083eb6675ba..0247793465e0 100644 --- a/generators/gae/generator.mjs +++ b/generators/gae/generator.mjs @@ -27,7 +27,7 @@ import runAsync from 'run-async'; import BaseGenerator from '../base/index.mjs'; import { GENERATOR_GAE } from '../generator-list.mjs'; import statistics from '../statistics.mjs'; -import dockerPrompts from '../base-docker/docker-prompts.mjs'; +import dockerPrompts from '../docker-compose/docker-prompts.mjs'; import { CLIENT_MAIN_SRC_DIR, MAIN_DIR, SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; import { applicationTypes, buildToolTypes, cacheTypes, databaseTypes } from '../../jdl/jhipster/index.mjs'; import { mavenProdProfileContent, mavenPluginConfiguration, mavenProfileContent } from './templates.mjs'; diff --git a/generators/kubernetes-helm/generator.mjs b/generators/kubernetes-helm/generator.mjs index 765374fa0d29..ea7b777ea11f 100644 --- a/generators/kubernetes-helm/generator.mjs +++ b/generators/kubernetes-helm/generator.mjs @@ -25,7 +25,7 @@ import BaseWorkspacesGenerator from '../base-docker/index.mjs'; import prompts from '../kubernetes/prompts.mjs'; import { writeFiles } from './files.mjs'; import { GENERATOR_KUBERNETES_HELM } from '../generator-list.mjs'; -import { checkImages, generateJwtSecret, configureImageNames } from '../base-docker/docker-base.mjs'; +import { checkImages, generateJwtSecret, configureImageNames } from '../base-workspaces/internal/docker-base.mjs'; import { checkKubernetes, checkHelm, diff --git a/generators/kubernetes-knative/generator.mjs b/generators/kubernetes-knative/generator.mjs index a251dbd34f7f..a0aff377b180 100644 --- a/generators/kubernetes-knative/generator.mjs +++ b/generators/kubernetes-knative/generator.mjs @@ -27,7 +27,7 @@ import BaseWorkspacesGenerator from '../base-docker/index.mjs'; import prompts from './prompts.mjs'; import { writeFiles } from './files.mjs'; import { GENERATOR_KUBERNETES_KNATIVE } from '../generator-list.mjs'; -import { checkImages, generateJwtSecret, configureImageNames } from '../base-docker/docker-base.mjs'; +import { checkImages, generateJwtSecret, configureImageNames } from '../base-workspaces/internal/docker-base.mjs'; import { checkHelm, checkKubernetes, diff --git a/generators/kubernetes/generator.mjs b/generators/kubernetes/generator.mjs index 5f102abda38d..21f22128e322 100644 --- a/generators/kubernetes/generator.mjs +++ b/generators/kubernetes/generator.mjs @@ -28,7 +28,7 @@ import { buildToolTypes, messageBrokerTypes } from '../../jdl/jhipster/index.mjs import { GENERATOR_KUBERNETES } from '../generator-list.mjs'; import statistics from '../statistics.mjs'; -import { checkImages, generateJwtSecret, configureImageNames } from '../base-docker/docker-base.mjs'; +import { checkImages, generateJwtSecret, configureImageNames } from '../base-workspaces/internal/docker-base.mjs'; import { checkKubernetes, loadConfig, diff --git a/generators/kubernetes/kubernetes-base.mjs b/generators/kubernetes/kubernetes-base.mjs index aae7e6a08e7f..2fa5ac4a60ab 100644 --- a/generators/kubernetes/kubernetes-base.mjs +++ b/generators/kubernetes/kubernetes-base.mjs @@ -22,7 +22,7 @@ import runAsync from 'run-async'; import shelljs from 'shelljs'; import { defaultKubernetesConfig } from './kubernetes-constants.mjs'; -import { loadFromYoRc } from '../base-docker/docker-base.mjs'; +import { loadFromYoRc } from '../base-workspaces/internal/docker-base.mjs'; import { KUBERNETES_CORE_API_VERSION, KUBERNETES_BATCH_API_VERSION, diff --git a/generators/kubernetes/prompts.mjs b/generators/kubernetes/prompts.mjs index ad319212faa0..4cadfba837a7 100644 --- a/generators/kubernetes/prompts.mjs +++ b/generators/kubernetes/prompts.mjs @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import dockerPrompts from '../base-docker/docker-prompts.mjs'; +import dockerPrompts from '../docker-compose/docker-prompts.mjs'; import { defaultKubernetesConfig, ingressDefaultConfig } from './kubernetes-constants.mjs'; import { applicationTypes, databaseTypes, kubernetesPlatformTypes } from '../../jdl/jhipster/index.mjs'; diff --git a/generators/openshift/generator.mjs b/generators/openshift/generator.mjs index 0822ade2b819..54ca2552b2f7 100644 --- a/generators/openshift/generator.mjs +++ b/generators/openshift/generator.mjs @@ -25,7 +25,7 @@ import BaseWorkspacesGenerator from '../base-docker/index.mjs'; import prompts from './prompts.mjs'; import { GENERATOR_OPENSHIFT } from '../generator-list.mjs'; -import { loadFromYoRc, checkImages, generateJwtSecret, configureImageNames } from '../base-docker/docker-base.mjs'; +import { loadFromYoRc, checkImages, generateJwtSecret, configureImageNames } from '../base-workspaces/internal/docker-base.mjs'; import { setupKubernetesConstants } from '../kubernetes/kubernetes-base.mjs'; import statistics from '../statistics.mjs'; diff --git a/generators/openshift/prompts.mjs b/generators/openshift/prompts.mjs index 510348635a13..58a183614afe 100644 --- a/generators/openshift/prompts.mjs +++ b/generators/openshift/prompts.mjs @@ -17,7 +17,7 @@ * limitations under the License. */ import { databaseTypes, monitoringTypes, searchEngineTypes, openshiftPlatformTypes } from '../../jdl/jhipster/index.mjs'; -import dockerPrompts from '../base-docker/docker-prompts.mjs'; +import dockerPrompts from '../docker-compose/docker-prompts.mjs'; const { ELASTICSEARCH } = searchEngineTypes; const { PROMETHEUS } = monitoringTypes; From e5a7e2d8ada78c26583561a96400ffcb695c16cc Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 1 Sep 2023 23:52:56 -0300 Subject: [PATCH 10/27] drop base-docker --- generators/base-docker/generator.mjs | 38 ------------------- generators/base-docker/index.mts | 25 ------------ generators/base-workspaces/command.mts | 14 +++++++ generators/base-workspaces/generator.mts | 3 ++ generators/docker-compose/generator.mjs | 2 +- .../support/docker-compose-file.spec.mts | 2 +- .../__snapshots__/generator.spec.mjs.snap | 20 +++++----- generators/generator-list.mjs | 2 +- generators/kubernetes-helm/generator.mjs | 2 +- generators/kubernetes-knative/generator.mjs | 2 +- generators/kubernetes/generator.mjs | 2 +- generators/openshift/generator.mjs | 2 +- test/__snapshots__/api.spec.mjs.snap | 2 +- 13 files changed, 35 insertions(+), 81 deletions(-) delete mode 100644 generators/base-docker/generator.mjs delete mode 100644 generators/base-docker/index.mts create mode 100644 generators/base-workspaces/command.mts diff --git a/generators/base-docker/generator.mjs b/generators/base-docker/generator.mjs deleted file mode 100644 index 00d82d83d6bd..000000000000 --- a/generators/base-docker/generator.mjs +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2013-2023 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 BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; - -/** - * @class - * @extends {BaseWorkspacesGenerator} - */ -export default class BaseDockerGenerator extends BaseWorkspacesGenerator { - constructor(args, options, features) { - super(args, options, features); - - // This adds support for a `--skip-prompts` flag - this.option('skip-prompts', { - description: 'Generate pre-existing configuration', - type: Boolean, - }); - - this.regenerate = this.options.skipPrompts; - } -} diff --git a/generators/base-docker/index.mts b/generators/base-docker/index.mts deleted file mode 100644 index 5f460ac25992..000000000000 --- a/generators/base-docker/index.mts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright 2013-2023 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. - */ - -/* - * Register generator-base at yeoman-environment - */ -import BaseDockerGenerator from './generator.mjs'; - -export default BaseDockerGenerator; diff --git a/generators/base-workspaces/command.mts b/generators/base-workspaces/command.mts new file mode 100644 index 000000000000..9a9fa0b1fb7d --- /dev/null +++ b/generators/base-workspaces/command.mts @@ -0,0 +1,14 @@ +import { JHipsterCommandDefinition } from '../base/api.mjs'; + +const command: JHipsterCommandDefinition = { + options: { + regenerate: { + name: 'skipPrompts', + type: Boolean, + description: 'Generate pre-existing configuration', + scope: 'generator', + }, + }, +}; + +export default command; diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts index b9dbc510c4f3..bb46af10a636 100644 --- a/generators/base-workspaces/generator.mts +++ b/generators/base-workspaces/generator.mts @@ -23,6 +23,7 @@ import BaseGenerator from '../base/index.mjs'; import { PRIORITY_NAMES, QUEUES } from '../base/priorities.mjs'; import { YO_RC_FILE } from '../generator-constants.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs'; +import command from './command.mjs'; const { DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END } = PRIORITY_NAMES; @@ -45,6 +46,8 @@ export default class BaseWorkspacesGenerator extends BaseGenerator { cancellable: true, queueName: QUEUES.PREPARING_QUEUE, }); + + this.parseJHipsterOptions(command.options); } } diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index ddf9bea83fa4..ea85ed312cc3 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -24,7 +24,7 @@ import normalize from 'normalize-path'; import runAsync from 'run-async'; import prompts from './docker-prompts.mjs'; -import BaseDockerGenerator from '../base-docker/index.mjs'; +import BaseDockerGenerator from '../base-workspaces/index.mjs'; import { writeFiles } from './files.mjs'; import { diff --git a/generators/docker/support/docker-compose-file.spec.mts b/generators/docker/support/docker-compose-file.spec.mts index 923b38e23a8a..888a02605f86 100644 --- a/generators/docker/support/docker-compose-file.spec.mts +++ b/generators/docker/support/docker-compose-file.spec.mts @@ -1,7 +1,7 @@ import { expect } from 'esmocha'; import { createDockerComposeFile } from './docker-compose-file.mjs'; -describe('generator - base-docker - utils', () => { +describe('generator - docker - docker-compose-file', () => { describe('createDockerComposeFile', () => { it('should return a docker compose file header with default name', () => { expect(createDockerComposeFile()).toMatchInlineSnapshot(` diff --git a/generators/generate-blueprint/__snapshots__/generator.spec.mjs.snap b/generators/generate-blueprint/__snapshots__/generator.spec.mjs.snap index eb121c51add4..e9b3a207a181 100644 --- a/generators/generate-blueprint/__snapshots__/generator.spec.mjs.snap +++ b/generators/generate-blueprint/__snapshots__/generator.spec.mjs.snap @@ -122,34 +122,34 @@ exports[`generator - generate-blueprint with all option should match snapshot 1` "generators/base-core/templates/template-file-base-core.ejs": { "stateCleared": "modified", }, - "generators/base-docker/command.mjs": { + "generators/base-entity-changes/command.mjs": { "stateCleared": "modified", }, - "generators/base-docker/generator.mjs": { + "generators/base-entity-changes/generator.mjs": { "stateCleared": "modified", }, - "generators/base-docker/generator.spec.mjs": { + "generators/base-entity-changes/generator.spec.mjs": { "stateCleared": "modified", }, - "generators/base-docker/index.mjs": { + "generators/base-entity-changes/index.mjs": { "stateCleared": "modified", }, - "generators/base-docker/templates/template-file-base-docker.ejs": { + "generators/base-entity-changes/templates/template-file-base-entity-changes.ejs": { "stateCleared": "modified", }, - "generators/base-entity-changes/command.mjs": { + "generators/base-workspaces/command.mjs": { "stateCleared": "modified", }, - "generators/base-entity-changes/generator.mjs": { + "generators/base-workspaces/generator.mjs": { "stateCleared": "modified", }, - "generators/base-entity-changes/generator.spec.mjs": { + "generators/base-workspaces/generator.spec.mjs": { "stateCleared": "modified", }, - "generators/base-entity-changes/index.mjs": { + "generators/base-workspaces/index.mjs": { "stateCleared": "modified", }, - "generators/base-entity-changes/templates/template-file-base-entity-changes.ejs": { + "generators/base-workspaces/templates/template-file-base-workspaces.ejs": { "stateCleared": "modified", }, "generators/base/command.mjs": { diff --git a/generators/generator-list.mjs b/generators/generator-list.mjs index 1f0928a3ac2d..6880dfdd20c7 100644 --- a/generators/generator-list.mjs +++ b/generators/generator-list.mjs @@ -25,8 +25,8 @@ export const GENERATOR_AZURE_SPRING_CLOUD = 'azure-spring-cloud'; export const GENERATOR_BASE = 'base'; export const GENERATOR_BASE_APPLICATION = 'base-application'; export const GENERATOR_BASE_CORE = 'base-core'; -export const GENERATOR_BASE_DOCKER = 'base-docker'; export const GENERATOR_BASE_ENTITY_CHANGES = 'base-entity-changes'; +export const GENERATOR_BASE_WORKSPACES = 'base-workspaces'; export const GENERATOR_BOOTSTRAP = 'bootstrap'; export const GENERATOR_BOOTSTRAP_APPLICATION = 'bootstrap-application'; export const GENERATOR_BOOTSTRAP_APPLICATION_BASE = 'bootstrap-application-base'; diff --git a/generators/kubernetes-helm/generator.mjs b/generators/kubernetes-helm/generator.mjs index ea7b777ea11f..9b492d52bf3c 100644 --- a/generators/kubernetes-helm/generator.mjs +++ b/generators/kubernetes-helm/generator.mjs @@ -20,7 +20,7 @@ import fs from 'fs'; import chalk from 'chalk'; -import BaseWorkspacesGenerator from '../base-docker/index.mjs'; +import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import prompts from '../kubernetes/prompts.mjs'; import { writeFiles } from './files.mjs'; diff --git a/generators/kubernetes-knative/generator.mjs b/generators/kubernetes-knative/generator.mjs index a0aff377b180..3d4b4141718f 100644 --- a/generators/kubernetes-knative/generator.mjs +++ b/generators/kubernetes-knative/generator.mjs @@ -22,7 +22,7 @@ import chalk from 'chalk'; import shelljs from 'shelljs'; import runAsync from 'run-async'; -import BaseWorkspacesGenerator from '../base-docker/index.mjs'; +import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import prompts from './prompts.mjs'; import { writeFiles } from './files.mjs'; diff --git a/generators/kubernetes/generator.mjs b/generators/kubernetes/generator.mjs index 21f22128e322..50cab019e4d8 100644 --- a/generators/kubernetes/generator.mjs +++ b/generators/kubernetes/generator.mjs @@ -20,7 +20,7 @@ import fs from 'fs'; import chalk from 'chalk'; -import BaseWorkspacesGenerator from '../base-docker/index.mjs'; +import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import prompts from './prompts.mjs'; import { writeFiles } from './files.mjs'; diff --git a/generators/openshift/generator.mjs b/generators/openshift/generator.mjs index 54ca2552b2f7..53e1473d194e 100644 --- a/generators/openshift/generator.mjs +++ b/generators/openshift/generator.mjs @@ -21,7 +21,7 @@ import chalk from 'chalk'; import shelljs from 'shelljs'; import runAsync from 'run-async'; -import BaseWorkspacesGenerator from '../base-docker/index.mjs'; +import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import prompts from './prompts.mjs'; import { GENERATOR_OPENSHIFT } from '../generator-list.mjs'; diff --git a/test/__snapshots__/api.spec.mjs.snap b/test/__snapshots__/api.spec.mjs.snap index 65bd08dd6643..c62979b46825 100644 --- a/test/__snapshots__/api.spec.mjs.snap +++ b/test/__snapshots__/api.spec.mjs.snap @@ -10,8 +10,8 @@ exports[`public api generator-jhipster/generators should match snapshot 1`] = ` "GENERATOR_BASE": "base", "GENERATOR_BASE_APPLICATION": "base-application", "GENERATOR_BASE_CORE": "base-core", - "GENERATOR_BASE_DOCKER": "base-docker", "GENERATOR_BASE_ENTITY_CHANGES": "base-entity-changes", + "GENERATOR_BASE_WORKSPACES": "base-workspaces", "GENERATOR_BOOTSTRAP": "bootstrap", "GENERATOR_BOOTSTRAP_APPLICATION": "bootstrap-application", "GENERATOR_BOOTSTRAP_APPLICATION_BASE": "bootstrap-application-base", From 9712fd97a0f6eb52ba1ef0d80f273b559bd5a458 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 2 Sep 2023 13:49:29 -0300 Subject: [PATCH 11/27] improvements to workspaces and docker-compose --- generators/docker-compose/generator.mjs | 38 ++++++++++++------------- generators/workspaces/generator.mjs | 19 ++++--------- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index ea85ed312cc3..89bd6f4562d6 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -158,12 +158,24 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { return this.delegateTasksToBlueprint(() => this.configuring); } - get preparing() { + get loading() { + return { + loadPlatformConfig() { + loadDeploymentConfig.call(this); + }, + }; + } + + get [BaseDockerGenerator.LOADING]() { + return this.delegateTasksToBlueprint(() => this.loading); + } + + get default() { return { - loadConfig() { - this.usesOauth2 = this.appConfigs.some(appConfig => appConfig.authenticationTypeOauth2); - this.useKafka = this.appConfigs.some(appConfig => appConfig.messageBroker === KAFKA); - this.usePulsar = this.appConfigs.some(appConfig => appConfig.messageBroker === PULSAR); + loadConfig({ applications }) { + this.usesOauth2 = applications.some(appConfig => appConfig.authenticationTypeOauth2); + this.useKafka = applications.some(appConfig => appConfig.messageBroker === KAFKA); + this.usePulsar = applications.some(appConfig => appConfig.messageBroker === PULSAR); this.entryPort = 8080; }, @@ -344,20 +356,8 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.PREPARING]() { - return this.delegateTasksToBlueprint(() => this.preparing); - } - - get loading() { - return { - loadPlatformConfig() { - loadDeploymentConfig.call(this); - }, - }; - } - - get [BaseDockerGenerator.LOADING]() { - return this.delegateTasksToBlueprint(() => this.loading); + get [BaseDockerGenerator.DEFAULT]() { + return this.delegateTasksToBlueprint(() => this.default); } get writing() { diff --git a/generators/workspaces/generator.mjs b/generators/workspaces/generator.mjs index c3c70a32ce96..577b1c8772ef 100644 --- a/generators/workspaces/generator.mjs +++ b/generators/workspaces/generator.mjs @@ -19,7 +19,7 @@ import { existsSync } from 'fs'; -import { GENERATOR_ANGULAR, GENERATOR_COMMON, GENERATOR_GIT, GENERATOR_WORKSPACES } from '../generator-list.mjs'; +import { GENERATOR_GIT, GENERATOR_WORKSPACES } from '../generator-list.mjs'; import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import command from './command.mjs'; @@ -137,21 +137,14 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { generatePackageJson({ applications }) { if (!this.generateWorkspaces) return; - const { - dependencies: { rxjs }, - devDependencies: { webpack: webpackVersion }, - } = this.fs.readJSON(this.fetchFromInstalledJHipster(GENERATOR_ANGULAR, 'resources', 'package.json')); - - const { - devDependencies: { concurrently }, - } = this.fs.readJSON(this.fetchFromInstalledJHipster(GENERATOR_COMMON, 'resources', 'package.json')); - + const findDependencyVersion = dependency => + applications.find(app => app.nodeDependencies[dependency])?.nodeDependencies[dependency]; this.packageJson.merge({ workspaces: { packages: this.packages, }, devDependencies: { - concurrently, + concurrently: findDependencyVersion('concurrently'), }, scripts: { 'ci:e2e:package': 'npm run ci:docker:build --workspaces --if-present && npm run java:docker --workspaces --if-present', @@ -165,10 +158,10 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { if (applications.some(app => app.clientFrameworkAngular)) { this.packageJson.merge({ devDependencies: { - rxjs, // Set version to workaround https://github.com/npm/cli/issues/4437 + rxjs: findDependencyVersion('rxjs'), // Set version to workaround https://github.com/npm/cli/issues/4437 }, overrides: { - webpack: webpackVersion, + webpack: findDependencyVersion('webpack'), }, }); } From f28c8215543c4b88093b2d05a5eabe6fb84cc221 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 2 Sep 2023 20:45:59 -0300 Subject: [PATCH 12/27] simplify docker-compose implementation --- generators/base-workspaces/generator.mts | 38 +- generators/base-workspaces/index.mts | 5 +- .../base-workspaces/internal/deployments.mts | 1 - .../internal/docker-dependencies.mts | 4 +- generators/base/shared-data.mts | 1 + .../docker-compose.spec.mts.snap | 44 +- generators/docker-compose/command.mts | 13 + .../docker-compose/docker-compose.spec.mts | 30 +- generators/docker-compose/docker-prompts.mjs | 5 +- generators/docker-compose/files.mjs | 39 +- generators/docker-compose/generator.mjs | 382 ++++++++++++++---- generators/docker-compose/index.mts | 1 + 12 files changed, 376 insertions(+), 187 deletions(-) create mode 100644 generators/docker-compose/command.mts diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts index bb46af10a636..e1a637d406d4 100644 --- a/generators/base-workspaces/generator.mts +++ b/generators/base-workspaces/generator.mts @@ -25,12 +25,12 @@ import { YO_RC_FILE } from '../generator-constants.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs'; import command from './command.mjs'; -const { DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END } = PRIORITY_NAMES; +const { LOADING, PREPARING, DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END } = PRIORITY_NAMES; /** * This is the base class for a generator that generates entities. */ -export default class BaseWorkspacesGenerator extends BaseGenerator { +export default abstract class BaseWorkspacesGenerator extends BaseGenerator { appsFolders?: string[]; directoryPath!: string; @@ -51,8 +51,7 @@ export default class BaseWorkspacesGenerator extends BaseGenerator { } } - protected async findApplicationFolders() { - const directoryPath = this.directoryPath ?? '.'; + protected async findApplicationFolders(directoryPath = this.directoryPath ?? '.') { return (await readdir(this.destinationPath(directoryPath), { withFileTypes: true })) .filter(dirent => dirent.isDirectory()) .map(dirent => dirent.name) @@ -63,8 +62,11 @@ export default class BaseWorkspacesGenerator extends BaseGenerator { ); } - protected async resolveApplicationFolders() { - return (this.appsFolders ?? []).map(appFolder => this.destinationPath(this.directoryPath ?? '.', appFolder)); + protected async resolveApplicationFolders({ + directoryPath = this.directoryPath, + appsFolders = this.appsFolders ?? [], + }: { directoryPath?: string; appsFolders?: string[] } = {}) { + return appsFolders.map(appFolder => this.destinationPath(directoryPath ?? '.', appFolder)); } async bootstrapApplications() { @@ -77,17 +79,31 @@ export default class BaseWorkspacesGenerator extends BaseGenerator { getArgsForPriority(priorityName): any { const args = super.getArgsForPriority(priorityName); - if (![DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END].includes(priorityName)) { + if (![LOADING, PREPARING, DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END].includes(priorityName)) { return args; } - const [first, ...others] = args ?? []; + const deployment = this.getSharedApplication(this.destinationPath()).sharedDeployment; + if (![DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END].includes(priorityName)) { + return [ + { + ...first, + deployment, + }, + ...others, + ]; + } + const applications = (this.appsFolders ?? []).map((appFolder, index) => { + const application = this.getSharedApplication(this.destinationPath(this.directoryPath ?? '.', appFolder))?.sharedApplication; + application.appFolder = appFolder; + application.composePort = 8080 + index; + return application; + }); return [ { ...first, - applications: (this.appsFolders ?? []).map( - appFolder => this.getSharedApplication(this.destinationPath(this.directoryPath ?? '.', appFolder))?.sharedApplication, - ), + deployment, + applications, }, ...others, ]; diff --git a/generators/base-workspaces/index.mts b/generators/base-workspaces/index.mts index 6556e074f61c..855a438fcc02 100644 --- a/generators/base-workspaces/index.mts +++ b/generators/base-workspaces/index.mts @@ -16,8 +16,5 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * Register generator-base at yeoman-environment - */ export { default } from './generator.mjs'; +export { default as command } from './command.mjs'; diff --git a/generators/base-workspaces/internal/deployments.mts b/generators/base-workspaces/internal/deployments.mts index a7c6ab5938de..2f81048e8880 100644 --- a/generators/base-workspaces/internal/deployments.mts +++ b/generators/base-workspaces/internal/deployments.mts @@ -35,7 +35,6 @@ export function loadDeploymentConfig( ) { deployment.appsFolders = config.appsFolders; deployment.directoryPath = config.directoryPath; - deployment.gatewayType = config.gatewayType; deployment.clusteredDbApps = config.clusteredDbApps; deployment.dockerRepositoryName = config.dockerRepositoryName; deployment.dockerPushCommand = config.dockerPushCommand; diff --git a/generators/base-workspaces/internal/docker-dependencies.mts b/generators/base-workspaces/internal/docker-dependencies.mts index 5a0d0629b88e..c5194f69d700 100644 --- a/generators/base-workspaces/internal/docker-dependencies.mts +++ b/generators/base-workspaces/internal/docker-dependencies.mts @@ -19,9 +19,9 @@ import { dockerContainers as elasticDockerContainer } from '../../generator-constants.mjs'; import { dockerPlaceholderGenerator, getDockerfileContainers } from '../../docker/utils.mjs'; -export async function loadDockerDependenciesTask(this: any) { +export async function loadDockerDependenciesTask(this: any, { context = this } = {}) { const dockerfile = this.readTemplate(this.jhipsterTemplatePath('../../server/resources/Dockerfile')); - this.dockerContainers = this.prepareDependencies( + context.dockerContainers = this.prepareDependencies( { ...elasticDockerContainer, ...getDockerfileContainers(dockerfile), diff --git a/generators/base/shared-data.mts b/generators/base/shared-data.mts index fef63c624cd0..3d036f05cd64 100644 --- a/generators/base/shared-data.mts +++ b/generators/base/shared-data.mts @@ -28,6 +28,7 @@ export default class SharedData { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], monitoring: NO_MONITORING, }) @@ -67,7 +67,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], monitoring: NO_MONITORING, }) @@ -103,7 +103,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: '.', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], monitoring: NO_MONITORING, }) @@ -134,7 +134,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], monitoring: NO_MONITORING, }) @@ -170,7 +170,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], }) .run(); @@ -208,7 +208,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], }) .run(); @@ -246,7 +246,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], monitoring: PROMETHEUS, }) @@ -285,7 +285,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], }) .run(); @@ -320,7 +320,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: ['04-mongo'], }) .run(); @@ -355,7 +355,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], }) .run(); @@ -390,7 +390,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MONOLITH, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], }) .run(); @@ -422,7 +422,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], }) .run(); @@ -462,7 +462,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], }) .run(); @@ -497,7 +497,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MICROSERVICE, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: ['10-couchbase'], }) .run(); @@ -532,7 +532,7 @@ describe('generator - Docker Compose', () => { .withAnswers({ deploymentApplicationType: MONOLITH, directoryPath: './', - chosenApps, + appsFolders: chosenApps, clusteredDbApps: [], monitoring: NO_MONITORING, }) diff --git a/generators/docker-compose/docker-prompts.mjs b/generators/docker-compose/docker-prompts.mjs index 437d5c2800dd..dd5761eec877 100644 --- a/generators/docker-compose/docker-prompts.mjs +++ b/generators/docker-compose/docker-prompts.mjs @@ -19,7 +19,7 @@ import chalk from 'chalk'; import shelljs from 'shelljs'; -import { loadConfigs, setClusteredApps } from '../base-workspaces/internal/docker-base.mjs'; +import { loadConfigs } from '../base-workspaces/internal/docker-base.mjs'; import { applicationTypes, monitoringTypes, serviceDiscoveryTypes } from '../../jdl/jhipster/index.mjs'; import { convertSecretToBase64 } from '../base/support/index.mjs'; @@ -204,7 +204,6 @@ async function askForClustersMode() { const props = await this.prompt(prompts, this.config); this.clusteredDbApps = props.clusteredDbApps; - setClusteredApps.call(this); } /** @@ -295,7 +294,7 @@ async function askForServiceDiscovery() { }, ]; - const props = this.prompt(prompts, this.config); + const props = await this.prompt(prompts, this.config); this.serviceDiscoveryType = props.serviceDiscoveryType; } } diff --git a/generators/docker-compose/files.mjs b/generators/docker-compose/files.mjs index cce9c4d966af..3936dfbc263c 100644 --- a/generators/docker-compose/files.mjs +++ b/generators/docker-compose/files.mjs @@ -31,39 +31,30 @@ export function writeFiles() { } }, - writeDockerCompose() { - this.writeFile('docker-compose.yml.ejs', 'docker-compose.yml'); - this.writeFile('README-DOCKER-COMPOSE.md.ejs', 'README-DOCKER-COMPOSE.md'); + writeDockerCompose({ deployment }) { + this.writeFile('docker-compose.yml.ejs', 'docker-compose.yml', deployment); + this.writeFile('README-DOCKER-COMPOSE.md.ejs', 'README-DOCKER-COMPOSE.md', deployment); }, - writeRegistryFiles() { - if (this.serviceDiscoveryAny) { - this.writeFile('central-server-config/application.yml.ejs', 'central-server-config/application.yml'); + writeRegistryFiles({ deployment }) { + if (deployment.serviceDiscoveryAny) { + this.writeFile('central-server-config/application.yml.ejs', 'central-server-config/application.yml', deployment); } }, - writeKeycloakFiles() { - if (this.authenticationType === OAUTH2 && this.applicationType !== MICROSERVICE) { - this.writeFile('realm-config/keycloak-health-check.sh', 'realm-config/keycloak-health-check.sh'); - this.writeFile('realm-config/jhipster-realm.json.ejs', 'realm-config/jhipster-realm.json'); + writeKeycloakFiles({ deployment }) { + if (deployment.authenticationType === OAUTH2 && deployment.applicationType !== MICROSERVICE) { + this.writeFile('realm-config/keycloak-health-check.sh', 'realm-config/keycloak-health-check.sh', deployment); + this.writeFile('realm-config/jhipster-realm.json.ejs', 'realm-config/jhipster-realm.json', deployment); } }, - writePrometheusFiles() { - if (this.monitoring !== PROMETHEUS) return; + writePrometheusFiles({ deployment }) { + if (deployment.monitoring !== PROMETHEUS) return; - // Generate a list of target apps to monitor for the prometheus config - const appsToMonitor = []; - for (let i = 0; i < this.appConfigs.length; i++) { - appsToMonitor.push(` - ${this.appConfigs[i].baseName}:${this.appConfigs[i].composePort}`); - } - - // Format the application target list as a YAML array - this.appsToMonitorList = appsToMonitor.join('\n').replace(/'/g, ''); - - this.writeFile('prometheus-conf/prometheus.yml.ejs', 'prometheus-conf/prometheus.yml'); - this.writeFile('prometheus-conf/alert_rules.yml.ejs', 'prometheus-conf/alert_rules.yml'); - this.writeFile('alertmanager-conf/config.yml.ejs', 'alertmanager-conf/config.yml'); + this.writeFile('prometheus-conf/prometheus.yml.ejs', 'prometheus-conf/prometheus.yml', deployment); + this.writeFile('prometheus-conf/alert_rules.yml.ejs', 'prometheus-conf/alert_rules.yml', deployment); + this.writeFile('alertmanager-conf/config.yml.ejs', 'alertmanager-conf/config.yml', deployment); }, }; } diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index 89bd6f4562d6..fdbe37d32290 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -23,8 +23,8 @@ import jsyaml from 'js-yaml'; import normalize from 'normalize-path'; import runAsync from 'run-async'; -import prompts from './docker-prompts.mjs'; -import BaseDockerGenerator from '../base-workspaces/index.mjs'; +import { existsSync } from 'fs'; +import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import { writeFiles } from './files.mjs'; import { @@ -32,24 +32,23 @@ import { applicationTypes, cacheTypes, databaseTypes, - messageBrokerTypes, monitoringTypes, serviceDiscoveryTypes, searchEngineTypes, } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; -import { stringHashCode, createFaker } from '../base/support/index.mjs'; +import { stringHashCode, createFaker, convertSecretToBase64, createBase64Secret, normalizePathEnd } from '../base/support/index.mjs'; import { loadDeploymentConfig } from '../base-workspaces/internal/deployments.mjs'; -import { loadFromYoRc, checkDocker, checkImages, generateJwtSecret } from '../base-workspaces/internal/docker-base.mjs'; +import { checkDocker } from '../base-workspaces/internal/docker-base.mjs'; import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; import statistics from '../statistics.mjs'; +import command from './command.mjs'; const { GATEWAY, MONOLITH } = applicationTypes; -const { PROMETHEUS } = monitoringTypes; -const { EUREKA, NO: NO_SERVICE_DISCOVERY } = serviceDiscoveryTypes; +const { PROMETHEUS, NO: NO_MONITORING } = monitoringTypes; +const { CONSUL, EUREKA, NO: NO_SERVICE_DISCOVERY } = serviceDiscoveryTypes; const { CASSANDRA, COUCHBASE, MONGODB, ORACLE, NO: NO_DATABASE } = databaseTypes; const { ELASTICSEARCH } = searchEngineTypes; -const { KAFKA, PULSAR } = messageBrokerTypes; const { MEMCACHED, REDIS } = cacheTypes; const { OAUTH2 } = authenticationTypes; @@ -58,7 +57,7 @@ const { OAUTH2 } = authenticationTypes; * @class * @extends {import('../base/index.mjs')} */ -export default class DockerComposeGenerator extends BaseDockerGenerator { +export default class DockerComposeGenerator extends BaseWorkspacesGenerator { async beforeQueue() { if (!this.fromBlueprint) { await this.composeWithBlueprints(GENERATOR_DOCKER_COMPOSE); @@ -67,10 +66,23 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { get initializing() { return { - loadDockerDependenciesTask, - checkDocker, - loadFromYoRc, + sayHello() { + this.log.log(chalk.white(`${chalk.bold('🐳')} Welcome to the JHipster Docker Compose Sub-Generator ${chalk.bold('🐳')}`)); + this.log.log(chalk.white(`Files will be generated in folder: ${chalk.yellow(this.destinationRoot())}`)); + }, + + parseArguments() { + this.parseJHipsterArguments(command.arguments); + if (this.appsFolders?.length > 0) { + this.jhipsterConfig.appsFolders = this.appsFolders; + } + this.parseJHipsterOptions(command.options); + if (this.appsFolder || this.jhipsterConfig.appsFolders) { + this.regenerate = true; + } + }, + checkDocker, checkDockerCompose: runAsync(function () { if (this.skipChecks) return; @@ -104,91 +116,282 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { }; } - get [BaseDockerGenerator.INITIALIZING]() { + get [BaseWorkspacesGenerator.INITIALIZING]() { return this.delegateTasksToBlueprint(() => this.initializing); } get prompting() { return { - askForApplicationType: prompts.askForApplicationType, - askForGatewayType: prompts.askForGatewayType, - askForPath: prompts.askForPath, - askForApps: prompts.askForApps, - askForClustersMode: prompts.askForClustersMode, - askForMonitoring: prompts.askForMonitoring, - askForConsoleOptions: prompts.askForConsoleOptions, - askForServiceDiscovery: prompts.askForServiceDiscovery, - askForAdminPassword: prompts.askForAdminPassword, + async askForOptions() { + if (this.regenerate && !this.options.askAnswered) return; + + await this.prompt( + [ + { + type: 'input', + name: 'directoryPath', + message: 'Enter the root directory where your applications are located', + default: '../', + validate: async input => { + const path = this.destinationPath(input); + if (existsSync(path)) { + const applications = await this.findApplicationFolders(path); + return applications.length === 0 ? `No application found in ${path}` : true; + } + return `${path} is not a directory or doesn't exist`; + }, + }, + /* + { + type: 'list', + name: 'deploymentApplicationType', + message: 'Which *type* of application would you like to deploy?', + choices: [ + { + value: MONOLITH, + name: 'Monolithic application', + }, + { + value: MICROSERVICE, + name: 'Microservice application', + }, + ], + default: MONOLITH, + }, + { + type: 'list', + name: 'gatewayType', + when: answers => answers.deploymentApplicationType === MICROSERVICE, + message: 'Which *type* of gateway would you like to use?', + choices: [ + { + value: 'SpringCloudGateway', + name: 'JHipster gateway based on Spring Cloud Gateway', + }, + ], + default: 'SpringCloudGateway', + }, + */ + ], + this.config, + ); + }, + async askForPath() { + if (this.regenerate) return; + + const directoryPath = this.jhipsterConfig.directoryPath; + const appsFolders = (await this.findApplicationFolders(directoryPath)).filter( + app => app !== 'jhipster-registry' && app !== 'registry', + ); + this.log.log(chalk.green(`${appsFolders.length} applications found at ${this.destinationPath(directoryPath)}\n`)); + + await this.prompt( + [ + { + type: 'checkbox', + name: 'appsFolders', + message: 'Which applications do you want to include in your configuration?', + choices: appsFolders, + default: appsFolders, + validate: input => (input.length === 0 ? 'Please choose at least one application' : true), + }, + { + type: 'list', + name: 'monitoring', + message: 'Do you want to setup monitoring for your applications ?', + choices: [ + { + value: NO_MONITORING, + name: 'No', + }, + { + value: PROMETHEUS, + name: 'Yes, for metrics only with Prometheus', + }, + ], + default: NO_MONITORING, + }, + ], + this.config, + ); + }, }; } - get [BaseDockerGenerator.PROMPTING]() { + get [BaseWorkspacesGenerator.PROMPTING]() { return this.delegateTasksToBlueprint(() => this.prompting); } get configuring() { return { - sayHello() { - this.log.log(chalk.white(`${chalk.bold('🐳')} Welcome to the JHipster Docker Compose Sub-Generator ${chalk.bold('🐳')}`)); - this.log.log(chalk.white(`Files will be generated in folder: ${chalk.yellow(this.destinationRoot())}`)); - }, - - insight() { - statistics.sendSubGenEvent('generator', GENERATOR_DOCKER_COMPOSE); - }, - - checkImages, - generateJwtSecret, - - saveConfig() { - this.config.set({ - appsFolders: this.appsFolders, - directoryPath: this.directoryPath, - gatewayType: this.gatewayType, - clusteredDbApps: this.clusteredDbApps, - monitoring: this.monitoring, - serviceDiscoveryType: this.serviceDiscoveryType, - jwtSecretKey: this.jwtSecretKey, - }); + configureDeployment() { + this.jhipsterConfig.directoryPath = normalizePathEnd(this.jhipsterConfig.directoryPath ?? './'); + this.jhipsterConfig.jwtSecretKey = this.jhipsterConfig.jwtSecretKey ?? createBase64Secret(this.options.reproducibleTests); }, }; } - get [BaseDockerGenerator.CONFIGURING]() { + get [BaseWorkspacesGenerator.CONFIGURING]() { return this.delegateTasksToBlueprint(() => this.configuring); } get loading() { return { - loadPlatformConfig() { - loadDeploymentConfig.call(this); + loadDeployment({ deployment }) { + this.appsFolders = this.jhipsterConfig.appsFolders; + this.directoryPath = this.jhipsterConfig.directoryPath ?? './'; + + deployment.jwtSecretKey = this.jhipsterConfig.jwtSecretKey; + + loadDockerDependenciesTask.call(this, { context: deployment }); }, }; } - get [BaseDockerGenerator.LOADING]() { + get [BaseWorkspacesGenerator.LOADING]() { return this.delegateTasksToBlueprint(() => this.loading); } get default() { return { - loadConfig({ applications }) { - this.usesOauth2 = applications.some(appConfig => appConfig.authenticationTypeOauth2); - this.useKafka = applications.some(appConfig => appConfig.messageBroker === KAFKA); - this.usePulsar = applications.some(appConfig => appConfig.messageBroker === PULSAR); - this.entryPort = 8080; + async askForClustersMode({ applications }) { + if (this.regenerate) return; + + const clusteredDbApps = applications.filter(app => app.databaseTypeMongodb || app.databaseTypeCouchbase).map(app => app.appFolder); + if (clusteredDbApps.length === 0) return; + + await this.prompt( + [ + { + type: 'checkbox', + name: 'clusteredDbApps', + message: 'Which applications do you want to use with clustered databases (only available with MongoDB and Couchbase)?', + choices: clusteredDbApps, + default: clusteredDbApps, + }, + ], + this.config, + ); }, + async askForServiceDiscovery({ applications }) { + if (this.regenerate) return; - async setAppsYaml() { + const serviceDiscoveryEnabledApps = applications.filter(app => app.serviceDiscoveryAny); + if (serviceDiscoveryEnabledApps.length === 0) { + this.jhipsterConfig.serviceDiscoveryType = 'no'; + return; + } + + if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryConsul)) { + this.jhipsterConfig.serviceDiscoveryType = CONSUL; + this.log.log(chalk.green('Consul detected as the service discovery and configuration provider used by your apps')); + } else if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryEureka)) { + this.jhipsterConfig.serviceDiscoveryType = EUREKA; + this.log.log(chalk.green('JHipster registry detected as the service discovery and configuration provider used by your apps')); + } else { + this.log.warn( + chalk.yellow('Unable to determine the service discovery and configuration provider to use from your apps configuration.'), + ); + this.log.verboseInfo('Your service discovery enabled apps:'); + serviceDiscoveryEnabledApps.forEach(app => { + this.log.verboseInfo(` -${app.baseName} (${app.serviceDiscoveryType})`); + }); + + await this.prompt( + [ + { + type: 'list', + name: 'serviceDiscoveryType', + message: 'Which Service Discovery registry and Configuration server would you like to use ?', + choices: [ + { + value: CONSUL, + name: 'Consul', + }, + { + value: EUREKA, + name: 'JHipster Registry', + }, + { + value: NO_SERVICE_DISCOVERY, + name: 'No Service Discovery and Configuration', + }, + ], + default: CONSUL, + }, + { + type: 'input', + when: answers => answers.serviceDiscoveryType === EUREKA, + name: 'adminPassword', + message: 'Enter the admin password used to secure the JHipster Registry', + default: 'admin', + validate: input => (input.length < 5 ? 'The password must have at least 5 characters' : true), + }, + ], + this.config, + ); + } + }, + + configurePassword() { + if (this.jhipsterConfig.serviceDiscoveryType !== EUREKA) return; + + this.jhipsterConfig.adminPasswordBase64 = convertSecretToBase64(this.jhipsterConfig.adminPassword); + }, + + checkImages({ applications }) { + this.log.log('\nChecking Docker images in applications directories...'); + + let imagePath = ''; + let runCommand = ''; + this.hasWarning = false; + this.warningMessage = 'To generate the missing Docker image(s), please run:\n'; + applications.forEach(application => { + if (application.buildToolGradle) { + imagePath = this.destinationPath(this.directoryPath, application.appFolder, 'build/jib-cache'); + runCommand = `./gradlew bootJar -Pprod jibDockerBuild${process.arch === 'arm64' ? ' -PjibArchitecture=arm64' : ''}`; + } else if (application.buildToolMaven) { + imagePath = this.destinationPath(this.directoryPath, application.appFolder, '/target/jib-cache'); + runCommand = `./mvnw -ntp -Pprod verify jib:dockerBuild${ + process.arch === 'arm64' ? ' -Djib-maven-plugin.architecture=arm64' : '' + }`; + } + if (!existsSync(imagePath)) { + this.hasWarning = true; + this.warningMessage += ` ${chalk.cyan(runCommand)} in ${this.destinationPath(this.directoryPath, application.appFolder)}\n`; + } + }); + }, + + loadPlatformConfig({ deployment }) { + loadDeploymentConfig.call(this, { deployment }); + }, + + insight() { + statistics.sendSubGenEvent('generator', GENERATOR_DOCKER_COMPOSE); + }, + + prepareDeployment({ deployment, applications }) { + deployment.usesOauth2 = applications.some(appConfig => appConfig.authenticationTypeOauth2); + deployment.useKafka = applications.some(appConfig => appConfig.messageBrokerKafka); + deployment.usePulsar = applications.some(appConfig => appConfig.messageBrokerPulsar); + deployment.useMemcached = applications.some(appConfig => appConfig.cacheProviderMemcached); + deployment.entryPort = 8080; + + deployment.appConfigs = applications; + }, + + async setAppsYaml({ deployment, applications }) { const faker = await createFaker(); - this.appsYaml = []; - this.keycloakRedirectUris = ''; - this.includesApplicationTypeGateway = false; - this.appConfigs.forEach(appConfig => { + deployment.appsYaml = []; + deployment.keycloakRedirectUris = ''; + deployment.includesApplicationTypeGateway = false; + applications.forEach(appConfig => { const lowercaseBaseName = appConfig.baseName.toLowerCase(); + appConfig.clusteredDb = deployment.clusteredDbApps?.includes(appConfig.appFolder); const parentConfiguration = {}; - const path = this.destinationPath(this.directoryPath + appConfig.appFolder); + const path = this.destinationPath(this.directoryPath, appConfig.appFolder); // Add application configuration const yaml = jsyaml.load(this.fs.read(`${path}/src/main/docker/app.yml`)); const yamlConfig = yaml.services.app; @@ -203,16 +406,16 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { ); } if (appConfig.applicationType === GATEWAY) { - this.includesApplicationTypeGateway = true; + deployment.includesApplicationTypeGateway = true; } if (appConfig.applicationType === GATEWAY || appConfig.applicationType === MONOLITH) { - if (this.keycloakSecrets === undefined && appConfig.authenticationType === OAUTH2) { + if (deployment.keycloakSecrets === undefined && appConfig.authenticationType === OAUTH2) { faker.seed(stringHashCode(appConfig.baseName)); - this.keycloakSecrets = Array.from(Array(6), () => faker.string.uuid()); + deployment.keycloakSecrets = Array.from(Array(6), () => faker.string.uuid()); } - this.keycloakRedirectUris += `"http://localhost:${appConfig.composePort}/*", "https://localhost:${appConfig.composePort}/*", `; + deployment.keycloakRedirectUris += `"http://localhost:${appConfig.composePort}/*", "https://localhost:${appConfig.composePort}/*", `; if (appConfig.devServerPort !== undefined) { - this.keycloakRedirectUris += `"http://localhost:${appConfig.devServerPort}/*", `; + deployment.keycloakRedirectUris += `"http://localhost:${appConfig.devServerPort}/*", `; } // Split ports by ":" and take last 2 elements to skip the hostname/IP if present const ports = yamlConfig.ports[0].split(':').slice(-2); @@ -251,17 +454,17 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { }); } - if (appConfig.applicationType === MONOLITH && this.monitoring === PROMETHEUS) { + if (appConfig.applicationType === MONOLITH && deployment.monitoring === PROMETHEUS) { yamlConfig.environment.push('JHIPSTER_LOGGING_LOGSTASH_ENABLED=false'); yamlConfig.environment.push('MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true'); } - if (this.serviceDiscoveryType === EUREKA) { + if (deployment.serviceDiscoveryType === EUREKA) { // Set the JHipster Registry password - yamlConfig.environment.push(`JHIPSTER_REGISTRY_PASSWORD=${this.adminPassword}`); + yamlConfig.environment.push(`JHIPSTER_REGISTRY_PASSWORD=${deployment.adminPassword}`); } - const hasNoServiceDiscovery = !this.serviceDiscoveryType && this.serviceDiscoveryType !== NO_SERVICE_DISCOVERY; + const hasNoServiceDiscovery = !deployment.serviceDiscoveryType && deployment.serviceDiscoveryType !== NO_SERVICE_DISCOVERY; if (hasNoServiceDiscovery && appConfig.skipClient) { yamlConfig.environment.push('SERVER_PORT=80'); // to simplify service resolution in docker/k8s } @@ -321,8 +524,7 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { // Add Memcached support const cacheProvider = appConfig.cacheProvider; if (cacheProvider === MEMCACHED) { - this.useMemcached = true; - const memcachedYaml = jsyaml.load(this.fs.read(`${path}/src/main/docker/memcached.yml`)); + const memcachedYaml = jsyaml.load(deployment.fs.read(`${path}/src/main/docker/memcached.yml`)); const memcachedConfig = memcachedYaml.services.memcached; delete memcachedConfig.ports; parentConfiguration[`${lowercaseBaseName}-memcached`] = memcachedConfig; @@ -330,14 +532,14 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { // Add Redis support if (cacheProvider === REDIS) { - this.useRedis = true; + deployment.useRedis = true; const redisYaml = jsyaml.load(this.fs.read(`${path}/src/main/docker/redis.yml`)); const redisConfig = redisYaml.services.redis; delete redisConfig.ports; parentConfiguration[`${lowercaseBaseName}-redis`] = redisConfig; } // Expose authenticationType - this.authenticationType = appConfig.authenticationType; + deployment.authenticationType = appConfig.authenticationType; // Dump the file let yamlString = jsyaml.dump(parentConfiguration, { indent: 2, lineWidth: -1 }); @@ -348,15 +550,24 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { yamlArray[j] = ` ${yamlArray[j]}`; } yamlString = yamlArray.join('\n'); - this.appsYaml.push(yamlString); + deployment.appsYaml.push(yamlString); - this.skipClient = appConfig.skipClient; + deployment.skipClient = appConfig.skipClient; }); }, + preparePrometheusFiles({ deployment, applications }) { + if (deployment.monitoring !== PROMETHEUS) return; + + // Generate a list of target apps to monitor for the prometheus config + const appsToMonitor = applications.map(application => ` - ${application.baseName}:${application.composePort}`); + + // Format the application target list as a YAML array + deployment.appsToMonitorList = appsToMonitor.join('\n').replace(/'/g, ''); + }, }; } - get [BaseDockerGenerator.DEFAULT]() { + get [BaseWorkspacesGenerator.DEFAULT]() { return this.delegateTasksToBlueprint(() => this.default); } @@ -364,13 +575,13 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { return writeFiles(); } - get [BaseDockerGenerator.WRITING]() { + get [BaseWorkspacesGenerator.WRITING]() { return this.delegateTasksToBlueprint(() => this.writing); } get end() { return { - end() { + end({ applications }) { if (this.hasWarning) { this.log.warn('Docker Compose configuration generated, but no Jib cache found'); this.log.warn('If you forgot to generate the Docker image for this application, please run:'); @@ -379,20 +590,21 @@ export default class DockerComposeGenerator extends BaseDockerGenerator { this.log.verboseInfo(`${chalk.bold.green('Docker Compose configuration successfully generated!')}`); } this.log.verboseInfo(`You can launch all your infrastructure by running : ${chalk.cyan('docker compose up -d')}`); - if (this.gatewayNb + this.monolithicNb > 1) { + const uiApplications = applications.filter( + app => (app.applicationTypeGateway || app.applicationTypeMonolith) && app.clientFrameworkAny, + ); + if (uiApplications.length > 0) { this.log.log('\nYour applications will be accessible on these URLs:'); - this.appConfigs.forEach(appConfig => { - if (appConfig.applicationType === GATEWAY || appConfig.applicationType === MONOLITH) { - this.log.verboseInfo(`\t- ${appConfig.baseName}: http://localhost:${appConfig.composePort}`); - } - }); + for (const application of uiApplications) { + this.log.verboseInfo(`\t- ${application.baseName}: http://localhost:${application.composePort}`); + } this.log.log('\n'); } }, }; } - get [BaseDockerGenerator.END]() { + get [BaseWorkspacesGenerator.END]() { return this.delegateTasksToBlueprint(() => this.end); } } diff --git a/generators/docker-compose/index.mts b/generators/docker-compose/index.mts index cfcecfbd2954..855a438fcc02 100644 --- a/generators/docker-compose/index.mts +++ b/generators/docker-compose/index.mts @@ -17,3 +17,4 @@ * limitations under the License. */ export { default } from './generator.mjs'; +export { default as command } from './command.mjs'; From fdf8b8b5657b893d2f9255d9764b53b5a8acc715 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 2 Sep 2023 22:04:46 -0300 Subject: [PATCH 13/27] docker-compose derived properties --- generators/docker-compose/generator.mjs | 48 +++++++++---------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index fdbe37d32290..6ebef30c763b 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -27,15 +27,7 @@ import { existsSync } from 'fs'; import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import { writeFiles } from './files.mjs'; -import { - authenticationTypes, - applicationTypes, - cacheTypes, - databaseTypes, - monitoringTypes, - serviceDiscoveryTypes, - searchEngineTypes, -} from '../../jdl/jhipster/index.mjs'; +import { monitoringTypes, serviceDiscoveryTypes } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; import { stringHashCode, createFaker, convertSecretToBase64, createBase64Secret, normalizePathEnd } from '../base/support/index.mjs'; import { loadDeploymentConfig } from '../base-workspaces/internal/deployments.mjs'; @@ -44,13 +36,8 @@ import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mj import statistics from '../statistics.mjs'; import command from './command.mjs'; -const { GATEWAY, MONOLITH } = applicationTypes; const { PROMETHEUS, NO: NO_MONITORING } = monitoringTypes; const { CONSUL, EUREKA, NO: NO_SERVICE_DISCOVERY } = serviceDiscoveryTypes; -const { CASSANDRA, COUCHBASE, MONGODB, ORACLE, NO: NO_DATABASE } = databaseTypes; -const { ELASTICSEARCH } = searchEngineTypes; -const { MEMCACHED, REDIS } = cacheTypes; -const { OAUTH2 } = authenticationTypes; /* eslint-disable consistent-return */ /** @@ -376,6 +363,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { deployment.useKafka = applications.some(appConfig => appConfig.messageBrokerKafka); deployment.usePulsar = applications.some(appConfig => appConfig.messageBrokerPulsar); deployment.useMemcached = applications.some(appConfig => appConfig.cacheProviderMemcached); + deployment.useRedis = applications.some(appConfig => appConfig.cacheProviderRedis); deployment.entryPort = 8080; deployment.appConfigs = applications; @@ -405,11 +393,11 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { }), ); } - if (appConfig.applicationType === GATEWAY) { + if (appConfig.applicationTypeGateway) { deployment.includesApplicationTypeGateway = true; } - if (appConfig.applicationType === GATEWAY || appConfig.applicationType === MONOLITH) { - if (deployment.keycloakSecrets === undefined && appConfig.authenticationType === OAUTH2) { + if (appConfig.applicationTypeGateway || appConfig.applicationTypeMonolith) { + if (deployment.keycloakSecrets === undefined && appConfig.authenticationTypeOauth2) { faker.seed(stringHashCode(appConfig.baseName)); deployment.keycloakSecrets = Array.from(Array(6), () => faker.string.uuid()); } @@ -454,7 +442,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { }); } - if (appConfig.applicationType === MONOLITH && deployment.monitoring === PROMETHEUS) { + if (appConfig.applicationTypeMonolith && deployment.monitoring === PROMETHEUS) { yamlConfig.environment.push('JHIPSTER_LOGGING_LOGSTASH_ENABLED=false'); yamlConfig.environment.push('MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true'); } @@ -472,8 +460,8 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { parentConfiguration[lowercaseBaseName] = yamlConfig; // Add database configuration - const database = appConfig.databaseTypeSql ? appConfig.prodDatabaseType : appConfig.databaseType; - if (database !== NO_DATABASE && database !== ORACLE) { + if (appConfig.databaseTypeAny && !appConfig.prodDatabaseTypeOracle) { + const database = appConfig.databaseTypeSql ? appConfig.prodDatabaseType : appConfig.databaseType; const relativePath = normalize(pathjs.relative(this.destinationRoot(), `${path}/src/main/docker`)); const databaseYaml = jsyaml.load(this.fs.read(`${path}/src/main/docker/${database}.yml`)); const databaseServiceName = `${lowercaseBaseName}-${database}`; @@ -481,7 +469,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { // Don't export database ports delete databaseYamlConfig.ports; - if (database === CASSANDRA) { + if (appConfig.databaseTypeCassandra) { // migration service config const cassandraMigrationYaml = jsyaml.load(this.fs.read(`${path}/src/main/docker/cassandra-migration.yml`)); const cassandraMigrationConfig = cassandraMigrationYaml.services[`${database}-migration`]; @@ -492,7 +480,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { parentConfiguration[`${databaseServiceName}-migration`] = cassandraMigrationConfig; } - if (database === COUCHBASE) { + if (appConfig.databaseTypeCouchbase) { databaseYamlConfig.build.context = relativePath; } @@ -502,28 +490,27 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { dbNodeConfig.build.context = relativePath; databaseYamlConfig = clusterDbYaml.services[database]; delete databaseYamlConfig.ports; - if (database === COUCHBASE) { + if (appConfig.databaseTypeCouchbase) { databaseYamlConfig.build.context = relativePath; } parentConfiguration[`${databaseServiceName}-node`] = dbNodeConfig; - if (database === MONGODB) { + if (appConfig.databaseTypeMongodb) { parentConfiguration[`${databaseServiceName}-config`] = clusterDbYaml.services[`${database}-config`]; } } parentConfiguration[databaseServiceName] = databaseYamlConfig; } - // Add search engine configuration - const searchEngine = appConfig.searchEngine; - if (searchEngine === ELASTICSEARCH) { + if (appConfig.searchEngineElasticsearch) { + // Add search engine configuration + const searchEngine = appConfig.searchEngine; const searchEngineYaml = jsyaml.load(this.fs.read(`${path}/src/main/docker/${searchEngine}.yml`)); const searchEngineConfig = searchEngineYaml.services[searchEngine]; delete searchEngineConfig.ports; parentConfiguration[`${lowercaseBaseName}-${searchEngine}`] = searchEngineConfig; } // Add Memcached support - const cacheProvider = appConfig.cacheProvider; - if (cacheProvider === MEMCACHED) { + if (appConfig.cacheProviderMemcached) { const memcachedYaml = jsyaml.load(deployment.fs.read(`${path}/src/main/docker/memcached.yml`)); const memcachedConfig = memcachedYaml.services.memcached; delete memcachedConfig.ports; @@ -531,8 +518,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { } // Add Redis support - if (cacheProvider === REDIS) { - deployment.useRedis = true; + if (appConfig.cacheProviderRedis) { const redisYaml = jsyaml.load(this.fs.read(`${path}/src/main/docker/redis.yml`)); const redisConfig = redisYaml.services.redis; delete redisConfig.ports; From 69cf6b714007e1de8ddf39047be545342dc767dc Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 2 Sep 2023 22:24:04 -0300 Subject: [PATCH 14/27] adjusts --- .../internal}/docker-prompts.mjs | 6 +++--- generators/docker-compose/generator.mjs | 10 ++++++++-- generators/gae/generator.mjs | 2 +- generators/kubernetes/prompts.mjs | 2 +- generators/openshift/prompts.mjs | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) rename generators/{docker-compose => base-workspaces/internal}/docker-prompts.mjs (98%) diff --git a/generators/docker-compose/docker-prompts.mjs b/generators/base-workspaces/internal/docker-prompts.mjs similarity index 98% rename from generators/docker-compose/docker-prompts.mjs rename to generators/base-workspaces/internal/docker-prompts.mjs index dd5761eec877..4ce25e5f7270 100644 --- a/generators/docker-compose/docker-prompts.mjs +++ b/generators/base-workspaces/internal/docker-prompts.mjs @@ -19,9 +19,9 @@ import chalk from 'chalk'; import shelljs from 'shelljs'; -import { loadConfigs } from '../base-workspaces/internal/docker-base.mjs'; -import { applicationTypes, monitoringTypes, serviceDiscoveryTypes } from '../../jdl/jhipster/index.mjs'; -import { convertSecretToBase64 } from '../base/support/index.mjs'; +import { loadConfigs } from './docker-base.mjs'; +import { applicationTypes, monitoringTypes, serviceDiscoveryTypes } from '../../../jdl/jhipster/index.mjs'; +import { convertSecretToBase64 } from '../../base/support/index.mjs'; const { MICROSERVICE, MONOLITH, GATEWAY } = applicationTypes; const { PROMETHEUS } = monitoringTypes; diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index 6ebef30c763b..912f7a038b14 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -265,7 +265,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { const serviceDiscoveryEnabledApps = applications.filter(app => app.serviceDiscoveryAny); if (serviceDiscoveryEnabledApps.length === 0) { - this.jhipsterConfig.serviceDiscoveryType = 'no'; + this.jhipsterConfig.serviceDiscoveryType = NO_SERVICE_DISCOVERY; return; } @@ -306,9 +306,15 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { ], default: CONSUL, }, + ], + this.config, + ); + } + if (this.jhipsterConfig.serviceDiscoveryType === EUREKA) { + await this.prompt( + [ { type: 'input', - when: answers => answers.serviceDiscoveryType === EUREKA, name: 'adminPassword', message: 'Enter the admin password used to secure the JHipster Registry', default: 'admin', diff --git a/generators/gae/generator.mjs b/generators/gae/generator.mjs index 0247793465e0..373113eddb0f 100644 --- a/generators/gae/generator.mjs +++ b/generators/gae/generator.mjs @@ -27,7 +27,7 @@ import runAsync from 'run-async'; import BaseGenerator from '../base/index.mjs'; import { GENERATOR_GAE } from '../generator-list.mjs'; import statistics from '../statistics.mjs'; -import dockerPrompts from '../docker-compose/docker-prompts.mjs'; +import dockerPrompts from '../base-workspaces/internal/docker-prompts.mjs'; import { CLIENT_MAIN_SRC_DIR, MAIN_DIR, SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; import { applicationTypes, buildToolTypes, cacheTypes, databaseTypes } from '../../jdl/jhipster/index.mjs'; import { mavenProdProfileContent, mavenPluginConfiguration, mavenProfileContent } from './templates.mjs'; diff --git a/generators/kubernetes/prompts.mjs b/generators/kubernetes/prompts.mjs index 4cadfba837a7..e96d8295cbcf 100644 --- a/generators/kubernetes/prompts.mjs +++ b/generators/kubernetes/prompts.mjs @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import dockerPrompts from '../docker-compose/docker-prompts.mjs'; +import dockerPrompts from '../base-workspaces/internal/docker-prompts.mjs'; import { defaultKubernetesConfig, ingressDefaultConfig } from './kubernetes-constants.mjs'; import { applicationTypes, databaseTypes, kubernetesPlatformTypes } from '../../jdl/jhipster/index.mjs'; diff --git a/generators/openshift/prompts.mjs b/generators/openshift/prompts.mjs index 58a183614afe..10e787d417cb 100644 --- a/generators/openshift/prompts.mjs +++ b/generators/openshift/prompts.mjs @@ -17,7 +17,7 @@ * limitations under the License. */ import { databaseTypes, monitoringTypes, searchEngineTypes, openshiftPlatformTypes } from '../../jdl/jhipster/index.mjs'; -import dockerPrompts from '../docker-compose/docker-prompts.mjs'; +import dockerPrompts from '../base-workspaces/internal/docker-prompts.mjs'; const { ELASTICSEARCH } = searchEngineTypes; const { PROMETHEUS } = monitoringTypes; From feb4b300ca8285381a3fb9af97c29c30b143fcfe Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 2 Sep 2023 23:26:48 -0300 Subject: [PATCH 15/27] adjusts --- generators/base-workspaces/generator.mts | 52 ++++++ .../base-workspaces/internal/deployments.mts | 4 +- generators/base/generator-base-todo.mts | 10 +- .../docker-compose.spec.mts.snap | 4 +- generators/docker-compose/generator.mjs | 165 ++++++++---------- .../prometheus-conf/prometheus.yml.ejs | 4 +- generators/server/support/config.mts | 4 +- 7 files changed, 134 insertions(+), 109 deletions(-) diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts index e1a637d406d4..c708520ecbac 100644 --- a/generators/base-workspaces/generator.mts +++ b/generators/base-workspaces/generator.mts @@ -19,11 +19,14 @@ import { readdir } from 'fs/promises'; import { existsSync } from 'fs'; +import chalk from 'chalk'; + import BaseGenerator from '../base/index.mjs'; import { PRIORITY_NAMES, QUEUES } from '../base/priorities.mjs'; import { YO_RC_FILE } from '../generator-constants.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs'; import command from './command.mjs'; +import { normalizePathEnd } from '../base/support/path.mjs'; const { LOADING, PREPARING, DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END } = PRIORITY_NAMES; @@ -51,6 +54,55 @@ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { } } + protected loadWorkspacesConfig() { + this.appsFolders = this.jhipsterConfig.appsFolders; + this.directoryPath = this.jhipsterConfig.directoryPath ?? './'; + } + + protected configureWorkspacesConfig() { + this.jhipsterConfig.directoryPath = normalizePathEnd(this.jhipsterConfig.directoryPath ?? './'); + } + + protected async askForWorkspacesConfig() { + await this.prompt( + [ + { + type: 'input', + name: 'directoryPath', + message: 'Enter the root directory where your applications are located', + default: '../', + validate: async input => { + const path = this.destinationPath(input); + if (existsSync(path)) { + const applications = await this.findApplicationFolders(path); + return applications.length === 0 ? `No application found in ${path}` : true; + } + return `${path} is not a directory or doesn't exist`; + }, + }, + ], + this.config, + ); + + const directoryPath = this.jhipsterConfig.directoryPath; + const appsFolders = (await this.findApplicationFolders(directoryPath)).filter(app => app !== 'jhipster-registry' && app !== 'registry'); + this.log.log(chalk.green(`${appsFolders.length} applications found at ${this.destinationPath(directoryPath)}\n`)); + + await this.prompt( + [ + { + type: 'checkbox', + name: 'appsFolders', + message: 'Which applications do you want to include in your configuration?', + choices: appsFolders, + default: appsFolders, + validate: input => (input.length === 0 ? 'Please choose at least one application' : true), + }, + ], + this.config, + ); + } + protected async findApplicationFolders(directoryPath = this.directoryPath ?? '.') { return (await readdir(this.destinationPath(directoryPath), { withFileTypes: true })) .filter(dirent => dirent.isDirectory()) diff --git a/generators/base-workspaces/internal/deployments.mts b/generators/base-workspaces/internal/deployments.mts index 2f81048e8880..6a89b43f62c4 100644 --- a/generators/base-workspaces/internal/deployments.mts +++ b/generators/base-workspaces/internal/deployments.mts @@ -18,7 +18,7 @@ */ import _ from 'lodash'; import { applicationOptions, deploymentOptions } from '../../../jdl/index.js'; -import { loadDerivedPlatformConfig, loadPlatformConfig, loadServerAndPlatformConfig } from '../../server/support/index.mjs'; +import { loadDerivedPlatformConfig, loadPlatformConfig, loadDerivedServerAndPlatformProperties } from '../../server/support/index.mjs'; import type { GeneratorBaseCore } from '../../index.js'; const { OptionNames } = applicationOptions; @@ -42,5 +42,5 @@ export function loadDeploymentConfig( deployment.jwtSecretKey = config[JWT_SECRET_KEY]; loadPlatformConfig({ config, application: deployment }); loadDerivedPlatformConfig({ application: deployment }); - loadServerAndPlatformConfig({ application: deployment }); + loadDerivedServerAndPlatformProperties({ application: deployment }); } diff --git a/generators/base/generator-base-todo.mts b/generators/base/generator-base-todo.mts index 605b7064d491..88e07ffc944b 100644 --- a/generators/base/generator-base-todo.mts +++ b/generators/base/generator-base-todo.mts @@ -22,7 +22,7 @@ import { loadDerivedPlatformConfig, loadDerivedServerConfig, loadPlatformConfig, - loadServerAndPlatformConfig, + loadDerivedServerAndPlatformProperties, loadServerConfig, } from '../server/support/index.mjs'; import { loadClientConfig, loadDerivedClientConfig } from '../client/support/index.mjs'; @@ -79,8 +79,8 @@ export default abstract class JHipsterBaseGenerator extends JHipsterBaseCoreGene /** * @deprecated */ - loadServerAndPlatformConfig(application: any = this) { - loadServerAndPlatformConfig({ application }); + loadDerivedServerAndPlatformProperties(application: any = this) { + loadDerivedServerAndPlatformProperties({ application }); } /** @@ -88,7 +88,7 @@ export default abstract class JHipsterBaseGenerator extends JHipsterBaseCoreGene */ loadDerivedServerConfig(application: any = this) { loadDerivedServerConfig({ application }); - (this as any).loadServerAndPlatformConfig(application); + (this as any).loadDerivedServerAndPlatformProperties(application); } /** @@ -104,6 +104,6 @@ export default abstract class JHipsterBaseGenerator extends JHipsterBaseCoreGene */ loadDerivedPlatformConfig(application: any = this) { loadDerivedPlatformConfig({ application }); - (this as any).loadServerAndPlatformConfig(application); + (this as any).loadDerivedServerAndPlatformProperties(application); } } diff --git a/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap b/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap index e419c90f563b..8c33b6bbdf31 100644 --- a/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap +++ b/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap @@ -2652,8 +2652,8 @@ scrape_configs: metrics_path: /management/prometheus static_configs: - targets: - - jhgate:8080 - - msmysql:8081 + - jhgate:8080 + - msmysql:8081 ", "stateCleared": "modified", }, diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index 912f7a038b14..5927d7fbc599 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -16,28 +16,31 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { existsSync } from 'fs'; import pathjs from 'path'; import chalk from 'chalk'; import shelljs from 'shelljs'; import jsyaml from 'js-yaml'; import normalize from 'normalize-path'; import runAsync from 'run-async'; +import _ from 'lodash'; -import { existsSync } from 'fs'; import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import { writeFiles } from './files.mjs'; -import { monitoringTypes, serviceDiscoveryTypes } from '../../jdl/jhipster/index.mjs'; +import { deploymentOptions, monitoringTypes, serviceDiscoveryTypes } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; -import { stringHashCode, createFaker, convertSecretToBase64, createBase64Secret, normalizePathEnd } from '../base/support/index.mjs'; -import { loadDeploymentConfig } from '../base-workspaces/internal/deployments.mjs'; +import { stringHashCode, createFaker, convertSecretToBase64, createBase64Secret } from '../base/support/index.mjs'; import { checkDocker } from '../base-workspaces/internal/docker-base.mjs'; import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; import statistics from '../statistics.mjs'; import command from './command.mjs'; +import { loadDerivedPlatformConfig, loadPlatformConfig, loadDerivedServerAndPlatformProperties } from '../server/support/index.mjs'; const { PROMETHEUS, NO: NO_MONITORING } = monitoringTypes; const { CONSUL, EUREKA, NO: NO_SERVICE_DISCOVERY } = serviceDiscoveryTypes; +const { Options: DeploymentOptions } = deploymentOptions; +const { defaults } = _; /* eslint-disable consistent-return */ /** @@ -112,23 +115,10 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { async askForOptions() { if (this.regenerate && !this.options.askAnswered) return; + await this.askForWorkspacesConfig(); + /* await this.prompt( [ - { - type: 'input', - name: 'directoryPath', - message: 'Enter the root directory where your applications are located', - default: '../', - validate: async input => { - const path = this.destinationPath(input); - if (existsSync(path)) { - const applications = await this.findApplicationFolders(path); - return applications.length === 0 ? `No application found in ${path}` : true; - } - return `${path} is not a directory or doesn't exist`; - }, - }, - /* { type: 'list', name: 'deploymentApplicationType', @@ -158,30 +148,16 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { ], default: 'SpringCloudGateway', }, - */ ], this.config, ); + */ }, - async askForPath() { + async askForMonitoring() { if (this.regenerate) return; - const directoryPath = this.jhipsterConfig.directoryPath; - const appsFolders = (await this.findApplicationFolders(directoryPath)).filter( - app => app !== 'jhipster-registry' && app !== 'registry', - ); - this.log.log(chalk.green(`${appsFolders.length} applications found at ${this.destinationPath(directoryPath)}\n`)); - await this.prompt( [ - { - type: 'checkbox', - name: 'appsFolders', - message: 'Which applications do you want to include in your configuration?', - choices: appsFolders, - default: appsFolders, - validate: input => (input.length === 0 ? 'Please choose at least one application' : true), - }, { type: 'list', name: 'monitoring', @@ -211,8 +187,10 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get configuring() { return { - configureDeployment() { - this.jhipsterConfig.directoryPath = normalizePathEnd(this.jhipsterConfig.directoryPath ?? './'); + configureWorkspaces() { + this.configureWorkspacesConfig(); + }, + configureBaseDeployment() { this.jhipsterConfig.jwtSecretKey = this.jhipsterConfig.jwtSecretKey ?? createBase64Secret(this.options.reproducibleTests); }, }; @@ -224,10 +202,10 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get loading() { return { - loadDeployment({ deployment }) { - this.appsFolders = this.jhipsterConfig.appsFolders; - this.directoryPath = this.jhipsterConfig.directoryPath ?? './'; - + loadWorkspacesConfig() { + this.loadWorkspacesConfig(); + }, + loadBaseDeployment({ deployment }) { deployment.jwtSecretKey = this.jhipsterConfig.jwtSecretKey; loadDockerDependenciesTask.call(this, { context: deployment }); @@ -326,38 +304,17 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { } }, - configurePassword() { - if (this.jhipsterConfig.serviceDiscoveryType !== EUREKA) return; - - this.jhipsterConfig.adminPasswordBase64 = convertSecretToBase64(this.jhipsterConfig.adminPassword); - }, - - checkImages({ applications }) { - this.log.log('\nChecking Docker images in applications directories...'); - - let imagePath = ''; - let runCommand = ''; - this.hasWarning = false; - this.warningMessage = 'To generate the missing Docker image(s), please run:\n'; - applications.forEach(application => { - if (application.buildToolGradle) { - imagePath = this.destinationPath(this.directoryPath, application.appFolder, 'build/jib-cache'); - runCommand = `./gradlew bootJar -Pprod jibDockerBuild${process.arch === 'arm64' ? ' -PjibArchitecture=arm64' : ''}`; - } else if (application.buildToolMaven) { - imagePath = this.destinationPath(this.directoryPath, application.appFolder, '/target/jib-cache'); - runCommand = `./mvnw -ntp -Pprod verify jib:dockerBuild${ - process.arch === 'arm64' ? ' -Djib-maven-plugin.architecture=arm64' : '' - }`; - } - if (!existsSync(imagePath)) { - this.hasWarning = true; - this.warningMessage += ` ${chalk.cyan(runCommand)} in ${this.destinationPath(this.directoryPath, application.appFolder)}\n`; - } - }); - }, - loadPlatformConfig({ deployment }) { - loadDeploymentConfig.call(this, { deployment }); + const config = this.deploymentConfigWithDefaults; + deployment.clusteredDbApps = config.clusteredDbApps; + deployment.adminPassword = config.adminPassword; + if (deployment.adminPassword) { + deployment.adminPasswordBase64 = convertSecretToBase64(deployment.adminPassword); + } + deployment.jwtSecretKey = config.jwtSecretKey; + loadPlatformConfig({ config, application: deployment }); + loadDerivedPlatformConfig({ application: deployment }); + loadDerivedServerAndPlatformProperties({ application: deployment }); }, insight() { @@ -370,18 +327,18 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { deployment.usePulsar = applications.some(appConfig => appConfig.messageBrokerPulsar); deployment.useMemcached = applications.some(appConfig => appConfig.cacheProviderMemcached); deployment.useRedis = applications.some(appConfig => appConfig.cacheProviderRedis); + deployment.includesApplicationTypeGateway = applications.some(appConfig => appConfig.applicationTypeGateway); deployment.entryPort = 8080; deployment.appConfigs = applications; + deployment.applications = applications; }, async setAppsYaml({ deployment, applications }) { const faker = await createFaker(); - deployment.appsYaml = []; deployment.keycloakRedirectUris = ''; - deployment.includesApplicationTypeGateway = false; - applications.forEach(appConfig => { + deployment.appsYaml = applications.map(appConfig => { const lowercaseBaseName = appConfig.baseName.toLowerCase(); appConfig.clusteredDb = deployment.clusteredDbApps?.includes(appConfig.appFolder); const parentConfiguration = {}; @@ -399,9 +356,6 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { }), ); } - if (appConfig.applicationTypeGateway) { - deployment.includesApplicationTypeGateway = true; - } if (appConfig.applicationTypeGateway || appConfig.applicationTypeMonolith) { if (deployment.keycloakSecrets === undefined && appConfig.authenticationTypeOauth2) { faker.seed(stringHashCode(appConfig.baseName)); @@ -542,20 +496,9 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { yamlArray[j] = ` ${yamlArray[j]}`; } yamlString = yamlArray.join('\n'); - deployment.appsYaml.push(yamlString); - - deployment.skipClient = appConfig.skipClient; + return yamlString; }); }, - preparePrometheusFiles({ deployment, applications }) { - if (deployment.monitoring !== PROMETHEUS) return; - - // Generate a list of target apps to monitor for the prometheus config - const appsToMonitor = applications.map(application => ` - ${application.baseName}:${application.composePort}`); - - // Format the application target list as a YAML array - deployment.appsToMonitorList = appsToMonitor.join('\n').replace(/'/g, ''); - }, }; } @@ -574,13 +517,8 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get end() { return { end({ applications }) { - if (this.hasWarning) { - this.log.warn('Docker Compose configuration generated, but no Jib cache found'); - this.log.warn('If you forgot to generate the Docker image for this application, please run:'); - this.log.log(chalk.red(this.warningMessage)); - } else { - this.log.verboseInfo(`${chalk.bold.green('Docker Compose configuration successfully generated!')}`); - } + this.checkApplicationsDockerImages({ applications }); + this.log.verboseInfo(`You can launch all your infrastructure by running : ${chalk.cyan('docker compose up -d')}`); const uiApplications = applications.filter( app => (app.applicationTypeGateway || app.applicationTypeMonolith) && app.clientFrameworkAny, @@ -599,4 +537,37 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get [BaseWorkspacesGenerator.END]() { return this.delegateTasksToBlueprint(() => this.end); } + + checkApplicationsDockerImages({ applications }) { + this.log.log('\nChecking Docker images in applications directories...'); + + let imagePath = ''; + let runCommand = ''; + let hasWarning = false; + let warningMessage = 'To generate the missing Docker image(s), please run:\n'; + applications.forEach(application => { + if (application.buildToolGradle) { + imagePath = this.destinationPath(this.directoryPath, application.appFolder, 'build/jib-cache'); + runCommand = `./gradlew bootJar -Pprod jibDockerBuild${process.arch === 'arm64' ? ' -PjibArchitecture=arm64' : ''}`; + } else if (application.buildToolMaven) { + imagePath = this.destinationPath(this.directoryPath, application.appFolder, '/target/jib-cache'); + runCommand = `./mvnw -ntp -Pprod verify jib:dockerBuild${process.arch === 'arm64' ? ' -Djib-maven-plugin.architecture=arm64' : ''}`; + } + if (!existsSync(imagePath)) { + hasWarning = true; + warningMessage += ` ${chalk.cyan(runCommand)} in ${this.destinationPath(this.directoryPath, application.appFolder)}\n`; + } + }); + if (hasWarning) { + this.log.warn('Docker Compose configuration generated, but no Jib cache found'); + this.log.warn('If you forgot to generate the Docker image for this application, please run:'); + this.log.log(chalk.red(warningMessage)); + } else { + this.log.verboseInfo(`${chalk.bold.green('Docker Compose configuration successfully generated!')}`); + } + } + + get deploymentConfigWithDefaults() { + return defaults({}, this.jhipsterConfig, DeploymentOptions.defaults(this.jhipsterConfig.deploymentType)); + } } diff --git a/generators/docker-compose/templates/prometheus-conf/prometheus.yml.ejs b/generators/docker-compose/templates/prometheus-conf/prometheus.yml.ejs index bfc0f9624c72..44d0ed47633d 100644 --- a/generators/docker-compose/templates/prometheus-conf/prometheus.yml.ejs +++ b/generators/docker-compose/templates/prometheus-conf/prometheus.yml.ejs @@ -50,4 +50,6 @@ scrape_configs: metrics_path: /management/prometheus static_configs: - targets: -<%= appsToMonitorList %> +<%_ for (const application of applications) { _%> + - <%- application.baseName %>:<%- application.composePort %> +<%_ } _%> diff --git a/generators/server/support/config.mts b/generators/server/support/config.mts index 88c604e47daa..cfccca925633 100644 --- a/generators/server/support/config.mts +++ b/generators/server/support/config.mts @@ -101,7 +101,7 @@ export const loadDerivedPlatformConfig = ({ application }: { application: Platfo application.monitoringPrometheus = application.monitoring === PROMETHEUS; }; -export const loadServerAndPlatformConfig = ({ application }: { application: any }) => { +export const loadDerivedServerAndPlatformProperties = ({ application }: { application: any }) => { if (!application.serviceDiscoveryType) { application.serviceDiscoveryType = NO_SERVICE_DISCOVERY; } @@ -180,5 +180,5 @@ export const loadDerivedServerConfig = ({ application }: { application: any }) = prepareSqlApplicationProperties({ application }); } - loadServerAndPlatformConfig({ application }); + loadDerivedServerAndPlatformProperties({ application }); }; From 99a6576e2cb72601702285e6903de81aaf2d8018 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 2 Sep 2023 23:33:03 -0300 Subject: [PATCH 16/27] more adjusts --- generators/docker-compose/generator.mjs | 254 +++++++++++++----------- 1 file changed, 137 insertions(+), 117 deletions(-) diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index 5927d7fbc599..0f0e25923694 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -156,27 +156,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { async askForMonitoring() { if (this.regenerate) return; - await this.prompt( - [ - { - type: 'list', - name: 'monitoring', - message: 'Do you want to setup monitoring for your applications ?', - choices: [ - { - value: NO_MONITORING, - name: 'No', - }, - { - value: PROMETHEUS, - name: 'Yes, for metrics only with Prometheus', - }, - ], - default: NO_MONITORING, - }, - ], - this.config, - ); + await this.askForMonitoring(); }, }; } @@ -222,99 +202,16 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { async askForClustersMode({ applications }) { if (this.regenerate) return; - const clusteredDbApps = applications.filter(app => app.databaseTypeMongodb || app.databaseTypeCouchbase).map(app => app.appFolder); - if (clusteredDbApps.length === 0) return; - - await this.prompt( - [ - { - type: 'checkbox', - name: 'clusteredDbApps', - message: 'Which applications do you want to use with clustered databases (only available with MongoDB and Couchbase)?', - choices: clusteredDbApps, - default: clusteredDbApps, - }, - ], - this.config, - ); + await this.askForClustersMode({ applications }); }, async askForServiceDiscovery({ applications }) { if (this.regenerate) return; - const serviceDiscoveryEnabledApps = applications.filter(app => app.serviceDiscoveryAny); - if (serviceDiscoveryEnabledApps.length === 0) { - this.jhipsterConfig.serviceDiscoveryType = NO_SERVICE_DISCOVERY; - return; - } - - if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryConsul)) { - this.jhipsterConfig.serviceDiscoveryType = CONSUL; - this.log.log(chalk.green('Consul detected as the service discovery and configuration provider used by your apps')); - } else if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryEureka)) { - this.jhipsterConfig.serviceDiscoveryType = EUREKA; - this.log.log(chalk.green('JHipster registry detected as the service discovery and configuration provider used by your apps')); - } else { - this.log.warn( - chalk.yellow('Unable to determine the service discovery and configuration provider to use from your apps configuration.'), - ); - this.log.verboseInfo('Your service discovery enabled apps:'); - serviceDiscoveryEnabledApps.forEach(app => { - this.log.verboseInfo(` -${app.baseName} (${app.serviceDiscoveryType})`); - }); - - await this.prompt( - [ - { - type: 'list', - name: 'serviceDiscoveryType', - message: 'Which Service Discovery registry and Configuration server would you like to use ?', - choices: [ - { - value: CONSUL, - name: 'Consul', - }, - { - value: EUREKA, - name: 'JHipster Registry', - }, - { - value: NO_SERVICE_DISCOVERY, - name: 'No Service Discovery and Configuration', - }, - ], - default: CONSUL, - }, - ], - this.config, - ); - } - if (this.jhipsterConfig.serviceDiscoveryType === EUREKA) { - await this.prompt( - [ - { - type: 'input', - name: 'adminPassword', - message: 'Enter the admin password used to secure the JHipster Registry', - default: 'admin', - validate: input => (input.length < 5 ? 'The password must have at least 5 characters' : true), - }, - ], - this.config, - ); - } + await this.askForServiceDiscovery({ applications }); }, loadPlatformConfig({ deployment }) { - const config = this.deploymentConfigWithDefaults; - deployment.clusteredDbApps = config.clusteredDbApps; - deployment.adminPassword = config.adminPassword; - if (deployment.adminPassword) { - deployment.adminPasswordBase64 = convertSecretToBase64(deployment.adminPassword); - } - deployment.jwtSecretKey = config.jwtSecretKey; - loadPlatformConfig({ config, application: deployment }); - loadDerivedPlatformConfig({ application: deployment }); - loadDerivedServerAndPlatformProperties({ application: deployment }); + this.loadDeploymentConfig({ deployment }); }, insight() { @@ -322,16 +219,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { }, prepareDeployment({ deployment, applications }) { - deployment.usesOauth2 = applications.some(appConfig => appConfig.authenticationTypeOauth2); - deployment.useKafka = applications.some(appConfig => appConfig.messageBrokerKafka); - deployment.usePulsar = applications.some(appConfig => appConfig.messageBrokerPulsar); - deployment.useMemcached = applications.some(appConfig => appConfig.cacheProviderMemcached); - deployment.useRedis = applications.some(appConfig => appConfig.cacheProviderRedis); - deployment.includesApplicationTypeGateway = applications.some(appConfig => appConfig.applicationTypeGateway); - deployment.entryPort = 8080; - - deployment.appConfigs = applications; - deployment.applications = applications; + this.prepareDeploymentDerivedProperties({ deployment, applications }); }, async setAppsYaml({ deployment, applications }) { @@ -570,4 +458,136 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get deploymentConfigWithDefaults() { return defaults({}, this.jhipsterConfig, DeploymentOptions.defaults(this.jhipsterConfig.deploymentType)); } + + loadDeploymentConfig({ deployment }) { + const config = this.deploymentConfigWithDefaults; + deployment.clusteredDbApps = config.clusteredDbApps; + deployment.adminPassword = config.adminPassword; + deployment.jwtSecretKey = config.jwtSecretKey; + loadPlatformConfig({ config, application: deployment }); + loadDerivedPlatformConfig({ application: deployment }); + loadDerivedServerAndPlatformProperties({ application: deployment }); + } + + prepareDeploymentDerivedProperties({ deployment, applications }) { + if (deployment.adminPassword) { + deployment.adminPasswordBase64 = convertSecretToBase64(deployment.adminPassword); + } + deployment.usesOauth2 = applications.some(appConfig => appConfig.authenticationTypeOauth2); + deployment.useKafka = applications.some(appConfig => appConfig.messageBrokerKafka); + deployment.usePulsar = applications.some(appConfig => appConfig.messageBrokerPulsar); + deployment.useMemcached = applications.some(appConfig => appConfig.cacheProviderMemcached); + deployment.useRedis = applications.some(appConfig => appConfig.cacheProviderRedis); + deployment.includesApplicationTypeGateway = applications.some(appConfig => appConfig.applicationTypeGateway); + deployment.entryPort = 8080; + + deployment.appConfigs = applications; + deployment.applications = applications; + } + + async askForMonitoring() { + await this.prompt( + [ + { + type: 'list', + name: 'monitoring', + message: 'Do you want to setup monitoring for your applications ?', + choices: [ + { + value: NO_MONITORING, + name: 'No', + }, + { + value: PROMETHEUS, + name: 'Yes, for metrics only with Prometheus', + }, + ], + default: NO_MONITORING, + }, + ], + this.config, + ); + } + + async askForClustersMode({ applications }) { + const clusteredDbApps = applications.filter(app => app.databaseTypeMongodb || app.databaseTypeCouchbase).map(app => app.appFolder); + if (clusteredDbApps.length === 0) return; + + await this.prompt( + [ + { + type: 'checkbox', + name: 'clusteredDbApps', + message: 'Which applications do you want to use with clustered databases (only available with MongoDB and Couchbase)?', + choices: clusteredDbApps, + default: clusteredDbApps, + }, + ], + this.config, + ); + } + + async askForServiceDiscovery({ applications }) { + const serviceDiscoveryEnabledApps = applications.filter(app => app.serviceDiscoveryAny); + if (serviceDiscoveryEnabledApps.length === 0) { + this.jhipsterConfig.serviceDiscoveryType = NO_SERVICE_DISCOVERY; + return; + } + + if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryConsul)) { + this.jhipsterConfig.serviceDiscoveryType = CONSUL; + this.log.log(chalk.green('Consul detected as the service discovery and configuration provider used by your apps')); + } else if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryEureka)) { + this.jhipsterConfig.serviceDiscoveryType = EUREKA; + this.log.log(chalk.green('JHipster registry detected as the service discovery and configuration provider used by your apps')); + } else { + this.log.warn( + chalk.yellow('Unable to determine the service discovery and configuration provider to use from your apps configuration.'), + ); + this.log.verboseInfo('Your service discovery enabled apps:'); + serviceDiscoveryEnabledApps.forEach(app => { + this.log.verboseInfo(` -${app.baseName} (${app.serviceDiscoveryType})`); + }); + + await this.prompt( + [ + { + type: 'list', + name: 'serviceDiscoveryType', + message: 'Which Service Discovery registry and Configuration server would you like to use ?', + choices: [ + { + value: CONSUL, + name: 'Consul', + }, + { + value: EUREKA, + name: 'JHipster Registry', + }, + { + value: NO_SERVICE_DISCOVERY, + name: 'No Service Discovery and Configuration', + }, + ], + default: CONSUL, + }, + ], + this.config, + ); + } + if (this.jhipsterConfig.serviceDiscoveryType === EUREKA) { + await this.prompt( + [ + { + type: 'input', + name: 'adminPassword', + message: 'Enter the admin password used to secure the JHipster Registry', + default: 'admin', + validate: input => (input.length < 5 ? 'The password must have at least 5 characters' : true), + }, + ], + this.config, + ); + } + } } From 89cbc278a92b1feebdf5e57b97b72629d554157a Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sun, 3 Sep 2023 07:35:14 -0300 Subject: [PATCH 17/27] adjust test --- jdl/models/jdl-deployment.spec.ts | 40 ++++++++++++++++++------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/jdl/models/jdl-deployment.spec.ts b/jdl/models/jdl-deployment.spec.ts index 9aa906566ac8..faf9bffff8c8 100644 --- a/jdl/models/jdl-deployment.spec.ts +++ b/jdl/models/jdl-deployment.spec.ts @@ -18,7 +18,7 @@ */ /* eslint-disable no-new, no-unused-expressions */ -import { expect } from 'chai'; +import { expect } from 'esmocha'; import JDLDeployment from '../models/jdl-deployment.js'; describe('jdl - JDLDeployment', () => { @@ -28,14 +28,14 @@ describe('jdl - JDLDeployment', () => { expect(() => { // @ts-expect-error new JDLDeployment(); - }).to.throw(/^The deploymentType is mandatory to create a deployment\.$/); + }).toThrow(/^The deploymentType is mandatory to create a deployment\.$/); }); }); context('when not passing the deploymentType', () => { it('should fail', () => { expect(() => { new JDLDeployment({ deploymentType: null }); - }).to.throw(/^The deploymentType is mandatory to create a deployment\.$/); + }).toThrow(/^The deploymentType is mandatory to create a deployment\.$/); }); }); context('when passing arguments', () => { @@ -52,9 +52,9 @@ describe('jdl - JDLDeployment', () => { }); it('should create a new instance', () => { - expect(deployment.deploymentType).to.equal(args.deploymentType); - expect(deployment.appsFolders).to.equal(args.appsFolders); - expect(deployment.dockerRepositoryName).to.equal(args.dockerRepositoryName); + expect(deployment.deploymentType).toEqual(args.deploymentType); + expect(deployment.appsFolders).toEqual(args.appsFolders); + expect(deployment.dockerRepositoryName).toEqual(args.dockerRepositoryName); }); }); }); @@ -75,11 +75,14 @@ describe('jdl - JDLDeployment', () => { }); it('should stringify its content without default values', () => { - expect(deployment.toString()).to.eql(`deployment { - appsFolders [${args.appsFolders.join(', ').replace(/'/g, '')}] - deploymentType ${args.deploymentType} - dockerRepositoryName ${args.dockerRepositoryName} - }`); + expect(deployment.toString()).toMatchInlineSnapshot(` +"deployment { + appsFolders [foo, bar] + clusteredDbApps [] + deploymentType docker-compose + dockerRepositoryName test + }" +`); }); }); context('with some non default options', () => { @@ -98,12 +101,15 @@ describe('jdl - JDLDeployment', () => { }); it('should stringify it', () => { - expect(deployment.toString()).to.eql(`deployment { - appsFolders [${args.appsFolders.join(', ').replace(/'/g, '')}] - directoryPath ${args.directoryPath} - deploymentType ${args.deploymentType} - dockerRepositoryName ${args.dockerRepositoryName} - }`); + expect(deployment.toString()).toMatchInlineSnapshot(` +"deployment { + appsFolders [foo, bar] + directoryPath ../parent + clusteredDbApps [] + deploymentType docker-compose + dockerRepositoryName test + }" +`); }); }); }); From 2f4d630a04844a4924e329e8f6d71d8e7624d4a6 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sun, 3 Sep 2023 08:32:02 -0300 Subject: [PATCH 18/27] add workspaces priorities. --- generators/base-workspaces/generator.mts | 72 ++++++++---- generators/base-workspaces/priorities.mts | 108 ++++++++++++++++++ generators/docker-compose/generator.mjs | 127 +++++++++++----------- 3 files changed, 218 insertions(+), 89 deletions(-) create mode 100644 generators/base-workspaces/priorities.mts diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts index c708520ecbac..981e29a964a7 100644 --- a/generators/base-workspaces/generator.mts +++ b/generators/base-workspaces/generator.mts @@ -22,18 +22,37 @@ import { existsSync } from 'fs'; import chalk from 'chalk'; import BaseGenerator from '../base/index.mjs'; -import { PRIORITY_NAMES, QUEUES } from '../base/priorities.mjs'; +import { PRIORITY_NAMES, QUEUES, CUSTOM_PRIORITIES } from './priorities.mjs'; import { YO_RC_FILE } from '../generator-constants.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs'; import command from './command.mjs'; import { normalizePathEnd } from '../base/support/path.mjs'; -const { LOADING, PREPARING, DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END } = PRIORITY_NAMES; +const { + PROMPTING_WORKSPACES, + CONFIGURING_WORKSPACES, + LOADING_WORKSPACES, + PREPARING_WORKSPACES, + DEFAULT, + WRITING, + POST_WRITING, + PRE_CONFLICTS, + INSTALL, + END, +} = PRIORITY_NAMES; /** * This is the base class for a generator that generates entities. */ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { + static PROMPTING_WORKSPACES = BaseGenerator.asPriority(PROMPTING_WORKSPACES); + + static CONFIGURING_WORKSPACES = BaseGenerator.asPriority(CONFIGURING_WORKSPACES); + + static LOADING_WORKSPACES = BaseGenerator.asPriority(LOADING_WORKSPACES); + + static PREPARING_WORKSPACES = BaseGenerator.asPriority(PREPARING_WORKSPACES); + appsFolders?: string[]; directoryPath!: string; @@ -41,6 +60,8 @@ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { super(args, options, features); if (!this.options.help) { + this.registerPriorities(CUSTOM_PRIORITIES); + this.queueTask({ async method() { await (this as any).bootstrapApplications(); @@ -64,6 +85,7 @@ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { } protected async askForWorkspacesConfig() { + let appsFolders; await this.prompt( [ { @@ -80,22 +102,20 @@ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { return `${path} is not a directory or doesn't exist`; }, }, - ], - this.config, - ); - - const directoryPath = this.jhipsterConfig.directoryPath; - const appsFolders = (await this.findApplicationFolders(directoryPath)).filter(app => app !== 'jhipster-registry' && app !== 'registry'); - this.log.log(chalk.green(`${appsFolders.length} applications found at ${this.destinationPath(directoryPath)}\n`)); - - await this.prompt( - [ { type: 'checkbox', name: 'appsFolders', + when: async answers => { + const directoryPath = answers.directoryPath; + appsFolders = (await this.findApplicationFolders(directoryPath)).filter( + app => app !== 'jhipster-registry' && app !== 'registry', + ); + this.log.log(chalk.green(`${appsFolders.length} applications found at ${this.destinationPath(directoryPath)}\n`)); + return true; + }, message: 'Which applications do you want to include in your configuration?', - choices: appsFolders, - default: appsFolders, + choices: () => appsFolders, + default: () => appsFolders, validate: input => (input.length === 0 ? 'Please choose at least one application' : true), }, ], @@ -131,20 +151,24 @@ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { getArgsForPriority(priorityName): any { const args = super.getArgsForPriority(priorityName); - if (![LOADING, PREPARING, DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END].includes(priorityName)) { + if ( + ![ + PROMPTING_WORKSPACES, + CONFIGURING_WORKSPACES, + LOADING_WORKSPACES, + PREPARING_WORKSPACES, + DEFAULT, + WRITING, + POST_WRITING, + PRE_CONFLICTS, + INSTALL, + END, + ].includes(priorityName) + ) { return args; } const [first, ...others] = args ?? []; const deployment = this.getSharedApplication(this.destinationPath()).sharedDeployment; - if (![DEFAULT, WRITING, POST_WRITING, PRE_CONFLICTS, INSTALL, END].includes(priorityName)) { - return [ - { - ...first, - deployment, - }, - ...others, - ]; - } const applications = (this.appsFolders ?? []).map((appFolder, index) => { const application = this.getSharedApplication(this.destinationPath(this.directoryPath ?? '.', appFolder))?.sharedApplication; application.appFolder = appFolder; diff --git a/generators/base-workspaces/priorities.mts b/generators/base-workspaces/priorities.mts new file mode 100644 index 000000000000..0b89b701d670 --- /dev/null +++ b/generators/base-workspaces/priorities.mts @@ -0,0 +1,108 @@ +/** + * Copyright 2013-2023 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 { QUEUE_PREFIX, PRIORITY_NAMES as PRIORITY_NAMES_BASE, QUEUES as QUEUES_BASE } from '../base/priorities.mjs'; + +const { DEFAULT } = PRIORITY_NAMES_BASE; + +/** Custom priorities */ +const PROMPTING_WORKSPACES = 'promptingWorkspaces'; +const PROMPTING_WORKSPACES_QUEUE = `${QUEUE_PREFIX}${PROMPTING_WORKSPACES}`; + +const CONFIGURING_WORKSPACES = 'configuringWorkspaces'; +const CONFIGURING_WORKSPACES_QUEUE = `${QUEUE_PREFIX}${CONFIGURING_WORKSPACES}`; + +const LOADING_WORKSPACES = 'loadingWorkspaces'; +const LOADING_WORKSPACES_QUEUE = `${QUEUE_PREFIX}${LOADING_WORKSPACES}`; + +const PREPARING_WORKSPACES = 'preparingWorkspaces'; +const PREPARING_WORKSPACES_QUEUE = `${QUEUE_PREFIX}${PREPARING_WORKSPACES}`; + +/** + * Custom priorities to improve jhipster workflow. + */ +export const CUSTOM_PRIORITIES = [ + { + priorityName: PROMPTING_WORKSPACES, + queueName: PROMPTING_WORKSPACES_QUEUE, + before: CONFIGURING_WORKSPACES, + args: generator => generator.getArgsForPriority(PROMPTING_WORKSPACES), + }, + { + priorityName: CONFIGURING_WORKSPACES, + queueName: CONFIGURING_WORKSPACES_QUEUE, + before: LOADING_WORKSPACES, + args: generator => generator.getArgsForPriority(CONFIGURING_WORKSPACES), + }, + { + priorityName: LOADING_WORKSPACES, + queueName: LOADING_WORKSPACES_QUEUE, + before: PREPARING_WORKSPACES, + args: generator => generator.getArgsForPriority(LOADING_WORKSPACES), + }, + { + priorityName: PREPARING_WORKSPACES, + queueName: PREPARING_WORKSPACES_QUEUE, + before: DEFAULT, + args: generator => generator.getArgsForPriority(PREPARING_WORKSPACES), + }, +].reverse(); + +const WORKSPACES_QUEUES = { + PROMPTING_WORKSPACES_QUEUE, + CONFIGURING_WORKSPACES_QUEUE, + LOADING_WORKSPACES_QUEUE, + PREPARING_WORKSPACES_QUEUE, +}; + +export const WORKSPACES_PRIORITY_NAMES = { + PROMPTING_WORKSPACES, + CONFIGURING_WORKSPACES, + LOADING_WORKSPACES, + PREPARING_WORKSPACES, +}; + +export const PRIORITY_NAMES = { + ...PRIORITY_NAMES_BASE, + ...WORKSPACES_PRIORITY_NAMES, +}; + +export const QUEUES = { + ...QUEUES_BASE, + ...WORKSPACES_QUEUES, +}; + +export const PRIORITY_NAMES_LIST = [ + PRIORITY_NAMES.INITIALIZING, + PRIORITY_NAMES.PROMPTING, + PRIORITY_NAMES.CONFIGURING, + PRIORITY_NAMES.COMPOSING, + PRIORITY_NAMES.LOADING, + PRIORITY_NAMES.PREPARING, + PROMPTING_WORKSPACES, + CONFIGURING_WORKSPACES, + LOADING_WORKSPACES, + PREPARING_WORKSPACES, + PRIORITY_NAMES.DEFAULT, + PRIORITY_NAMES.WRITING, + PRIORITY_NAMES.POST_WRITING, + PRIORITY_NAMES_BASE.INSTALL, + PRIORITY_NAMES_BASE.POST_INSTALL, + PRIORITY_NAMES_BASE.END, +]; diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index 0f0e25923694..470bb5522104 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -48,7 +48,16 @@ const { defaults } = _; * @extends {import('../base/index.mjs')} */ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { + existingDeployment; + async beforeQueue() { + this.parseJHipsterArguments(command.arguments); + if (this.appsFolders?.length > 0) { + this.jhipsterConfig.appsFolders = this.appsFolders; + } + this.existingDeployment = Boolean(this.jhipsterConfig.appsFolders); + + // await this.dependsOnJHipster('bootstrap-workspaces'); if (!this.fromBlueprint) { await this.composeWithBlueprints(GENERATOR_DOCKER_COMPOSE); } @@ -61,16 +70,8 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { this.log.log(chalk.white(`Files will be generated in folder: ${chalk.yellow(this.destinationRoot())}`)); }, - parseArguments() { - this.parseJHipsterArguments(command.arguments); - if (this.appsFolders?.length > 0) { - this.jhipsterConfig.appsFolders = this.appsFolders; - } + parseOptions() { this.parseJHipsterOptions(command.options); - - if (this.appsFolder || this.jhipsterConfig.appsFolders) { - this.regenerate = true; - } }, checkDocker, checkDockerCompose: runAsync(function () { @@ -113,50 +114,9 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get prompting() { return { async askForOptions() { - if (this.regenerate && !this.options.askAnswered) return; + if (this.existingDeployment && !this.options.askAnswered) return; await this.askForWorkspacesConfig(); - /* - await this.prompt( - [ - { - type: 'list', - name: 'deploymentApplicationType', - message: 'Which *type* of application would you like to deploy?', - choices: [ - { - value: MONOLITH, - name: 'Monolithic application', - }, - { - value: MICROSERVICE, - name: 'Microservice application', - }, - ], - default: MONOLITH, - }, - { - type: 'list', - name: 'gatewayType', - when: answers => answers.deploymentApplicationType === MICROSERVICE, - message: 'Which *type* of gateway would you like to use?', - choices: [ - { - value: 'SpringCloudGateway', - name: 'JHipster gateway based on Spring Cloud Gateway', - }, - ], - default: 'SpringCloudGateway', - }, - ], - this.config, - ); - */ - }, - async askForMonitoring() { - if (this.regenerate) return; - - await this.askForMonitoring(); }, }; } @@ -170,9 +130,6 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { configureWorkspaces() { this.configureWorkspacesConfig(); }, - configureBaseDeployment() { - this.jhipsterConfig.jwtSecretKey = this.jhipsterConfig.jwtSecretKey ?? createBase64Secret(this.options.reproducibleTests); - }, }; } @@ -185,11 +142,6 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { loadWorkspacesConfig() { this.loadWorkspacesConfig(); }, - loadBaseDeployment({ deployment }) { - deployment.jwtSecretKey = this.jhipsterConfig.jwtSecretKey; - - loadDockerDependenciesTask.call(this, { context: deployment }); - }, }; } @@ -197,31 +149,76 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { return this.delegateTasksToBlueprint(() => this.loading); } - get default() { + get promptingWorkspaces() { return { + async askForMonitoring() { + if (this.existingDeployment) return; + + await this.askForMonitoring(); + }, async askForClustersMode({ applications }) { - if (this.regenerate) return; + if (this.existingDeployment) return; await this.askForClustersMode({ applications }); }, async askForServiceDiscovery({ applications }) { - if (this.regenerate) return; + if (this.existingDeployment) return; await this.askForServiceDiscovery({ applications }); }, + }; + } + get [BaseWorkspacesGenerator.PROMPTING_WORKSPACES]() { + return this.delegateTasksToBlueprint(() => this.promptingWorkspaces); + } + + get configuringWorkspaces() { + return { + configureBaseDeployment() { + this.jhipsterConfig.jwtSecretKey = this.jhipsterConfig.jwtSecretKey ?? createBase64Secret(this.options.reproducibleTests); + }, + }; + } + + get [BaseWorkspacesGenerator.CONFIGURING_WORKSPACES]() { + return this.delegateTasksToBlueprint(() => this.configuringWorkspaces); + } + + get loadingWorkspaces() { + return { + loadBaseDeployment({ deployment }) { + deployment.jwtSecretKey = this.jhipsterConfig.jwtSecretKey; + + loadDockerDependenciesTask.call(this, { context: deployment }); + }, loadPlatformConfig({ deployment }) { this.loadDeploymentConfig({ deployment }); }, + }; + } - insight() { - statistics.sendSubGenEvent('generator', GENERATOR_DOCKER_COMPOSE); - }, + get [BaseWorkspacesGenerator.LOADING_WORKSPACES]() { + return this.delegateTasksToBlueprint(() => this.loadingWorkspaces); + } + get preparingWorkspaces() { + return { prepareDeployment({ deployment, applications }) { this.prepareDeploymentDerivedProperties({ deployment, applications }); }, + }; + } + + get [BaseWorkspacesGenerator.PREPARING_WORKSPACES]() { + return this.delegateTasksToBlueprint(() => this.preparingWorkspaces); + } + get default() { + return { + insight() { + statistics.sendSubGenEvent('generator', GENERATOR_DOCKER_COMPOSE); + }, async setAppsYaml({ deployment, applications }) { const faker = await createFaker(); From 532aa84430d64eeb0b1e525d1a3b6497e59180a2 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sun, 3 Sep 2023 08:48:35 -0300 Subject: [PATCH 19/27] more adjusts --- generators/base-workspaces/generator.mts | 27 ++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts index 981e29a964a7..7e90cfc33a6e 100644 --- a/generators/base-workspaces/generator.mts +++ b/generators/base-workspaces/generator.mts @@ -134,19 +134,28 @@ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { ); } - protected async resolveApplicationFolders({ + private async resolveApplicationFolders({ directoryPath = this.directoryPath, appsFolders = this.appsFolders ?? [], }: { directoryPath?: string; appsFolders?: string[] } = {}) { - return appsFolders.map(appFolder => this.destinationPath(directoryPath ?? '.', appFolder)); + return Object.fromEntries(appsFolders.map(appFolder => [appFolder, this.destinationPath(directoryPath ?? '.', appFolder)])); } async bootstrapApplications() { - for (const resolvedApplicationFolder of await this.resolveApplicationFolders()) { + const resolvedApplicationFolders = await this.resolveApplicationFolders(); + for (const [_appFolder, resolvedFolder] of Object.entries(resolvedApplicationFolders)) { await this.composeWithJHipster(GENERATOR_BOOTSTRAP_APPLICATION, { - generatorOptions: { destinationRoot: resolvedApplicationFolder }, + generatorOptions: { destinationRoot: resolvedFolder }, } as any); } + this.getSharedApplication(this.destinationPath()).workspacesApplications = Object.entries(resolvedApplicationFolders).map( + ([appFolder, resolvedFolder], index) => { + const application = this.getSharedApplication(resolvedFolder)?.sharedApplication; + application.appFolder = appFolder; + application.composePort = 8080 + index; + return application; + }, + ); } getArgsForPriority(priorityName): any { @@ -168,13 +177,9 @@ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { return args; } const [first, ...others] = args ?? []; - const deployment = this.getSharedApplication(this.destinationPath()).sharedDeployment; - const applications = (this.appsFolders ?? []).map((appFolder, index) => { - const application = this.getSharedApplication(this.destinationPath(this.directoryPath ?? '.', appFolder))?.sharedApplication; - application.appFolder = appFolder; - application.composePort = 8080 + index; - return application; - }); + const sharedData = this.getSharedApplication(this.destinationPath()); + const deployment = sharedData.sharedDeployment; + const applications = sharedData.workspacesApplications; return [ { ...first, From 1a0148e09c8a2bb23b3f51351cc80bc7fe46a41e Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sun, 3 Sep 2023 14:33:23 -0300 Subject: [PATCH 20/27] implement bootstrap-workspaces --- generators/base-core/generator.mts | 2 +- generators/base-workspaces/command.mts | 9 +- generators/base-workspaces/generator.mts | 13 +- generators/base/shared-data.mts | 1 + generators/bootstrap-workspaces/command.mts | 14 + generators/bootstrap-workspaces/generator.mts | 87 ++++ generators/bootstrap-workspaces/index.mts | 19 + .../docker-compose.spec.mts.snap | 81 --- .../docker-compose/docker-compose.spec.mts | 7 +- generators/docker-compose/generator.mjs | 30 +- .../__snapshots__/generator.spec.mjs.snap | 15 + generators/generator-list.mjs | 1 + .../kubernetes.helm.spec.mts.snap | 254 ---------- .../__snapshots__/knative.spec.mts.snap | 460 ------------------ .../__snapshots__/kubernetes.spec.mts.snap | 418 ---------------- .../__snapshots__/openshift.spec.mts.snap | 192 -------- generators/workspaces/generator.mjs | 38 +- test/support/helpers.mts | 4 +- test/support/tests.mjs | 23 +- 19 files changed, 182 insertions(+), 1486 deletions(-) create mode 100644 generators/bootstrap-workspaces/command.mts create mode 100644 generators/bootstrap-workspaces/generator.mts create mode 100644 generators/bootstrap-workspaces/index.mts diff --git a/generators/base-core/generator.mts b/generators/base-core/generator.mts index 6af94a01b400..43bb94b8c292 100644 --- a/generators/base-core/generator.mts +++ b/generators/base-core/generator.mts @@ -987,7 +987,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; return `${createHash('shake256', { outputLength: 1 }).update(applicationPath, 'utf8').digest('hex')}-${dirname}`; } - protected getSharedApplication(applicationFolder: string) { + protected getSharedApplication(applicationFolder: string = this.destinationPath()) { return this.options.sharedData.applications?.[this.calculateApplicationId(applicationFolder)]; } diff --git a/generators/base-workspaces/command.mts b/generators/base-workspaces/command.mts index 9a9fa0b1fb7d..c36a578a615d 100644 --- a/generators/base-workspaces/command.mts +++ b/generators/base-workspaces/command.mts @@ -1,14 +1,7 @@ import { JHipsterCommandDefinition } from '../base/api.mjs'; const command: JHipsterCommandDefinition = { - options: { - regenerate: { - name: 'skipPrompts', - type: Boolean, - description: 'Generate pre-existing configuration', - scope: 'generator', - }, - }, + options: {}, }; export default command; diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts index 7e90cfc33a6e..0ad7cd6ce3f8 100644 --- a/generators/base-workspaces/generator.mts +++ b/generators/base-workspaces/generator.mts @@ -22,7 +22,7 @@ import { existsSync } from 'fs'; import chalk from 'chalk'; import BaseGenerator from '../base/index.mjs'; -import { PRIORITY_NAMES, QUEUES, CUSTOM_PRIORITIES } from './priorities.mjs'; +import { PRIORITY_NAMES, CUSTOM_PRIORITIES } from './priorities.mjs'; import { YO_RC_FILE } from '../generator-constants.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs'; import command from './command.mjs'; @@ -62,15 +62,6 @@ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { if (!this.options.help) { this.registerPriorities(CUSTOM_PRIORITIES); - this.queueTask({ - async method() { - await (this as any).bootstrapApplications(); - }, - taskName: 'bootstrapApplications', - cancellable: true, - queueName: QUEUES.PREPARING_QUEUE, - }); - this.parseJHipsterOptions(command.options); } } @@ -179,10 +170,12 @@ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { const [first, ...others] = args ?? []; const sharedData = this.getSharedApplication(this.destinationPath()); const deployment = sharedData.sharedDeployment; + const workspaces = sharedData.sharedWorkspaces; const applications = sharedData.workspacesApplications; return [ { ...first, + workspaces, deployment, applications, }, diff --git a/generators/base/shared-data.mts b/generators/base/shared-data.mts index 3d036f05cd64..1a38b3b2e70c 100644 --- a/generators/base/shared-data.mts +++ b/generators/base/shared-data.mts @@ -29,6 +29,7 @@ export default class SharedData this.prompting); + } + + get configuring() { + return this.asConfiguringTaskGroup({ + configureWorkspaces() { + this.configureWorkspacesConfig(); + }, + }); + } + + get [BaseWorkspacesGenerator.CONFIGURING]() { + return this.delegateTasksToBlueprint(() => this.configuring); + } + + get loading() { + return this.asLoadingTaskGroup({ + loadWorkspacesConfig() { + this.loadWorkspacesConfig(); + }, + }); + } + + get [BaseWorkspacesGenerator.LOADING]() { + return this.delegateTasksToBlueprint(() => this.loading); + } + + get preparing() { + return this.asPreparingTaskGroup({ + async bootstrapApplications() { + await this.bootstrapApplications(); + }, + }); + } + + get [BaseWorkspacesGenerator.PREPARING]() { + return this.delegateTasksToBlueprint(() => this.preparing); + } +} diff --git a/generators/bootstrap-workspaces/index.mts b/generators/bootstrap-workspaces/index.mts new file mode 100644 index 000000000000..cfcecfbd2954 --- /dev/null +++ b/generators/bootstrap-workspaces/index.mts @@ -0,0 +1,19 @@ +/** + * Copyright 2013-2023 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.mjs'; diff --git a/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap b/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap index 8c33b6bbdf31..4de33edd13d1 100644 --- a/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap +++ b/generators/docker-compose/__snapshots__/docker-compose.spec.mts.snap @@ -10,17 +10,12 @@ exports[`generator - Docker Compose gateway and 1 microservice, with 1 couchbase "10-couchbase" ], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [ "10-couchbase" ], "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "01-gateway", - "10-couchbase" - ], "serviceDiscoveryType": "consul" } } @@ -210,14 +205,9 @@ exports[`generator - Docker Compose gateway and 1 microservice, with Cassandra s "05-cassandra" ], "baseName": "workspaces", - "clientPackageManager": "npm", "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "01-gateway", - "05-cassandra" - ], "serviceDiscoveryType": "consul" } } @@ -414,18 +404,10 @@ exports[`generator - Docker Compose gateway and multi microservices should match "07-mariadb" ], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "01-gateway", - "02-mysql", - "03-psql", - "04-mongo", - "07-mariadb" - ], "serviceDiscoveryType": "consul" } } @@ -798,18 +780,10 @@ exports[`generator - Docker Compose gateway and multi microservices using oauth2 "07-mariadb" ], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "01-gateway", - "02-mysql", - "03-psql", - "10-couchbase", - "07-mariadb" - ], "serviceDiscoveryType": "consul" } } @@ -1253,19 +1227,12 @@ exports[`generator - Docker Compose gateway and multi microservices, with 1 mong "04-mongo" ], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [ "04-mongo" ], "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "01-gateway", - "02-mysql", - "03-psql", - "04-mongo" - ], "serviceDiscoveryType": "consul" } } @@ -1580,18 +1547,10 @@ exports[`generator - Docker Compose gateway and multi microservices, with couchb "07-mariadb" ], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "01-gateway", - "02-mysql", - "03-psql", - "10-couchbase", - "07-mariadb" - ], "serviceDiscoveryType": "consul" } } @@ -1965,14 +1924,9 @@ exports[`generator - Docker Compose gateway and one microservice should match fi "02-mysql" ], "baseName": "workspaces", - "clientPackageManager": "npm", "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "01-gateway", - "02-mysql" - ], "serviceDiscoveryType": "consul" } } @@ -2162,14 +2116,9 @@ exports[`generator - Docker Compose gateway and one microservice, with curator s "02-mysql" ], "baseName": "workspaces", - "clientPackageManager": "npm", "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "01-gateway", - "02-mysql" - ], "serviceDiscoveryType": "consul" } } @@ -2359,14 +2308,9 @@ exports[`generator - Docker Compose gateway and one microservice, with prometheu "02-mysql" ], "baseName": "workspaces", - "clientPackageManager": "npm", "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "prometheus", - "packages": [ - "01-gateway", - "02-mysql" - ], "serviceDiscoveryType": "consul" } } @@ -2670,14 +2614,9 @@ exports[`generator - Docker Compose gateway and one microservice, without monito "02-mysql" ], "baseName": "workspaces", - "clientPackageManager": "npm", "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "01-gateway", - "02-mysql" - ], "serviceDiscoveryType": "consul" } } @@ -2866,13 +2805,9 @@ exports[`generator - Docker Compose monolith should match files snapshot 1`] = ` "08-monolith" ], "baseName": "workspaces", - "clientPackageManager": "npm", "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "08-monolith" - ], "serviceDiscoveryType": "no" } } @@ -2989,13 +2924,9 @@ exports[`generator - Docker Compose one microservice and a directory path withou "02-mysql" ], "baseName": "workspaces", - "clientPackageManager": "npm", "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "02-mysql" - ], "serviceDiscoveryType": "consul" } } @@ -3125,13 +3056,9 @@ exports[`generator - Docker Compose only gateway should match files snapshot 1`] "01-gateway" ], "baseName": "workspaces", - "clientPackageManager": "npm", "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "01-gateway" - ], "serviceDiscoveryType": "consul" } } @@ -3263,13 +3190,9 @@ exports[`generator - Docker Compose only one microservice should match files sna "02-mysql" ], "baseName": "workspaces", - "clientPackageManager": "npm", "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "02-mysql" - ], "serviceDiscoveryType": "consul" } } @@ -3399,13 +3322,9 @@ exports[`generator - Docker Compose oracle monolith should match files snapshot "12-oracle" ], "baseName": "workspaces", - "clientPackageManager": "npm", "directoryPath": "./", "jwtSecretKey": "SECRET--50", "monitoring": "no", - "packages": [ - "12-oracle" - ], "serviceDiscoveryType": "no" } } diff --git a/generators/docker-compose/docker-compose.spec.mts b/generators/docker-compose/docker-compose.spec.mts index c10ccc6db41b..0711b03282ad 100644 --- a/generators/docker-compose/docker-compose.spec.mts +++ b/generators/docker-compose/docker-compose.spec.mts @@ -3,7 +3,7 @@ import { expect } from 'esmocha'; import monitoringTypes from '../../jdl/jhipster/monitoring-types.js'; import applicationTypes from '../../jdl/jhipster/application-types.js'; import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; -import { defaultHelpers as helpers, getGenerator } from '../../test/support/index.mjs'; +import { defaultHelpers as helpers, getGenerator, runResult } from '../../test/support/index.mjs'; const { PROMETHEUS } = monitoringTypes; const { MICROSERVICE, MONOLITH } = applicationTypes; @@ -121,15 +121,14 @@ describe('generator - Docker Compose', () => { }); describe('gateway and one microservice, without monitoring', () => { - let runResult; const chosenApps = ['01-gateway', '02-mysql']; before(async () => { - runResult = await helpers + await helpers .generateDeploymentWorkspaces({ serviceDiscoveryType: 'consul' }) .withWorkspacesSamples(...chosenApps) .withGenerateWorkspaceApplications(); - runResult = await runResult + await runResult .create(getGenerator(GENERATOR_DOCKER_COMPOSE)) .withAnswers({ deploymentApplicationType: MICROSERVICE, diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index 470bb5522104..2ec0f3bed0de 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -29,7 +29,7 @@ import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import { writeFiles } from './files.mjs'; import { deploymentOptions, monitoringTypes, serviceDiscoveryTypes } from '../../jdl/jhipster/index.mjs'; -import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; +import { GENERATOR_BOOTSTRAP_WORKSPACES, GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; import { stringHashCode, createFaker, convertSecretToBase64, createBase64Secret } from '../base/support/index.mjs'; import { checkDocker } from '../base-workspaces/internal/docker-base.mjs'; import { loadDockerDependenciesTask } from '../base-workspaces/internal/index.mjs'; @@ -57,7 +57,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { } this.existingDeployment = Boolean(this.jhipsterConfig.appsFolders); - // await this.dependsOnJHipster('bootstrap-workspaces'); + await this.dependsOnJHipster(GENERATOR_BOOTSTRAP_WORKSPACES); if (!this.fromBlueprint) { await this.composeWithBlueprints(GENERATOR_DOCKER_COMPOSE); } @@ -111,32 +111,6 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { return this.delegateTasksToBlueprint(() => this.initializing); } - get prompting() { - return { - async askForOptions() { - if (this.existingDeployment && !this.options.askAnswered) return; - - await this.askForWorkspacesConfig(); - }, - }; - } - - get [BaseWorkspacesGenerator.PROMPTING]() { - return this.delegateTasksToBlueprint(() => this.prompting); - } - - get configuring() { - return { - configureWorkspaces() { - this.configureWorkspacesConfig(); - }, - }; - } - - get [BaseWorkspacesGenerator.CONFIGURING]() { - return this.delegateTasksToBlueprint(() => this.configuring); - } - get loading() { return { loadWorkspacesConfig() { diff --git a/generators/generate-blueprint/__snapshots__/generator.spec.mjs.snap b/generators/generate-blueprint/__snapshots__/generator.spec.mjs.snap index e9b3a207a181..e475985815a0 100644 --- a/generators/generate-blueprint/__snapshots__/generator.spec.mjs.snap +++ b/generators/generate-blueprint/__snapshots__/generator.spec.mjs.snap @@ -227,6 +227,21 @@ exports[`generator - generate-blueprint with all option should match snapshot 1` "generators/bootstrap-application/templates/template-file-bootstrap-application.ejs": { "stateCleared": "modified", }, + "generators/bootstrap-workspaces/command.mjs": { + "stateCleared": "modified", + }, + "generators/bootstrap-workspaces/generator.mjs": { + "stateCleared": "modified", + }, + "generators/bootstrap-workspaces/generator.spec.mjs": { + "stateCleared": "modified", + }, + "generators/bootstrap-workspaces/index.mjs": { + "stateCleared": "modified", + }, + "generators/bootstrap-workspaces/templates/template-file-bootstrap-workspaces.ejs": { + "stateCleared": "modified", + }, "generators/bootstrap/command.mjs": { "stateCleared": "modified", }, diff --git a/generators/generator-list.mjs b/generators/generator-list.mjs index 6880dfdd20c7..51ed39692619 100644 --- a/generators/generator-list.mjs +++ b/generators/generator-list.mjs @@ -32,6 +32,7 @@ export const GENERATOR_BOOTSTRAP_APPLICATION = 'bootstrap-application'; export const GENERATOR_BOOTSTRAP_APPLICATION_BASE = 'bootstrap-application-base'; export const GENERATOR_BOOTSTRAP_APPLICATION_CLIENT = 'bootstrap-application-client'; export const GENERATOR_BOOTSTRAP_APPLICATION_SERVER = 'bootstrap-application-server'; +export const GENERATOR_BOOTSTRAP_WORKSPACES = 'bootstrap-workspaces'; export const GENERATOR_CI_CD = 'ci-cd'; export const GENERATOR_CLIENT = 'client'; export const GENERATOR_CLOUDFOUNDRY = 'cloudfoundry'; diff --git a/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap b/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap index 3709797ea7f6..6db4c1b93b22 100644 --- a/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap +++ b/generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.mts.snap @@ -7,7 +7,6 @@ exports[`generator - Kubernetes Helm Kafka application should match files snapsh "generator-jhipster": { "appsFolders": ["09-kafka"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "monolith", "directoryPath": "./", @@ -19,25 +18,9 @@ exports[`generator - Kubernetes Helm Kafka application should match files snapsh "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["09-kafka"], "serviceDiscoveryType": false } } -", - "stateCleared": "modified", - }, - "09-kafka/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "monolith", - "authenticationType": "session", - "baseName": "sampleKafka", - "entities": [], - "messageBroker": "kafka", - "prodDatabaseType": "mysql", - "serverPort": 8080 - } -} ", "stateCleared": "modified", }, @@ -412,7 +395,6 @@ exports[`generator - Kubernetes Helm MySQL and PostgreSQL microservices without "generator-jhipster": { "appsFolders": ["02-mysql", "03-psql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -424,37 +406,6 @@ exports[`generator - Kubernetes Helm MySQL and PostgreSQL microservices without "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["02-mysql", "03-psql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "03-psql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mspsql", - "entities": [], - "prodDatabaseType": "postgresql", - "searchEngine": "elasticsearch", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -1331,7 +1282,6 @@ exports[`generator - Kubernetes Helm gateway and ingress should match files snap "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -1344,21 +1294,6 @@ exports[`generator - Kubernetes Helm gateway and ingress should match files snap "kubernetesNamespace": "default", "kubernetesServiceType": "Ingress", "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "consul" } } @@ -1996,7 +1931,6 @@ exports[`generator - Kubernetes Helm gateway and mysql microservice should match "generator-jhipster": { "appsFolders": ["01-gateway", "02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -2008,36 +1942,6 @@ exports[`generator - Kubernetes Helm gateway and mysql microservice should match "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway", "02-mysql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -2839,7 +2743,6 @@ exports[`generator - Kubernetes Helm gateway with istio should match files snaps "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -2851,21 +2754,6 @@ exports[`generator - Kubernetes Helm gateway with istio should match files snaps "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "consul" } } @@ -3736,7 +3624,6 @@ exports[`generator - Kubernetes Helm gateway, mysql, psql, mongodb, mariadb micr "07-mariadb" ], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -3748,79 +3635,6 @@ exports[`generator - Kubernetes Helm gateway, mysql, psql, mongodb, mariadb micr "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway", "02-mysql", "03-psql", "04-mongo", "07-mariadb"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "03-psql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mspsql", - "entities": [], - "prodDatabaseType": "postgresql", - "searchEngine": "elasticsearch", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "04-mongo/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmongodb", - "databaseType": "mongodb", - "entities": [], - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "07-mariadb/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmariadb", - "entities": [], - "prodDatabaseType": "mariadb", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -5254,7 +5068,6 @@ exports[`generator - Kubernetes Helm monolith application should match files sna "generator-jhipster": { "appsFolders": ["08-monolith"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "monolith", "directoryPath": "./", @@ -5266,26 +5079,9 @@ exports[`generator - Kubernetes Helm monolith application should match files sna "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["08-monolith"], "serviceDiscoveryType": false } } -", - "stateCleared": "modified", - }, - "08-monolith/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "monolith", - "authenticationType": "session", - "baseName": "sampleMysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "searchEngine": "elasticsearch", - "serverPort": 8080 - } -} ", "stateCleared": "modified", }, @@ -5645,7 +5441,6 @@ exports[`generator - Kubernetes Helm mysql microservice with custom namespace an "generator-jhipster": { "appsFolders": ["02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -5657,22 +5452,6 @@ exports[`generator - Kubernetes Helm mysql microservice with custom namespace an "kubernetesNamespace": "mynamespace", "kubernetesServiceType": "LoadBalancer", "monitoring": "prometheus", - "packages": ["02-mysql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -8642,7 +8421,6 @@ exports[`generator - Kubernetes Helm mysql microservice with custom namespace sh "generator-jhipster": { "appsFolders": ["02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -8654,22 +8432,6 @@ exports[`generator - Kubernetes Helm mysql microservice with custom namespace sh "kubernetesNamespace": "mynamespace", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["02-mysql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -9292,7 +9054,6 @@ exports[`generator - Kubernetes Helm only gateway should match files snapshot 1` "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -9304,21 +9065,6 @@ exports[`generator - Kubernetes Helm only gateway should match files snapshot 1` "kubernetesNamespace": "jhipsternamespace", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "consul" } } diff --git a/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap b/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap index 96ed48935b35..05c58712de81 100644 --- a/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap +++ b/generators/kubernetes-knative/__snapshots__/knative.spec.mts.snap @@ -7,7 +7,6 @@ exports[`generator - Knative Using Helm generator type MySQL and PostgreSQL micr "generator-jhipster": { "appsFolders": ["02-mysql", "03-psql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -19,37 +18,6 @@ exports[`generator - Knative Using Helm generator type MySQL and PostgreSQL micr "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["02-mysql", "03-psql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "03-psql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mspsql", - "entities": [], - "prodDatabaseType": "postgresql", - "searchEngine": "elasticsearch", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -1108,7 +1076,6 @@ exports[`generator - Knative Using Helm generator type gateway and ingress shoul "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -1120,21 +1087,6 @@ exports[`generator - Knative Using Helm generator type gateway and ingress shoul "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "consul" } } @@ -1949,7 +1901,6 @@ exports[`generator - Knative Using Helm generator type gateway and mysql microse "generator-jhipster": { "appsFolders": ["01-gateway", "02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -1961,36 +1912,6 @@ exports[`generator - Knative Using Helm generator type gateway and mysql microse "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway", "02-mysql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -3018,7 +2939,6 @@ exports[`generator - Knative Using Helm generator type gateway with istio routin "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -3030,21 +2950,6 @@ exports[`generator - Knative Using Helm generator type gateway with istio routin "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "consul" } } @@ -3865,7 +3770,6 @@ exports[`generator - Knative Using Helm generator type gateway, mysql, psql, mon "07-mariadb" ], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -3877,79 +3781,6 @@ exports[`generator - Knative Using Helm generator type gateway, mysql, psql, mon "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway", "02-mysql", "03-psql", "04-mongo", "07-mariadb"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "03-psql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mspsql", - "entities": [], - "prodDatabaseType": "postgresql", - "searchEngine": "elasticsearch", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "04-mongo/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmongodb", - "databaseType": "mongodb", - "entities": [], - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "07-mariadb/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmariadb", - "entities": [], - "prodDatabaseType": "mariadb", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -5705,7 +5536,6 @@ exports[`generator - Knative Using Helm generator type mysql microservice with c "generator-jhipster": { "appsFolders": ["02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -5717,22 +5547,6 @@ exports[`generator - Knative Using Helm generator type mysql microservice with c "kubernetesNamespace": "mynamespace", "kubernetesServiceType": "LoadBalancer", "monitoring": "prometheus", - "packages": ["02-mysql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -8900,7 +8714,6 @@ exports[`generator - Knative Using Helm generator type mysql microservice with c "generator-jhipster": { "appsFolders": ["02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -8912,22 +8725,6 @@ exports[`generator - Knative Using Helm generator type mysql microservice with c "kubernetesNamespace": "mynamespace", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["02-mysql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -9698,7 +9495,6 @@ exports[`generator - Knative Using Helm generator type only gateway should match "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -9710,21 +9506,6 @@ exports[`generator - Knative Using Helm generator type only gateway should match "kubernetesNamespace": "jhipsternamespace", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "consul" } } @@ -10548,7 +10329,6 @@ exports[`generator - Knative Using K8s generator type MySQL and PostgreSQL micro "generator-jhipster": { "appsFolders": ["02-mysql", "03-psql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -10560,37 +10340,6 @@ exports[`generator - Knative Using K8s generator type MySQL and PostgreSQL micro "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["02-mysql", "03-psql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "03-psql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mspsql", - "entities": [], - "prodDatabaseType": "postgresql", - "searchEngine": "elasticsearch", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -11571,7 +11320,6 @@ exports[`generator - Knative Using K8s generator type gateway and ingress should "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -11583,21 +11331,6 @@ exports[`generator - Knative Using K8s generator type gateway and ingress should "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "consul" } } @@ -12341,7 +12074,6 @@ exports[`generator - Knative Using K8s generator type gateway and mysql microser "generator-jhipster": { "appsFolders": ["01-gateway", "02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -12353,36 +12085,6 @@ exports[`generator - Knative Using K8s generator type gateway and mysql microser "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway", "02-mysql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -13324,7 +13026,6 @@ exports[`generator - Knative Using K8s generator type gateway with istio routing "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -13336,21 +13037,6 @@ exports[`generator - Knative Using K8s generator type gateway with istio routing "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "consul" } } @@ -14101,7 +13787,6 @@ exports[`generator - Knative Using K8s generator type gateway, mysql, psql, mong "11-mssql" ], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -14113,101 +13798,6 @@ exports[`generator - Knative Using K8s generator type gateway, mysql, psql, mong "kubernetesNamespace": "default", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": [ - "01-gateway", - "02-mysql", - "03-psql", - "04-mongo", - "07-mariadb", - "11-mssql" - ], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "03-psql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mspsql", - "entities": [], - "prodDatabaseType": "postgresql", - "searchEngine": "elasticsearch", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "04-mongo/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmongodb", - "databaseType": "mongodb", - "entities": [], - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "07-mariadb/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmariadb", - "entities": [], - "prodDatabaseType": "mariadb", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "11-mssql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmssqldb", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mssql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -16333,7 +15923,6 @@ exports[`generator - Knative Using K8s generator type mysql microservice with cu "generator-jhipster": { "appsFolders": ["02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -16345,22 +15934,6 @@ exports[`generator - Knative Using K8s generator type mysql microservice with cu "kubernetesNamespace": "mynamespace", "kubernetesServiceType": "LoadBalancer", "monitoring": "prometheus", - "packages": ["02-mysql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -19751,7 +19324,6 @@ exports[`generator - Knative Using K8s generator type mysql microservice with cu "generator-jhipster": { "appsFolders": ["02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -19763,22 +19335,6 @@ exports[`generator - Knative Using K8s generator type mysql microservice with cu "kubernetesNamespace": "mynamespace", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["02-mysql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -20477,7 +20033,6 @@ exports[`generator - Knative Using K8s generator type only gateway should match "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "directoryPath": "./", "dockerPushCommand": "docker push", @@ -20489,21 +20044,6 @@ exports[`generator - Knative Using K8s generator type only gateway should match "kubernetesNamespace": "jhipsternamespace", "kubernetesServiceType": "LoadBalancer", "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "consul" } } diff --git a/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap b/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap index ffda6bbe34b3..2eb11c26c0b2 100644 --- a/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap +++ b/generators/kubernetes/__snapshots__/kubernetes.spec.mts.snap @@ -7,7 +7,6 @@ exports[`generator - Kubernetes Kafka application should match files snapshot 1` "generator-jhipster": { "appsFolders": ["09-kafka"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "monolith", "directoryPath": "./", @@ -21,25 +20,9 @@ exports[`generator - Kubernetes Kafka application should match files snapshot 1` "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": ["09-kafka"], "serviceDiscoveryType": false } } -", - "stateCleared": "modified", - }, - "09-kafka/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "monolith", - "authenticationType": "session", - "baseName": "sampleKafka", - "entities": [], - "messageBroker": "kafka", - "prodDatabaseType": "mysql", - "serverPort": 8080 - } -} ", "stateCleared": "modified", }, @@ -507,7 +490,6 @@ exports[`generator - Kubernetes MySQL and PostgreSQL microservices without gatew "generator-jhipster": { "appsFolders": ["02-mysql", "03-psql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -521,37 +503,6 @@ exports[`generator - Kubernetes MySQL and PostgreSQL microservices without gatew "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": ["02-mysql", "03-psql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "03-psql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mspsql", - "entities": [], - "prodDatabaseType": "postgresql", - "searchEngine": "elasticsearch", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -1497,7 +1448,6 @@ exports[`generator - Kubernetes gateway and ingress should match files snapshot "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -1512,21 +1462,6 @@ exports[`generator - Kubernetes gateway and ingress should match files snapshot "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "consul" } } @@ -2203,7 +2138,6 @@ exports[`generator - Kubernetes gateway and ingressType gke should match files s "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -2218,24 +2152,9 @@ exports[`generator - Kubernetes gateway and ingressType gke should match files s "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": ["01-gateway"], "serviceDiscoveryType": "consul" } } -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "authenticationType": "oauth2", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080 - } -} ", "stateCleared": "modified", }, @@ -5745,7 +5664,6 @@ exports[`generator - Kubernetes gateway and ingressType nginx should match files "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -5760,24 +5678,9 @@ exports[`generator - Kubernetes gateway and ingressType nginx should match files "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": ["01-gateway"], "serviceDiscoveryType": "consul" } } -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "authenticationType": "oauth2", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080 - } -} ", "stateCleared": "modified", }, @@ -9199,7 +9102,6 @@ exports[`generator - Kubernetes gateway and mysql microservice should match file "generator-jhipster": { "appsFolders": ["01-gateway", "02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -9213,36 +9115,6 @@ exports[`generator - Kubernetes gateway and mysql microservice should match file "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": ["01-gateway", "02-mysql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -10081,7 +9953,6 @@ exports[`generator - Kubernetes gateway with istio routing should match files sn "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -10095,21 +9966,6 @@ exports[`generator - Kubernetes gateway with istio routing should match files sn "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "consul" } } @@ -11085,7 +10941,6 @@ exports[`generator - Kubernetes gateway, mysql, psql, mongodb, mariadb, mssql mi "11-mssql" ], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -11099,101 +10954,6 @@ exports[`generator - Kubernetes gateway, mysql, psql, mongodb, mariadb, mssql mi "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": [ - "01-gateway", - "02-mysql", - "03-psql", - "04-mongo", - "07-mariadb", - "11-mssql" - ], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "03-psql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mspsql", - "entities": [], - "prodDatabaseType": "postgresql", - "searchEngine": "elasticsearch", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "04-mongo/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmongodb", - "databaseType": "mongodb", - "entities": [], - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "07-mariadb/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmariadb", - "entities": [], - "prodDatabaseType": "mariadb", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "11-mssql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmssqldb", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mssql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -13180,7 +12940,6 @@ exports[`generator - Kubernetes monolith application should match files snapshot "generator-jhipster": { "appsFolders": ["08-monolith"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "monolith", "directoryPath": "./", @@ -13194,26 +12953,9 @@ exports[`generator - Kubernetes monolith application should match files snapshot "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": ["08-monolith"], "serviceDiscoveryType": false } } -", - "stateCleared": "modified", - }, - "08-monolith/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "monolith", - "authenticationType": "session", - "baseName": "sampleMysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "searchEngine": "elasticsearch", - "serverPort": 8080 - } -} ", "stateCleared": "modified", }, @@ -13653,7 +13395,6 @@ exports[`generator - Kubernetes mysql microservice with custom namespace and jhi "generator-jhipster": { "appsFolders": ["02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -13667,22 +13408,6 @@ exports[`generator - Kubernetes mysql microservice with custom namespace and jhi "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "prometheus", - "packages": ["02-mysql"], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -17023,7 +16748,6 @@ exports[`generator - Kubernetes mysql microservice with custom namespace should "generator-jhipster": { "appsFolders": ["02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -17037,24 +16761,9 @@ exports[`generator - Kubernetes mysql microservice with custom namespace should "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": ["02-mysql"], "serviceDiscoveryType": "consul" } } -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081 - } -} ", "stateCleared": "modified", }, @@ -17722,7 +17431,6 @@ exports[`generator - Kubernetes mysql, psql, mongodb, mariadb, mssql microservic "11-mssql" ], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -17736,101 +17444,6 @@ exports[`generator - Kubernetes mysql, psql, mongodb, mariadb, mssql microservic "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": [ - "01-gateway", - "02-mysql", - "03-psql", - "04-mongo", - "07-mariadb", - "11-mssql" - ], - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "03-psql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mspsql", - "entities": [], - "prodDatabaseType": "postgresql", - "searchEngine": "elasticsearch", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "04-mongo/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmongodb", - "databaseType": "mongodb", - "entities": [], - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "07-mariadb/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmariadb", - "entities": [], - "prodDatabaseType": "mariadb", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "11-mssql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmssqldb", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mssql", - "serverPort": 8081, "serviceDiscoveryType": "consul" } } @@ -19817,7 +19430,6 @@ exports[`generator - Kubernetes only gateway should match files snapshot 1`] = ` "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "gateway", "directoryPath": "./", @@ -19831,23 +19443,9 @@ exports[`generator - Kubernetes only gateway should match files snapshot 1`] = ` "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": ["01-gateway"], "serviceDiscoveryType": "consul" } } -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080 - } -} ", "stateCleared": "modified", }, @@ -20505,7 +20103,6 @@ exports[`generator - Kubernetes only gateway with eureka should match files snap "adminPassword": "meetup", "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "monolith", "directoryPath": "./", @@ -20519,21 +20116,6 @@ exports[`generator - Kubernetes only gateway with eureka should match files snap "kubernetesStorageClassName": "", "kubernetesUseDynamicStorage": true, "monitoring": "no", - "packages": ["01-gateway"], - "serviceDiscoveryType": "eureka" - } -} -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, "serviceDiscoveryType": "eureka" } } diff --git a/generators/openshift/__snapshots__/openshift.spec.mts.snap b/generators/openshift/__snapshots__/openshift.spec.mts.snap index b5202f8ec772..6066e2f3b5a1 100644 --- a/generators/openshift/__snapshots__/openshift.spec.mts.snap +++ b/generators/openshift/__snapshots__/openshift.spec.mts.snap @@ -7,7 +7,6 @@ exports[`generator - OpenShift gateway and one microservice with mysql should ma "generator-jhipster": { "appsFolders": ["01-gateway", "02-mysql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -16,41 +15,11 @@ exports[`generator - OpenShift gateway and one microservice with mysql should ma "jwtSecretKey": "SECRET--50", "monitoring": "no", "openshiftNamespace": "default", - "packages": ["01-gateway", "02-mysql"], "registryReplicas": 2, "serviceDiscoveryType": "consul", "storageType": "ephemeral" } } -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} ", "stateCleared": "modified", }, @@ -1061,7 +1030,6 @@ exports[`generator - OpenShift gateway with multiple microservices backed by mys "07-mariadb" ], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -1070,105 +1038,11 @@ exports[`generator - OpenShift gateway with multiple microservices backed by mys "jwtSecretKey": "SECRET--50", "monitoring": "no", "openshiftNamespace": "default", - "packages": [ - "01-gateway", - "02-mysql", - "03-psql", - "04-mongo", - "05-cassandra", - "07-mariadb" - ], "registryReplicas": 2, "serviceDiscoveryType": "consul", "storageType": "ephemeral" } } -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "03-psql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mspsql", - "entities": [], - "prodDatabaseType": "postgresql", - "searchEngine": "elasticsearch", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "04-mongo/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmongodb", - "databaseType": "mongodb", - "entities": [], - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "05-cassandra/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mscassandra", - "databaseType": "cassandra", - "entities": [], - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "07-mariadb/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmariadb", - "entities": [], - "prodDatabaseType": "mariadb", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} ", "stateCleared": "modified", }, @@ -3492,7 +3366,6 @@ exports[`generator - OpenShift monolith application should match files snapshot "generator-jhipster": { "appsFolders": ["08-monolith"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "monolith", "directoryPath": "./", @@ -3501,28 +3374,11 @@ exports[`generator - OpenShift monolith application should match files snapshot "jwtSecretKey": "SECRET--50", "monitoring": "no", "openshiftNamespace": "default", - "packages": ["08-monolith"], "registryReplicas": 2, "serviceDiscoveryType": false, "storageType": "ephemeral" } } -", - "stateCleared": "modified", - }, - "08-monolith/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "monolith", - "authenticationType": "session", - "baseName": "sampleMysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "searchEngine": "elasticsearch", - "serverPort": 8080 - } -} ", "stateCleared": "modified", }, @@ -4031,7 +3887,6 @@ exports[`generator - OpenShift only gateway should match files snapshot 1`] = ` "generator-jhipster": { "appsFolders": ["01-gateway"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -4040,26 +3895,11 @@ exports[`generator - OpenShift only gateway should match files snapshot 1`] = ` "jwtSecretKey": "SECRET--50", "monitoring": "no", "openshiftNamespace": "default", - "packages": ["01-gateway"], "registryReplicas": 2, "serviceDiscoveryType": "consul", "storageType": "ephemeral" } } -", - "stateCleared": "modified", - }, - "01-gateway/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "gateway", - "baseName": "jhgate", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8080, - "serviceDiscoveryType": "consul" - } -} ", "stateCleared": "modified", }, @@ -4743,7 +4583,6 @@ exports[`generator - OpenShift two microservices backed by mysql and postgres wi "generator-jhipster": { "appsFolders": ["02-mysql", "03-psql"], "baseName": "workspaces", - "clientPackageManager": "npm", "clusteredDbApps": [], "deploymentApplicationType": "microservice", "directoryPath": "./", @@ -4752,42 +4591,11 @@ exports[`generator - OpenShift two microservices backed by mysql and postgres wi "jwtSecretKey": "SECRET--50", "monitoring": "no", "openshiftNamespace": "default", - "packages": ["02-mysql", "03-psql"], "registryReplicas": 2, "serviceDiscoveryType": "consul", "storageType": "ephemeral" } } -", - "stateCleared": "modified", - }, - "02-mysql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "msmysql", - "databaseType": "sql", - "entities": [], - "prodDatabaseType": "mysql", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} -", - "stateCleared": "modified", - }, - "03-psql/.yo-rc.json": { - "contents": "{ - "generator-jhipster": { - "applicationType": "microservice", - "baseName": "mspsql", - "entities": [], - "prodDatabaseType": "postgresql", - "searchEngine": "elasticsearch", - "serverPort": 8081, - "serviceDiscoveryType": "consul" - } -} ", "stateCleared": "modified", }, diff --git a/generators/workspaces/generator.mjs b/generators/workspaces/generator.mjs index 577b1c8772ef..25892b73cbab 100644 --- a/generators/workspaces/generator.mjs +++ b/generators/workspaces/generator.mjs @@ -19,7 +19,7 @@ import { existsSync } from 'fs'; -import { GENERATOR_GIT, GENERATOR_WORKSPACES } from '../generator-list.mjs'; +import { GENERATOR_BOOTSTRAP_WORKSPACES, GENERATOR_GIT, GENERATOR_WORKSPACES } from '../generator-list.mjs'; import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import command from './command.mjs'; @@ -38,6 +38,8 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { generateWorkspaces; async beforeQueue() { + await this.dependsOnJHipster(GENERATOR_BOOTSTRAP_WORKSPACES, { generatorOptions: { customWorkspacesConfig: true } }); + if (!this.fromBlueprint) { await this.composeWithBlueprints(GENERATOR_WORKSPACES); } @@ -49,7 +51,7 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { this.parseJHipsterOptions(command.options); // Generate workspaces file only when option passed or regenerating - this.generateWorkspaces = this.workspaces !== false || !!this.packageJson.get('workspaces'); + this.generateWorkspaces = this.workspaces !== false || !!this.packageJson?.get('workspaces'); // When generating workspaces, save to .yo-rc.json. Use a dummy config otherwise. this.workspacesConfig = this.generateWorkspaces ? this.jhipsterConfig : {}; @@ -66,6 +68,15 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { async configure() { this.jhipsterConfig.baseName = this.jhipsterConfig.baseName || 'workspaces'; }, + async configureUsingFiles() { + if (!this.generateWorkspaces) return; + + if (existsSync(this.destinationPath('docker-compose'))) { + this.workspacesConfig.dockerCompose = true; + } + this.workspacesConfig.appsFolders = [...new Set([...(this.workspacesConfig.packages ?? []), ...this.appsFolders])]; + delete this.workspacesConfig.packages; + }, }); } @@ -100,36 +111,25 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { return this.delegateTasksToBlueprint(() => this.composing); } - get default() { + get loadingWorkspaces() { return this.asDefaultTaskGroup({ - async configureUsingFiles() { - if (!this.generateWorkspaces) return; - - if (existsSync(this.destinationPath('docker-compose'))) { - this.workspacesConfig.dockerCompose = true; - } - this.workspacesConfig.packages = [...new Set([...(this.workspacesConfig.packages ?? []), ...this.appsFolders])]; - }, - configurePackageManager({ applications }) { if (this.workspacesConfig.clientPackageManager || !this.generateWorkspaces) return; this.workspacesConfig.clientPackageManager = this.options.clientPackageManager ?? applications.find(app => app.clientPackageManager)?.clientPackageManager ?? 'npm'; }, - async loadConfig() { if (!this.generateWorkspaces) return; this.dockerCompose = this.workspacesConfig.dockerCompose; - this.packages = this.workspacesConfig.packages; this.env.options.nodePackageManager = this.workspacesConfig.clientPackageManager; }, }); } - get [BaseWorkspacesGenerator.DEFAULT]() { - return this.delegateTasksToBlueprint(() => this.default); + get [BaseWorkspacesGenerator.LOADING_WORKSPACES]() { + return this.delegateTasksToBlueprint(() => this.loadingWorkspaces); } get postWriting() { @@ -141,7 +141,7 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { applications.find(app => app.nodeDependencies[dependency])?.nodeDependencies[dependency]; this.packageJson.merge({ workspaces: { - packages: this.packages, + packages: this.appsFolders, }, devDependencies: { concurrently: findDependencyVersion('concurrently'), @@ -187,11 +187,11 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { createConcurrentlyScript(...scripts) { const scriptsList = scripts .map(script => { - const packageScripts = this.packages.map(packageName => [ + const packageScripts = this.appsFolders.map(packageName => [ `${script}:${packageName}`, `npm run ${script} --workspace ${packageName} --if-present`, ]); - packageScripts.push([script, `concurrently ${this.packages.map(packageName => `npm:${script}:${packageName}`).join(' ')}`]); + packageScripts.push([script, `concurrently ${this.appsFolders.map(packageName => `npm:${script}:${packageName}`).join(' ')}`]); return packageScripts; }) .flat(); diff --git a/test/support/helpers.mts b/test/support/helpers.mts index 3cf4ac7ef844..4b8d6ef39a1f 100644 --- a/test/support/helpers.mts +++ b/test/support/helpers.mts @@ -130,9 +130,9 @@ class JHipsterRunContext return this; } - withGenerateWorkspaceApplications(): this { + withGenerateWorkspaceApplications(generateWorkspaces: boolean = false): this { this.generateApplicationsSet = true; - return this.withOptions({ generateApplications: true, workspacesFolders: this.workspaceApplications }); + return this.withOptions({ generateApplications: true, workspacesFolders: this.workspaceApplications, workspaces: generateWorkspaces }); } withFakeTestBlueprint(blueprintPackage: string, { packageJson, generator = 'test-blueprint' }: FakeBlueprintOptions = {}): this { diff --git a/test/support/tests.mjs b/test/support/tests.mjs index 15e904ca988c..a390abdf7cef 100644 --- a/test/support/tests.mjs +++ b/test/support/tests.mjs @@ -9,6 +9,9 @@ import { GENERATOR_JHIPSTER } from '../../generators/generator-constants.mjs'; import { skipPrettierHelpers as helpers } from './helpers.mjs'; import * as GeneratorList from '../../generators/generator-list.mjs'; import { PRIORITY_NAMES, ENTITY_PRIORITY_NAMES, PRIORITY_NAMES_LIST } from '../../generators/base-application/priorities.mjs'; +import { WORKSPACES_PRIORITY_NAMES } from '../../generators/base-workspaces/priorities.mjs'; + +const workspacesPriorityList = Object.values(WORKSPACES_PRIORITY_NAMES); const { CONFIGURING_EACH_ENTITY, @@ -245,7 +248,7 @@ export const testBlueprintSupport = (generatorName, options = {}) => { const prioritiesSpy = sinon.spy(); const prioritiesTasks = []; let prioritiesCount = 0; - PRIORITY_NAMES_LIST.forEach(priority => { + [...PRIORITY_NAMES_LIST, ...workspacesPriorityList].forEach(priority => { let callback; if (Object.getOwnPropertyDescriptor(Object.getPrototypeOf(generator), `${taskPrefix}${priority}`)) { prioritiesCount++; @@ -376,15 +379,17 @@ export const testBlueprintSupport = (generatorName, options = {}) => { it('should call every priority', () => { expect(spy.prioritiesSpy.callCount).toBe(spy.prioritiesCount); }); - PRIORITY_NAMES_LIST.filter(priority => !Object.values(ENTITY_PRIORITY_NAMES).includes(priority)).forEach(priority => { - it(`should call ${priority} tasks if implemented`, function () { - if (!spy.prioritiesTasks[priority]) { - this.skip(); - return; - } - expect(spy.prioritiesTasks[priority].callCount).toBe(1); + [...PRIORITY_NAMES_LIST, ...workspacesPriorityList] + .filter(priority => !Object.values(ENTITY_PRIORITY_NAMES).includes(priority)) + .forEach(priority => { + it(`should call ${priority} tasks if implemented`, function () { + if (!spy.prioritiesTasks[priority]) { + this.skip(); + return; + } + expect(spy.prioritiesTasks[priority].callCount).toBe(1); + }); }); - }); if (entity) { [LOADING_ENTITIES, WRITING_ENTITIES, POST_WRITING_ENTITIES].forEach(priority => { it(`should call ${priority} tasks once`, function () { From 9296a4309749055fea371dcc199609741102a97f Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sun, 3 Sep 2023 14:48:12 -0300 Subject: [PATCH 21/27] adjusts --- generators/base-workspaces/generator.mts | 6 ++-- generators/bootstrap-workspaces/generator.mts | 14 ++++++++- generators/docker-compose/generator.mjs | 29 +++++++++---------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts index 0ad7cd6ce3f8..ae6b5b35f4f4 100644 --- a/generators/base-workspaces/generator.mts +++ b/generators/base-workspaces/generator.mts @@ -66,9 +66,9 @@ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { } } - protected loadWorkspacesConfig() { - this.appsFolders = this.jhipsterConfig.appsFolders; - this.directoryPath = this.jhipsterConfig.directoryPath ?? './'; + protected loadWorkspacesConfig({ context = this } = {}) { + context.appsFolders = this.jhipsterConfig.appsFolders; + context.directoryPath = this.jhipsterConfig.directoryPath ?? './'; } protected configureWorkspacesConfig() { diff --git a/generators/bootstrap-workspaces/generator.mts b/generators/bootstrap-workspaces/generator.mts index 97977c0b77cd..2d1eefec015a 100644 --- a/generators/bootstrap-workspaces/generator.mts +++ b/generators/bootstrap-workspaces/generator.mts @@ -38,7 +38,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get prompting() { return this.asPromptingTaskGroup({ async askForOptions() { - if (!this.customWorkspacesConfig && this.sharedWorkspaces.existingWorkspaces && !this.options.askAnswered) return; + if (this.customWorkspacesConfig || (this.sharedWorkspaces.existingWorkspaces && !this.options.askAnswered)) return; await this.askForWorkspacesConfig(); }, @@ -84,4 +84,16 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get [BaseWorkspacesGenerator.PREPARING]() { return this.delegateTasksToBlueprint(() => this.preparing); } + + get loadingWorkspaces() { + return { + loadWorkspacesConfig({ workspaces }) { + (this as any).loadWorkspacesConfig({ context: workspaces }); + }, + }; + } + + get [BaseWorkspacesGenerator.LOADING_WORKSPACES]() { + return this.delegateTasksToBlueprint(() => this.loadingWorkspaces); + } } diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index 2ec0f3bed0de..c5df1016f4c7 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -55,7 +55,6 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { if (this.appsFolders?.length > 0) { this.jhipsterConfig.appsFolders = this.appsFolders; } - this.existingDeployment = Boolean(this.jhipsterConfig.appsFolders); await this.dependsOnJHipster(GENERATOR_BOOTSTRAP_WORKSPACES); if (!this.fromBlueprint) { @@ -125,18 +124,18 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get promptingWorkspaces() { return { - async askForMonitoring() { - if (this.existingDeployment) return; + async askForMonitoring({ workspaces }) { + if (workspaces.existingWorkspaces && !this.options.askAnswered) return; await this.askForMonitoring(); }, - async askForClustersMode({ applications }) { - if (this.existingDeployment) return; + async askForClustersMode({ workspaces, applications }) { + if (workspaces.existingWorkspaces && !this.options.askAnswered) return; await this.askForClustersMode({ applications }); }, - async askForServiceDiscovery({ applications }) { - if (this.existingDeployment) return; + async askForServiceDiscovery({ workspaces, applications }) { + if (workspaces.existingWorkspaces && !this.options.askAnswered) return; await this.askForServiceDiscovery({ applications }); }, @@ -193,7 +192,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { insight() { statistics.sendSubGenEvent('generator', GENERATOR_DOCKER_COMPOSE); }, - async setAppsYaml({ deployment, applications }) { + async setAppsYaml({ workspaces, deployment, applications }) { const faker = await createFaker(); deployment.keycloakRedirectUris = ''; @@ -201,7 +200,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { const lowercaseBaseName = appConfig.baseName.toLowerCase(); appConfig.clusteredDb = deployment.clusteredDbApps?.includes(appConfig.appFolder); const parentConfiguration = {}; - const path = this.destinationPath(this.directoryPath, appConfig.appFolder); + const path = this.destinationPath(workspaces.directoryPath, appConfig.appFolder); // Add application configuration const yaml = jsyaml.load(this.fs.read(`${path}/src/main/docker/app.yml`)); const yamlConfig = yaml.services.app; @@ -375,8 +374,8 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get end() { return { - end({ applications }) { - this.checkApplicationsDockerImages({ applications }); + end({ workspaces, applications }) { + this.checkApplicationsDockerImages({ workspaces, applications }); this.log.verboseInfo(`You can launch all your infrastructure by running : ${chalk.cyan('docker compose up -d')}`); const uiApplications = applications.filter( @@ -397,7 +396,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { return this.delegateTasksToBlueprint(() => this.end); } - checkApplicationsDockerImages({ applications }) { + checkApplicationsDockerImages({ workspaces, applications }) { this.log.log('\nChecking Docker images in applications directories...'); let imagePath = ''; @@ -406,15 +405,15 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { let warningMessage = 'To generate the missing Docker image(s), please run:\n'; applications.forEach(application => { if (application.buildToolGradle) { - imagePath = this.destinationPath(this.directoryPath, application.appFolder, 'build/jib-cache'); + imagePath = this.destinationPath(workspaces.directoryPath, application.appFolder, 'build/jib-cache'); runCommand = `./gradlew bootJar -Pprod jibDockerBuild${process.arch === 'arm64' ? ' -PjibArchitecture=arm64' : ''}`; } else if (application.buildToolMaven) { - imagePath = this.destinationPath(this.directoryPath, application.appFolder, '/target/jib-cache'); + imagePath = this.destinationPath(workspaces.directoryPath, application.appFolder, '/target/jib-cache'); runCommand = `./mvnw -ntp -Pprod verify jib:dockerBuild${process.arch === 'arm64' ? ' -Djib-maven-plugin.architecture=arm64' : ''}`; } if (!existsSync(imagePath)) { hasWarning = true; - warningMessage += ` ${chalk.cyan(runCommand)} in ${this.destinationPath(this.directoryPath, application.appFolder)}\n`; + warningMessage += ` ${chalk.cyan(runCommand)} in ${this.destinationPath(workspaces.directoryPath, application.appFolder)}\n`; } }); if (hasWarning) { From ed0b77053593a9591387bd4b81be686b40f1ec83 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sun, 3 Sep 2023 14:57:24 -0300 Subject: [PATCH 22/27] update snapshot --- test/__snapshots__/api.spec.mjs.snap | 1 + 1 file changed, 1 insertion(+) diff --git a/test/__snapshots__/api.spec.mjs.snap b/test/__snapshots__/api.spec.mjs.snap index c62979b46825..e84e3a625f07 100644 --- a/test/__snapshots__/api.spec.mjs.snap +++ b/test/__snapshots__/api.spec.mjs.snap @@ -17,6 +17,7 @@ exports[`public api generator-jhipster/generators should match snapshot 1`] = ` "GENERATOR_BOOTSTRAP_APPLICATION_BASE": "bootstrap-application-base", "GENERATOR_BOOTSTRAP_APPLICATION_CLIENT": "bootstrap-application-client", "GENERATOR_BOOTSTRAP_APPLICATION_SERVER": "bootstrap-application-server", + "GENERATOR_BOOTSTRAP_WORKSPACES": "bootstrap-workspaces", "GENERATOR_CI_CD": "ci-cd", "GENERATOR_CLIENT": "client", "GENERATOR_CLOUDFOUNDRY": "cloudfoundry", From ed979c1d7e07f7d302c92e486f46d7dd590c01c7 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 4 Sep 2023 11:05:14 -0300 Subject: [PATCH 23/27] fix jhipster-registry adminPassword --- generators/docker-compose/generator.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index c5df1016f4c7..9d2e3e5f8648 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -148,8 +148,11 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { get configuringWorkspaces() { return { - configureBaseDeployment() { + configureBaseDeployment({ applications }) { this.jhipsterConfig.jwtSecretKey = this.jhipsterConfig.jwtSecretKey ?? createBase64Secret(this.options.reproducibleTests); + if (applications.some(app => app.serviceDiscoveryEureka)) { + this.jhipsterConfig.adminPassword = this.jhipsterConfig.adminPassword ?? 'admin'; + } }, }; } From afa5cd6b49e3abc83851991cacd977e3752b58f0 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 4 Sep 2023 11:14:20 -0300 Subject: [PATCH 24/27] fix loading of angular dependencies version. --- generators/workspaces/generator.mjs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/generators/workspaces/generator.mjs b/generators/workspaces/generator.mjs index 25892b73cbab..0f45aade4cb2 100644 --- a/generators/workspaces/generator.mjs +++ b/generators/workspaces/generator.mjs @@ -19,7 +19,7 @@ import { existsSync } from 'fs'; -import { GENERATOR_BOOTSTRAP_WORKSPACES, GENERATOR_GIT, GENERATOR_WORKSPACES } from '../generator-list.mjs'; +import { GENERATOR_ANGULAR, GENERATOR_BOOTSTRAP_WORKSPACES, GENERATOR_GIT, GENERATOR_WORKSPACES } from '../generator-list.mjs'; import BaseWorkspacesGenerator from '../base-workspaces/index.mjs'; import command from './command.mjs'; @@ -156,12 +156,17 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { }); if (applications.some(app => app.clientFrameworkAngular)) { + const { + dependencies: { rxjs }, + devDependencies: { webpack: webpackVersion }, + } = this.fs.readJSON(this.fetchFromInstalledJHipster(GENERATOR_ANGULAR, 'resources', 'package.json')); + this.packageJson.merge({ devDependencies: { - rxjs: findDependencyVersion('rxjs'), // Set version to workaround https://github.com/npm/cli/issues/4437 + rxjs, // Set version to workaround https://github.com/npm/cli/issues/4437 }, overrides: { - webpack: findDependencyVersion('webpack'), + webpack: webpackVersion, }, }); } From d24f3265e7ebb72c6307b06ba949f4edd42a1a7a Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 4 Sep 2023 11:21:24 -0300 Subject: [PATCH 25/27] pass reproducible to bootstrap-application --- generators/base-workspaces/generator.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/base-workspaces/generator.mts b/generators/base-workspaces/generator.mts index ae6b5b35f4f4..4e4716170b28 100644 --- a/generators/base-workspaces/generator.mts +++ b/generators/base-workspaces/generator.mts @@ -136,7 +136,7 @@ export default abstract class BaseWorkspacesGenerator extends BaseGenerator { const resolvedApplicationFolders = await this.resolveApplicationFolders(); for (const [_appFolder, resolvedFolder] of Object.entries(resolvedApplicationFolders)) { await this.composeWithJHipster(GENERATOR_BOOTSTRAP_APPLICATION, { - generatorOptions: { destinationRoot: resolvedFolder }, + generatorOptions: { destinationRoot: resolvedFolder, reproducible: true }, } as any); } this.getSharedApplication(this.destinationPath()).workspacesApplications = Object.entries(resolvedApplicationFolders).map( From 0f698187586ac4aa351174e91ec6645b27986d9a Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 4 Sep 2023 12:02:33 -0300 Subject: [PATCH 26/27] Fix workspaces with memcached --- generators/docker-compose/generator.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index 9d2e3e5f8648..6c3a7e4b85f1 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -332,7 +332,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { } // Add Memcached support if (appConfig.cacheProviderMemcached) { - const memcachedYaml = jsyaml.load(deployment.fs.read(`${path}/src/main/docker/memcached.yml`)); + const memcachedYaml = jsyaml.load(this.readDestination(`${path}/src/main/docker/memcached.yml`)); const memcachedConfig = memcachedYaml.services.memcached; delete memcachedConfig.ports; parentConfiguration[`${lowercaseBaseName}-memcached`] = memcachedConfig; @@ -340,7 +340,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { // Add Redis support if (appConfig.cacheProviderRedis) { - const redisYaml = jsyaml.load(this.fs.read(`${path}/src/main/docker/redis.yml`)); + const redisYaml = jsyaml.load(this.readDestionation(`${path}/src/main/docker/redis.yml`)); const redisConfig = redisYaml.services.redis; delete redisConfig.ports; parentConfiguration[`${lowercaseBaseName}-redis`] = redisConfig; From 4ea37b8e8a590a921a2ed17db39f287f87287987 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 4 Sep 2023 12:26:07 -0300 Subject: [PATCH 27/27] fix typo --- generators/docker-compose/generator.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index 6c3a7e4b85f1..166f78bad327 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -340,7 +340,7 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator { // Add Redis support if (appConfig.cacheProviderRedis) { - const redisYaml = jsyaml.load(this.readDestionation(`${path}/src/main/docker/redis.yml`)); + const redisYaml = jsyaml.load(this.readDestination(`${path}/src/main/docker/redis.yml`)); const redisConfig = redisYaml.services.redis; delete redisConfig.ports; parentConfiguration[`${lowercaseBaseName}-redis`] = redisConfig;