Refactor env variables (#2094)

* Rename the env to sync with BE/Docker

* Refactor envs

* Use the env.yml strategy
This commit is contained in:
Maurizio Vitale
2021-04-28 15:14:20 +01:00
committed by GitHub
parent cc6bb7e95b
commit 4ebc7447f9
10 changed files with 35 additions and 248 deletions

View File

@@ -4,41 +4,38 @@ const program = require('commander');
require('dotenv').config({ path: process.env.ENV_FILE });
const fs = require('fs');
const API_HOST = process.env.API_HOST || null;
const API_CONTENT_HOST = process.env.API_CONTENT_HOST || API_HOST;
const API_PROCESS_HOST = process.env.API_PROCESS_HOST || API_HOST;
const API_AOS_HOST = process.env.API_AOS_HOST || API_HOST;
const OAUTH_HOST = process.env.OAUTH_HOST || 'oauth-host-default-replaced-value';
const IDENTITY_HOST = process.env.IDENTITY_HOST || 'identity-host-default-replaced-value';
const NOTIFICATION_LAST = parseInt(process.env.NOTIFICATION_LAST, 10) || 2000;
const APP_CONFIG_ECM_HOST = process.env.APP_CONFIG_ECM_HOST;
const APP_CONFIG_BPM_HOST = process.env.APP_CONFIG_BPM_HOST;
const APP_CONFIG_OAUTH2_HOST = process.env.APP_CONFIG_OAUTH2_HOST || 'oauth-host-default-replaced-value';
const APP_CONFIG_IDENTITY_HOST = process.env.APP_CONFIG_IDENTITY_HOST || 'identity-host-default-replaced-value';
const APP_CONFIG_NOTIFICATION_LAST = parseInt(process.env.APP_CONFIG_NOTIFICATION_LAST, 10) || 2000;
const options = {
apiHost: {
flags: '-a, --api-host',
description:
'set apiHost=API_HOST, bpmHost=API_PROCESS_HOST, ecmHost=API_CONTENT_HOST, aosHost = API_AOS_HOST if present or fall back to API_HOST in each case',
'set bpmHost=APP_CONFIG_BPM_HOST, ecmHost=APP_CONFIG_ECM_HOST, aosHost = APP_CONFIG_ECM_HOST if present',
set: (appConfig) => {
appConfig.apiHost = API_HOST;
appConfig.bpmHost = API_PROCESS_HOST;
appConfig.ecmHost = API_CONTENT_HOST;
appConfig.baseShareUrl = appConfig.baseShareUrl.replace('{protocol}//{hostname}{:port}', API_CONTENT_HOST);
appConfig.aosHost = appConfig.aosHost.replace('{protocol}//{hostname}{:port}', API_AOS_HOST);
appConfig.bpmHost = APP_CONFIG_BPM_HOST;
appConfig.ecmHost = APP_CONFIG_ECM_HOST;
appConfig.baseShareUrl = appConfig.baseShareUrl.replace('{protocol}//{hostname}{:port}', APP_CONFIG_ECM_HOST);
appConfig.aosHost = appConfig.aosHost.replace('{protocol}//{hostname}{:port}', APP_CONFIG_ECM_HOST);
}
},
identityHost: {
flags: '-i, --identity-host',
description: "set identityHost's value with IDENTITY_HOST",
description: "set identityHost's value with APP_CONFIG_IDENTITY_HOST",
set: (appConfig) => {
appConfig.authType = 'OAUTH';
appConfig.identityHost = IDENTITY_HOST;
appConfig.identityHost = APP_CONFIG_IDENTITY_HOST;
}
},
oauthHost: {
flags: '-o, --oauth-host',
description: "set oauth2.host's value with OAUTH_HOST",
description: "set oauth2.host's value with APP_CONFIG_OAUTH2_HOST",
set: (appConfig) => {
appConfig.authType = 'OAUTH';
appConfig.oauth2.host = OAUTH_HOST;
appConfig.oauth2.host = APP_CONFIG_OAUTH2_HOST;
}
},
notification: {
@@ -46,7 +43,7 @@ const options = {
description: "set notificationDefaultDuration's value with <duration> and switch on showNotificationHistory",
set: (appConfig) => {
appConfig.showNotificationHistory = true;
appConfig.notificationDefaultDuration = NOTIFICATION_LAST;
appConfig.notificationDefaultDuration = APP_CONFIG_NOTIFICATION_LAST;
}
}
};