diff --git a/generators/docker-base.js b/generators/docker-base.js
index c25375f19d6..4519d2f0450 100644
--- a/generators/docker-base.js
+++ b/generators/docker-base.js
@@ -111,8 +111,7 @@ function loadConfigs() {
if (this.fs.exists(`${path}/.yo-rc.json`)) {
const config = this.getJhipsterConfig(`${path}/.yo-rc.json`).getAll();
_.defaults(config, defaultConfig);
- this.loadServerConfig(config);
- this.loadDerivedServerConfig(config);
+ this.loadServerConfig(config, config);
this.loadDerivedPlatformConfig(config);
this.loadDerivedAppConfig(config);
diff --git a/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs b/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs
index 46259a98ce4..5ecf4092486 100644
--- a/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs
+++ b/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs
@@ -186,25 +186,25 @@ _%>
<%_ } _%>
}
: {
+<%_ for (field of fields.filter(field => !field.id)) {
+ const fieldName = field.fieldName;
+ if (field.fieldIsEnum) {
+ const enumValues = field.enumValues;_%>
+<%= fieldName %>: '<%= enumValues[0].name %>',
+ <%_ } _%>
+<%_ } _%>
...<%= entityInstance %>Entity,
<%_ for (field of fields.filter(field => !field.id)) {
- const fieldType = field.fieldType;
const fieldName = field.fieldName;
- const fieldNameHumanized = field.fieldNameHumanized;
-
- if (field.fieldTypeTimed) { _%>
+ if (field.fieldTypeTimed) { _%>
<%= fieldName %>: convertDateTimeFromServer(<%= entityInstance %>Entity.<%= fieldName %>),
- <%_ } else if (field.fieldIsEnum) {
- const enumValues = field.enumValues;
- _%>
- <%= fieldName %>: '<%= enumValues[0].name %>',
<%_ } _%>
<%_ } _%>
<%_ relationships.forEach(rel => {
const otherEntityPkName = rel.otherEntity.primaryKey && rel.otherEntity.primaryKey.name || 'id';
const relationshipFieldName = rel.relationshipFieldName;
const relationshipFieldNamePlural = rel.relationshipFieldNamePlural;
- if (rel.relationshipManyToOne || (rel.relationshipOneToOne && rel.ownerSide)) { _%>
+ if (rel.relationshipManyToOne || (rel.relationshipOneToOne && rel.ownerSide)) { _%>
<%= relationshipFieldName %>Id: <%= entityInstance %>Entity?.<%= relationshipFieldName %>?.id,
<%_ } else if (rel.relationshipManyToMany && rel.ownerSide) { _%>
<%= relationshipFieldNamePlural %>: <%= entityInstance %>Entity?.<%= relationshipFieldNamePlural %>?.map(e => e.<%= otherEntityPkName %>.toString()),
diff --git a/generators/generator-base.js b/generators/generator-base.js
index 9ff3537fadd..88e3632a960 100644
--- a/generators/generator-base.js
+++ b/generators/generator-base.js
@@ -56,7 +56,7 @@ const NO_DATABASE = databaseTypes.NO;
const { GENERATOR_BOOTSTRAP } = require('./generator-list');
const { PROMETHEUS, ELK } = require('../jdl/jhipster/monitoring-types');
const { JWT, OAUTH2, SESSION } = require('../jdl/jhipster/authentication-types');
-const { EHCACHE, REDIS, HAZELCAST, MEMCACHED } = require('../jdl/jhipster/cache-types');
+const { CAFFEINE, EHCACHE, REDIS, HAZELCAST, INFINISPAN, MEMCACHED } = require('../jdl/jhipster/cache-types');
const { GRADLE, MAVEN } = require('../jdl/jhipster/build-tool-types');
const { SPRING_WEBSOCKET } = require('../jdl/jhipster/websocket-types');
const { KAFKA } = require('../jdl/jhipster/message-broker-types');
@@ -64,7 +64,18 @@ const { CONSUL, EUREKA } = require('../jdl/jhipster/service-discovery-types');
const { GATLING, CUCUMBER, PROTRACTOR, CYPRESS } = require('../jdl/jhipster/test-framework-types');
const { GATEWAY, MICROSERVICE, MONOLITH } = require('../jdl/jhipster/application-types');
const { ELASTICSEARCH } = require('../jdl/jhipster/search-engine-types');
-
+const { getBase64Secret, getRandomHex } = require('./utils');
+const cacheTypes = require('../jdl/jhipster/cache-types');
+const serviceDiscoveryTypes = require('../jdl/jhipster/service-discovery-types');
+const searchEngineTypes = require('../jdl/jhipster/search-engine-types');
+const messageBrokerTypes = require('../jdl/jhipster/message-broker-types');
+const websocketTypes = require('../jdl/jhipster/websocket-types');
+
+const NO_CACHE = cacheTypes.NO;
+const NO_SERVICE_DISCOVERY = serviceDiscoveryTypes.NO;
+const NO_SEARCH_ENGINE = searchEngineTypes.FALSE;
+const NO_MESSAGE_BROKER = messageBrokerTypes.NO;
+const NO_WEBSOCKET = websocketTypes.FALSE;
// Reverse order.
const CUSTOM_PRIORITIES = [
{
@@ -2638,19 +2649,93 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`;
}
loadDerivedServerConfig(dest = this) {
+ if (!dest.packageFolder) {
+ dest.packageFolder = dest.packageName.replace(/\./g, '/');
+ }
+
+ // JWT authentication is mandatory with Eureka, so the JHipster Registry
+ // can control the applications
+ if (dest.serviceDiscoveryType === EUREKA && dest.authenticationType !== OAUTH2) {
+ dest.authenticationType = JWT;
+ }
+
+ // Generate JWT secret key if key does not already exist in config
+ if ((dest.authenticationType === JWT || dest.applicationType === MICROSERVICE) && dest.jwtSecretKey === undefined) {
+ dest.jwtSecretKey = getBase64Secret.call(this, null, 64);
+ }
+ // Generate remember me key if key does not already exist in config
+ if (dest.authenticationType === SESSION && !dest.rememberMeKey) {
+ dest.rememberMeKey = getRandomHex();
+ }
+
+ if (dest.authenticationType === OAUTH2) {
+ dest.skipUserManagement = true;
+ }
+
+ if (dest.enableHibernateCache && [NO_CACHE, MEMCACHED].includes(dest.cacheProvider)) {
+ this.info(`Disabling hibernate cache for cache provider ${dest.cacheProvider}`);
+ dest.enableHibernateCache = false;
+ }
+
+ // Convert to false for templates.
+ if (dest.serviceDiscoveryType === NO_SERVICE_DISCOVERY || !dest.serviceDiscoveryType) {
+ dest.serviceDiscoveryType = false;
+ }
+ if (dest.websocket === NO_WEBSOCKET || !dest.websocket) {
+ dest.websocket = false;
+ }
+ if (dest.searchEngine === NO_SEARCH_ENGINE || !dest.searchEngine) {
+ dest.searchEngine = false;
+ }
+ if (dest.messageBroker === NO_MESSAGE_BROKER || !dest.messageBroker) {
+ dest.messageBroker = false;
+ }
+
+ if (!dest.databaseType && dest.prodDatabaseType) {
+ dest.databaseType = this.getDBTypeFromDBValue(dest.prodDatabaseType);
+ }
+ if (!dest.devDatabaseType && dest.prodDatabaseType) {
+ dest.devDatabaseType = dest.prodDatabaseType;
+ }
+
+ // force variables unused by microservice applications
+ if (dest.applicationType === MICROSERVICE) {
+ dest.websocket = false;
+ }
+
+ const databaseType = dest.databaseType;
+ if (databaseType === NO_DATABASE) {
+ dest.devDatabaseType = NO_DATABASE;
+ dest.prodDatabaseType = NO_DATABASE;
+ dest.enableHibernateCache = false;
+ dest.skipUserManagement = true;
+ } else if ([MONGODB, NEO4J, COUCHBASE, CASSANDRA].includes(databaseType)) {
+ dest.devDatabaseType = databaseType;
+ dest.prodDatabaseType = databaseType;
+ dest.enableHibernateCache = false;
+ }
dest.buildToolGradle = dest.buildTool === GRADLE;
dest.buildToolMaven = dest.buildTool === MAVEN;
dest.buildToolUnknown = !dest.buildToolGradle && !dest.buildToolMaven;
dest.buildDir = this.getBuildDirectoryForBuildTool(dest.buildTool);
- dest.cacheProviderRedis = dest.cacheProvider === REDIS;
+ dest.cacheProviderNo = dest.cacheProvider === NO_CACHE;
+ dest.cacheProviderCaffeine = dest.cacheProvider === CAFFEINE;
+ dest.cacheProviderEhCache = dest.cacheProvider === EHCACHE;
dest.cacheProviderHazelcast = dest.cacheProvider === HAZELCAST;
+ dest.cacheProviderInfinispan = dest.cacheProvider === INFINISPAN;
dest.cacheProviderMemcached = dest.cacheProvider === MEMCACHED;
+ dest.cacheProviderRedis = dest.cacheProvider === REDIS;
dest.devDatabaseTypeH2Disk = dest.devDatabaseType === H2_DISK;
dest.devDatabaseTypeH2Memory = dest.devDatabaseType === H2_MEMORY;
dest.devDatabaseTypeH2Any = dest.devDatabaseTypeH2Disk || dest.devDatabaseTypeH2Memory;
dest.devDatabaseTypeCouchbase = dest.devDatabaseType === COUCHBASE;
+ dest.devDatabaseTypeMariadb = dest.devDatabaseType === MARIADB;
+ dest.devDatabaseTypeMssql = dest.devDatabaseType === MSSQL;
+ dest.devDatabaseTypeMysql = dest.devDatabaseType === MYSQL;
+ dest.devDatabaseTypeOracle = dest.devDatabaseType === ORACLE;
+ dest.devDatabaseTypePostgres = dest.devDatabaseType === POSTGRESQL;
dest.prodDatabaseTypeCouchbase = dest.prodDatabaseType === COUCHBASE;
dest.prodDatabaseTypeH2Disk = dest.prodDatabaseType === H2_DISK;
diff --git a/generators/languages/index.js b/generators/languages/index.js
index cf6cd3f8723..626f6ed3a91 100644
--- a/generators/languages/index.js
+++ b/generators/languages/index.js
@@ -24,6 +24,7 @@ const prompts = require('./prompts');
const statistics = require('../statistics');
const constants = require('../generator-constants');
const { translationDefaultConfig } = require('../generator-defaults');
+const { GENERATOR_LANGUAGES } = require('../generator-list');
const ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR;
const REACT = constants.SUPPORTED_CLIENT_FRAMEWORKS.REACT;
@@ -182,7 +183,6 @@ module.exports = class extends BaseBlueprintGenerator {
this.loadDerivedClientConfig();
this.loadPlatformConfig();
this.loadServerConfig();
- this.loadDerivedServerConfig();
this.loadTranslationConfig();
},
};
@@ -221,7 +221,7 @@ module.exports = class extends BaseBlueprintGenerator {
...super._missingPreDefault(),
insight() {
- statistics.sendSubGenEvent('generator', 'languages');
+ statistics.sendSubGenEvent('generator', GENERATOR_LANGUAGES);
},
};
}
diff --git a/generators/openshift/index.js b/generators/openshift/index.js
index dae2f791253..2f457eb7105 100644
--- a/generators/openshift/index.js
+++ b/generators/openshift/index.js
@@ -24,6 +24,9 @@ const { KAFKA } = require('../../jdl/jhipster/message-broker-types');
const { PROMETHEUS } = require('../../jdl/jhipster/monitoring-types');
const { ELASTICSEARCH } = require('../../jdl/jhipster/search-engine-types');
const { GATEWAY, MONOLITH } = require('../../jdl/jhipster/application-types');
+const { EUREKA } = require('../../jdl/jhipster/service-discovery-types');
+const serviceDiscoveryTypes = require('../../jdl/jhipster/service-discovery-types');
+const { StorageTypes } = require('../../jdl/jhipster/openshift-platform-types');
const databaseTypes = require('../../jdl/jhipster/database-types');
const writeFiles = require('./files').writeFiles;
const BaseDockerGenerator = require('../generator-base-docker');
@@ -32,6 +35,8 @@ const { setupKubernetesConstants } = require('../kubernetes-base');
const statistics = require('../statistics');
const NO_DATABASE = databaseTypes.NO;
+const NO_SERVICE_DISCOVERY = serviceDiscoveryTypes.NO;
+const { EPHEMERAL, PERSISTENT } = StorageTypes;
let useBlueprints;
@@ -167,6 +172,7 @@ module.exports = class extends BaseDockerGenerator {
this.loadDerivedAppConfig(element);
});
this.loadDeploymentConfig(this);
+ this._loadDerivedOpenshiftConfig(this);
},
};
}
@@ -217,7 +223,7 @@ module.exports = class extends BaseDockerGenerator {
if (this.monitoring === PROMETHEUS) {
this.log(` ${chalk.cyan(`oc process -f ${this.directoryPath}ocp/monitoring/jhipster-metrics.yml | oc apply -f -`)}`);
}
- if (this.useKafka === true) {
+ if (this.useKafka) {
this.log(` ${chalk.cyan(`oc process -f ${this.directoryPath}ocp/messagebroker/kafka.yml | oc apply -f -`)}`);
}
for (let i = 0, regIndex = 0; i < this.appsFolders.length; i++) {
@@ -226,9 +232,9 @@ module.exports = class extends BaseDockerGenerator {
if (app.searchEngine === ELASTICSEARCH) {
this.log(` ${chalk.cyan(`oc process -f ${this.directoryPath}ocp/${appName}/${appName}-elasticsearch.yml | oc apply -f -`)}`);
}
- if (app.serviceDiscoveryType !== false && regIndex++ === 0) {
+ if (app.serviceDiscoveryType !== NO_SERVICE_DISCOVERY && regIndex++ === 0) {
this.log(` ${chalk.cyan(`oc process -f ${this.directoryPath}ocp/registry/application-configmap.yml | oc apply -f -`)}`);
- if (app.serviceDiscoveryType === 'eureka') {
+ if (app.serviceDiscoveryType === EUREKA) {
this.log(` ${chalk.cyan(`oc process -f ${this.directoryPath}ocp/registry/jhipster-registry.yml | oc apply -f -`)}`);
} else {
this.log(` ${chalk.cyan(`oc process -f ${this.directoryPath}ocp/registry/consul.yml | oc apply -f -`)}`);
@@ -259,4 +265,9 @@ module.exports = class extends BaseDockerGenerator {
if (useBlueprints) return;
return this._end();
}
+
+ _loadDerivedOpenshiftConfig(dest = this) {
+ dest.storageTypeEphemeral = dest.storageType === EPHEMERAL;
+ dest.storageTypePersistent = dest.storageType === PERSISTENT;
+ }
};
diff --git a/generators/openshift/prompts.js b/generators/openshift/prompts.js
index b8e164dd73a..53a2b084f1c 100644
--- a/generators/openshift/prompts.js
+++ b/generators/openshift/prompts.js
@@ -20,6 +20,9 @@ const dockerPrompts = require('../docker-prompts');
const databaseTypes = require('../../jdl/jhipster/database-types');
const { ELASTICSEARCH } = require('../../jdl/jhipster/search-engine-types');
const { PROMETHEUS } = require('../../jdl/jhipster/monitoring-types');
+const { StorageTypes } = require('../../jdl/jhipster/openshift-platform-types');
+
+const { EPHEMERAL, PERSISTENT } = StorageTypes;
const NO_DATABASE = databaseTypes.NO;
@@ -69,15 +72,15 @@ async function askForStorageType() {
message: 'Which *type* of database storage would you like to use?',
choices: [
{
- value: 'persistent',
+ value: PERSISTENT,
name: 'Persistent Storage',
},
{
- value: 'ephemeral',
+ value: EPHEMERAL,
name: 'Ephemeral Storage',
},
],
- default: 'ephemeral',
+ default: EPHEMERAL,
},
];
diff --git a/generators/openshift/templates/db/cassandra.yml.ejs b/generators/openshift/templates/db/cassandra.yml.ejs
index f3827a9d215..db90f012ca9 100644
--- a/generators/openshift/templates/db/cassandra.yml.ejs
+++ b/generators/openshift/templates/db/cassandra.yml.ejs
@@ -31,13 +31,12 @@ metadata:
namespace: <%= openshiftNamespace %>
annotations:
description: This template defines objects that are required to spin up a cassandra pod
- tags: db, <%= app.baseName.toLowerCase() %>-cassandra<% if (storageType === 'persistent') { %> ,persistent <% } %> <% if (storageType === 'ephemeral') { %> ,ephemeral <% } %>
+ tags: db, <%= app.baseName.toLowerCase() %>-cassandra<% if (storageTypePersistent) { %> ,persistent <% } %> <% if (storageTypeEphemeral) { %> ,ephemeral <% } %>
openshift.io/display-name: <%= app.baseName.toLowerCase() %>-cassandra-template
openshift.io/long-description: >-
- This template provides objects that are required to spin up a cassandra pod.<% if (storageType ==
- 'persistent') { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
+ This template provides objects that are required to spin up a cassandra pod.<% if (storageTypePersistent) { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
Please make sure you have provisioned PVs (Persistent Volumes) before using this template. <% } %>
- <% if (storageType === 'ephemeral') { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
+ <% if (storageTypeEphemeral) { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
openshift.io/provider-display-name: JHipster-OpenShift
labels:
app: <%= app.baseName.toLowerCase() %>-cassandra
@@ -62,7 +61,7 @@ parameters:
required: true
displayName: "*** PLEASE DO NOT CHANGE THIS ***"
objects:
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
-
apiVersion: <%= KUBERNETES_CORE_API_VERSION %>
kind: PersistentVolumeClaim
@@ -120,11 +119,11 @@ objects:
spec:
volumes:
- name: ${APPLICATION_NAME}-data
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}
<%_ } _%>
-<%_ if (storageType === 'ephemeral') { _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
<%_ } _%>
containers:
diff --git a/generators/openshift/templates/db/couchbase.yml.ejs b/generators/openshift/templates/db/couchbase.yml.ejs
index 9d128adde46..fd4ced5a66f 100644
--- a/generators/openshift/templates/db/couchbase.yml.ejs
+++ b/generators/openshift/templates/db/couchbase.yml.ejs
@@ -32,13 +32,12 @@ metadata:
namespace: <%= openshiftNamespace %>
annotations:
description: This template defines objects that are required to spin up a couchbase pod
- tags: db, <%= app.baseName.toLowerCase() %>-couchbase<% if (storageType === 'persistent') { %> ,persistent <% } %> <% if (storageType === 'ephemeral') { %> ,ephemeral <% } %>
+ tags: db, <%= app.baseName.toLowerCase() %>-couchbase<% if (storageTypePersistent) { %> ,persistent <% } %> <% if (storageTypeEphemeral) { %> ,ephemeral <% } %>
openshift.io/display-name: <%= app.baseName.toLowerCase() %>-couchbase-template
openshift.io/long-description: >-
- This template provides objects that are required to spin up a couchbase pod.<% if (storageType ==
- 'persistent') { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
+ This template provides objects that are required to spin up a couchbase pod.<% if (storageTypePersistent) { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
Please make sure you have provisioned PVs (Persistent Volumes) before using this template. <% } %>
- <% if (storageType === 'ephemeral') { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
+ <% if (storageTypeEphemeral) { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
openshift.io/provider-display-name: JHipster-OpenShift
labels:
app: <%= app.baseName.toLowerCase() %>-couchbase
@@ -91,7 +90,7 @@ objects:
stringData:
database-admin-user: "${COUCHBASE_ADMIN_USER}"
database-admin-password: "${COUCHBASE_ADMIN_PASSWORD}"
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
-
apiVersion: <%= KUBERNETES_CORE_API_VERSION %>
kind: PersistentVolumeClaim
@@ -168,13 +167,13 @@ objects:
spec:
volumes:
- name: ${APPLICATION_NAME}-data
- <%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}
- <%_ } _%>
- <%_ if (storageType === 'ephemeral') { _%>
+<%_ } _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
- <%_ } _%>
+<%_ } _%>
containers:
- name: ${APPLICATION_NAME}
image: <%= DOCKER_COUCHBASE %>
diff --git a/generators/openshift/templates/db/elasticsearch.yml.ejs b/generators/openshift/templates/db/elasticsearch.yml.ejs
index e76002a2908..c0109140433 100644
--- a/generators/openshift/templates/db/elasticsearch.yml.ejs
+++ b/generators/openshift/templates/db/elasticsearch.yml.ejs
@@ -29,13 +29,12 @@ metadata:
namespace: <%= openshiftNamespace %>
annotations:
description: This template defines objects that are required to spin up an elasticsearch pod
- tags: elasticsearch, <%= app.baseName.toLowerCase() %>-elasticsearch<% if (storageType === 'persistent') { %> ,persistent <% } %> <% if (storageType === 'ephemeral') { %> ,ephemeral <% } %>
+ tags: elasticsearch, <%= app.baseName.toLowerCase() %>-elasticsearch<% if (storageTypePersistent) { %> ,persistent <% } %> <% if (storageTypeEphemeral) { %> ,ephemeral <% } %>
openshift.io/display-name: <%= app.baseName.toLowerCase() %>-elasticsearch-template
openshift.io/long-description: >-
- This template provides objects that are required to spin up an elasticsearch pod.<% if (storageType ==
- 'persistent') { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
+ This template provides objects that are required to spin up an elasticsearch pod.<% if (storageTypePersistent) { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
Please make sure you have provisioned PVs (Persistent Volumes) before using this template. <% } %>
- <% if (storageType === 'ephemeral') { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
+ <% if (storageTypeEphemeral) { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
openshift.io/provider-display-name: JHipster-OpenShift
labels:
app: <%= app.baseName.toLowerCase() %>-elasticsearch
@@ -54,7 +53,7 @@ parameters:
value: 1Gi
required: true
objects:
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
-
apiVersion: <%= KUBERNETES_CORE_API_VERSION %>
kind: PersistentVolumeClaim
@@ -98,11 +97,11 @@ objects:
spec:
volumes:
- name: ${APPLICATION_NAME}-data
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}
<%_ } _%>
-<%_ if (storageType === 'ephemeral') { _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
<%_ } _%>
containers:
diff --git a/generators/openshift/templates/db/mariadb.yml.ejs b/generators/openshift/templates/db/mariadb.yml.ejs
index 8c62aa3a72b..3cc56d0c145 100644
--- a/generators/openshift/templates/db/mariadb.yml.ejs
+++ b/generators/openshift/templates/db/mariadb.yml.ejs
@@ -29,13 +29,12 @@ metadata:
namespace: <%= openshiftNamespace %>
annotations:
description: This template defines objects that are required to spin up a mariadb pod
- tags: db, <%= app.baseName.toLowerCase() %>-mariadb<% if (storageType === 'persistent') { %> ,persistent <% } %> <% if (storageType === 'ephemeral') { %> ,ephemeral <% } %>
+ tags: db, <%= app.baseName.toLowerCase() %>-mariadb<% if (storageTypePersistent) { %> ,persistent <% } %> <% if (storageTypeEphemeral) { %> ,ephemeral <% } %>
openshift.io/display-name: <%= app.baseName.toLowerCase() %>-mariadb-template
openshift.io/long-description: >-
- This template provides objects that are required to spin up a mariadb pod.<% if (storageType ==
- 'persistent') { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
+ This template provides objects that are required to spin up a mariadb pod.<% if (storageTypePersistent) { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
Please make sure you have provisioned PVs (Persistent Volumes) before using this template. <% } %>
- <% if (storageType === 'ephemeral') { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
+ <% if (storageTypeEphemeral) { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
openshift.io/provider-display-name: JHipster-OpenShift
labels:
app: <%= app.baseName.toLowerCase() %>-mariadb
@@ -96,7 +95,7 @@ objects:
database-user: "${MYSQL_USER}"
database-password: "${MYSQL_PASSWORD}"
database-root-password: "${MYSQL_ROOT_PASSWORD}"
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
-
apiVersion: <%= KUBERNETES_CORE_API_VERSION %>
kind: PersistentVolumeClaim
@@ -140,11 +139,11 @@ objects:
spec:
volumes:
- name: ${APPLICATION_NAME}-data
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}
<%_ } _%>
-<%_ if (storageType === 'ephemeral') { _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
<%_ } _%>
containers:
diff --git a/generators/openshift/templates/db/mongodb.yml.ejs b/generators/openshift/templates/db/mongodb.yml.ejs
index 8611fed4ea9..90cb040890a 100644
--- a/generators/openshift/templates/db/mongodb.yml.ejs
+++ b/generators/openshift/templates/db/mongodb.yml.ejs
@@ -31,13 +31,12 @@ metadata:
namespace: <%= openshiftNamespace %>
annotations:
description: This template defines objects that are required to spin up a mongodb pod
- tags: db, <%= app.baseName.toLowerCase() %>-mongodb<% if (storageType === 'persistent') { %> ,persistent <% } %> <% if (storageType === 'ephemeral') { %> ,ephemeral <% } %>
+ tags: db, <%= app.baseName.toLowerCase() %>-mongodb<% if (storageTypePersistent) { %> ,persistent <% } %> <% if (storageTypeEphemeral) { %> ,ephemeral <% } %>
openshift.io/display-name: <%= app.baseName.toLowerCase() %>-mongodb-template
openshift.io/long-description: >-
- This template provides objects that are required to spin up a mongodb pod.<% if (storageType ==
- 'persistent') { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
+ This template provides objects that are required to spin up a mongodb pod.<% if (storageTypePersistent) { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
Please make sure you have provisioned PVs (Persistent Volumes) before using this template. <% } %>
- <% if (storageType === 'ephemeral') { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
+ <% if (storageTypeEphemeral) { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
openshift.io/provider-display-name: JHipster-OpenShift
labels:
app: <%= app.baseName.toLowerCase() %>-mongodb
@@ -98,7 +97,7 @@ objects:
database-user: "${MONGODB_USER}"
database-password: "${MONGODB_PASSWORD}"
database-admin-password: "${MONGODB_ADMIN_PASSWORD}"
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
-
apiVersion: <%= KUBERNETES_CORE_API_VERSION %>
kind: PersistentVolumeClaim
@@ -150,11 +149,11 @@ objects:
spec:
volumes:
- name: ${APPLICATION_NAME}-data
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}
<%_ } _%>
-<%_ if (storageType === 'ephemeral') { _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
<%_ } _%>
containers:
diff --git a/generators/openshift/templates/db/mysql.yml.ejs b/generators/openshift/templates/db/mysql.yml.ejs
index d8961e77f20..196e111c7ff 100644
--- a/generators/openshift/templates/db/mysql.yml.ejs
+++ b/generators/openshift/templates/db/mysql.yml.ejs
@@ -29,13 +29,12 @@ metadata:
namespace: <%= openshiftNamespace %>
annotations:
description: This template defines objects that are required to spin up a mysqldb pod
- tags: db, <%= app.baseName.toLowerCase() %>-mysqldb<% if (storageType === 'persistent') { %> ,persistent <% } %> <% if (storageType === 'ephemeral') { %> ,ephemeral <% } %>
+ tags: db, <%= app.baseName.toLowerCase() %>-mysqldb<% if (storageTypePersistent) { %> ,persistent <% } %> <% if (storageTypeEphemeral) { %> ,ephemeral <% } %>
openshift.io/display-name: <%= app.baseName.toLowerCase() %>-mysqldb-template
openshift.io/long-description: >-
- This template provides objects that are required to spin up a mysqldb pod.<% if (storageType ==
- 'persistent') { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
+ This template provides objects that are required to spin up a mysqldb pod.<% if (storageTypePersistent) { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
Please make sure you have provisioned PVs (Persistent Volumes) before using this template. <% } %>
- <% if (storageType === 'ephemeral') { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
+ <% if (storageTypeEphemeral) { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
openshift.io/provider-display-name: JHipster-OpenShift
labels:
app: <%= app.baseName.toLowerCase() %>-mysqldb
@@ -96,7 +95,7 @@ objects:
database-user: "${MYSQL_USER}"
database-password: "${MYSQL_PASSWORD}"
database-root-password: "${MYSQL_ROOT_PASSWORD}"
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
-
apiVersion: <%= KUBERNETES_CORE_API_VERSION %>
kind: PersistentVolumeClaim
@@ -140,11 +139,11 @@ objects:
spec:
volumes:
- name: ${APPLICATION_NAME}-data
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}
<%_ } _%>
-<%_ if (storageType === 'ephemeral') { _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
<%_ } _%>
containers:
diff --git a/generators/openshift/templates/db/postgresql.yml.ejs b/generators/openshift/templates/db/postgresql.yml.ejs
index a93ebf449d8..c310932c40d 100644
--- a/generators/openshift/templates/db/postgresql.yml.ejs
+++ b/generators/openshift/templates/db/postgresql.yml.ejs
@@ -29,13 +29,12 @@ metadata:
namespace: <%= openshiftNamespace %>
annotations:
description: This template defines objects that are required to spin up a postgresqldb pod
- tags: db, <%= app.baseName.toLowerCase() %>-postgresqldb<% if (storageType === 'persistent') { %> ,persistent <% } %> <% if (storageType === 'ephemeral') { %> ,ephemeral <% } %>
+ tags: db, <%= app.baseName.toLowerCase() %>-postgresqldb<% if (storageTypePersistent) { %> ,persistent <% } %> <% if (storageTypeEphemeral) { %> ,ephemeral <% } %>
openshift.io/display-name: <%= app.baseName.toLowerCase() %>-postgresqldb-template
openshift.io/long-description: >-
- This template provides objects that are required to spin up a postgresqldb pod.<% if (storageType ==
- 'persistent') { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
+ This template provides objects that are required to spin up a postgresqldb pod.<% if (storageTypePersistent) { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
Please make sure you have provisioned PVs (Persistent Volumes) before using this template. <% } %>
- <% if (storageType === 'ephemeral') { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
+ <% if (storageTypeEphemeral) { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
openshift.io/provider-display-name: JHipster-OpenShift
labels:
app: <%= app.baseName.toLowerCase() %>-postgresqldb
@@ -93,7 +92,7 @@ objects:
stringData:
database-user: "${POSTGRESQL_USER}"
database-password: "${POSTGRESQL_PASSWORD}"
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
-
apiVersion: <%= KUBERNETES_CORE_API_VERSION %>
kind: PersistentVolumeClaim
@@ -137,11 +136,11 @@ objects:
spec:
volumes:
- name: ${APPLICATION_NAME}-data
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}
<%_ } _%>
-<%_ if (storageType === 'ephemeral') { _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
<%_ } _%>
containers:
diff --git a/generators/openshift/templates/messagebroker/kafka.yml.ejs b/generators/openshift/templates/messagebroker/kafka.yml.ejs
index c1ba384aabe..8e23264c537 100644
--- a/generators/openshift/templates/messagebroker/kafka.yml.ejs
+++ b/generators/openshift/templates/messagebroker/kafka.yml.ejs
@@ -29,13 +29,12 @@ metadata:
namespace: <%= openshiftNamespace %>
annotations:
description: This template defines objects that are required to spin up a kafka and zookeeper pod
- tags: kafka, jhipster-kafka<% if (storageType === 'persistent') { %> ,persistent <% } %> <% if (storageType === 'ephemeral') { %> ,ephemeral <% } %>
+ tags: kafka, jhipster-kafka<% if (storageTypePersistent) { %> ,persistent <% } %> <% if (storageTypeEphemeral) { %> ,ephemeral <% } %>
openshift.io/display-name: jhipster-kafka-template
openshift.io/long-description: >-
- This template provides objects that are required to spin up a kafka and zookeeper pod.<% if (storageType ==
- 'persistent') { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
+ This template provides objects that are required to spin up a kafka and zookeeper pod.<% if (storageTypePersistent) { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
Please make sure you have provisioned PVs (Persistent Volumes) before using this template. <% } %>
- <% if (storageType === 'ephemeral') { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
+ <% if (storageTypeEphemeral) { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
openshift.io/provider-display-name: JHipster-OpenShift
labels:
app: jhipster-kafka
@@ -66,7 +65,7 @@ parameters:
required: true
displayName: "*** PLEASE DO NOT CHANGE THIS ***"
objects:
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
-
apiVersion: <%= KUBERNETES_CORE_API_VERSION %>
kind: PersistentVolumeClaim
@@ -79,7 +78,7 @@ objects:
requests:
storage: "${VOLUME_CAPACITY}"
<%_ } _%>
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
-
apiVersion: <%= KUBERNETES_CORE_API_VERSION %>
kind: PersistentVolumeClaim
@@ -124,11 +123,11 @@ objects:
spec:
volumes:
- name: ${ZK_APPLICATION_NAME}-data
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${ZK_APPLICATION_NAME}
<%_ } _%>
-<%_ if (storageType === 'ephemeral') { _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
<%_ } _%>
containers:
@@ -199,13 +198,13 @@ objects:
spec:
volumes:
- name: ${APPLICATION_NAME}-data
- <%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}
- <%_ } _%>
- <%_ if (storageType === 'ephemeral') { _%>
+<%_ } _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
- <%_ } _%>
+<%_ } _%>
containers:
- name: ${APPLICATION_NAME}
image: <%= DOCKER_KAFKA %>
diff --git a/generators/openshift/templates/monitoring/jhipster-metrics.yml.ejs b/generators/openshift/templates/monitoring/jhipster-metrics.yml.ejs
index dc78cfee1c3..748c410bcdf 100644
--- a/generators/openshift/templates/monitoring/jhipster-metrics.yml.ejs
+++ b/generators/openshift/templates/monitoring/jhipster-metrics.yml.ejs
@@ -30,13 +30,13 @@ metadata:
namespace: <%= openshiftNamespace %>
annotations:
description: This template defines objects that are required to spin up metrics monitoring pod
- tags: prometheus, alertmanager, grafana, jhipster-metrics<% if (storageType === 'persistent') { %> ,persistent <% } %> <% if (storageType === 'ephemeral') { %> ,ephemeral <% } %>
+ tags: prometheus, alertmanager, grafana, jhipster-metrics<% if (storageTypePersistent) { %> ,persistent <% } %> <% if (storageTypeEphemeral) { %> ,ephemeral <% } %>
openshift.io/display-name: jhipster-metrics-monitoring-template
openshift.io/long-description: >-
This template provides objects that are required to spin up a metrics monitoring pod. It contains
- prometheus for metrics aggregation, and grafana for visualization .<% if (storageType =='persistent') { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
+ prometheus for metrics aggregation, and grafana for visualization .<% if (storageTypePersistent) { %>The database is stored on persistent storage, so any restart of the service will not cause any impact to the data.
Please make sure you have provisioned PVs (Persistent Volumes) before using this template. <% } %>
- <% if (storageType === 'ephemeral') { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
+ <% if (storageTypeEphemeral) { %>The database is not stored on persistent storage, so any restart of the service will result in all data being lost.<% } %>
openshift.io/provider-display-name: JHipster-OpenShift
labels:
app: jhipster-metrics
@@ -73,7 +73,7 @@ parameters:
value: 1Gi
required: true
objects:
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
-
apiVersion: <%= KUBERNETES_CORE_API_VERSION %>
kind: PersistentVolumeClaim
@@ -223,11 +223,11 @@ objects:
spec:
volumes:
- name: ${PT_APP_NAME}-data
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${PT_APP_NAME}
<%_ } _%>
-<%_ if (storageType === 'ephemeral') { _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
<%_ } _%>
- name: ${PT_APP_NAME}-config
@@ -319,11 +319,11 @@ objects:
spec:
volumes:
- name: ${AM_APP_NAME}-data
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${AM_APP_NAME}
<%_ } _%>
-<%_ if (storageType === 'ephemeral') { _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
<%_ } _%>
- name: ${AM_APP_NAME}-config
@@ -406,11 +406,11 @@ objects:
spec:
volumes:
- name: ${GF_APP_NAME}-data
-<%_ if (storageType === 'persistent') { _%>
+<%_ if (storageTypePersistent) { _%>
persistentVolumeClaim:
claimName: ${GF_APP_NAME}
<%_ } _%>
-<%_ if (storageType === 'ephemeral') { _%>
+<%_ if (storageTypeEphemeral) { _%>
emptyDir: {}
<%_ } _%>
containers:
diff --git a/generators/page/index.js b/generators/page/index.js
index 871c1dd2bd1..213f44286e1 100644
--- a/generators/page/index.js
+++ b/generators/page/index.js
@@ -22,6 +22,8 @@ const BaseBlueprintGenerator = require('../generator-base-blueprint');
const prompts = require('./prompts');
const { writeFiles: writeVueFiles, customizeFiles: customizeVueFiles } = require('./files-vue');
const constants = require('../generator-constants');
+const { GENERATOR_PAGE } = require('../generator-list');
+const { PROTRACTOR } = require('../../jdl/jhipster/test-framework-types');
const { VUE } = constants.SUPPORTED_CLIENT_FRAMEWORKS;
@@ -60,7 +62,7 @@ module.exports = class extends BaseBlueprintGenerator {
this.rootGenerator = this.env.rootGenerator() === this;
- useBlueprints = !this.fromBlueprint && this.instantiateBlueprints('page');
+ useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_PAGE);
}
_initializing() {
@@ -72,7 +74,7 @@ module.exports = class extends BaseBlueprintGenerator {
this.skipClient = this.jhipsterConfig.skipClient;
this.clientPackageManager = this.jhipsterConfig.clientPackageManager;
this.enableTranslation = this.jhipsterConfig.enableTranslation;
- this.protractorTests = this.jhipsterConfig.testFrameworks && this.jhipsterConfig.testFrameworks.includes('protractor');
+ this.protractorTests = this.jhipsterConfig.testFrameworks && this.jhipsterConfig.testFrameworks.includes(PROTRACTOR);
this.clientFramework = this.jhipsterConfig.clientFramework;
},
};
diff --git a/generators/server/files.js b/generators/server/files.js
index 79d010b4fcf..2a709549fca 100644
--- a/generators/server/files.js
+++ b/generators/server/files.js
@@ -18,8 +18,19 @@
*/
const cleanup = require('../cleanup');
const constants = require('../generator-constants');
+const { GATEWAY, MICROSERVICE, MONOLITH } = require('../../jdl/jhipster/application-types');
+const { JWT, OAUTH2, SESSION } = require('../../jdl/jhipster/authentication-types');
+const { GRADLE, MAVEN } = require('../../jdl/jhipster/build-tool-types');
+const { SPRING_WEBSOCKET } = require('../../jdl/jhipster/websocket-types');
+const databaseTypes = require('../../jdl/jhipster/database-types');
+const { CASSANDRA, COUCHBASE, H2_DISK, H2_MEMORY, MARIADB, MONGODB, NEO4J, ORACLE, SQL } = require('../../jdl/jhipster/database-types');
+const { CAFFEINE, EHCACHE, HAZELCAST, INFINISPAN, MEMCACHED, REDIS } = require('../../jdl/jhipster/cache-types');
+const { ELASTICSEARCH } = require('../../jdl/jhipster/search-engine-types');
+const { KAFKA } = require('../../jdl/jhipster/message-broker-types');
+const { CONSUL, EUREKA } = require('../../jdl/jhipster/service-discovery-types');
/* Constants use throughout */
+const NO_DATABASE = databaseTypes.NO;
const INTERPOLATE_REGEX = constants.INTERPOLATE_REGEX;
const DOCKER_DIR = constants.DOCKER_DIR;
const TEST_DIR = constants.TEST_DIR;
@@ -31,7 +42,7 @@ const REACT = constants.SUPPORTED_CLIENT_FRAMEWORKS.REACT;
const VUE = constants.SUPPORTED_CLIENT_FRAMEWORKS.VUE;
const shouldSkipUserManagement = generator =>
- generator.skipUserManagement && (generator.applicationType !== 'monolith' || generator.authenticationType !== 'oauth2');
+ generator.skipUserManagement && (generator.applicationType !== MONOLITH || generator.authenticationType !== OAUTH2);
/**
* The default is to use a file path string. It implies use of the template method.
* For any other config an object { file:.., method:.., template:.. } can be used
@@ -64,22 +75,22 @@ const serverFiles = {
],
},
{
- condition: generator => generator.prodDatabaseType !== 'no' && generator.prodDatabaseType !== 'oracle',
+ condition: generator => generator.prodDatabaseType !== NO_DATABASE && generator.prodDatabaseType !== ORACLE,
path: DOCKER_DIR,
templates: [{ file: generator => `${generator.prodDatabaseType}.yml` }],
},
{
- condition: generator => generator.prodDatabaseType === 'mongodb',
+ condition: generator => generator.databaseType === MONGODB,
path: DOCKER_DIR,
templates: ['mongodb-cluster.yml', 'mongodb/MongoDB.Dockerfile', 'mongodb/scripts/init_replicaset.js'],
},
{
- condition: generator => generator.prodDatabaseType === 'couchbase',
+ condition: generator => generator.databaseType === COUCHBASE,
path: DOCKER_DIR,
templates: ['couchbase-cluster.yml', 'couchbase/Couchbase.Dockerfile', 'couchbase/scripts/configure-node.sh'],
},
{
- condition: generator => generator.prodDatabaseType === 'cassandra',
+ condition: generator => generator.databaseType === CASSANDRA,
path: DOCKER_DIR,
templates: [
// docker-compose files
@@ -93,27 +104,27 @@ const serverFiles = {
],
},
{
- condition: generator => generator.cacheProvider === 'hazelcast',
+ condition: generator => generator.cacheProvider === HAZELCAST,
path: DOCKER_DIR,
templates: ['hazelcast-management-center.yml'],
},
{
- condition: generator => generator.cacheProvider === 'memcached',
+ condition: generator => generator.cacheProvider === MEMCACHED,
path: DOCKER_DIR,
templates: ['memcached.yml'],
},
{
- condition: generator => generator.cacheProvider === 'redis',
+ condition: generator => generator.cacheProvider === REDIS,
path: DOCKER_DIR,
templates: ['redis.yml', 'redis-cluster.yml', 'redis/Redis-Cluster.Dockerfile', 'redis/connectRedisCluster.sh'],
},
{
- condition: generator => generator.searchEngine === 'elasticsearch',
+ condition: generator => generator.searchEngine === ELASTICSEARCH,
path: DOCKER_DIR,
templates: ['elasticsearch.yml'],
},
{
- condition: generator => generator.messageBroker === 'kafka',
+ condition: generator => generator.messageBroker === KAFKA,
path: DOCKER_DIR,
templates: ['kafka.yml'],
},
@@ -123,7 +134,7 @@ const serverFiles = {
templates: [{ file: 'config/README.md', renameTo: () => 'central-server-config/README.md' }],
},
{
- condition: generator => generator.serviceDiscoveryType && generator.serviceDiscoveryType === 'consul',
+ condition: generator => generator.serviceDiscoveryType && generator.serviceDiscoveryType === CONSUL,
path: DOCKER_DIR,
templates: [
'consul.yml',
@@ -132,7 +143,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.serviceDiscoveryType && generator.serviceDiscoveryType === 'eureka',
+ condition: generator => generator.serviceDiscoveryType && generator.serviceDiscoveryType === EUREKA,
path: DOCKER_DIR,
templates: [
'jhipster-registry.yml',
@@ -152,7 +163,7 @@ const serverFiles = {
templates: ['swagger-editor.yml'],
},
{
- condition: generator => generator.authenticationType === 'oauth2' && generator.applicationType !== 'microservice',
+ condition: generator => generator.authenticationType === OAUTH2 && generator.applicationType !== MICROSERVICE,
path: DOCKER_DIR,
templates: [
'keycloak.yml',
@@ -166,7 +177,7 @@ const serverFiles = {
templates: [{ file: 'checkstyle.xml', options: { interpolate: INTERPOLATE_REGEX } }],
},
{
- condition: generator => generator.buildTool === 'gradle',
+ condition: generator => generator.buildTool === GRADLE,
templates: [
'build.gradle',
'settings.gradle',
@@ -184,11 +195,11 @@ const serverFiles = {
],
},
{
- condition: generator => generator.buildTool === 'gradle' && !!generator.enableSwaggerCodegen,
+ condition: generator => generator.buildTool === GRADLE && !!generator.enableSwaggerCodegen,
templates: ['gradle/swagger.gradle'],
},
{
- condition: generator => generator.buildTool === 'maven',
+ condition: generator => generator.buildTool === MAVEN,
templates: [
{ file: 'mvnw', method: 'copy', noEjs: true },
{ file: 'mvnw.cmd', method: 'copy', noEjs: true },
@@ -199,7 +210,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.buildTool === 'maven',
+ condition: generator => generator.buildTool === MAVEN,
templates: [
{ file: 'npmw', method: 'copy', noEjs: true },
{ file: 'npmw.cmd', method: 'copy', noEjs: true },
@@ -237,7 +248,7 @@ const serverFiles = {
templates: [{ file: 'banner.txt', method: 'copy', noEjs: true }],
},
{
- condition: generator => generator.devDatabaseType === 'h2Disk' || generator.devDatabaseType === 'h2Memory',
+ condition: generator => generator.devDatabaseType === H2_DISK || generator.devDatabaseType === H2_MEMORY,
path: SERVER_MAIN_RES_DIR,
templates: [{ file: 'h2.server.properties', renameTo: () => '.h2.server.properties' }],
},
@@ -260,7 +271,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.databaseType === 'sql',
+ condition: generator => generator.databaseType === SQL,
path: SERVER_MAIN_RES_DIR,
templates: [
{
@@ -276,7 +287,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.databaseType === 'mongodb',
+ condition: generator => generator.databaseType === MONGODB,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -287,8 +298,8 @@ const serverFiles = {
},
{
condition: generator =>
- generator.databaseType === 'mongodb' &&
- (!generator.skipUserManagement || (generator.skipUserManagement && generator.authenticationType === 'oauth2')),
+ generator.databaseType === MONGODB &&
+ (!generator.skipUserManagement || (generator.skipUserManagement && generator.authenticationType === OAUTH2)),
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -298,13 +309,13 @@ const serverFiles = {
],
},
{
- condition: generator => generator.databaseType === 'couchbase',
+ condition: generator => generator.databaseType === COUCHBASE,
path: SERVER_MAIN_RES_DIR,
templates: ['config/couchmove/changelog/V0__create_indexes.n1ql'],
},
{
condition: generator =>
- generator.databaseType === 'couchbase' && (!generator.skipUserManagement || generator.authenticationType === 'oauth2'),
+ generator.databaseType === COUCHBASE && (!generator.skipUserManagement || generator.authenticationType === OAUTH2),
path: SERVER_MAIN_RES_DIR,
templates: [
'config/couchmove/changelog/V0.1__initial_setup/ROLE_ADMIN.json',
@@ -315,7 +326,7 @@ const serverFiles = {
},
{
condition: generator =>
- generator.databaseType === 'neo4j' && (!generator.skipUserManagement || generator.authenticationType === 'oauth2'),
+ generator.databaseType === NEO4J && (!generator.skipUserManagement || generator.authenticationType === OAUTH2),
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -330,7 +341,7 @@ const serverFiles = {
},
{
condition: generator =>
- generator.databaseType === 'neo4j' && (!generator.skipUserManagement || generator.authenticationType === 'oauth2'),
+ generator.databaseType === NEO4J && (!generator.skipUserManagement || generator.authenticationType === OAUTH2),
path: SERVER_MAIN_RES_DIR,
templates: [
{
@@ -344,7 +355,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.databaseType === 'cassandra',
+ condition: generator => generator.databaseType === CASSANDRA,
path: SERVER_MAIN_RES_DIR,
templates: [
'config/cql/create-keyspace-prod.cql',
@@ -355,9 +366,9 @@ const serverFiles = {
},
{
condition: generator =>
- generator.databaseType === 'cassandra' &&
- generator.applicationType !== 'microservice' &&
- (!generator.skipUserManagement || generator.authenticationType === 'oauth2'),
+ generator.databaseType === CASSANDRA &&
+ generator.applicationType !== MICROSERVICE &&
+ (!generator.skipUserManagement || generator.authenticationType === OAUTH2),
path: SERVER_MAIN_RES_DIR,
templates: [
{ file: 'config/cql/changelog/create-tables.cql', renameTo: () => 'config/cql/changelog/00000000000000_create-tables.cql' },
@@ -372,7 +383,7 @@ const serverFiles = {
{
condition: generator =>
!generator.reactive &&
- (generator.databaseType === 'sql' || generator.databaseType === 'mongodb' || generator.databaseType === 'couchbase'),
+ (generator.databaseType === SQL || generator.databaseType === MONGODB || generator.databaseType === COUCHBASE),
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -408,7 +419,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.authenticationType === 'jwt',
+ condition: generator => generator.authenticationType === JWT,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -422,7 +433,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.authenticationType === 'jwt' && !generator.reactive,
+ condition: generator => generator.authenticationType === JWT && !generator.reactive,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -432,7 +443,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.reactive && generator.applicationType === 'gateway' && generator.authenticationType === 'jwt',
+ condition: generator => generator.reactive && generator.applicationType === GATEWAY && generator.authenticationType === JWT,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -462,7 +473,7 @@ const serverFiles = {
],
},
{
- condition: generator => !shouldSkipUserManagement(generator) && generator.authenticationType === 'session' && !generator.reactive,
+ condition: generator => !shouldSkipUserManagement(generator) && generator.authenticationType === SESSION && !generator.reactive,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -480,7 +491,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.authenticationType === 'oauth2',
+ condition: generator => generator.authenticationType === OAUTH2,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -498,7 +509,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.authenticationType === 'oauth2',
+ condition: generator => generator.authenticationType === OAUTH2,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -514,8 +525,8 @@ const serverFiles = {
{
condition: generator =>
!generator.reactive &&
- generator.authenticationType === 'oauth2' &&
- (generator.applicationType === 'microservice' || generator.applicationType === 'gateway'),
+ generator.authenticationType === OAUTH2 &&
+ (generator.applicationType === MICROSERVICE || generator.applicationType === GATEWAY),
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -525,7 +536,7 @@ const serverFiles = {
],
},
{
- condition: generator => !shouldSkipUserManagement(generator) && generator.authenticationType !== 'oauth2',
+ condition: generator => !shouldSkipUserManagement(generator) && generator.authenticationType !== OAUTH2,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -539,7 +550,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.applicationType !== 'microservice' && generator.authenticationType === 'jwt',
+ condition: generator => generator.applicationType !== MICROSERVICE && generator.authenticationType === JWT,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -563,7 +574,7 @@ const serverFiles = {
],
},
{
- condition: generator => !generator.reactive && generator.authenticationType === 'oauth2' && generator.applicationType === 'monolith',
+ condition: generator => !generator.reactive && generator.authenticationType === OAUTH2 && generator.applicationType === MONOLITH,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -573,7 +584,7 @@ const serverFiles = {
],
},
{
- condition: generator => !generator.reactive && generator.authenticationType === 'oauth2' && generator.applicationType === 'monolith',
+ condition: generator => !generator.reactive && generator.authenticationType === OAUTH2 && generator.applicationType === MONOLITH,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -585,7 +596,7 @@ const serverFiles = {
],
serverJavaGateway: [
{
- condition: generator => generator.applicationType === 'gateway' && generator.serviceDiscoveryType,
+ condition: generator => generator.applicationType === GATEWAY && generator.serviceDiscoveryType,
path: SERVER_MAIN_SRC_DIR,
templates: [
{ file: 'package/web/rest/vm/RouteVM.java', renameTo: generator => `${generator.javaDir}web/rest/vm/RouteVM.java` },
@@ -597,7 +608,7 @@ const serverFiles = {
},
{
condition: generator =>
- generator.authenticationType === 'oauth2' && (generator.applicationType === 'monolith' || generator.applicationType === 'gateway'),
+ generator.authenticationType === OAUTH2 && (generator.applicationType === MONOLITH || generator.applicationType === GATEWAY),
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -611,7 +622,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.applicationType === 'gateway' && generator.serviceDiscoveryType && generator.reactive,
+ condition: generator => generator.applicationType === GATEWAY && generator.serviceDiscoveryType && generator.reactive,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -625,7 +636,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.applicationType === 'gateway' && generator.serviceDiscoveryType && generator.reactive,
+ condition: generator => generator.applicationType === GATEWAY && generator.serviceDiscoveryType && generator.reactive,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -643,8 +654,8 @@ const serverFiles = {
{
condition: generator =>
!generator.reactive &&
- (generator.applicationType === 'microservice' || generator.applicationType === 'gateway') &&
- generator.authenticationType === 'jwt',
+ (generator.applicationType === MICROSERVICE || generator.applicationType === GATEWAY) &&
+ generator.authenticationType === JWT,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -660,8 +671,8 @@ const serverFiles = {
{
condition: generator =>
!generator.reactive &&
- generator.authenticationType === 'oauth2' &&
- (generator.applicationType === 'microservice' || generator.applicationType === 'gateway'),
+ generator.authenticationType === OAUTH2 &&
+ (generator.applicationType === MICROSERVICE || generator.applicationType === GATEWAY),
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -687,7 +698,7 @@ const serverFiles = {
],
},
{
- condition: generator => !generator.reactive && generator.applicationType === 'gateway' && !generator.serviceDiscoveryType,
+ condition: generator => !generator.reactive && generator.applicationType === GATEWAY && !generator.serviceDiscoveryType,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -697,7 +708,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.applicationType === 'microservice',
+ condition: generator => generator.applicationType === MICROSERVICE,
path: SERVER_MAIN_RES_DIR,
templates: [{ file: 'static/microservices_index.html', renameTo: () => 'static/index.html' }],
},
@@ -798,7 +809,7 @@ const serverFiles = {
],
},
{
- condition: generator => !generator.skipUserManagement || ['sql', 'mongodb', 'couchbase', 'neo4j'].includes(generator.databaseType),
+ condition: generator => !generator.skipUserManagement || [SQL, MONGODB, COUCHBASE, NEO4J].includes(generator.databaseType),
path: SERVER_MAIN_SRC_DIR,
templates: [{ file: 'package/config/Constants.java', renameTo: generator => `${generator.javaDir}config/Constants.java` }],
},
@@ -814,8 +825,8 @@ const serverFiles = {
},
{
condition: generator =>
- ['ehcache', 'caffeine', 'hazelcast', 'infinispan', 'memcached', 'redis'].includes(generator.cacheProvider) ||
- generator.applicationType === 'gateway',
+ [EHCACHE, CAFFEINE, HAZELCAST, INFINISPAN, MEMCACHED, REDIS].includes(generator.cacheProvider) ||
+ generator.applicationType === GATEWAY,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -825,7 +836,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.cacheProvider === 'infinispan',
+ condition: generator => generator.cacheProvider === INFINISPAN,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -835,7 +846,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.cacheProvider === 'redis',
+ condition: generator => generator.cacheProvider === REDIS,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -845,7 +856,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.databaseType !== 'no',
+ condition: generator => generator.databaseType !== NO_DATABASE,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -855,7 +866,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.databaseType === 'sql',
+ condition: generator => generator.databaseType === SQL,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -865,7 +876,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.databaseType === 'sql' && generator.reactive,
+ condition: generator => generator.databaseType === SQL && generator.reactive,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -880,9 +891,7 @@ const serverFiles = {
},
{
condition: generator =>
- generator.databaseType === 'sql' &&
- generator.reactive &&
- (!generator.skipUserManagement || generator.authenticationType === 'oauth2'),
+ generator.databaseType === SQL && generator.reactive && (!generator.skipUserManagement || generator.authenticationType === OAUTH2),
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -892,7 +901,7 @@ const serverFiles = {
],
},
{
- condition: generator => !generator.reactive && generator.databaseType === 'couchbase',
+ condition: generator => !generator.reactive && generator.databaseType === COUCHBASE,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -906,7 +915,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.searchEngine === 'couchbase',
+ condition: generator => generator.searchEngine === COUCHBASE,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -916,7 +925,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.searchEngine === 'couchbase',
+ condition: generator => generator.searchEngine === COUCHBASE,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -926,7 +935,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.reactive && generator.databaseType === 'couchbase',
+ condition: generator => generator.reactive && generator.databaseType === COUCHBASE,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -940,7 +949,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.websocket === 'spring-websocket',
+ condition: generator => generator.websocket === SPRING_WEBSOCKET,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -954,7 +963,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.searchEngine === 'elasticsearch',
+ condition: generator => generator.searchEngine === ELASTICSEARCH,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -970,7 +979,7 @@ const serverFiles = {
templates: [{ file: 'package/domain/package-info.java', renameTo: generator => `${generator.javaDir}domain/package-info.java` }],
},
{
- condition: generator => ['sql', 'mongodb', 'neo4j', 'couchbase'].includes(generator.databaseType),
+ condition: generator => [SQL, MONGODB, NEO4J, COUCHBASE].includes(generator.databaseType),
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -982,7 +991,7 @@ const serverFiles = {
],
serverJavaPackageInfo: [
{
- condition: generator => generator.searchEngine === 'elasticsearch',
+ condition: generator => generator.searchEngine === ELASTICSEARCH,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -1024,7 +1033,7 @@ const serverFiles = {
templates: [{ file: 'package/service/package-info.java', renameTo: generator => `${generator.javaDir}service/package-info.java` }],
},
{
- condition: generator => generator.messageBroker === 'kafka',
+ condition: generator => generator.messageBroker === KAFKA,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -1114,7 +1123,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.messageBroker === 'kafka',
+ condition: generator => generator.messageBroker === KAFKA,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -1126,7 +1135,7 @@ const serverFiles = {
],
serverJavaWebsocket: [
{
- condition: generator => generator.websocket === 'spring-websocket',
+ condition: generator => generator.websocket === SPRING_WEBSOCKET,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -1196,7 +1205,7 @@ const serverFiles = {
],
serverTestFw: [
{
- condition: generator => generator.databaseType === 'cassandra',
+ condition: generator => generator.databaseType === CASSANDRA,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1207,7 +1216,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.databaseType === 'couchbase',
+ condition: generator => generator.databaseType === COUCHBASE,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1217,7 +1226,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.databaseType === 'neo4j',
+ condition: generator => generator.databaseType === NEO4J,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1251,7 +1260,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.databaseType === 'sql' && !generator.reactive,
+ condition: generator => generator.databaseType === SQL && !generator.reactive,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1273,12 +1282,12 @@ const serverFiles = {
templates: ['config/application.yml', 'logback.xml'],
},
{
- condition: generator => generator.databaseType === 'sql' && !generator.reactive,
+ condition: generator => generator.databaseType === SQL && !generator.reactive,
path: SERVER_TEST_RES_DIR,
templates: ['config/application-testcontainers.yml'],
},
{
- condition: generator => generator.prodDatabaseType === 'mariadb' && !generator.reactive,
+ condition: generator => generator.prodDatabaseType === MARIADB && !generator.reactive,
path: SERVER_TEST_RES_DIR,
templates: [{ file: 'testcontainers/mariadb/my.cnf', method: 'copy', noEjs: true }],
},
@@ -1325,7 +1334,7 @@ const serverFiles = {
},
{
condition: generator =>
- generator.authenticationType === 'oauth2' && (generator.applicationType === 'monolith' || generator.applicationType === 'gateway'),
+ generator.authenticationType === OAUTH2 && (generator.applicationType === MONOLITH || generator.applicationType === GATEWAY),
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1366,7 +1375,7 @@ const serverFiles = {
templates: ['cucumber.properties'],
},
{
- condition: generator => !shouldSkipUserManagement(generator) && generator.authenticationType !== 'oauth2',
+ condition: generator => !shouldSkipUserManagement(generator) && generator.authenticationType !== OAUTH2,
path: SERVER_TEST_SRC_DIR,
templates: [
// Create auth config test files
@@ -1377,7 +1386,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.messageBroker === 'kafka',
+ condition: generator => generator.messageBroker === KAFKA,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1411,20 +1420,20 @@ const serverFiles = {
},
{
condition: generator =>
- (generator.authenticationType === 'oauth2' && generator.applicationType !== 'microservice') ||
- (!generator.skipUserManagement && generator.databaseType === 'sql'),
+ (generator.authenticationType === OAUTH2 && generator.applicationType !== MICROSERVICE) ||
+ (!generator.skipUserManagement && generator.databaseType === SQL),
path: SERVER_MAIN_RES_DIR,
templates: ['config/liquibase/data/user.csv'],
},
{
condition: generator =>
- (generator.authenticationType === 'oauth2' && generator.applicationType !== 'microservice' && generator.databaseType === 'sql') ||
- (!generator.skipUserManagement && generator.databaseType === 'sql'),
+ (generator.authenticationType === OAUTH2 && generator.applicationType !== MICROSERVICE && generator.databaseType === SQL) ||
+ (!generator.skipUserManagement && generator.databaseType === SQL),
path: SERVER_MAIN_RES_DIR,
templates: ['config/liquibase/data/authority.csv', 'config/liquibase/data/user_authority.csv'],
},
{
- condition: generator => generator.authenticationType === 'oauth2',
+ condition: generator => generator.authenticationType === OAUTH2,
path: SERVER_MAIN_SRC_DIR,
templates: [
{ file: 'package/config/Constants.java', renameTo: generator => `${generator.javaDir}config/Constants.java` },
@@ -1444,7 +1453,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.authenticationType === 'oauth2' && generator.databaseType !== 'no',
+ condition: generator => generator.authenticationType === OAUTH2 && generator.databaseType !== NO_DATABASE,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -1471,7 +1480,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.skipUserManagement && ['monolith', 'gateway'].includes(generator.applicationType),
+ condition: generator => generator.skipUserManagement && [MONOLITH, GATEWAY].includes(generator.applicationType),
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -1481,7 +1490,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.authenticationType === 'oauth2',
+ condition: generator => generator.authenticationType === OAUTH2,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1491,7 +1500,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.authenticationType === 'oauth2' && generator.databaseType !== 'no',
+ condition: generator => generator.authenticationType === OAUTH2 && generator.databaseType !== NO_DATABASE,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1510,9 +1519,7 @@ const serverFiles = {
},
{
condition: generator =>
- generator.skipUserManagement &&
- generator.authenticationType !== 'oauth2' &&
- ['monolith', 'gateway'].includes(generator.applicationType),
+ generator.skipUserManagement && generator.authenticationType !== OAUTH2 && [MONOLITH, GATEWAY].includes(generator.applicationType),
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1523,9 +1530,7 @@ const serverFiles = {
},
{
condition: generator =>
- generator.skipUserManagement &&
- generator.authenticationType === 'oauth2' &&
- ['monolith', 'gateway'].includes(generator.applicationType),
+ generator.skipUserManagement && generator.authenticationType === OAUTH2 && [MONOLITH, GATEWAY].includes(generator.applicationType),
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1535,7 +1540,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.authenticationType === 'oauth2' && generator.searchEngine === 'elasticsearch',
+ condition: generator => generator.authenticationType === OAUTH2 && generator.searchEngine === ELASTICSEARCH,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -1545,7 +1550,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.authenticationType === 'oauth2' && generator.searchEngine === 'elasticsearch',
+ condition: generator => generator.authenticationType === OAUTH2 && generator.searchEngine === ELASTICSEARCH,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1617,7 +1622,7 @@ const serverFiles = {
],
},
{
- condition: generator => !generator.skipUserManagement && generator.searchEngine === 'elasticsearch',
+ condition: generator => !generator.skipUserManagement && generator.searchEngine === ELASTICSEARCH,
path: SERVER_MAIN_SRC_DIR,
templates: [
{
@@ -1627,7 +1632,7 @@ const serverFiles = {
],
},
{
- condition: generator => !generator.skipUserManagement && generator.searchEngine === 'elasticsearch',
+ condition: generator => !generator.skipUserManagement && generator.searchEngine === ELASTICSEARCH,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1637,7 +1642,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.authenticationType === 'jwt',
+ condition: generator => generator.authenticationType === JWT,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1651,7 +1656,7 @@ const serverFiles = {
],
},
{
- condition: generator => generator.applicationType !== 'microservice' && generator.authenticationType === 'jwt',
+ condition: generator => generator.applicationType !== MICROSERVICE && generator.authenticationType === JWT,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1711,7 +1716,7 @@ const serverFiles = {
],
},
{
- condition: generator => !generator.skipUserManagement && generator.authenticationType !== 'oauth2',
+ condition: generator => !generator.skipUserManagement && generator.authenticationType !== OAUTH2,
path: SERVER_TEST_SRC_DIR,
templates: [
{
@@ -1721,7 +1726,7 @@ const serverFiles = {
],
},
{
- condition: generator => !generator.skipUserManagement && generator.authenticationType === 'oauth2',
+ condition: generator => !generator.skipUserManagement && generator.authenticationType === OAUTH2,
path: SERVER_TEST_SRC_DIR,
templates: [
{
diff --git a/generators/server/index.js b/generators/server/index.js
index a00c429329a..06289b5d5da 100644
--- a/generators/server/index.js
+++ b/generators/server/index.js
@@ -21,16 +21,22 @@ const chalk = require('chalk');
const _ = require('lodash');
const os = require('os');
const prompts = require('./prompts');
+const { GENERATOR_COMMON, GENERATOR_LANGUAGES, GENERATOR_SERVER } = require('../generator-list');
+const databaseTypes = require('../../jdl/jhipster/database-types');
+const { OAUTH2, SESSION } = require('../../jdl/jhipster/authentication-types');
+const { GRADLE, MAVEN } = require('../../jdl/jhipster/build-tool-types');
+const { CASSANDRA, COUCHBASE, MARIADB, MSSQL, MYSQL, ORACLE, POSTGRESQL, SQL } = require('../../jdl/jhipster/database-types');
+const { CAFFEINE, EHCACHE, HAZELCAST, INFINISPAN, MEMCACHED, REDIS } = require('../../jdl/jhipster/cache-types');
const BaseBlueprintGenerator = require('../generator-base-blueprint');
const writeFiles = require('./files').writeFiles;
const packagejs = require('../../package.json');
const constants = require('../generator-constants');
const statistics = require('../statistics');
-const { getBase64Secret, getRandomHex } = require('../utils');
const { defaultConfig } = require('../generator-defaults');
-const { GRADLE } = require('../../jdl/jhipster/build-tool-types');
const { ELASTICSEARCH } = require('../../jdl/jhipster/search-engine-types');
+const NO_DATABASE = databaseTypes.NO;
+
let useBlueprints;
module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
@@ -53,7 +59,7 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
// preserve old jhipsterVersion value for cleanup which occurs after new config is written into disk
this.jhipsterOldVersion = this.jhipsterConfig.jhipsterVersion;
- useBlueprints = !this.fromBlueprint && this.instantiateBlueprints('server');
+ useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_SERVER);
// Not using normal blueprints or this is a normal blueprint.
if (!useBlueprints || (this.fromBlueprint && this.sbsBlueprint)) {
@@ -218,9 +224,6 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
this.jhipsterConfig.serverPort = 8080 + this.jhipsterConfig.applicationIndex;
}
},
- validateConfig() {
- this._validateServerConfiguration();
- },
};
}
@@ -233,13 +236,13 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
_composing() {
return {
composeCommon() {
- this.composeWithJHipster('common', true);
+ this.composeWithJHipster(GENERATOR_COMMON, true);
},
composeLanguages() {
// We don't expose client/server to cli, composing with languages is used for test purposes.
if (this.jhipsterConfig.enableTranslation === false) return;
- this.composeWithJHipster('languages', true);
+ this.composeWithJHipster(GENERATOR_LANGUAGES, true);
},
};
}
@@ -258,7 +261,6 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
this.loadClientConfig();
this.loadDerivedClientConfig();
this.loadServerConfig();
- this.loadDerivedServerConfig();
this.loadPlatformConfig();
this.loadTranslationConfig();
},
@@ -281,30 +283,28 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
this.lowercaseBaseName = this.baseName.toLowerCase();
this.humanizedBaseName = _.startCase(this.baseName);
this.mainClass = this.getMainClassName();
- this.cacheManagerIsAvailable = ['ehcache', 'caffeine', 'hazelcast', 'infinispan', 'memcached', 'redis'].includes(
- this.cacheProvider
- );
- this.testsNeedCsrf = ['oauth2', 'session'].includes(this.authenticationType);
+ this.cacheManagerIsAvailable = [EHCACHE, CAFFEINE, HAZELCAST, INFINISPAN, MEMCACHED, REDIS].includes(this.cacheProvider);
+ this.testsNeedCsrf = [OAUTH2, SESSION].includes(this.authenticationType);
this.jhiTablePrefix = this.getTableName(this.jhiPrefix);
- if (this.jhipsterConfig.databaseType === 'sql') {
+ if (this.jhipsterConfig.databaseType === SQL) {
// sql
let dbContainer;
switch (this.jhipsterConfig.prodDatabaseType) {
- case 'mysql':
+ case MYSQL:
dbContainer = this.DOCKER_MYSQL;
break;
- case 'mariadb':
+ case MARIADB:
dbContainer = this.DOCKER_MARIADB;
break;
- case 'postgresql':
+ case POSTGRESQL:
dbContainer = this.DOCKER_POSTGRESQL;
break;
- case 'mssql':
+ case MSSQL:
dbContainer = this.DOCKER_MSSQL;
break;
- case 'oracle':
+ case ORACLE:
default:
dbContainer = null;
}
@@ -335,7 +335,7 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
},
insight() {
- statistics.sendSubGenEvent('generator', 'server', {
+ statistics.sendSubGenEvent('generator', GENERATOR_SERVER, {
app: {
authenticationType: this.authenticationType,
cacheProvider: this.cacheProvider,
@@ -384,9 +384,9 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
const scriptsStorage = this.packageJson.createStorage('scripts');
const databaseType = this.jhipsterConfig.databaseType;
const dockerAwaitScripts = [];
- if (databaseType === 'sql') {
+ if (databaseType === SQL) {
const prodDatabaseType = this.jhipsterConfig.prodDatabaseType;
- if (prodDatabaseType === 'no' || prodDatabaseType === 'oracle') {
+ if (prodDatabaseType === NO_DATABASE || prodDatabaseType === ORACLE) {
scriptsStorage.set('docker:db:up', `echo "Docker for db ${prodDatabaseType} not configured for application ${this.baseName}"`);
} else {
scriptsStorage.set({
@@ -396,12 +396,12 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
}
} else {
const dockerFile = `src/main/docker/${databaseType}.yml`;
- if (databaseType === 'cassandra') {
+ if (databaseType === CASSANDRA) {
scriptsStorage.set({
'docker:db:await': 'wait-on tcp:9042 && sleep 20',
});
}
- if (databaseType === 'couchbase' || databaseType === 'cassandra') {
+ if (databaseType === COUCHBASE || databaseType === CASSANDRA) {
scriptsStorage.set({
'docker:db:build': `docker-compose -f ${dockerFile} build`,
'docker:db:up': `docker-compose -f ${dockerFile} up -d`,
@@ -466,7 +466,7 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
const buildTool = this.jhipsterConfig.buildTool;
let e2ePackage = 'target/e2e';
- if (buildTool === 'maven') {
+ if (buildTool === MAVEN) {
scriptsStorage.set({
'backend:info': './mvnw -ntp enforcer:display-info --batch-mode',
'backend:doc:test': './mvnw -ntp javadoc:javadoc --batch-mode',
@@ -479,7 +479,7 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
'backend:build-cache': './mvnw dependency:go-offline',
'backend:debug': './mvnw -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000"',
});
- } else if (buildTool === 'gradle') {
+ } else if (buildTool === GRADLE) {
const excludeWebapp = this.jhipsterConfig.skipClient ? '' : '-x webapp';
e2ePackage = 'e2e';
scriptsStorage.set({
@@ -513,7 +513,7 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
},
packageJsonE2eScripts() {
const scriptsStorage = this.packageJson.createStorage('scripts');
- const buildCmd = this.jhipsterConfig.buildTool === 'gradle' ? 'gradlew' : 'mvnw';
+ const buildCmd = this.jhipsterConfig.buildTool === GRADLE ? 'gradlew' : 'mvnw';
if (scriptsStorage.get('e2e')) {
scriptsStorage.set({
'ci:server:await':
@@ -539,7 +539,7 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
this.log(chalk.green.bold('\nServer application generated successfully.\n'));
let executable = 'mvnw';
- if (this.buildTool === 'gradle') {
+ if (this.buildTool === GRADLE) {
executable = 'gradlew';
}
let logMsgComment = '';
@@ -555,72 +555,4 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
if (useBlueprints) return;
return this._end();
}
-
- _validateServerConfiguration(config = this.jhipsterConfig) {
- if (!config.packageFolder) {
- config.packageFolder = config.packageName.replace(/\./g, '/');
- }
-
- // JWT authentication is mandatory with Eureka, so the JHipster Registry
- // can control the applications
- if (config.serviceDiscoveryType === 'eureka' && config.authenticationType !== 'oauth2') {
- config.authenticationType = 'jwt';
- }
-
- // Generate JWT secret key if key does not already exist in config
- if ((config.authenticationType === 'jwt' || config.applicationType === 'microservice') && config.jwtSecretKey === undefined) {
- config.jwtSecretKey = getBase64Secret.call(this, null, 64);
- }
- // Generate remember me key if key does not already exist in config
- if (config.authenticationType === 'session' && !config.rememberMeKey) {
- config.rememberMeKey = getRandomHex();
- }
-
- if (config.authenticationType === 'oauth2') {
- config.skipUserManagement = true;
- }
-
- if (config.enableHibernateCache && ['no', 'memcached'].includes(config.cacheProvider)) {
- this.info(`Disabling hibernate cache for cache provider ${config.cacheProvider}`);
- config.enableHibernateCache = false;
- }
-
- // Convert to false for templates.
- if (config.serviceDiscoveryType === 'no' || !config.serviceDiscoveryType) {
- config.serviceDiscoveryType = false;
- }
- if (config.websocket === 'no' || !config.websocket) {
- config.websocket = false;
- }
- if (config.searchEngine === 'no' || !config.searchEngine) {
- config.searchEngine = false;
- }
- if (config.messageBroker === 'no' || !config.messageBroker) {
- config.messageBroker = false;
- }
-
- if (!config.databaseType && config.prodDatabaseType) {
- config.databaseType = this.getDBTypeFromDBValue(config.prodDatabaseType);
- }
- if (!config.devDatabaseType && config.prodDatabaseType) {
- config.devDatabaseType = config.prodDatabaseType;
- }
-
- // force variables unused by microservice applications
- if (config.applicationType === 'microservice') {
- config.websocket = false;
- }
-
- const databaseType = config.databaseType;
- if (databaseType === 'no') {
- config.devDatabaseType = 'no';
- config.prodDatabaseType = 'no';
- config.enableHibernateCache = false;
- config.skipUserManagement = true;
- } else if (['mongodb', 'neo4j', 'couchbase', 'cassandra'].includes(databaseType)) {
- config.devDatabaseType = databaseType;
- config.prodDatabaseType = databaseType;
- config.enableHibernateCache = false;
- }
- }
};
diff --git a/generators/server/needle-api/needle-server-cache.js b/generators/server/needle-api/needle-server-cache.js
index 6c9f447191b..dc3df91fc5d 100644
--- a/generators/server/needle-api/needle-server-cache.js
+++ b/generators/server/needle-api/needle-server-cache.js
@@ -19,6 +19,7 @@
const chalk = require('chalk');
const needleServer = require('./needle-server');
const constants = require('../../generator-constants');
+const { CAFFEINE, EHCACHE, REDIS } = require('../../../jdl/jhipster/cache-types');
const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR;
@@ -42,12 +43,12 @@ module.exports = class extends needleServer {
const errorMessage = chalk.yellow(`\nUnable to add ${entry} to CacheConfiguration.java file.`);
const cachePath = `${SERVER_MAIN_SRC_DIR}${packageFolder}/config/CacheConfiguration.java`;
- if (cacheProvider === 'ehcache' || cacheProvider === 'caffeine') {
+ if (cacheProvider === EHCACHE || cacheProvider === CAFFEINE) {
const needle = `jhipster-needle-${cacheProvider}-add-entry`;
const content = `createCache(cm, ${entry});`;
this._doAddBlockContentToFile(cachePath, needle, content, errorMessage);
- } else if (cacheProvider === 'redis') {
+ } else if (cacheProvider === REDIS) {
const needle = 'jhipster-needle-redis-add-entry';
const content = `createCache(cm, ${entry}, jcacheConfiguration);`;
diff --git a/generators/server/prompts.js b/generators/server/prompts.js
index d2add2daee2..519d87944a5 100644
--- a/generators/server/prompts.js
+++ b/generators/server/prompts.js
@@ -21,6 +21,32 @@ const chalk = require('chalk');
const constants = require('../generator-constants');
const { serverDefaultConfig } = require('../generator-defaults');
+const { GATEWAY, MICROSERVICE, MONOLITH } = require('../../jdl/jhipster/application-types');
+const { CAFFEINE, EHCACHE, HAZELCAST, INFINISPAN, MEMCACHED, REDIS } = require('../../jdl/jhipster/cache-types');
+const cacheProviderTypes = require('../../jdl/jhipster/cache-types');
+const { JWT, OAUTH2, SESSION } = require('../../jdl/jhipster/authentication-types');
+const { GRADLE, MAVEN } = require('../../jdl/jhipster/build-tool-types');
+const { CASSANDRA, H2_DISK, H2_MEMORY, MONGODB, NEO4J, SQL } = require('../../jdl/jhipster/database-types');
+const databaseTypes = require('../../jdl/jhipster/database-types');
+const { CONSUL, EUREKA } = require('../../jdl/jhipster/service-discovery-types');
+const serviceDiscoveryTypes = require('../../jdl/jhipster/service-discovery-types');
+const { OptionNames } = require('../../jdl/jhipster/application-options');
+
+const {
+ AUTHENTICATION_TYPE,
+ BUILD_TOOL,
+ CACHE_PROVIDER,
+ DATABASE_TYPE,
+ PACKAGE_NAME,
+ DEV_DATABASE_TYPE,
+ PROD_DATABASE_TYPE,
+ REACTIVE,
+ SERVER_PORT,
+ SERVICE_DISCOVERY_TYPE,
+} = OptionNames;
+const NO_SERVICE_DISCOVERY = serviceDiscoveryTypes.NO;
+const NO_DATABASE = databaseTypes.NO;
+const NO_CACHE_PROVIDER = cacheProviderTypes.NO;
module.exports = {
askForModuleName,
@@ -38,19 +64,19 @@ function askForServerSideOpts() {
if (this.existingProject) return undefined;
const applicationType = this.jhipsterConfig.applicationType;
- const defaultPort = applicationType === 'gateway' ? '8080' : '8081';
+ const defaultPort = applicationType === GATEWAY ? '8080' : '8081';
const prompts = [
{
- when: () => ['monolith', 'microservice'].includes(applicationType),
+ when: () => [MONOLITH, MICROSERVICE].includes(applicationType),
type: 'confirm',
- name: 'reactive',
+ name: REACTIVE,
message: 'Do you want to make it reactive with Spring WebFlux?',
default: serverDefaultConfig.reactive,
},
{
- when: () => applicationType === 'gateway' || applicationType === 'microservice',
+ when: () => applicationType === GATEWAY || applicationType === MICROSERVICE,
type: 'input',
- name: 'serverPort',
+ name: SERVER_PORT,
validate: input => (/^([0-9]*)$/.test(input) ? true : 'This is not a valid port number.'),
message:
'As you are running in a microservice architecture, on which port would like your server to run? It should be unique to avoid port conflicts.',
@@ -58,7 +84,7 @@ function askForServerSideOpts() {
},
{
type: 'input',
- name: 'packageName',
+ name: PACKAGE_NAME,
validate: input =>
/^([a-z_]{1}[a-z0-9_]*(\.[a-z_]{1}[a-z0-9_]*)*)$/.test(input)
? true
@@ -70,45 +96,44 @@ function askForServerSideOpts() {
{
when: () => applicationType === 'gateway' || applicationType === 'microservice',
type: 'list',
- name: 'serviceDiscoveryType',
+ name: SERVICE_DISCOVERY_TYPE,
message: 'Which service discovery server do you want to use?',
choices: [
{
- value: 'eureka',
+ value: EUREKA,
name: 'JHipster Registry (uses Eureka, provides Spring Cloud Config support and monitoring dashboards)',
},
{
- value: 'consul',
+ value: CONSUL,
name: 'Consul',
},
{
- value: false,
+ value: NO_SERVICE_DISCOVERY,
name: 'No service discovery',
},
],
- default: 'eureka',
+ default: EUREKA,
},
{
when: answers =>
- (applicationType === 'monolith' && answers.serviceDiscoveryType !== 'eureka') ||
- ['gateway', 'microservice'].includes(applicationType),
+ (applicationType === MONOLITH && answers.serviceDiscoveryType !== EUREKA) || [GATEWAY, MICROSERVICE].includes(applicationType),
type: 'list',
- name: 'authenticationType',
+ name: AUTHENTICATION_TYPE,
message: `Which ${chalk.yellow('*type*')} of authentication would you like to use?`,
choices: answers => {
const opts = [
{
- value: 'jwt',
+ value: JWT,
name: 'JWT authentication (stateless, with a token)',
},
];
opts.push({
- value: 'oauth2',
+ value: OAUTH2,
name: 'OAuth 2.0 / OIDC Authentication (stateful, works with Keycloak and Okta)',
});
- if (applicationType === 'monolith' && answers.serviceDiscoveryType !== 'eureka') {
+ if (applicationType === MONOLITH && answers.serviceDiscoveryType !== EUREKA) {
opts.push({
- value: 'session',
+ value: SESSION,
name: 'HTTP Session Authentication (stateful, default Spring Security mechanism)',
});
}
@@ -118,28 +143,28 @@ function askForServerSideOpts() {
},
{
type: 'list',
- name: 'databaseType',
+ name: DATABASE_TYPE,
message: `Which ${chalk.yellow('*type*')} of database would you like to use?`,
choices: answers => {
const opts = [];
if (!answers.reactive) {
opts.push({
- value: 'sql',
+ value: SQL,
name: 'SQL (H2, PostgreSQL, MySQL, MariaDB, Oracle, MSSQL)',
});
} else {
opts.push({
- value: 'sql',
+ value: SQL,
name: 'SQL (H2, PostgreSQL, MySQL, MariaDB, MSSQL)',
});
}
opts.push({
- value: 'mongodb',
+ value: MONGODB,
name: 'MongoDB',
});
- if (answers.authenticationType !== 'oauth2') {
+ if (answers.authenticationType !== OAUTH2) {
opts.push({
- value: 'cassandra',
+ value: CASSANDRA,
name: 'Cassandra',
});
}
@@ -149,11 +174,11 @@ function askForServerSideOpts() {
name: 'Couchbase',
}); */
opts.push({
- value: 'neo4j',
+ value: NEO4J,
name: '[BETA] Neo4j',
});
opts.push({
- value: 'no',
+ value: NO_DATABASE,
name: 'No database',
});
return opts;
@@ -161,26 +186,26 @@ function askForServerSideOpts() {
default: serverDefaultConfig.databaseType,
},
{
- when: response => response.databaseType === 'sql',
+ when: response => response.databaseType === SQL,
type: 'list',
- name: 'prodDatabaseType',
+ name: PROD_DATABASE_TYPE,
message: `Which ${chalk.yellow('*production*')} database would you like to use?`,
choices: answers => (answers.reactive ? constants.R2DBC_DB_OPTIONS : constants.SQL_DB_OPTIONS),
default: serverDefaultConfig.prodDatabaseType,
},
{
- when: response => response.databaseType === 'sql',
+ when: response => response.databaseType === SQL,
type: 'list',
- name: 'devDatabaseType',
+ name: DEV_DATABASE_TYPE,
message: `Which ${chalk.yellow('*development*')} database would you like to use?`,
choices: response =>
[
{
- value: 'h2Disk',
+ value: H2_DISK,
name: 'H2 with disk-based persistence',
},
{
- value: 'h2Memory',
+ value: H2_MEMORY,
name: 'H2 with in-memory persistence',
},
].concat(constants.SQL_DB_OPTIONS.find(it => it.value === response.prodDatabaseType)),
@@ -189,44 +214,44 @@ function askForServerSideOpts() {
{
when: answers => !answers.reactive,
type: 'list',
- name: 'cacheProvider',
+ name: CACHE_PROVIDER,
message: 'Which cache do you want to use? (Spring cache abstraction)',
choices: [
{
- value: 'ehcache',
+ value: EHCACHE,
name: 'Ehcache (local cache, for a single node)',
},
{
- value: 'caffeine',
+ value: CAFFEINE,
name: 'Caffeine (local cache, for a single node)',
},
{
- value: 'hazelcast',
+ value: HAZELCAST,
name: 'Hazelcast (distributed cache, for multiple nodes, supports rate-limiting for gateway applications)',
},
{
- value: 'infinispan',
+ value: INFINISPAN,
name: 'Infinispan (hybrid cache, for multiple nodes)',
},
{
- value: 'memcached',
+ value: MEMCACHED,
name: 'Memcached (distributed cache) - Warning, when using an SQL database, this will disable the Hibernate 2nd level cache!',
},
{
- value: 'redis',
+ value: REDIS,
name: 'Redis (distributed cache)',
},
{
- value: 'no',
+ value: NO_CACHE_PROVIDER,
name: 'No cache - Warning, when using an SQL database, this will disable the Hibernate 2nd level cache!',
},
],
- default: applicationType === 'microservice' ? 2 : serverDefaultConfig.cacheProvider,
+ default: applicationType === MICROSERVICE ? 2 : serverDefaultConfig.cacheProvider,
},
{
when: answers =>
- ((answers.cacheProvider !== 'no' && answers.cacheProvider !== 'memcached') || applicationType === 'gateway') &&
- answers.databaseType === 'sql' &&
+ ((answers.cacheProvider !== NO_CACHE_PROVIDER && answers.cacheProvider !== MEMCACHED) || applicationType === GATEWAY) &&
+ answers.databaseType === SQL &&
!answers.reactive,
type: 'confirm',
name: 'enableHibernateCache',
@@ -235,32 +260,32 @@ function askForServerSideOpts() {
},
{
type: 'list',
- name: 'buildTool',
+ name: BUILD_TOOL,
message: 'Would you like to use Maven or Gradle for building the backend?',
choices: [
{
- value: 'maven',
+ value: MAVEN,
name: 'Maven',
},
{
- value: 'gradle',
+ value: GRADLE,
name: 'Gradle',
},
],
default: serverDefaultConfig.buildTool,
},
{
- when: applicationType === 'monolith',
+ when: applicationType === MONOLITH,
type: 'list',
- name: 'serviceDiscoveryType',
+ name: SERVICE_DISCOVERY_TYPE,
message: 'Do you want to use the JHipster Registry to configure, monitor and scale your application?',
choices: [
{
- value: false,
+ value: NO_SERVICE_DISCOVERY,
name: 'No',
},
{
- value: 'eureka',
+ value: EUREKA,
name: 'Yes',
},
],
@@ -270,7 +295,7 @@ function askForServerSideOpts() {
return this.prompt(prompts).then(answers => {
this.serviceDiscoveryType = this.jhipsterConfig.serviceDiscoveryType = answers.serviceDiscoveryType;
- if (this.jhipsterConfig.applicationType === 'gateway') {
+ if (this.jhipsterConfig.applicationType === GATEWAY) {
this.reactive = this.jhipsterConfig.reactive = answers.reactive = true;
} else {
this.reactive = this.jhipsterConfig.reactive = answers.reactive;
@@ -279,7 +304,7 @@ function askForServerSideOpts() {
this.packageName = this.jhipsterConfig.packageName = answers.packageName;
this.serverPort = this.jhipsterConfig.serverPort = answers.serverPort || '8080';
- this.cacheProvider = this.jhipsterConfig.cacheProvider = !answers.reactive ? answers.cacheProvider : 'no';
+ this.cacheProvider = this.jhipsterConfig.cacheProvider = !answers.reactive ? answers.cacheProvider : NO_CACHE_PROVIDER;
this.enableHibernateCache = this.jhipsterConfig.enableHibernateCache = !!answers.enableHibernateCache;
this.databaseType = this.jhipsterConfig.databaseType = answers.databaseType;
this.devDatabaseType = this.jhipsterConfig.devDatabaseType = answers.devDatabaseType;
@@ -298,7 +323,7 @@ function askForOptionalItems() {
const choices = [];
const defaultChoice = [];
- if (['sql', 'mongodb', 'neo4j'].includes(databaseType)) {
+ if ([SQL, MONGODB, NEO4J].includes(databaseType)) {
choices.push({
name: 'Elasticsearch as search engine',
value: 'searchEngine:elasticsearch',
@@ -311,7 +336,7 @@ function askForOptionalItems() {
});
}
if (!reactive) {
- if (applicationType === 'monolith' || applicationType === 'gateway') {
+ if (applicationType === MONOLITH || applicationType === GATEWAY) {
choices.push({
name: 'WebSockets using Spring Websocket',
value: 'websocket:spring-websocket',
diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs
index 79f0405be86..99e7f0f5e69 100644
--- a/generators/server/templates/build.gradle.ejs
+++ b/generators/server/templates/build.gradle.ejs
@@ -34,15 +34,15 @@ plugins {
id "org.springframework.boot"
id "com.google.cloud.tools.jib"
id "com.gorylenko.gradle-git-properties"
- <%_ if (enableSwaggerCodegen) { _%>
+<%_ if (enableSwaggerCodegen) { _%>
id "org.openapi.generator"
- <%_ } _%>
- <%_ if (!skipClient) { _%>
+<%_ } _%>
+<%_ if (!skipClient) { _%>
id "com.github.node-gradle.node"
- <%_ } _%>
- <%_ if (databaseType === 'sql' && !reactive) { _%>
+<%_ } _%>
+<%_ if (databaseTypeSql && !reactive) { _%>
id "org.liquibase.gradle"
- <%_ } _%>
+<%_ } _%>
id "org.sonarqube"
id "io.spring.nohttp"
//jhipster-needle-gradle-plugins - JHipster will add additional gradle plugins here
diff --git a/generators/server/templates/checkstyle.xml.ejs b/generators/server/templates/checkstyle.xml.ejs
index 7916559a965..5166ee1c72c 100644
--- a/generators/server/templates/checkstyle.xml.ejs
+++ b/generators/server/templates/checkstyle.xml.ejs
@@ -27,9 +27,9 @@