From e2d5ffa6e2d2df0f2b5723fadbac530b30bc8a85 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 2 Sep 2024 14:18:06 -0300 Subject: [PATCH 1/8] drop openshift option from jdl --- jdl/__snapshots__/jdl-importer.spec.ts.snap | 18 --- jdl/__test-files__/deployments.jdl | 5 - .../deployment-converter.spec.ts | 11 +- jdl/jdl-importer.spec.ts | 2 +- jdl/jhipster/deployment-options.spec.ts | 16 --- jdl/jhipster/deployment-options.ts | 19 --- jdl/jhipster/index.ts | 1 - jdl/parsing/lexer/deployment-tokens.ts | 1 - jdl/parsing/validator.spec.ts | 2 +- jdl/parsing/validator.ts | 5 - jdl/validators/deployment-validator.spec.ts | 109 +----------------- jdl/validators/deployment-validator.ts | 25 +--- 12 files changed, 8 insertions(+), 206 deletions(-) diff --git a/jdl/__snapshots__/jdl-importer.spec.ts.snap b/jdl/__snapshots__/jdl-importer.spec.ts.snap index 101bde1c8b63..4cfaf1dcf070 100644 --- a/jdl/__snapshots__/jdl-importer.spec.ts.snap +++ b/jdl/__snapshots__/jdl-importer.spec.ts.snap @@ -670,24 +670,6 @@ exports[`jdl - JDLImporter import when parsing deployment config should export t "serviceDiscoveryType": "consul", }, }, - { - "generator-jhipster": { - "appsFolders": [ - "tata", - "titi", - ], - "clusteredDbApps": [], - "deploymentType": "openshift", - "directoryPath": "../", - "dockerPushCommand": "docker push", - "dockerRepositoryName": "test", - "monitoring": "no", - "openshiftNamespace": "default", - "registryReplicas": 2, - "serviceDiscoveryType": "consul", - "storageType": "ephemeral", - }, - }, ] `; diff --git a/jdl/__test-files__/deployments.jdl b/jdl/__test-files__/deployments.jdl index 37bb9401b5eb..8b0381dacc03 100644 --- a/jdl/__test-files__/deployments.jdl +++ b/jdl/__test-files__/deployments.jdl @@ -9,8 +9,3 @@ deployment { dockerRepositoryName "test" kubernetesStorageClassName "KubernetesStorageClassName" } -deployment { - deploymentType openshift, - appsFolders [tata, titi], - dockerRepositoryName "test" -} diff --git a/jdl/converters/parsed-jdl-to-jdl-object/deployment-converter.spec.ts b/jdl/converters/parsed-jdl-to-jdl-object/deployment-converter.spec.ts index ad77b8b01fdd..1754c6b2e974 100644 --- a/jdl/converters/parsed-jdl-to-jdl-object/deployment-converter.spec.ts +++ b/jdl/converters/parsed-jdl-to-jdl-object/deployment-converter.spec.ts @@ -34,7 +34,7 @@ describe('jdl - DeploymentConverter', () => { before(() => { convertedDeployments = convertDeployments([ { - deploymentType: 'openshift', + deploymentType: 'docker-compose', appsFolders: ['tata', 'titi'], dockerRepositoryName: 'test', }, @@ -50,20 +50,17 @@ describe('jdl - DeploymentConverter', () => { "titi", }, "clusteredDbApps": Set {}, - "deploymentType": "openshift", + "deploymentType": "docker-compose", "directoryPath": "../", - "dockerPushCommand": "docker push", "dockerRepositoryName": "test", - "gatewayType": undefined, + "gatewayType": "SpringCloudGateway", "ingressDomain": undefined, "ingressType": undefined, "istio": undefined, "kubernetesServiceType": undefined, "monitoring": "no", - "openshiftNamespace": "default", - "registryReplicas": 2, "serviceDiscoveryType": "consul", - "storageType": "ephemeral", + "storageType": undefined, }, ] `); diff --git a/jdl/jdl-importer.spec.ts b/jdl/jdl-importer.spec.ts index 75ff0e4abd14..4e2f2eba11aa 100644 --- a/jdl/jdl-importer.spec.ts +++ b/jdl/jdl-importer.spec.ts @@ -357,7 +357,7 @@ relationship OneToOne { }); describe('when parsing deployment config', () => { const contents: any[] = []; - const DEPLOYMENT_NAMES = ['docker-compose', 'kubernetes', 'openshift']; + const DEPLOYMENT_NAMES = ['docker-compose', 'kubernetes']; before(() => { const importer = createImporterFromFiles([path.join(__dirname, '__test-files__', 'deployments.jdl')]); diff --git a/jdl/jhipster/deployment-options.spec.ts b/jdl/jhipster/deployment-options.spec.ts index a6f714ab0a05..5c213b61327e 100644 --- a/jdl/jhipster/deployment-options.spec.ts +++ b/jdl/jhipster/deployment-options.spec.ts @@ -78,22 +78,6 @@ describe('jdl - DeploymentOptions', () => { }); }); }); - describe('when passing openshift as arg', () => { - it('should return openshift deployment config', () => { - expect(Options.defaults('openshift')).to.eql({ - appsFolders: [], - clusteredDbApps: [], - directoryPath: '../', - dockerPushCommand: 'docker push', - dockerRepositoryName: '', - monitoring: 'no', - serviceDiscoveryType: 'consul', - openshiftNamespace: 'default', - storageType: 'ephemeral', - registryReplicas: 2, - }); - }); - }); }); }); }); diff --git a/jdl/jhipster/deployment-options.ts b/jdl/jhipster/deployment-options.ts index 12a5829a6338..7e53c8199d81 100644 --- a/jdl/jhipster/deployment-options.ts +++ b/jdl/jhipster/deployment-options.ts @@ -17,15 +17,12 @@ * limitations under the License. */ import kubernetesPlatformTypes from './kubernetes-platform-types.js'; -import openshiftPlatformTypes from './openshift-platform-types.js'; import monitoringTypes from './monitoring-types.js'; import serviceDiscoveryTypes from './service-discovery-types.js'; const { LOAD_BALANCER, NODE_PORT, INGRESS } = kubernetesPlatformTypes.ServiceTypes; const { NGINX, GKE } = kubernetesPlatformTypes.IngressTypes; -const { EPHEMERAL, PERSISTENT } = openshiftPlatformTypes.StorageTypes; - const { EUREKA, CONSUL } = serviceDiscoveryTypes; const NO_SERVICE_DISCOVERY = serviceDiscoveryTypes.NO; @@ -35,13 +32,11 @@ const { PROMETHEUS } = monitoringTypes; export const DeploymentTypes = { DOCKERCOMPOSE: 'docker-compose', KUBERNETES: 'kubernetes', - OPENSHIFT: 'openshift', exists: (deploymentType?: any) => !!deploymentType && !!DeploymentTypes[deploymentType.toUpperCase().replace('-', '')], }; export const DOCKERCOMPOSE = DeploymentTypes.DOCKERCOMPOSE; export const KUBERNETES = DeploymentTypes.KUBERNETES; -export const OPENSHIFT = DeploymentTypes.OPENSHIFT; const kubernetesRelatedOptions = { kubernetesNamespace: 'default', @@ -66,17 +61,6 @@ const kubernetesRelatedOptions = { }, }; -const openshiftRelatedOptions = { - openshiftNamespace: 'default', - registryReplicas: { - two: 2, - }, - storageType: { - ephemeral: EPHEMERAL, - persistent: PERSISTENT, - }, -}; - const dockerComposeRelatedOptions = { gatewayType: { springCloudGateway: 'SpringCloudGateway', @@ -103,13 +87,11 @@ const Options: any = { deploymentType: { dockerCompose: DeploymentTypes.DOCKERCOMPOSE, kubernetes: DeploymentTypes.KUBERNETES, - openshift: DeploymentTypes.OPENSHIFT, }, dockerPushCommand: 'docker push', dockerRepositoryName: '', ...dockerComposeRelatedOptions, ...kubernetesRelatedOptions, - ...openshiftRelatedOptions, }; Options.defaults = (deploymentType = Options.deploymentType.dockerCompose) => { @@ -150,7 +132,6 @@ Options.defaults = (deploymentType = Options.deploymentType.dockerCompose) => { monitoring: Options.monitoring.no, dockerRepositoryName: Options.dockerRepositoryName, dockerPushCommand: Options.dockerPushCommand, - openshiftNamespace: Options.openshiftNamespace, storageType: Options.storageType.ephemeral, registryReplicas: Options.registryReplicas.two, }; diff --git a/jdl/jhipster/index.ts b/jdl/jhipster/index.ts index d93008a9fafc..955dc9472925 100644 --- a/jdl/jhipster/index.ts +++ b/jdl/jhipster/index.ts @@ -15,7 +15,6 @@ export { default as kubernetesPlatformTypes } from './kubernetes-platform-types. export { default as messageBrokerTypes } from './message-broker-types.js'; export { default as monitoringTypes } from './monitoring-types.js'; export { default as openapiOptions } from './openapi-options.js'; -export { default as openshiftPlatformTypes } from './openshift-platform-types.js'; export { default as reservedKeywords } from './reserved-keywords.js'; export { default as searchEngineTypes } from './search-engine-types.js'; export { default as serviceDiscoveryTypes } from './service-discovery-types.js'; diff --git a/jdl/parsing/lexer/deployment-tokens.ts b/jdl/parsing/lexer/deployment-tokens.ts index 01ae5308e6f1..8bf8ae81a2b8 100644 --- a/jdl/parsing/lexer/deployment-tokens.ts +++ b/jdl/parsing/lexer/deployment-tokens.ts @@ -41,7 +41,6 @@ const deploymentTokens = [ { name: 'KUBERNETES_STORAGE_CLASS_NAME', pattern: 'kubernetesStorageClassName' }, { name: 'KUBERNETES_USE_DYNAMIC_STORAGE', pattern: 'kubernetesUseDynamicStorage' }, { name: 'MONITORING', pattern: 'monitoring' }, - { name: 'OPENSHIFT_NAMESPACE', pattern: 'openshiftNamespace' }, { name: 'REGISTRY_REPLICAS', pattern: 'registryReplicas' }, { name: 'STORAGE_TYPE', pattern: 'storageType' }, ].map(tokenConfig => { diff --git a/jdl/parsing/validator.spec.ts b/jdl/parsing/validator.spec.ts index 66b390eee8dd..f7782526a71b 100644 --- a/jdl/parsing/validator.spec.ts +++ b/jdl/parsing/validator.spec.ts @@ -1844,7 +1844,7 @@ describe('jdl - JDLSyntaxValidatorVisitor', () => { }); }); }); - const ALPHANUMERIC_DASH_NAME = ['kubernetesNamespace', 'openshiftNamespace']; + const ALPHANUMERIC_DASH_NAME = ['kubernetesNamespace']; ALPHANUMERIC_DASH_NAME.forEach(type => { describe(`and using for ${type}`, () => { diff --git a/jdl/parsing/validator.ts b/jdl/parsing/validator.ts index 6b83b6647c16..e2b207bf0d74 100644 --- a/jdl/parsing/validator.ts +++ b/jdl/parsing/validator.ts @@ -310,11 +310,6 @@ const deploymentConfigPropsValidations = { type: 'BOOLEAN', msg: 'istio property', }, - OPENSHIFT_NAMESPACE: { - type: 'NAME', - pattern: ALPHANUMERIC_DASH, - msg: 'openshiftNamespace property', - }, REGISTRY_REPLICAS: { type: 'INTEGER' }, STORAGE_TYPE: { type: 'NAME', diff --git a/jdl/validators/deployment-validator.spec.ts b/jdl/validators/deployment-validator.spec.ts index 6551822db2f4..817f587dc065 100644 --- a/jdl/validators/deployment-validator.spec.ts +++ b/jdl/validators/deployment-validator.spec.ts @@ -19,12 +19,11 @@ import { before, describe, it } from 'esmocha'; import { expect } from 'chai'; -import { applicationTypes, databaseTypes, deploymentOptions, searchEngineTypes } from '../built-in-options/index.js'; +import { applicationTypes, deploymentOptions } from '../built-in-options/index.js'; import DeploymentValidator from '../validators/deployment-validator.js'; const { MICROSERVICE } = applicationTypes; -const { MONGODB, NO } = databaseTypes; const { Options } = deploymentOptions; describe('jdl - DeploymentValidator', () => { @@ -202,112 +201,6 @@ describe('jdl - DeploymentValidator', () => { }); }); }); - describe('when having an openshift-related deployment', () => { - describe('without appFolders', () => { - it('should fail', () => { - expect(() => - validator.validate({ - deploymentType: Options.deploymentType.openshift, - directoryPath: '../', - gatewayType: Options.gatewayType.springCloudGateway, - openshiftNamespace: 'default', - }), - ).to.throw(/^The deployment attribute appsFolders was not found.$/); - }); - }); - describe('without directoryPath', () => { - it('should fail', () => { - expect(() => - validator.validate({ - deploymentType: Options.deploymentType.openshift, - appsFolders: ['beers', 'burgers'], - monitoring: 'no', - openshiftNamespace: 'default', - }), - ).to.throw(/^The deployment attribute directoryPath was not found.$/); - }); - }); - describe('without monitoring', () => { - it('should not fail', () => { - expect(() => - validator.validate({ - deploymentType: Options.deploymentType.openshift, - appsFolders: ['beers', 'burgers'], - directoryPath: '../', - openshiftNamespace: 'default', - }), - ).not.to.throw(); - }); - }); - describe('without openshiftNamespace', () => { - it('should not fail', () => { - expect(() => - validator.validate({ - deploymentType: Options.deploymentType.openshift, - appsFolders: ['beers', 'burgers'], - directoryPath: '../', - }), - ).not.to.throw(); - }); - }); - describe('when there is no prodDatabaseType', () => { - it('should fail if there is a storageType', () => { - expect(() => - validator.validate( - { - deploymentType: Options.deploymentType.openshift, - appsFolders: ['beers', 'burgers'], - directoryPath: '../', - storageType: Options.storageType.ephemeral, - }, - { prodDatabaseType: NO }, - ), - ).to.throw(/^Can't have the storageType option set when there is no prodDatabaseType.$/); - }); - }); - describe('when the search engine is elasticsearch', () => { - it('should fail if there is a storageType', () => { - expect(() => - validator.validate( - { - deploymentType: Options.deploymentType.openshift, - appsFolders: ['beers', 'burgers'], - directoryPath: '../', - storageType: Options.storageType.ephemeral, - }, - { searchEngine: searchEngineTypes.ELASTICSEARCH }, - ), - ).to.throw(/^Can't have the storageType option set when elasticsearch is the search engine.$/); - }); - }); - describe('when the monitoring is done with prometheus', () => { - it('should fail if there is a storageType', () => { - expect(() => - validator.validate({ - deploymentType: Options.deploymentType.openshift, - appsFolders: ['beers', 'burgers'], - directoryPath: '../', - storageType: Options.storageType.ephemeral, - monitoring: Options.monitoring.prometheus, - }), - ).to.throw(/^Can't have the storageType option set when the monitoring is done with prometheus.$/); - }); - }); - describe('when the prodDatabaseType is set and the storageType is not set', () => { - it('should not fail', () => { - expect(() => - validator.validate( - { - deploymentType: Options.deploymentType.openshift, - appsFolders: ['beers', 'burgers'], - directoryPath: '../', - }, - { prodDatabaseType: MONGODB }, - ), - ).not.to.throw(); - }); - }); - }); }); describe('when passing an unknown deployment type', () => { it('should fail', () => { diff --git a/jdl/validators/deployment-validator.ts b/jdl/validators/deployment-validator.ts index 4cb30cafb130..b7e116ea410d 100644 --- a/jdl/validators/deployment-validator.ts +++ b/jdl/validators/deployment-validator.ts @@ -17,16 +17,12 @@ * limitations under the License. */ -import { applicationOptions, applicationTypes, databaseTypes, deploymentOptions, searchEngineTypes } from '../built-in-options/index.js'; +import { applicationTypes, deploymentOptions } from '../built-in-options/index.js'; import JDLDeployment from '../models/jdl-deployment.js'; import Validator from './validator.js'; const { Options } = deploymentOptions; const { MICROSERVICE } = applicationTypes; -const { NO } = databaseTypes; -const { ELASTICSEARCH } = searchEngineTypes; -const { OptionNames } = applicationOptions; -const { PROD_DATABASE_TYPE } = OptionNames; export default class DeploymentValidator extends Validator { constructor() { @@ -43,9 +39,6 @@ export default class DeploymentValidator extends Validator { case Options.deploymentType.kubernetes: validateKubernetesRelatedDeployment(jdlDeployment); break; - case Options.deploymentType.openshift: - validateOpenshiftRelatedDeployment(jdlDeployment, options); - break; default: throw new Error(`The deployment type ${jdlDeployment.deploymentType} isn't supported.`); } @@ -71,19 +64,3 @@ function validateKubernetesRelatedDeployment(jdlDeployment: JDLDeployment) { throw new Error('An ingress type is required when dealing with kubernetes-related deployments and when the service type is ingress.'); } } - -function validateOpenshiftRelatedDeployment(jdlDeployment: JDLDeployment, options) { - if (jdlDeployment.storageType) { - if (options.prodDatabaseType === NO) { - throw new Error(`Can't have the storageType option set when there is no ${PROD_DATABASE_TYPE}.`); - } - - if (options.searchEngine === ELASTICSEARCH) { - throw new Error("Can't have the storageType option set when elasticsearch is the search engine."); - } - - if (jdlDeployment.monitoring === Options.monitoring.prometheus) { - throw new Error("Can't have the storageType option set when the monitoring is done with prometheus."); - } - } -} From f534baf798485bc2c3562ccc687a9d3cfc641ef8 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 2 Sep 2024 14:51:28 -0300 Subject: [PATCH 2/8] cleanup --- jdl/converters/jdl-to-json/jdl-to-json-option-converter.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jdl/converters/jdl-to-json/jdl-to-json-option-converter.ts b/jdl/converters/jdl-to-json/jdl-to-json-option-converter.ts index 7ae5caf7366d..1cecacb36c0e 100644 --- a/jdl/converters/jdl-to-json/jdl-to-json-option-converter.ts +++ b/jdl/converters/jdl-to-json/jdl-to-json-option-converter.ts @@ -18,7 +18,7 @@ */ import logger from '../../utils/objects/logger.js'; -import { binaryOptions, entityOptions, searchEngineTypes, unaryOptions } from '../../built-in-options/index.js'; +import { binaryOptions, entityOptions, unaryOptions } from '../../built-in-options/index.js'; import JDLObject from '../../models/jdl-object.js'; import JDLApplication from '../../models/jdl-application.js'; import AbstractJDLOption from '../../models/abstract-jdl-option.js'; @@ -27,7 +27,6 @@ import JDLBinaryOption from '../../models/jdl-binary-option.js'; const { FILTER, NO_FLUENT_METHOD, READ_ONLY, EMBEDDED, SKIP_CLIENT, SKIP_SERVER } = unaryOptions; const { ServiceTypes } = entityOptions; -const { NO: NO_SEARCH_ENGINE } = searchEngineTypes; const NO_SERVICE = ServiceTypes.NO; const { @@ -120,7 +119,7 @@ function getJSONOptionKeyAndValue(jdlOption: AbstractJDLOption): { key: string; function preventEntitiesFromBeingSearched(entityNames: Set) { entityNames.forEach(entityName => { - setOptionToEntityName({ optionName: 'searchEngine', optionValue: NO_SEARCH_ENGINE }, entityName); + setOptionToEntityName({ optionName: 'searchEngine', optionValue: 'no' }, entityName); }); } From 859051214652fefd4ad0eda72019bc6501b077d1 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 2 Sep 2024 14:54:41 -0300 Subject: [PATCH 3/8] move jdl-application-definition to built-in-options --- jdl/built-in-options/index.ts | 6 ------ .../jdl-application-definition.spec.ts | 2 +- .../jdl-application-definition.ts | 2 +- jdl/jhipster/application-options.ts | 2 +- jdl/models/jdl-application-configuration-factory.ts | 2 +- jdl/types/types.d.ts | 2 +- 6 files changed, 5 insertions(+), 11 deletions(-) rename jdl/{models => built-in-options}/jdl-application-definition.spec.ts (98%) rename jdl/{models => built-in-options}/jdl-application-definition.ts (98%) diff --git a/jdl/built-in-options/index.ts b/jdl/built-in-options/index.ts index cae853824bba..7ae6d3b127a0 100644 --- a/jdl/built-in-options/index.ts +++ b/jdl/built-in-options/index.ts @@ -21,12 +21,6 @@ export { /** @deprecated */ entityOptions, /** @deprecated */ - jhipsterOptionTypes, - /** @deprecated */ - jhipsterOptionValues, - /** @deprecated */ - jhipsterQuotedOptionNames, - /** @deprecated */ clientFrameworkTypes, /** @deprecated */ serviceDiscoveryTypes, diff --git a/jdl/models/jdl-application-definition.spec.ts b/jdl/built-in-options/jdl-application-definition.spec.ts similarity index 98% rename from jdl/models/jdl-application-definition.spec.ts rename to jdl/built-in-options/jdl-application-definition.spec.ts index 313a69f8a895..c2926a7f36d4 100644 --- a/jdl/models/jdl-application-definition.spec.ts +++ b/jdl/built-in-options/jdl-application-definition.spec.ts @@ -19,7 +19,7 @@ import { describe, it } from 'esmocha'; import { expect } from 'chai'; -import { applicationOptions } from '../built-in-options/index.js'; +import { applicationOptions } from '../jhipster/index.js'; import JDLApplicationDefinition from './jdl-application-definition.js'; const { OptionNames } = applicationOptions; diff --git a/jdl/models/jdl-application-definition.ts b/jdl/built-in-options/jdl-application-definition.ts similarity index 98% rename from jdl/models/jdl-application-definition.ts rename to jdl/built-in-options/jdl-application-definition.ts index b1649ae27e14..8eba47262ee6 100644 --- a/jdl/models/jdl-application-definition.ts +++ b/jdl/built-in-options/jdl-application-definition.ts @@ -1,4 +1,4 @@ -import { jhipsterOptionTypes, jhipsterOptionValues, jhipsterQuotedOptionNames } from '../built-in-options/index.js'; +import { jhipsterOptionTypes, jhipsterOptionValues, jhipsterQuotedOptionNames } from '../jhipster/index.js'; export type JDLApplicationOptionValue = string | number | boolean | undefined | never[] | Record; export type JDLApplicationOptionTypeValue = 'string' | 'integer' | 'boolean' | 'list' | 'quotedList'; diff --git a/jdl/jhipster/application-options.ts b/jdl/jhipster/application-options.ts index e12db90d6702..abfb6340997d 100644 --- a/jdl/jhipster/application-options.ts +++ b/jdl/jhipster/application-options.ts @@ -22,7 +22,7 @@ import { JDLApplicationOptionType, JDLApplicationOptionTypeValue, JDLApplicationOptionValue, -} from '../models/jdl-application-definition.js'; +} from '../built-in-options/jdl-application-definition.js'; import applicationTypes from './application-types.js'; import authenticationTypes from './authentication-types.js'; import databaseTypes from './database-types.js'; diff --git a/jdl/models/jdl-application-configuration-factory.ts b/jdl/models/jdl-application-configuration-factory.ts index da85553c46b9..622e76a665a8 100644 --- a/jdl/models/jdl-application-configuration-factory.ts +++ b/jdl/models/jdl-application-configuration-factory.ts @@ -23,7 +23,7 @@ import StringJDLApplicationConfigurationOption from './string-jdl-application-co import IntegerJDLApplicationConfigurationOption from './integer-jdl-application-configuration-option.js'; import BooleanJDLApplicationConfigurationOption from './boolean-jdl-application-configuration-option.js'; import ListJDLApplicationConfigurationOption from './list-jdl-application-configuration-option.js'; -import JDLApplicationDefinition, { JDLApplicationOptionTypeValue } from './jdl-application-definition.js'; +import JDLApplicationDefinition, { JDLApplicationOptionTypeValue } from '../built-in-options/jdl-application-definition.js'; import JDLApplicationConfigurationOption from './jdl-application-configuration-option.js'; const applicationDefinition = new JDLApplicationDefinition(); diff --git a/jdl/types/types.d.ts b/jdl/types/types.d.ts index 171d0d04831b..1b14839bfe7c 100644 --- a/jdl/types/types.d.ts +++ b/jdl/types/types.d.ts @@ -21,7 +21,7 @@ import { JDLApplicationOptionType, JDLApplicationOptionTypeValue, JDLApplicationOptionValue, -} from '../models/jdl-application-definition.ts'; +} from '../built-in-options/jdl-application-definition.ts'; import { JDLValidatorOption, JDLValidatorOptionType } from '../parsing/validator.ts'; export type JDLTokenConfig = Pick; From bcf727bf7493eb518c7aaad2c120ea939b07263c Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 2 Sep 2024 14:59:52 -0300 Subject: [PATCH 4/8] drop entityOptions from built-in-options --- jdl/built-in-options/index.ts | 2 -- .../jdl-to-json/jdl-to-json-option-converter.ts | 7 ++----- jdl/models/jdl-application-configuration-factory.ts | 2 +- jdl/parsing/jdl-ast-builder-visitor.ts | 13 ++++++++----- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/jdl/built-in-options/index.ts b/jdl/built-in-options/index.ts index 7ae6d3b127a0..d90c8f443f2b 100644 --- a/jdl/built-in-options/index.ts +++ b/jdl/built-in-options/index.ts @@ -19,8 +19,6 @@ export { /** @deprecated */ searchEngineTypes, /** @deprecated */ - entityOptions, - /** @deprecated */ clientFrameworkTypes, /** @deprecated */ serviceDiscoveryTypes, diff --git a/jdl/converters/jdl-to-json/jdl-to-json-option-converter.ts b/jdl/converters/jdl-to-json/jdl-to-json-option-converter.ts index 1cecacb36c0e..88d298be4a61 100644 --- a/jdl/converters/jdl-to-json/jdl-to-json-option-converter.ts +++ b/jdl/converters/jdl-to-json/jdl-to-json-option-converter.ts @@ -18,7 +18,7 @@ */ import logger from '../../utils/objects/logger.js'; -import { binaryOptions, entityOptions, unaryOptions } from '../../built-in-options/index.js'; +import { binaryOptions, unaryOptions } from '../../built-in-options/index.js'; import JDLObject from '../../models/jdl-object.js'; import JDLApplication from '../../models/jdl-application.js'; import AbstractJDLOption from '../../models/abstract-jdl-option.js'; @@ -26,9 +26,6 @@ import JDLBinaryOption from '../../models/jdl-binary-option.js'; const { FILTER, NO_FLUENT_METHOD, READ_ONLY, EMBEDDED, SKIP_CLIENT, SKIP_SERVER } = unaryOptions; -const { ServiceTypes } = entityOptions; - -const NO_SERVICE = ServiceTypes.NO; const { Options: { ANGULAR_SUFFIX, MICROSERVICE, SEARCH, DTO }, } = binaryOptions; @@ -81,7 +78,7 @@ function setOptionsToEachEntityName(jdlOption: AbstractJDLOption): void { }); jdlOption.entityNames.forEach(entityName => { const serviceOptionValue = convertedOptionContent.get(entityName).service; - if ((!serviceOptionValue || serviceOptionValue === NO_SERVICE) && [DTO, FILTER].includes(jdlOption.name)) { + if ((!serviceOptionValue || serviceOptionValue === 'no') && [DTO, FILTER].includes(jdlOption.name)) { logger.info( `The ${jdlOption.name} option is set for ${entityName}, the '${serviceClassOptionValue}' value for the ` + "'service' is gonna be set for this entity if no other value has been set.", diff --git a/jdl/models/jdl-application-configuration-factory.ts b/jdl/models/jdl-application-configuration-factory.ts index 622e76a665a8..3e28ef0cf438 100644 --- a/jdl/models/jdl-application-configuration-factory.ts +++ b/jdl/models/jdl-application-configuration-factory.ts @@ -18,12 +18,12 @@ */ import logger from '../utils/objects/logger.js'; +import JDLApplicationDefinition, { JDLApplicationOptionTypeValue } from '../built-in-options/jdl-application-definition.js'; import JDLApplicationConfiguration from './jdl-application-configuration.js'; import StringJDLApplicationConfigurationOption from './string-jdl-application-configuration-option.js'; import IntegerJDLApplicationConfigurationOption from './integer-jdl-application-configuration-option.js'; import BooleanJDLApplicationConfigurationOption from './boolean-jdl-application-configuration-option.js'; import ListJDLApplicationConfigurationOption from './list-jdl-application-configuration-option.js'; -import JDLApplicationDefinition, { JDLApplicationOptionTypeValue } from '../built-in-options/jdl-application-definition.js'; import JDLApplicationConfigurationOption from './jdl-application-configuration-option.js'; const applicationDefinition = new JDLApplicationDefinition(); diff --git a/jdl/parsing/jdl-ast-builder-visitor.ts b/jdl/parsing/jdl-ast-builder-visitor.ts index 8322e25f434f..cc655425b911 100644 --- a/jdl/parsing/jdl-ast-builder-visitor.ts +++ b/jdl/parsing/jdl-ast-builder-visitor.ts @@ -18,17 +18,16 @@ */ import deduplicate from '../utils/array-utils.js'; -import { applicationOptions, entityOptions, relationshipOptions, validations } from '../built-in-options/index.js'; +import { applicationOptions, relationshipOptions, validations } from '../built-in-options/index.js'; +import logger from '../utils/objects/logger.js'; import JDLParser from './jdl-parser.js'; const { BUILT_IN_ENTITY } = relationshipOptions; const { OptionNames } = applicationOptions; -const { PaginationTypes } = entityOptions; const { Validations: { PATTERN, REQUIRED, UNIQUE }, } = validations; -const { PAGINATION } = PaginationTypes; const { PACKAGE_NAME } = OptionNames; const parser = JDLParser.getParser(); @@ -97,7 +96,9 @@ export default class JDLAstBuilderVisitor extends BaseJDLCSTVisitor { if (context.binaryOptionDeclaration) { context.binaryOptionDeclaration.map(this.visit, this).forEach(option => { if (option.optionName === 'paginate') { - option.optionName = PAGINATION; + // TODO drop for v9 + logger.warn('The paginate option is deprecated, please use pagination instead.'); + option.optionName = 'pagination'; } const newOption = !ast.options[option.optionName]; if (newOption) { @@ -526,7 +527,9 @@ export default class JDLAstBuilderVisitor extends BaseJDLCSTVisitor { if (context.binaryOptionDeclaration) { context.binaryOptionDeclaration.map(this.visit, this).forEach(option => { if (option.optionName === 'paginate') { - option.optionName = PAGINATION; + // TODO drop for v9 + logger.warn('The paginate option is deprecated, please use pagination instead.'); + option.optionName = 'pagination'; } const newOption = !applicationSubDeclaration.options[option.optionName]; if (newOption) { From 9318ee6ff0e289ddf8cf05aa39b0a6266603986b Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 2 Sep 2024 15:00:44 -0300 Subject: [PATCH 5/8] cleanup --- jdl/built-in-options/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdl/built-in-options/index.ts b/jdl/built-in-options/index.ts index d90c8f443f2b..7ae6d3b127a0 100644 --- a/jdl/built-in-options/index.ts +++ b/jdl/built-in-options/index.ts @@ -19,6 +19,8 @@ export { /** @deprecated */ searchEngineTypes, /** @deprecated */ + entityOptions, + /** @deprecated */ clientFrameworkTypes, /** @deprecated */ serviceDiscoveryTypes, From 5b9a71869a5ab3e29aacf3895093d9e812d1050a Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 2 Sep 2024 15:02:48 -0300 Subject: [PATCH 6/8] cleanup --- jdl/built-in-options/index.ts | 2 -- jdl/exporters/jdl-exporter.spec.ts | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/jdl/built-in-options/index.ts b/jdl/built-in-options/index.ts index 7ae6d3b127a0..725d065ffcef 100644 --- a/jdl/built-in-options/index.ts +++ b/jdl/built-in-options/index.ts @@ -21,7 +21,5 @@ export { /** @deprecated */ entityOptions, /** @deprecated */ - clientFrameworkTypes, - /** @deprecated */ serviceDiscoveryTypes, } from '../jhipster/index.js'; diff --git a/jdl/exporters/jdl-exporter.spec.ts b/jdl/exporters/jdl-exporter.spec.ts index 266212a16745..b1ffc24adf6c 100644 --- a/jdl/exporters/jdl-exporter.spec.ts +++ b/jdl/exporters/jdl-exporter.spec.ts @@ -25,10 +25,9 @@ import { JDLEntity } from '../models/index.js'; import exportToJDL from '../exporters/jdl-exporter.js'; import JDLApplication from '../models/jdl-application.js'; import { JDLJSONApplicationConfiguration } from '../parsing/jdl-parsing-types.js'; -import { applicationOptions, clientFrameworkTypes } from '../built-in-options/index.js'; +import { applicationOptions } from '../built-in-options/index.js'; import { basicHelpers as helpers } from '../../testing/index.js'; -const NO_CLIENT_FRAMEWORK = clientFrameworkTypes.NO; const { OptionNames: { CLIENT_FRAMEWORK }, } = applicationOptions; @@ -104,7 +103,7 @@ describe('jdl - JDLExporter', () => { beforeEach(() => { jdlObject = new JDLObject(); const jdlApplication: JDLJSONApplicationConfiguration = { - config: { [CLIENT_FRAMEWORK]: NO_CLIENT_FRAMEWORK }, + config: { [CLIENT_FRAMEWORK]: 'no' }, }; jdlObject.addApplication(new JDLApplication(jdlApplication)); }); From c953c384aa6a66b28a2eafdd767c1615a253bf01 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 2 Sep 2024 15:04:04 -0300 Subject: [PATCH 7/8] cleanup --- jdl/built-in-options/index.ts | 2 -- jdl/models/jdl-deployment.ts | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/jdl/built-in-options/index.ts b/jdl/built-in-options/index.ts index 725d065ffcef..a54a8a4bc056 100644 --- a/jdl/built-in-options/index.ts +++ b/jdl/built-in-options/index.ts @@ -20,6 +20,4 @@ export { searchEngineTypes, /** @deprecated */ entityOptions, - /** @deprecated */ - serviceDiscoveryTypes, } from '../jhipster/index.js'; diff --git a/jdl/models/jdl-deployment.ts b/jdl/models/jdl-deployment.ts index 65a6425f3a7f..88b5dc333f79 100644 --- a/jdl/models/jdl-deployment.ts +++ b/jdl/models/jdl-deployment.ts @@ -17,14 +17,13 @@ * limitations under the License. */ import { isEqual } from 'lodash-es'; -import { applicationOptions, deploymentOptions, serviceDiscoveryTypes } from '../built-in-options/index.js'; +import { applicationOptions, deploymentOptions } from '../built-in-options/index.js'; import { merge } from '../utils/object-utils.js'; import { join } from '../utils/set-utils.js'; import { ParsedJDLDeployment } from '../converters/parsed-jdl-to-jdl-object/types.js'; const { Options } = deploymentOptions; const arrayTypes = ['appsFolders', 'clusteredDbApps']; -const NO_SERVICE_DISCOVERY = serviceDiscoveryTypes.NO; export default class JDLDeployment { deploymentType!: string; @@ -48,7 +47,7 @@ export default class JDLDeployment { if (Array.isArray(option) && arrayTypes.includes(key)) { this[key] = new Set(option); } else if (key === applicationOptions.OptionNames.SERVICE_DISCOVERY_TYPE && option === Options.serviceDiscoveryType.no) { - this[key] = NO_SERVICE_DISCOVERY; + this[key] = 'no'; } else { this[key] = option; } From 457cf3695272d9d1de72fc7ea884bf9ad06bed3d Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 2 Sep 2024 15:09:10 -0300 Subject: [PATCH 8/8] cleanup --- jdl/built-in-options/index.ts | 2 -- .../option-converter.spec.ts | 16 +++++----------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/jdl/built-in-options/index.ts b/jdl/built-in-options/index.ts index a54a8a4bc056..751de79485a8 100644 --- a/jdl/built-in-options/index.ts +++ b/jdl/built-in-options/index.ts @@ -17,7 +17,5 @@ export { /** @deprecated */ deploymentOptions, /** @deprecated */ - searchEngineTypes, - /** @deprecated */ entityOptions, } from '../jhipster/index.js'; diff --git a/jdl/converters/parsed-jdl-to-jdl-object/option-converter.spec.ts b/jdl/converters/parsed-jdl-to-jdl-object/option-converter.spec.ts index a99c94523a8c..a6b0736a26b9 100644 --- a/jdl/converters/parsed-jdl-to-jdl-object/option-converter.spec.ts +++ b/jdl/converters/parsed-jdl-to-jdl-object/option-converter.spec.ts @@ -18,15 +18,9 @@ */ import { before, describe, expect, it } from 'esmocha'; -import { binaryOptions, entityOptions, searchEngineTypes, unaryOptions } from '../../built-in-options/index.js'; +import { binaryOptions, unaryOptions } from '../../built-in-options/index.js'; import { convertOptions } from './option-converter.js'; -const { MapperTypes, PaginationTypes } = entityOptions; -const { COUCHBASE } = searchEngineTypes; - -const { MAPSTRUCT } = MapperTypes; -const { PAGINATION } = PaginationTypes; - describe('jdl - OptionConverter', () => { describe('convertOptions', () => { describe('when not passing options', () => { @@ -91,12 +85,12 @@ describe('jdl - OptionConverter', () => { before(() => { convertedOptions = convertOptions({}, [ { - optionValues: [MAPSTRUCT, COUCHBASE], + optionValues: ['mapstruct', 'elasticsearch'], list: ['*'], excluded: ['B'], }, { - optionValues: [PAGINATION], + optionValues: ['pagination'], list: ['A', 'C'], excluded: [], }, @@ -123,7 +117,7 @@ describe('jdl - OptionConverter', () => { "B", }, "name": "search", - "value": "couchbase", + "value": "elasticsearch", }, JDLBinaryOption { "entityNames": Set { @@ -144,7 +138,7 @@ describe('jdl - OptionConverter', () => { before(() => { convertedOptions = convertOptions({}, [ { - optionValues: [MAPSTRUCT], + optionValues: ['mapstruct'], list: ['*'], excluded: ['B'], },