cli: add --lax option to config:check which assumes that all env vars are set

This commit is contained in:
Patrik Oldsberg
2021-01-24 17:47:41 +01:00
parent 9f33201f55
commit 651561eda8
4 changed files with 8 additions and 1 deletions
@@ -24,6 +24,7 @@ export default async (cmd: Command) => {
const { schema, appConfigs } = await loadCliConfig({
args: cmd.config,
fromPackage: cmd.package,
mockEnv: cmd.lax,
});
const visibility = getVisibilityOption(cmd);
const data = serializeConfigData(appConfigs, schema, visibility);
@@ -21,5 +21,6 @@ export default async (cmd: Command) => {
await loadCliConfig({
args: cmd.config,
fromPackage: cmd.package,
mockEnv: cmd.lax,
});
};
+2
View File
@@ -153,6 +153,7 @@ export function registerCommands(program: CommanderStatic) {
'--package <name>',
'Only load config schema that applies to the given package',
)
.option('--lax', 'Do not require environment variables to be set')
.option('--frontend', 'Print only the frontend configuration')
.option('--with-secrets', 'Include secrets in the printed configuration')
.option(
@@ -169,6 +170,7 @@ export function registerCommands(program: CommanderStatic) {
'--package <name>',
'Only load config schema that applies to the given package',
)
.option('--lax', 'Do not require environment variables to be set')
.option(...configOption)
.description(
'Validate that the given configuration loads and matches schema',
+4 -1
View File
@@ -21,6 +21,7 @@ import { paths } from './paths';
type Options = {
args: string[];
fromPackage?: string;
mockEnv?: boolean;
};
export async function loadCliConfig(options: Options) {
@@ -40,7 +41,9 @@ export async function loadCliConfig(options: Options) {
});
const appConfigs = await loadConfig({
env: process.env.APP_ENV ?? process.env.NODE_ENV ?? 'production',
experimentalEnvFunc: options.mockEnv
? async name => process.env[name] || 'x'
: undefined,
configRoot: paths.targetRoot,
configPaths,
});