Skip to content

Commit 53c66a0

Browse files
committed
feat: adds includeNoEnvironment option for app-config validate
1 parent 36ae096 commit 53c66a0

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

app-config-cli/src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,18 @@ export const cli = yargs
469469
description: 'Validates only using one environment',
470470
group: OptionGroups.Options,
471471
},
472+
includeNoEnvironment: {
473+
type: 'boolean',
474+
description: 'Validates config with no environment selected',
475+
group: OptionGroups.Options,
476+
},
472477
},
473478
},
474-
async ({ environment }) => {
479+
async ({ environment, includeNoEnvironment }) => {
475480
if (environment) {
476481
await loadValidatedConfig({ environmentOverride: environment });
477482
} else {
478-
await validateAllConfigVariants();
483+
await validateAllConfigVariants({ includeNoEnvironment });
479484
}
480485
},
481486
),

app-config-cli/src/validation.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import { loadValidatedConfig } from '@app-config/config';
66
export interface Options {
77
directory?: string;
88
environmentAliases?: EnvironmentAliases;
9+
includeNoEnvironment?: boolean;
910
}
1011

1112
export async function validateAllConfigVariants({
1213
directory = '.',
1314
environmentAliases = defaultAliases,
15+
includeNoEnvironment = false,
1416
}: Options = {}) {
1517
// first, we have to find any applicable app-config files
1618
// this is less trivial than config loading, because we can't "assume" the current environment (it could be anything)
@@ -68,4 +70,13 @@ export async function validateAllConfigVariants({
6870
environmentVariableName: '', // do not load APP_CONFIG
6971
});
7072
}
73+
74+
if (includeNoEnvironment || appConfigEnvironments.size === 0) {
75+
logger.info(`Validating configuration for no environment`);
76+
77+
await loadValidatedConfig({
78+
directory,
79+
environmentVariableName: '', // do not load APP_CONFIG
80+
});
81+
}
7182
}

0 commit comments

Comments
 (0)