Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix configureServer with --defaults #21477

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generators/app/__snapshots__/generator.spec.mts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
"jhipsterDependenciesVersion": "JHIPSTER_DEPENDENCIES_VERSION",
"jhipsterPackageJson": Any<Object>,
"jhipsterVersion": "7.9.3",
"jwtSecretKey": undefined,
"jwtSecretKey": "SECRET--64",
"languages": [
"en",
"fr",
Expand Down
34 changes: 17 additions & 17 deletions generators/server/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -814,55 +814,55 @@ export default class JHipsterServerGenerator extends BaseApplicationGenerator {
return this.asEndTaskGroup(this.delegateTasksToBlueprint(() => this.end));
}

_configureServer(config = this.jhipsterConfig) {
_configureServer(config = this.jhipsterConfigWithDefaults, dest = this.jhipsterConfig) {
// JWT authentication is mandatory with Eureka, so the JHipster Registry
// can control the applications
if (config.serviceDiscoveryType === EUREKA && config.authenticationType !== OAUTH2) {
config.authenticationType = JWT;
dest.authenticationType = JWT;
}

// Generate JWT secret key if key does not already exist in config
if (
(config.authenticationType === JWT || config.applicationType === MICROSERVICE || config.applicationType === GATEWAY) &&
config.jwtSecretKey === undefined
) {
config.jwtSecretKey = createBase64Secret(64, this.options.reproducibleTests);
dest.jwtSecretKey = createBase64Secret(64, this.options.reproducibleTests);
}
// Generate remember me key if key does not already exist in config
if (config.authenticationType === SESSION && !config.rememberMeKey) {
config.rememberMeKey = createSecret();
if (config.authenticationType === SESSION && !dest.rememberMeKey) {
dest.rememberMeKey = createSecret();
}

if (config.authenticationType === OAUTH2) {
config.skipUserManagement = true;
dest.skipUserManagement = true;
}

if (config.enableHibernateCache && [NO_CACHE, MEMCACHED].includes(config.cacheProvider)) {
this.logger.info(`Disabling hibernate cache for cache provider ${config.cacheProvider}`);
config.enableHibernateCache = false;
dest.enableHibernateCache = false;
}

if (!config.databaseType && config.prodDatabaseType) {
config.databaseType = getDBTypeFromDBValue(config.prodDatabaseType);
dest.databaseType = getDBTypeFromDBValue(config.prodDatabaseType);
}
if (!config.devDatabaseType && config.prodDatabaseType) {
config.devDatabaseType = config.prodDatabaseType;
dest.devDatabaseType = config.prodDatabaseType;
}

// force variables unused by microservice applications
if (config.applicationType === MICROSERVICE) {
config.websocket = NO_WEBSOCKET;
dest.websocket = NO_WEBSOCKET;
}
const databaseType = config.databaseType;
if (databaseType === NO_DATABASE) {
config.devDatabaseType = NO_DATABASE;
config.prodDatabaseType = NO_DATABASE;
config.enableHibernateCache = false;
config.skipUserManagement = true;
dest.devDatabaseType = NO_DATABASE;
dest.prodDatabaseType = NO_DATABASE;
dest.enableHibernateCache = false;
dest.skipUserManagement = true;
} else if ([MONGODB, NEO4J, COUCHBASE, CASSANDRA].includes(databaseType)) {
config.devDatabaseType = databaseType;
config.prodDatabaseType = databaseType;
config.enableHibernateCache = false;
dest.devDatabaseType = databaseType;
dest.prodDatabaseType = databaseType;
dest.enableHibernateCache = false;
}
}

Expand Down