Enable strict checking of config during CLI.

Signed-off-by: Aramis Sennyey <sennyeya@amazon.com>
This commit is contained in:
Aramis Sennyey
2023-05-05 13:45:53 -04:00
parent 9ab7a4b538
commit 473db605a4
13 changed files with 64 additions and 11 deletions
+1
View File
@@ -58,6 +58,7 @@ Options:
--lax
--frontend
--deprecated
--strict
--config <path>
-h, --help
```
@@ -24,5 +24,6 @@ export default async (opts: OptionValues) => {
mockEnv: opts.lax,
fullVisibility: !opts.frontend,
withDeprecatedKeys: opts.deprecated,
strict: opts.strict,
});
};
+4
View File
@@ -345,6 +345,10 @@ export function registerCommands(program: Command) {
.option('--lax', 'Do not require environment variables to be set')
.option('--frontend', 'Only validate the frontend configuration')
.option('--deprecated', 'Output deprecated configuration settings')
.option(
'--strict',
'Enable strict config validation, forbidding errors and unknown errors',
)
.option(...configOption)
.description(
'Validate that the given configuration loads and matches schema',
+3
View File
@@ -32,6 +32,7 @@ type Options = {
withFilteredKeys?: boolean;
withDeprecatedKeys?: boolean;
fullVisibility?: boolean;
strict?: boolean;
};
export async function loadCliConfig(options: Options) {
@@ -70,6 +71,7 @@ export async function loadCliConfig(options: Options) {
dependencies: localPackageNames,
// Include the package.json in the project root if it exists
packagePaths: [paths.resolveTargetRoot('package.json')],
noUndeclaredProperties: options.strict,
});
const { appConfigs } = await loadConfig({
@@ -93,6 +95,7 @@ export async function loadCliConfig(options: Options) {
: ['frontend'],
withFilteredKeys: options.withFilteredKeys,
withDeprecatedKeys: options.withDeprecatedKeys,
ignoreSchemaErrors: !options.strict,
});
const frontendConfig = ConfigReader.fromConfigs(frontendAppConfigs);