Skip to content

feat: add local template support with --from-path option#763

Merged
iankhou merged 36 commits intomainfrom
feat/local-template-support
Aug 26, 2025
Merged

feat: add local template support with --from-path option#763
iankhou merged 36 commits intomainfrom
feat/local-template-support

Conversation

@rohang9000
Copy link
Copy Markdown
Contributor

This PR adds local template support through the new --from-path CLI option. Users can initialize CDK projects from local custom templates, copying the template as is without placeholder processing.

The feature includes language auto-detection when templates contain a single language option and error handling for invalid paths. 3 new test cases covering basic local template functionality, language auto-detection, and error handling scenarios were added.

Fixes #


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions Bot added the p2 label Aug 4, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team August 4, 2025 05:03
Copy link
Copy Markdown
Contributor

@iankhou iankhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments about code efficiency and validations.

Also, about option exclusivity for the --from-path option.

Comment thread packages/aws-cdk/lib/commands/init/init.ts
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/cli/cli.ts
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Aug 7, 2025

Codecov Report

❌ Patch coverage is 75.93819% with 109 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.60%. Comparing base (5128946) to head (33dee82).
⚠️ Report is 269 commits behind head on main.

Files with missing lines Patch % Lines
packages/aws-cdk/lib/commands/init/init.ts 76.74% 98 Missing and 5 partials ⚠️
packages/aws-cdk/lib/cli/cli.ts 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #763      +/-   ##
==========================================
+ Coverage   80.88%   82.60%   +1.72%     
==========================================
  Files          63       64       +1     
  Lines        8599     9465     +866     
  Branches     1028     1107      +79     
==========================================
+ Hits         6955     7819     +864     
+ Misses       1614     1612       -2     
- Partials       30       34       +4     
Flag Coverage Δ
suite.unit 82.60% <75.93%> (+1.72%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@iankhou iankhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's handle flag conflicts at yargs, more details in comments. Some questions about error-handling, other minor corrections.

Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/cli/cli.ts
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/cli/user-input.ts
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
@rohang9000 rohang9000 force-pushed the feat/local-template-support branch from c882bc2 to 54e20f1 Compare August 8, 2025 19:23
Copy link
Copy Markdown
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't want to step on @iankhou's toes on the review but here are some thoughts, mostly surrounding non-essential portions.

Comment thread packages/aws-cdk/lib/commands/init/init.ts
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/cli/user-input.ts
Comment thread packages/aws-cdk/lib/cli/cli-config.ts Outdated
Comment thread packages/aws-cdk/test/commands/init.test.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts Outdated
Comment thread packages/aws-cdk/lib/commands/init/init.ts
Signed-off-by: github-actions <[email protected]>
@rohang9000 rohang9000 marked this pull request as ready for review August 11, 2025 14:42
…guage specified, and fixed post-install for CDK languages
Signed-off-by: github-actions <[email protected]>
Copy link
Copy Markdown
Contributor

@iankhou iankhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a test for cdk init --language=[language], since we are adjusting logic surrounding that behavior.

ex. Currently, when I run cdk init --language=typescript, I get an initialization of the typescript CDK app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants