diff --git a/generators/angular/support/needles.ts b/generators/angular/support/needles.ts index 1b7138f4af6f..6fabcdde6e46 100644 --- a/generators/angular/support/needles.ts +++ b/generators/angular/support/needles.ts @@ -19,7 +19,7 @@ import type { Entity } from '../../base-application/index.js'; import type { BaseApplication, CommonClientServerApplication } from '../../base-application/types.js'; import { createNeedleCallback } from '../../base/support/needles.js'; -import { upperFirstCamelCase } from '../../base/support/string.js'; +import { upperFirstCamelCase } from '../../../lib/utils/string.js'; import { joinCallbacks } from '../../base/support/write-files.js'; export function addRoute({ diff --git a/generators/app/support/config.ts b/generators/app/support/config.ts index a5a6b3e973ec..5d276676d1ae 100644 --- a/generators/app/support/config.ts +++ b/generators/app/support/config.ts @@ -1,6 +1,6 @@ import { camelCase, kebabCase, startCase, upperFirst } from 'lodash-es'; import { NODE_VERSION } from '../../generator-constants.js'; -import { applicationTypes, authenticationTypes, databaseTypes, testFrameworkTypes } from '../../../jdl/index.js'; +import { applicationTypes, authenticationTypes, databaseTypes, testFrameworkTypes } from '../../../jdl/jhipster/index.js'; import { getHipster, mutateData, pickFields, upperFirstCamelCase } from '../../base/support/index.js'; import { getDBTypeFromDBValue } from '../../server/support/index.js'; import detectLanguage from '../../languages/support/detect-language.js'; diff --git a/generators/base-application/generator.ts b/generators/base-application/generator.ts index 0b5779d4d78b..4b2a388a481a 100644 --- a/generators/base-application/generator.ts +++ b/generators/base-application/generator.ts @@ -26,7 +26,7 @@ import type { SpringBootSourceType } from '../server/types.js'; import type { ClientSourceType } from '../client/types.js'; import type { I18nApplication } from '../languages/types.js'; import type { JHipsterGeneratorFeatures, JHipsterGeneratorOptions } from '../base/api.js'; -import { mutateData } from '../base/support/config.js'; +import { mutateData } from '../../lib/utils/object.js'; import { GENERATOR_BOOTSTRAP_APPLICATION, GENERATOR_BOOTSTRAP_APPLICATION_BASE, diff --git a/generators/base-application/support/prepare-field.js b/generators/base-application/support/prepare-field.js index ff2222f8b019..4b8a5e2ad438 100644 --- a/generators/base-application/support/prepare-field.js +++ b/generators/base-application/support/prepare-field.js @@ -20,7 +20,7 @@ import { defaults, kebabCase, snakeCase, startCase, upperFirst } from 'lodash-es import { fieldTypes, validations } from '../../../jdl/jhipster/index.js'; import { getTypescriptType, prepareField as prepareClientFieldForTemplates } from '../../client/support/index.js'; import { prepareField as prepareServerFieldForTemplates } from '../../server/support/index.js'; -import { mutateData } from '../../base/support/config.js'; +import { mutateData } from '../../../lib/utils/object.js'; import { fieldIsEnum } from './field-utils.js'; import { prepareProperty } from './prepare-property.js'; diff --git a/generators/base-application/support/prepare-property.ts b/generators/base-application/support/prepare-property.ts index 70c1e21e531d..be50b15cc864 100644 --- a/generators/base-application/support/prepare-property.ts +++ b/generators/base-application/support/prepare-property.ts @@ -17,7 +17,7 @@ * limitations under the License. */ import { snakeCase, upperFirst } from 'lodash-es'; -import { mutateData } from '../../base/support/config.js'; +import { mutateData } from '../../../lib/utils/object.js'; export const prepareProperty = (property: any) => { mutateData(property, { diff --git a/generators/base-application/support/prepare-relationship.js b/generators/base-application/support/prepare-relationship.js index 76f2781114d4..4ca7e03d8db1 100644 --- a/generators/base-application/support/prepare-relationship.js +++ b/generators/base-application/support/prepare-relationship.js @@ -21,7 +21,7 @@ import pluralize from 'pluralize'; import { checkAndReturnRelationshipOnValue, databaseTypes, entityOptions, validations } from '../../../jdl/jhipster/index.js'; import { getJoinTableName, hibernateSnakeCase } from '../../server/support/index.js'; -import { mutateData } from '../../base/support/config.js'; +import { mutateData } from '../../../lib/utils/object.js'; import { stringifyApplicationData } from './debug.js'; import { prepareProperty } from './prepare-property.js'; diff --git a/generators/base-core/generator-core.spec.ts b/generators/base-core/generator-core.spec.ts index da114db1c5d6..947724802e33 100644 --- a/generators/base-core/generator-core.spec.ts +++ b/generators/base-core/generator-core.spec.ts @@ -1,7 +1,7 @@ import { beforeEach, describe, it, expect as jestExpect } from 'esmocha'; import { basicHelpers as helpers } from '../../testing/index.js'; -import { createJHipsterLogger } from '../base/support/logger.js'; +import { createJHipsterLogger } from '../base/support/index.js'; import Base from './index.js'; const BaseGenerator: any = Base.prototype; diff --git a/generators/base-core/generator.ts b/generators/base-core/generator.ts index e065851ee342..6e272768eb7f 100644 --- a/generators/base-core/generator.ts +++ b/generators/base-core/generator.ts @@ -64,7 +64,7 @@ import { GENERATOR_JHIPSTER, YO_RC_FILE } from '../generator-constants.js'; import { loadConfig } from '../../lib/internal/index.js'; import { getGradleLibsVersionsProperties } from '../gradle/support/dependabot-gradle.js'; import { dockerPlaceholderGenerator } from '../docker/utils.js'; -import { getConfigWithDefaults } from '../../jdl/index.js'; +import { getConfigWithDefaults } from '../../jdl/jhipster/index.js'; import { extractArgumentsFromConfigs } from '../../lib/command/index.js'; const { diff --git a/generators/base-workspaces/internal/deployments.ts b/generators/base-workspaces/internal/deployments.ts index 87f443740cbf..d0e999cc1fb1 100644 --- a/generators/base-workspaces/internal/deployments.ts +++ b/generators/base-workspaces/internal/deployments.ts @@ -17,7 +17,7 @@ * limitations under the License. */ import { defaults } from 'lodash-es'; -import { applicationOptions, deploymentOptions } from '../../../jdl/index.js'; +import { applicationOptions, deploymentOptions } from '../../../jdl/jhipster/index.js'; import { loadDerivedPlatformConfig, loadDerivedServerAndPlatformProperties, loadPlatformConfig } from '../../server/support/index.js'; import type { GeneratorBaseCore } from '../../index.js'; diff --git a/generators/base/support/hipster.ts b/generators/base/support/hipster.ts index 72c27452ec69..f3799ab58afc 100644 --- a/generators/base/support/hipster.ts +++ b/generators/base/support/hipster.ts @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { stringHashCode } from './string.js'; +import { stringHashCode } from '../../../lib/utils/string.js'; /** * get a hipster based on the applications name. diff --git a/generators/base/support/index.ts b/generators/base/support/index.ts index de275e8387bc..7dd80722a854 100644 --- a/generators/base/support/index.ts +++ b/generators/base/support/index.ts @@ -18,17 +18,17 @@ */ export * from './basename.js'; export * from './configuration-helpers/options.js'; -export * from './config.js'; +export * from '../../../lib/utils/object.js'; export * from './contents.js'; export * from './faker.js'; export { default as getHipster } from './hipster.js'; export * from './jhipster7-context.js'; -export * from './logger.js'; +export * from '../../../lib/utils/logger.js'; export * from './namespace.js'; export * from './needles.js'; export * from './path.js'; export { default as httpsGet } from './remote.js'; export * from './secret.js'; -export * from './string.js'; +export * from '../../../lib/utils/string.js'; export * from './timestamp.js'; export * from './write-files.js'; diff --git a/generators/base/support/jhipster7-context.js b/generators/base/support/jhipster7-context.js index 987e5d791190..71d681a8c4b3 100644 --- a/generators/base/support/jhipster7-context.js +++ b/generators/base/support/jhipster7-context.js @@ -12,8 +12,8 @@ import { } from '../../server/support/index.js'; import { getDBCExtraOption } from '../../spring-data-relational/support/database-data.js'; import { getJdbcUrl, getR2dbcUrl } from '../../spring-data-relational/support/database-url.js'; -import { fieldTypes } from '../../../jdl/index.js'; -import { upperFirstCamelCase } from './string.js'; +import { fieldTypes } from '../../../jdl/jhipster/index.js'; +import { upperFirstCamelCase } from '../../../lib/utils/string.js'; const { BYTES, BYTE_BUFFER } = fieldTypes.RelationalOnlyDBTypes; diff --git a/generators/bootstrap-application-base/generator.ts b/generators/bootstrap-application-base/generator.ts index bbfa5917a902..85c98738642e 100644 --- a/generators/bootstrap-application-base/generator.ts +++ b/generators/bootstrap-application-base/generator.ts @@ -38,6 +38,7 @@ import { GENERATOR_BOOTSTRAP, GENERATOR_COMMON, GENERATOR_PROJECT_NAME } from '. import { packageJson } from '../../lib/index.js'; import { loadLanguagesConfig } from '../languages/support/index.js'; import { loadAppConfig, loadDerivedAppConfig, loadStoredAppOptions } from '../app/support/index.js'; +import jdlDefinition from '../app/jdl/index.js'; import { createAuthorityEntity, createUserEntity, createUserManagementEntity } from './utils.js'; import { exportJDLTransform, importJDLTransform } from './support/index.js'; @@ -79,8 +80,8 @@ export default class BootstrapApplicationBase extends BaseApplicationGenerator { const destinationPath = this.destinationPath(); const jdlStorePath = this.destinationPath(this.jhipsterConfig.jdlStore); - this.features.commitTransformFactory = () => exportJDLTransform({ destinationPath, jdlStorePath }); - await this.pipeline({ refresh: true, pendingFiles: false }, importJDLTransform({ destinationPath, jdlStorePath })); + this.features.commitTransformFactory = () => exportJDLTransform({ destinationPath, jdlStorePath, jdlDefinition }); + await this.pipeline({ refresh: true, pendingFiles: false }, importJDLTransform({ destinationPath, jdlStorePath, jdlDefinition })); } }, }); diff --git a/generators/bootstrap-application-base/support/export-jdl-transform.ts b/generators/bootstrap-application-base/support/export-jdl-transform.ts index 407f444a5059..83959afadee6 100644 --- a/generators/bootstrap-application-base/support/export-jdl-transform.ts +++ b/generators/bootstrap-application-base/support/export-jdl-transform.ts @@ -7,17 +7,21 @@ import { setModifiedFileState } from 'mem-fs-editor/state'; import { GENERATOR_JHIPSTER } from '../../generator-constants.js'; import { getJDLObjectFromSingleApplication } from '../../../jdl/converters/json-to-jdl-converter.js'; import type { JSONEntity } from '../../../jdl/converters/types.js'; +import { createRuntime } from '../../../jdl/runtime.js'; +import type { JDLApplicationConfig } from '../../../jdl/types/types.js'; export const exportJDLTransform = ({ destinationPath, jdlStorePath, throwOnMissingConfig = true, keepEntitiesConfig, + jdlDefinition, }: { destinationPath: string; jdlStorePath: string; throwOnMissingConfig?: boolean; keepEntitiesConfig?: boolean; + jdlDefinition: JDLApplicationConfig; }) => Duplex.from(async function* (files: AsyncGenerator) { const yoRcFilePath = join(destinationPath, '.yo-rc.json'); @@ -52,6 +56,8 @@ export const exportJDLTransform = ({ const jdlObject = getJDLObjectFromSingleApplication( { ...contents, [GENERATOR_JHIPSTER]: { ...rest, incrementalChangelog } }, entitiesMap, + undefined, + createRuntime(jdlDefinition), ); const jdlContents = jdlObject.toString(); diff --git a/generators/bootstrap-application-base/support/import-jdl-transform.ts b/generators/bootstrap-application-base/support/import-jdl-transform.ts index 16e3615909ec..cf7aec24b5b9 100644 --- a/generators/bootstrap-application-base/support/import-jdl-transform.ts +++ b/generators/bootstrap-application-base/support/import-jdl-transform.ts @@ -6,10 +6,18 @@ import { Minimatch } from 'minimatch'; import { upperFirst } from 'lodash-es'; import { GENERATOR_JHIPSTER } from '../../generator-constants.js'; import { createImporterFromContent } from '../../../jdl/jdl-importer.js'; -import { mergeYoRcContent } from '../../../jdl/index.js'; -import jhipsterDefinition from '../../../generators/app/jdl/index.js'; +import { mergeYoRcContent } from '../../../lib/utils/yo-rc.js'; +import type { JDLApplicationConfig } from '../../../jdl/types/types.js'; -export const importJDLTransform = ({ destinationPath, jdlStorePath }: { destinationPath: string; jdlStorePath: string }) => +export const importJDLTransform = ({ + destinationPath, + jdlStorePath, + jdlDefinition, +}: { + destinationPath: string; + jdlStorePath: string; + jdlDefinition: JDLApplicationConfig; +}) => Duplex.from(async function* (files: AsyncGenerator) { const yoRcFilePath = join(destinationPath, '.yo-rc.json'); const entitiesFolder = join(destinationPath, '.jhipster'); @@ -45,7 +53,7 @@ export const importJDLTransform = ({ destinationPath, jdlStorePath }: { destinat if (entityFields.length > 0) { throw new Error('Entities configuration files are not supported by jdlStore'); } - const importer = createImporterFromContent(jdlStoreContents.toString(), undefined, jhipsterDefinition); + const importer = createImporterFromContent(jdlStoreContents.toString(), undefined, jdlDefinition); const importState = importer.import(); const applicationWithEntities = Object.values(importState.exportedApplicationsWithEntities); if (applicationWithEntities.length !== 1) { diff --git a/generators/client/command.ts b/generators/client/command.ts index 6b6ea6dae44e..5247c1bb65b3 100644 --- a/generators/client/command.ts +++ b/generators/client/command.ts @@ -18,9 +18,13 @@ */ import chalk from 'chalk'; import { intersection } from 'lodash-es'; -import { testFrameworkTypes } from '../../jdl/jhipster/index.js'; +import { + APPLICATION_TYPE_GATEWAY, + APPLICATION_TYPE_MICROSERVICE, + clientFrameworkTypes, + testFrameworkTypes, +} from '../../jdl/jhipster/index.js'; import type { JHipsterCommandDefinition } from '../../lib/command/index.js'; -import { APPLICATION_TYPE_GATEWAY, APPLICATION_TYPE_MICROSERVICE, clientFrameworkTypes } from '../../jdl/index.js'; import { GENERATOR_COMMON } from '../generator-list.js'; const { CYPRESS } = testFrameworkTypes; diff --git a/generators/client/files-common.js b/generators/client/files-common.js index 5b076b7e959d..6f163cac2805 100644 --- a/generators/client/files-common.js +++ b/generators/client/files-common.js @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { clientFrameworkTypes } from '../../jdl/index.js'; +import { clientFrameworkTypes } from '../../jdl/jhipster/index.js'; import { clientRootTemplatesBlock, clientSrcTemplatesBlock } from './support/files.js'; const { ANGULAR, REACT, VUE } = clientFrameworkTypes; diff --git a/generators/export-jdl/generator.ts b/generators/export-jdl/generator.ts index c381a060ca40..c86808da9271 100644 --- a/generators/export-jdl/generator.ts +++ b/generators/export-jdl/generator.ts @@ -21,8 +21,9 @@ import chalk from 'chalk'; import BaseGenerator from '../base/index.js'; import { applicationOptions } from '../../jdl/jhipster/index.js'; -import JSONToJDLConverter from '../../jdl/converters/json-to-jdl-converter.js'; +import { convertToJDL } from '../../jdl/converters/json-to-jdl-converter.js'; import type { JHipsterGeneratorFeatures, JHipsterGeneratorOptions } from '../base/api.js'; +import jdlDefinition from '../app/jdl/index.js'; const { OptionNames } = applicationOptions; @@ -50,7 +51,7 @@ export default class extends BaseGenerator { return this.asDefaultTaskGroup({ convertToJDL() { try { - const jdlObject = JSONToJDLConverter.convertToJDL(this.destinationPath(), false); + const jdlObject = convertToJDL(this.destinationPath(), false, jdlDefinition); if (jdlObject) { this.jdlContent = jdlObject.toString(); } diff --git a/generators/gradle/generator.ts b/generators/gradle/generator.ts index 9bb0521f76de..4c9187b7a895 100644 --- a/generators/gradle/generator.ts +++ b/generators/gradle/generator.ts @@ -22,7 +22,7 @@ import assert from 'assert/strict'; import BaseApplicationGenerator from '../base-application/index.js'; import { GRADLE_BUILD_SRC_DIR } from '../generator-constants.js'; -import { mutateData } from '../base/support/config.js'; +import { mutateData } from '../../lib/utils/object.js'; import { QUEUES } from '../base/priorities.js'; import files from './files.js'; import { GRADLE } from './constants.js'; diff --git a/generators/java/generators/build-tool/command.ts b/generators/java/generators/build-tool/command.ts index e7f6d36ddd4e..ac92e272a348 100644 --- a/generators/java/generators/build-tool/command.ts +++ b/generators/java/generators/build-tool/command.ts @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { buildToolTypes } from '../../../../jdl/index.js'; +import { buildToolTypes } from '../../../../jdl/jhipster/index.js'; import { GENERATOR_GRADLE, GENERATOR_MAVEN } from '../../../generator-list.js'; import { asCommand } from '../../../type-utils.js'; diff --git a/generators/java/generators/build-tool/generator.ts b/generators/java/generators/build-tool/generator.ts index 1ccca6df8eec..76f0a7008ffa 100644 --- a/generators/java/generators/build-tool/generator.ts +++ b/generators/java/generators/build-tool/generator.ts @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { buildToolTypes } from '../../../../jdl/index.js'; +import { buildToolTypes } from '../../../../jdl/jhipster/index.js'; import BaseApplicationGenerator from '../../../base-application/index.js'; import { GENERATOR_GRADLE, GENERATOR_MAVEN } from '../../../generator-list.js'; import type { MavenDependency } from '../../../maven/types.js'; diff --git a/generators/jdl/generator.ts b/generators/jdl/generator.ts index 5e05d2a61f59..83896ff5b7a2 100644 --- a/generators/jdl/generator.ts +++ b/generators/jdl/generator.ts @@ -30,10 +30,10 @@ import { GENERATOR_APP, GENERATOR_ENTITIES, GENERATOR_WORKSPACES } from '../gene import type { ApplicationWithEntities } from '../../jdl/jdl-importer.js'; import { createImporterFromContent } from '../../jdl/jdl-importer.js'; import { GENERATOR_JHIPSTER, JHIPSTER_CONFIG_DIR } from '../generator-constants.js'; -import { mergeYoRcContent } from '../../jdl/index.js'; +import { mergeYoRcContent } from '../../lib/utils/yo-rc.js'; import { normalizeBlueprintName } from '../base/internal/blueprint.js'; import { updateApplicationEntitiesTransform } from '../base-application/support/update-application-entities-transform.js'; -import jhipsterDefinition from '../../generators/app/jdl/index.js'; +import jdlDefinition from '../app/jdl/index.js'; import { addApplicationIndex, allNewApplications, customizeForMicroservices } from './internal/index.js'; /** @@ -135,7 +135,7 @@ export default class JdlGenerator extends BaseGenerator { skipUserManagement: this.options.skipUserManagement, }; - const importer = createImporterFromContent(this.jdlContents.join('\n'), configuration, jhipsterDefinition); + const importer = createImporterFromContent(this.jdlContents.join('\n'), configuration, jdlDefinition); const importState = importer.import(); diff --git a/generators/languages/generator.js b/generators/languages/generator.js index ae78b4dfd68f..f450772f0f00 100644 --- a/generators/languages/generator.js +++ b/generators/languages/generator.js @@ -28,7 +28,7 @@ import { updateLanguagesTask as updateLanguagesInJava } from '../server/support/ import { SERVER_MAIN_RES_DIR, SERVER_TEST_RES_DIR } from '../generator-constants.js'; import { QUEUES } from '../base-application/priorities.js'; import { PRIORITY_NAMES } from '../base/priorities.js'; -import { clientFrameworkTypes } from '../../jdl/index.js'; +import { clientFrameworkTypes } from '../../jdl/jhipster/index.js'; import { findLanguageForTag, supportedLanguages } from './support/languages.js'; import TranslationData, { createTranslationsFileFilter, createTranslationsFilter } from './translation-data.js'; import { writeEntityFiles } from './entity-files.js'; diff --git a/generators/server/command.ts b/generators/server/command.ts index 70fdd1edded9..9eded5ec7575 100644 --- a/generators/server/command.ts +++ b/generators/server/command.ts @@ -19,7 +19,7 @@ import chalk from 'chalk'; import type { JHipsterCommandDefinition } from '../../lib/command/index.js'; import { GENERATOR_COMMON, GENERATOR_SPRING_BOOT } from '../generator-list.js'; -import { APPLICATION_TYPE_GATEWAY, APPLICATION_TYPE_MICROSERVICE, APPLICATION_TYPE_MONOLITH } from '../../jdl/index.js'; +import { APPLICATION_TYPE_GATEWAY, APPLICATION_TYPE_MICROSERVICE, APPLICATION_TYPE_MONOLITH } from '../../jdl/jhipster/index.js'; const command: JHipsterCommandDefinition = { options: { diff --git a/generators/server/jdl/application-definition.ts b/generators/server/jdl/application-definition.ts index 42156b0150aa..67813c1aaf16 100644 --- a/generators/server/jdl/application-definition.ts +++ b/generators/server/jdl/application-definition.ts @@ -20,15 +20,17 @@ import { snakeCase, upperCase } from 'lodash-es'; import type { JDLApplicationConfig, JHipsterOptionDefinition } from '../../../jdl/types/types.js'; import databaseMigrationOption from '../options/database-migration.js'; import messageBrokerOption from '../options/message-broker.js'; -import { feignClientDefinition, syncUserWithIdpDefinition } from '../options/index.js'; +import { syncUserWithIdpDefinition } from '../options/index.js'; import { jdlRoutesOptions } from '../../spring-cloud/generators/gateway/jdl/jdl-routes-option.js'; +import command from '../../spring-boot/command.js'; +import { extractJdlDefinitionFromCommandConfig } from '../../../lib/command/index.js'; const jdlOptions: JHipsterOptionDefinition[] = [ databaseMigrationOption, messageBrokerOption, - feignClientDefinition, syncUserWithIdpDefinition, jdlRoutesOptions, + ...extractJdlDefinitionFromCommandConfig(command.configs), ]; const applicationConfig: JDLApplicationConfig = { diff --git a/generators/server/options/feign-client.ts b/generators/server/options/feign-client.ts deleted file mode 100644 index 41036cc1d8cf..000000000000 --- a/generators/server/options/feign-client.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2013-2024 the original author or authors from the JHipster project. - * - * This file is part of the JHipster project, see https://www.jhipster.tech/ - * for more information. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { JHipsterOptionDefinition } from '../../../jdl/types/types.js'; - -export const FEIGN_CLIENT = 'feignClient'; - -export const feignClientDefinition: JHipsterOptionDefinition = { - name: FEIGN_CLIENT, - type: 'boolean', - tokenType: 'BOOLEAN', -}; diff --git a/generators/server/options/index.ts b/generators/server/options/index.ts index 1820b16da131..ca90eaab7319 100644 --- a/generators/server/options/index.ts +++ b/generators/server/options/index.ts @@ -19,5 +19,4 @@ export * from './database-migration.js'; export * from './message-broker.js'; -export * from './feign-client.js'; export * from './sync-user-with-idp.js'; diff --git a/generators/server/support/prepare-field.js b/generators/server/support/prepare-field.js index acdff7938be3..8cef367901f5 100644 --- a/generators/server/support/prepare-field.js +++ b/generators/server/support/prepare-field.js @@ -21,7 +21,7 @@ import { snakeCase, upperFirst } from 'lodash-es'; import { databaseTypes, entityOptions, fieldTypes, reservedKeywords } from '../../../jdl/jhipster/index.js'; import { formatDocAsApiDescription, formatDocAsJavaDoc } from '../../java/support/doc.js'; -import { mutateData } from '../../base/support/config.js'; +import { mutateData } from '../../../lib/utils/object.js'; import { getUXConstraintName } from './database.js'; import { getJavaValueGeneratorForType } from './templates/field-values.js'; diff --git a/generators/server/support/prepare-relationship.ts b/generators/server/support/prepare-relationship.ts index e30ffc6750df..247506382732 100644 --- a/generators/server/support/prepare-relationship.ts +++ b/generators/server/support/prepare-relationship.ts @@ -1,4 +1,4 @@ -import { mutateData } from '../../base/support/config.js'; +import { mutateData } from '../../../lib/utils/object.js'; import { formatDocAsApiDescription, formatDocAsJavaDoc } from '../../java/support/doc.js'; export function prepareRelationship({ relationship }: { relationship: any; entity: any }) { diff --git a/generators/server/support/relationship.ts b/generators/server/support/relationship.ts index cc4388429416..16373b0cdc28 100644 --- a/generators/server/support/relationship.ts +++ b/generators/server/support/relationship.ts @@ -20,7 +20,7 @@ import type { JSONEntity } from '../../../jdl/converters/types.js'; import { addOtherRelationship } from '../../base-application/support/index.js'; import type { ValidationResult } from '../../base/api.js'; -import { databaseTypes } from '../../../jdl/index.js'; +import { databaseTypes } from '../../../jdl/jhipster/index.js'; const { NO: NO_DATABASE, SQL, NEO4J } = databaseTypes; diff --git a/generators/spring-boot/command.ts b/generators/spring-boot/command.ts index 7280182c9bf5..e6941e57befe 100644 --- a/generators/spring-boot/command.ts +++ b/generators/spring-boot/command.ts @@ -20,7 +20,7 @@ import chalk from 'chalk'; import type { JHipsterCommandDefinition } from '../../lib/command/index.js'; import { GENERATOR_JAVA, GENERATOR_LIQUIBASE, GENERATOR_SPRING_DATA_RELATIONAL } from '../generator-list.js'; import { createBase64Secret, createSecret } from '../base/support/secret.js'; -import { applicationTypes, authenticationTypes } from '../../jdl/index.js'; +import { applicationTypes, authenticationTypes } from '../../jdl/jhipster/index.js'; const { OAUTH2, SESSION, JWT } = authenticationTypes; const { GATEWAY, MICROSERVICE } = applicationTypes; @@ -125,6 +125,10 @@ const command: JHipsterCommandDefinition = { [MICROSERVICE].includes(gen.jhipsterConfigWithDefaults.applicationType) && (reactive ?? gen.jhipsterConfigWithDefaults.reactive) === false, }), + jdl: { + type: 'boolean', + tokenType: 'BOOLEAN', + }, default: false, }, syncUserWithIdp: { diff --git a/generators/spring-boot/generator.ts b/generators/spring-boot/generator.ts index 58d1c5890b60..362b9cc63843 100644 --- a/generators/spring-boot/generator.ts +++ b/generators/spring-boot/generator.ts @@ -58,7 +58,7 @@ import { searchEngineTypes, testFrameworkTypes, websocketTypes, -} from '../../jdl/index.js'; +} from '../../jdl/jhipster/index.js'; import { getPomVersionProperties, parseMavenPom } from '../maven/support/index.js'; import { writeFiles as writeEntityFiles } from './entity-files.js'; import cleanupTask from './cleanup.js'; diff --git a/generators/server/options/feign-client.spec.ts b/generators/spring-boot/options/feign-client.spec.ts similarity index 93% rename from generators/server/options/feign-client.spec.ts rename to generators/spring-boot/options/feign-client.spec.ts index 7a32c71bc209..db4c9142109c 100644 --- a/generators/server/options/feign-client.spec.ts +++ b/generators/spring-boot/options/feign-client.spec.ts @@ -2,7 +2,8 @@ import { before, describe, expect, it } from 'esmocha'; import type { ImportState } from '../../../jdl/jdl-importer.js'; import { createImporterFromContent } from '../../../jdl/jdl-importer.js'; import definition from '../../app/jdl/index.js'; -import { FEIGN_CLIENT as optionName } from './index.js'; + +const optionName = 'feignClient'; describe(`generators - server - jdl - ${optionName}`, () => { [true, false].forEach(optionValue => { diff --git a/jdl/converters/json-to-jdl-converter.ts b/jdl/converters/json-to-jdl-converter.ts index 8f67adce6bb7..3c469c796cfe 100644 --- a/jdl/converters/json-to-jdl-converter.ts +++ b/jdl/converters/json-to-jdl-converter.ts @@ -24,11 +24,12 @@ import mergeJDLObjects from '../models/jdl-object-merger.js'; import { doesDirectoryExist, doesFileExist } from '../utils/file-utils.js'; import { readJSONFile } from '../readers/json-file-reader.js'; import exportJDLObject from '../exporters/jdl-exporter.js'; -import { removeFieldsWithNullishValues } from '../../generators/base/support/config.js'; -import { GENERATOR_JHIPSTER } from '../../generators/generator-constants.js'; +import { removeFieldsWithNullishValues } from '../../lib/utils/object.js'; import type JDLApplication from '../models/jdl-application.js'; import type { JDLRuntime } from '../types/runtime.js'; -import { getDefaultRuntime } from '../runtime.js'; +import { createRuntime, getDefaultRuntime } from '../runtime.js'; +import { YO_RC_CONFIG_KEY } from '../../lib/utils/yo-rc.js'; +import type { JDLApplicationConfig } from '../types/types.js'; import type { JHipsterYoRcContent, JSONEntity, PostProcessedJSONRootObject } from './types.js'; import { convertEntitiesToJDL } from './json-to-jdl-entity-converter.js'; import { convertApplicationToJDL } from './json-to-jdl-application-converter.js'; @@ -43,18 +44,23 @@ export default { * @param directory the directory to find JHipster files. * @param output the file where the JDL will be written */ -export function convertToJDL(directory = '.', output: string | false = 'app.jdl'): JDLObject | undefined { +export function convertToJDL( + directory = '.', + output: string | false = 'app.jdl', + definition?: JDLApplicationConfig, +): JDLObject | undefined { let jdlObject: JDLObject; + const runtime = definition ? createRuntime(definition) : getDefaultRuntime(); if (doesFileExist(path.join(directory, '.yo-rc.json'))) { const yoRcFileContent: JHipsterYoRcContent = readJSONFile(path.join(directory, '.yo-rc.json')); let entities: Map | undefined; if (doesDirectoryExist(path.join(directory, '.jhipster'))) { entities = getJSONEntityFiles(directory); } - jdlObject = getJDLObjectFromSingleApplication(yoRcFileContent, entities); + jdlObject = getJDLObjectFromSingleApplication(yoRcFileContent, entities, undefined, runtime); } else { try { - jdlObject = getJDLObjectFromMultipleApplications(directory); + jdlObject = getJDLObjectFromMultipleApplications(directory, runtime); } catch { return undefined; } @@ -70,7 +76,7 @@ export function convertSingleContentToJDL(yoRcFileContent: JHipsterYoRcContent, return getJDLObjectFromSingleApplication(yoRcFileContent, entities).toString(); } -function getJDLObjectFromMultipleApplications(directory: string): JDLObject { +function getJDLObjectFromMultipleApplications(directory: string, runtime: JDLRuntime): JDLObject { const subDirectories = getSubdirectories(directory); if (subDirectories.length === 0) { throw new Error('There are no subdirectories.'); @@ -83,7 +89,7 @@ function getJDLObjectFromMultipleApplications(directory: string): JDLObject { if (doesDirectoryExist(path.join(applicationDirectory, '.jhipster'))) { entities = getJSONEntityFiles(applicationDirectory); } - jdlObject = getJDLObjectFromSingleApplication(yoRcFileContent, entities, jdlObject); + jdlObject = getJDLObjectFromSingleApplication(yoRcFileContent, entities, jdlObject, runtime); }); return jdlObject; } @@ -110,13 +116,13 @@ function cleanYoRcFileContent(yoRcFileContent: JHipsterYoRcContent): PostProcess for (const key of Object.keys(yoRcFileContent)) { yoRcFileContent[key] = removeFieldsWithNullishValues(yoRcFileContent[key]); } - delete yoRcFileContent[GENERATOR_JHIPSTER].promptValues; + delete yoRcFileContent[YO_RC_CONFIG_KEY].promptValues; const result: PostProcessedJSONRootObject = structuredClone(yoRcFileContent) as PostProcessedJSONRootObject; - if (yoRcFileContent[GENERATOR_JHIPSTER].blueprints) { - result[GENERATOR_JHIPSTER].blueprints = yoRcFileContent[GENERATOR_JHIPSTER].blueprints.map(blueprint => blueprint.name); + if (yoRcFileContent[YO_RC_CONFIG_KEY].blueprints) { + result[YO_RC_CONFIG_KEY].blueprints = yoRcFileContent[YO_RC_CONFIG_KEY].blueprints.map(blueprint => blueprint.name); } - if (yoRcFileContent[GENERATOR_JHIPSTER].microfrontends) { - result[GENERATOR_JHIPSTER].microfrontends = yoRcFileContent[GENERATOR_JHIPSTER].microfrontends.map(({ baseName }) => baseName); + if (yoRcFileContent[YO_RC_CONFIG_KEY].microfrontends) { + result[YO_RC_CONFIG_KEY].microfrontends = yoRcFileContent[YO_RC_CONFIG_KEY].microfrontends.map(({ baseName }) => baseName); } return result; } diff --git a/jdl/converters/types.d.ts b/jdl/converters/types.d.ts index 33a43c3b2120..4789d138962a 100644 --- a/jdl/converters/types.d.ts +++ b/jdl/converters/types.d.ts @@ -1,5 +1,5 @@ +import type { YO_RC_CONFIG_KEY } from '../../lib/utils/yo-rc.ts'; import type { RelationshipSide, RelationshipType } from '../basic-types/relationships.js'; -import type { GENERATOR_JHIPSTER } from '../../generators/index.js'; export type JSONField = { fieldName: string; @@ -94,11 +94,11 @@ export type PostProcessedJSONGeneratorJhipsterContent = { } & AbstractJSONGeneratorJhipsterContent; export type PostProcessedJSONRootObject = { - [GENERATOR_JHIPSTER]: PostProcessedJSONGeneratorJhipsterContent; + [YO_RC_CONFIG_KEY]: PostProcessedJSONGeneratorJhipsterContent; }; export type JHipsterYoRcContent = { - [GENERATOR_JHIPSTER]: JSONGeneratorJhipsterContent; + [YO_RC_CONFIG_KEY]: JSONGeneratorJhipsterContent; }; export type JHipsterYoRcContentWrapper = { diff --git a/jdl/exporters/config.ts b/jdl/exporters/config.ts deleted file mode 100644 index 4da43929bdb0..000000000000 --- a/jdl/exporters/config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { JHipsterYoRcContent } from '../converters/types.js'; -import { GENERATOR_NAME } from './export-utils.js'; - -export const mergeYoRcContent = (oldConfig: JHipsterYoRcContent, newConfig: JHipsterYoRcContent): JHipsterYoRcContent => { - // @ts-expect-error partial assignment - const merged: Partial = { [GENERATOR_NAME]: {} }; - for (const ns of new Set([...Object.keys(oldConfig), ...Object.keys(newConfig)])) { - merged[ns] = { ...oldConfig[ns], ...newConfig[ns] }; - } - if (oldConfig[GENERATOR_NAME]?.creationTimestamp) { - merged[GENERATOR_NAME]!.creationTimestamp = oldConfig[GENERATOR_NAME].creationTimestamp; - } - return merged as JHipsterYoRcContent; -}; diff --git a/jdl/exporters/export-utils.ts b/jdl/exporters/export-utils.ts index 3b7ab15df145..7e04f60092a2 100644 --- a/jdl/exporters/export-utils.ts +++ b/jdl/exporters/export-utils.ts @@ -20,7 +20,7 @@ import fs from 'fs'; import { doesFileExist } from '../utils/file-utils.js'; import type { JHipsterYoRcContent } from '../converters/types.js'; -import { mergeYoRcContent } from './config.js'; +import { mergeYoRcContent } from '../../lib/utils/yo-rc.js'; export const GENERATOR_NAME = 'generator-jhipster'; diff --git a/jdl/index.ts b/jdl/index.ts index b0671d634f43..0be130459f17 100644 --- a/jdl/index.ts +++ b/jdl/index.ts @@ -1,4 +1,4 @@ export * from './jdl-importer.js'; export * from './parsing/api.js'; export * from './jhipster/index.js'; -export * from './exporters/config.js'; +export * from '../lib/utils/yo-rc.js'; diff --git a/jdl/jhipster/default-application-options.ts b/jdl/jhipster/default-application-options.ts index 17e2fcbb77a0..046949ec2de6 100644 --- a/jdl/jhipster/default-application-options.ts +++ b/jdl/jhipster/default-application-options.ts @@ -17,7 +17,7 @@ * limitations under the License. */ -import { MESSAGE_BROKER, MESSAGE_BROKER_NO } from '../../generators/server/options/index.js'; +import { MESSAGE_BROKER, MESSAGE_BROKER_NO } from '../../generators/server/options/message-broker.js'; import applicationTypes from './application-types.js'; import authenticationTypes from './authentication-types.js'; import databaseTypes from './database-types.js'; diff --git a/jdl/utils/objects/logger.ts b/jdl/utils/objects/logger.ts index 52088cf12a5f..af175b6b6ceb 100644 --- a/jdl/utils/objects/logger.ts +++ b/jdl/utils/objects/logger.ts @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { createJHipsterLogger } from '../../../generators/base/support/logger.js'; +import { createJHipsterLogger } from '../../../lib/utils/logger.js'; const logger = createJHipsterLogger({ namespace: 'jhipster:jdl' }); diff --git a/lib/internal/config-def.ts b/lib/internal/config-def.ts index f08de318cb78..282f49f30b80 100644 --- a/lib/internal/config-def.ts +++ b/lib/internal/config-def.ts @@ -1,6 +1,6 @@ import type { JHipsterConfigs } from '../../lib/command/index.js'; import type CoreGenerator from '../../generators/base-core/index.js'; -import { upperFirstCamelCase } from '../../generators/base/support/string.js'; +import { upperFirstCamelCase } from '../utils/string.js'; export function loadConfig( this: CoreGenerator | void, diff --git a/generators/base/support/logger.ts b/lib/utils/logger.ts similarity index 100% rename from generators/base/support/logger.ts rename to lib/utils/logger.ts diff --git a/generators/base/support/config.spec.ts b/lib/utils/object.spec.ts similarity index 92% rename from generators/base/support/config.spec.ts rename to lib/utils/object.spec.ts index 3e313a6bcc87..92f1fa290588 100644 --- a/generators/base/support/config.spec.ts +++ b/lib/utils/object.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'esmocha'; -import { removeFieldsWithNullishValues } from './config.js'; +import { removeFieldsWithNullishValues } from './object.js'; describe('generator - base - support - config', () => { describe('deepCleanup', () => { diff --git a/generators/base/support/config.ts b/lib/utils/object.ts similarity index 100% rename from generators/base/support/config.ts rename to lib/utils/object.ts diff --git a/generators/base/support/string.spec.ts b/lib/utils/string.spec.ts similarity index 100% rename from generators/base/support/string.spec.ts rename to lib/utils/string.spec.ts diff --git a/generators/base/support/string.ts b/lib/utils/string.ts similarity index 100% rename from generators/base/support/string.ts rename to lib/utils/string.ts diff --git a/lib/utils/yo-rc.ts b/lib/utils/yo-rc.ts new file mode 100644 index 000000000000..1165ac3ddc1e --- /dev/null +++ b/lib/utils/yo-rc.ts @@ -0,0 +1,14 @@ +export const YO_RC_CONFIG_KEY = 'generator-jhipster' as const; + +type YoRcContent = Record; + +export const mergeYoRcContent = (oldConfig: YoRcContent, newConfig: YoRcContent): YoRcContent => { + const merged: YoRcContent = { [YO_RC_CONFIG_KEY]: {} }; + for (const ns of new Set([...Object.keys(oldConfig), ...Object.keys(newConfig)])) { + merged[ns] = { ...oldConfig[ns], ...newConfig[ns] }; + } + if (oldConfig[YO_RC_CONFIG_KEY]?.creationTimestamp) { + merged[YO_RC_CONFIG_KEY]!.creationTimestamp = oldConfig[YO_RC_CONFIG_KEY].creationTimestamp; + } + return merged; +}; diff --git a/testing/sample-config.ts b/testing/sample-config.ts index 4ef58662bae8..ead912abff19 100644 --- a/testing/sample-config.ts +++ b/testing/sample-config.ts @@ -3,7 +3,7 @@ import { join } from 'node:path'; import type { InfoFile } from '../generators/info/support/extract-info.js'; import { GENERATOR_JHIPSTER } from '../generators/generator-constants.js'; -import { mutateData } from '../generators/base/support/config.js'; +import { mutateData } from '../lib/utils/object.js'; const isFile = async (filename: string): Promise => { try {