Enable strict checking of config during CLI.
Signed-off-by: Aramis Sennyey <sennyeya@amazon.com>
This commit is contained in:
@@ -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,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user