From fa16f7a9c11981da75e44ffc83adcdc6edad94fc Mon Sep 17 00:00:00 2001 From: Christopher Rybicki Date: Sun, 27 Feb 2022 18:56:46 -0800 Subject: [PATCH] fix(cli): cdk version displays notices (#19181) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/aws/aws-cdk/issues/19179 + + + If you don’t want to see a notice anymore, use "cdk acknowledge ". 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* --- packages/aws-cdk/lib/cli.ts | 2 +- packages/aws-cdk/test/integ/cli/cli.integtest.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/lib/cli.ts b/packages/aws-cdk/lib/cli.ts index 3552ac10b2a42..f63c60ca5ced0 100644 --- a/packages/aws-cdk/lib/cli.ts +++ b/packages/aws-cdk/lib/cli.ts @@ -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') ?? [], diff --git a/packages/aws-cdk/test/integ/cli/cli.integtest.ts b/packages/aws-cdk/test/integ/cli/cli.integtest.ts index 658bb7d355120..a0deaf1b3c3bc 100644 --- a/packages/aws-cdk/test/integ/cli/cli.integtest.ts +++ b/packages/aws-cdk/test/integ/cli/cli.integtest.ts @@ -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 });