Skip to content

Commit daaedb6

Browse files
authored
fix: add cdk error mapping for error 'command cdk not found' (#2294)
* fix: add cdk error mapping for error 'command cdk not found' * PR Updates
1 parent 5cbe318 commit daaedb6

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

.changeset/rude-moles-attack.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/backend-deployer': patch
3+
---
4+
5+
add cdk error mapping for error "cdk command not found"

packages/backend-deployer/src/cdk_error_mapper.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,12 @@ const testErrorMappings = [
374374
expectedDownstreamErrorMessage: `This CDK CLI is not compatible with the CDK library used by your application. Please upgrade the CLI to the latest version.
375375
(Cloud assembly schema version mismatch: Maximum schema version supported is 36.0.0, but found 36.1.1)`,
376376
},
377+
{
378+
errorMessage: `error Command cdk not found. Did you mean cdl?`,
379+
expectedTopLevelErrorMessage: 'Unable to detect cdk installation',
380+
errorName: 'CDKNotFoundError',
381+
expectedDownstreamErrorMessage: `error Command cdk not found. Did you mean cdl?`,
382+
},
377383
{
378384
errorMessage: `[31m amplify-some-stack failed: ValidationError: Stack:stack-arn is in UPDATE_ROLLBACK_FAILED state and can not be updated.`,
379385
expectedTopLevelErrorMessage:

packages/backend-deployer/src/cdk_error_mapper.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ export class CdkErrorMapper {
156156
errorName: 'CDKVersionMismatchError',
157157
classification: 'ERROR',
158158
},
159+
{
160+
errorRegex: /Command cdk not found/,
161+
humanReadableErrorMessage: 'Unable to detect cdk installation',
162+
resolutionMessage:
163+
"Ensure dependencies in your project are installed with your package manager. For example, by running 'yarn install' or 'npm install'",
164+
errorName: 'CDKNotFoundError',
165+
classification: 'ERROR',
166+
},
159167
{
160168
errorRegex: new RegExp(
161169
`(SyntaxError|ReferenceError|TypeError)( \\[[A-Z_]+])?:((?:.|${this.multiLineEolRegex})*?at .*)`
@@ -468,6 +476,7 @@ export type CDKDeploymentError =
468476
| 'BootstrapDetectionError'
469477
| 'BootstrapOutdatedError'
470478
| 'CDKAssetPublishError'
479+
| 'CDKNotFoundError'
471480
| 'CDKResolveAWSAccountError'
472481
| 'CDKVersionMismatchError'
473482
| 'CFNUpdateNotSupportedError'

0 commit comments

Comments
 (0)