mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 23:43:01 +00:00
Merge pull request #1814 from atmire/issue_1795_issue_1778_fix_config_issues
Repair config issues
This commit is contained in:
@@ -143,10 +143,6 @@ export abstract class InitService {
|
||||
if (environment.debug) {
|
||||
console.info(environment);
|
||||
}
|
||||
|
||||
const env: string = environment.production ? 'Production' : 'Development';
|
||||
const color: string = environment.production ? 'red' : 'green';
|
||||
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -54,14 +54,28 @@ const getEnvironment = (): Environment => {
|
||||
return environment;
|
||||
};
|
||||
|
||||
const getLocalConfigPath = (env: Environment) => {
|
||||
// default to config/config.yml
|
||||
let localConfigPath = join(CONFIG_PATH, 'config.yml');
|
||||
/**
|
||||
* Get the path of the default config file.
|
||||
*/
|
||||
const getDefaultConfigPath = () => {
|
||||
|
||||
if (!fs.existsSync(localConfigPath)) {
|
||||
localConfigPath = join(CONFIG_PATH, 'config.yaml');
|
||||
// default to config/config.yml
|
||||
let defaultConfigPath = join(CONFIG_PATH, 'config.yml');
|
||||
|
||||
if (!fs.existsSync(defaultConfigPath)) {
|
||||
defaultConfigPath = join(CONFIG_PATH, 'config.yaml');
|
||||
}
|
||||
|
||||
return defaultConfigPath;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the path of an environment-specific config file.
|
||||
*
|
||||
* @param env the environment to get the config file for
|
||||
*/
|
||||
const getEnvConfigFilePath = (env: Environment) => {
|
||||
|
||||
// determine app config filename variations
|
||||
let envVariations;
|
||||
switch (env) {
|
||||
@@ -76,22 +90,21 @@ const getLocalConfigPath = (env: Environment) => {
|
||||
envVariations = ['dev', 'development'];
|
||||
}
|
||||
|
||||
let envLocalConfigPath;
|
||||
|
||||
// check if any environment variations of app config exist
|
||||
for (const envVariation of envVariations) {
|
||||
let envLocalConfigPath = join(CONFIG_PATH, `config.${envVariation}.yml`);
|
||||
envLocalConfigPath = join(CONFIG_PATH, `config.${envVariation}.yml`);
|
||||
if (fs.existsSync(envLocalConfigPath)) {
|
||||
break;
|
||||
}
|
||||
envLocalConfigPath = join(CONFIG_PATH, `config.${envVariation}.yaml`);
|
||||
if (fs.existsSync(envLocalConfigPath)) {
|
||||
localConfigPath = envLocalConfigPath;
|
||||
break;
|
||||
} else {
|
||||
envLocalConfigPath = join(CONFIG_PATH, `config.${envVariation}.yaml`);
|
||||
if (fs.existsSync(envLocalConfigPath)) {
|
||||
localConfigPath = envLocalConfigPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return localConfigPath;
|
||||
return envLocalConfigPath;
|
||||
};
|
||||
|
||||
const overrideWithConfig = (config: Config, pathToConfig: string) => {
|
||||
@@ -174,12 +187,20 @@ export const buildAppConfig = (destConfigPath?: string): AppConfig => {
|
||||
console.log(`Building ${colors.green.bold(`development`)} app config`);
|
||||
}
|
||||
|
||||
// override with dist config
|
||||
const localConfigPath = getLocalConfigPath(env);
|
||||
// override with default config
|
||||
const defaultConfigPath = getDefaultConfigPath();
|
||||
if (fs.existsSync(defaultConfigPath)) {
|
||||
overrideWithConfig(appConfig, defaultConfigPath);
|
||||
} else {
|
||||
console.warn(`Unable to find default config file at ${defaultConfigPath}`);
|
||||
}
|
||||
|
||||
// override with env config
|
||||
const localConfigPath = getEnvConfigFilePath(env);
|
||||
if (fs.existsSync(localConfigPath)) {
|
||||
overrideWithConfig(appConfig, localConfigPath);
|
||||
} else {
|
||||
console.warn(`Unable to find dist config file at ${localConfigPath}`);
|
||||
console.warn(`Unable to find env config file at ${localConfigPath}`);
|
||||
}
|
||||
|
||||
// override with external config if specified by environment variable `DSPACE_APP_CONFIG_PATH`
|
||||
|
@@ -28,6 +28,7 @@ import { StoreAction, StoreActionTypes } from '../../app/store.actions';
|
||||
import { coreSelector } from '../../app/core/core.selectors';
|
||||
import { find, map } from 'rxjs/operators';
|
||||
import { isNotEmpty } from '../../app/shared/empty.util';
|
||||
import { logStartupMessage } from '../../../startup-message';
|
||||
|
||||
/**
|
||||
* Performs client-side initialization.
|
||||
@@ -79,6 +80,7 @@ export class BrowserInitService extends InitService {
|
||||
this.initCorrelationId();
|
||||
|
||||
this.checkEnvironment();
|
||||
logStartupMessage(environment);
|
||||
|
||||
this.initI18n();
|
||||
this.initAngulartics();
|
||||
|
Reference in New Issue
Block a user