Skip to content

Commit

Permalink
fix(cli): cdk version displays notices (#19181)
Browse files Browse the repository at this point in the history
One of our integration tests started failing after a [notice](https://github.com/aws/aws-cdk-rfcs/blob/master/text/0308-cli-advisories.md) was added because `cdk version` displayed information besides the actual CLI version:

```
 ● Two ways of shoing the version

    expect(received).toEqual(expected) // deep equality

    - Expected  -  0
    + Received  + 14

      2.14.0 (build 762d71b)
    +
    + NOTICES
    +
    + 19179 (aws-eks): Regression in installing Helm charts from assets
    +
    +   Overview: Helm charts fail to install when provided as an asset. This
    +             issue does not affect charts installed from a repository.
    +
    +   Affected versions: framework: 2.14.0, framework: 1.146.0
    +
    +   More information at: #19179
    +
    +
    + If you don’t want to see a notice anymore, use "cdk acknowledge <id>". For example, "cdk acknowledge 19179".

      at cli.integtest.ts:39:20
      at ../helpers/cdk.ts:130:7
      at ResourcePool.using (../helpers/resource-pool.ts:44:14)
      at ../helpers/test-helpers.ts:30:14
```

This fixes that bug.

Another option we could consider here is to keep the current behavior (where `cdk version` and `cdk --version` display different output) and just update the test case, but I think keeping them the same is probably simpler for customers.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
Chriscbr authored Feb 28, 2022
1 parent a6b0a10 commit fa16f7a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ async function initCommandLine() {
acknowledgedIssueNumbers: [],
ignoreCache: true,
});
} else {
} else if (cmd !== 'version') {
await displayNotices({
outdir: configuration.settings.get(['output']) ?? 'cdk.out',
acknowledgedIssueNumbers: configuration.context.get('acknowledged-issue-numbers') ?? [],
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/test/integ/cli/cli.integtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ integTest('Construct with builtin Lambda function', withDefaultFixture(async (fi
await fixture.cdkDestroy('builtin-lambda-function');
}));

integTest('Two ways of shoing the version', withDefaultFixture(async (fixture) => {
integTest('Two ways of showing the version', withDefaultFixture(async (fixture) => {
const version1 = await fixture.cdk(['version'], { verbose: false });
const version2 = await fixture.cdk(['--version'], { verbose: false });

Expand Down

0 comments on commit fa16f7a

Please sign in to comment.