feat: add support for local env specific config files
Signed-off-by: Hellgren Heikki <heikki.hellgren@op.fi>
This commit is contained in:
@@ -25,6 +25,7 @@ Loading order of these files is as follows:
|
||||
1. `app-config.yaml`
|
||||
2. `app-config.<BACKSTAGE_ENVIRONMENT>.yaml`
|
||||
3. `app-config.local.yaml`
|
||||
4. `app-config.<BACKSTAGE_ENVIRONMENT>.local.yaml`
|
||||
|
||||
Other sets of files can by loaded by passing `--config <path>` flags.
|
||||
Read more about the configuration loading order in the
|
||||
|
||||
@@ -99,6 +99,7 @@ describe('ConfigSources', () => {
|
||||
{ name: 'FileConfigSource', path: `${root}app-config.yaml` },
|
||||
{ name: 'FileConfigSource', path: `${root}app-config.test.yaml` },
|
||||
{ name: 'FileConfigSource', path: `${root}app-config.local.yaml` },
|
||||
{ name: 'FileConfigSource', path: `${root}app-config.test.local.yaml` },
|
||||
]);
|
||||
|
||||
fsSpy.mockRestore();
|
||||
|
||||
@@ -186,6 +186,10 @@ export class ConfigSources {
|
||||
rootDir,
|
||||
`app-config.${process.env.BACKSTAGE_ENVIRONMENT}.yaml`,
|
||||
);
|
||||
const envLocalPath = resolvePath(
|
||||
rootDir,
|
||||
`app-config.${process.env.BACKSTAGE_ENVIRONMENT}.local.yaml`,
|
||||
);
|
||||
const alwaysIncludeDefaultConfigSource =
|
||||
!options.allowMissingDefaultConfig;
|
||||
|
||||
@@ -218,6 +222,19 @@ export class ConfigSources {
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
process.env.BACKSTAGE_ENVIRONMENT &&
|
||||
fs.pathExistsSync(envLocalPath)
|
||||
) {
|
||||
argSources.push(
|
||||
FileConfigSource.create({
|
||||
watch: options.watch,
|
||||
path: envLocalPath,
|
||||
substitutionFunc: options.substitutionFunc,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return this.merge(argSources);
|
||||
|
||||
Reference in New Issue
Block a user