Skip to content

Commit

Permalink
chore: upgrade cdk-from-cfn dependency to 0.157.0 (#29967)
Browse files Browse the repository at this point in the history
### Reason for this change

The latest version of `cdk-from-cfn` is 0.157.0 which has introduced improved error types and error messages. As a result, I am manually bumping the version so that I can fix the unit tests that were testing the old error messages.

### Description of changes

Bumped `cdk-from-cfn` to 0.157.0, updated our error handling, and fixed broken unit tests.

### Description of how you validated changes

Fixed broken unit tests and ensured that no existing unit tests are failing.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
colifran committed Apr 29, 2024
1 parent c949076 commit 86c1320
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 41 deletions.
2 changes: 1 addition & 1 deletion packages/aws-cdk/THIRD_PARTY_LICENSES
Expand Up @@ -484,7 +484,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

----------------

** cdk-from-cfn@0.156.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.156.0 | MIT OR Apache-2.0
** cdk-from-cfn@0.157.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.157.0 | MIT OR Apache-2.0

----------------

Expand Down
5 changes: 1 addition & 4 deletions packages/aws-cdk/lib/commands/migrate.ts
Expand Up @@ -86,10 +86,7 @@ export function generateStack(template: string, stackName: string, language: str
try {
return cdk_from_cfn.transmute(template, language, formattedStackName);
} catch (e) {
const errorMessage = (e as Error).message === 'unreachable'
? 'template and/or language inputs caused the source code to panic'
: (e as Error).message.replace('TransmuteError: ', '');
throw new Error(`${formattedStackName} could not be generated because ${errorMessage}`);
throw new Error(`${formattedStackName} could not be generated because ${(e as Error).message}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/package.json
Expand Up @@ -105,7 +105,7 @@
"aws-sdk": "^2.1600.0",
"camelcase": "^6.3.0",
"cdk-assets": "0.0.0",
"cdk-from-cfn": "^0.156.0",
"cdk-from-cfn": "^0.157.0",
"chalk": "^4",
"chokidar": "^3.6.0",
"decamelize": "^5.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk/test/cdk-toolkit.test.ts
Expand Up @@ -916,8 +916,8 @@ describe('synth', () => {
stackName: 'cannot-generate-template',
fromPath: path.join(__dirname, 'commands', 'test-resources', 'templates', 'sqs-template.json'),
language: 'rust',
})).rejects.toThrowError('CannotGenerateTemplateStack could not be generated because template and/or language inputs caused the source code to panic');
expect(stderrMock.mock.calls[1][0]).toContain(' ❌ Migrate failed for `cannot-generate-template`: CannotGenerateTemplateStack could not be generated because template and/or language inputs caused the source code to panic');
})).rejects.toThrowError('CannotGenerateTemplateStack could not be generated because rust is not a supported language');
expect(stderrMock.mock.calls[1][0]).toContain(' ❌ Migrate failed for `cannot-generate-template`: CannotGenerateTemplateStack could not be generated because rust is not a supported language');
});

cliTest('migrate succeeds for valid template from local path when no lanugage is provided', async (workDir) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/test/commands/migrate.test.ts
Expand Up @@ -134,7 +134,7 @@ describe('Migrate Function Tests', () => {
});

test('generateStack throws error when called for other language', () => {
expect(() => generateStack(validTemplate, 'BadBadBad', 'php')).toThrowError('BadBadBadStack could not be generated because template and/or language inputs caused the source code to panic');
expect(() => generateStack(validTemplate, 'BadBadBad', 'php')).toThrowError('BadBadBadStack could not be generated because php is not a supported language');
});

test('generateStack throws error for invalid resource property', () => {
Expand Down
39 changes: 7 additions & 32 deletions yarn.lock
Expand Up @@ -6884,10 +6884,10 @@ case@1.6.3, case@^1.6.3:
resolved "https://registry.npmjs.org/case/-/case-1.6.3.tgz#0a4386e3e9825351ca2e6216c60467ff5f1ea1c9"
integrity sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ==

cdk-from-cfn@^0.156.0:
version "0.156.0"
resolved "https://registry.npmjs.org/cdk-from-cfn/-/cdk-from-cfn-0.156.0.tgz#921134095983db664bd68556463dcde115d73cdb"
integrity sha512-nYK6SCC4yOPPxkPbrg23d6wTiu6Mtms5dWPI9kymwblpcXfIr+YaoiVlvlT9CFyyddGugG7AaTA6UN7U9LUOAg==
cdk-from-cfn@^0.157.0:
version "0.157.0"
resolved "https://registry.npmjs.org/cdk-from-cfn/-/cdk-from-cfn-0.157.0.tgz#4ff0dcd8f31c52561127c462358d72090ad9178a"
integrity sha512-CQdB41IdhEG6lQx+KDnmttwWntendz0IVJwU8BFBNhT+Ci9hTR9pxxtqzV32Hl4d3uH0XeH/b/V2xcD/sMBP2A==

cdk-generate-synthetic-examples@^0.2.0:
version "0.2.0"
Expand Down Expand Up @@ -14809,16 +14809,7 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@*, string-width@^1.0.1, "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3, string-width@^5.0.1, string-width@^5.1.2:
"string-width-cjs@npm:string-width@^4.2.0", string-width@*, string-width@^1.0.1, "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3, string-width@^5.0.1, string-width@^5.1.2:
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -14896,7 +14887,7 @@ stringify-package@^1.0.1:
resolved "https://registry.npmjs.org/stringify-package/-/stringify-package-1.0.1.tgz#e5aa3643e7f74d0f28628b72f3dad5cecfc3ba85"
integrity sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg==

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -14910,13 +14901,6 @@ strip-ansi@^3.0.1:
dependencies:
ansi-regex "^2.0.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1, strip-ansi@^7.1.0:
version "7.1.0"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -15897,7 +15881,7 @@ workerpool@^6.5.1:
resolved "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544"
integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -15915,15 +15899,6 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 86c1320

Please sign in to comment.