From 677d2fd0869bc99473d22a0236dd7c17418b5da7 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Mon, 26 Dec 2022 23:22:57 +0100 Subject: [PATCH 1/8] migrate remaining cjs files to mjs --- cli/environment-builder.mjs | 2 +- cli/import-jdl.mjs | 5 +- cli/program.mjs | 2 +- generators/angular/generator.spec.mts | 2 +- generators/app/generator.mjs | 2 +- generators/app/prompts.mjs | 2 +- generators/aws/generator.mjs | 4 +- generators/aws/lib/{aws.cjs => aws.mjs} | 14 +- generators/aws/lib/{eb.cjs => eb.mjs} | 5 +- generators/aws/lib/{iam.cjs => iam.mjs} | 5 +- generators/aws/lib/{rds.cjs => rds.mjs} | 5 +- generators/aws/lib/{s3.cjs => s3.mjs} | 12 +- generators/azure-app-service/generator.mjs | 4 +- generators/azure-spring-cloud/generator.mjs | 4 +- generators/base-application/generator.mjs | 3 +- generators/base-application/priorities.cjs | 138 -------- generators/base-application/priorities.mjs | 157 +++++++-- generators/base-docker/generator.mjs | 4 +- generators/base/generator-base-blueprint.mjs | 2 +- generators/base/generator-base-private.mjs | 4 +- generators/base/generator-base.mjs | 8 +- generators/base/jhipster7-proxy.mjs | 2 +- generators/base/priorities.cjs | 201 ------------ generators/base/priorities.mjs | 174 +++++++++- .../bootstrap-application-base/faker.mts | 4 +- .../bootstrap-application-base/generator.mts | 3 +- .../generator.mts | 4 +- generators/bootstrap/generator.mts | 2 +- generators/ci-cd/generator.mjs | 4 +- generators/cleanup.mjs | 2 +- generators/client/entity-files.mjs | 5 +- generators/client/generator.mjs | 4 +- ...-angular.cjs => needle-client-angular.mjs} | 14 +- ...client-i18n.cjs => needle-client-i18n.mjs} | 8 +- ...ient-react.cjs => needle-client-react.mjs} | 10 +- ...e-client-vue.cjs => needle-client-vue.mjs} | 12 +- ...-webpack.cjs => needle-client-webpack.mjs} | 8 +- .../{needle-client.cjs => needle-client.mjs} | 6 +- generators/client/utils.mjs | 4 +- generators/cloudfoundry/generator.mjs | 4 +- generators/common/generator.mjs | 2 +- generators/couchbase/entity-files.mjs | 3 +- generators/couchbase/files.mjs | 3 +- generators/cypress/files.mts | 2 +- generators/cypress/generator.mts | 4 +- generators/cypress/generator.spec.mts | 2 +- generators/docker-compose/generator.mjs | 3 +- .../service-discovery-matcher.mts | 2 +- generators/docker/files.mjs | 4 +- generators/docker/generator.mjs | 3 +- generators/entities/generator.mjs | 3 +- generators/entities/generator.spec.mts | 2 +- generators/entity/generator.mjs | 2 +- generators/entity/prompts.mjs | 2 +- generators/export-jdl/generator.mts | 2 +- generators/gae/generator.mjs | 4 +- generators/generator-constants.cjs | 297 ------------------ generators/generator-constants.mjs | 284 ++++++++++++++++- generators/gradle/generator.spec.mjs | 3 +- generators/heroku/generator.mjs | 4 +- generators/init/generator.spec.mts | 3 +- generators/kafka/files.mjs | 3 +- generators/kubernetes-helm/generator.mjs | 2 +- generators/kubernetes-knative/generator.mjs | 2 +- generators/kubernetes/generator.mjs | 2 +- generators/kubernetes/kubernetes-base.mjs | 2 +- generators/languages/detect-language.mjs | 2 +- generators/languages/entity-files.mjs | 2 +- generators/languages/files.mjs | 2 +- generators/languages/generator.mjs | 8 +- generators/languages/languages.spec.mjs | 2 +- generators/liquibase-changelogs/files.mjs | 4 +- .../incremental-liquibase.spec.mts | 2 +- generators/liquibase/files.mts | 4 +- generators/liquibase/generator.mts | 2 +- generators/maven/generator.spec.mjs | 3 +- generators/{needle-api.cjs => needle-api.mjs} | 28 +- .../{needle-base.cjs => needle-base.mjs} | 8 +- generators/openapi-client/files.mjs | 2 +- generators/openshift/generator.mjs | 2 +- generators/page/files-vue.mjs | 4 +- generators/react/generator.spec.mts | 2 +- .../__test-support/elastic-search-matcher.mts | 2 +- generators/server/cleanup.mjs | 4 +- generators/server/entity-files.mjs | 4 +- generators/server/files-sql.mjs | 6 +- generators/server/files.mjs | 4 +- generators/server/generator.mjs | 4 +- ...rver-cache.cjs => needle-server-cache.mjs} | 10 +- ...er-gradle.cjs => needle-server-gradle.mjs} | 8 +- ...uibase.cjs => needle-server-liquibase.mjs} | 10 +- ...g.cjs => needle-server-logback-spring.mjs} | 10 +- ...rver-maven.cjs => needle-server-maven.mjs} | 8 +- .../{needle-server.cjs => needle-server.mjs} | 4 +- generators/spring-controller/generator.mjs | 4 +- generators/spring-service/generator.mjs | 4 +- generators/{statistics.cjs => statistics.mjs} | 16 +- generators/upgrade/generator.mjs | 4 +- generators/upgrade/upgrade.spec.mts | 2 +- generators/{utils.cjs => utils.mjs} | 51 ++- generators/vue/generator.spec.mts | 2 +- generators/workspaces/generator.mjs | 4 +- test-integration/scripts/00-init-env.sh | 4 +- test/app/composing.spec.mts | 3 +- test/app/database-changelog.spec.mts | 4 +- test/entity/database-changelog.spec.mts | 3 +- test/entity/single-entity.spec.mts | 3 +- test/heroku.spec.mts | 2 +- test/needle-api/needle-base.spec.mts | 2 +- .../needle-api/needle-client-angular.spec.mts | 2 +- test/needle-api/needle-client-i18n.spec.mts | 2 +- test/needle-api/needle-client-react.spec.mts | 2 +- test/needle-api/needle-client-vue.spec.mts | 2 +- .../needle-api/needle-client-webpack.spec.mts | 2 +- test/needle-api/needle-client.spec.mts | 2 +- test/needle-api/needle-server-cache.spec.mts | 2 +- .../needle-server-liquibase.spec.mts | 2 +- .../needle-server-logback-spring.spec.mts | 2 +- test/page.spec.mts | 2 +- test/spring-controller.spec.mts | 2 +- test/spring-service.spec.mts | 2 +- test/support/tests.mjs | 6 +- test/utils.spec.mjs | 2 +- 123 files changed, 865 insertions(+), 926 deletions(-) rename generators/aws/lib/{aws.cjs => aws.mjs} (86%) rename generators/aws/lib/{eb.cjs => eb.mjs} (99%) rename generators/aws/lib/{iam.cjs => iam.mjs} (99%) rename generators/aws/lib/{rds.cjs => rds.mjs} (98%) rename generators/aws/lib/{s3.cjs => s3.mjs} (95%) delete mode 100644 generators/base-application/priorities.cjs delete mode 100644 generators/base/priorities.cjs rename generators/client/needle-api/{needle-client-angular.cjs => needle-client-angular.mjs} (97%) rename generators/client/needle-api/{needle-client-i18n.cjs => needle-client-i18n.mjs} (93%) rename generators/client/needle-api/{needle-client-react.cjs => needle-client-react.mjs} (95%) rename generators/client/needle-api/{needle-client-vue.cjs => needle-client-vue.mjs} (97%) rename generators/client/needle-api/{needle-client-webpack.cjs => needle-client-webpack.mjs} (92%) rename generators/client/needle-api/{needle-client.cjs => needle-client.mjs} (95%) delete mode 100644 generators/generator-constants.cjs rename generators/{needle-api.cjs => needle-api.mjs} (59%) rename generators/{needle-base.cjs => needle-base.mjs} (94%) rename generators/server/needle-api/{needle-server-cache.cjs => needle-server-cache.mjs} (93%) rename generators/server/needle-api/{needle-server-gradle.cjs => needle-server-gradle.mjs} (97%) rename generators/server/needle-api/{needle-server-liquibase.cjs => needle-server-liquibase.mjs} (93%) rename generators/server/needle-api/{needle-server-logback-spring.cjs => needle-server-logback-spring.mjs} (87%) rename generators/server/needle-api/{needle-server-maven.cjs => needle-server-maven.mjs} (98%) rename generators/server/needle-api/{needle-server.cjs => needle-server.mjs} (88%) rename generators/{statistics.cjs => statistics.mjs} (95%) rename generators/{utils.cjs => utils.mjs} (98%) diff --git a/cli/environment-builder.mjs b/cli/environment-builder.mjs index 0472eedd5f22..90cf768fcfd2 100644 --- a/cli/environment-builder.mjs +++ b/cli/environment-builder.mjs @@ -26,7 +26,7 @@ import { dirname } from 'path'; import { fileURLToPath } from 'url'; import { CLI_NAME, logger } from './utils.mjs'; -import generatorUtils from '../generators/utils.cjs'; +import generatorUtils from '../generators/utils.mjs'; import { parseBlueprintInfo, loadBlueprintsFromConfiguration, mergeBlueprints } from '../utils/blueprint.mjs'; const { packageNameToNamespace } = generatorUtils; diff --git a/cli/import-jdl.mjs b/cli/import-jdl.mjs index 42db8b68045d..226d46973465 100644 --- a/cli/import-jdl.mjs +++ b/cli/import-jdl.mjs @@ -28,10 +28,11 @@ import { fork as forkProcess } from 'child_process'; import EnvironmentBuilder from './environment-builder.mjs'; import { CLI_NAME, GENERATOR_NAME, logger, printSuccess, getOptionAsArgs } from './utils.mjs'; import { packageJson as packagejs } from '../lib/index.mjs'; -import statistics from '../generators/statistics.cjs'; -import { JHIPSTER_CONFIG_DIR } from '../generators/generator-constants.mjs'; +import statistics from '../generators/statistics.mjs'; +import constants from '../generators/generator-constants.mjs'; import { writeConfigFile } from './export-utils.mjs'; +const { JHIPSTER_CONFIG_DIR } = constants; const jhipsterCli = join(dirname(fileURLToPath(import.meta.url)), 'cli.mjs'); const getDeploymentType = deployment => deployment && deployment[GENERATOR_NAME] && deployment[GENERATOR_NAME].deploymentType; diff --git a/cli/program.mjs b/cli/program.mjs index 09a74d778480..3ccdf48c9a90 100644 --- a/cli/program.mjs +++ b/cli/program.mjs @@ -32,7 +32,7 @@ import SUB_GENERATORS from './commands.mjs'; import JHipsterCommand from './jhipster-command.mjs'; import { CLI_NAME, logger, getCommand, done } from './utils.mjs'; import { packageJson } from '../lib/index.mjs'; -import generatorUtils from '../generators/utils.cjs'; +import generatorUtils from '../generators/utils.mjs'; const { packageNameToNamespace } = generatorUtils; const __filename = fileURLToPath(import.meta.url); diff --git a/generators/angular/generator.spec.mts b/generators/angular/generator.spec.mts index 171a08a29b89..c616eca823c1 100644 --- a/generators/angular/generator.spec.mts +++ b/generators/angular/generator.spec.mts @@ -9,7 +9,7 @@ import Generator from './index.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import BaseApplicationGenerator from '../base-application/index.mjs'; const { snakeCase } = lodash; diff --git a/generators/app/generator.mjs b/generators/app/generator.mjs index 0fb0d1bc9c98..071f0bb716e5 100644 --- a/generators/app/generator.mjs +++ b/generators/app/generator.mjs @@ -26,7 +26,7 @@ import serverOptions from '../server/options.mjs'; import { cleanupOldFiles, upgradeFiles } from '../cleanup.mjs'; import prompts from './prompts.mjs'; import { packageJson as packagejs } from '../../lib/index.mjs'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; import generatorDefaults from '../generator-defaults.mjs'; import { GENERATOR_APP, diff --git a/generators/app/prompts.mjs b/generators/app/prompts.mjs index 7d43d27b6e7c..74c5175ce21d 100644 --- a/generators/app/prompts.mjs +++ b/generators/app/prompts.mjs @@ -17,7 +17,7 @@ * limitations under the License. */ import chalk from 'chalk'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; import { packageJson as packagejs } from '../../lib/index.mjs'; import generatorsDefaults from '../generator-defaults.mjs'; import { applicationTypes, testFrameworkTypes } from '../../jdl/jhipster/index.mjs'; diff --git a/generators/aws/generator.mjs b/generators/aws/generator.mjs index d1472154706e..3232853c0202 100644 --- a/generators/aws/generator.mjs +++ b/generators/aws/generator.mjs @@ -20,8 +20,8 @@ import chalk from 'chalk'; import BaseGenerator from '../base/index.mjs'; import prompts from './prompts.mjs'; -import AwsFactory from './lib/aws.cjs'; -import statistics from '../statistics.cjs'; +import AwsFactory from './lib/aws.mjs'; +import statistics from '../statistics.mjs'; import { GENERATOR_AWS } from '../generator-list.mjs'; import { applicationOptions, databaseTypes } from '../../jdl/jhipster/index.mjs'; diff --git a/generators/aws/lib/aws.cjs b/generators/aws/lib/aws.mjs similarity index 86% rename from generators/aws/lib/aws.cjs rename to generators/aws/lib/aws.mjs index df64cbf4cd94..aa1d28b30024 100644 --- a/generators/aws/lib/aws.cjs +++ b/generators/aws/lib/aws.mjs @@ -16,15 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const S3 = require('./s3.cjs'); -const Rds = require('./rds.cjs'); -const Eb = require('./eb.cjs'); -const Iam = require('./iam.cjs'); +import S3 from './s3.mjs'; +import Rds from './rds.mjs'; +import Eb from './eb.mjs'; +import Iam from './iam.mjs'; let Aws; let generator; -const AwsFactory = (module.exports = function AwsFactory(generatorRef, cb) { +const AwsFactory = function AwsFactory(generatorRef, cb) { generator = generatorRef; try { Aws = require('aws-sdk'); // eslint-disable-line @@ -32,7 +32,7 @@ const AwsFactory = (module.exports = function AwsFactory(generatorRef, cb) { } catch (e) { generator.error(`Something went wrong while running jhipster:aws:\n${e}`); } -}); +}; AwsFactory.prototype.init = function initAws(options) { Aws.config.region = options.region; @@ -53,3 +53,5 @@ AwsFactory.prototype.getEb = function getEb() { AwsFactory.prototype.getIam = function getIa() { return new Iam(Aws, generator); }; + +export default AwsFactory; diff --git a/generators/aws/lib/eb.cjs b/generators/aws/lib/eb.mjs similarity index 99% rename from generators/aws/lib/eb.cjs rename to generators/aws/lib/eb.mjs index e51483152a01..83f434540b6d 100644 --- a/generators/aws/lib/eb.cjs +++ b/generators/aws/lib/eb.mjs @@ -19,7 +19,7 @@ let aws; let uuidV4; -const Eb = (module.exports = function Eb(Aws, generator) { +const Eb = function Eb(Aws, generator) { aws = Aws; try { const { v4 } = require('uuid'); // eslint-disable-line @@ -27,7 +27,7 @@ const Eb = (module.exports = function Eb(Aws, generator) { } catch (e) { generator.error(`Something went wrong while running jhipster:aws:\n${e}`); } -}); +}; Eb.prototype.createApplication = function createApplication(params, callback) { const applicationName = params.applicationName; @@ -245,3 +245,4 @@ function updateEnvironment(params, callback) { } }); } +export default Eb; diff --git a/generators/aws/lib/iam.cjs b/generators/aws/lib/iam.mjs similarity index 99% rename from generators/aws/lib/iam.cjs rename to generators/aws/lib/iam.mjs index 73e58c39e151..9be032afe4aa 100644 --- a/generators/aws/lib/iam.cjs +++ b/generators/aws/lib/iam.mjs @@ -25,10 +25,10 @@ const AWS_SERVICE_ARN = suffix => `arn:aws:iam::aws:policy/service-role/${suffix let aws; let log; -const Iam = (module.exports = function Iam(Aws, generator) { +const Iam = function Iam(Aws, generator) { aws = Aws; log = generator.log; -}); +}; const createRole = (RoleName, Description, AssumeRolePolicyDocument) => { const iam = new aws.IAM(); @@ -219,3 +219,4 @@ Iam.prototype.verifyRoles = function verifyRoles(params, callback) { ); }); }; +export default Iam; diff --git a/generators/aws/lib/rds.cjs b/generators/aws/lib/rds.mjs similarity index 98% rename from generators/aws/lib/rds.cjs rename to generators/aws/lib/rds.mjs index d21c5b4a3281..c474bd9f138f 100644 --- a/generators/aws/lib/rds.cjs +++ b/generators/aws/lib/rds.mjs @@ -18,9 +18,9 @@ */ let aws; -const Rds = (module.exports = function Rds(Aws) { +const Rds = function Rds(Aws) { aws = Aws; -}); +}; Rds.prototype.createDatabase = function createDatabase(params, callback) { const dbInstanceClass = params.dbInstanceClass; @@ -148,3 +148,4 @@ function createDbInstance(params, callback) { } }); } +export default Rds; diff --git a/generators/aws/lib/s3.cjs b/generators/aws/lib/s3.mjs similarity index 95% rename from generators/aws/lib/s3.cjs rename to generators/aws/lib/s3.mjs index e3007a60e3ad..334057d64a1e 100644 --- a/generators/aws/lib/s3.cjs +++ b/generators/aws/lib/s3.mjs @@ -16,23 +16,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const fs = require('fs'); - -const { GRADLE } = require('../../../jdl/jhipster/build-tool-types'); +import fs from 'fs'; +import { buildToolTypes } from '../../../jdl/jhipster/index.mjs'; +const { GRADLE } = buildToolTypes; const FILE_EXTENSION = '.war'; const S3_STANDARD_REGION = 'us-east-1'; let Progressbar; -const S3 = (module.exports = function S3(Aws, generator) { +const S3 = function S3(Aws, generator) { this.Aws = Aws; try { Progressbar = require('progress'); // eslint-disable-line } catch (e) { generator.error(`Something went wrong while running jhipster:aws:\n${e}`); } -}); +}; S3.prototype.createBucket = function createBucket(params, callback) { const bucket = params.bucket; @@ -161,3 +161,5 @@ function success(message, callback) { function error(message, callback) { callback({ message }, null); } + +export default S3; diff --git a/generators/azure-app-service/generator.mjs b/generators/azure-app-service/generator.mjs index 6e5f663338bb..bcc61b5d9577 100644 --- a/generators/azure-app-service/generator.mjs +++ b/generators/azure-app-service/generator.mjs @@ -23,11 +23,11 @@ import { exec } from 'child_process'; import chalk from 'chalk'; import BaseGenerator from '../base/index.mjs'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; import generatorDefaults from '../generator-defaults.mjs'; // Global constants -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { GENERATOR_AZURE_APP_SERVICE } from '../generator-list.mjs'; import { buildToolTypes } from '../../jdl/jhipster/index.mjs'; diff --git a/generators/azure-spring-cloud/generator.mjs b/generators/azure-spring-cloud/generator.mjs index 3cbb5802053d..b49a93492ba0 100644 --- a/generators/azure-spring-cloud/generator.mjs +++ b/generators/azure-spring-cloud/generator.mjs @@ -21,9 +21,9 @@ import { exec } from 'child_process'; import chalk from 'chalk'; import BaseGenerator from '../base/index.mjs'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { cacheTypes, buildToolTypes } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_AZURE_SPRING_CLOUD } from '../generator-list.mjs'; diff --git a/generators/base-application/generator.mjs b/generators/base-application/generator.mjs index 92ab37186200..a1dbb22d28f5 100644 --- a/generators/base-application/generator.mjs +++ b/generators/base-application/generator.mjs @@ -20,8 +20,9 @@ import _ from 'lodash'; import BaseGenerator from '../base/index.mjs'; import { CUSTOM_PRIORITIES, PRIORITY_NAMES, QUEUES } from './priorities.mjs'; -import { JHIPSTER_CONFIG_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; +const { JHIPSTER_CONFIG_DIR } = constants; const { LOADING, PREPARING, diff --git a/generators/base-application/priorities.cjs b/generators/base-application/priorities.cjs deleted file mode 100644 index e346d51c9bc2..000000000000 --- a/generators/base-application/priorities.cjs +++ /dev/null @@ -1,138 +0,0 @@ -const { PRIORITY_PREFIX, QUEUE_PREFIX, PRIORITY_NAMES, QUEUES } = require('../base/priorities.cjs'); - -const { DEFAULT, TRANSFORM, PRE_CONFLICTS } = PRIORITY_NAMES; - -const CONFIGURING_EACH_ENTITY = 'configuringEachEntity'; -const CONFIGURING_EACH_ENTITY_QUEUE = `${QUEUE_PREFIX}${CONFIGURING_EACH_ENTITY}`; - -const LOADING_ENTITIES = 'loadingEntities'; -const LOADING_ENTITIES_QUEUE = `${QUEUE_PREFIX}${LOADING_ENTITIES}`; - -const PREPARING_EACH_ENTITY = 'preparingEachEntity'; -const PREPARING_EACH_ENTITY_QUEUE = `${QUEUE_PREFIX}${PREPARING_EACH_ENTITY}`; - -const PREPARING_EACH_ENTITY_FIELD = 'preparingEachEntityField'; -const PREPARING_EACH_ENTITY_FIELD_QUEUE = `${QUEUE_PREFIX}${PREPARING_EACH_ENTITY_FIELD}`; - -const PREPARING_EACH_ENTITY_RELATIONSHIP = 'preparingEachEntityRelationship'; -const PREPARING_EACH_ENTITY_RELATIONSHIP_QUEUE = `${QUEUE_PREFIX}${PREPARING_EACH_ENTITY_RELATIONSHIP}`; - -const POST_PREPARING_EACH_ENTITY = 'postPreparingEachEntity'; -const POST_PREPARING_EACH_ENTITY_QUEUE = `${QUEUE_PREFIX}${POST_PREPARING_EACH_ENTITY}`; - -const WRITING_ENTITIES = 'writingEntities'; -const WRITING_ENTITIES_QUEUE = `${QUEUE_PREFIX}${WRITING_ENTITIES}`; - -const POST_WRITING_ENTITIES = 'postWritingEntities'; -const POST_WRITING_ENTITIES_QUEUE = `${QUEUE_PREFIX}${POST_WRITING_ENTITIES}`; - -const CUSTOM_PRIORITIES = [ - { - priorityName: CONFIGURING_EACH_ENTITY, - queueName: CONFIGURING_EACH_ENTITY_QUEUE, - before: LOADING_ENTITIES, - skip: true, - }, - { - priorityName: LOADING_ENTITIES, - queueName: LOADING_ENTITIES_QUEUE, - before: PREPARING_EACH_ENTITY, - skip: true, - }, - { - priorityName: PREPARING_EACH_ENTITY, - queueName: PREPARING_EACH_ENTITY_QUEUE, - before: PREPARING_EACH_ENTITY_FIELD, - skip: true, - }, - { - priorityName: PREPARING_EACH_ENTITY_FIELD, - queueName: PREPARING_EACH_ENTITY_FIELD_QUEUE, - before: PREPARING_EACH_ENTITY_RELATIONSHIP, - skip: true, - }, - { - priorityName: PREPARING_EACH_ENTITY_RELATIONSHIP, - queueName: PREPARING_EACH_ENTITY_RELATIONSHIP_QUEUE, - before: POST_PREPARING_EACH_ENTITY, - skip: true, - }, - { - priorityName: POST_PREPARING_EACH_ENTITY, - queueName: POST_PREPARING_EACH_ENTITY_QUEUE, - before: DEFAULT, - skip: true, - }, - { - priorityName: WRITING_ENTITIES, - queueName: WRITING_ENTITIES_QUEUE, - before: TRANSFORM, - skip: true, - }, - { - priorityName: POST_WRITING_ENTITIES, - queueName: POST_WRITING_ENTITIES_QUEUE, - before: PRE_CONFLICTS, - skip: true, - }, -].reverse(); - -const ENTITY_QUEUES = { - CONFIGURING_EACH_ENTITY_QUEUE, - LOADING_ENTITIES_QUEUE, - PREPARING_EACH_ENTITY_QUEUE, - PREPARING_EACH_ENTITY_FIELD_QUEUE, - PREPARING_EACH_ENTITY_RELATIONSHIP_QUEUE, - POST_PREPARING_EACH_ENTITY_QUEUE, - WRITING_ENTITIES_QUEUE, - POST_WRITING_ENTITIES_QUEUE, -}; - -const ENTITY_PRIORITY_NAMES = { - CONFIGURING_EACH_ENTITY, - LOADING_ENTITIES, - PREPARING_EACH_ENTITY, - PREPARING_EACH_ENTITY_FIELD, - PREPARING_EACH_ENTITY_RELATIONSHIP, - POST_PREPARING_EACH_ENTITY, - WRITING_ENTITIES, - POST_WRITING_ENTITIES, -}; - -const PRIORITY_NAMES_LIST = [ - PRIORITY_NAMES.INITIALIZING, - PRIORITY_NAMES.PROMPTING, - PRIORITY_NAMES.CONFIGURING, - PRIORITY_NAMES.COMPOSING, - PRIORITY_NAMES.LOADING, - PRIORITY_NAMES.PREPARING, - CONFIGURING_EACH_ENTITY, - LOADING_ENTITIES, - PREPARING_EACH_ENTITY, - PREPARING_EACH_ENTITY_FIELD, - PREPARING_EACH_ENTITY_RELATIONSHIP, - POST_PREPARING_EACH_ENTITY, - DEFAULT, - PRIORITY_NAMES.WRITING, - WRITING_ENTITIES, - PRIORITY_NAMES.POST_WRITING, - POST_WRITING_ENTITIES, - PRIORITY_NAMES.INSTALL, - PRIORITY_NAMES.POST_INSTALL, - PRIORITY_NAMES.END, -]; - -module.exports = { - PRIORITY_PREFIX, - CUSTOM_PRIORITIES, - PRIORITY_NAMES_LIST, - PRIORITY_NAMES: { - ...PRIORITY_NAMES, - ...ENTITY_PRIORITY_NAMES, - }, - ENTITY_PRIORITY_NAMES, - QUEUES: { - ...QUEUES, - ...ENTITY_QUEUES, - }, -}; diff --git a/generators/base-application/priorities.mjs b/generators/base-application/priorities.mjs index ad73da379c6d..585557f309eb 100644 --- a/generators/base-application/priorities.mjs +++ b/generators/base-application/priorities.mjs @@ -1,24 +1,133 @@ -/** - * Copyright 2013-2022 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 priorities from './priorities.cjs'; - -const { PRIORITY_PREFIX, CUSTOM_PRIORITIES, QUEUES, PRIORITY_NAMES, PRIORITY_NAMES_LIST } = priorities; - -export { PRIORITY_PREFIX, CUSTOM_PRIORITIES, QUEUES, PRIORITY_NAMES, PRIORITY_NAMES_LIST }; +import { PRIORITY_PREFIX, QUEUE_PREFIX, PRIORITY_NAMES as PRIORITY_NAMES2, QUEUES as QUEUES2 } from '../base/priorities.mjs'; + +const { DEFAULT, TRANSFORM, PRE_CONFLICTS } = PRIORITY_NAMES2; + +const CONFIGURING_EACH_ENTITY = 'configuringEachEntity'; +const CONFIGURING_EACH_ENTITY_QUEUE = `${QUEUE_PREFIX}${CONFIGURING_EACH_ENTITY}`; + +const LOADING_ENTITIES = 'loadingEntities'; +const LOADING_ENTITIES_QUEUE = `${QUEUE_PREFIX}${LOADING_ENTITIES}`; + +const PREPARING_EACH_ENTITY = 'preparingEachEntity'; +const PREPARING_EACH_ENTITY_QUEUE = `${QUEUE_PREFIX}${PREPARING_EACH_ENTITY}`; + +const PREPARING_EACH_ENTITY_FIELD = 'preparingEachEntityField'; +const PREPARING_EACH_ENTITY_FIELD_QUEUE = `${QUEUE_PREFIX}${PREPARING_EACH_ENTITY_FIELD}`; + +const PREPARING_EACH_ENTITY_RELATIONSHIP = 'preparingEachEntityRelationship'; +const PREPARING_EACH_ENTITY_RELATIONSHIP_QUEUE = `${QUEUE_PREFIX}${PREPARING_EACH_ENTITY_RELATIONSHIP}`; + +const POST_PREPARING_EACH_ENTITY = 'postPreparingEachEntity'; +const POST_PREPARING_EACH_ENTITY_QUEUE = `${QUEUE_PREFIX}${POST_PREPARING_EACH_ENTITY}`; + +const WRITING_ENTITIES = 'writingEntities'; +const WRITING_ENTITIES_QUEUE = `${QUEUE_PREFIX}${WRITING_ENTITIES}`; + +const POST_WRITING_ENTITIES = 'postWritingEntities'; +const POST_WRITING_ENTITIES_QUEUE = `${QUEUE_PREFIX}${POST_WRITING_ENTITIES}`; + +export const CUSTOM_PRIORITIES = [ + { + priorityName: CONFIGURING_EACH_ENTITY, + queueName: CONFIGURING_EACH_ENTITY_QUEUE, + before: LOADING_ENTITIES, + skip: true, + }, + { + priorityName: LOADING_ENTITIES, + queueName: LOADING_ENTITIES_QUEUE, + before: PREPARING_EACH_ENTITY, + skip: true, + }, + { + priorityName: PREPARING_EACH_ENTITY, + queueName: PREPARING_EACH_ENTITY_QUEUE, + before: PREPARING_EACH_ENTITY_FIELD, + skip: true, + }, + { + priorityName: PREPARING_EACH_ENTITY_FIELD, + queueName: PREPARING_EACH_ENTITY_FIELD_QUEUE, + before: PREPARING_EACH_ENTITY_RELATIONSHIP, + skip: true, + }, + { + priorityName: PREPARING_EACH_ENTITY_RELATIONSHIP, + queueName: PREPARING_EACH_ENTITY_RELATIONSHIP_QUEUE, + before: POST_PREPARING_EACH_ENTITY, + skip: true, + }, + { + priorityName: POST_PREPARING_EACH_ENTITY, + queueName: POST_PREPARING_EACH_ENTITY_QUEUE, + before: DEFAULT, + skip: true, + }, + { + priorityName: WRITING_ENTITIES, + queueName: WRITING_ENTITIES_QUEUE, + before: TRANSFORM, + skip: true, + }, + { + priorityName: POST_WRITING_ENTITIES, + queueName: POST_WRITING_ENTITIES_QUEUE, + before: PRE_CONFLICTS, + skip: true, + }, +].reverse(); + +const ENTITY_QUEUES = { + CONFIGURING_EACH_ENTITY_QUEUE, + LOADING_ENTITIES_QUEUE, + PREPARING_EACH_ENTITY_QUEUE, + PREPARING_EACH_ENTITY_FIELD_QUEUE, + PREPARING_EACH_ENTITY_RELATIONSHIP_QUEUE, + POST_PREPARING_EACH_ENTITY_QUEUE, + WRITING_ENTITIES_QUEUE, + POST_WRITING_ENTITIES_QUEUE, +}; + +export const ENTITY_PRIORITY_NAMES = { + CONFIGURING_EACH_ENTITY, + LOADING_ENTITIES, + PREPARING_EACH_ENTITY, + PREPARING_EACH_ENTITY_FIELD, + PREPARING_EACH_ENTITY_RELATIONSHIP, + POST_PREPARING_EACH_ENTITY, + WRITING_ENTITIES, + POST_WRITING_ENTITIES, +}; + +export const PRIORITY_NAMES = { + ...PRIORITY_NAMES2, + ...ENTITY_PRIORITY_NAMES, +}; + +export const QUEUES = { + ...QUEUES2, + ...ENTITY_QUEUES, +}; + +export const PRIORITY_NAMES_LIST = [ + PRIORITY_NAMES.INITIALIZING, + PRIORITY_NAMES.PROMPTING, + PRIORITY_NAMES.CONFIGURING, + PRIORITY_NAMES.COMPOSING, + PRIORITY_NAMES.LOADING, + PRIORITY_NAMES.PREPARING, + CONFIGURING_EACH_ENTITY, + LOADING_ENTITIES, + PREPARING_EACH_ENTITY, + PREPARING_EACH_ENTITY_FIELD, + PREPARING_EACH_ENTITY_RELATIONSHIP, + POST_PREPARING_EACH_ENTITY, + DEFAULT, + PRIORITY_NAMES.WRITING, + WRITING_ENTITIES, + PRIORITY_NAMES.POST_WRITING, + POST_WRITING_ENTITIES, + PRIORITY_NAMES2.INSTALL, + PRIORITY_NAMES2.POST_INSTALL, + PRIORITY_NAMES2.END, +]; diff --git a/generators/base-docker/generator.mjs b/generators/base-docker/generator.mjs index 34eb2ae03264..899777f720e0 100644 --- a/generators/base-docker/generator.mjs +++ b/generators/base-docker/generator.mjs @@ -22,10 +22,10 @@ import prompts from './docker-prompts.mjs'; import BlueprintBaseGenerator from '../base/index.mjs'; import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; import { loadFromYoRc, checkDocker, checkImages, generateJwtSecret, setAppsFolderPaths } from './docker-base.mjs'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; import { applicationOptions, deploymentOptions } from '../../jdl/jhipster/index.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { dockerPlaceholderGenerator, getDockerfileContainers } from '../docker/utils.mjs'; const { OptionNames } = applicationOptions; diff --git a/generators/base/generator-base-blueprint.mjs b/generators/base/generator-base-blueprint.mjs index 52410a42d568..1d720036292e 100644 --- a/generators/base/generator-base-blueprint.mjs +++ b/generators/base/generator-base-blueprint.mjs @@ -22,7 +22,7 @@ import path from 'path'; import semver from 'semver'; import { packageJson as packagejs } from '../../lib/index.mjs'; -import generatorUtils from '../utils.cjs'; +import generatorUtils from '../utils.mjs'; import JHipsterBaseGenerator from './generator-base.mjs'; import { mergeBlueprints, parseBluePrints, loadBlueprintsFromConfiguration, normalizeBlueprintName } from '../../utils/blueprint.mjs'; diff --git a/generators/base/generator-base-private.mjs b/generators/base/generator-base-private.mjs index 8d64abcc7526..23dcf8358481 100644 --- a/generators/base/generator-base-private.mjs +++ b/generators/base/generator-base-private.mjs @@ -28,8 +28,8 @@ import https from 'https'; import { databaseTypes, buildToolTypes, fieldTypes, validations } from '../../jdl/jhipster/index.mjs'; import { packageJson as packagejs } from '../../lib/index.mjs'; -import jhipsterUtils from '../utils.cjs'; -import generatorConstants from '../generator-constants.cjs'; +import jhipsterUtils from '../utils.mjs'; +import generatorConstants from '../generator-constants.mjs'; import { stringify } from '../../utils/index.mjs'; import { fieldIsEnum } from '../../utils/field.mjs'; import databaseData from '../sql-constants.mjs'; diff --git a/generators/base/generator-base.mjs b/generators/base/generator-base.mjs index 430cdcccac15..8ec62dfe4f19 100644 --- a/generators/base/generator-base.mjs +++ b/generators/base/generator-base.mjs @@ -30,10 +30,9 @@ import { fileURLToPath } from 'url'; import jhipster7Proxy from './jhipster7-proxy.mjs'; import { packageJson as packagejs } from '../../lib/index.mjs'; -import jhipsterUtils from '../utils.cjs'; -import constants from '../generator-constants.cjs'; +import jhipsterUtils from '../utils.mjs'; import PrivateBase from './generator-base-private.mjs'; -import NeedleApi from '../needle-api.cjs'; +import NeedleApi from '../needle-api.mjs'; import generatorDefaults from '../generator-defaults.mjs'; import commonOptions from './options.mjs'; import detectLanguage from '../languages/detect-language.mjs'; @@ -58,7 +57,7 @@ import { import databaseData from '../sql-constants.mjs'; import { CUSTOM_PRIORITIES } from './priorities.mjs'; import { GENERATOR_BOOTSTRAP } from '../generator-list.mjs'; -import { NODE_VERSION } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -74,6 +73,7 @@ const { SERVER_TEST_RES_DIR, CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR, + NODE_VERSION, } = constants; const MODULES_HOOK_FILE = `${JHIPSTER_CONFIG_DIR}/modules/jhi-hooks.json`; diff --git a/generators/base/jhipster7-proxy.mjs b/generators/base/jhipster7-proxy.mjs index 557c37c636b3..86b3676470c4 100644 --- a/generators/base/jhipster7-proxy.mjs +++ b/generators/base/jhipster7-proxy.mjs @@ -1,7 +1,7 @@ /* eslint-disable no-console */ import chalk from 'chalk'; -import * as oldConstants from '../generator-constants.cjs'; +import * as oldConstants from '../generator-constants.mjs'; import * as newConstants from '../generator-constants.mjs'; const deprecatedProperties = { diff --git a/generators/base/priorities.cjs b/generators/base/priorities.cjs deleted file mode 100644 index 0df9c7565470..000000000000 --- a/generators/base/priorities.cjs +++ /dev/null @@ -1,201 +0,0 @@ -/** - * Copyright 2013-2022 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. - */ - -const PRIORITY_PREFIX = '>'; -const QUEUE_PREFIX = 'jhipster:'; - -/** Yeoman priorities */ -const INITIALIZING = 'initializing'; - -const PROMPTING = 'prompting'; - -const CONFIGURING = 'configuring'; - -const DEFAULT = 'default'; - -const WRITING = 'writing'; - -const TRANSFORM = 'transform'; - -const CONFLICTS = 'conflicts'; - -const INSTALL = 'install'; - -const END = 'end'; - -/** Custom priorities */ -const COMPOSING = 'composing'; -const COMPOSING_QUEUE = `${QUEUE_PREFIX}${COMPOSING}`; - -const LOADING = 'loading'; -const LOADING_QUEUE = `${QUEUE_PREFIX}${LOADING}`; - -const PREPARING = 'preparing'; -const PREPARING_QUEUE = `${QUEUE_PREFIX}${PREPARING}`; - -const POST_WRITING = 'postWriting'; -const POST_WRITING_QUEUE = `${QUEUE_PREFIX}${POST_WRITING}`; - -const POST_INSTALL = 'postInstall'; -const POST_INSTALL_QUEUE = `${QUEUE_PREFIX}${POST_INSTALL}`; - -/** @private */ -const PRE_CONFLICTS = 'preConflicts'; -/** @private */ -const PRE_CONFLICTS_QUEUE = `${QUEUE_PREFIX}${PRE_CONFLICTS}`; - -/** - * Custom priorities to improve jhipster workflow. - */ -const CUSTOM_PRIORITIES = [ - { - priorityName: INITIALIZING, - args: generator => generator.getArgsForPriority(INITIALIZING), - edit: true, - }, - { - priorityName: PROMPTING, - args: generator => generator.getArgsForPriority(PROMPTING), - edit: true, - }, - { - priorityName: CONFIGURING, - args: generator => generator.getArgsForPriority(CONFIGURING), - edit: true, - }, - { - priorityName: COMPOSING, - queueName: COMPOSING_QUEUE, - before: LOADING, - args: generator => generator.getArgsForPriority(COMPOSING), - }, - { - priorityName: LOADING, - queueName: LOADING_QUEUE, - before: PREPARING, - args: generator => generator.getArgsForPriority(LOADING), - }, - { - priorityName: PREPARING, - queueName: PREPARING_QUEUE, - before: DEFAULT, - args: generator => generator.getArgsForPriority(PREPARING), - }, - { - priorityName: DEFAULT, - args: generator => generator.getArgsForPriority(DEFAULT), - edit: true, - }, - { - priorityName: WRITING, - args: generator => generator.getArgsForPriority(WRITING), - edit: true, - }, - { - priorityName: POST_WRITING, - queueName: POST_WRITING_QUEUE, - before: PRE_CONFLICTS, - args: generator => generator.getArgsForPriority(POST_WRITING), - }, - { - priorityName: PRE_CONFLICTS, - queueName: PRE_CONFLICTS_QUEUE, - args: generator => generator.getArgsForPriority(PRE_CONFLICTS), - before: CONFLICTS, - }, - { - priorityName: INSTALL, - args: generator => generator.getArgsForPriority(INSTALL), - edit: true, - }, - { - priorityName: POST_INSTALL, - queueName: POST_INSTALL_QUEUE, - before: END, - args: generator => generator.getArgsForPriority(POST_INSTALL), - }, - { - priorityName: END, - args: generator => generator.getArgsForPriority(END), - edit: true, - }, -].reverse(); - -const PRIORITY_NAMES = { - INITIALIZING, - PROMPTING, - CONFIGURING, - COMPOSING, - LOADING, - PREPARING, - - DEFAULT, - WRITING, - TRANSFORM, - POST_WRITING, - PRE_CONFLICTS, - INSTALL, - POST_INSTALL, - END, -}; - -const PRIORITY_NAMES_LIST = [ - INITIALIZING, - PROMPTING, - CONFIGURING, - COMPOSING, - LOADING, - PREPARING, - - DEFAULT, - WRITING, - TRANSFORM, - POST_WRITING, - INSTALL, - POST_INSTALL, - END, -]; - -const QUEUES = { - INITIALIZING_QUEUE: INITIALIZING, - PROMPTING_QUEUE: PROMPTING, - CONFIGURING_QUEUE: CONFIGURING, - COMPOSING_QUEUE, - LOADING_QUEUE, - PREPARING_QUEUE, - - DEFAULT_QUEUE: DEFAULT, - WRITING_QUEUE: WRITING, - TRANSFORM_QUEUE: TRANSFORM, - POST_WRITING_QUEUE, - PRE_CONFLICTS_QUEUE, - INSTALL_QUEUE: INSTALL, - POST_INSTALL_QUEUE, - END_QUEUE: END, -}; - -module.exports = { - PRIORITY_PREFIX, - QUEUE_PREFIX, - - PRIORITY_NAMES, - CUSTOM_PRIORITIES, - PRIORITY_NAMES_LIST, - QUEUES, -}; diff --git a/generators/base/priorities.mjs b/generators/base/priorities.mjs index 31a2947722d8..55c051bcb14d 100644 --- a/generators/base/priorities.mjs +++ b/generators/base/priorities.mjs @@ -16,8 +16,176 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import priorities from './priorities.cjs'; -const { PRIORITY_PREFIX, QUEUE_PREFIX, PRIORITY_NAMES, PRIORITY_NAMES_LIST, QUEUES, CUSTOM_PRIORITIES } = priorities; +export const PRIORITY_PREFIX = '>'; +export const QUEUE_PREFIX = 'jhipster:'; -export { PRIORITY_PREFIX, QUEUE_PREFIX, PRIORITY_NAMES, PRIORITY_NAMES_LIST, QUEUES, CUSTOM_PRIORITIES }; +/** Yeoman priorities */ +const INITIALIZING = 'initializing'; + +const PROMPTING = 'prompting'; + +const CONFIGURING = 'configuring'; + +const DEFAULT = 'default'; + +const WRITING = 'writing'; + +const TRANSFORM = 'transform'; + +const CONFLICTS = 'conflicts'; + +const INSTALL = 'install'; + +const END = 'end'; + +/** Custom priorities */ +const COMPOSING = 'composing'; +const COMPOSING_QUEUE = `${QUEUE_PREFIX}${COMPOSING}`; + +const LOADING = 'loading'; +const LOADING_QUEUE = `${QUEUE_PREFIX}${LOADING}`; + +const PREPARING = 'preparing'; +const PREPARING_QUEUE = `${QUEUE_PREFIX}${PREPARING}`; + +const POST_WRITING = 'postWriting'; +const POST_WRITING_QUEUE = `${QUEUE_PREFIX}${POST_WRITING}`; + +const POST_INSTALL = 'postInstall'; +const POST_INSTALL_QUEUE = `${QUEUE_PREFIX}${POST_INSTALL}`; + +/** @private */ +const PRE_CONFLICTS = 'preConflicts'; +/** @private */ +const PRE_CONFLICTS_QUEUE = `${QUEUE_PREFIX}${PRE_CONFLICTS}`; + +/** + * Custom priorities to improve jhipster workflow. + */ +export const CUSTOM_PRIORITIES = [ + { + priorityName: INITIALIZING, + args: generator => generator.getArgsForPriority(INITIALIZING), + edit: true, + }, + { + priorityName: PROMPTING, + args: generator => generator.getArgsForPriority(PROMPTING), + edit: true, + }, + { + priorityName: CONFIGURING, + args: generator => generator.getArgsForPriority(CONFIGURING), + edit: true, + }, + { + priorityName: COMPOSING, + queueName: COMPOSING_QUEUE, + before: LOADING, + args: generator => generator.getArgsForPriority(COMPOSING), + }, + { + priorityName: LOADING, + queueName: LOADING_QUEUE, + before: PREPARING, + args: generator => generator.getArgsForPriority(LOADING), + }, + { + priorityName: PREPARING, + queueName: PREPARING_QUEUE, + before: DEFAULT, + args: generator => generator.getArgsForPriority(PREPARING), + }, + { + priorityName: DEFAULT, + args: generator => generator.getArgsForPriority(DEFAULT), + edit: true, + }, + { + priorityName: WRITING, + args: generator => generator.getArgsForPriority(WRITING), + edit: true, + }, + { + priorityName: POST_WRITING, + queueName: POST_WRITING_QUEUE, + before: PRE_CONFLICTS, + args: generator => generator.getArgsForPriority(POST_WRITING), + }, + { + priorityName: PRE_CONFLICTS, + queueName: PRE_CONFLICTS_QUEUE, + args: generator => generator.getArgsForPriority(PRE_CONFLICTS), + before: CONFLICTS, + }, + { + priorityName: INSTALL, + args: generator => generator.getArgsForPriority(INSTALL), + edit: true, + }, + { + priorityName: POST_INSTALL, + queueName: POST_INSTALL_QUEUE, + before: END, + args: generator => generator.getArgsForPriority(POST_INSTALL), + }, + { + priorityName: END, + args: generator => generator.getArgsForPriority(END), + edit: true, + }, +].reverse(); + +export const PRIORITY_NAMES = { + INITIALIZING, + PROMPTING, + CONFIGURING, + COMPOSING, + LOADING, + PREPARING, + + DEFAULT, + WRITING, + TRANSFORM, + POST_WRITING, + PRE_CONFLICTS, + INSTALL, + POST_INSTALL, + END, +}; + +export const PRIORITY_NAMES_LIST = [ + INITIALIZING, + PROMPTING, + CONFIGURING, + COMPOSING, + LOADING, + PREPARING, + + DEFAULT, + WRITING, + TRANSFORM, + POST_WRITING, + INSTALL, + POST_INSTALL, + END, +]; + +export const QUEUES = { + INITIALIZING_QUEUE: INITIALIZING, + PROMPTING_QUEUE: PROMPTING, + CONFIGURING_QUEUE: CONFIGURING, + COMPOSING_QUEUE, + LOADING_QUEUE, + PREPARING_QUEUE, + + DEFAULT_QUEUE: DEFAULT, + WRITING_QUEUE: WRITING, + TRANSFORM_QUEUE: TRANSFORM, + POST_WRITING_QUEUE, + PRE_CONFLICTS_QUEUE, + INSTALL_QUEUE: INSTALL, + POST_INSTALL_QUEUE, + END_QUEUE: END, +}; diff --git a/generators/bootstrap-application-base/faker.mts b/generators/bootstrap-application-base/faker.mts index b0143281b1d6..75978744c305 100644 --- a/generators/bootstrap-application-base/faker.mts +++ b/generators/bootstrap-application-base/faker.mts @@ -21,7 +21,9 @@ import { Faker } from '@faker-js/faker'; import Randexp from 'randexp'; import { languageToJavaLanguage } from '../languages/utils.mjs'; -import { stringHashCode } from '../utils.cjs'; +import utils from '../utils.mjs'; + +const { stringHashCode } = utils; class RandexpWithFaker extends Randexp { faker: Faker; diff --git a/generators/bootstrap-application-base/generator.mts b/generators/bootstrap-application-base/generator.mts index ce285d2bd281..27ceb3b9201a 100644 --- a/generators/bootstrap-application-base/generator.mts +++ b/generators/bootstrap-application-base/generator.mts @@ -24,12 +24,13 @@ import { prepareFieldForTemplates } from '../../utils/field.mjs'; import { prepareRelationshipForTemplates } from '../../utils/relationship.mjs'; import { stringify } from '../../utils/index.mjs'; import { createUserEntity } from './utils.mjs'; -import { DOCKER_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; import type { CommonClientServerApplication } from '../base-application/types.mjs'; import { GENERATOR_BOOTSTRAP, GENERATOR_COMMON, GENERATOR_PROJECT_NAME } from '../generator-list.mjs'; import { addFakerToEntity } from './faker.mjs'; import { packageJson } from '../../lib/index.mjs'; +const { DOCKER_DIR } = constants; const { upperFirst } = _; /** diff --git a/generators/bootstrap-application-server/generator.mts b/generators/bootstrap-application-server/generator.mts index 13c1d14b0b39..60b0505b7fab 100644 --- a/generators/bootstrap-application-server/generator.mts +++ b/generators/bootstrap-application-server/generator.mts @@ -20,8 +20,7 @@ import _ from 'lodash'; import BaseApplicationGenerator from '../base-application/index.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION_BASE } from '../generator-list.mjs'; -import constants from '../generator-constants.cjs'; -import { dockerContainers, javaDependencies } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; import { loadRequiredConfigIntoEntity, loadRequiredConfigDerivedProperties, @@ -38,6 +37,7 @@ import { GRADLE_VERSION } from '../gradle/constants.mjs'; const { CommonDBTypes } = fieldTypes; const { OAUTH2 } = authenticationTypes; +const { dockerContainers, javaDependencies } = constants; const { LONG: TYPE_LONG } = CommonDBTypes; diff --git a/generators/bootstrap/generator.mts b/generators/bootstrap/generator.mts index 3ac746cde4f7..207ce3d33d75 100644 --- a/generators/bootstrap/generator.mts +++ b/generators/bootstrap/generator.mts @@ -28,7 +28,7 @@ import type Environment from 'yeoman-environment'; import BaseGenerator from '../base/index.mjs'; import MultiStepTransform from './multi-step-transform/index.mjs'; import { prettierTransform, generatedAnnotationTransform } from './transforms.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { GENERATOR_UPGRADE } from '../generator-list.mjs'; import { PRIORITY_NAMES } from '../base-application/priorities.mjs'; import type { PreConflictsTaskGroup } from '../base/tasks.mjs'; diff --git a/generators/ci-cd/generator.mjs b/generators/ci-cd/generator.mjs index e4aa116eee9e..30bb83b2dab2 100644 --- a/generators/ci-cd/generator.mjs +++ b/generators/ci-cd/generator.mjs @@ -24,8 +24,8 @@ import BaseApplicationGenerator from '../base-application/index.mjs'; import generatorDefaults from '../generator-defaults.mjs'; import prompts from './prompts.mjs'; -import statistics from '../statistics.cjs'; -import constants from '../generator-constants.cjs'; +import statistics from '../statistics.mjs'; +import constants from '../generator-constants.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION, GENERATOR_CI_CD } from '../generator-list.mjs'; import { buildToolTypes } from '../../jdl/jhipster/index.mjs'; import { REACT } from '../../jdl/jhipster/client-framework-types.js'; diff --git a/generators/cleanup.mjs b/generators/cleanup.mjs index 3cfee447627f..90fcf6b9f95f 100644 --- a/generators/cleanup.mjs +++ b/generators/cleanup.mjs @@ -18,7 +18,7 @@ */ import { ANGULAR, REACT, VUE } from '../jdl/jhipster/client-framework-types.js'; -import constants from './generator-constants.cjs'; +import constants from './generator-constants.mjs'; import { languageSnakeCase, languageToJavaLanguage } from './languages/utils.mjs'; export { cleanupOldServerFiles } from './server/cleanup.mjs'; diff --git a/generators/client/entity-files.mjs b/generators/client/entity-files.mjs index e7f83d185ea9..71e0f4dc9391 100644 --- a/generators/client/entity-files.mjs +++ b/generators/client/entity-files.mjs @@ -16,9 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import utils from '../utils.cjs'; -import { CLIENT_MAIN_SRC_DIR } from '../generator-constants.mjs'; +import utils from '../utils.mjs'; +import constants from '../generator-constants.mjs'; +const { CLIENT_MAIN_SRC_DIR } = constants; const CLIENT_COMMON_TEMPLATES_DIR = 'entity/common'; async function addEnumerationFiles({ application, entity }) { diff --git a/generators/client/generator.mjs b/generators/client/generator.mjs index 4980900930e4..e2435fcfcf07 100644 --- a/generators/client/generator.mjs +++ b/generators/client/generator.mjs @@ -27,8 +27,8 @@ import { writeFiles as writeCommonFiles } from './files-common.mjs'; import { writeEnumerationFiles } from './entity-files.mjs'; -import constants from '../generator-constants.cjs'; -import statistics from '../statistics.cjs'; +import constants from '../generator-constants.mjs'; +import statistics from '../statistics.mjs'; import generatorDefaults from '../generator-defaults.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION, GENERATOR_CYPRESS, GENERATOR_COMMON, GENERATOR_CLIENT } from '../generator-list.mjs'; diff --git a/generators/client/needle-api/needle-client-angular.cjs b/generators/client/needle-api/needle-client-angular.mjs similarity index 97% rename from generators/client/needle-api/needle-client-angular.cjs rename to generators/client/needle-api/needle-client-angular.mjs index d3b11d3bddb5..f4cd1e5ae082 100644 --- a/generators/client/needle-api/needle-client-angular.cjs +++ b/generators/client/needle-api/needle-client-angular.mjs @@ -16,13 +16,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const chalk = require('chalk'); -const _ = require('lodash'); -const needleClientBase = require('./needle-client.cjs'); -const constants = require('../../generator-constants.cjs'); -const jhipsterUtils = require('../../utils.cjs'); +import chalk from 'chalk'; +import _ from 'lodash'; +import needleClientBase from './needle-client.mjs'; +import constants from '../../generator-constants.mjs'; +import jhipsterUtils from '../../utils.mjs'; -module.exports = class extends needleClientBase { +export default class extends needleClientBase { addGlobalSCSSStyle(style, comment) { const filePath = `${this.clientSrcDir}content/scss/global.scss`; this.addStyle(style, comment, filePath, 'jhipster-needle-scss-add-main'); @@ -248,4 +248,4 @@ module.exports = class extends needleClientBase { const adminModulePath = `${this.clientSrcDir}app/admin/admin-routing.module.ts`; this._addRoute(route, modulePath, moduleName, 'jhipster-needle-add-admin-route', adminModulePath, pageTitle); } -}; +} diff --git a/generators/client/needle-api/needle-client-i18n.cjs b/generators/client/needle-api/needle-client-i18n.mjs similarity index 93% rename from generators/client/needle-api/needle-client-i18n.cjs rename to generators/client/needle-api/needle-client-i18n.mjs index 3b2dc55576e0..44ace96ee4df 100644 --- a/generators/client/needle-api/needle-client-i18n.cjs +++ b/generators/client/needle-api/needle-client-i18n.mjs @@ -16,10 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const chalk = require('chalk'); -const needleClient = require('./needle-client.cjs'); +import chalk from 'chalk'; +import needleClient from './needle-client.mjs'; -module.exports = class extends needleClient { +export default class extends needleClient { addElementTranslationKey(key, value, language, webappSrcDir) { const errorMessage = ' not added as a new entity in the menu.'; this._addTranslationKey(key, value, language, errorMessage, 'jhipster-needle-menu-add-element', webappSrcDir); @@ -42,4 +42,4 @@ module.exports = class extends needleClient { this.addBlockContentToFile(rewriteFileModel, fullErrorMessage); } -}; +} diff --git a/generators/client/needle-api/needle-client-react.cjs b/generators/client/needle-api/needle-client-react.mjs similarity index 95% rename from generators/client/needle-api/needle-client-react.cjs rename to generators/client/needle-api/needle-client-react.mjs index 6a74dfd05d2b..30e2f6e49ef3 100644 --- a/generators/client/needle-api/needle-client-react.cjs +++ b/generators/client/needle-api/needle-client-react.mjs @@ -16,12 +16,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const chalk = require('chalk'); -const _ = require('lodash'); +import chalk from 'chalk'; +import _ from 'lodash'; -const needleClientBase = require('./needle-client.cjs'); +import needleClientBase from './needle-client.mjs'; -module.exports = class extends needleClientBase { +export default class extends needleClientBase { addAppSCSSStyle(style, comment) { const filePath = `${this.clientSrcDir}app/app.scss`; this.addStyle(style, comment, filePath, 'jhipster-needle-scss-add-main'); @@ -86,4 +86,4 @@ module.exports = class extends needleClientBase { ); this.addBlockContentToFile(reducerAddCombineRewriteFileModel, errorMessage(indexReducerPath)); } -}; +} diff --git a/generators/client/needle-api/needle-client-vue.cjs b/generators/client/needle-api/needle-client-vue.mjs similarity index 97% rename from generators/client/needle-api/needle-client-vue.cjs rename to generators/client/needle-api/needle-client-vue.mjs index 509dcbe86271..6709151eb058 100644 --- a/generators/client/needle-api/needle-client-vue.cjs +++ b/generators/client/needle-api/needle-client-vue.mjs @@ -16,12 +16,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const chalk = require('chalk'); -const _ = require('lodash'); -const jhipsterUtils = require('../../utils.cjs'); -const needleClientBase = require('./needle-client.cjs'); +import chalk from 'chalk'; +import _ from 'lodash'; +import jhipsterUtils from '../../utils.mjs'; +import needleClientBase from './needle-client.mjs'; -module.exports = class extends needleClientBase { +export default class extends needleClientBase { addEntityToMenu(routerName, enableTranslation, entityTranslationKeyMenu, entityTranslationValue = _.startCase(routerName)) { const errorMessage = `${chalk.yellow('Reference to ') + routerName} ${chalk.yellow('not added to menu.\n')}`; const filePath = `${this.clientSrcDir}/app/entities/entities-menu.vue`; @@ -202,4 +202,4 @@ module.exports = class extends needleClientBase { const rewriteFileModel = this.generateFileModel(filePath, 'jhipster-needle-add-entity-service-to-entities-component', entityEntry); this.addBlockContentToFile(rewriteFileModel, errorMessage); } -}; +} diff --git a/generators/client/needle-api/needle-client-webpack.cjs b/generators/client/needle-api/needle-client-webpack.mjs similarity index 92% rename from generators/client/needle-api/needle-client-webpack.cjs rename to generators/client/needle-api/needle-client-webpack.mjs index 6fac9a7ecb03..cc7a93c8ddc9 100644 --- a/generators/client/needle-api/needle-client-webpack.cjs +++ b/generators/client/needle-api/needle-client-webpack.mjs @@ -16,13 +16,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const needleClient = require('./needle-client.cjs'); -const constants = require('../../generator-constants.cjs'); +import needleClient from './needle-client.mjs'; +import constants from '../../generator-constants.mjs'; const CLIENT_WEBPACK_DIR = constants.CLIENT_WEBPACK_DIR; const SUPPORTED_CLIENT_FRAMEWORKS = constants.SUPPORTED_CLIENT_FRAMEWORKS; -module.exports = class extends needleClient { +export default class extends needleClient { _getWebpackFile(clientFramework = this.clientFramework) { return this.clientFramework === SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR ? `${CLIENT_WEBPACK_DIR}/webpack.custom.js` @@ -50,4 +50,4 @@ module.exports = class extends needleClient { rewriteFileModel.prettierAware = true; this.addBlockContentToFile(rewriteFileModel, 'Webpack config not added to JHipster app.\n'); } -}; +} diff --git a/generators/client/needle-api/needle-client.cjs b/generators/client/needle-api/needle-client.mjs similarity index 95% rename from generators/client/needle-api/needle-client.cjs rename to generators/client/needle-api/needle-client.mjs index 64666a0f5bc0..25661ab536ab 100644 --- a/generators/client/needle-api/needle-client.cjs +++ b/generators/client/needle-api/needle-client.mjs @@ -16,9 +16,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const needleBase = require('../../needle-base.cjs'); +import needleBase from '../../needle-base.mjs'; -module.exports = class extends needleBase { +export default class extends needleBase { addStyle(style, comment, filePath, needle) { const styleBlock = this._mergeStyleAndComment(style, comment); const rewriteFileModel = this.generateFileModel(filePath, needle, styleBlock); @@ -53,4 +53,4 @@ module.exports = class extends needleBase { this.addBlockContentToFile(rewriteFileModel, errorMessage); } -}; +} diff --git a/generators/client/utils.mjs b/generators/client/utils.mjs index 6752f09c10bc..e3d4f5ad9d06 100644 --- a/generators/client/utils.mjs +++ b/generators/client/utils.mjs @@ -1,4 +1,6 @@ -import { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; + +const { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR } = constants; export const replaceEntityFilePath = (data, filepath) => filepath diff --git a/generators/cloudfoundry/generator.mjs b/generators/cloudfoundry/generator.mjs index a75dfcb83220..f74f9577e480 100644 --- a/generators/cloudfoundry/generator.mjs +++ b/generators/cloudfoundry/generator.mjs @@ -24,8 +24,8 @@ import glob from 'glob'; import BaseGenerator from '../base/index.mjs'; import prompts from './prompts.mjs'; -import statistics from '../statistics.cjs'; -import constants from '../generator-constants.cjs'; +import statistics from '../statistics.mjs'; +import constants from '../generator-constants.mjs'; import { GENERATOR_CLOUDFOUNDRY } from '../generator-list.mjs'; import { cacheTypes, buildToolTypes, databaseTypes } from '../../jdl/jhipster/index.mjs'; diff --git a/generators/common/generator.mjs b/generators/common/generator.mjs index 0bf698fb3138..9226b2e2caf2 100644 --- a/generators/common/generator.mjs +++ b/generators/common/generator.mjs @@ -22,7 +22,7 @@ import _ from 'lodash'; import BaseApplicationGenerator from '../base-application/index.mjs'; import { writeFiles, prettierConfigFiles } from './files.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { packageJson } from '../../lib/index.mjs'; import { GENERATOR_COMMON, GENERATOR_BOOTSTRAP_APPLICATION, GENERATOR_GIT } from '../generator-list.mjs'; diff --git a/generators/couchbase/entity-files.mjs b/generators/couchbase/entity-files.mjs index 8acb114b8f13..ecd8fb49566a 100644 --- a/generators/couchbase/entity-files.mjs +++ b/generators/couchbase/entity-files.mjs @@ -16,9 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; import { moveToJavaEntityPackageSrcDir } from '../server/utils.mjs'; +const { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR } = constants; export const entityFiles = { dbChangelog: [ { diff --git a/generators/couchbase/files.mjs b/generators/couchbase/files.mjs index 3347510626fa..ce00fd460b84 100644 --- a/generators/couchbase/files.mjs +++ b/generators/couchbase/files.mjs @@ -16,9 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_SRC_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; import { moveToJavaPackageSrcDir, moveToJavaPackageTestDir } from '../server/utils.mjs'; +const { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_SRC_DIR } = constants; export const couchbaseFiles = { serverJavaConfig: [ { diff --git a/generators/cypress/files.mts b/generators/cypress/files.mts index 1944dd8a493c..64089c820f77 100644 --- a/generators/cypress/files.mts +++ b/generators/cypress/files.mts @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import type { WriteFileSection } from '../base/api.mjs'; import type CypressGenerator from './generator.mjs'; diff --git a/generators/cypress/generator.mts b/generators/cypress/generator.mts index 2631afcf3cc5..65f63d04224f 100644 --- a/generators/cypress/generator.mts +++ b/generators/cypress/generator.mts @@ -19,10 +19,10 @@ import { faker } from '@faker-js/faker/locale/en'; import _ from 'lodash'; -import utils from '../utils.cjs'; +import utils from '../utils.mjs'; import BaseApplicationGenerator from '../base-application/index.mjs'; import { cypressFiles, cypressEntityFiles } from './files.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { GENERATOR_CYPRESS, GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs'; import type { CypressApplication } from './types.mjs'; diff --git a/generators/cypress/generator.spec.mts b/generators/cypress/generator.spec.mts index c528352f1f19..78e4cd2d73aa 100644 --- a/generators/cypress/generator.spec.mts +++ b/generators/cypress/generator.spec.mts @@ -27,7 +27,7 @@ import { fromMatrix, extendMatrix, AuthenticationTypeMatrix } from '../../test/s import { testBlueprintSupport } from '../../test/support/tests.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; import Generator from './generator.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; const { CYPRESS } = TestFrameworkTypes; const { ANGULAR, REACT, VUE } = clientFrameworkTypes; diff --git a/generators/docker-compose/generator.mjs b/generators/docker-compose/generator.mjs index 712536b6f426..a07ffb16c94a 100644 --- a/generators/docker-compose/generator.mjs +++ b/generators/docker-compose/generator.mjs @@ -36,8 +36,9 @@ import { searchEngineTypes, } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; -import { stringHashCode } from '../utils.cjs'; +import utils from '../utils.mjs'; +const { stringHashCode } = utils; const { GATEWAY, MONOLITH } = applicationTypes; const { PROMETHEUS } = monitoringTypes; const { EUREKA } = serviceDiscoveryTypes; diff --git a/generators/docker/__test-support/service-discovery-matcher.mts b/generators/docker/__test-support/service-discovery-matcher.mts index c09ebf2e3ad5..9e7f0f0b3160 100644 --- a/generators/docker/__test-support/service-discovery-matcher.mts +++ b/generators/docker/__test-support/service-discovery-matcher.mts @@ -1,6 +1,6 @@ import type { RunResult } from 'yeoman-test'; -import constants from '../../generator-constants.cjs'; +import constants from '../../generator-constants.mjs'; import { matchWrittenConfig, matchWrittenFiles } from '../../../test/support/matcher.mjs'; const { DOCKER_DIR } = constants; diff --git a/generators/docker/files.mjs b/generators/docker/files.mjs index d64d4b78b396..c8fba0ae586e 100644 --- a/generators/docker/files.mjs +++ b/generators/docker/files.mjs @@ -1,4 +1,6 @@ -import { DOCKER_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; + +const { DOCKER_DIR } = constants; // eslint-disable-next-line import/prefer-default-export export const dockerFiles = { diff --git a/generators/docker/generator.mjs b/generators/docker/generator.mjs index a389d8a13b1b..263cf23bd1ed 100644 --- a/generators/docker/generator.mjs +++ b/generators/docker/generator.mjs @@ -23,8 +23,9 @@ import { createDockerComposeFile, createDockerExtendedServices } from '../base-d 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'; -import { stringHashCode } from '../utils.cjs'; +import utils from '../utils.mjs'; +const { stringHashCode } = utils; /** * @class * @extends {BaseApplicationGenerator} diff --git a/generators/entities/generator.mjs b/generators/entities/generator.mjs index 6e84a4148016..04dc260f9bdc 100644 --- a/generators/entities/generator.mjs +++ b/generators/entities/generator.mjs @@ -18,9 +18,10 @@ */ import BaseGenerator from '../base/index.mjs'; -import { JHIPSTER_CONFIG_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; import { GENERATOR_ENTITIES, GENERATOR_APP } from '../generator-list.mjs'; +const { JHIPSTER_CONFIG_DIR } = constants; export default class EntitiesGenerator extends BaseGenerator { constructor(args, options, features) { super(args, options, { unique: 'namespace', ...features }); diff --git a/generators/entities/generator.spec.mts b/generators/entities/generator.spec.mts index b5c5e864ba35..32fa3a943075 100644 --- a/generators/entities/generator.spec.mts +++ b/generators/entities/generator.spec.mts @@ -21,7 +21,7 @@ import lodash from 'lodash'; import { basename, dirname } from 'path'; import { fileURLToPath } from 'url'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { testBlueprintSupport } from '../../test/support/tests.mjs'; import Generator from './generator.mjs'; import { skipPrettierHelpers as helpers } from '../../test/support/helpers.mjs'; diff --git a/generators/entity/generator.mjs b/generators/entity/generator.mjs index e2b0a8a96b93..df48e9e0031b 100644 --- a/generators/entity/generator.mjs +++ b/generators/entity/generator.mjs @@ -26,7 +26,7 @@ import BaseGenerator from '../base/index.mjs'; import prompts from './prompts.mjs'; import generatorDefaults from '../generator-defaults.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { applicationTypes, clientFrameworkTypes, reservedKeywords } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_ENTITIES, GENERATOR_ENTITY } from '../generator-list.mjs'; diff --git a/generators/entity/prompts.mjs b/generators/entity/prompts.mjs index f015e4c67ef2..af3554b6e37e 100644 --- a/generators/entity/prompts.mjs +++ b/generators/entity/prompts.mjs @@ -19,7 +19,7 @@ import chalk from 'chalk'; import fs from 'fs'; import _ from 'lodash'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { reservedKeywords, databaseTypes, applicationTypes, entityOptions, fieldTypes, validations } from '../../jdl/jhipster/index.mjs'; const { isReservedPaginationWords, isReservedFieldName, isReservedTableName } = reservedKeywords; diff --git a/generators/export-jdl/generator.mts b/generators/export-jdl/generator.mts index bdde6082cfb7..0f408d6ad5fe 100644 --- a/generators/export-jdl/generator.mts +++ b/generators/export-jdl/generator.mts @@ -20,7 +20,7 @@ import chalk from 'chalk'; import BaseGenerator from '../base/index.mjs'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; import { GENERATOR_EXPORT_JDL } from '../generator-list.mjs'; import applicationOptions from '../../jdl/jhipster/application-options.js'; import JSONToJDLConverter from '../../jdl/converters/json-to-jdl-converter.js'; diff --git a/generators/gae/generator.mjs b/generators/gae/generator.mjs index 104e7d59a6a4..0cf841830b9b 100644 --- a/generators/gae/generator.mjs +++ b/generators/gae/generator.mjs @@ -26,9 +26,9 @@ import _ from 'lodash'; import BaseGenerator from '../base/index.mjs'; import { GENERATOR_GAE } from '../generator-list.mjs'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; import dockerPrompts from '../base-docker/docker-prompts.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { applicationTypes, buildToolTypes, cacheTypes, databaseTypes } from '../../jdl/jhipster/index.mjs'; const cacheProviders = cacheTypes; diff --git a/generators/generator-constants.cjs b/generators/generator-constants.cjs deleted file mode 100644 index 6661b0986da8..000000000000 --- a/generators/generator-constants.cjs +++ /dev/null @@ -1,297 +0,0 @@ -/** - * Copyright 2013-2022 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. - */ -// Version of Java -const JAVA_VERSION = '17'; -const JAVA_COMPATIBLE_VERSIONS = ['17', '18', '19']; - -/** - * Manually updated java dependencies - * @type {Record} - */ -const javaDependencies = {}; -Object.freeze(javaDependencies); - -// The version should be coherent with the one from spring-data-elasticsearch project -const ELATICSEARCH_TAG = '8.5.3'; -const ELATICSEARCH_IMAGE = 'docker.elastic.co/elasticsearch/elasticsearch'; - -/** - * Manually updated docker containers - */ -const dockerContainers = { - elasticsearchTag: ELATICSEARCH_TAG, - elasticsearchImage: ELATICSEARCH_IMAGE, - elasticsearch: `${ELATICSEARCH_IMAGE}:${ELATICSEARCH_TAG}`, -}; -Object.freeze(dockerContainers); - -// Version of Node, NPM -const NODE_VERSION = '16.17.0'; -const OPENAPI_GENERATOR_CLI_VERSION = '2.5.1'; - -// Libraries version -const JHIPSTER_DEPENDENCIES_VERSION = '8.0.0-SNAPSHOT'; -// The spring-boot version should match the one managed by https://mvnrepository.com/artifact/tech.jhipster/jhipster-dependencies/JHIPSTER_DEPENDENCIES_VERSION -const SPRING_BOOT_VERSION = '3.0.1'; -const SPRING_CLOUD_VERSION = '2022.0.0'; -const HIBERNATE_VERSION = '6.1.6.Final'; -const JACOCO_VERSION = '0.8.8'; -const JACKSON_DATABIND_NULLABLE_VERSION = '0.2.4'; - -// Kubernetes versions -const KUBERNETES_CORE_API_VERSION = 'v1'; -const KUBERNETES_BATCH_API_VERSION = 'batch/v1'; -const KUBERNETES_DEPLOYMENT_API_VERSION = 'apps/v1'; -const KUBERNETES_STATEFULSET_API_VERSION = 'apps/v1'; -const KUBERNETES_INGRESS_API_VERSION = 'networking.k8s.io/v1'; -const KUBERNETES_ISTIO_NETWORKING_API_VERSION = 'networking.istio.io/v1beta1'; -const KUBERNETES_RBAC_API_VERSION = 'rbac.authorization.k8s.io/v1'; - -// Helm versions -const HELM_KAFKA = '^0.20.1'; -const HELM_ELASTICSEARCH = '^1.32.0'; -const HELM_PROMETHEUS = '^9.2.0'; -const HELM_GRAFANA = '^4.0.0'; -const HELM_MYSQL = '^1.4.0'; -const HELM_MARIADB = '^6.12.2'; -const HELM_POSTGRESQL = '^6.5.3'; -const HELM_MOGODB_REPLICASET = '^3.10.1'; -const HELM_COUCHBASE_OPERATOR = '^2.2.1'; - -// all constants used throughout all generators - -const LOGIN_REGEX = '^(?>[a-zA-Z0-9!$&*+=?^_`{|}~.-]+@[a-zA-Z0-9-]+(?:\\\\.[a-zA-Z0-9-]+)*)|(?>[_.@A-Za-z0-9-]+)$'; -// JS does not support atomic groups -const LOGIN_REGEX_JS = '^[a-zA-Z0-9!$&*+=?^_`{|}~.-]+@[a-zA-Z0-9-]+(?:\\\\.[a-zA-Z0-9-]+)*$|^[_.@A-Za-z0-9-]+$'; - -const MAIN_DIR = 'src/main/'; -const TEST_DIR = 'src/test/'; - -// Note: this will be prepended with 'target/classes' for Maven, or with 'build/resources/main' for Gradle. -const CLIENT_DIST_DIR = 'static/'; - -// documentation constants -const JHIPSTER_DOCUMENTATION_URL = 'https://www.jhipster.tech'; -const JHIPSTER_DOCUMENTATION_ARCHIVE_PATH = '/documentation-archive/'; - -const LANGUAGES = [ - { - name: 'Albanian', - dispName: 'Shqip', - value: 'al', - dayjsLocaleId: 'sq', - localeId: 'sq', - }, - { - name: 'Arabic (Libya)', - dispName: 'العربية', - value: 'ar-ly', - rtl: true, - skipForLocale: true, - localeId: 'ar-LY', - }, - { - name: 'Armenian', - dispName: 'Հայերեն', - value: 'hy', - dayjsLocaleId: 'hy-am', - }, - { - name: 'Belarusian', - dispName: 'Беларускі', - value: 'by', - dayjsLocaleId: 'be', - localeId: 'be', - }, - { - name: 'Bengali', - dispName: 'বাংলা', - value: 'bn', - dayjsLocaleId: 'bn', - }, - { name: 'Bulgarian', dispName: 'Български', value: 'bg' }, - { - name: 'Catalan', - dispName: 'Català', - value: 'ca', - }, - { - name: 'Chinese (Simplified)', - dispName: '中文(简体)', - value: 'zh-cn', - localeId: 'zh-Hans', - }, - { - name: 'Chinese (Traditional)', - dispName: '繁體中文', - value: 'zh-tw', - localeId: 'zh-Hant', - }, - { name: 'Croatian', dispName: 'Hrvatski', value: 'hr' }, - { name: 'Czech', dispName: 'Český', value: 'cs' }, - { name: 'Danish', dispName: 'Dansk', value: 'da' }, - { name: 'Dutch', dispName: 'Nederlands', value: 'nl' }, - { name: 'English', dispName: 'English', value: 'en' }, - { name: 'Estonian', dispName: 'Eesti', value: 'et' }, - { - name: 'Farsi', - dispName: 'فارسی', - value: 'fa', - rtl: true, - }, - { name: 'Finnish', dispName: 'Suomi', value: 'fi' }, - { name: 'French', dispName: 'Français', value: 'fr' }, - { name: 'Galician', dispName: 'Galego', value: 'gl' }, - { name: 'German', dispName: 'Deutsch', value: 'de' }, - { name: 'Greek', dispName: 'Ελληνικά', value: 'el' }, - { name: 'Hindi', dispName: 'हिंदी', value: 'hi' }, - { name: 'Hungarian', dispName: 'Magyar', value: 'hu' }, - { name: 'Indonesian', dispName: 'Bahasa Indonesia', value: 'id' }, - { name: 'Italian', dispName: 'Italiano', value: 'it' }, - { name: 'Japanese', dispName: '日本語', value: 'ja' }, - { name: 'Korean', dispName: '한국어', value: 'ko' }, - { name: 'Marathi', dispName: 'मराठी', value: 'mr' }, - { name: 'Myanmar', dispName: 'မြန်မာ', value: 'my' }, - { name: 'Polish', dispName: 'Polski', value: 'pl' }, - { - name: 'Portuguese (Brazilian)', - dispName: 'Português (Brasil)', - value: 'pt-br', - localeId: 'pt', - }, - { - name: 'Portuguese', - dispName: 'Português', - value: 'pt-pt', - localeId: 'pt-PT', - dayjsLocaleId: 'pt', - }, - { - name: 'Punjabi', - dispName: 'ਪੰਜਾਬੀ', - value: 'pa', - dayjsLocaleId: 'pa-in', - }, - { name: 'Romanian', dispName: 'Română', value: 'ro' }, - { name: 'Russian', dispName: 'Русский', value: 'ru' }, - { name: 'Slovak', dispName: 'Slovenský', value: 'sk' }, - { name: 'Serbian', dispName: 'Srpski', value: 'sr' }, - { name: 'Sinhala', dispName: 'සිංහල', value: 'si' }, - { name: 'Spanish', dispName: 'Español', value: 'es' }, - { name: 'Swedish', dispName: 'Svenska', value: 'sv' }, - { name: 'Turkish', dispName: 'Türkçe', value: 'tr' }, - { name: 'Tamil', dispName: 'தமிழ்', value: 'ta' }, - { name: 'Telugu', dispName: 'తెలుగు', value: 'te' }, - { name: 'Thai', dispName: 'ไทย', value: 'th' }, - { - name: 'Ukrainian', - dispName: 'Українська', - value: 'ua', - localeId: 'uk', - dayjsLocaleId: 'uk', - }, - { - name: 'Uzbek (Cyrillic)', - dispName: 'Ўзбекча', - value: 'uz-Cyrl-uz', - localeId: 'uz-Cyrl', - dayjsLocaleId: 'uz', - }, - { - name: 'Uzbek (Latin)', - dispName: 'O`zbekcha', - value: 'uz-Latn-uz', - localeId: 'uz-Latn', - dayjsLocaleId: 'uz-latn', - }, - { name: 'Vietnamese', dispName: 'Tiếng Việt', value: 'vi' }, -]; - -const constants = { - GENERATOR_JHIPSTER: 'generator-jhipster', - JHIPSTER_CONFIG_DIR: '.jhipster', - DOCKER_DIR: `${MAIN_DIR}docker/`, - LINE_LENGTH: 180, - LANGUAGES, - - MAIN_DIR, - TEST_DIR, - - LOGIN_REGEX, - LOGIN_REGEX_JS, - // supported client frameworks - SUPPORTED_CLIENT_FRAMEWORKS: { ANGULAR: 'angular', REACT: 'react', VUE: 'vue' }, - - CLIENT_MAIN_SRC_DIR: `${MAIN_DIR}webapp/`, - CLIENT_TEST_SRC_DIR: `${TEST_DIR}javascript/`, - CLIENT_WEBPACK_DIR: 'webpack/', - CLIENT_DIST_DIR, - ANGULAR_DIR: `${MAIN_DIR}webapp/app/`, - REACT_DIR: `${MAIN_DIR}webapp/app/`, - VUE_DIR: `${MAIN_DIR}webapp/app/`, - - SERVER_MAIN_SRC_DIR: `${MAIN_DIR}java/`, - SERVER_MAIN_RES_DIR: `${MAIN_DIR}resources/`, - SERVER_TEST_SRC_DIR: `${TEST_DIR}java/`, - SERVER_TEST_RES_DIR: `${TEST_DIR}resources/`, - PRETTIER_EXTENSIONS: 'md,json,yml,html,cjs,mjs,js,ts,tsx,css,scss,vue,svelte,java', - - JHIPSTER_DOCUMENTATION_URL, - JHIPSTER_DOCUMENTATION_ARCHIVE_PATH, - - JAVA_VERSION, - JAVA_COMPATIBLE_VERSIONS, - - // NPM - NODE_VERSION, - OPENAPI_GENERATOR_CLI_VERSION, - - // Libraries - JHIPSTER_DEPENDENCIES_VERSION, - SPRING_BOOT_VERSION, - SPRING_CLOUD_VERSION, - HIBERNATE_VERSION, - JACOCO_VERSION, - JACKSON_DATABIND_NULLABLE_VERSION, - - // Kubernetes - KUBERNETES_CORE_API_VERSION, - KUBERNETES_BATCH_API_VERSION, - KUBERNETES_DEPLOYMENT_API_VERSION, - KUBERNETES_STATEFULSET_API_VERSION, - KUBERNETES_INGRESS_API_VERSION, - KUBERNETES_ISTIO_NETWORKING_API_VERSION, - KUBERNETES_RBAC_API_VERSION, - - // Helm - HELM_KAFKA, - HELM_ELASTICSEARCH, - HELM_PROMETHEUS, - HELM_GRAFANA, - HELM_MYSQL, - HELM_MARIADB, - HELM_POSTGRESQL, - HELM_MOGODB_REPLICASET, - HELM_COUCHBASE_OPERATOR, - - javaDependencies, - dockerContainers, -}; - -module.exports = constants; diff --git a/generators/generator-constants.mjs b/generators/generator-constants.mjs index 422fc5c22034..fcc2c20e7bb9 100644 --- a/generators/generator-constants.mjs +++ b/generators/generator-constants.mjs @@ -16,21 +16,281 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import constants from './generator-constants.cjs'; +// Version of Java +const JAVA_VERSION = '17'; +const JAVA_COMPATIBLE_VERSIONS = ['17', '18', '19']; -export const { - GENERATOR_JHIPSTER, - JHIPSTER_CONFIG_DIR, +/** + * Manually updated java dependencies + * @type {Record} + */ +const javaDependencies = {}; +Object.freeze(javaDependencies); + +// The version should be coherent with the one from spring-data-elasticsearch project +const ELATICSEARCH_TAG = '8.5.3'; +const ELATICSEARCH_IMAGE = 'docker.elastic.co/elasticsearch/elasticsearch'; + +/** + * Manually updated docker containers + */ +const dockerContainers = { + elasticsearchTag: ELATICSEARCH_TAG, + elasticsearchImage: ELATICSEARCH_IMAGE, + elasticsearch: `${ELATICSEARCH_IMAGE}:${ELATICSEARCH_TAG}`, +}; +Object.freeze(dockerContainers); + +// Version of Node, NPM +const NODE_VERSION = '16.17.0'; +const OPENAPI_GENERATOR_CLI_VERSION = '2.5.1'; + +// Libraries version +const JHIPSTER_DEPENDENCIES_VERSION = '8.0.0-SNAPSHOT'; +// The spring-boot version should match the one managed by https://mvnrepository.com/artifact/tech.jhipster/jhipster-dependencies/JHIPSTER_DEPENDENCIES_VERSION +const SPRING_BOOT_VERSION = '3.0.1'; +const SPRING_CLOUD_VERSION = '2022.0.0'; +const HIBERNATE_VERSION = '6.1.6.Final'; +const JACOCO_VERSION = '0.8.8'; +const JACKSON_DATABIND_NULLABLE_VERSION = '0.2.4'; + +// Kubernetes versions +const KUBERNETES_CORE_API_VERSION = 'v1'; +const KUBERNETES_BATCH_API_VERSION = 'batch/v1'; +const KUBERNETES_DEPLOYMENT_API_VERSION = 'apps/v1'; +const KUBERNETES_STATEFULSET_API_VERSION = 'apps/v1'; +const KUBERNETES_INGRESS_API_VERSION = 'networking.k8s.io/v1'; +const KUBERNETES_ISTIO_NETWORKING_API_VERSION = 'networking.istio.io/v1beta1'; +const KUBERNETES_RBAC_API_VERSION = 'rbac.authorization.k8s.io/v1'; + +// Helm versions +const HELM_KAFKA = '^0.20.1'; +const HELM_ELASTICSEARCH = '^1.32.0'; +const HELM_PROMETHEUS = '^9.2.0'; +const HELM_GRAFANA = '^4.0.0'; +const HELM_MYSQL = '^1.4.0'; +const HELM_MARIADB = '^6.12.2'; +const HELM_POSTGRESQL = '^6.5.3'; +const HELM_MOGODB_REPLICASET = '^3.10.1'; +const HELM_COUCHBASE_OPERATOR = '^2.2.1'; + +// all constants used throughout all generators + +const LOGIN_REGEX = '^(?>[a-zA-Z0-9!$&*+=?^_`{|}~.-]+@[a-zA-Z0-9-]+(?:\\\\.[a-zA-Z0-9-]+)*)|(?>[_.@A-Za-z0-9-]+)$'; +// JS does not support atomic groups +const LOGIN_REGEX_JS = '^[a-zA-Z0-9!$&*+=?^_`{|}~.-]+@[a-zA-Z0-9-]+(?:\\\\.[a-zA-Z0-9-]+)*$|^[_.@A-Za-z0-9-]+$'; + +const MAIN_DIR = 'src/main/'; +const TEST_DIR = 'src/test/'; + +// Note: this will be prepended with 'target/classes' for Maven, or with 'build/resources/main' for Gradle. +const CLIENT_DIST_DIR = 'static/'; + +// documentation constants +const JHIPSTER_DOCUMENTATION_URL = 'https://www.jhipster.tech'; +const JHIPSTER_DOCUMENTATION_ARCHIVE_PATH = '/documentation-archive/'; + +const LANGUAGES = [ + { + name: 'Albanian', + dispName: 'Shqip', + value: 'al', + dayjsLocaleId: 'sq', + localeId: 'sq', + }, + { + name: 'Arabic (Libya)', + dispName: 'العربية', + value: 'ar-ly', + rtl: true, + skipForLocale: true, + localeId: 'ar-LY', + }, + { + name: 'Armenian', + dispName: 'Հայերեն', + value: 'hy', + dayjsLocaleId: 'hy-am', + }, + { + name: 'Belarusian', + dispName: 'Беларускі', + value: 'by', + dayjsLocaleId: 'be', + localeId: 'be', + }, + { + name: 'Bengali', + dispName: 'বাংলা', + value: 'bn', + dayjsLocaleId: 'bn', + }, + { name: 'Bulgarian', dispName: 'Български', value: 'bg' }, + { + name: 'Catalan', + dispName: 'Català', + value: 'ca', + }, + { + name: 'Chinese (Simplified)', + dispName: '中文(简体)', + value: 'zh-cn', + localeId: 'zh-Hans', + }, + { + name: 'Chinese (Traditional)', + dispName: '繁體中文', + value: 'zh-tw', + localeId: 'zh-Hant', + }, + { name: 'Croatian', dispName: 'Hrvatski', value: 'hr' }, + { name: 'Czech', dispName: 'Český', value: 'cs' }, + { name: 'Danish', dispName: 'Dansk', value: 'da' }, + { name: 'Dutch', dispName: 'Nederlands', value: 'nl' }, + { name: 'English', dispName: 'English', value: 'en' }, + { name: 'Estonian', dispName: 'Eesti', value: 'et' }, + { + name: 'Farsi', + dispName: 'فارسی', + value: 'fa', + rtl: true, + }, + { name: 'Finnish', dispName: 'Suomi', value: 'fi' }, + { name: 'French', dispName: 'Français', value: 'fr' }, + { name: 'Galician', dispName: 'Galego', value: 'gl' }, + { name: 'German', dispName: 'Deutsch', value: 'de' }, + { name: 'Greek', dispName: 'Ελληνικά', value: 'el' }, + { name: 'Hindi', dispName: 'हिंदी', value: 'hi' }, + { name: 'Hungarian', dispName: 'Magyar', value: 'hu' }, + { name: 'Indonesian', dispName: 'Bahasa Indonesia', value: 'id' }, + { name: 'Italian', dispName: 'Italiano', value: 'it' }, + { name: 'Japanese', dispName: '日本語', value: 'ja' }, + { name: 'Korean', dispName: '한국어', value: 'ko' }, + { name: 'Marathi', dispName: 'मराठी', value: 'mr' }, + { name: 'Myanmar', dispName: 'မြန်မာ', value: 'my' }, + { name: 'Polish', dispName: 'Polski', value: 'pl' }, + { + name: 'Portuguese (Brazilian)', + dispName: 'Português (Brasil)', + value: 'pt-br', + localeId: 'pt', + }, + { + name: 'Portuguese', + dispName: 'Português', + value: 'pt-pt', + localeId: 'pt-PT', + dayjsLocaleId: 'pt', + }, + { + name: 'Punjabi', + dispName: 'ਪੰਜਾਬੀ', + value: 'pa', + dayjsLocaleId: 'pa-in', + }, + { name: 'Romanian', dispName: 'Română', value: 'ro' }, + { name: 'Russian', dispName: 'Русский', value: 'ru' }, + { name: 'Slovak', dispName: 'Slovenský', value: 'sk' }, + { name: 'Serbian', dispName: 'Srpski', value: 'sr' }, + { name: 'Sinhala', dispName: 'සිංහල', value: 'si' }, + { name: 'Spanish', dispName: 'Español', value: 'es' }, + { name: 'Swedish', dispName: 'Svenska', value: 'sv' }, + { name: 'Turkish', dispName: 'Türkçe', value: 'tr' }, + { name: 'Tamil', dispName: 'தமிழ்', value: 'ta' }, + { name: 'Telugu', dispName: 'తెలుగు', value: 'te' }, + { name: 'Thai', dispName: 'ไทย', value: 'th' }, + { + name: 'Ukrainian', + dispName: 'Українська', + value: 'ua', + localeId: 'uk', + dayjsLocaleId: 'uk', + }, + { + name: 'Uzbek (Cyrillic)', + dispName: 'Ўзбекча', + value: 'uz-Cyrl-uz', + localeId: 'uz-Cyrl', + dayjsLocaleId: 'uz', + }, + { + name: 'Uzbek (Latin)', + dispName: 'O`zbekcha', + value: 'uz-Latn-uz', + localeId: 'uz-Latn', + dayjsLocaleId: 'uz-latn', + }, + { name: 'Vietnamese', dispName: 'Tiếng Việt', value: 'vi' }, +]; + +const constants = { + GENERATOR_JHIPSTER: 'generator-jhipster', + JHIPSTER_CONFIG_DIR: '.jhipster', + DOCKER_DIR: `${MAIN_DIR}docker/`, + LINE_LENGTH: 180, + LANGUAGES, + + MAIN_DIR, + TEST_DIR, + + LOGIN_REGEX, + LOGIN_REGEX_JS, + // supported client frameworks + SUPPORTED_CLIENT_FRAMEWORKS: { ANGULAR: 'angular', REACT: 'react', VUE: 'vue' }, + + CLIENT_MAIN_SRC_DIR: `${MAIN_DIR}webapp/`, + CLIENT_TEST_SRC_DIR: `${TEST_DIR}javascript/`, + CLIENT_WEBPACK_DIR: 'webpack/', + CLIENT_DIST_DIR, + ANGULAR_DIR: `${MAIN_DIR}webapp/app/`, + REACT_DIR: `${MAIN_DIR}webapp/app/`, + VUE_DIR: `${MAIN_DIR}webapp/app/`, + + SERVER_MAIN_SRC_DIR: `${MAIN_DIR}java/`, + SERVER_MAIN_RES_DIR: `${MAIN_DIR}resources/`, + SERVER_TEST_SRC_DIR: `${TEST_DIR}java/`, + SERVER_TEST_RES_DIR: `${TEST_DIR}resources/`, + PRETTIER_EXTENSIONS: 'md,json,yml,html,cjs,mjs,js,ts,tsx,css,scss,vue,svelte,java', + + JHIPSTER_DOCUMENTATION_URL, + JHIPSTER_DOCUMENTATION_ARCHIVE_PATH, + + JAVA_VERSION, + JAVA_COMPATIBLE_VERSIONS, + + // NPM NODE_VERSION, + OPENAPI_GENERATOR_CLI_VERSION, + + // Libraries + JHIPSTER_DEPENDENCIES_VERSION, + SPRING_BOOT_VERSION, + SPRING_CLOUD_VERSION, + HIBERNATE_VERSION, + JACOCO_VERSION, + JACKSON_DATABIND_NULLABLE_VERSION, + + // Kubernetes + KUBERNETES_CORE_API_VERSION, + KUBERNETES_BATCH_API_VERSION, + KUBERNETES_DEPLOYMENT_API_VERSION, + KUBERNETES_STATEFULSET_API_VERSION, + KUBERNETES_INGRESS_API_VERSION, + KUBERNETES_ISTIO_NETWORKING_API_VERSION, + KUBERNETES_RBAC_API_VERSION, - SERVER_MAIN_SRC_DIR, - SERVER_MAIN_RES_DIR, - SERVER_TEST_SRC_DIR, - SERVER_TEST_RES_DIR, - CLIENT_MAIN_SRC_DIR, - CLIENT_TEST_SRC_DIR, - DOCKER_DIR, + // Helm + HELM_KAFKA, + HELM_ELASTICSEARCH, + HELM_PROMETHEUS, + HELM_GRAFANA, + HELM_MYSQL, + HELM_MARIADB, + HELM_POSTGRESQL, + HELM_MOGODB_REPLICASET, + HELM_COUCHBASE_OPERATOR, javaDependencies, dockerContainers, -} = constants; +}; +export default constants; diff --git a/generators/gradle/generator.spec.mjs b/generators/gradle/generator.spec.mjs index 96538b7941b4..35045fbae814 100644 --- a/generators/gradle/generator.spec.mjs +++ b/generators/gradle/generator.spec.mjs @@ -22,9 +22,10 @@ import { fileURLToPath } from 'url'; import { testBlueprintSupport } from '../../test/support/tests.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; -import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; import { GENERATOR_GRADLE } from '../generator-list.mjs'; +const { GENERATOR_JHIPSTER } = constants; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); diff --git a/generators/heroku/generator.mjs b/generators/heroku/generator.mjs index c7c2f6ad75e6..77e104471998 100644 --- a/generators/heroku/generator.mjs +++ b/generators/heroku/generator.mjs @@ -27,8 +27,8 @@ import glob from 'glob'; import BaseGenerator from '../base/index.mjs'; -import statistics from '../statistics.cjs'; -import constants from '../generator-constants.cjs'; +import statistics from '../statistics.mjs'; +import constants from '../generator-constants.mjs'; import { GENERATOR_HEROKU } from '../generator-list.mjs'; import { authenticationTypes, diff --git a/generators/init/generator.spec.mts b/generators/init/generator.spec.mts index 206fbda37cf0..e9616fe9db5b 100644 --- a/generators/init/generator.spec.mts +++ b/generators/init/generator.spec.mts @@ -23,9 +23,10 @@ import { fileURLToPath } from 'url'; import { basicTests, testBlueprintSupport } from '../../test/support/tests.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; import { defaultConfig, requiredConfig } from './config.mjs'; -import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; import { GENERATOR_INIT } from '../generator-list.mjs'; +const { GENERATOR_JHIPSTER } = constants; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); diff --git a/generators/kafka/files.mjs b/generators/kafka/files.mjs index e08c1c9ff3c2..e62699b137d5 100644 --- a/generators/kafka/files.mjs +++ b/generators/kafka/files.mjs @@ -16,9 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { SERVER_MAIN_SRC_DIR, SERVER_TEST_SRC_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; import { moveToJavaPackageSrcDir, moveToJavaPackageTestDir } from '../server/utils.mjs'; +const { SERVER_MAIN_SRC_DIR, SERVER_TEST_SRC_DIR } = constants; /** * @type {import('../base/api.mjs').WriteFileSection} * The default is to use a file path string. It implies use of the template method. diff --git a/generators/kubernetes-helm/generator.mjs b/generators/kubernetes-helm/generator.mjs index ac4a95f0d9d9..5d31fb6c7893 100644 --- a/generators/kubernetes-helm/generator.mjs +++ b/generators/kubernetes-helm/generator.mjs @@ -35,7 +35,7 @@ import { setupHelmConstants, derivedKubernetesPlatformProperties, } from '../kubernetes/kubernetes-base.mjs'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; import { messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; const { KAFKA } = messageBrokerTypes; diff --git a/generators/kubernetes-knative/generator.mjs b/generators/kubernetes-knative/generator.mjs index 654698a5669d..cfd6a562f334 100644 --- a/generators/kubernetes-knative/generator.mjs +++ b/generators/kubernetes-knative/generator.mjs @@ -36,7 +36,7 @@ import { setupHelmConstants, derivedKubernetesPlatformProperties, } from '../kubernetes/kubernetes-base.mjs'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; import { kubernetesPlatformTypes, buildToolTypes, messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; const { GeneratorTypes } = kubernetesPlatformTypes; diff --git a/generators/kubernetes/generator.mjs b/generators/kubernetes/generator.mjs index 66b1ccf0434d..82898210ed45 100644 --- a/generators/kubernetes/generator.mjs +++ b/generators/kubernetes/generator.mjs @@ -26,7 +26,7 @@ import prompts from './prompts.mjs'; import { writeFiles } from './files.mjs'; import { buildToolTypes, messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_KUBERNETES } from '../generator-list.mjs'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; import { checkImages, generateJwtSecret, configureImageNames, setAppsFolderPaths } from '../base-docker/docker-base.mjs'; import { diff --git a/generators/kubernetes/kubernetes-base.mjs b/generators/kubernetes/kubernetes-base.mjs index 5bac96a7be53..d565ce448b7d 100644 --- a/generators/kubernetes/kubernetes-base.mjs +++ b/generators/kubernetes/kubernetes-base.mjs @@ -23,7 +23,7 @@ import chalk from 'chalk'; import crypto from 'crypto'; import { defaultKubernetesConfig } from './kubernetes-constants.mjs'; import { loadFromYoRc } from '../base-docker/docker-base.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { applicationTypes, kubernetesPlatformTypes } from '../../jdl/jhipster/index.mjs'; const { MICROSERVICE } = applicationTypes; diff --git a/generators/languages/detect-language.mjs b/generators/languages/detect-language.mjs index 28ed8c0e6051..aefde2c57e92 100644 --- a/generators/languages/detect-language.mjs +++ b/generators/languages/detect-language.mjs @@ -18,7 +18,7 @@ */ import osLocale from 'os-locale'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; const { LANGUAGES } = constants; diff --git a/generators/languages/entity-files.mjs b/generators/languages/entity-files.mjs index b589545177b1..bb1756b4e787 100644 --- a/generators/languages/entity-files.mjs +++ b/generators/languages/entity-files.mjs @@ -17,7 +17,7 @@ * limitations under the License. */ import _ from 'lodash'; -import utils from '../utils.cjs'; +import utils from '../utils.mjs'; const { startCase } = _; diff --git a/generators/languages/files.mjs b/generators/languages/files.mjs index f322e3f4485b..fe449a281d99 100644 --- a/generators/languages/files.mjs +++ b/generators/languages/files.mjs @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; const { CLIENT_MAIN_SRC_DIR } = constants; diff --git a/generators/languages/generator.mjs b/generators/languages/generator.mjs index b90f5d5a187f..454bfba05f52 100644 --- a/generators/languages/generator.mjs +++ b/generators/languages/generator.mjs @@ -21,19 +21,19 @@ import chalk from 'chalk'; import _ from 'lodash'; import BaseApplicationGenerator from '../base-application/index.mjs'; - +import constants from '../generator-constants.mjs'; import { askForLanguages, askI18n } from './prompts.mjs'; -import statistics from '../statistics.cjs'; -import { SERVER_TEST_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_RES_DIR } from '../generator-constants.mjs'; +import statistics from '../statistics.mjs'; import generatorDefaults from '../generator-defaults.mjs'; import { GENERATOR_LANGUAGES, GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs'; import { clientI18nFiles } from './files.mjs'; import { writeEntityFiles } from './entity-files.mjs'; import { languageToJavaLanguage } from './utils.mjs'; -import jhipsterUtils from '../utils.cjs'; +import jhipsterUtils from '../utils.mjs'; import TranslationData from './translation-data.mjs'; +const { SERVER_TEST_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_RES_DIR } = constants; const { translationDefaultConfig } = generatorDefaults; /** diff --git a/generators/languages/languages.spec.mjs b/generators/languages/languages.spec.mjs index b80e1f880736..abe67c35d361 100644 --- a/generators/languages/languages.spec.mjs +++ b/generators/languages/languages.spec.mjs @@ -3,7 +3,7 @@ import helpers from 'yeoman-test'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import EnvironmentBuilder from '../../cli/environment-builder.mjs'; const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; diff --git a/generators/liquibase-changelogs/files.mjs b/generators/liquibase-changelogs/files.mjs index 4faa987041ee..d44705eda790 100644 --- a/generators/liquibase-changelogs/files.mjs +++ b/generators/liquibase-changelogs/files.mjs @@ -16,7 +16,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; + +const { SERVER_MAIN_RES_DIR } = constants; export const addEntityFiles = { dbChangelog: [ diff --git a/generators/liquibase-changelogs/incremental-liquibase.spec.mts b/generators/liquibase-changelogs/incremental-liquibase.spec.mts index 57d49e631fee..fc42a8d5f3cb 100644 --- a/generators/liquibase-changelogs/incremental-liquibase.spec.mts +++ b/generators/liquibase-changelogs/incremental-liquibase.spec.mts @@ -4,7 +4,7 @@ import { existsSync, mkdirSync, writeFileSync } from 'fs'; import { fileURLToPath } from 'url'; import { skipPrettierHelpers as helpers } from '../../test/support/helpers.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { createImporterFromContent } from '../../jdl/jdl-importer.js'; const __filename = fileURLToPath(import.meta.url); diff --git a/generators/liquibase/files.mts b/generators/liquibase/files.mts index 3a7bde3dde63..11907c636568 100644 --- a/generators/liquibase/files.mts +++ b/generators/liquibase/files.mts @@ -19,9 +19,11 @@ import type { WriteFileSection } from '../base/api.mjs'; import type LiquibaseGenerator from './generator.mjs'; import type { LiquibaseApplication, SpringBootApplication } from '../server/types.mjs'; -import { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; import { moveToJavaPackageSrcDir } from '../server/utils.mjs'; +const { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR } = constants; + // eslint-disable-next-line import/prefer-default-export export const liquibaseFiles: WriteFileSection = { liquibase: [ diff --git a/generators/liquibase/generator.mts b/generators/liquibase/generator.mts index 1b78c7ad673a..0eb218e57201 100644 --- a/generators/liquibase/generator.mts +++ b/generators/liquibase/generator.mts @@ -21,7 +21,7 @@ import fs from 'fs'; import BaseApplication from '../base-application/index.mjs'; import type { DefaultTaskGroup } from '../base-application/tasks.mjs'; import type { LiquibaseApplication, SpringBootApplication } from '../server/types.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { GENERATOR_LIQUIBASE, GENERATOR_LIQUIBASE_CHANGELOGS, GENERATOR_BOOTSTRAP_APPLICATION_SERVER } from '../generator-list.mjs'; import { liquibaseFiles } from './files.mjs'; diff --git a/generators/maven/generator.spec.mjs b/generators/maven/generator.spec.mjs index 6306cd5646d3..c6d30474fe22 100644 --- a/generators/maven/generator.spec.mjs +++ b/generators/maven/generator.spec.mjs @@ -22,9 +22,10 @@ import { fileURLToPath } from 'url'; import { testBlueprintSupport } from '../../test/support/tests.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; -import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; import { GENERATOR_MAVEN } from '../generator-list.mjs'; +const { GENERATOR_JHIPSTER } = constants; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); diff --git a/generators/needle-api.cjs b/generators/needle-api.mjs similarity index 59% rename from generators/needle-api.cjs rename to generators/needle-api.mjs index 073473aaf812..b87082fe4509 100644 --- a/generators/needle-api.cjs +++ b/generators/needle-api.mjs @@ -16,20 +16,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const Base = require('./needle-base.cjs'); -const Client = require('./client/needle-api/needle-client.cjs'); -const ClientAngular = require('./client/needle-api/needle-client-angular.cjs'); -const ClientReact = require('./client/needle-api/needle-client-react.cjs'); -const ClientVue = require('./client/needle-api/needle-client-vue.cjs'); -const ClientWebpack = require('./client/needle-api/needle-client-webpack.cjs'); -const ClientI18n = require('./client/needle-api/needle-client-i18n.cjs'); -const ServerMaven = require('./server/needle-api/needle-server-maven.cjs'); -const ServerGradle = require('./server/needle-api/needle-server-gradle.cjs'); -const ServerCache = require('./server/needle-api/needle-server-cache.cjs'); -const ServerLiquibase = require('./server/needle-api/needle-server-liquibase.cjs'); -const ServerLog = require('./server/needle-api/needle-server-logback-spring.cjs'); +import Base from './needle-base.mjs'; +import Client from './client/needle-api/needle-client.mjs'; +import ClientAngular from './client/needle-api/needle-client-angular.mjs'; +import ClientReact from './client/needle-api/needle-client-react.mjs'; +import ClientVue from './client/needle-api/needle-client-vue.mjs'; +import ClientWebpack from './client/needle-api/needle-client-webpack.mjs'; +import ClientI18n from './client/needle-api/needle-client-i18n.mjs'; +import ServerMaven from './server/needle-api/needle-server-maven.mjs'; +import ServerGradle from './server/needle-api/needle-server-gradle.mjs'; +import ServerCache from './server/needle-api/needle-server-cache.mjs'; +import ServerLiquibase from './server/needle-api/needle-server-liquibase.mjs'; +import ServerLog from './server/needle-api/needle-server-logback-spring.mjs'; -module.exports = class NeedleApi { +export default class NeedleApi { constructor(generator) { this.base = new Base(generator); this.client = new Client(generator); @@ -44,4 +44,4 @@ module.exports = class NeedleApi { this.serverGradle = new ServerGradle(generator); this.serverLog = new ServerLog(generator); } -}; +} diff --git a/generators/needle-base.cjs b/generators/needle-base.mjs similarity index 94% rename from generators/needle-base.cjs rename to generators/needle-base.mjs index 8ff7f7fd7912..8e44ec9d3973 100644 --- a/generators/needle-base.cjs +++ b/generators/needle-base.mjs @@ -16,10 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const chalk = require('chalk'); -const jhipsterUtils = require('./utils.cjs'); +import chalk from 'chalk'; +import jhipsterUtils from './utils.mjs'; -module.exports = class { +export default class { constructor(generator) { this.generator = generator; } @@ -60,4 +60,4 @@ module.exports = class { splicable: content, }; } -}; +} diff --git a/generators/openapi-client/files.mjs b/generators/openapi-client/files.mjs index 218be9b26361..5a27460400ed 100644 --- a/generators/openapi-client/files.mjs +++ b/generators/openapi-client/files.mjs @@ -20,7 +20,7 @@ import path from 'path'; import _ from 'lodash'; import chalk from 'chalk'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { applicationOptions, buildToolTypes, applicationTypes, authenticationTypes } from '../../jdl/jhipster/index.mjs'; const { OptionNames } = applicationOptions; diff --git a/generators/openshift/generator.mjs b/generators/openshift/generator.mjs index fdc4fa181899..f21b5000f81a 100644 --- a/generators/openshift/generator.mjs +++ b/generators/openshift/generator.mjs @@ -26,7 +26,7 @@ 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 { setupKubernetesConstants } from '../kubernetes/kubernetes-base.mjs'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; import { applicationTypes, diff --git a/generators/page/files-vue.mjs b/generators/page/files-vue.mjs index 8b7b8f421036..9b600d0c3b00 100644 --- a/generators/page/files-vue.mjs +++ b/generators/page/files-vue.mjs @@ -16,8 +16,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import constants from '../generator-constants.cjs'; -import utils from '../utils.cjs'; +import constants from '../generator-constants.mjs'; +import utils from '../utils.mjs'; /* Constants use throughout */ const CLIENT_TEST_SRC_DIR = constants.CLIENT_TEST_SRC_DIR; diff --git a/generators/react/generator.spec.mts b/generators/react/generator.spec.mts index 08f7564f05e8..7034e2305615 100644 --- a/generators/react/generator.spec.mts +++ b/generators/react/generator.spec.mts @@ -9,7 +9,7 @@ import Generator from './index.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import BaseApplicationGenerator from '../base-application/index.mjs'; const { snakeCase } = lodash; diff --git a/generators/server/__test-support/elastic-search-matcher.mts b/generators/server/__test-support/elastic-search-matcher.mts index 4eb42a71435e..a13eb86f7eea 100644 --- a/generators/server/__test-support/elastic-search-matcher.mts +++ b/generators/server/__test-support/elastic-search-matcher.mts @@ -2,7 +2,7 @@ import type { RunResult } from 'yeoman-test'; import type BaseApplicationGenerator from '../../base-application/index.mjs'; import type { SpringBootApplication } from '../../server/types.mjs'; -import constants from '../../generator-constants.cjs'; +import constants from '../../generator-constants.mjs'; import { matchWrittenConfig, matchWrittenFiles } from '../../../test/support/matcher.mjs'; const { SERVER_MAIN_SRC_DIR, DOCKER_DIR } = constants; diff --git a/generators/server/cleanup.mjs b/generators/server/cleanup.mjs index 4baf0518c87b..2fda230f6c20 100644 --- a/generators/server/cleanup.mjs +++ b/generators/server/cleanup.mjs @@ -27,7 +27,9 @@ import cleanupOauth2 from './cleanup-oauth2.mjs'; import cleanupReactive from './cleanup-reactive.mjs'; import cleanupCucumber from './cleanup-cucumber.mjs'; import cleanupMaven from './cleanup-maven.mjs'; -import { DOCKER_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; + +const { DOCKER_DIR } = constants; /** * Removes server files that where generated in previous JHipster versions and therefore diff --git a/generators/server/entity-files.mjs b/generators/server/entity-files.mjs index e74c8b953a27..b2ddb2c62c88 100644 --- a/generators/server/entity-files.mjs +++ b/generators/server/entity-files.mjs @@ -20,8 +20,8 @@ import _ from 'lodash'; import chalk from 'chalk'; import fs from 'fs'; import { cleanupOldFiles } from './entity-cleanup.mjs'; -import utils from '../utils.cjs'; -import constants from '../generator-constants.cjs'; +import utils from '../utils.mjs'; +import constants from '../generator-constants.mjs'; import { databaseTypes, searchEngineTypes, entityOptions, cacheTypes } from '../../jdl/jhipster/index.mjs'; const { CASSANDRA, COUCHBASE, MONGODB, NEO4J, SQL } = databaseTypes; diff --git a/generators/server/files-sql.mjs b/generators/server/files-sql.mjs index 7bc260041060..2a9ce75f0d53 100644 --- a/generators/server/files-sql.mjs +++ b/generators/server/files-sql.mjs @@ -17,7 +17,9 @@ * limitations under the License. */ import { mergeSections, addSectionsCondition } from './utils.mjs'; -import { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_SRC_DIR, SERVER_TEST_RES_DIR } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; + +const { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_SRC_DIR, SERVER_TEST_RES_DIR } = constants; export const sqlFiles = { reactiveJavaUserManagement: [ @@ -183,7 +185,7 @@ export const serverFiles = mergeSections( ); /** - * @this {import('./index.cjs')} + * @this {import('./index.mjs')} */ export function writeSqlFiles() { return this.asWritingTaskGroup({ diff --git a/generators/server/files.mjs b/generators/server/files.mjs index b135daff3a37..b489daa59189 100644 --- a/generators/server/files.mjs +++ b/generators/server/files.mjs @@ -17,7 +17,7 @@ * limitations under the License. */ import { cleanupOldServerFiles } from './cleanup.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { addSectionsCondition, mergeSections } from './utils.mjs'; import { writeSqlFiles } from './files-sql.mjs'; @@ -1521,7 +1521,7 @@ export const serverFiles = mergeSections( ); /** - * @this {import('./index.cjs')} + * @this {import('./index.mjs')} */ export function writeFiles() { return this.asWritingTaskGroup({ diff --git a/generators/server/generator.mjs b/generators/server/generator.mjs index efb2a0dce75e..ab9c578aa247 100644 --- a/generators/server/generator.mjs +++ b/generators/server/generator.mjs @@ -41,8 +41,8 @@ import BaseApplicationGenerator from '../base-application/index.mjs'; import { writeFiles } from './files.mjs'; import { writeFiles as writeEntityFiles, customizeFiles } from './entity-files.mjs'; import { packageJson as packagejs } from '../../lib/index.mjs'; -import constants from '../generator-constants.cjs'; -import statistics from '../statistics.cjs'; +import constants from '../generator-constants.mjs'; +import statistics from '../statistics.mjs'; import generatorDefaults from '../generator-defaults.mjs'; import { diff --git a/generators/server/needle-api/needle-server-cache.cjs b/generators/server/needle-api/needle-server-cache.mjs similarity index 93% rename from generators/server/needle-api/needle-server-cache.cjs rename to generators/server/needle-api/needle-server-cache.mjs index c375ffb6cafb..c75c559d4f36 100644 --- a/generators/server/needle-api/needle-server-cache.cjs +++ b/generators/server/needle-api/needle-server-cache.mjs @@ -16,9 +16,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const chalk = require('chalk'); -const needleServer = require('./needle-server.cjs'); -const constants = require('../../generator-constants.cjs'); +import chalk from 'chalk'; +import needleServer from './needle-server.cjs'; +import constants from '../../generator-constants.mjs'; // const { CAFFEINE, EHCACHE, REDIS } = require('../../../jdl/jhipster/cache-types'); const CAFFEINE = 'caffeine'; const EHCACHE = 'ehcache'; @@ -26,7 +26,7 @@ const REDIS = 'redis'; const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; -module.exports = class extends needleServer { +export default class extends needleServer { addEntityToCache(entityClass, relationships, packageName, packageFolder, cacheProvider) { const entityAbsoluteClass = entityClass.includes('.') ? entityClass : `${packageName}.domain.${entityClass}`; const entityClassNameGetter = `${entityAbsoluteClass}.class.getName()`; @@ -61,4 +61,4 @@ module.exports = class extends needleServer { const rewriteFileModel = this.generateFileModel(cachePath, needle, content); this.addBlockContentToFile(rewriteFileModel, errorMessage); } -}; +} diff --git a/generators/server/needle-api/needle-server-gradle.cjs b/generators/server/needle-api/needle-server-gradle.mjs similarity index 97% rename from generators/server/needle-api/needle-server-gradle.cjs rename to generators/server/needle-api/needle-server-gradle.mjs index fa6f9e5bc3f3..71f153787032 100644 --- a/generators/server/needle-api/needle-server-gradle.cjs +++ b/generators/server/needle-api/needle-server-gradle.mjs @@ -16,13 +16,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const chalk = require('chalk'); -const needleServer = require('./needle-server.cjs'); +import chalk from 'chalk'; +import needleServer from './needle-server.cjs'; const buildGradlePath = 'build.gradle'; const gradleSettingsPath = 'settings.gradle'; -module.exports = class extends needleServer { +export default class extends needleServer { addProperty(name, value) { const gradlePropertiesPath = 'gradle.properties'; const errorMessage = `${chalk.yellow('Reference to ')}gradle property (name: ${name}, value:${value})${chalk.yellow(' not added.')}`; @@ -130,4 +130,4 @@ module.exports = class extends needleServer { ); this.addBlockContentToFile(rewriteFileModel, errorMessage); } -}; +} diff --git a/generators/server/needle-api/needle-server-liquibase.cjs b/generators/server/needle-api/needle-server-liquibase.mjs similarity index 93% rename from generators/server/needle-api/needle-server-liquibase.cjs rename to generators/server/needle-api/needle-server-liquibase.mjs index 03d2ba3b6c4b..626a0e88a74b 100644 --- a/generators/server/needle-api/needle-server-liquibase.cjs +++ b/generators/server/needle-api/needle-server-liquibase.mjs @@ -16,13 +16,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const chalk = require('chalk'); -const needleServer = require('./needle-server.cjs'); -const constants = require('../../generator-constants.cjs'); +import chalk from 'chalk'; +import needleServer from './needle-server.mjs'; +import constants from '../../generator-constants.mjs'; const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; -module.exports = class extends needleServer { +export default class extends needleServer { addChangelog(changelogName) { this.addChangelogToMaster(changelogName, 'jhipster-needle-liquibase-add-changelog'); } @@ -65,4 +65,4 @@ module.exports = class extends needleServer { this.addBlockContentToFile(rewriteFileModel, errorMessage); } -}; +} diff --git a/generators/server/needle-api/needle-server-logback-spring.cjs b/generators/server/needle-api/needle-server-logback-spring.mjs similarity index 87% rename from generators/server/needle-api/needle-server-logback-spring.cjs rename to generators/server/needle-api/needle-server-logback-spring.mjs index c964b5f31daa..9a065c983d4e 100644 --- a/generators/server/needle-api/needle-server-logback-spring.cjs +++ b/generators/server/needle-api/needle-server-logback-spring.mjs @@ -16,13 +16,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const chalk = require('chalk'); -const needleServer = require('./needle-server.cjs'); -const constants = require('../../generator-constants.cjs'); +import chalk from 'chalk'; +import needleServer from './needle-server.mjs'; +import constants from '../../generator-constants.mjs'; const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; -module.exports = class extends needleServer { +export default class extends needleServer { addlog(logName, level) { this.addlogToMaster(logName, level, 'jhipster-needle-logback-add-log'); } @@ -36,4 +36,4 @@ module.exports = class extends needleServer { this.addBlockContentToFile(rewriteFileModel, errorMessage); } -}; +} diff --git a/generators/server/needle-api/needle-server-maven.cjs b/generators/server/needle-api/needle-server-maven.mjs similarity index 98% rename from generators/server/needle-api/needle-server-maven.cjs rename to generators/server/needle-api/needle-server-maven.mjs index 05398145fd7e..d0419b13087c 100644 --- a/generators/server/needle-api/needle-server-maven.cjs +++ b/generators/server/needle-api/needle-server-maven.mjs @@ -16,12 +16,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const chalk = require('chalk'); -const needleServer = require('./needle-server.cjs'); +import chalk from 'chalk'; +import needleServer from './needle-server.mjs'; const pomPath = 'pom.xml'; -module.exports = class extends needleServer { +export default class extends needleServer { addDependencyManagement(groupId, artifactId, version, type, scope, other) { const errorMessage = `${chalk.yellow('Reference to maven dependency ')} (groupId: ${groupId}, artifactId:${artifactId}, version:${version})${chalk.yellow(' not added.\n')}`; @@ -199,4 +199,4 @@ module.exports = class extends needleServer { this.addBlockContentToFile(rewriteFileModel, errorMessage); } -}; +} diff --git a/generators/server/needle-api/needle-server.cjs b/generators/server/needle-api/needle-server.mjs similarity index 88% rename from generators/server/needle-api/needle-server.cjs rename to generators/server/needle-api/needle-server.mjs index d7f3d4cca9a4..2c12bce5bf0d 100644 --- a/generators/server/needle-api/needle-server.cjs +++ b/generators/server/needle-api/needle-server.mjs @@ -16,6 +16,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const needleBase = require('../../needle-base.cjs'); +import needleBase from '../../needle-base.mjs'; -module.exports = class extends needleBase {}; +export default class extends needleBase {} diff --git a/generators/spring-controller/generator.mjs b/generators/spring-controller/generator.mjs index 7e8bba4eb2c5..36e578035ae2 100644 --- a/generators/spring-controller/generator.mjs +++ b/generators/spring-controller/generator.mjs @@ -22,9 +22,9 @@ import chalk from 'chalk'; import BaseGenerator from '../base/index.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; import { askForControllerActions } from './prompts.mjs'; -import statistics from '../statistics.cjs'; +import statistics from '../statistics.mjs'; import { GENERATOR_SPRING_CONTROLLER } from '../generator-list.mjs'; import { applicationOptions, cacheTypes, messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; diff --git a/generators/spring-service/generator.mjs b/generators/spring-service/generator.mjs index 64f017ff478a..3fa3f809c68e 100644 --- a/generators/spring-service/generator.mjs +++ b/generators/spring-service/generator.mjs @@ -21,8 +21,8 @@ import _ from 'lodash'; import BaseGenerator from '../base/index.mjs'; -import constants from '../generator-constants.cjs'; -import statistics from '../statistics.cjs'; +import constants from '../generator-constants.mjs'; +import statistics from '../statistics.mjs'; import { GENERATOR_SPRING_SERVICE } from '../generator-list.mjs'; import { applicationOptions } from '../../jdl/jhipster/index.mjs'; diff --git a/generators/statistics.cjs b/generators/statistics.mjs similarity index 95% rename from generators/statistics.cjs rename to generators/statistics.mjs index 4f1cb2eb8cd2..10991c79ad4d 100644 --- a/generators/statistics.cjs +++ b/generators/statistics.mjs @@ -16,13 +16,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const { v4: uuid } = require('uuid'); -const Config = require('conf'); -const osLocale = require('os-locale'); -const axios = require('axios'); -const os = require('os'); -const Insight = require('insight'); -const { packageJson: packagejs } = require('../lib/index.cjs'); +import { v4 as uuid } from 'uuid'; +import Config from 'conf'; +import osLocale from 'os-locale'; +import axios from 'axios'; +import os from 'os'; +import Insight from 'insight'; +import { packageJson as packagejs } from '../lib/index.cjs'; const DO_NOT_ASK_LIMIT = 100; @@ -243,4 +243,4 @@ function get() { return currentInstance; } -module.exports = get(); +export default get(); diff --git a/generators/upgrade/generator.mjs b/generators/upgrade/generator.mjs index 90ea316a3b6b..c57f3e22265f 100644 --- a/generators/upgrade/generator.mjs +++ b/generators/upgrade/generator.mjs @@ -28,8 +28,8 @@ import childProcess from 'child_process'; import BaseGenerator from '../base/index.mjs'; import { upgradeFiles } from '../cleanup.mjs'; -import constants from '../generator-constants.cjs'; -import statistics from '../statistics.cjs'; +import constants from '../generator-constants.mjs'; +import statistics from '../statistics.mjs'; import { parseBluePrints } from '../../utils/blueprint.mjs'; import { packageJson as packagejs } from '../../lib/index.mjs'; diff --git a/generators/upgrade/upgrade.spec.mts b/generators/upgrade/upgrade.spec.mts index 6e52f563337c..d27c55d5a4aa 100644 --- a/generators/upgrade/upgrade.spec.mts +++ b/generators/upgrade/upgrade.spec.mts @@ -7,7 +7,7 @@ import { fileURLToPath } from 'url'; import { jestExpect as expect } from 'mocha-expect-snapshot'; import { packageJson } from '../../lib/index.mjs'; import { prepareTempDir } from '../../test/support/temp-dir.mjs'; -import generatorUtils from '../utils.cjs'; +import generatorUtils from '../utils.mjs'; const { escapeRegExp } = generatorUtils; diff --git a/generators/utils.cjs b/generators/utils.mjs similarity index 98% rename from generators/utils.cjs rename to generators/utils.mjs index c17c06ec286d..4bad7436b756 100644 --- a/generators/utils.cjs +++ b/generators/utils.mjs @@ -18,32 +18,10 @@ */ /* eslint-disable no-console */ -const path = require('path'); -const ejs = require('ejs'); -const _ = require('lodash'); -const os = require('os'); - -const constants = require('./generator-constants.cjs'); - -module.exports = { - rewrite, - rewriteFile, - replaceContent, - renderContent, - deepFind, - escapeRegExp, - getJavadoc, - buildEnumInfo, - getEnumInfo, - checkStringInFile, - checkRegexInFile, - packageNameToNamespace, - stringHashCode, - vueAddPageToRouterImport, - vueAddPageToRouter, - vueAddPageServiceToMainImport, - vueAddPageServiceToMain, -}; +import path from 'path'; +import ejs from 'ejs'; +import _ from 'lodash'; +import os from 'os'; /** * Rewrite file with passed arguments @@ -508,3 +486,24 @@ function vueAddPageServiceToMain(generator, { clientSrcDir, pageName, pageInstan generator ); } + +const utils = { + rewrite, + rewriteFile, + replaceContent, + renderContent, + deepFind, + escapeRegExp, + getJavadoc, + buildEnumInfo, + getEnumInfo, + checkStringInFile, + checkRegexInFile, + packageNameToNamespace, + stringHashCode, + vueAddPageToRouterImport, + vueAddPageToRouter, + vueAddPageServiceToMainImport, + vueAddPageServiceToMain, +}; +export default utils; diff --git a/generators/vue/generator.spec.mts b/generators/vue/generator.spec.mts index 979cb4fc62d4..e5260ea69c60 100644 --- a/generators/vue/generator.spec.mts +++ b/generators/vue/generator.spec.mts @@ -9,7 +9,7 @@ import Generator from './index.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; -import constants from '../generator-constants.cjs'; +import constants from '../generator-constants.mjs'; const { snakeCase } = lodash; diff --git a/generators/workspaces/generator.mjs b/generators/workspaces/generator.mjs index 3567aa22ba4a..ecdd194bcd69 100644 --- a/generators/workspaces/generator.mjs +++ b/generators/workspaces/generator.mjs @@ -22,14 +22,14 @@ import path from 'path'; import { GENERATOR_ANGULAR, GENERATOR_APP, GENERATOR_COMMON, GENERATOR_GIT } from '../generator-list.mjs'; -import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; +import constants from '../generator-constants.mjs'; import BaseGenerator from '../base/index.mjs'; import { deploymentOptions } from '../../jdl/jhipster/index.mjs'; const { DeploymentTypes: { DOCKERCOMPOSE }, } = deploymentOptions; - +const { GENERATOR_JHIPSTER } = constants; /** * Base class for a generator that can be extended through a blueprint. * diff --git a/test-integration/scripts/00-init-env.sh b/test-integration/scripts/00-init-env.sh index 3b3c5d5a7997..4e46f717f241 100755 --- a/test-integration/scripts/00-init-env.sh +++ b/test-integration/scripts/00-init-env.sh @@ -79,7 +79,7 @@ fi # jdk version if [[ "$JHI_JDK" == "" ]]; then - JHI_JDK=$(grep -o "JAVA_VERSION = '[^']*'" $JHI_HOME/generators/generator-constants.cjs | cut -f2 -d "'") + JHI_JDK=$(grep -o "JAVA_VERSION = '[^']*'" $JHI_HOME/generators/generator-constants.mjs | cut -f2 -d "'") fi # set correct OpenJDK version @@ -92,7 +92,7 @@ if [[ "$JHI_CLI" == "" ]]; then fi # node version -JHI_NODE_VERSION=$(grep -o "NODE_VERSION = '[^']*'" $JHI_HOME/generators/generator-constants.cjs | cut -f2 -d "'") +JHI_NODE_VERSION=$(grep -o "NODE_VERSION = '[^']*'" $JHI_HOME/generators/generator-constants.mjs | cut -f2 -d "'") # npm version JHI_NPM_VERSION=$(grep -o '"npm": "[^"]*"' $JHI_HOME/generators/common/templates/package.json | cut -f4 -d '"') diff --git a/test/app/composing.spec.mts b/test/app/composing.spec.mts index 70178a75e7e7..85896bdf9ed1 100644 --- a/test/app/composing.spec.mts +++ b/test/app/composing.spec.mts @@ -4,9 +4,10 @@ import assert from 'yeoman-assert'; import Environment from 'yeoman-environment'; import { dryRunHelpers as helpers } from '../support/helpers.mjs'; -import { JHIPSTER_CONFIG_DIR } from '../../generators/generator-constants.mjs'; +import constants from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; +const { JHIPSTER_CONFIG_DIR } = constants; const { createEnv } = Environment; helpers.createEnv = createEnv; diff --git a/test/app/database-changelog.spec.mts b/test/app/database-changelog.spec.mts index aba0679f1b37..ef1a60388bc6 100644 --- a/test/app/database-changelog.spec.mts +++ b/test/app/database-changelog.spec.mts @@ -3,9 +3,11 @@ import fse from 'fs-extra'; import helpers from 'yeoman-test'; import createMockedConfig from '../support/mock-config.mjs'; -import { SERVER_MAIN_RES_DIR } from '../../generators/generator-constants.mjs'; +import constants from '../../generators/generator-constants.mjs'; import { getEntityTemplatePath, getGenerator } from '../support/index.mjs'; +const { SERVER_MAIN_RES_DIR } = constants; + describe('jhipster:app database changelogs', () => { context('when regenerating the application', () => { describe('with cassandra database', () => { diff --git a/test/entity/database-changelog.spec.mts b/test/entity/database-changelog.spec.mts index 151b54206706..e3fea30f879e 100644 --- a/test/entity/database-changelog.spec.mts +++ b/test/entity/database-changelog.spec.mts @@ -2,11 +2,12 @@ import path from 'path'; import fse from 'fs-extra'; import { skipPrettierHelpers as helpers } from '../support/helpers.mjs'; -import { SERVER_MAIN_RES_DIR } from '../../generators/generator-constants.mjs'; +import constants from '../../generators/generator-constants.mjs'; import createMockedConfig from '../support/mock-config.mjs'; import { getEntityTemplatePath, getGenerator } from '../support/index.mjs'; import BaseApplicationGenerator from '../../generators/base-application/generator.mjs'; +const { SERVER_MAIN_RES_DIR } = constants; class MockedLanguagesGenerator extends BaseApplicationGenerator { get [BaseApplicationGenerator.PREPARING]() { return { diff --git a/test/entity/single-entity.spec.mts b/test/entity/single-entity.spec.mts index 3aae5afe7944..f9626a2856f2 100644 --- a/test/entity/single-entity.spec.mts +++ b/test/entity/single-entity.spec.mts @@ -2,11 +2,12 @@ import path from 'path'; import fse from 'fs-extra'; import { skipPrettierHelpers as helpers } from '../support/helpers.mjs'; -import { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR, CLIENT_MAIN_SRC_DIR } from '../../generators/generator-constants.mjs'; +import constants from '../../generators/generator-constants.mjs'; import createMockedConfig from '../support/mock-config.mjs'; import { getTemplatePath, getEntityTemplatePath, getGenerator } from '../support/index.mjs'; import BaseApplicationGenerator from '../../generators/base-application/generator.mjs'; +const { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR, CLIENT_MAIN_SRC_DIR } = constants; const DEFAULT_TEST_OPTIONS = { skipInstall: true, skipChecks: true, skipPrettier: true }; class MockedLanguagesGenerator extends BaseApplicationGenerator { diff --git a/test/heroku.spec.mts b/test/heroku.spec.mts index 3f88a94e0445..29c0191843c4 100644 --- a/test/heroku.spec.mts +++ b/test/heroku.spec.mts @@ -5,7 +5,7 @@ import sinon from 'sinon'; import ChildProcess from 'child_process'; import { jestExpect as expect } from 'mocha-expect-snapshot'; -import constants from '../generators/generator-constants.cjs'; +import constants from '../generators/generator-constants.mjs'; import { getTemplatePath, getGenerator } from './support/index.mjs'; const expectedFiles = { diff --git a/test/needle-api/needle-base.spec.mts b/test/needle-api/needle-base.spec.mts index b040c69e206b..a7311e6def29 100644 --- a/test/needle-api/needle-base.spec.mts +++ b/test/needle-api/needle-base.spec.mts @@ -1,5 +1,5 @@ import assert from 'yeoman-assert'; -import NeedleApiBase from '../../generators/needle-base.cjs'; +import NeedleApiBase from '../../generators/needle-base.mjs'; describe('Unit tests for needle-base API', () => { let needleApiBase; diff --git a/test/needle-api/needle-client-angular.spec.mts b/test/needle-api/needle-client-angular.spec.mts index e70de96a0908..f789277eaed1 100644 --- a/test/needle-api/needle-client-angular.spec.mts +++ b/test/needle-api/needle-client-angular.spec.mts @@ -3,7 +3,7 @@ import helpers from 'yeoman-test'; import { getGenerator } from '../support/index.mjs'; import ClientGenerator from '../../generators/client/index.mjs'; -import constants from '../../generators/generator-constants.cjs'; +import constants from '../../generators/generator-constants.mjs'; const ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR; const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; diff --git a/test/needle-api/needle-client-i18n.spec.mts b/test/needle-api/needle-client-i18n.spec.mts index 90c56080f282..7f846db4eeed 100644 --- a/test/needle-api/needle-client-i18n.spec.mts +++ b/test/needle-api/needle-client-i18n.spec.mts @@ -3,7 +3,7 @@ import helpers from 'yeoman-test'; import fse from 'fs-extra'; import LanguagesGenerator from '../../generators/languages/index.mjs'; -import constants from '../../generators/generator-constants.cjs'; +import constants from '../../generators/generator-constants.mjs'; import { getGenerator, getTemplatePath } from '../support/index.mjs'; const ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR; diff --git a/test/needle-api/needle-client-react.spec.mts b/test/needle-api/needle-client-react.spec.mts index 5dfc674eec57..476397cf5e2d 100644 --- a/test/needle-api/needle-client-react.spec.mts +++ b/test/needle-api/needle-client-react.spec.mts @@ -1,7 +1,7 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ClientGenerator from '../../generators/client/index.mjs'; -import constants from '../../generators/generator-constants.cjs'; +import constants from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; const REACT = constants.SUPPORTED_CLIENT_FRAMEWORKS.REACT; diff --git a/test/needle-api/needle-client-vue.spec.mts b/test/needle-api/needle-client-vue.spec.mts index 6124b835682f..d6099b7fb1a6 100644 --- a/test/needle-api/needle-client-vue.spec.mts +++ b/test/needle-api/needle-client-vue.spec.mts @@ -2,7 +2,7 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ClientGenerator from '../../generators/client/index.mjs'; -import constants from '../../generators/generator-constants.cjs'; +import constants from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; const VUE = constants.SUPPORTED_CLIENT_FRAMEWORKS.VUE; diff --git a/test/needle-api/needle-client-webpack.spec.mts b/test/needle-api/needle-client-webpack.spec.mts index aaebe5f42651..61e0abf3f526 100644 --- a/test/needle-api/needle-client-webpack.spec.mts +++ b/test/needle-api/needle-client-webpack.spec.mts @@ -1,7 +1,7 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ClientGenerator from '../../generators/client/index.mjs'; -import constants from '../../generators/generator-constants.cjs'; +import constants from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; const { ANGULAR, VUE, REACT } = constants.SUPPORTED_CLIENT_FRAMEWORKS; diff --git a/test/needle-api/needle-client.spec.mts b/test/needle-api/needle-client.spec.mts index cec9c3fbcd8d..36efe73fcaa2 100644 --- a/test/needle-api/needle-client.spec.mts +++ b/test/needle-api/needle-client.spec.mts @@ -1,7 +1,7 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ClientGenerator from '../../generators/client/index.mjs'; -import constants from '../../generators/generator-constants.cjs'; +import constants from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; diff --git a/test/needle-api/needle-server-cache.spec.mts b/test/needle-api/needle-server-cache.spec.mts index f74c976d65be..cf5321515361 100644 --- a/test/needle-api/needle-server-cache.spec.mts +++ b/test/needle-api/needle-server-cache.spec.mts @@ -1,7 +1,7 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ServerGenerator from '../../generators/server/index.mjs'; -import constants from '../../generators/generator-constants.cjs'; +import constants from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; diff --git a/test/needle-api/needle-server-liquibase.spec.mts b/test/needle-api/needle-server-liquibase.spec.mts index 97669528c98e..49f1be01e6cc 100644 --- a/test/needle-api/needle-server-liquibase.spec.mts +++ b/test/needle-api/needle-server-liquibase.spec.mts @@ -4,7 +4,7 @@ import helpers from 'yeoman-test'; import fse from 'fs-extra'; import { fileURLToPath } from 'url'; import ServerGenerator from '../../generators/server/index.mjs'; -import constants from '../../generators/generator-constants.cjs'; +import constants from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; diff --git a/test/needle-api/needle-server-logback-spring.spec.mts b/test/needle-api/needle-server-logback-spring.spec.mts index bc3a3904e5d3..5f9853a2673b 100644 --- a/test/needle-api/needle-server-logback-spring.spec.mts +++ b/test/needle-api/needle-server-logback-spring.spec.mts @@ -1,7 +1,7 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ServerGenerator from '../../generators/server/index.mjs'; -import constants from '../../generators/generator-constants.cjs'; +import constants from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; diff --git a/test/page.spec.mts b/test/page.spec.mts index 2b9a8aa5ff5e..e66c6fbb71fa 100644 --- a/test/page.spec.mts +++ b/test/page.spec.mts @@ -1,7 +1,7 @@ import helpers from 'yeoman-test'; import EnvironmentBuilder from '../cli/environment-builder.mjs'; -import constants from '../generators/generator-constants.cjs'; +import constants from '../generators/generator-constants.mjs'; const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; const CLIENT_TEST_SRC_DIR = constants.CLIENT_TEST_SRC_DIR; diff --git a/test/spring-controller.spec.mts b/test/spring-controller.spec.mts index c968bc71c872..d1ff62d46861 100644 --- a/test/spring-controller.spec.mts +++ b/test/spring-controller.spec.mts @@ -2,7 +2,7 @@ import path from 'path'; import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import fse from 'fs-extra'; -import constants from '../generators/generator-constants.cjs'; +import constants from '../generators/generator-constants.mjs'; import { getGenerator, getTemplatePath } from './support/index.mjs'; const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; diff --git a/test/spring-service.spec.mts b/test/spring-service.spec.mts index 6f82b4a0909b..62b979275f5a 100644 --- a/test/spring-service.spec.mts +++ b/test/spring-service.spec.mts @@ -1,7 +1,7 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import fse from 'fs-extra'; -import constants from '../generators/generator-constants.cjs'; +import constants from '../generators/generator-constants.mjs'; import { getGenerator, getTemplatePath } from './support/index.mjs'; const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; diff --git a/test/support/tests.mjs b/test/support/tests.mjs index 4baa9c054c9b..a3716e65e07a 100644 --- a/test/support/tests.mjs +++ b/test/support/tests.mjs @@ -4,11 +4,11 @@ import sinon from 'sinon'; import { existsSync } from 'fs'; import { fileURLToPath } from 'url'; -import { GENERATOR_JHIPSTER } from '../../generators/generator-constants.mjs'; +import constants from '../../generators/generator-constants.mjs'; import { skipPrettierHelpers as helpers } from './helpers.mjs'; -import priorities from '../../generators/base-application/priorities.cjs'; +import { PRIORITY_NAMES, ENTITY_PRIORITY_NAMES, PRIORITY_NAMES_LIST } from '../../generators/base-application/priorities.mjs'; -const { PRIORITY_NAMES, ENTITY_PRIORITY_NAMES, PRIORITY_NAMES_LIST } = priorities; +const { GENERATOR_JHIPSTER } = constants; const { CONFIGURING_EACH_ENTITY, diff --git a/test/utils.spec.mjs b/test/utils.spec.mjs index 5d975757cb03..6da81d672edf 100644 --- a/test/utils.spec.mjs +++ b/test/utils.spec.mjs @@ -3,7 +3,7 @@ import { fileURLToPath } from 'url'; import assert from 'yeoman-assert'; import path, { dirname } from 'path'; -import utils from '../generators/utils.cjs'; +import utils from '../generators/utils.mjs'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); From ded97016128efa275029d5167678742f19145e8e Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Tue, 27 Dec 2022 00:14:07 +0100 Subject: [PATCH 2/8] pre rebasing --- generators/base-application/priorities.mjs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/generators/base-application/priorities.mjs b/generators/base-application/priorities.mjs index 585557f309eb..71e9421a8920 100644 --- a/generators/base-application/priorities.mjs +++ b/generators/base-application/priorities.mjs @@ -1,6 +1,6 @@ -import { PRIORITY_PREFIX, QUEUE_PREFIX, PRIORITY_NAMES as PRIORITY_NAMES2, QUEUES as QUEUES2 } from '../base/priorities.mjs'; +import { QUEUE_PREFIX, PRIORITY_NAMES as PRIORITY_NAMES_BASE, QUEUES as QUEUES_BASE } from '../base/priorities.mjs'; -const { DEFAULT, TRANSFORM, PRE_CONFLICTS } = PRIORITY_NAMES2; +const { DEFAULT, TRANSFORM, PRE_CONFLICTS } = PRIORITY_NAMES_BASE; const CONFIGURING_EACH_ENTITY = 'configuringEachEntity'; const CONFIGURING_EACH_ENTITY_QUEUE = `${QUEUE_PREFIX}${CONFIGURING_EACH_ENTITY}`; @@ -100,12 +100,12 @@ export const ENTITY_PRIORITY_NAMES = { }; export const PRIORITY_NAMES = { - ...PRIORITY_NAMES2, + ...PRIORITY_NAMES_BASE, ...ENTITY_PRIORITY_NAMES, }; export const QUEUES = { - ...QUEUES2, + ...QUEUES_BASE, ...ENTITY_QUEUES, }; @@ -127,7 +127,7 @@ export const PRIORITY_NAMES_LIST = [ WRITING_ENTITIES, PRIORITY_NAMES.POST_WRITING, POST_WRITING_ENTITIES, - PRIORITY_NAMES2.INSTALL, - PRIORITY_NAMES2.POST_INSTALL, - PRIORITY_NAMES2.END, + PRIORITY_NAMES_BASE.INSTALL, + PRIORITY_NAMES_BASE.POST_INSTALL, + PRIORITY_NAMES_BASE.END, ]; From 94bbed0653c13669b57a6441768fdb6ee7d8d6cb Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Tue, 27 Dec 2022 00:17:37 +0100 Subject: [PATCH 3/8] pre rebasing --- generators/base/jhipster7-proxy.mjs | 3 --- 1 file changed, 3 deletions(-) diff --git a/generators/base/jhipster7-proxy.mjs b/generators/base/jhipster7-proxy.mjs index 86b3676470c4..9ae50214152a 100644 --- a/generators/base/jhipster7-proxy.mjs +++ b/generators/base/jhipster7-proxy.mjs @@ -90,9 +90,6 @@ const getProperty = (context, prop) => { )}.` ); } - if (prop in oldConstants && !(prop in newConstants)) { - console.log(`Template data ${chalk.yellow(String(prop))} is deprecated but a replacement is not yet added.`); - } const { generator, data } = context; if (prop in data) { return data[prop]; From 5561b2738767ec40db285a5c33475a6ddd518360 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Tue, 27 Dec 2022 10:47:40 +0100 Subject: [PATCH 4/8] prepare ejs migration --- generators/base/jhipster7-proxy.mjs | 3 --- generators/entities/generator.mjs | 2 +- generators/entities/generator.spec.mts | 4 ---- generators/entity/generator.mjs | 1 - 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/generators/base/jhipster7-proxy.mjs b/generators/base/jhipster7-proxy.mjs index 9ae50214152a..d526cc95780b 100644 --- a/generators/base/jhipster7-proxy.mjs +++ b/generators/base/jhipster7-proxy.mjs @@ -1,9 +1,6 @@ /* eslint-disable no-console */ import chalk from 'chalk'; -import * as oldConstants from '../generator-constants.mjs'; -import * as newConstants from '../generator-constants.mjs'; - const deprecatedProperties = { GRADLE_VERSION: { replacement: 'gradleVersion', diff --git a/generators/entities/generator.mjs b/generators/entities/generator.mjs index 04dc260f9bdc..b38977eab277 100644 --- a/generators/entities/generator.mjs +++ b/generators/entities/generator.mjs @@ -17,11 +17,11 @@ * limitations under the License. */ import BaseGenerator from '../base/index.mjs'; - import constants from '../generator-constants.mjs'; import { GENERATOR_ENTITIES, GENERATOR_APP } from '../generator-list.mjs'; const { JHIPSTER_CONFIG_DIR } = constants; + export default class EntitiesGenerator extends BaseGenerator { constructor(args, options, features) { super(args, options, { unique: 'namespace', ...features }); diff --git a/generators/entities/generator.spec.mts b/generators/entities/generator.spec.mts index 32fa3a943075..7f2afdbf0681 100644 --- a/generators/entities/generator.spec.mts +++ b/generators/entities/generator.spec.mts @@ -27,15 +27,11 @@ import Generator from './generator.mjs'; import { skipPrettierHelpers as helpers } from '../../test/support/helpers.mjs'; const { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR, CLIENT_MAIN_SRC_DIR } = constants; - const { snakeCase } = lodash; - const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); - const generator = basename(__dirname); const generatorPath = `${__dirname}/index.mts`; - const DEFAULT_TEST_OPTIONS = { skipInstall: true, skipChecks: true, skipPrettier: true }; describe(`JHipster ${generator} generator`, () => { diff --git a/generators/entity/generator.mjs b/generators/entity/generator.mjs index df48e9e0031b..b2c36ce8fafa 100644 --- a/generators/entity/generator.mjs +++ b/generators/entity/generator.mjs @@ -23,7 +23,6 @@ import _ from 'lodash'; import path from 'path'; import BaseGenerator from '../base/index.mjs'; - import prompts from './prompts.mjs'; import generatorDefaults from '../generator-defaults.mjs'; import constants from '../generator-constants.mjs'; From 8e9f1455b7941703aba51d782ccc7e3800b8dfe7 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Tue, 27 Dec 2022 17:54:32 +0100 Subject: [PATCH 5/8] do not use default export for constants and utils --- cli/environment-builder.mjs | 3 +- cli/import-jdl.mjs | 5 +- cli/program.mjs | 3 +- generators/angular/generator.spec.mts | 3 +- generators/app/generator.mjs | 2 +- generators/app/prompts.mjs | 2 +- generators/aws/generator.mjs | 2 +- generators/azure-app-service/generator.mjs | 8 +- generators/azure-spring-cloud/generator.mjs | 12 +- generators/base-application/generator.mjs | 3 +- generators/base-docker/generator.mjs | 6 +- generators/base/generator-base-blueprint.mjs | 5 +- generators/base/generator-base-private.mjs | 14 +- generators/base/generator-base.mjs | 40 ++--- .../bootstrap-application-base/faker.mts | 4 +- .../bootstrap-application-base/generator.mts | 3 +- .../generator.mts | 6 +- generators/bootstrap/generator.mts | 3 +- generators/ci-cd/generator.mjs | 10 +- generators/cleanup.mjs | 10 +- generators/client/entity-files.mjs | 7 +- generators/client/generator.mjs | 6 +- .../needle-api/needle-client-angular.mjs | 14 +- .../client/needle-api/needle-client-vue.mjs | 12 +- .../needle-api/needle-client-webpack.mjs | 10 +- generators/client/utils.mjs | 4 +- generators/cloudfoundry/generator.mjs | 8 +- generators/common/generator.mjs | 24 ++- generators/couchbase/entity-files.mjs | 3 +- generators/couchbase/files.mjs | 3 +- generators/cypress/files.mts | 3 +- generators/cypress/generator.mts | 11 +- generators/cypress/generator.spec.mts | 4 +- generators/docker-compose/generator.mjs | 3 +- .../service-discovery-matcher.mts | 4 +- generators/docker/files.mjs | 4 +- generators/docker/generator.mjs | 3 +- generators/entities/generator.mjs | 4 +- generators/entities/generator.spec.mts | 3 +- generators/entity/generator.mjs | 12 +- generators/entity/prompts.mjs | 16 +- generators/export-jdl/generator.mts | 2 +- generators/gae/generator.mjs | 12 +- generators/generate-blueprint/files.mjs | 2 +- generators/generator-constants.mjs | 168 ++++++------------ generators/gradle/generator.spec.mjs | 4 +- generators/heroku/generator.mjs | 14 +- generators/init/generator.spec.mts | 3 +- generators/kafka/files.mjs | 3 +- generators/kubernetes-helm/generator.mjs | 2 +- generators/kubernetes-knative/generator.mjs | 2 +- generators/kubernetes/generator.mjs | 2 +- generators/kubernetes/kubernetes-base.mjs | 51 ++++-- generators/languages/detect-language.mjs | 4 +- generators/languages/entity-files.mjs | 4 +- generators/languages/files.mjs | 4 +- generators/languages/generator.mjs | 25 ++- generators/languages/languages.spec.mjs | 8 +- generators/liquibase-changelogs/files.mjs | 4 +- .../incremental-liquibase.spec.mts | 4 +- generators/liquibase/files.mts | 4 +- generators/liquibase/generator.mts | 5 +- generators/maven/generator.spec.mjs | 4 +- generators/needle-base.mjs | 4 +- generators/openapi-client/files.mjs | 16 +- generators/openshift/generator.mjs | 2 +- generators/page/files-vue.mjs | 13 +- generators/react/generator.spec.mts | 3 +- .../__test-support/elastic-search-matcher.mts | 4 +- generators/server/cleanup.mjs | 4 +- generators/server/entity-files.mjs | 12 +- generators/server/files-sql.mjs | 4 +- generators/server/files.mjs | 9 +- generators/server/generator.mjs | 64 ++++--- .../server/needle-api/needle-server-cache.mjs | 6 +- .../needle-api/needle-server-gradle.mjs | 2 +- .../needle-api/needle-server-liquibase.mjs | 4 +- .../needle-server-logback-spring.mjs | 4 +- generators/spring-controller/generator.mjs | 6 +- generators/spring-service/generator.mjs | 6 +- generators/{statistics.mjs => statistics.cjs} | 16 +- generators/upgrade/generator.mjs | 5 +- generators/upgrade/upgrade.spec.mts | 4 +- generators/utils.mjs | 67 +++---- generators/vue/generator.spec.mts | 3 +- generators/workspaces/generator.mjs | 3 +- lib/support/needles.mjs | 2 +- test/app/composing.spec.mts | 3 +- test/app/database-changelog.spec.mts | 4 +- test/entity/database-changelog.spec.mts | 3 +- test/entity/single-entity.spec.mts | 3 +- test/heroku.spec.mts | 20 +-- .../needle-api/needle-client-angular.spec.mts | 6 +- test/needle-api/needle-client-i18n.spec.mts | 6 +- test/needle-api/needle-client-react.spec.mts | 6 +- test/needle-api/needle-client-vue.spec.mts | 7 +- .../needle-api/needle-client-webpack.spec.mts | 6 +- test/needle-api/needle-client.spec.mts | 4 +- test/needle-api/needle-server-cache.spec.mts | 4 +- .../needle-server-liquibase.spec.mts | 4 +- .../needle-server-logback-spring.spec.mts | 4 +- test/page.spec.mts | 4 +- test/spring-controller.spec.mts | 9 +- test/spring-service.spec.mts | 4 +- test/support/tests.mjs | 4 +- test/utils.spec.mjs | 40 ++--- 106 files changed, 437 insertions(+), 600 deletions(-) rename generators/{statistics.mjs => statistics.cjs} (95%) diff --git a/cli/environment-builder.mjs b/cli/environment-builder.mjs index 90cf768fcfd2..e19e7e0afe01 100644 --- a/cli/environment-builder.mjs +++ b/cli/environment-builder.mjs @@ -26,10 +26,9 @@ import { dirname } from 'path'; import { fileURLToPath } from 'url'; import { CLI_NAME, logger } from './utils.mjs'; -import generatorUtils from '../generators/utils.mjs'; +import { packageNameToNamespace } from '../generators/utils.mjs'; import { parseBlueprintInfo, loadBlueprintsFromConfiguration, mergeBlueprints } from '../utils/blueprint.mjs'; -const { packageNameToNamespace } = generatorUtils; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); diff --git a/cli/import-jdl.mjs b/cli/import-jdl.mjs index 226d46973465..42db8b68045d 100644 --- a/cli/import-jdl.mjs +++ b/cli/import-jdl.mjs @@ -28,11 +28,10 @@ import { fork as forkProcess } from 'child_process'; import EnvironmentBuilder from './environment-builder.mjs'; import { CLI_NAME, GENERATOR_NAME, logger, printSuccess, getOptionAsArgs } from './utils.mjs'; import { packageJson as packagejs } from '../lib/index.mjs'; -import statistics from '../generators/statistics.mjs'; -import constants from '../generators/generator-constants.mjs'; +import statistics from '../generators/statistics.cjs'; +import { JHIPSTER_CONFIG_DIR } from '../generators/generator-constants.mjs'; import { writeConfigFile } from './export-utils.mjs'; -const { JHIPSTER_CONFIG_DIR } = constants; const jhipsterCli = join(dirname(fileURLToPath(import.meta.url)), 'cli.mjs'); const getDeploymentType = deployment => deployment && deployment[GENERATOR_NAME] && deployment[GENERATOR_NAME].deploymentType; diff --git a/cli/program.mjs b/cli/program.mjs index 3ccdf48c9a90..8cb3279c083b 100644 --- a/cli/program.mjs +++ b/cli/program.mjs @@ -32,9 +32,8 @@ import SUB_GENERATORS from './commands.mjs'; import JHipsterCommand from './jhipster-command.mjs'; import { CLI_NAME, logger, getCommand, done } from './utils.mjs'; import { packageJson } from '../lib/index.mjs'; -import generatorUtils from '../generators/utils.mjs'; +import { packageNameToNamespace } from '../generators/utils.mjs'; -const { packageNameToNamespace } = generatorUtils; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); diff --git a/generators/angular/generator.spec.mts b/generators/angular/generator.spec.mts index c616eca823c1..480970e00cb7 100644 --- a/generators/angular/generator.spec.mts +++ b/generators/angular/generator.spec.mts @@ -9,7 +9,7 @@ import Generator from './index.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; -import constants from '../generator-constants.mjs'; +import { CLIENT_MAIN_SRC_DIR } from '../generator-constants.mjs'; import BaseApplicationGenerator from '../base-application/index.mjs'; const { snakeCase } = lodash; @@ -21,7 +21,6 @@ const generator = basename(__dirname); const generatorFile = join(__dirname, 'index.mts'); const { ANGULAR: clientFramework } = clientFrameworkTypes; -const { CLIENT_MAIN_SRC_DIR } = constants; const commonConfig = { clientFramework, nativeLanguage: 'en', languages: ['fr', 'en'] }; const samplesBuilder = () => diff --git a/generators/app/generator.mjs b/generators/app/generator.mjs index 071f0bb716e5..0fb0d1bc9c98 100644 --- a/generators/app/generator.mjs +++ b/generators/app/generator.mjs @@ -26,7 +26,7 @@ import serverOptions from '../server/options.mjs'; import { cleanupOldFiles, upgradeFiles } from '../cleanup.mjs'; import prompts from './prompts.mjs'; import { packageJson as packagejs } from '../../lib/index.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import generatorDefaults from '../generator-defaults.mjs'; import { GENERATOR_APP, diff --git a/generators/app/prompts.mjs b/generators/app/prompts.mjs index 74c5175ce21d..7d43d27b6e7c 100644 --- a/generators/app/prompts.mjs +++ b/generators/app/prompts.mjs @@ -17,7 +17,7 @@ * limitations under the License. */ import chalk from 'chalk'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import { packageJson as packagejs } from '../../lib/index.mjs'; import generatorsDefaults from '../generator-defaults.mjs'; import { applicationTypes, testFrameworkTypes } from '../../jdl/jhipster/index.mjs'; diff --git a/generators/aws/generator.mjs b/generators/aws/generator.mjs index 3232853c0202..5e8c3b662d71 100644 --- a/generators/aws/generator.mjs +++ b/generators/aws/generator.mjs @@ -21,7 +21,7 @@ import BaseGenerator from '../base/index.mjs'; import prompts from './prompts.mjs'; import AwsFactory from './lib/aws.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import { GENERATOR_AWS } from '../generator-list.mjs'; import { applicationOptions, databaseTypes } from '../../jdl/jhipster/index.mjs'; diff --git a/generators/azure-app-service/generator.mjs b/generators/azure-app-service/generator.mjs index bcc61b5d9577..680b8e06e884 100644 --- a/generators/azure-app-service/generator.mjs +++ b/generators/azure-app-service/generator.mjs @@ -23,11 +23,11 @@ import { exec } from 'child_process'; import chalk from 'chalk'; import BaseGenerator from '../base/index.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import generatorDefaults from '../generator-defaults.mjs'; // Global constants -import constants from '../generator-constants.mjs'; +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'; @@ -93,7 +93,7 @@ export default class AzureAppServiceGenerator extends BaseGenerator { this.azureGroupId = ''; }, loadConstants() { - this.JAVA_VERSION = constants.JAVA_VERSION; + this.JAVA_VERSION = JAVA_VERSION; }, }; } @@ -512,7 +512,7 @@ which is free for the first 30 days`); writeFiles() { if (this.abort) return; this.log(chalk.bold('\nCreating Azure App Service deployment files')); - this.template('application-azure.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/application-azure.yml`); + this.template('application-azure.yml.ejs', `${SERVER_MAIN_RES_DIR}/config/application-azure.yml`); if (this.azureAppServiceDeploymentType === 'github-action') { this.template('github/workflows/azure-app-service.yml.ejs', '.github/workflows/azure-app-service.yml'); } diff --git a/generators/azure-spring-cloud/generator.mjs b/generators/azure-spring-cloud/generator.mjs index b49a93492ba0..1c8712b999e8 100644 --- a/generators/azure-spring-cloud/generator.mjs +++ b/generators/azure-spring-cloud/generator.mjs @@ -21,9 +21,9 @@ import { exec } from 'child_process'; import chalk from 'chalk'; import BaseGenerator from '../base/index.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; -import constants from '../generator-constants.mjs'; +import { JAVA_VERSION, CLIENT_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; import { cacheTypes, buildToolTypes } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_AZURE_SPRING_CLOUD } from '../generator-list.mjs'; @@ -75,7 +75,7 @@ export default class AzureSpringCloudGenerator extends BaseGenerator { this.loadDerivedPlatformConfig(); }, getConfig() { - this.env.options.appPath = this.config.get('appPath') || constants.CLIENT_MAIN_SRC_DIR; + this.env.options.appPath = this.config.get('appPath') || CLIENT_MAIN_SRC_DIR; this.cacheProvider = this.cacheProvider || NO_CACHE_PROVIDER; this.enableHibernateCache = this.enableHibernateCache && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider); this.frontendAppName = this.getFrontendAppName(); @@ -85,7 +85,7 @@ export default class AzureSpringCloudGenerator extends BaseGenerator { this.azureSpringCloudDeploymentType = this.config.get('azureSpringCloudDeploymentType'); }, loadConstants() { - this.JAVA_VERSION = constants.JAVA_VERSION; + this.JAVA_VERSION = JAVA_VERSION; }, }; } @@ -337,8 +337,8 @@ ${chalk.red('az extension add --name spring-cloud')}` copyAzureSpringCloudFiles() { if (this.abort) return; this.log(chalk.bold('\nCreating Azure Spring Cloud deployment files')); - this.template('application-azure.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/application-azure.yml`); - this.template('bootstrap-azure.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/bootstrap-azure.yml`); + this.template('application-azure.yml.ejs', `${SERVER_MAIN_RES_DIR}/config/application-azure.yml`); + this.template('bootstrap-azure.yml.ejs', `${SERVER_MAIN_RES_DIR}/config/bootstrap-azure.yml`); if (this.azureSpringCloudDeploymentType === 'github-action') { this.template('github/workflows/azure-spring-cloud.yml.ejs', '.github/workflows/azure-spring-cloud.yml'); } diff --git a/generators/base-application/generator.mjs b/generators/base-application/generator.mjs index a1dbb22d28f5..92ab37186200 100644 --- a/generators/base-application/generator.mjs +++ b/generators/base-application/generator.mjs @@ -20,9 +20,8 @@ import _ from 'lodash'; import BaseGenerator from '../base/index.mjs'; import { CUSTOM_PRIORITIES, PRIORITY_NAMES, QUEUES } from './priorities.mjs'; -import constants from '../generator-constants.mjs'; +import { JHIPSTER_CONFIG_DIR } from '../generator-constants.mjs'; -const { JHIPSTER_CONFIG_DIR } = constants; const { LOADING, PREPARING, diff --git a/generators/base-docker/generator.mjs b/generators/base-docker/generator.mjs index 899777f720e0..6798c42ae51a 100644 --- a/generators/base-docker/generator.mjs +++ b/generators/base-docker/generator.mjs @@ -22,10 +22,10 @@ import prompts from './docker-prompts.mjs'; import BlueprintBaseGenerator from '../base/index.mjs'; import { GENERATOR_DOCKER_COMPOSE } from '../generator-list.mjs'; import { loadFromYoRc, checkDocker, checkImages, generateJwtSecret, setAppsFolderPaths } from './docker-base.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import { applicationOptions, deploymentOptions } from '../../jdl/jhipster/index.mjs'; -import constants from '../generator-constants.mjs'; +import { dockerContainers as elasticDockerContainer } from '../generator-constants.mjs'; import { dockerPlaceholderGenerator, getDockerfileContainers } from '../docker/utils.mjs'; const { OptionNames } = applicationOptions; @@ -65,7 +65,7 @@ export default class BaseDockerGenerator extends BlueprintBaseGenerator { const dockerfile = this.readTemplate(this.jhipsterTemplatePath('../../server/templates/Dockerfile')); this.dockerContainers = this.prepareDependencies( { - ...constants.dockerContainers, + ...elasticDockerContainer, ...getDockerfileContainers(dockerfile), }, dockerPlaceholderGenerator diff --git a/generators/base/generator-base-blueprint.mjs b/generators/base/generator-base-blueprint.mjs index 1d720036292e..6354a22d46e5 100644 --- a/generators/base/generator-base-blueprint.mjs +++ b/generators/base/generator-base-blueprint.mjs @@ -22,14 +22,11 @@ import path from 'path'; import semver from 'semver'; import { packageJson as packagejs } from '../../lib/index.mjs'; -import generatorUtils from '../utils.mjs'; +import { packageNameToNamespace } from '../utils.mjs'; import JHipsterBaseGenerator from './generator-base.mjs'; import { mergeBlueprints, parseBluePrints, loadBlueprintsFromConfiguration, normalizeBlueprintName } from '../../utils/blueprint.mjs'; - import { PRIORITY_NAMES } from './priorities.mjs'; -const { packageNameToNamespace } = generatorUtils; - /** * Base class for a generator that can be extended through a blueprint. * diff --git a/generators/base/generator-base-private.mjs b/generators/base/generator-base-private.mjs index 23dcf8358481..464ba9a743f6 100644 --- a/generators/base/generator-base-private.mjs +++ b/generators/base/generator-base-private.mjs @@ -28,15 +28,14 @@ import https from 'https'; import { databaseTypes, buildToolTypes, fieldTypes, validations } from '../../jdl/jhipster/index.mjs'; import { packageJson as packagejs } from '../../lib/index.mjs'; -import jhipsterUtils from '../utils.mjs'; -import generatorConstants from '../generator-constants.mjs'; +import { getJavadoc, renderContent } from '../utils.mjs'; +import { JAVA_COMPATIBLE_VERSIONS } from '../generator-constants.mjs'; import { stringify } from '../../utils/index.mjs'; import { fieldIsEnum } from '../../utils/field.mjs'; import databaseData from '../sql-constants.mjs'; import { ANGULAR, REACT, VUE } from '../../jdl/jhipster/client-framework-types.js'; import { getDBTypeFromDBValue } from '../server/support/database.mjs'; -const { JAVA_COMPATIBLE_VERSIONS } = generatorConstants; const dbTypes = fieldTypes; const { REQUIRED } = validations; @@ -208,7 +207,7 @@ export default class PrivateBase extends Generator { * @returns class javadoc */ formatAsClassJavadoc(text) { - return jhipsterUtils.getJavadoc(text, 0); + return getJavadoc(text, 0); } /** @@ -219,7 +218,7 @@ export default class PrivateBase extends Generator { * @returns field javadoc */ formatAsFieldJavadoc(text) { - return jhipsterUtils.getJavadoc(text, 4); + return getJavadoc(text, 4); } /** @@ -429,8 +428,7 @@ export default class PrivateBase extends Generator { this.debug(`File ${destination} ignored`); return Promise.resolved(); } - return jhipsterUtils - .renderContent(source, _this, _context, options) + return renderContent(source, _this, _context, options) .then(res => { _this.fs.write(customDestination, res); return customDestination; @@ -454,7 +452,7 @@ export default class PrivateBase extends Generator { render(source, callback, generator, options = {}, context) { const _this = generator || this; const _context = context || _this; - jhipsterUtils.renderContent(source, _this, _context, options, res => { + renderContent(source, _this, _context, options, res => { callback(res); }); } diff --git a/generators/base/generator-base.mjs b/generators/base/generator-base.mjs index 8ec62dfe4f19..d2e59bc8f3fd 100644 --- a/generators/base/generator-base.mjs +++ b/generators/base/generator-base.mjs @@ -29,8 +29,8 @@ import { dirname, join } from 'path'; import { fileURLToPath } from 'url'; import jhipster7Proxy from './jhipster7-proxy.mjs'; -import { packageJson as packagejs } from '../../lib/index.mjs'; -import jhipsterUtils from '../utils.mjs'; +import { packageJson } from '../../lib/index.mjs'; +import { stringHashCode } from '../utils.mjs'; import PrivateBase from './generator-base-private.mjs'; import NeedleApi from '../needle-api.mjs'; import generatorDefaults from '../generator-defaults.mjs'; @@ -57,15 +57,7 @@ import { import databaseData from '../sql-constants.mjs'; import { CUSTOM_PRIORITIES } from './priorities.mjs'; import { GENERATOR_BOOTSTRAP } from '../generator-list.mjs'; -import constants from '../generator-constants.mjs'; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); - -const { defaultConfig, defaultConfigMicroservice } = generatorDefaults; -const { ANGULAR, REACT, VUE, NO: CLIENT_FRAMEWORK_NO } = clientFrameworkTypes; - -const { +import { JHIPSTER_CONFIG_DIR, SERVER_MAIN_SRC_DIR, SERVER_TEST_SRC_DIR, @@ -74,9 +66,15 @@ const { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR, NODE_VERSION, -} = constants; + LANGUAGES, +} from '../generator-constants.mjs'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const { defaultConfig, defaultConfigMicroservice } = generatorDefaults; +const { ANGULAR, REACT, VUE, NO: CLIENT_FRAMEWORK_NO } = clientFrameworkTypes; -const MODULES_HOOK_FILE = `${JHIPSTER_CONFIG_DIR}/modules/jhi-hooks.json`; const GENERATOR_JHIPSTER = 'generator-jhipster'; const { ORACLE, MYSQL, POSTGRESQL, MARIADB, MSSQL, SQL, MONGODB, COUCHBASE, NEO4J, CASSANDRA, H2_MEMORY, H2_DISK } = databaseTypes; @@ -552,7 +550,7 @@ export default class JHipsterBaseGenerator extends PrivateBase { * get all the languages options supported by JHipster */ getAllSupportedLanguageOptions() { - return constants.LANGUAGES; + return LANGUAGES; } /** @@ -1548,13 +1546,13 @@ export default class JHipsterBaseGenerator extends PrivateBase { `npm show ${GENERATOR_JHIPSTER} version --fetch-retries 1 --fetch-retry-mintimeout 500 --fetch-retry-maxtimeout 500`, { silent: true }, (code, stdout, stderr) => { - if (!stderr && semver.lt(packagejs.version, stdout)) { + if (!stderr && semver.lt(packageJson.version, stdout)) { this.log( `${ chalk.yellow(' ______________________________________________________________________________\n\n') + chalk.yellow(' JHipster update available: ') + chalk.green.bold(stdout.replace('\n', '')) + - chalk.gray(` (current: ${packagejs.version})`) + chalk.gray(` (current: ${packageJson.version})`) }\n` ); this.log(chalk.yellow(` Run ${chalk.magenta(`npm install -g ${GENERATOR_JHIPSTER}`)} to update.\n`)); @@ -1605,7 +1603,7 @@ export default class JHipsterBaseGenerator extends PrivateBase { * @param {string} baseName of application */ getHipster(baseName = this.baseName) { - const hash = jhipsterUtils.stringHashCode(baseName); + const hash = stringHashCode(baseName); switch (hash % 4) { case 0: @@ -2171,9 +2169,9 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; dest.backendName = config.backendName; config.nodeDependencies = config.nodeDependencies || { - prettier: packagejs.dependencies.prettier, - 'prettier-plugin-java': packagejs.dependencies['prettier-plugin-java'], - 'prettier-plugin-packagejson': packagejs.dependencies['prettier-plugin-packagejson'], + prettier: packageJson.dependencies.prettier, + 'prettier-plugin-java': packageJson.dependencies['prettier-plugin-java'], + 'prettier-plugin-packagejson': packageJson.dependencies['prettier-plugin-packagejson'], }; dest.nodeDependencies = config.nodeDependencies; @@ -2592,7 +2590,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; } setConfigDefaults(defaults = this.jhipsterConfigWithDefaults) { - const jhipsterVersion = packagejs.version; + const jhipsterVersion = packageJson.version; const baseName = this.getDefaultAppName(); const creationTimestamp = new Date().getTime(); diff --git a/generators/bootstrap-application-base/faker.mts b/generators/bootstrap-application-base/faker.mts index 75978744c305..c9eae8dbb3b1 100644 --- a/generators/bootstrap-application-base/faker.mts +++ b/generators/bootstrap-application-base/faker.mts @@ -21,9 +21,7 @@ import { Faker } from '@faker-js/faker'; import Randexp from 'randexp'; import { languageToJavaLanguage } from '../languages/utils.mjs'; -import utils from '../utils.mjs'; - -const { stringHashCode } = utils; +import { stringHashCode } from '../utils.mjs'; class RandexpWithFaker extends Randexp { faker: Faker; diff --git a/generators/bootstrap-application-base/generator.mts b/generators/bootstrap-application-base/generator.mts index 27ceb3b9201a..ce285d2bd281 100644 --- a/generators/bootstrap-application-base/generator.mts +++ b/generators/bootstrap-application-base/generator.mts @@ -24,13 +24,12 @@ import { prepareFieldForTemplates } from '../../utils/field.mjs'; import { prepareRelationshipForTemplates } from '../../utils/relationship.mjs'; import { stringify } from '../../utils/index.mjs'; import { createUserEntity } from './utils.mjs'; -import constants from '../generator-constants.mjs'; +import { DOCKER_DIR } from '../generator-constants.mjs'; import type { CommonClientServerApplication } from '../base-application/types.mjs'; import { GENERATOR_BOOTSTRAP, GENERATOR_COMMON, GENERATOR_PROJECT_NAME } from '../generator-list.mjs'; import { addFakerToEntity } from './faker.mjs'; import { packageJson } from '../../lib/index.mjs'; -const { DOCKER_DIR } = constants; const { upperFirst } = _; /** diff --git a/generators/bootstrap-application-server/generator.mts b/generators/bootstrap-application-server/generator.mts index 60b0505b7fab..f461b6aeecb8 100644 --- a/generators/bootstrap-application-server/generator.mts +++ b/generators/bootstrap-application-server/generator.mts @@ -20,7 +20,7 @@ import _ from 'lodash'; import BaseApplicationGenerator from '../base-application/index.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION_BASE } from '../generator-list.mjs'; -import constants from '../generator-constants.mjs'; +import { dockerContainers, javaDependencies, CLIENT_DIST_DIR } from '../generator-constants.mjs'; import { loadRequiredConfigIntoEntity, loadRequiredConfigDerivedProperties, @@ -37,8 +37,6 @@ import { GRADLE_VERSION } from '../gradle/constants.mjs'; const { CommonDBTypes } = fieldTypes; const { OAUTH2 } = authenticationTypes; -const { dockerContainers, javaDependencies } = constants; - const { LONG: TYPE_LONG } = CommonDBTypes; /** @@ -63,7 +61,7 @@ export default class BoostrapApplicationServer extends BaseApplicationGenerator< application.backendType = 'Java'; application.temporaryDir = application.buildTool === 'gradle' ? 'build/' : 'target/'; application.buildDir = `${application.temporaryDir}${application.buildTool === 'gradle' ? 'resources/main/' : 'classes/'}`; - application.clientDistDir = `${application.buildDir}${constants.CLIENT_DIST_DIR}`; + application.clientDistDir = `${application.buildDir}${CLIENT_DIST_DIR}`; const pomFile = this.readTemplate(this.jhipsterTemplatePath('../../server/templates/pom.xml')); application.javaDependencies = this.prepareDependencies( diff --git a/generators/bootstrap/generator.mts b/generators/bootstrap/generator.mts index 207ce3d33d75..0eb24cbee2f1 100644 --- a/generators/bootstrap/generator.mts +++ b/generators/bootstrap/generator.mts @@ -28,7 +28,7 @@ import type Environment from 'yeoman-environment'; import BaseGenerator from '../base/index.mjs'; import MultiStepTransform from './multi-step-transform/index.mjs'; import { prettierTransform, generatedAnnotationTransform } from './transforms.mjs'; -import constants from '../generator-constants.mjs'; +import { PRETTIER_EXTENSIONS } from '../generator-constants.mjs'; import { GENERATOR_UPGRADE } from '../generator-list.mjs'; import { PRIORITY_NAMES } from '../base-application/priorities.mjs'; import type { PreConflictsTaskGroup } from '../base/tasks.mjs'; @@ -47,7 +47,6 @@ const { const { State } = memFsEditor as any; const { hasState, setModifiedFileState } = State; -const { PRETTIER_EXTENSIONS } = constants; const TRANSFORM_PRIORITY = BaseGenerator.asPriority(TRANSFORM); const PRE_CONFLICTS_PRIORITY = BaseGenerator.asPriority(PRE_CONFLICTS); diff --git a/generators/ci-cd/generator.mjs b/generators/ci-cd/generator.mjs index 30bb83b2dab2..c069d7b9910b 100644 --- a/generators/ci-cd/generator.mjs +++ b/generators/ci-cd/generator.mjs @@ -24,8 +24,8 @@ import BaseApplicationGenerator from '../base-application/index.mjs'; import generatorDefaults from '../generator-defaults.mjs'; import prompts from './prompts.mjs'; -import statistics from '../statistics.mjs'; -import constants from '../generator-constants.mjs'; +import statistics from '../statistics.cjs'; +import { NODE_VERSION, SERVER_MAIN_RES_DIR, JAVA_VERSION } from '../generator-constants.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION, GENERATOR_CI_CD } from '../generator-list.mjs'; import { buildToolTypes } from '../../jdl/jhipster/index.mjs'; import { REACT } from '../../jdl/jhipster/client-framework-types.js'; @@ -123,12 +123,12 @@ export default class CiCdGenerator extends BaseApplicationGenerator { }, initConstants() { - this.NODE_VERSION = constants.NODE_VERSION; + this.NODE_VERSION = NODE_VERSION; }, getConstants() { - this.SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; - this.JAVA_VERSION = constants.JAVA_VERSION; + this.SERVER_MAIN_RES_DIR = SERVER_MAIN_RES_DIR; + this.JAVA_VERSION = JAVA_VERSION; }, }; } diff --git a/generators/cleanup.mjs b/generators/cleanup.mjs index 90fcf6b9f95f..5aa6bf3391b8 100644 --- a/generators/cleanup.mjs +++ b/generators/cleanup.mjs @@ -18,13 +18,9 @@ */ import { ANGULAR, REACT, VUE } from '../jdl/jhipster/client-framework-types.js'; -import constants from './generator-constants.mjs'; +import { SERVER_MAIN_RES_DIR, ANGULAR_DIR, REACT_DIR, VUE_DIR, CLIENT_WEBPACK_DIR, DOCKER_DIR } from './generator-constants.mjs'; import { languageSnakeCase, languageToJavaLanguage } from './languages/utils.mjs'; -export { cleanupOldServerFiles } from './server/cleanup.mjs'; - -const { SERVER_MAIN_RES_DIR, ANGULAR_DIR, REACT_DIR, VUE_DIR, CLIENT_WEBPACK_DIR } = constants; - /** * Removes files that where generated in previous JHipster versions and therefore * need to be removed. @@ -86,8 +82,8 @@ export function cleanupOldFiles(generator, data) { generator.authenticationType === 'oauth2' && generator.applicationType === 'microservice' ) { - generator.removeFolder(`${constants.DOCKER_DIR}realm-config`); - generator.removeFile(`${constants.DOCKER_DIR}keycloak.yml`); + generator.removeFolder(`${DOCKER_DIR}realm-config`); + generator.removeFile(`${DOCKER_DIR}keycloak.yml`); } if (generator.isJhipsterVersionLessThan('6.0.0')) { generator.removeFolder(`${data.clientSrcDir}app/shared/layout/header/menus`); diff --git a/generators/client/entity-files.mjs b/generators/client/entity-files.mjs index 71e0f4dc9391..8de9fb9cde09 100644 --- a/generators/client/entity-files.mjs +++ b/generators/client/entity-files.mjs @@ -16,10 +16,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import utils from '../utils.mjs'; -import constants from '../generator-constants.mjs'; +import { getEnumInfo } from '../utils.mjs'; +import { CLIENT_MAIN_SRC_DIR } from '../generator-constants.mjs'; -const { CLIENT_MAIN_SRC_DIR } = constants; const CLIENT_COMMON_TEMPLATES_DIR = 'entity/common'; async function addEnumerationFiles({ application, entity }) { @@ -27,7 +26,7 @@ async function addEnumerationFiles({ application, entity }) { if (field.fieldIsEnum === true) { const { enumFileName } = field; const enumInfo = { - ...utils.getEnumInfo(field, entity.clientRootFolder), + ...getEnumInfo(field, entity.clientRootFolder), frontendAppName: application.frontendAppName, packageName: application.packageName, webappEnumerationsDir: application.webappEnumerationsDir, diff --git a/generators/client/generator.mjs b/generators/client/generator.mjs index e2435fcfcf07..e23c94a7fb22 100644 --- a/generators/client/generator.mjs +++ b/generators/client/generator.mjs @@ -27,8 +27,8 @@ import { writeFiles as writeCommonFiles } from './files-common.mjs'; import { writeEnumerationFiles } from './entity-files.mjs'; -import constants from '../generator-constants.mjs'; -import statistics from '../statistics.mjs'; +import { LOGIN_REGEX_JS } from '../generator-constants.mjs'; +import statistics from '../statistics.cjs'; import generatorDefaults from '../generator-defaults.mjs'; import { GENERATOR_BOOTSTRAP_APPLICATION, GENERATOR_CYPRESS, GENERATOR_COMMON, GENERATOR_CLIENT } from '../generator-list.mjs'; @@ -200,7 +200,7 @@ export default class JHipsterClientGenerator extends BaseApplicationGenerator { }, prepareForTemplates({ application }) { - application.webappLoginRegExp = constants.LOGIN_REGEX_JS; + application.webappLoginRegExp = LOGIN_REGEX_JS; }, }); } diff --git a/generators/client/needle-api/needle-client-angular.mjs b/generators/client/needle-api/needle-client-angular.mjs index f4cd1e5ae082..6a8eeddada08 100644 --- a/generators/client/needle-api/needle-client-angular.mjs +++ b/generators/client/needle-api/needle-client-angular.mjs @@ -19,8 +19,8 @@ import chalk from 'chalk'; import _ from 'lodash'; import needleClientBase from './needle-client.mjs'; -import constants from '../../generator-constants.mjs'; -import jhipsterUtils from '../../utils.mjs'; +import { LINE_LENGTH } from '../../generator-constants.mjs'; +import { checkStringInFile, replaceContent, checkRegexInFile } from '../../utils.mjs'; export default class extends needleClientBase { addGlobalSCSSStyle(style, comment) { @@ -107,7 +107,7 @@ export default class extends needleClientBase { _generateImportStatement(appName, angularName, folderName, fileName) { let importStatement = `|import { ${appName}${angularName}Module } from './${folderName}/${fileName}.module';`; - if (importStatement.length > constants.LINE_LENGTH) { + if (importStatement.length > LINE_LENGTH) { // prettier-ignore importStatement = `|import { | ${appName}${angularName}Module @@ -124,9 +124,9 @@ export default class extends needleClientBase { addIcon(iconName) { const iconsPath = `${this.clientSrcDir}app/config/font-awesome-icons.ts`; const iconImport = `fa${this.generator.upperFirstCamelCase(iconName)}`; - if (!jhipsterUtils.checkRegexInFile(iconsPath, new RegExp(`\\b${iconImport}\\b`), this.generator)) { + if (!checkRegexInFile(iconsPath, new RegExp(`\\b${iconImport}\\b`), this.generator)) { try { - jhipsterUtils.replaceContent( + replaceContent( { file: iconsPath, pattern: /(\r?\n)(\s*)\/\/ jhipster-needle-add-icon-import/g, @@ -208,7 +208,7 @@ export default class extends needleClientBase { } _addRoute(route, modulePath, moduleName, needleName, filePath, pageTitle) { - const isRouteAlreadyAdded = jhipsterUtils.checkStringInFile(filePath, `path: '${route}'`, this.generator); + const isRouteAlreadyAdded = checkStringInFile(filePath, `path: '${route}'`, this.generator); if (isRouteAlreadyAdded) { return; } @@ -232,7 +232,7 @@ export default class extends needleClientBase { addEntityToModule(entityAngularName, entityFolderName, entityFileName, entityUrl, microserviceName, pageTitle) { const entityModulePath = `${this.clientSrcDir}app/entities/entity-routing.module.ts`; try { - const isSpecificEntityAlreadyGenerated = jhipsterUtils.checkStringInFile(entityModulePath, `path: '${entityUrl}'`, this.generator); + const isSpecificEntityAlreadyGenerated = checkStringInFile(entityModulePath, `path: '${entityUrl}'`, this.generator); if (!isSpecificEntityAlreadyGenerated) { const modulePath = `./${entityFolderName}/${entityFileName}.routes`; diff --git a/generators/client/needle-api/needle-client-vue.mjs b/generators/client/needle-api/needle-client-vue.mjs index 6709151eb058..1dcc27209bab 100644 --- a/generators/client/needle-api/needle-client-vue.mjs +++ b/generators/client/needle-api/needle-client-vue.mjs @@ -18,7 +18,7 @@ */ import chalk from 'chalk'; import _ from 'lodash'; -import jhipsterUtils from '../../utils.mjs'; +import { checkStringInFile } from '../../utils.mjs'; import needleClientBase from './needle-client.mjs'; export default class extends needleClientBase { @@ -26,11 +26,7 @@ export default class extends needleClientBase { const errorMessage = `${chalk.yellow('Reference to ') + routerName} ${chalk.yellow('not added to menu.\n')}`; const filePath = `${this.clientSrcDir}/app/entities/entities-menu.vue`; - const isSpecificEntityAlreadyGenerated = jhipsterUtils.checkStringInFile( - filePath, - ``, - this.generator - ); + const isSpecificEntityAlreadyGenerated = checkStringInFile(filePath, ``, this.generator); if (isSpecificEntityAlreadyGenerated) { return; } @@ -52,7 +48,7 @@ export default class extends needleClientBase { const errorMessage = `${chalk.yellow('Reference to entity ') + entityName} ${chalk.yellow('not added to router entities import.\n')}`; const filePath = `${this.clientSrcDir}/app/router/entities.ts`; - const isSpecificEntityAlreadyGenerated = jhipsterUtils.checkStringInFile( + const isSpecificEntityAlreadyGenerated = checkStringInFile( filePath, `import('@/entities/${folderName}/${fileName}.vue');`, this.generator @@ -90,7 +86,7 @@ export default class extends needleClientBase { const errorMessage = `${chalk.yellow('Reference to entity ') + entityName} ${chalk.yellow('not added to router entities.\n')}`; const filePath = `${this.clientSrcDir}/app/router/entities.ts`; - const isSpecificEntityAlreadyGenerated = jhipsterUtils.checkStringInFile(filePath, `path: '${entityFileName}'`, this.generator); + const isSpecificEntityAlreadyGenerated = checkStringInFile(filePath, `path: '${entityFileName}'`, this.generator); if (isSpecificEntityAlreadyGenerated) { return; } diff --git a/generators/client/needle-api/needle-client-webpack.mjs b/generators/client/needle-api/needle-client-webpack.mjs index cc7a93c8ddc9..0dffa9165f85 100644 --- a/generators/client/needle-api/needle-client-webpack.mjs +++ b/generators/client/needle-api/needle-client-webpack.mjs @@ -17,16 +17,14 @@ * limitations under the License. */ import needleClient from './needle-client.mjs'; -import constants from '../../generator-constants.mjs'; +import { CLIENT_WEBPACK_DIR } from '../../generator-constants.mjs'; +import { clientFrameworkTypes } from '../../../jdl/jhipster/index.mjs'; -const CLIENT_WEBPACK_DIR = constants.CLIENT_WEBPACK_DIR; -const SUPPORTED_CLIENT_FRAMEWORKS = constants.SUPPORTED_CLIENT_FRAMEWORKS; +const { ANGULAR } = clientFrameworkTypes; export default class extends needleClient { _getWebpackFile(clientFramework = this.clientFramework) { - return this.clientFramework === SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR - ? `${CLIENT_WEBPACK_DIR}/webpack.custom.js` - : `${CLIENT_WEBPACK_DIR}/webpack.common.js`; + return this.clientFramework === ANGULAR ? `${CLIENT_WEBPACK_DIR}/webpack.custom.js` : `${CLIENT_WEBPACK_DIR}/webpack.common.js`; } copyExternalAssets(source, target, clientFramework) { diff --git a/generators/client/utils.mjs b/generators/client/utils.mjs index e3d4f5ad9d06..6752f09c10bc 100644 --- a/generators/client/utils.mjs +++ b/generators/client/utils.mjs @@ -1,6 +1,4 @@ -import constants from '../generator-constants.mjs'; - -const { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR } = constants; +import { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR } from '../generator-constants.mjs'; export const replaceEntityFilePath = (data, filepath) => filepath diff --git a/generators/cloudfoundry/generator.mjs b/generators/cloudfoundry/generator.mjs index f74f9577e480..364bde15f790 100644 --- a/generators/cloudfoundry/generator.mjs +++ b/generators/cloudfoundry/generator.mjs @@ -24,8 +24,8 @@ import glob from 'glob'; import BaseGenerator from '../base/index.mjs'; import prompts from './prompts.mjs'; -import statistics from '../statistics.mjs'; -import constants from '../generator-constants.mjs'; +import statistics from '../statistics.cjs'; +import { CLIENT_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; import { GENERATOR_CLOUDFOUNDRY } from '../generator-list.mjs'; import { cacheTypes, buildToolTypes, databaseTypes } from '../../jdl/jhipster/index.mjs'; @@ -62,7 +62,7 @@ export default class CloudfoundryGenerator extends BaseGenerator { }, getConfig() { const configuration = this.config; - this.env.options.appPath = configuration.get('appPath') || constants.CLIENT_MAIN_SRC_DIR; + this.env.options.appPath = configuration.get('appPath') || CLIENT_MAIN_SRC_DIR; this.cacheProvider = this.cacheProvider || NO_CACHE_PROVIDER; this.enableHibernateCache = this.enableHibernateCache && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider); this.frontendAppName = this.getFrontendAppName(); @@ -96,7 +96,7 @@ export default class CloudfoundryGenerator extends BaseGenerator { if (this.abort) return; this.log(chalk.bold('\nCreating Cloud Foundry deployment files')); this.template('manifest.yml.ejs', 'deploy/cloudfoundry/manifest.yml'); - this.template('application-cloudfoundry.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}config/application-cloudfoundry.yml`); + this.template('application-cloudfoundry.yml.ejs', `${SERVER_MAIN_RES_DIR}config/application-cloudfoundry.yml`); }, checkInstallation() { diff --git a/generators/common/generator.mjs b/generators/common/generator.mjs index 9226b2e2caf2..28222b048934 100644 --- a/generators/common/generator.mjs +++ b/generators/common/generator.mjs @@ -22,10 +22,18 @@ import _ from 'lodash'; import BaseApplicationGenerator from '../base-application/index.mjs'; import { writeFiles, prettierConfigFiles } from './files.mjs'; -import constants from '../generator-constants.mjs'; +import { + MAIN_DIR, + TEST_DIR, + SERVER_MAIN_RES_DIR, + JHIPSTER_DOCUMENTATION_URL, + JHIPSTER_DOCUMENTATION_ARCHIVE_PATH, +} from '../generator-constants.mjs'; +import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; import { packageJson } from '../../lib/index.mjs'; import { GENERATOR_COMMON, GENERATOR_BOOTSTRAP_APPLICATION, GENERATOR_GIT } from '../generator-list.mjs'; +const { REACT, ANGULAR, VUE } = clientFrameworkTypes; /** * @class * @extends {BaseApplicationGenerator} @@ -124,15 +132,15 @@ export default class CommonGenerator extends BaseApplicationGenerator { return { setupConstants({ application }) { // Make constants available in templates - application.MAIN_DIR = constants.MAIN_DIR; - application.TEST_DIR = constants.TEST_DIR; - application.SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; - application.ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR; - application.REACT = constants.SUPPORTED_CLIENT_FRAMEWORKS.REACT; + application.MAIN_DIR = MAIN_DIR; + application.TEST_DIR = TEST_DIR; + application.SERVER_MAIN_RES_DIR = SERVER_MAIN_RES_DIR; + application.ANGULAR = ANGULAR; + application.REACT = REACT; // Make documentation URL available in templates - application.DOCUMENTATION_URL = constants.JHIPSTER_DOCUMENTATION_URL; - application.DOCUMENTATION_ARCHIVE_PATH = constants.JHIPSTER_DOCUMENTATION_ARCHIVE_PATH; + application.DOCUMENTATION_URL = JHIPSTER_DOCUMENTATION_URL; + application.DOCUMENTATION_ARCHIVE_PATH = JHIPSTER_DOCUMENTATION_ARCHIVE_PATH; }, }; } diff --git a/generators/couchbase/entity-files.mjs b/generators/couchbase/entity-files.mjs index ecd8fb49566a..8acb114b8f13 100644 --- a/generators/couchbase/entity-files.mjs +++ b/generators/couchbase/entity-files.mjs @@ -16,10 +16,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import constants from '../generator-constants.mjs'; +import { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; import { moveToJavaEntityPackageSrcDir } from '../server/utils.mjs'; -const { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR } = constants; export const entityFiles = { dbChangelog: [ { diff --git a/generators/couchbase/files.mjs b/generators/couchbase/files.mjs index ce00fd460b84..3347510626fa 100644 --- a/generators/couchbase/files.mjs +++ b/generators/couchbase/files.mjs @@ -16,10 +16,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import constants from '../generator-constants.mjs'; +import { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_SRC_DIR } from '../generator-constants.mjs'; import { moveToJavaPackageSrcDir, moveToJavaPackageTestDir } from '../server/utils.mjs'; -const { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_SRC_DIR } = constants; export const couchbaseFiles = { serverJavaConfig: [ { diff --git a/generators/cypress/files.mts b/generators/cypress/files.mts index 64089c820f77..3709e51a75c4 100644 --- a/generators/cypress/files.mts +++ b/generators/cypress/files.mts @@ -16,13 +16,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import constants from '../generator-constants.mjs'; +import { CLIENT_TEST_SRC_DIR } from '../generator-constants.mjs'; import type { WriteFileSection } from '../base/api.mjs'; import type CypressGenerator from './generator.mjs'; import type { CypressApplication } from './types.mjs'; -const { CLIENT_TEST_SRC_DIR } = constants; const CYPRESS_TEMPLATE_SOURCE_DIR = `${CLIENT_TEST_SRC_DIR}cypress/`; export const cypressFiles: WriteFileSection = { diff --git a/generators/cypress/generator.mts b/generators/cypress/generator.mts index 65f63d04224f..84e9e77dc2db 100644 --- a/generators/cypress/generator.mts +++ b/generators/cypress/generator.mts @@ -19,10 +19,11 @@ import { faker } from '@faker-js/faker/locale/en'; import _ from 'lodash'; -import utils from '../utils.mjs'; +import { stringHashCode } from '../utils.mjs'; import BaseApplicationGenerator from '../base-application/index.mjs'; import { cypressFiles, cypressEntityFiles } from './files.mjs'; -import constants from '../generator-constants.mjs'; +import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; +import { CLIENT_MAIN_SRC_DIR } from '../generator-constants.mjs'; import { GENERATOR_CYPRESS, GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs'; import type { CypressApplication } from './types.mjs'; @@ -36,7 +37,7 @@ import type { WritingTaskGroup, } from '../base-application/tasks.mjs'; -const { stringHashCode } = utils; +const { ANGULAR } = clientFrameworkTypes; /** * @class @@ -68,7 +69,7 @@ export default class CypressGenerator extends BaseApplicationGenerator { return [ `${DOCKER_DIR}central-server-config/localhost-config/application.yml`, diff --git a/generators/docker/files.mjs b/generators/docker/files.mjs index c8fba0ae586e..d64d4b78b396 100644 --- a/generators/docker/files.mjs +++ b/generators/docker/files.mjs @@ -1,6 +1,4 @@ -import constants from '../generator-constants.mjs'; - -const { DOCKER_DIR } = constants; +import { DOCKER_DIR } from '../generator-constants.mjs'; // eslint-disable-next-line import/prefer-default-export export const dockerFiles = { diff --git a/generators/docker/generator.mjs b/generators/docker/generator.mjs index 263cf23bd1ed..5015727547c0 100644 --- a/generators/docker/generator.mjs +++ b/generators/docker/generator.mjs @@ -23,9 +23,8 @@ import { createDockerComposeFile, createDockerExtendedServices } from '../base-d 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'; -import utils from '../utils.mjs'; +import { stringHashCode } from '../utils.mjs'; -const { stringHashCode } = utils; /** * @class * @extends {BaseApplicationGenerator} diff --git a/generators/entities/generator.mjs b/generators/entities/generator.mjs index b38977eab277..a25b78916030 100644 --- a/generators/entities/generator.mjs +++ b/generators/entities/generator.mjs @@ -17,11 +17,9 @@ * limitations under the License. */ import BaseGenerator from '../base/index.mjs'; -import constants from '../generator-constants.mjs'; +import { JHIPSTER_CONFIG_DIR } from '../generator-constants.mjs'; import { GENERATOR_ENTITIES, GENERATOR_APP } from '../generator-list.mjs'; -const { JHIPSTER_CONFIG_DIR } = constants; - export default class EntitiesGenerator extends BaseGenerator { constructor(args, options, features) { super(args, options, { unique: 'namespace', ...features }); diff --git a/generators/entities/generator.spec.mts b/generators/entities/generator.spec.mts index 7f2afdbf0681..7af7b37ea54d 100644 --- a/generators/entities/generator.spec.mts +++ b/generators/entities/generator.spec.mts @@ -21,12 +21,11 @@ import lodash from 'lodash'; import { basename, dirname } from 'path'; import { fileURLToPath } from 'url'; -import constants from '../generator-constants.mjs'; +import { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR, CLIENT_MAIN_SRC_DIR } from '../generator-constants.mjs'; import { testBlueprintSupport } from '../../test/support/tests.mjs'; import Generator from './generator.mjs'; import { skipPrettierHelpers as helpers } from '../../test/support/helpers.mjs'; -const { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR, CLIENT_MAIN_SRC_DIR } = constants; const { snakeCase } = lodash; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); diff --git a/generators/entity/generator.mjs b/generators/entity/generator.mjs index b2c36ce8fafa..1d1ce3673962 100644 --- a/generators/entity/generator.mjs +++ b/generators/entity/generator.mjs @@ -25,19 +25,15 @@ import path from 'path'; import BaseGenerator from '../base/index.mjs'; import prompts from './prompts.mjs'; import generatorDefaults from '../generator-defaults.mjs'; -import constants from '../generator-constants.mjs'; +import { JHIPSTER_CONFIG_DIR, ANGULAR_DIR } from '../generator-constants.mjs'; import { applicationTypes, clientFrameworkTypes, reservedKeywords } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_ENTITIES, GENERATOR_ENTITY } from '../generator-list.mjs'; const { defaultConfig } = generatorDefaults; const { GATEWAY, MICROSERVICE } = applicationTypes; -const { NO: CLIENT_FRAMEWORK_NO } = clientFrameworkTypes; +const { NO: CLIENT_FRAMEWORK_NO, ANGULAR } = clientFrameworkTypes; const { isReservedClassName } = reservedKeywords; -/* constants used throughout */ -const { JHIPSTER_CONFIG_DIR } = constants; -const ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR; - export default class EntityGenerator extends BaseGenerator { constructor(args, options, features) { super(args, options, { unique: 'argument', ...features }); @@ -317,10 +313,10 @@ export default class EntityGenerator extends BaseGenerator { const context = this.context; const entityName = context.name; if (this.isJhipsterVersionLessThan('5.0.0')) { - this.removeFile(`${constants.ANGULAR_DIR}entities/${entityName}/${entityName}.model.ts`); + this.removeFile(`${ANGULAR_DIR}entities/${entityName}/${entityName}.model.ts`); } if (this.isJhipsterVersionLessThan('6.3.0') && context.clientFramework === ANGULAR) { - this.removeFile(`${constants.ANGULAR_DIR}entities/${context.entityFolderName}/index.ts`); + this.removeFile(`${ANGULAR_DIR}entities/${context.entityFolderName}/index.ts`); } }, }; diff --git a/generators/entity/prompts.mjs b/generators/entity/prompts.mjs index af3554b6e37e..e819bd0cbeac 100644 --- a/generators/entity/prompts.mjs +++ b/generators/entity/prompts.mjs @@ -19,14 +19,21 @@ import chalk from 'chalk'; import fs from 'fs'; import _ from 'lodash'; -import constants from '../generator-constants.mjs'; -import { reservedKeywords, databaseTypes, applicationTypes, entityOptions, fieldTypes, validations } from '../../jdl/jhipster/index.mjs'; +import { + reservedKeywords, + databaseTypes, + applicationTypes, + entityOptions, + fieldTypes, + validations, + clientFrameworkTypes, +} from '../../jdl/jhipster/index.mjs'; const { isReservedPaginationWords, isReservedFieldName, isReservedTableName } = reservedKeywords; const { CASSANDRA, SQL } = databaseTypes; const { GATEWAY } = applicationTypes; const { FilteringTypes, MapperTypes, ServiceTypes, PaginationTypes } = entityOptions; - +const { ANGULAR, REACT } = clientFrameworkTypes; const { JPA_METAMODEL } = FilteringTypes; const NO_FILTERING = FilteringTypes.NO; const { INFINITE_SCROLL, PAGINATION } = PaginationTypes; @@ -37,9 +44,6 @@ const { MAPSTRUCT } = MapperTypes; const NO_MAPPER = MapperTypes.NO; const NO_DATABASE = databaseTypes.NO; -const ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR; -const REACT = constants.SUPPORTED_CLIENT_FRAMEWORKS.REACT; - const { CommonDBTypes, RelationalOnlyDBTypes, BlobTypes } = fieldTypes; const { BIG_DECIMAL, BOOLEAN, DOUBLE, DURATION, ENUM, FLOAT, INTEGER, INSTANT, LOCAL_DATE, LONG, STRING, UUID, ZONED_DATE_TIME } = diff --git a/generators/export-jdl/generator.mts b/generators/export-jdl/generator.mts index 0f408d6ad5fe..bdde6082cfb7 100644 --- a/generators/export-jdl/generator.mts +++ b/generators/export-jdl/generator.mts @@ -20,7 +20,7 @@ import chalk from 'chalk'; import BaseGenerator from '../base/index.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import { GENERATOR_EXPORT_JDL } from '../generator-list.mjs'; import applicationOptions from '../../jdl/jhipster/application-options.js'; import JSONToJDLConverter from '../../jdl/converters/json-to-jdl-converter.js'; diff --git a/generators/gae/generator.mjs b/generators/gae/generator.mjs index 0cf841830b9b..a3243543ac8a 100644 --- a/generators/gae/generator.mjs +++ b/generators/gae/generator.mjs @@ -26,9 +26,9 @@ import _ from 'lodash'; import BaseGenerator from '../base/index.mjs'; import { GENERATOR_GAE } from '../generator-list.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import dockerPrompts from '../base-docker/docker-prompts.mjs'; -import constants from '../generator-constants.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'; const cacheProviders = cacheTypes; @@ -102,7 +102,7 @@ export default class GaeGenerator extends BaseGenerator { loadConfig() { const configuration = this.config; - this.env.options.appPath = configuration.get('appPath') || constants.CLIENT_MAIN_SRC_DIR; + this.env.options.appPath = configuration.get('appPath') || CLIENT_MAIN_SRC_DIR; this.mainClass = this.getMainClassName(); this.cacheProvider = this.cacheProvider || NO_CACHE_PROVIDER; this.enableHibernateCache = this.enableHibernateCache && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider); @@ -772,11 +772,11 @@ export default class GaeGenerator extends BaseGenerator { this.log(chalk.bold('\nCreating Google App Engine deployment files')); - this.template('app.yaml.ejs', `${constants.MAIN_DIR}/appengine/app.yaml`); + this.template('app.yaml.ejs', `${MAIN_DIR}/appengine/app.yaml`); if (this.applicationType === GATEWAY) { - this.template('dispatch.yaml.ejs', `${constants.MAIN_DIR}/appengine/dispatch.yaml`); + this.template('dispatch.yaml.ejs', `${MAIN_DIR}/appengine/dispatch.yaml`); } - this.template('application-prod-gae.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/application-prod-gae.yml`); + this.template('application-prod-gae.yml.ejs', `${SERVER_MAIN_RES_DIR}/config/application-prod-gae.yml`); if (this.buildTool === 'gradle') { this.template('gae.gradle.ejs', 'gradle/gae.gradle'); } diff --git a/generators/generate-blueprint/files.mjs b/generators/generate-blueprint/files.mjs index ac70ebfdb0a1..e90c1a6d31fc 100644 --- a/generators/generate-blueprint/files.mjs +++ b/generators/generate-blueprint/files.mjs @@ -37,7 +37,7 @@ export const files = { }, { condition: ctx => ctx.commands.length > 0, - templates: ['cli/commands.cjs'], + templates: ['cli/commands.mjs'], }, ], }; diff --git a/generators/generator-constants.mjs b/generators/generator-constants.mjs index fcc2c20e7bb9..ba5e1addfd6d 100644 --- a/generators/generator-constants.mjs +++ b/generators/generator-constants.mjs @@ -17,24 +17,24 @@ * limitations under the License. */ // Version of Java -const JAVA_VERSION = '17'; -const JAVA_COMPATIBLE_VERSIONS = ['17', '18', '19']; +export const JAVA_VERSION = '17'; +export const JAVA_COMPATIBLE_VERSIONS = ['17', '18', '19']; /** * Manually updated java dependencies * @type {Record} */ -const javaDependencies = {}; +export const javaDependencies = {}; Object.freeze(javaDependencies); // The version should be coherent with the one from spring-data-elasticsearch project -const ELATICSEARCH_TAG = '8.5.3'; -const ELATICSEARCH_IMAGE = 'docker.elastic.co/elasticsearch/elasticsearch'; +export const ELATICSEARCH_TAG = '8.5.3'; +export const ELATICSEARCH_IMAGE = 'docker.elastic.co/elasticsearch/elasticsearch'; /** * Manually updated docker containers */ -const dockerContainers = { +export const dockerContainers = { elasticsearchTag: ELATICSEARCH_TAG, elasticsearchImage: ELATICSEARCH_IMAGE, elasticsearch: `${ELATICSEARCH_IMAGE}:${ELATICSEARCH_TAG}`, @@ -42,55 +42,49 @@ const dockerContainers = { Object.freeze(dockerContainers); // Version of Node, NPM -const NODE_VERSION = '16.17.0'; -const OPENAPI_GENERATOR_CLI_VERSION = '2.5.1'; +export const NODE_VERSION = '16.17.0'; +export const OPENAPI_GENERATOR_CLI_VERSION = '2.5.1'; // Libraries version -const JHIPSTER_DEPENDENCIES_VERSION = '8.0.0-SNAPSHOT'; +export const JHIPSTER_DEPENDENCIES_VERSION = '8.0.0-SNAPSHOT'; // The spring-boot version should match the one managed by https://mvnrepository.com/artifact/tech.jhipster/jhipster-dependencies/JHIPSTER_DEPENDENCIES_VERSION -const SPRING_BOOT_VERSION = '3.0.1'; -const SPRING_CLOUD_VERSION = '2022.0.0'; -const HIBERNATE_VERSION = '6.1.6.Final'; -const JACOCO_VERSION = '0.8.8'; -const JACKSON_DATABIND_NULLABLE_VERSION = '0.2.4'; +export const SPRING_BOOT_VERSION = '3.0.1'; +export const SPRING_CLOUD_VERSION = '2022.0.0'; +export const HIBERNATE_VERSION = '6.1.6.Final'; +export const JACOCO_VERSION = '0.8.8'; +export const JACKSON_DATABIND_NULLABLE_VERSION = '0.2.4'; // Kubernetes versions -const KUBERNETES_CORE_API_VERSION = 'v1'; -const KUBERNETES_BATCH_API_VERSION = 'batch/v1'; -const KUBERNETES_DEPLOYMENT_API_VERSION = 'apps/v1'; -const KUBERNETES_STATEFULSET_API_VERSION = 'apps/v1'; -const KUBERNETES_INGRESS_API_VERSION = 'networking.k8s.io/v1'; -const KUBERNETES_ISTIO_NETWORKING_API_VERSION = 'networking.istio.io/v1beta1'; -const KUBERNETES_RBAC_API_VERSION = 'rbac.authorization.k8s.io/v1'; +export const KUBERNETES_CORE_API_VERSION = 'v1'; +export const KUBERNETES_BATCH_API_VERSION = 'batch/v1'; +export const KUBERNETES_DEPLOYMENT_API_VERSION = 'apps/v1'; +export const KUBERNETES_STATEFULSET_API_VERSION = 'apps/v1'; +export const KUBERNETES_INGRESS_API_VERSION = 'networking.k8s.io/v1'; +export const KUBERNETES_ISTIO_NETWORKING_API_VERSION = 'networking.istio.io/v1beta1'; +export const KUBERNETES_RBAC_API_VERSION = 'rbac.authorization.k8s.io/v1'; // Helm versions -const HELM_KAFKA = '^0.20.1'; -const HELM_ELASTICSEARCH = '^1.32.0'; -const HELM_PROMETHEUS = '^9.2.0'; -const HELM_GRAFANA = '^4.0.0'; -const HELM_MYSQL = '^1.4.0'; -const HELM_MARIADB = '^6.12.2'; -const HELM_POSTGRESQL = '^6.5.3'; -const HELM_MOGODB_REPLICASET = '^3.10.1'; -const HELM_COUCHBASE_OPERATOR = '^2.2.1'; +export const HELM_KAFKA = '^0.20.1'; +export const HELM_ELASTICSEARCH = '^1.32.0'; +export const HELM_PROMETHEUS = '^9.2.0'; +export const HELM_GRAFANA = '^4.0.0'; +export const HELM_MYSQL = '^1.4.0'; +export const HELM_MARIADB = '^6.12.2'; +export const HELM_POSTGRESQL = '^6.5.3'; +export const HELM_MOGODB_REPLICASET = '^3.10.1'; +export const HELM_COUCHBASE_OPERATOR = '^2.2.1'; // all constants used throughout all generators -const LOGIN_REGEX = '^(?>[a-zA-Z0-9!$&*+=?^_`{|}~.-]+@[a-zA-Z0-9-]+(?:\\\\.[a-zA-Z0-9-]+)*)|(?>[_.@A-Za-z0-9-]+)$'; +export const LOGIN_REGEX = '^(?>[a-zA-Z0-9!$&*+=?^_`{|}~.-]+@[a-zA-Z0-9-]+(?:\\\\.[a-zA-Z0-9-]+)*)|(?>[_.@A-Za-z0-9-]+)$'; // JS does not support atomic groups -const LOGIN_REGEX_JS = '^[a-zA-Z0-9!$&*+=?^_`{|}~.-]+@[a-zA-Z0-9-]+(?:\\\\.[a-zA-Z0-9-]+)*$|^[_.@A-Za-z0-9-]+$'; - -const MAIN_DIR = 'src/main/'; -const TEST_DIR = 'src/test/'; - -// Note: this will be prepended with 'target/classes' for Maven, or with 'build/resources/main' for Gradle. -const CLIENT_DIST_DIR = 'static/'; +export const LOGIN_REGEX_JS = '^[a-zA-Z0-9!$&*+=?^_`{|}~.-]+@[a-zA-Z0-9-]+(?:\\\\.[a-zA-Z0-9-]+)*$|^[_.@A-Za-z0-9-]+$'; // documentation constants -const JHIPSTER_DOCUMENTATION_URL = 'https://www.jhipster.tech'; -const JHIPSTER_DOCUMENTATION_ARCHIVE_PATH = '/documentation-archive/'; +export const JHIPSTER_DOCUMENTATION_URL = 'https://www.jhipster.tech'; +export const JHIPSTER_DOCUMENTATION_ARCHIVE_PATH = '/documentation-archive/'; -const LANGUAGES = [ +export const LANGUAGES = [ { name: 'Albanian', dispName: 'Shqip', @@ -222,75 +216,25 @@ const LANGUAGES = [ }, { name: 'Vietnamese', dispName: 'Tiếng Việt', value: 'vi' }, ]; +export const MAIN_DIR = 'src/main/'; +export const TEST_DIR = 'src/test/'; -const constants = { - GENERATOR_JHIPSTER: 'generator-jhipster', - JHIPSTER_CONFIG_DIR: '.jhipster', - DOCKER_DIR: `${MAIN_DIR}docker/`, - LINE_LENGTH: 180, - LANGUAGES, - - MAIN_DIR, - TEST_DIR, - - LOGIN_REGEX, - LOGIN_REGEX_JS, - // supported client frameworks - SUPPORTED_CLIENT_FRAMEWORKS: { ANGULAR: 'angular', REACT: 'react', VUE: 'vue' }, - - CLIENT_MAIN_SRC_DIR: `${MAIN_DIR}webapp/`, - CLIENT_TEST_SRC_DIR: `${TEST_DIR}javascript/`, - CLIENT_WEBPACK_DIR: 'webpack/', - CLIENT_DIST_DIR, - ANGULAR_DIR: `${MAIN_DIR}webapp/app/`, - REACT_DIR: `${MAIN_DIR}webapp/app/`, - VUE_DIR: `${MAIN_DIR}webapp/app/`, - - SERVER_MAIN_SRC_DIR: `${MAIN_DIR}java/`, - SERVER_MAIN_RES_DIR: `${MAIN_DIR}resources/`, - SERVER_TEST_SRC_DIR: `${TEST_DIR}java/`, - SERVER_TEST_RES_DIR: `${TEST_DIR}resources/`, - PRETTIER_EXTENSIONS: 'md,json,yml,html,cjs,mjs,js,ts,tsx,css,scss,vue,svelte,java', - - JHIPSTER_DOCUMENTATION_URL, - JHIPSTER_DOCUMENTATION_ARCHIVE_PATH, - - JAVA_VERSION, - JAVA_COMPATIBLE_VERSIONS, - - // NPM - NODE_VERSION, - OPENAPI_GENERATOR_CLI_VERSION, - - // Libraries - JHIPSTER_DEPENDENCIES_VERSION, - SPRING_BOOT_VERSION, - SPRING_CLOUD_VERSION, - HIBERNATE_VERSION, - JACOCO_VERSION, - JACKSON_DATABIND_NULLABLE_VERSION, - - // Kubernetes - KUBERNETES_CORE_API_VERSION, - KUBERNETES_BATCH_API_VERSION, - KUBERNETES_DEPLOYMENT_API_VERSION, - KUBERNETES_STATEFULSET_API_VERSION, - KUBERNETES_INGRESS_API_VERSION, - KUBERNETES_ISTIO_NETWORKING_API_VERSION, - KUBERNETES_RBAC_API_VERSION, - - // Helm - HELM_KAFKA, - HELM_ELASTICSEARCH, - HELM_PROMETHEUS, - HELM_GRAFANA, - HELM_MYSQL, - HELM_MARIADB, - HELM_POSTGRESQL, - HELM_MOGODB_REPLICASET, - HELM_COUCHBASE_OPERATOR, - - javaDependencies, - dockerContainers, -}; -export default constants; +// Note: this will be prepended with 'target/classes' for Maven, or with 'build/resources/main' for Gradle. +export const CLIENT_DIST_DIR = 'static/'; + +export const GENERATOR_JHIPSTER = 'generator-jhipster'; + +export const JHIPSTER_CONFIG_DIR = '.jhipster'; +export const DOCKER_DIR = `${MAIN_DIR}docker/`; +export const LINE_LENGTH = 180; +export const CLIENT_MAIN_SRC_DIR = `${MAIN_DIR}webapp/`; +export const CLIENT_TEST_SRC_DIR = `${TEST_DIR}javascript/`; +export const CLIENT_WEBPACK_DIR = 'webpack/'; +export const ANGULAR_DIR = `${MAIN_DIR}webapp/app/`; +export const REACT_DIR = `${MAIN_DIR}webapp/app/`; +export const VUE_DIR = `${MAIN_DIR}webapp/app/`; +export const SERVER_MAIN_SRC_DIR = `${MAIN_DIR}java/`; +export const SERVER_MAIN_RES_DIR = `${MAIN_DIR}resources/`; +export const SERVER_TEST_SRC_DIR = `${TEST_DIR}java/`; +export const SERVER_TEST_RES_DIR = `${TEST_DIR}resources/`; +export const PRETTIER_EXTENSIONS = 'md,json,yml,html,cjs,mjs,js,ts,tsx,css,scss,vue,svelte,java'; diff --git a/generators/gradle/generator.spec.mjs b/generators/gradle/generator.spec.mjs index 35045fbae814..441944f30e29 100644 --- a/generators/gradle/generator.spec.mjs +++ b/generators/gradle/generator.spec.mjs @@ -22,13 +22,11 @@ import { fileURLToPath } from 'url'; import { testBlueprintSupport } from '../../test/support/tests.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; -import constants from '../generator-constants.mjs'; +import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; import { GENERATOR_GRADLE } from '../generator-list.mjs'; -const { GENERATOR_JHIPSTER } = constants; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); - const generator = basename(__dirname); const generatorFile = join(__dirname, 'index.mjs'); diff --git a/generators/heroku/generator.mjs b/generators/heroku/generator.mjs index 77e104471998..762d3d404012 100644 --- a/generators/heroku/generator.mjs +++ b/generators/heroku/generator.mjs @@ -27,8 +27,8 @@ import glob from 'glob'; import BaseGenerator from '../base/index.mjs'; -import statistics from '../statistics.mjs'; -import constants from '../generator-constants.mjs'; +import statistics from '../statistics.cjs'; +import { CLIENT_MAIN_SRC_DIR, JAVA_COMPATIBLE_VERSIONS, JAVA_VERSION, SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; import { GENERATOR_HEROKU } from '../generator-list.mjs'; import { authenticationTypes, @@ -96,7 +96,7 @@ export default class HerokuGenerator extends BaseGenerator { initializing() { this.log(chalk.bold('Heroku configuration is starting')); const configuration = this.config; - this.env.options.appPath = configuration.get('appPath') || constants.CLIENT_MAIN_SRC_DIR; + this.env.options.appPath = configuration.get('appPath') || CLIENT_MAIN_SRC_DIR; this.cacheProvider = this.cacheProvider || NO_CACHE_PROVIDER; this.enableHibernateCache = this.enableHibernateCache && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider); this.frontendAppName = this.getFrontendAppName(); @@ -203,8 +203,8 @@ export default class HerokuGenerator extends BaseGenerator { type: 'list', name: 'herokuJavaVersion', message: 'Which Java version would you like to use to build and run your app ?', - choices: constants.JAVA_COMPATIBLE_VERSIONS.map(version => ({ value: version })), - default: constants.JAVA_VERSION, + choices: JAVA_COMPATIBLE_VERSIONS.map(version => ({ value: version })), + default: JAVA_VERSION, }, ]; @@ -576,8 +576,8 @@ export default class HerokuGenerator extends BaseGenerator { this.log(chalk.bold('\nCreating Heroku deployment files')); - this.template('bootstrap-heroku.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/bootstrap-heroku.yml`); - this.renderTemplate('application-heroku.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, this); + this.template('bootstrap-heroku.yml.ejs', `${SERVER_MAIN_RES_DIR}/config/bootstrap-heroku.yml`); + this.renderTemplate('application-heroku.yml.ejs', `${SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, this); this.template('Procfile.ejs', 'Procfile'); this.template('system.properties.ejs', 'system.properties'); if (this.buildTool === GRADLE) { diff --git a/generators/init/generator.spec.mts b/generators/init/generator.spec.mts index e9616fe9db5b..206fbda37cf0 100644 --- a/generators/init/generator.spec.mts +++ b/generators/init/generator.spec.mts @@ -23,10 +23,9 @@ import { fileURLToPath } from 'url'; import { basicTests, testBlueprintSupport } from '../../test/support/tests.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; import { defaultConfig, requiredConfig } from './config.mjs'; -import constants from '../generator-constants.mjs'; +import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; import { GENERATOR_INIT } from '../generator-list.mjs'; -const { GENERATOR_JHIPSTER } = constants; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); diff --git a/generators/kafka/files.mjs b/generators/kafka/files.mjs index e62699b137d5..e08c1c9ff3c2 100644 --- a/generators/kafka/files.mjs +++ b/generators/kafka/files.mjs @@ -16,10 +16,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import constants from '../generator-constants.mjs'; +import { SERVER_MAIN_SRC_DIR, SERVER_TEST_SRC_DIR } from '../generator-constants.mjs'; import { moveToJavaPackageSrcDir, moveToJavaPackageTestDir } from '../server/utils.mjs'; -const { SERVER_MAIN_SRC_DIR, SERVER_TEST_SRC_DIR } = constants; /** * @type {import('../base/api.mjs').WriteFileSection} * The default is to use a file path string. It implies use of the template method. diff --git a/generators/kubernetes-helm/generator.mjs b/generators/kubernetes-helm/generator.mjs index 5d31fb6c7893..ac4a95f0d9d9 100644 --- a/generators/kubernetes-helm/generator.mjs +++ b/generators/kubernetes-helm/generator.mjs @@ -35,7 +35,7 @@ import { setupHelmConstants, derivedKubernetesPlatformProperties, } from '../kubernetes/kubernetes-base.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import { messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; const { KAFKA } = messageBrokerTypes; diff --git a/generators/kubernetes-knative/generator.mjs b/generators/kubernetes-knative/generator.mjs index cfd6a562f334..654698a5669d 100644 --- a/generators/kubernetes-knative/generator.mjs +++ b/generators/kubernetes-knative/generator.mjs @@ -36,7 +36,7 @@ import { setupHelmConstants, derivedKubernetesPlatformProperties, } from '../kubernetes/kubernetes-base.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import { kubernetesPlatformTypes, buildToolTypes, messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; const { GeneratorTypes } = kubernetesPlatformTypes; diff --git a/generators/kubernetes/generator.mjs b/generators/kubernetes/generator.mjs index 82898210ed45..66b1ccf0434d 100644 --- a/generators/kubernetes/generator.mjs +++ b/generators/kubernetes/generator.mjs @@ -26,7 +26,7 @@ import prompts from './prompts.mjs'; import { writeFiles } from './files.mjs'; import { buildToolTypes, messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; import { GENERATOR_KUBERNETES } from '../generator-list.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import { checkImages, generateJwtSecret, configureImageNames, setAppsFolderPaths } from '../base-docker/docker-base.mjs'; import { diff --git a/generators/kubernetes/kubernetes-base.mjs b/generators/kubernetes/kubernetes-base.mjs index d565ce448b7d..5ababc6e3309 100644 --- a/generators/kubernetes/kubernetes-base.mjs +++ b/generators/kubernetes/kubernetes-base.mjs @@ -23,7 +23,24 @@ import chalk from 'chalk'; import crypto from 'crypto'; import { defaultKubernetesConfig } from './kubernetes-constants.mjs'; import { loadFromYoRc } from '../base-docker/docker-base.mjs'; -import constants from '../generator-constants.mjs'; +import { + KUBERNETES_CORE_API_VERSION, + KUBERNETES_BATCH_API_VERSION, + KUBERNETES_DEPLOYMENT_API_VERSION, + KUBERNETES_STATEFULSET_API_VERSION, + KUBERNETES_INGRESS_API_VERSION, + KUBERNETES_ISTIO_NETWORKING_API_VERSION, + KUBERNETES_RBAC_API_VERSION, + HELM_KAFKA, + HELM_ELASTICSEARCH, + HELM_PROMETHEUS, + HELM_GRAFANA, + HELM_MARIADB, + HELM_MYSQL, + HELM_POSTGRESQL, + HELM_MOGODB_REPLICASET, + HELM_COUCHBASE_OPERATOR, +} from '../generator-constants.mjs'; import { applicationTypes, kubernetesPlatformTypes } from '../../jdl/jhipster/index.mjs'; const { MICROSERVICE } = applicationTypes; @@ -118,13 +135,13 @@ export function saveConfig() { export function setupKubernetesConstants() { // Make constants available in templates - this.KUBERNETES_CORE_API_VERSION = constants.KUBERNETES_CORE_API_VERSION; - this.KUBERNETES_BATCH_API_VERSION = constants.KUBERNETES_BATCH_API_VERSION; - this.KUBERNETES_DEPLOYMENT_API_VERSION = constants.KUBERNETES_DEPLOYMENT_API_VERSION; - this.KUBERNETES_STATEFULSET_API_VERSION = constants.KUBERNETES_STATEFULSET_API_VERSION; - this.KUBERNETES_INGRESS_API_VERSION = constants.KUBERNETES_INGRESS_API_VERSION; - this.KUBERNETES_ISTIO_NETWORKING_API_VERSION = constants.KUBERNETES_ISTIO_NETWORKING_API_VERSION; - this.KUBERNETES_RBAC_API_VERSION = constants.KUBERNETES_RBAC_API_VERSION; + this.KUBERNETES_CORE_API_VERSION = KUBERNETES_CORE_API_VERSION; + this.KUBERNETES_BATCH_API_VERSION = KUBERNETES_BATCH_API_VERSION; + this.KUBERNETES_DEPLOYMENT_API_VERSION = KUBERNETES_DEPLOYMENT_API_VERSION; + this.KUBERNETES_STATEFULSET_API_VERSION = KUBERNETES_STATEFULSET_API_VERSION; + this.KUBERNETES_INGRESS_API_VERSION = KUBERNETES_INGRESS_API_VERSION; + this.KUBERNETES_ISTIO_NETWORKING_API_VERSION = KUBERNETES_ISTIO_NETWORKING_API_VERSION; + this.KUBERNETES_RBAC_API_VERSION = KUBERNETES_RBAC_API_VERSION; } export function derivedKubernetesPlatformProperties(dest = _.defaults({}, this, defaultKubernetesConfig)) { @@ -138,13 +155,13 @@ export function derivedKubernetesPlatformProperties(dest = _.defaults({}, this, } export function setupHelmConstants() { - this.HELM_KAFKA = constants.HELM_KAFKA; - this.HELM_ELASTICSEARCH = constants.HELM_ELASTICSEARCH; - this.HELM_PROMETHEUS = constants.HELM_PROMETHEUS; - this.HELM_GRAFANA = constants.HELM_GRAFANA; - this.HELM_MARIADB = constants.HELM_MARIADB; - this.HELM_MYSQL = constants.HELM_MYSQL; - this.HELM_POSTGRESQL = constants.HELM_POSTGRESQL; - this.HELM_MOGODB_REPLICASET = constants.HELM_MOGODB_REPLICASET; - this.HELM_COUCHBASE_OPERATOR = constants.HELM_COUCHBASE_OPERATOR; + this.HELM_KAFKA = HELM_KAFKA; + this.HELM_ELASTICSEARCH = HELM_ELASTICSEARCH; + this.HELM_PROMETHEUS = HELM_PROMETHEUS; + this.HELM_GRAFANA = HELM_GRAFANA; + this.HELM_MARIADB = HELM_MARIADB; + this.HELM_MYSQL = HELM_MYSQL; + this.HELM_POSTGRESQL = HELM_POSTGRESQL; + this.HELM_MOGODB_REPLICASET = HELM_MOGODB_REPLICASET; + this.HELM_COUCHBASE_OPERATOR = HELM_COUCHBASE_OPERATOR; } diff --git a/generators/languages/detect-language.mjs b/generators/languages/detect-language.mjs index aefde2c57e92..57d32bc9cac4 100644 --- a/generators/languages/detect-language.mjs +++ b/generators/languages/detect-language.mjs @@ -18,9 +18,7 @@ */ import osLocale from 'os-locale'; -import constants from '../generator-constants.mjs'; - -const { LANGUAGES } = constants; +import { LANGUAGES } from '../generator-constants.mjs'; const detectLanguage = () => { const locale = osLocale.sync(); diff --git a/generators/languages/entity-files.mjs b/generators/languages/entity-files.mjs index bb1756b4e787..6846d061ea4c 100644 --- a/generators/languages/entity-files.mjs +++ b/generators/languages/entity-files.mjs @@ -17,7 +17,7 @@ * limitations under the License. */ import _ from 'lodash'; -import utils from '../utils.mjs'; +import { getEnumInfo } from '../utils.mjs'; const { startCase } = _; @@ -69,7 +69,7 @@ export function writeEntityFiles() { this.writeFiles({ sections: enumClientI18nFiles, context: { - ...utils.getEnumInfo(field, entity.clientRootFolder), + ...getEnumInfo(field, entity.clientRootFolder), lang, frontendAppName, packageName, diff --git a/generators/languages/files.mjs b/generators/languages/files.mjs index fe449a281d99..baf882a8f837 100644 --- a/generators/languages/files.mjs +++ b/generators/languages/files.mjs @@ -16,9 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import constants from '../generator-constants.mjs'; - -const { CLIENT_MAIN_SRC_DIR } = constants; +import { CLIENT_MAIN_SRC_DIR } from '../generator-constants.mjs'; // eslint-disable-next-line import/prefer-default-export export const clientI18nFiles = { diff --git a/generators/languages/generator.mjs b/generators/languages/generator.mjs index 454bfba05f52..ade464d6f6c8 100644 --- a/generators/languages/generator.mjs +++ b/generators/languages/generator.mjs @@ -21,19 +21,18 @@ import chalk from 'chalk'; import _ from 'lodash'; import BaseApplicationGenerator from '../base-application/index.mjs'; -import constants from '../generator-constants.mjs'; +import { SERVER_TEST_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_RES_DIR } from '../generator-constants.mjs'; import { askForLanguages, askI18n } from './prompts.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import generatorDefaults from '../generator-defaults.mjs'; import { GENERATOR_LANGUAGES, GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs'; import { clientI18nFiles } from './files.mjs'; import { writeEntityFiles } from './entity-files.mjs'; import { languageToJavaLanguage } from './utils.mjs'; -import jhipsterUtils from '../utils.mjs'; +import { replaceContent } from '../utils.mjs'; import TranslationData from './translation-data.mjs'; -const { SERVER_TEST_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_RES_DIR } = constants; const { translationDefaultConfig } = generatorDefaults; /** @@ -360,7 +359,7 @@ export default class LanguagesGenerator extends BaseApplicationGenerator { }); content += ' // jhipster-needle-i18n-language-constant - JHipster will add/remove languages in this array\n];'; - jhipsterUtils.replaceContent( + replaceContent( { file: fullPath, pattern: /export.*LANGUAGES.*\[([^\]]*jhipster-needle-i18n-language-constant[^\]]*)\];/g, @@ -395,7 +394,7 @@ export default class LanguagesGenerator extends BaseApplicationGenerator { }); content += ' // jhipster-needle-i18n-language-constant - JHipster will add/remove languages in this array\n };'; - jhipsterUtils.replaceContent( + replaceContent( { file: fullPath, pattern: /private.*static.*String.*languages.*\{([^}]*jhipster-needle-i18n-language-constant[^}]*)\};/g, @@ -431,7 +430,7 @@ export default class LanguagesGenerator extends BaseApplicationGenerator { }); content += ' // jhipster-needle-i18n-language-key-pipe - JHipster will add/remove languages in this object\n };'; - jhipsterUtils.replaceContent( + replaceContent( { file: fullPath, pattern: /{\s*('[a-z-]*':)?([^=]*jhipster-needle-i18n-language-key-pipe[^;]*)\};/g, @@ -470,7 +469,7 @@ export default class LanguagesGenerator extends BaseApplicationGenerator { ' // jhipster-needle-i18n-language-webpack - JHipster will add/remove languages in this array\n' + ' ]'; - jhipsterUtils.replaceContent( + replaceContent( { file: fullPath, pattern: /groupBy:.*\[([^\]]*jhipster-needle-i18n-language-webpack[^\]]*)\]/g, @@ -509,7 +508,7 @@ export default class LanguagesGenerator extends BaseApplicationGenerator { ' // jhipster-needle-i18n-language-webpack - JHipster will add/remove languages in this array\n' + ' ]'; - jhipsterUtils.replaceContent( + replaceContent( { file: fullPath, pattern: /groupBy:.*\[([^\]]*jhipster-needle-i18n-language-webpack[^\]]*)\]/g, @@ -548,7 +547,7 @@ export default class LanguagesGenerator extends BaseApplicationGenerator { '// jhipster-needle-i18n-language-dayjs-imports - JHipster will import languages from dayjs here\n' ); - jhipsterUtils.replaceContent( + replaceContent( { file: fullPath, // match needle until // DAYJS CONFIGURATION (excluded) @@ -579,7 +578,7 @@ export default class LanguagesGenerator extends BaseApplicationGenerator { }); } content += ' // jhipster-needle-i18n-language-key-pipe - JHipster will add/remove languages in this object\n }'; - jhipsterUtils.replaceContent( + replaceContent( { file: fullPath, pattern: /languages:.*\{([^\]]*jhipster-needle-i18n-language-key-pipe[^}]*)}/g, @@ -613,7 +612,7 @@ export default class LanguagesGenerator extends BaseApplicationGenerator { i18nConfig += ' // jhipster-needle-i18n-language-date-time-format - JHipster will add/remove format options in this object\n'; i18nConfig += '}'; - jhipsterUtils.replaceContent( + replaceContent( { file: fullPath, pattern: /const dateTimeFormats.*\{([^\]]*jhipster-needle-i18n-language-date-time-format[^}]*)}/g, @@ -645,7 +644,7 @@ export default class LanguagesGenerator extends BaseApplicationGenerator { }); content += ' // jhipster-needle-i18n-language-webpack - JHipster will add/remove languages in this array\n ]'; - jhipsterUtils.replaceContent( + replaceContent( { file: fullPath, pattern: /groupBy:.*\[([^\]]*jhipster-needle-i18n-language-webpack[^\]]*)\]/g, diff --git a/generators/languages/languages.spec.mjs b/generators/languages/languages.spec.mjs index abe67c35d361..e4814763abb8 100644 --- a/generators/languages/languages.spec.mjs +++ b/generators/languages/languages.spec.mjs @@ -3,13 +3,9 @@ import helpers from 'yeoman-test'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; -import constants from '../generator-constants.mjs'; +import { CLIENT_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, CLIENT_WEBPACK_DIR, LANGUAGES } from '../generator-constants.mjs'; import EnvironmentBuilder from '../../cli/environment-builder.mjs'; -const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; -const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; -const CLIENT_WEBPACK_DIR = constants.CLIENT_WEBPACK_DIR; - const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -103,7 +99,7 @@ const containsLanguageInVueStore = languageValue => { describe('JHipster generator languages', () => { context('Creates default i18n files', () => { - constants.LANGUAGES.forEach(language => { + LANGUAGES.forEach(language => { describe(`with prompts for ${language.name}`, () => { before(() => helpers diff --git a/generators/liquibase-changelogs/files.mjs b/generators/liquibase-changelogs/files.mjs index d44705eda790..4faa987041ee 100644 --- a/generators/liquibase-changelogs/files.mjs +++ b/generators/liquibase-changelogs/files.mjs @@ -16,9 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import constants from '../generator-constants.mjs'; - -const { SERVER_MAIN_RES_DIR } = constants; +import { SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; export const addEntityFiles = { dbChangelog: [ diff --git a/generators/liquibase-changelogs/incremental-liquibase.spec.mts b/generators/liquibase-changelogs/incremental-liquibase.spec.mts index fc42a8d5f3cb..4e9fb2f730ab 100644 --- a/generators/liquibase-changelogs/incremental-liquibase.spec.mts +++ b/generators/liquibase-changelogs/incremental-liquibase.spec.mts @@ -4,14 +4,12 @@ import { existsSync, mkdirSync, writeFileSync } from 'fs'; import { fileURLToPath } from 'url'; import { skipPrettierHelpers as helpers } from '../../test/support/helpers.mjs'; -import constants from '../generator-constants.mjs'; +import { SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; import { createImporterFromContent } from '../../jdl/jdl-importer.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); -const { SERVER_MAIN_RES_DIR } = constants; - const incrementalFiles = [ `${SERVER_MAIN_RES_DIR}config/liquibase/master.xml`, `${SERVER_MAIN_RES_DIR}config/liquibase/changelog/00000000000000_initial_schema.xml`, diff --git a/generators/liquibase/files.mts b/generators/liquibase/files.mts index 11907c636568..3a7bde3dde63 100644 --- a/generators/liquibase/files.mts +++ b/generators/liquibase/files.mts @@ -19,11 +19,9 @@ import type { WriteFileSection } from '../base/api.mjs'; import type LiquibaseGenerator from './generator.mjs'; import type { LiquibaseApplication, SpringBootApplication } from '../server/types.mjs'; -import constants from '../generator-constants.mjs'; +import { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR } from '../generator-constants.mjs'; import { moveToJavaPackageSrcDir } from '../server/utils.mjs'; -const { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR } = constants; - // eslint-disable-next-line import/prefer-default-export export const liquibaseFiles: WriteFileSection = { liquibase: [ diff --git a/generators/liquibase/generator.mts b/generators/liquibase/generator.mts index 0eb218e57201..cff8051e92da 100644 --- a/generators/liquibase/generator.mts +++ b/generators/liquibase/generator.mts @@ -21,19 +21,16 @@ import fs from 'fs'; import BaseApplication from '../base-application/index.mjs'; import type { DefaultTaskGroup } from '../base-application/tasks.mjs'; import type { LiquibaseApplication, SpringBootApplication } from '../server/types.mjs'; -import constants from '../generator-constants.mjs'; +import { JHIPSTER_CONFIG_DIR } from '../generator-constants.mjs'; import { GENERATOR_LIQUIBASE, GENERATOR_LIQUIBASE_CHANGELOGS, GENERATOR_BOOTSTRAP_APPLICATION_SERVER } from '../generator-list.mjs'; import { liquibaseFiles } from './files.mjs'; -const { JHIPSTER_CONFIG_DIR } = constants; - const BASE_CHANGELOG = { addedFields: [], removedFields: [], addedRelationships: [], removedRelationships: [], }; - export default class DatabaseChangelogGenerator extends BaseApplication { constructor(args: any, options: any, features: any) { super(args, options, { unique: 'namespace', ...features }); diff --git a/generators/maven/generator.spec.mjs b/generators/maven/generator.spec.mjs index c6d30474fe22..439d03461371 100644 --- a/generators/maven/generator.spec.mjs +++ b/generators/maven/generator.spec.mjs @@ -22,13 +22,11 @@ import { fileURLToPath } from 'url'; import { testBlueprintSupport } from '../../test/support/tests.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; -import constants from '../generator-constants.mjs'; +import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; import { GENERATOR_MAVEN } from '../generator-list.mjs'; -const { GENERATOR_JHIPSTER } = constants; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); - const generator = basename(__dirname); const generatorFile = join(__dirname, 'index.mjs'); diff --git a/generators/needle-base.mjs b/generators/needle-base.mjs index 8e44ec9d3973..46ba84bee6b5 100644 --- a/generators/needle-base.mjs +++ b/generators/needle-base.mjs @@ -17,7 +17,7 @@ * limitations under the License. */ import chalk from 'chalk'; -import jhipsterUtils from './utils.mjs'; +import { rewriteFile } from './utils.mjs'; export default class { constructor(generator) { @@ -34,7 +34,7 @@ export default class { addBlockContentToFile(rewriteFileModel, errorMessage) { try { - return jhipsterUtils.rewriteFile(rewriteFileModel, this.generator); + return rewriteFile(rewriteFileModel, this.generator); } catch (e) { this.logNeedleNotFound(e, errorMessage, rewriteFileModel.file); return false; diff --git a/generators/openapi-client/files.mjs b/generators/openapi-client/files.mjs index 5a27460400ed..1c417b5cae37 100644 --- a/generators/openapi-client/files.mjs +++ b/generators/openapi-client/files.mjs @@ -20,7 +20,7 @@ import path from 'path'; import _ from 'lodash'; import chalk from 'chalk'; -import constants from '../generator-constants.mjs'; +import { SERVER_MAIN_SRC_DIR, OPENAPI_GENERATOR_CLI_VERSION, JACKSON_DATABIND_NULLABLE_VERSION } from '../generator-constants.mjs'; import { applicationOptions, buildToolTypes, applicationTypes, authenticationTypes } from '../../jdl/jhipster/index.mjs'; const { OptionNames } = applicationOptions; @@ -51,8 +51,8 @@ export function customizeFiles() { const baseCliPackage = `${this.packageName}.client.`; const cliPackage = `${baseCliPackage}${_.toLower(cliName)}`; const snakeCaseCliPackage = `${baseCliPackage}${_.snakeCase(cliName)}`; - this.removeFolder(path.resolve(constants.SERVER_MAIN_SRC_DIR, ...cliPackage.split('.'))); - this.removeFolder(path.resolve(constants.SERVER_MAIN_SRC_DIR, ...snakeCaseCliPackage.split('.'))); + this.removeFolder(path.resolve(SERVER_MAIN_SRC_DIR, ...cliPackage.split('.'))); + this.removeFolder(path.resolve(SERVER_MAIN_SRC_DIR, ...snakeCaseCliPackage.split('.'))); const inputSpec = this.clientsToGenerate[cliName].spec; const generatorName = this.clientsToGenerate[cliName].generatorName; @@ -141,11 +141,11 @@ export function customizeFiles() { addJacksonDataBindNullable() { if (!this.enableSwaggerCodegen) { if (this.buildTool === MAVEN) { - this.addMavenProperty('jackson-databind-nullable.version', constants.JACKSON_DATABIND_NULLABLE_VERSION); + this.addMavenProperty('jackson-databind-nullable.version', JACKSON_DATABIND_NULLABLE_VERSION); // eslint-disable-next-line no-template-curly-in-string this.addMavenDependency('org.openapitools', 'jackson-databind-nullable', '${jackson-databind-nullable.version}'); } else if (this.buildTool === GRADLE) { - this.addGradleProperty('jacksonDatabindNullableVersion', constants.JACKSON_DATABIND_NULLABLE_VERSION); + this.addGradleProperty('jacksonDatabindNullableVersion', JACKSON_DATABIND_NULLABLE_VERSION); this.addGradleDependency( 'compile', 'org.openapitools', @@ -162,7 +162,7 @@ export function customizeFiles() { return; } - this.javaDir = `${constants.SERVER_MAIN_SRC_DIR + this.packageFolder}/`; + this.javaDir = `${SERVER_MAIN_SRC_DIR + this.packageFolder}/`; const mainClassFile = `${this.javaDir + this.getMainClassName()}.java`; if (this.applicationType !== MICROSERVICE || ![JWT].includes(this.authenticationType)) { @@ -180,7 +180,7 @@ export function customizeFiles() { return; } - this.javaDir = `${constants.SERVER_MAIN_SRC_DIR + this.packageFolder}/`; + this.javaDir = `${SERVER_MAIN_SRC_DIR + this.packageFolder}/`; const mainClassFile = `${this.javaDir + this.getMainClassName()}.java`; this.rewriteFile( @@ -199,7 +199,7 @@ export function customizeFiles() { customizePackageJson() { this.packageJson.merge({ dependencies: { - '@openapitools/openapi-generator-cli': constants.OPENAPI_GENERATOR_CLI_VERSION, + '@openapitools/openapi-generator-cli': OPENAPI_GENERATOR_CLI_VERSION, }, }); }, diff --git a/generators/openshift/generator.mjs b/generators/openshift/generator.mjs index f21b5000f81a..fdc4fa181899 100644 --- a/generators/openshift/generator.mjs +++ b/generators/openshift/generator.mjs @@ -26,7 +26,7 @@ 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 { setupKubernetesConstants } from '../kubernetes/kubernetes-base.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import { applicationTypes, diff --git a/generators/page/files-vue.mjs b/generators/page/files-vue.mjs index 9b600d0c3b00..fe1b738d8ecc 100644 --- a/generators/page/files-vue.mjs +++ b/generators/page/files-vue.mjs @@ -16,11 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import constants from '../generator-constants.mjs'; -import utils from '../utils.mjs'; +import { CLIENT_TEST_SRC_DIR } from '../generator-constants.mjs'; +import { vueAddPageToRouterImport, vueAddPageToRouter, vueAddPageServiceToMainImport, vueAddPageServiceToMain } from '../utils.mjs'; /* Constants use throughout */ -const CLIENT_TEST_SRC_DIR = constants.CLIENT_TEST_SRC_DIR; const VUE_DIR = 'src/main/webapp/app/'; export const vueFiles = { @@ -67,9 +66,9 @@ export const vueFiles = { export function customizeFiles(data) { // Add page paths to routing system - utils.vueAddPageToRouterImport(this, data); - utils.vueAddPageToRouter(this, data); + vueAddPageToRouterImport(this, data); + vueAddPageToRouter(this, data); // Add page services to main - utils.vueAddPageServiceToMainImport(this, data); - utils.vueAddPageServiceToMain(this, data); + vueAddPageServiceToMainImport(this, data); + vueAddPageServiceToMain(this, data); } diff --git a/generators/react/generator.spec.mts b/generators/react/generator.spec.mts index 7034e2305615..2ec5a5dce4ae 100644 --- a/generators/react/generator.spec.mts +++ b/generators/react/generator.spec.mts @@ -9,7 +9,7 @@ import Generator from './index.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; -import constants from '../generator-constants.mjs'; +import { CLIENT_MAIN_SRC_DIR } from '../generator-constants.mjs'; import BaseApplicationGenerator from '../base-application/index.mjs'; const { snakeCase } = lodash; @@ -21,7 +21,6 @@ const generator = basename(__dirname); const generatorFile = join(__dirname, 'index.mts'); const { REACT: clientFramework } = clientFrameworkTypes; -const { CLIENT_MAIN_SRC_DIR } = constants; const commonConfig = { clientFramework, nativeLanguage: 'en', languages: ['fr', 'en'] }; const samplesBuilder = () => diff --git a/generators/server/__test-support/elastic-search-matcher.mts b/generators/server/__test-support/elastic-search-matcher.mts index a13eb86f7eea..8b6f3e9b877a 100644 --- a/generators/server/__test-support/elastic-search-matcher.mts +++ b/generators/server/__test-support/elastic-search-matcher.mts @@ -2,11 +2,9 @@ import type { RunResult } from 'yeoman-test'; import type BaseApplicationGenerator from '../../base-application/index.mjs'; import type { SpringBootApplication } from '../../server/types.mjs'; -import constants from '../../generator-constants.mjs'; +import { SERVER_MAIN_SRC_DIR, DOCKER_DIR } from '../../generator-constants.mjs'; import { matchWrittenConfig, matchWrittenFiles } from '../../../test/support/matcher.mjs'; -const { SERVER_MAIN_SRC_DIR, DOCKER_DIR } = constants; - const expectedElasticsearchFiles = () => { return [`${DOCKER_DIR}elasticsearch.yml`]; }; diff --git a/generators/server/cleanup.mjs b/generators/server/cleanup.mjs index 2fda230f6c20..4baf0518c87b 100644 --- a/generators/server/cleanup.mjs +++ b/generators/server/cleanup.mjs @@ -27,9 +27,7 @@ import cleanupOauth2 from './cleanup-oauth2.mjs'; import cleanupReactive from './cleanup-reactive.mjs'; import cleanupCucumber from './cleanup-cucumber.mjs'; import cleanupMaven from './cleanup-maven.mjs'; -import constants from '../generator-constants.mjs'; - -const { DOCKER_DIR } = constants; +import { DOCKER_DIR } from '../generator-constants.mjs'; /** * Removes server files that where generated in previous JHipster versions and therefore diff --git a/generators/server/entity-files.mjs b/generators/server/entity-files.mjs index b2ddb2c62c88..f32b619af666 100644 --- a/generators/server/entity-files.mjs +++ b/generators/server/entity-files.mjs @@ -20,8 +20,8 @@ import _ from 'lodash'; import chalk from 'chalk'; import fs from 'fs'; import { cleanupOldFiles } from './entity-cleanup.mjs'; -import utils from '../utils.mjs'; -import constants from '../generator-constants.mjs'; +import { getEnumInfo } from '../utils.mjs'; +import { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, TEST_DIR, SERVER_TEST_SRC_DIR } from '../generator-constants.mjs'; import { databaseTypes, searchEngineTypes, entityOptions, cacheTypes } from '../../jdl/jhipster/index.mjs'; const { CASSANDRA, COUCHBASE, MONGODB, NEO4J, SQL } = databaseTypes; @@ -31,12 +31,6 @@ const { EHCACHE, CAFFEINE, INFINISPAN, REDIS } = cacheTypes; const { MAPSTRUCT } = MapperTypes; const { SERVICE_CLASS, SERVICE_IMPL } = ServiceTypes; -/* Constants use throughout */ -const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; -const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; -const TEST_DIR = constants.TEST_DIR; -const SERVER_TEST_SRC_DIR = constants.SERVER_TEST_SRC_DIR; - export const cassandraChangelogFiles = { dbChangelog: [ { @@ -463,7 +457,7 @@ export function writeFiles() { for (const field of entity.fields.filter(field => field.fieldIsEnum)) { const fieldType = field.fieldType; const enumInfo = { - ...utils.getEnumInfo(field, entity.clientRootFolder), + ...getEnumInfo(field, entity.clientRootFolder), frontendAppName: application.frontendAppName, packageName: application.packageName, entityAbsolutePackage: entity.entityAbsolutePackage || application.packageName, diff --git a/generators/server/files-sql.mjs b/generators/server/files-sql.mjs index 2a9ce75f0d53..2e80d600b867 100644 --- a/generators/server/files-sql.mjs +++ b/generators/server/files-sql.mjs @@ -17,9 +17,7 @@ * limitations under the License. */ import { mergeSections, addSectionsCondition } from './utils.mjs'; -import constants from '../generator-constants.mjs'; - -const { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_SRC_DIR, SERVER_TEST_RES_DIR } = constants; +import { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_SRC_DIR, SERVER_TEST_RES_DIR } from '../generator-constants.mjs'; export const sqlFiles = { reactiveJavaUserManagement: [ diff --git a/generators/server/files.mjs b/generators/server/files.mjs index b489daa59189..c73e8d9b722b 100644 --- a/generators/server/files.mjs +++ b/generators/server/files.mjs @@ -17,17 +17,10 @@ * limitations under the License. */ import { cleanupOldServerFiles } from './cleanup.mjs'; -import constants from '../generator-constants.mjs'; +import { TEST_DIR, SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_SRC_DIR, SERVER_TEST_RES_DIR } from '../generator-constants.mjs'; import { addSectionsCondition, mergeSections } from './utils.mjs'; import { writeSqlFiles } from './files-sql.mjs'; -/* Constants use throughout */ -const TEST_DIR = constants.TEST_DIR; -const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; -const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; -const SERVER_TEST_SRC_DIR = constants.SERVER_TEST_SRC_DIR; -const SERVER_TEST_RES_DIR = constants.SERVER_TEST_RES_DIR; - /** * Move the template to `javaPackageSrcDir` (defaults to`src/main/java/${packageFolder}/${filePath}`). * Removes trailing specifiers. diff --git a/generators/server/generator.mjs b/generators/server/generator.mjs index ab9c578aa247..09e7bcad630f 100644 --- a/generators/server/generator.mjs +++ b/generators/server/generator.mjs @@ -41,8 +41,25 @@ import BaseApplicationGenerator from '../base-application/index.mjs'; import { writeFiles } from './files.mjs'; import { writeFiles as writeEntityFiles, customizeFiles } from './entity-files.mjs'; import { packageJson as packagejs } from '../../lib/index.mjs'; -import constants from '../generator-constants.mjs'; -import statistics from '../statistics.mjs'; +import { + SERVER_MAIN_SRC_DIR, + SERVER_MAIN_RES_DIR, + SERVER_TEST_SRC_DIR, + SERVER_TEST_RES_DIR, + CLIENT_WEBPACK_DIR, + MAIN_DIR, + LOGIN_REGEX, + TEST_DIR, + JHIPSTER_DEPENDENCIES_VERSION, + SPRING_BOOT_VERSION, + JAVA_VERSION, + JAVA_COMPATIBLE_VERSIONS, + SPRING_CLOUD_VERSION, + HIBERNATE_VERSION, + JACKSON_DATABIND_NULLABLE_VERSION, + JACOCO_VERSION, +} from '../generator-constants.mjs'; +import statistics from '../statistics.cjs'; import generatorDefaults from '../generator-defaults.mjs'; import { @@ -58,6 +75,7 @@ import { validations, reservedKeywords, messageBrokerTypes, + clientFrameworkTypes, } from '../../jdl/jhipster/index.mjs'; import { stringify } from '../../utils/index.mjs'; @@ -66,6 +84,7 @@ import { normalizePathEnd } from '../base/utils.mjs'; import { SUPPORTED_VALIDATION_RULES } from '../../jdl/jhipster/validations.js'; const { isReservedTableName } = reservedKeywords; +const { ANGULAR, REACT, VUE } = clientFrameworkTypes; const { defaultConfig } = generatorDefaults; const { JWT, OAUTH2, SESSION } = authenticationTypes; const { GRADLE, MAVEN } = buildToolTypes; @@ -76,7 +95,6 @@ const { CASSANDRA, COUCHBASE, MONGODB, NEO4J, SQL, NO: NO_DATABASE } = databaseT const { MICROSERVICE, GATEWAY } = applicationTypes; const { KAFKA } = messageBrokerTypes; -const { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_SRC_DIR, SERVER_TEST_RES_DIR, MAIN_DIR, TEST_DIR } = constants; const { CommonDBTypes, RelationalOnlyDBTypes } = fieldTypes; const { INSTANT } = CommonDBTypes; const { BYTES, BYTE_BUFFER } = RelationalOnlyDBTypes; @@ -262,17 +280,17 @@ export default class JHipsterServerGenerator extends BaseApplicationGenerator { setupServerconsts({ control, application }) { // Make constants available in templates - application.MAIN_DIR = constants.MAIN_DIR; - application.TEST_DIR = constants.TEST_DIR; - application.LOGIN_REGEX = constants.LOGIN_REGEX; - application.CLIENT_WEBPACK_DIR = constants.CLIENT_WEBPACK_DIR; - application.SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; - application.SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; - application.SERVER_TEST_SRC_DIR = constants.SERVER_TEST_SRC_DIR; - application.SERVER_TEST_RES_DIR = constants.SERVER_TEST_RES_DIR; - - application.JAVA_VERSION = control.useVersionPlaceholders ? 'JAVA_VERSION' : constants.JAVA_VERSION; - application.JAVA_COMPATIBLE_VERSIONS = constants.JAVA_COMPATIBLE_VERSIONS; + application.MAIN_DIR = MAIN_DIR; + application.TEST_DIR = TEST_DIR; + application.LOGIN_REGEX = LOGIN_REGEX; + application.CLIENT_WEBPACK_DIR = CLIENT_WEBPACK_DIR; + application.SERVER_MAIN_SRC_DIR = SERVER_MAIN_SRC_DIR; + application.SERVER_MAIN_RES_DIR = SERVER_MAIN_RES_DIR; + application.SERVER_TEST_SRC_DIR = SERVER_TEST_SRC_DIR; + application.SERVER_TEST_RES_DIR = SERVER_TEST_RES_DIR; + + application.JAVA_VERSION = control.useVersionPlaceholders ? 'JAVA_VERSION' : JAVA_VERSION; + application.JAVA_COMPATIBLE_VERSIONS = JAVA_COMPATIBLE_VERSIONS; if (this.projectVersion) { this.info(`Using projectVersion: ${application.jhipsterDependenciesVersion}`); @@ -287,19 +305,19 @@ export default class JHipsterServerGenerator extends BaseApplicationGenerator { application.jhipsterDependenciesVersion = this.jhipsterDependenciesVersion; this.info(`Using jhipsterDependenciesVersion: ${application.jhipsterDependenciesVersion}`); } else { - application.jhipsterDependenciesVersion = constants.JHIPSTER_DEPENDENCIES_VERSION; + application.jhipsterDependenciesVersion = JHIPSTER_DEPENDENCIES_VERSION; } - application.SPRING_BOOT_VERSION = control.useVersionPlaceholders ? 'SPRING_BOOT_VERSION' : constants.SPRING_BOOT_VERSION; - application.SPRING_CLOUD_VERSION = control.useVersionPlaceholders ? 'SPRING_CLOUD_VERSION' : constants.SPRING_CLOUD_VERSION; - application.HIBERNATE_VERSION = control.useVersionPlaceholders ? 'HIBERNATE_VERSION' : constants.HIBERNATE_VERSION; + application.SPRING_BOOT_VERSION = control.useVersionPlaceholders ? 'SPRING_BOOT_VERSION' : SPRING_BOOT_VERSION; + application.SPRING_CLOUD_VERSION = control.useVersionPlaceholders ? 'SPRING_CLOUD_VERSION' : SPRING_CLOUD_VERSION; + application.HIBERNATE_VERSION = control.useVersionPlaceholders ? 'HIBERNATE_VERSION' : HIBERNATE_VERSION; application.JACKSON_DATABIND_NULLABLE_VERSION = control.useVersionPlaceholders ? 'JACKSON_DATABIND_NULLABLE_VERSION' - : constants.JACKSON_DATABIND_NULLABLE_VERSION; - application.JACOCO_VERSION = control.useVersionPlaceholders ? 'JACOCO_VERSION' : constants.JACOCO_VERSION; + : JACKSON_DATABIND_NULLABLE_VERSION; + application.JACOCO_VERSION = control.useVersionPlaceholders ? 'JACOCO_VERSION' : JACOCO_VERSION; - application.ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR; - application.VUE = constants.SUPPORTED_CLIENT_FRAMEWORKS.VUE; - application.REACT = constants.SUPPORTED_CLIENT_FRAMEWORKS.REACT; + application.ANGULAR = ANGULAR; + application.VUE = VUE; + application.REACT = REACT; this.packagejs = packagejs; application.jhipsterPackageJson = packagejs; diff --git a/generators/server/needle-api/needle-server-cache.mjs b/generators/server/needle-api/needle-server-cache.mjs index c75c559d4f36..92b949db94b6 100644 --- a/generators/server/needle-api/needle-server-cache.mjs +++ b/generators/server/needle-api/needle-server-cache.mjs @@ -17,15 +17,13 @@ * limitations under the License. */ import chalk from 'chalk'; -import needleServer from './needle-server.cjs'; -import constants from '../../generator-constants.mjs'; +import needleServer from './needle-server.mjs'; +import { SERVER_MAIN_SRC_DIR } from '../../generator-constants.mjs'; // const { CAFFEINE, EHCACHE, REDIS } = require('../../../jdl/jhipster/cache-types'); const CAFFEINE = 'caffeine'; const EHCACHE = 'ehcache'; const REDIS = 'redis'; -const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; - export default class extends needleServer { addEntityToCache(entityClass, relationships, packageName, packageFolder, cacheProvider) { const entityAbsoluteClass = entityClass.includes('.') ? entityClass : `${packageName}.domain.${entityClass}`; diff --git a/generators/server/needle-api/needle-server-gradle.mjs b/generators/server/needle-api/needle-server-gradle.mjs index 71f153787032..74317ea30f13 100644 --- a/generators/server/needle-api/needle-server-gradle.mjs +++ b/generators/server/needle-api/needle-server-gradle.mjs @@ -17,7 +17,7 @@ * limitations under the License. */ import chalk from 'chalk'; -import needleServer from './needle-server.cjs'; +import needleServer from './needle-server.mjs'; const buildGradlePath = 'build.gradle'; const gradleSettingsPath = 'settings.gradle'; diff --git a/generators/server/needle-api/needle-server-liquibase.mjs b/generators/server/needle-api/needle-server-liquibase.mjs index 626a0e88a74b..4d74993b2f1c 100644 --- a/generators/server/needle-api/needle-server-liquibase.mjs +++ b/generators/server/needle-api/needle-server-liquibase.mjs @@ -18,9 +18,7 @@ */ import chalk from 'chalk'; import needleServer from './needle-server.mjs'; -import constants from '../../generator-constants.mjs'; - -const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; +import { SERVER_MAIN_RES_DIR } from '../../generator-constants.mjs'; export default class extends needleServer { addChangelog(changelogName) { diff --git a/generators/server/needle-api/needle-server-logback-spring.mjs b/generators/server/needle-api/needle-server-logback-spring.mjs index 9a065c983d4e..febd1263d298 100644 --- a/generators/server/needle-api/needle-server-logback-spring.mjs +++ b/generators/server/needle-api/needle-server-logback-spring.mjs @@ -18,9 +18,7 @@ */ import chalk from 'chalk'; import needleServer from './needle-server.mjs'; -import constants from '../../generator-constants.mjs'; - -const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; +import { SERVER_MAIN_RES_DIR } from '../../generator-constants.mjs'; export default class extends needleServer { addlog(logName, level) { diff --git a/generators/spring-controller/generator.mjs b/generators/spring-controller/generator.mjs index 36e578035ae2..09d05857279a 100644 --- a/generators/spring-controller/generator.mjs +++ b/generators/spring-controller/generator.mjs @@ -22,17 +22,15 @@ import chalk from 'chalk'; import BaseGenerator from '../base/index.mjs'; -import constants from '../generator-constants.mjs'; +import { SERVER_MAIN_SRC_DIR, SERVER_TEST_SRC_DIR } from '../generator-constants.mjs'; import { askForControllerActions } from './prompts.mjs'; -import statistics from '../statistics.mjs'; +import statistics from '../statistics.cjs'; import { GENERATOR_SPRING_CONTROLLER } from '../generator-list.mjs'; import { applicationOptions, cacheTypes, messageBrokerTypes } from '../../jdl/jhipster/index.mjs'; const { OptionNames } = applicationOptions; const cacheProviders = cacheTypes; const messageBrokers = messageBrokerTypes; -const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; -const SERVER_TEST_SRC_DIR = constants.SERVER_TEST_SRC_DIR; const { BASE_NAME, PACKAGE_NAME, diff --git a/generators/spring-service/generator.mjs b/generators/spring-service/generator.mjs index 3fa3f809c68e..2fdd37b78033 100644 --- a/generators/spring-service/generator.mjs +++ b/generators/spring-service/generator.mjs @@ -21,15 +21,13 @@ import _ from 'lodash'; import BaseGenerator from '../base/index.mjs'; -import constants from '../generator-constants.mjs'; -import statistics from '../statistics.mjs'; +import { SERVER_MAIN_SRC_DIR } from '../generator-constants.mjs'; +import statistics from '../statistics.cjs'; import { GENERATOR_SPRING_SERVICE } from '../generator-list.mjs'; import { applicationOptions } from '../../jdl/jhipster/index.mjs'; const { OptionNames } = applicationOptions; const { BASE_NAME, PACKAGE_NAME, PACKAGE_FOLDER, DATABASE_TYPE } = OptionNames; -const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; - export default class SpringServiceGenerator extends BaseGenerator { constructor(args, options, features) { super(args, options, features); diff --git a/generators/statistics.mjs b/generators/statistics.cjs similarity index 95% rename from generators/statistics.mjs rename to generators/statistics.cjs index 10991c79ad4d..4f1cb2eb8cd2 100644 --- a/generators/statistics.mjs +++ b/generators/statistics.cjs @@ -16,13 +16,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { v4 as uuid } from 'uuid'; -import Config from 'conf'; -import osLocale from 'os-locale'; -import axios from 'axios'; -import os from 'os'; -import Insight from 'insight'; -import { packageJson as packagejs } from '../lib/index.cjs'; +const { v4: uuid } = require('uuid'); +const Config = require('conf'); +const osLocale = require('os-locale'); +const axios = require('axios'); +const os = require('os'); +const Insight = require('insight'); +const { packageJson: packagejs } = require('../lib/index.cjs'); const DO_NOT_ASK_LIMIT = 100; @@ -243,4 +243,4 @@ function get() { return currentInstance; } -export default get(); +module.exports = get(); diff --git a/generators/upgrade/generator.mjs b/generators/upgrade/generator.mjs index c57f3e22265f..39e9b2a825b1 100644 --- a/generators/upgrade/generator.mjs +++ b/generators/upgrade/generator.mjs @@ -28,8 +28,8 @@ import childProcess from 'child_process'; import BaseGenerator from '../base/index.mjs'; import { upgradeFiles } from '../cleanup.mjs'; -import constants from '../generator-constants.mjs'; -import statistics from '../statistics.mjs'; +import { SERVER_MAIN_RES_DIR } from '../generator-constants.mjs'; +import statistics from '../statistics.cjs'; import { parseBluePrints } from '../../utils/blueprint.mjs'; import { packageJson as packagejs } from '../../lib/index.mjs'; @@ -39,7 +39,6 @@ const UPGRADE_BRANCH = 'jhipster_upgrade'; const GLOBAL_VERSION = 'global'; const GIT_VERSION_NOT_ALLOW_MERGE_UNRELATED_HISTORIES = '2.9.0'; const FIRST_CLI_SUPPORTED_VERSION = '4.5.1'; // The first version in which CLI support was added -const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; /** * Executes a Git command using shellJS diff --git a/generators/upgrade/upgrade.spec.mts b/generators/upgrade/upgrade.spec.mts index d27c55d5a4aa..fcae4282fd04 100644 --- a/generators/upgrade/upgrade.spec.mts +++ b/generators/upgrade/upgrade.spec.mts @@ -7,9 +7,7 @@ import { fileURLToPath } from 'url'; import { jestExpect as expect } from 'mocha-expect-snapshot'; import { packageJson } from '../../lib/index.mjs'; import { prepareTempDir } from '../../test/support/temp-dir.mjs'; -import generatorUtils from '../utils.mjs'; - -const { escapeRegExp } = generatorUtils; +import { escapeRegExp } from '../utils.mjs'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); diff --git a/generators/utils.mjs b/generators/utils.mjs index 4bad7436b756..fa8ddd0283d1 100644 --- a/generators/utils.mjs +++ b/generators/utils.mjs @@ -28,7 +28,7 @@ import os from 'os'; * @param {object} args argument object (containing path, file, haystack, etc properties) * @param {object} generator reference to the generator */ -function rewriteFile(args, generator) { +export function rewriteFile(args, generator) { const { path: rewritePath, file } = args; let fullPath; if (rewritePath) { @@ -51,7 +51,7 @@ function rewriteFile(args, generator) { * @param {object} args argument object * @param {object} generator reference to the generator */ -function replaceContent(args, generator) { +export function replaceContent(args, generator) { let fullPath = generator.destinationPath(args.file); if (!generator.env.sharedFs.existsInMemory(fullPath) && generator.env.sharedFs.existsInMemory(`${fullPath}.jhi`)) { fullPath = `${fullPath}.jhi`; @@ -71,7 +71,7 @@ function replaceContent(args, generator) { * @param {string} str string * @returns {string} string with regular expressions escaped */ -function escapeRegExp(str) { +export function escapeRegExp(str) { return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); // eslint-disable-line } @@ -83,7 +83,7 @@ function escapeRegExp(str) { * @param {string} str string * @returns {string} string where CRLF is replaced with LF in Windows */ -function normalizeWindowsLineEndings(str) { +export function normalizeWindowsLineEndings(str) { const isWin32 = os.platform() === 'win32'; return isWin32 ? str.replace(/\r\n/g, '\n') : str; } @@ -94,7 +94,7 @@ function normalizeWindowsLineEndings(str) { * @param {string} str string * @returns {string} string where CRLF is replaced with LF in Windows */ -function convertToPrettierExpressions(str) { +export function convertToPrettierExpressions(str) { return str.replace(/\s+/g, '([\\s\n]*)').replace(/>+/g, '(\n?[\\s]*)>'); } @@ -110,7 +110,7 @@ function convertToPrettierExpressions(str) { * @param {string} [args.file] - file path for logging purposes * @returns {string} re-written content */ -function rewrite(args) { +export function rewrite(args) { // check if splicable is already in the body text let re; if (args.regexp) { @@ -173,7 +173,7 @@ function rewrite(args) { * @param {function} [cb] callback function * @return {Promise} Promise rendered content */ -function renderContent(source, generator, context, options, cb) { +export function renderContent(source, generator, context, options, cb) { options = { root: options.root || generator.jhipsterTemplatesFolders || generator.templatePath(), context: generator, @@ -207,7 +207,7 @@ function renderContent(source, generator, context, options, cb) { * @param path path to traverse * @param placeholder placeholder */ -function deepFind(obj, path, placeholder) { +export function deepFind(obj, path, placeholder) { const paths = path.split('.'); let current = obj; if (placeholder) { @@ -231,7 +231,7 @@ function deepFind(obj, path, placeholder) { * @param {number} indentSize indent size (default 0) * @returns javadoc formatted string */ -function getJavadoc(text, indentSize = 0) { +export function getJavadoc(text, indentSize = 0) { if (!text) { text = ''; } @@ -253,7 +253,7 @@ function getJavadoc(text, indentSize = 0) { * @param {String} clientRootFolder - the client's root folder * @return {Object} the enum info. */ -function getEnumInfo(field, clientRootFolder) { +export function getEnumInfo(field, clientRootFolder) { const fieldType = field.fieldType; // Todo: check if the next line does a side-effect and refactor it. field.enumInstance = _.lowerFirst(fieldType); @@ -278,7 +278,7 @@ function getEnumInfo(field, clientRootFolder) { * @param {string} packageName * @param {string} clientRootFolder */ -function buildEnumInfo(field, frontendAppName, packageName, clientRootFolder) { +export function buildEnumInfo(field, frontendAppName, packageName, clientRootFolder) { const fieldType = field.fieldType; field.enumInstance = _.lowerFirst(fieldType); const enums = field.fieldValues.replace(/\s/g, '').split(','); @@ -301,7 +301,7 @@ function buildEnumInfo(field, frontendAppName, packageName, clientRootFolder) { * @param enums * @return {*} */ -function getEnumsWithCustomValue(enums) { +export function getEnumsWithCustomValue(enums) { return enums.reduce((enumsWithCustomValueArray, currentEnumValue) => { if (doesTheEnumValueHaveACustomValue(currentEnumValue)) { const matches = /([A-Z\-_]+)(\((.+?)\))?/.exec(currentEnumValue); @@ -315,7 +315,7 @@ function getEnumsWithCustomValue(enums) { }, []); } -function getCustomValuesState(enumValues) { +export function getCustomValuesState(enumValues) { const state = { withoutCustomValue: 0, withCustomValue: 0, @@ -334,7 +334,7 @@ function getCustomValuesState(enumValues) { }; } -function getEnums(enums, customValuesState, comments) { +export function getEnums(enums, customValuesState, comments) { if (customValuesState.withoutCustomValues) { return enums.map(enumValue => ({ name: enumValue, @@ -360,7 +360,7 @@ function getEnums(enums, customValuesState, comments) { }); } -function doesTheEnumValueHaveACustomValue(enumValue) { +export function doesTheEnumValueHaveACustomValue(enumValue) { return enumValue.includes('('); } @@ -371,7 +371,7 @@ function doesTheEnumValueHaveACustomValue(enumValue) { * @param {object} generator reference to generator * @returns {boolean} true if string is in file, false otherwise */ -function checkStringInFile(path, search, generator) { +export function checkStringInFile(path, search, generator) { const fileContent = generator.fs.read(generator.destinationPath(path)); return fileContent.includes(search); } @@ -383,7 +383,7 @@ function checkStringInFile(path, search, generator) { * @param {object} generator reference to generator * @returns {boolean} true if regex is matched in file, false otherwise */ -function checkRegexInFile(path, regex, generator) { +export function checkRegexInFile(path, regex, generator) { const fileContent = generator.fs.read(generator.destinationPath(path)); return fileContent.match(regex); } @@ -393,7 +393,7 @@ function checkRegexInFile(path, regex, generator) { * @param {string} packageName - name of the blueprint's package name * @returns {string} namespace of the blueprint */ -function packageNameToNamespace(packageName) { +export function packageNameToNamespace(packageName) { return packageName.replace('generator-', ''); } @@ -402,7 +402,7 @@ function packageNameToNamespace(packageName) { * @param {string} str - any string * @returns {number} returns the calculated hash code. */ -function stringHashCode(str) { +export function stringHashCode(str) { let hash = 0; for (let i = 0; i < str.length; i++) { @@ -417,7 +417,7 @@ function stringHashCode(str) { return hash; } -function vueAddPageToRouterImport(generator, { clientSrcDir, pageName, pageFolderName, pageFilename = pageFolderName }) { +export function vueAddPageToRouterImport(generator, { clientSrcDir, pageName, pageFolderName, pageFilename = pageFolderName }) { rewriteFile( { file: `${clientSrcDir}/app/router/pages.ts`, @@ -434,7 +434,7 @@ function vueAddPageToRouterImport(generator, { clientSrcDir, pageName, pageFolde ); } -function vueAddPageToRouter(generator, { clientSrcDir, pageName, pageFilename }) { +export function vueAddPageToRouter(generator, { clientSrcDir, pageName, pageFilename }) { rewriteFile( { file: `${clientSrcDir}/app/router/pages.ts`, @@ -455,7 +455,7 @@ function vueAddPageToRouter(generator, { clientSrcDir, pageName, pageFilename }) ); } -function vueAddPageServiceToMainImport(generator, { clientSrcDir, pageName, pageFolderName, pageFilename = pageFolderName }) { +export function vueAddPageServiceToMainImport(generator, { clientSrcDir, pageName, pageFolderName, pageFilename = pageFolderName }) { rewriteFile( { file: `${clientSrcDir}/app/main.ts`, @@ -471,7 +471,7 @@ function vueAddPageServiceToMainImport(generator, { clientSrcDir, pageName, page ); } -function vueAddPageServiceToMain(generator, { clientSrcDir, pageName, pageInstance }) { +export function vueAddPageServiceToMain(generator, { clientSrcDir, pageName, pageInstance }) { rewriteFile( { file: `${clientSrcDir}/app/main.ts`, @@ -486,24 +486,3 @@ function vueAddPageServiceToMain(generator, { clientSrcDir, pageName, pageInstan generator ); } - -const utils = { - rewrite, - rewriteFile, - replaceContent, - renderContent, - deepFind, - escapeRegExp, - getJavadoc, - buildEnumInfo, - getEnumInfo, - checkStringInFile, - checkRegexInFile, - packageNameToNamespace, - stringHashCode, - vueAddPageToRouterImport, - vueAddPageToRouter, - vueAddPageServiceToMainImport, - vueAddPageServiceToMain, -}; -export default utils; diff --git a/generators/vue/generator.spec.mts b/generators/vue/generator.spec.mts index e5260ea69c60..a6a2b99b486b 100644 --- a/generators/vue/generator.spec.mts +++ b/generators/vue/generator.spec.mts @@ -9,7 +9,7 @@ import Generator from './index.mjs'; import { defaultHelpers as helpers } from '../../test/support/helpers.mjs'; import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; -import constants from '../generator-constants.mjs'; +import { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR } from '../generator-constants.mjs'; const { snakeCase } = lodash; @@ -20,7 +20,6 @@ const generator = basename(__dirname); const generatorFile = join(__dirname, 'index.mts'); const { VUE: clientFramework } = clientFrameworkTypes; -const { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR } = constants; const commonConfig = { clientFramework, nativeLanguage: 'en', languages: ['fr', 'en'] }; const samplesBuilder = () => diff --git a/generators/workspaces/generator.mjs b/generators/workspaces/generator.mjs index ecdd194bcd69..6f744691513e 100644 --- a/generators/workspaces/generator.mjs +++ b/generators/workspaces/generator.mjs @@ -22,14 +22,13 @@ import path from 'path'; import { GENERATOR_ANGULAR, GENERATOR_APP, GENERATOR_COMMON, GENERATOR_GIT } from '../generator-list.mjs'; -import constants from '../generator-constants.mjs'; +import { GENERATOR_JHIPSTER } from '../generator-constants.mjs'; import BaseGenerator from '../base/index.mjs'; import { deploymentOptions } from '../../jdl/jhipster/index.mjs'; const { DeploymentTypes: { DOCKERCOMPOSE }, } = deploymentOptions; -const { GENERATOR_JHIPSTER } = constants; /** * Base class for a generator that can be extended through a blueprint. * diff --git a/lib/support/needles.mjs b/lib/support/needles.mjs index 23e39f2f3029..290fcb0da146 100644 --- a/lib/support/needles.mjs +++ b/lib/support/needles.mjs @@ -175,7 +175,7 @@ export const createNeedleCallback = ({ needle, contentToAdd, optional = false, i * @param {string} [options.filePath] path to file * @param {string} [options.needlesPrefix] common needle prefix * @param {boolean} [options.optional=false] throw error if needle was not found - * @returns {import('../../generators/base/index.cjs').CascatedEditFileCallback | import('../../generators/base/index.cjs').EditFileCallback} + * @returns {import('../../generators/base/index.mjs').CascatedEditFileCallback | import('../../generators/base/index.mjs').EditFileCallback} */ export const createBaseNeedle = (options, needles) => { if (!needles) { diff --git a/test/app/composing.spec.mts b/test/app/composing.spec.mts index 85896bdf9ed1..70178a75e7e7 100644 --- a/test/app/composing.spec.mts +++ b/test/app/composing.spec.mts @@ -4,10 +4,9 @@ import assert from 'yeoman-assert'; import Environment from 'yeoman-environment'; import { dryRunHelpers as helpers } from '../support/helpers.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { JHIPSTER_CONFIG_DIR } from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; -const { JHIPSTER_CONFIG_DIR } = constants; const { createEnv } = Environment; helpers.createEnv = createEnv; diff --git a/test/app/database-changelog.spec.mts b/test/app/database-changelog.spec.mts index ef1a60388bc6..aba0679f1b37 100644 --- a/test/app/database-changelog.spec.mts +++ b/test/app/database-changelog.spec.mts @@ -3,11 +3,9 @@ import fse from 'fs-extra'; import helpers from 'yeoman-test'; import createMockedConfig from '../support/mock-config.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { SERVER_MAIN_RES_DIR } from '../../generators/generator-constants.mjs'; import { getEntityTemplatePath, getGenerator } from '../support/index.mjs'; -const { SERVER_MAIN_RES_DIR } = constants; - describe('jhipster:app database changelogs', () => { context('when regenerating the application', () => { describe('with cassandra database', () => { diff --git a/test/entity/database-changelog.spec.mts b/test/entity/database-changelog.spec.mts index e3fea30f879e..151b54206706 100644 --- a/test/entity/database-changelog.spec.mts +++ b/test/entity/database-changelog.spec.mts @@ -2,12 +2,11 @@ import path from 'path'; import fse from 'fs-extra'; import { skipPrettierHelpers as helpers } from '../support/helpers.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { SERVER_MAIN_RES_DIR } from '../../generators/generator-constants.mjs'; import createMockedConfig from '../support/mock-config.mjs'; import { getEntityTemplatePath, getGenerator } from '../support/index.mjs'; import BaseApplicationGenerator from '../../generators/base-application/generator.mjs'; -const { SERVER_MAIN_RES_DIR } = constants; class MockedLanguagesGenerator extends BaseApplicationGenerator { get [BaseApplicationGenerator.PREPARING]() { return { diff --git a/test/entity/single-entity.spec.mts b/test/entity/single-entity.spec.mts index f9626a2856f2..3aae5afe7944 100644 --- a/test/entity/single-entity.spec.mts +++ b/test/entity/single-entity.spec.mts @@ -2,12 +2,11 @@ import path from 'path'; import fse from 'fs-extra'; import { skipPrettierHelpers as helpers } from '../support/helpers.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR, CLIENT_MAIN_SRC_DIR } from '../../generators/generator-constants.mjs'; import createMockedConfig from '../support/mock-config.mjs'; import { getTemplatePath, getEntityTemplatePath, getGenerator } from '../support/index.mjs'; import BaseApplicationGenerator from '../../generators/base-application/generator.mjs'; -const { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR, CLIENT_MAIN_SRC_DIR } = constants; const DEFAULT_TEST_OPTIONS = { skipInstall: true, skipChecks: true, skipPrettier: true }; class MockedLanguagesGenerator extends BaseApplicationGenerator { diff --git a/test/heroku.spec.mts b/test/heroku.spec.mts index 29c0191843c4..c383bc06b068 100644 --- a/test/heroku.spec.mts +++ b/test/heroku.spec.mts @@ -5,15 +5,11 @@ import sinon from 'sinon'; import ChildProcess from 'child_process'; import { jestExpect as expect } from 'mocha-expect-snapshot'; -import constants from '../generators/generator-constants.mjs'; +import { SERVER_MAIN_RES_DIR, SERVER_MAIN_RES_DIR } from '../generators/generator-constants.mjs'; import { getTemplatePath, getGenerator } from './support/index.mjs'; const expectedFiles = { - monolith: [ - 'Procfile', - `${constants.SERVER_MAIN_RES_DIR}/config/bootstrap-heroku.yml`, - `${constants.SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, - ], + monolith: ['Procfile', `${SERVER_MAIN_RES_DIR}/config/bootstrap-heroku.yml`, `${SERVER_MAIN_RES_DIR}/config/application-heroku.yml`], }; describe('JHipster Heroku Sub Generator', () => { @@ -174,8 +170,8 @@ describe('JHipster Heroku Sub Generator', () => { it('creates expected monolith files', () => { assert.file(expectedFiles.monolith); assert.fileContent('.yo-rc.json', '"herokuDeployType": "jar"'); - assert.fileContent(`${constants.SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'datasource:'); - assert.noFileContent(`${constants.SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'mongodb:'); + assert.fileContent(`${SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'datasource:'); + assert.noFileContent(`${SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'mongodb:'); }); }); @@ -232,8 +228,8 @@ describe('JHipster Heroku Sub Generator', () => { }); it('creates expected monolith files', () => { assert.file(expectedFiles.monolith); - assert.fileContent(`${constants.SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'datasource:'); - assert.noFileContent(`${constants.SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'mongodb:'); + assert.fileContent(`${SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'datasource:'); + assert.noFileContent(`${SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'mongodb:'); }); }); @@ -290,8 +286,8 @@ describe('JHipster Heroku Sub Generator', () => { it('creates expected monolith files', () => { assert.file(expectedFiles.monolith); assert.fileContent('.yo-rc.json', '"herokuDeployType": "jar"'); - assert.fileContent(`${constants.SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'datasource:'); - assert.noFileContent(`${constants.SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'mongodb:'); + assert.fileContent(`${SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'datasource:'); + assert.noFileContent(`${SERVER_MAIN_RES_DIR}/config/application-heroku.yml`, 'mongodb:'); }); }); }); diff --git a/test/needle-api/needle-client-angular.spec.mts b/test/needle-api/needle-client-angular.spec.mts index f789277eaed1..b1ac527082ef 100644 --- a/test/needle-api/needle-client-angular.spec.mts +++ b/test/needle-api/needle-client-angular.spec.mts @@ -1,12 +1,12 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import { getGenerator } from '../support/index.mjs'; +import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; import ClientGenerator from '../../generators/client/index.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { CLIENT_MAIN_SRC_DIR } from '../../generators/generator-constants.mjs'; -const ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR; -const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; +const { ANGULAR } = clientFrameworkTypes; const mockBlueprintSubGen = class extends ClientGenerator { constructor(args, opts, features) { diff --git a/test/needle-api/needle-client-i18n.spec.mts b/test/needle-api/needle-client-i18n.spec.mts index 7f846db4eeed..aa169d262203 100644 --- a/test/needle-api/needle-client-i18n.spec.mts +++ b/test/needle-api/needle-client-i18n.spec.mts @@ -3,11 +3,11 @@ import helpers from 'yeoman-test'; import fse from 'fs-extra'; import LanguagesGenerator from '../../generators/languages/index.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; +import { CLIENT_MAIN_SRC_DIR } from '../../generators/generator-constants.mjs'; import { getGenerator, getTemplatePath } from '../support/index.mjs'; -const ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR; -const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; +const { ANGULAR } = clientFrameworkTypes; const generatorPath = getGenerator('languages'); diff --git a/test/needle-api/needle-client-react.spec.mts b/test/needle-api/needle-client-react.spec.mts index 476397cf5e2d..0709bd1e3e50 100644 --- a/test/needle-api/needle-client-react.spec.mts +++ b/test/needle-api/needle-client-react.spec.mts @@ -1,11 +1,11 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ClientGenerator from '../../generators/client/index.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { CLIENT_MAIN_SRC_DIR } from '../../generators/generator-constants.mjs'; +import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; import { getGenerator } from '../support/index.mjs'; -const REACT = constants.SUPPORTED_CLIENT_FRAMEWORKS.REACT; -const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; +const { REACT } = clientFrameworkTypes; // eslint-disable-next-line @typescript-eslint/no-explicit-any const mockBlueprintSubGen: any = class extends ClientGenerator { diff --git a/test/needle-api/needle-client-vue.spec.mts b/test/needle-api/needle-client-vue.spec.mts index d6099b7fb1a6..9e04ea0c2633 100644 --- a/test/needle-api/needle-client-vue.spec.mts +++ b/test/needle-api/needle-client-vue.spec.mts @@ -2,11 +2,12 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ClientGenerator from '../../generators/client/index.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { CLIENT_MAIN_SRC_DIR } from '../../generators/generator-constants.mjs'; +import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; + import { getGenerator } from '../support/index.mjs'; -const VUE = constants.SUPPORTED_CLIENT_FRAMEWORKS.VUE; -const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; +const { VUE } = clientFrameworkTypes; // eslint-disable-next-line @typescript-eslint/no-explicit-any const mockBlueprintSubGen: any = class extends ClientGenerator { diff --git a/test/needle-api/needle-client-webpack.spec.mts b/test/needle-api/needle-client-webpack.spec.mts index 61e0abf3f526..b2d6f3168e3b 100644 --- a/test/needle-api/needle-client-webpack.spec.mts +++ b/test/needle-api/needle-client-webpack.spec.mts @@ -1,11 +1,11 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ClientGenerator from '../../generators/client/index.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { CLIENT_WEBPACK_DIR } from '../../generators/generator-constants.mjs'; +import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; import { getGenerator } from '../support/index.mjs'; -const { ANGULAR, VUE, REACT } = constants.SUPPORTED_CLIENT_FRAMEWORKS; -const CLIENT_WEBPACK_DIR = constants.CLIENT_WEBPACK_DIR; +const { ANGULAR, VUE, REACT } = clientFrameworkTypes; const assetFrom = 'source'; const assetTo = 'target'; diff --git a/test/needle-api/needle-client.spec.mts b/test/needle-api/needle-client.spec.mts index 36efe73fcaa2..16b301422640 100644 --- a/test/needle-api/needle-client.spec.mts +++ b/test/needle-api/needle-client.spec.mts @@ -1,11 +1,9 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ClientGenerator from '../../generators/client/index.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { CLIENT_MAIN_SRC_DIR } from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; -const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; - // eslint-disable-next-line @typescript-eslint/no-explicit-any const mockBlueprintSubGen: any = class extends ClientGenerator { constructor(args, opts, features) { diff --git a/test/needle-api/needle-server-cache.spec.mts b/test/needle-api/needle-server-cache.spec.mts index cf5321515361..01412a28916a 100644 --- a/test/needle-api/needle-server-cache.spec.mts +++ b/test/needle-api/needle-server-cache.spec.mts @@ -1,11 +1,9 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ServerGenerator from '../../generators/server/index.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { SERVER_MAIN_SRC_DIR } from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; -const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; - const DEFAULT_TEST_OPTIONS = { skipInstall: true, skipChecks: true, skipPrettier: true }; // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/test/needle-api/needle-server-liquibase.spec.mts b/test/needle-api/needle-server-liquibase.spec.mts index 49f1be01e6cc..999df1c81108 100644 --- a/test/needle-api/needle-server-liquibase.spec.mts +++ b/test/needle-api/needle-server-liquibase.spec.mts @@ -4,11 +4,9 @@ import helpers from 'yeoman-test'; import fse from 'fs-extra'; import { fileURLToPath } from 'url'; import ServerGenerator from '../../generators/server/index.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { SERVER_MAIN_RES_DIR } from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; -const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; - const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); diff --git a/test/needle-api/needle-server-logback-spring.spec.mts b/test/needle-api/needle-server-logback-spring.spec.mts index 5f9853a2673b..fff71f3c40ea 100644 --- a/test/needle-api/needle-server-logback-spring.spec.mts +++ b/test/needle-api/needle-server-logback-spring.spec.mts @@ -1,11 +1,9 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import ServerGenerator from '../../generators/server/index.mjs'; -import constants from '../../generators/generator-constants.mjs'; +import { SERVER_MAIN_RES_DIR } from '../../generators/generator-constants.mjs'; import { getGenerator } from '../support/index.mjs'; -const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; - const filePath = `${SERVER_MAIN_RES_DIR}logback-spring.xml`; // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/test/page.spec.mts b/test/page.spec.mts index e66c6fbb71fa..876b565a05eb 100644 --- a/test/page.spec.mts +++ b/test/page.spec.mts @@ -1,10 +1,8 @@ import helpers from 'yeoman-test'; import EnvironmentBuilder from '../cli/environment-builder.mjs'; -import constants from '../generators/generator-constants.mjs'; +import { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR } from '../generators/generator-constants.mjs'; -const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; -const CLIENT_TEST_SRC_DIR = constants.CLIENT_TEST_SRC_DIR; const CLIENT_SPEC_SRC_DIR = `${CLIENT_TEST_SRC_DIR}spec/`; const pageName = 'MyTestPage'; diff --git a/test/spring-controller.spec.mts b/test/spring-controller.spec.mts index d1ff62d46861..da2651e1c693 100644 --- a/test/spring-controller.spec.mts +++ b/test/spring-controller.spec.mts @@ -2,12 +2,9 @@ import path from 'path'; import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import fse from 'fs-extra'; -import constants from '../generators/generator-constants.mjs'; +import { SERVER_MAIN_SRC_DIR, SERVER_TEST_SRC_DIR, GENERATOR_JHIPSTER } from '../generators/generator-constants.mjs'; import { getGenerator, getTemplatePath } from './support/index.mjs'; -const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; -const SERVER_TEST_SRC_DIR = constants.SERVER_TEST_SRC_DIR; - const generator = getGenerator('spring-controller'); describe('JHipster generator spring-controller', () => { @@ -56,11 +53,11 @@ describe('JHipster generator spring-controller', () => { .run(generator) .inTmpDir(dir => { const config = { - ...fse.readJSONSync(getTemplatePath('default/.yo-rc.json'))[constants.GENERATOR_JHIPSTER], + ...fse.readJSONSync(getTemplatePath('default/.yo-rc.json'))[GENERATOR_JHIPSTER], packageFolder: undefined, packageName: 'com.test', }; - fse.writeJsonSync(path.join(dir, '.yo-rc.json'), { [constants.GENERATOR_JHIPSTER]: config }); + fse.writeJsonSync(path.join(dir, '.yo-rc.json'), { [GENERATOR_JHIPSTER]: config }); }) .withArguments(['fooBar']) .withPrompts({ diff --git a/test/spring-service.spec.mts b/test/spring-service.spec.mts index 62b979275f5a..d0610d2fbd63 100644 --- a/test/spring-service.spec.mts +++ b/test/spring-service.spec.mts @@ -1,11 +1,9 @@ import assert from 'yeoman-assert'; import helpers from 'yeoman-test'; import fse from 'fs-extra'; -import constants from '../generators/generator-constants.mjs'; +import { SERVER_MAIN_SRC_DIR } from '../generators/generator-constants.mjs'; import { getGenerator, getTemplatePath } from './support/index.mjs'; -const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR; - const generator = getGenerator('spring-service'); describe('JHipster generator service', () => { diff --git a/test/support/tests.mjs b/test/support/tests.mjs index a3716e65e07a..ad12402266cb 100644 --- a/test/support/tests.mjs +++ b/test/support/tests.mjs @@ -4,12 +4,10 @@ import sinon from 'sinon'; import { existsSync } from 'fs'; import { fileURLToPath } from 'url'; -import constants from '../../generators/generator-constants.mjs'; +import { GENERATOR_JHIPSTER } from '../../generators/generator-constants.mjs'; import { skipPrettierHelpers as helpers } from './helpers.mjs'; import { PRIORITY_NAMES, ENTITY_PRIORITY_NAMES, PRIORITY_NAMES_LIST } from '../../generators/base-application/priorities.mjs'; -const { GENERATOR_JHIPSTER } = constants; - const { CONFIGURING_EACH_ENTITY, LOADING_ENTITIES, diff --git a/test/utils.spec.mjs b/test/utils.spec.mjs index 6da81d672edf..fc74a1100c1f 100644 --- a/test/utils.spec.mjs +++ b/test/utils.spec.mjs @@ -3,7 +3,7 @@ import { fileURLToPath } from 'url'; import assert from 'yeoman-assert'; import path, { dirname } from 'path'; -import utils from '../generators/utils.mjs'; +import { getEnumInfo, getJavadoc, deepFind, stringHashCode, renderContent } from '../generators/utils.mjs'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -12,23 +12,23 @@ describe('JHipster Utils', () => { describe('::getJavadoc', () => { describe('when passing a negative or nil increment', () => { it('returns the comment with no increment', () => { - assert.textEqual(utils.getJavadoc('whatever', -42), '/**\n * whatever\n */'); - assert.textEqual(utils.getJavadoc('whatever', 0), '/**\n * whatever\n */'); + assert.textEqual(getJavadoc('whatever', -42), '/**\n * whatever\n */'); + assert.textEqual(getJavadoc('whatever', 0), '/**\n * whatever\n */'); }); }); describe('when passing a positive increment', () => { it('returns the comment with the increment', () => { - assert.textEqual(utils.getJavadoc('whatever', 1), ' /**\n * whatever\n */'); + assert.textEqual(getJavadoc('whatever', 1), ' /**\n * whatever\n */'); }); }); describe('when passing a nil comment', () => { it('inserts an empty comment instead of failing', () => { - assert.textEqual(utils.getJavadoc(null, 1), ' /**\n * \n */'); + assert.textEqual(getJavadoc(null, 1), ' /**\n * \n */'); }); }); describe('when passing a comment containing double quotes', () => { it('escapes the quotes', () => { - assert.textEqual(utils.getJavadoc('Comment="KO"', 1), ' /**\n * Comment=\\"KO\\"\n */'); + assert.textEqual(getJavadoc('Comment="KO"', 1), ' /**\n * Comment=\\"KO\\"\n */'); }); }); }); @@ -39,7 +39,7 @@ describe('JHipster Utils', () => { before(() => { const clientRootFolder = 'root'; const field = { enumName: 'fieldName', fieldType: 'BigLetters', fieldValues: 'AAA, BBB', fieldTypeJavadoc: 'enum comment' }; - enumInfo = utils.getEnumInfo(field, clientRootFolder); + enumInfo = getEnumInfo(field, clientRootFolder); }); it("returns the enum's name", () => { @@ -61,7 +61,7 @@ describe('JHipster Utils', () => { before(() => { const clientRootFolder = 'root'; const field = { enumName: 'fieldName', fieldValues: 'AAA, BBB' }; - enumInfo = utils.getEnumInfo(field, clientRootFolder); + enumInfo = getEnumInfo(field, clientRootFolder); }); it('returns whether there are custom enums', () => { @@ -82,7 +82,7 @@ describe('JHipster Utils', () => { before(() => { const clientRootFolder = 'root'; const field = { enumName: 'fieldName', fieldValues: 'AAA(aaa), BBB' }; - enumInfo = utils.getEnumInfo(field, clientRootFolder); + enumInfo = getEnumInfo(field, clientRootFolder); }); it('returns whether there are custom enums', () => { @@ -108,7 +108,7 @@ describe('JHipster Utils', () => { before(() => { const clientRootFolder = 'root'; const field = { enumName: 'fieldName', fieldValues: 'AAA(aaa), BBB(bbb)' }; - enumInfo = utils.getEnumInfo(field, clientRootFolder); + enumInfo = getEnumInfo(field, clientRootFolder); }); it('returns whether there are custom enums', () => { @@ -133,7 +133,7 @@ describe('JHipster Utils', () => { before(() => { const clientRootFolder = 'root'; const field = { enumName: 'fieldName', fieldValues: 'AAA(aaa), BBB(bbb and b)' }; - enumInfo = utils.getEnumInfo(field, clientRootFolder); + enumInfo = getEnumInfo(field, clientRootFolder); }); it('returns whether there are custom enums', () => { @@ -165,7 +165,7 @@ describe('JHipster Utils', () => { BBB: 'second comment', }, }; - enumInfo = utils.getEnumInfo(field, clientRootFolder); + enumInfo = getEnumInfo(field, clientRootFolder); }); it('returns whether there are custom enums', () => { @@ -190,7 +190,7 @@ describe('JHipster Utils', () => { before(() => { const field = { enumName: 'fieldName', fieldValues: 'AAA, BBB' }; - enumInfo = utils.getEnumInfo(field); + enumInfo = getEnumInfo(field); }); it('returns an empty string for the clientRootFolder property', () => { @@ -203,7 +203,7 @@ describe('JHipster Utils', () => { before(() => { const field = { enumName: 'fieldName', fieldValues: 'AAA, BBB' }; const clientRootFolder = 'root'; - enumInfo = utils.getEnumInfo(field, clientRootFolder); + enumInfo = getEnumInfo(field, clientRootFolder); }); it('returns the clientRootFolder property suffixed by a dash', () => { @@ -219,26 +219,26 @@ describe('JHipster Utils', () => { }; describe('the key is found in the object that is searched', () => { it('returns the value associated to the key', () => { - const value = utils.deepFind(jsonData, 'foo21'); + const value = deepFind(jsonData, 'foo21'); assert.textEqual(value, 'foo21value'); }); }); describe('the key is not found in the object that is searched', () => { it('returns undefined', () => { - const value = utils.deepFind(jsonData, 'foo123'); + const value = deepFind(jsonData, 'foo123'); assert.textEqual(`${value}`, 'undefined'); }); }); }); describe('::stringHashCode', () => { it('calculates hash', () => { - assert.equal(utils.stringHashCode('some text'), 642107175); + assert.equal(stringHashCode('some text'), 642107175); }); }); describe('::renderContent', () => { const fixturesPath = path.join(__dirname, 'fixtures', 'renderContent'); it('should render the included content', done => { - utils.renderContent( + renderContent( path.join(fixturesPath, 'include.ejs'), { templatePath: tmpl => tmpl }, {}, @@ -250,7 +250,7 @@ describe('JHipster Utils', () => { ); }); it('when 2 roots are provided, first should have precedence', done => { - utils.renderContent( + renderContent( path.join(fixturesPath, 'include.ejs'), { templatePath: tmpl => tmpl }, {}, @@ -262,7 +262,7 @@ describe('JHipster Utils', () => { ); }); it('when 2 roots are provided, should find the template in the second folder if does not exists in the first', done => { - utils.renderContent( + renderContent( path.join(fixturesPath, 'include_common.ejs'), { templatePath: tmpl => tmpl }, {}, From faa9c22cce3671c1d13f4f56a81a5e69661302c9 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Wed, 28 Dec 2022 11:41:31 +0100 Subject: [PATCH 6/8] Update generators/base-application/priorities.mjs Co-authored-by: Daniel Franco --- generators/base-application/priorities.mjs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/generators/base-application/priorities.mjs b/generators/base-application/priorities.mjs index 71e9421a8920..c9d20b894859 100644 --- a/generators/base-application/priorities.mjs +++ b/generators/base-application/priorities.mjs @@ -1,4 +1,23 @@ -import { QUEUE_PREFIX, PRIORITY_NAMES as PRIORITY_NAMES_BASE, QUEUES as QUEUES_BASE } from '../base/priorities.mjs'; +/** + * Copyright 2013-2022 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, TRANSFORM, PRE_CONFLICTS } = PRIORITY_NAMES_BASE; From 9752802e66e8b21d09b701b058fcdd9de90980de Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Wed, 28 Dec 2022 15:37:18 +0100 Subject: [PATCH 7/8] lint --- generators/base-application/priorities.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/base-application/priorities.mjs b/generators/base-application/priorities.mjs index c9d20b894859..9620539b31fb 100644 --- a/generators/base-application/priorities.mjs +++ b/generators/base-application/priorities.mjs @@ -16,8 +16,8 @@ * 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'; + +import { QUEUE_PREFIX, PRIORITY_NAMES as PRIORITY_NAMES_BASE, QUEUES as QUEUES_BASE } from '../base/priorities.mjs'; const { DEFAULT, TRANSFORM, PRE_CONFLICTS } = PRIORITY_NAMES_BASE; From 0ab1eeea33c4e890285cedadd3405c73c8e61216 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Wed, 28 Dec 2022 19:38:03 +0100 Subject: [PATCH 8/8] rebased from main --- generators/base/generator-base-blueprint.mjs | 2 +- generators/base/generator-base-private.mjs | 2 +- generators/cleanup.mjs | 2 -- generators/server/generator.mjs | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/generators/base/generator-base-blueprint.mjs b/generators/base/generator-base-blueprint.mjs index d0a7dc14f060..f4efde069618 100644 --- a/generators/base/generator-base-blueprint.mjs +++ b/generators/base/generator-base-blueprint.mjs @@ -21,7 +21,7 @@ import fs from 'fs'; import path from 'path'; import semver from 'semver'; -import { packageJson as packagejs } from '../../lib/index.mjs'; +import { packageJson } from '../../lib/index.mjs'; import { packageNameToNamespace } from '../utils.mjs'; import JHipsterBaseGenerator from './generator-base.mjs'; import { mergeBlueprints, parseBluePrints, loadBlueprintsFromConfiguration, normalizeBlueprintName } from '../../utils/blueprint.mjs'; diff --git a/generators/base/generator-base-private.mjs b/generators/base/generator-base-private.mjs index 5c1ce8b15e80..538300c73fa1 100644 --- a/generators/base/generator-base-private.mjs +++ b/generators/base/generator-base-private.mjs @@ -27,7 +27,7 @@ import https from 'https'; import { databaseTypes, buildToolTypes, fieldTypes, validations, clientFrameworkTypes } from '../../jdl/jhipster/index.mjs'; -import { packageJson as packagejs } from '../../lib/index.mjs'; +import { packageJson } from '../../lib/index.mjs'; import { getJavadoc, renderContent } from '../utils.mjs'; import { JAVA_COMPATIBLE_VERSIONS } from '../generator-constants.mjs'; import { stringify } from '../../utils/index.mjs'; diff --git a/generators/cleanup.mjs b/generators/cleanup.mjs index 6cea90ca074e..99df8ad7f57e 100644 --- a/generators/cleanup.mjs +++ b/generators/cleanup.mjs @@ -20,8 +20,6 @@ import { SERVER_MAIN_RES_DIR, ANGULAR_DIR, REACT_DIR, VUE_DIR, CLIENT_WEBPACK_DIR, DOCKER_DIR } from './generator-constants.mjs'; import { languageSnakeCase, languageToJavaLanguage } from './languages/utils.mjs'; import { clientFrameworkTypes } from '../jdl/jhipster/index.mjs'; -import constants from './generator-constants.cjs'; -import { languageSnakeCase, languageToJavaLanguage } from './languages/utils.mjs'; const { ANGULAR, REACT, VUE } = clientFrameworkTypes; diff --git a/generators/server/generator.mjs b/generators/server/generator.mjs index 0aa386c392e4..50aa9a5a4a39 100644 --- a/generators/server/generator.mjs +++ b/generators/server/generator.mjs @@ -97,7 +97,6 @@ const { MICROSERVICE, GATEWAY } = applicationTypes; const { KAFKA } = messageBrokerTypes; const NO_SEARCH_ENGINE = searchEngineTypes.NO; -const { SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR, SERVER_TEST_SRC_DIR, SERVER_TEST_RES_DIR, MAIN_DIR, TEST_DIR } = constants; const { CommonDBTypes, RelationalOnlyDBTypes } = fieldTypes; const { INSTANT } = CommonDBTypes; const { BYTES, BYTE_BUFFER } = RelationalOnlyDBTypes;