You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: notices key in cdk.json is not respected (#821)
Fixes#724
## Description
Setting `"notices": false` in cdk.json doesn't suppress notices.
The root cause is that we handle logic to determine whether we should
print notices at *yargs*. Yargs had a default value determined by a
helper function (`YARGS_HELPERS.shouldDisplayNotices()`) that returned
true when not in CI, or when in a safe CI.
This meant that any setting in our configuration would be overwritten by
the output of this helper, because it looks like it's coming from the
command line!
## Solution
Centralize logic for notices in `cli.ts`.
Made the notices option in yargs `undefined` by default. Moved the logic
from `YARGS_HELPERS.shouldDisplayNotices()` into the `cli.ts`. This has
several implications.
- Setting `notices` in config now functions as expected; it will still
not override the command line setting
- If a CDK app is running in a CI environment where it would not be safe
to print notices
- NEW BEHAVIOR: Notices WILL be printed if `notices: true` or `notices:
[truthy value]` is set in config
- Notices WILL be printed if flag `--notices` is passed, and NOT printed
if `--no-notices` / `--notices=false` is passed at the command line (was
already the case)
**Caveat: `"notices": "false"` in the config will suppress notices, but
other "truthy" values will cause them to be printed.**
### Testing
Added unit tests to verify the hierarchy of behavior:
1. Flags in CLI (`--notices` or `--no-notices`)
2. Setting in configuration (`"notices": false` in cdk.json)
3. Print notices if not in CI or in CI where it is safe
---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license
---------
Signed-off-by: github-actions <[email protected]>
Co-authored-by: github-actions <[email protected]>
Copy file name to clipboardExpand all lines: packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/synth/cdk-synth-telemetry-with-errors.integtest.ts
-2Lines changed: 0 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,6 @@ integTest(
32
32
json: false,
33
33
debug: false,
34
34
staging: true,
35
-
notices: true,
36
35
['no-color']: false,
37
36
ci: expect.anything(),// changes based on where this is called
38
37
validation: true,
@@ -81,7 +80,6 @@ integTest(
81
80
json: false,
82
81
debug: false,
83
82
staging: true,
84
-
notices: true,
85
83
['no-color']: false,
86
84
ci: expect.anything(),// changes based on where this is called
Copy file name to clipboardExpand all lines: packages/aws-cdk/lib/cli/cli-config.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ export async function makeConfig(): Promise<CliConfig> {
39
39
'role-arn': {type: 'string',alias: 'r',desc: 'ARN of Role to use when invoking CloudFormation',default: undefined,requiresArg: true},
40
40
'staging': {type: 'boolean',desc: 'Copy assets to the output directory (use --no-staging to disable the copy of assets which allows local debugging via the SAM CLI to reference the original source files)',default: true},
41
41
'output': {type: 'string',alias: 'o',desc: 'Emits the synthesized cloud assembly into a directory (default: cdk.out)',requiresArg: true},
'no-color': {type: 'boolean',desc: 'Removes colors and other style from console output',default: false},
44
44
'ci': {type: 'boolean',desc: 'Force CI detection. If CI=true then logs will be sent to stdout instead of stderr',default: YARGS_HELPERS.isCI()},
45
45
'unstable': {type: 'array',desc: 'Opt in to unstable features. The flag indicates that the scope and API of a feature might still change. Otherwise the feature is generally production ready and fully supported. Can be specified multiple times.',default: []},
0 commit comments