Skip to content

Commit

Permalink
fix(project generator): Add join and CfnInclude imports only when…
Browse files Browse the repository at this point in the history
… needed
  • Loading branch information
akash1810 committed Oct 5, 2023
1 parent 16404a7 commit d43919a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/bin/commands/new-project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const newCdkProject = async (props: NewProjectProps): CliCommandResponse

// lib directory
await constructStack({
imports: Imports.newStackImports(),
imports: Imports.newStackImports(!!config.yamlTemplateLocation),
appName: config.appName,
outputFile: basename(config.stackPath),
outputDir: dirname(config.stackPath),
Expand Down
20 changes: 11 additions & 9 deletions src/bin/commands/new-project/utils/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ export class Imports {
this.imports = imports;
}

public static newStackImports(): Imports {
public static newStackImports(addCfnIncludeImports: boolean): Imports {
return new Imports({
path: {
types: [],
components: ["join"],
},
"aws-cdk-lib/cloudformation-include": {
types: [],
components: ["CfnInclude"],
},
...(addCfnIncludeImports && {
path: {
types: [],
components: ["join"],
},
"aws-cdk-lib/cloudformation-include": {
types: [],
components: ["CfnInclude"],
},
}),
"aws-cdk-lib": {
types: ["App"],
components: [],
Expand Down

0 comments on commit d43919a

Please sign in to comment.