config-loader: pass in env as an option
This commit is contained in:
@@ -23,6 +23,7 @@ import { loadConfig } from '@backstage/config-loader';
|
||||
export async function loadBackendConfig() {
|
||||
const paths = findPaths(__dirname);
|
||||
const configs = await loadConfig({
|
||||
env: process.env.NODE_ENV,
|
||||
rootPaths: [paths.targetDir, paths.targetRoot],
|
||||
shouldReadSecrets: true,
|
||||
});
|
||||
|
||||
@@ -22,6 +22,7 @@ import { buildBundle } from '../../lib/bundler';
|
||||
|
||||
export default async (cmd: Command) => {
|
||||
const appConfigs = await loadConfig({
|
||||
env: 'production',
|
||||
rootPaths: [paths.targetDir, paths.targetRoot],
|
||||
});
|
||||
await buildBundle({
|
||||
|
||||
@@ -22,6 +22,7 @@ import { serveBundle } from '../../lib/bundler';
|
||||
|
||||
export default async (cmd: Command) => {
|
||||
const appConfigs = await loadConfig({
|
||||
env: 'development',
|
||||
rootPaths: [paths.targetDir, paths.targetRoot],
|
||||
});
|
||||
const waitForExit = await serveBundle({
|
||||
|
||||
@@ -22,6 +22,7 @@ import { serveBackend } from '../../lib/bundler/backend';
|
||||
|
||||
export default async (cmd: Command) => {
|
||||
const appConfigs = await loadConfig({
|
||||
env: 'development',
|
||||
rootPaths: [paths.targetDir, paths.targetRoot],
|
||||
});
|
||||
const waitForExit = await serveBackend({
|
||||
|
||||
@@ -22,6 +22,7 @@ import { buildBundle } from '../../lib/bundler';
|
||||
|
||||
export default async (cmd: Command) => {
|
||||
const appConfigs = await loadConfig({
|
||||
env: 'production',
|
||||
rootPaths: [paths.targetDir, paths.targetRoot],
|
||||
});
|
||||
await buildBundle({
|
||||
|
||||
@@ -22,6 +22,7 @@ import { serveBundle } from '../../lib/bundler';
|
||||
|
||||
export default async (cmd: Command) => {
|
||||
const appConfigs = await loadConfig({
|
||||
env: 'development',
|
||||
rootPaths: [paths.targetDir, paths.targetRoot],
|
||||
});
|
||||
const waitForExit = await serveBundle({
|
||||
|
||||
@@ -20,6 +20,8 @@ import { pathExists } from 'fs-extra';
|
||||
type ResolveOptions = {
|
||||
// Root paths to search for config files. Config from earlier paths has higher priority.
|
||||
rootPaths: string[];
|
||||
// The environment that we're loading config for, e.g. 'development', 'production'.
|
||||
env: string;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -35,11 +37,9 @@ type ResolveOptions = {
|
||||
export async function resolveStaticConfig(
|
||||
options: ResolveOptions,
|
||||
): Promise<string[]> {
|
||||
const env = process.env.NODE_ENV ?? 'development';
|
||||
|
||||
const filePaths = [
|
||||
`app-config.${env}.local.yaml`,
|
||||
`app-config.${env}.yaml`,
|
||||
`app-config.${options.env}.local.yaml`,
|
||||
`app-config.${options.env}.yaml`,
|
||||
`app-config.local.yaml`,
|
||||
`app-config.yaml`,
|
||||
];
|
||||
|
||||
@@ -28,6 +28,9 @@ export type LoadConfigOptions = {
|
||||
// Root paths to search for config files. Config from earlier paths has higher priority.
|
||||
rootPaths: string[];
|
||||
|
||||
// The environment that we're loading config for, e.g. 'development', 'production'.
|
||||
env: string;
|
||||
|
||||
// Whether to read secrets or omit them, defaults to false.
|
||||
shouldReadSecrets?: boolean;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user