Skip to content

Conversation

rohang9000
Copy link
Contributor

Updated code for cdk init command to handle custom templates from Git repository sources. This is compatible with the existing --language and --template-path flags. The --from-git-url flag was added to clone a Git URL that is passed in by the user, clones the repository, extracts the specified template files and initializes new project with them. The cdk init functionality of creating new local Git repo to track changes, making initial commit, and installing project dependencies is maintained.

Fixes #


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

rohang9000 and others added 30 commits August 4, 2025 00:47
Signed-off-by: github-actions <[email protected]>
Signed-off-by: github-actions <[email protected]>
…positories that users can select templates from using --template-path param
Signed-off-by: github-actions <[email protected]>
Signed-off-by: github-actions <[email protected]>
Signed-off-by: github-actions <[email protected]>
Signed-off-by: github-actions <[email protected]>
Signed-off-by: github-actions <[email protected]>
Signed-off-by: github-actions <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Aug 28, 2025

Codecov Report

❌ Patch coverage is 46.31579% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.93%. Comparing base (5fc1b13) to head (3c79410).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/aws-cdk/lib/commands/init/init.ts 47.31% 48 Missing and 1 partial ⚠️
packages/aws-cdk/lib/cli/cli.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #820      +/-   ##
==========================================
- Coverage   82.60%   80.93%   -1.68%     
==========================================
  Files          64       64              
  Lines        9465     9075     -390     
  Branches     1106     1108       +2     
==========================================
- Hits         7819     7345     -474     
- Misses       1612     1698      +86     
+ Partials       34       32       -2     
Flag Coverage Δ
suite.unit 80.93% <46.31%> (-1.68%) ⬇️

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
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.

Probably will need to wait until #819 is merged.

'template-path': { type: 'string', desc: 'Path to a specific template within a multi-template repository', requiresArg: true },
},
implies: { 'template-path': 'from-path' },
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be replaced by a check that ensures that from-path or from-git-url was also used.

@@ -84,16 +91,27 @@ export async function cliInit(options: CliInitOptions) {
const generateOnly = options.generateOnly ?? false;
const workDir = options.workDir ?? process.cwd();

// Validate that if template-path is provided, exactly one custom template source must be provided
if (options.templatePath && !options.fromPath && !options.fromGitUrl) {
throw new ToolkitError('--template-path can only be used with --from-path or --from-git-url');
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use a check in yargs instead? In general, try to catch problems as early as you can.

@rohang9000 rohang9000 force-pushed the feat/git-repository-support-for-custom-templates branch from 9b3ea2d to 5437650 Compare August 29, 2025 19:34
Signed-off-by: github-actions <[email protected]>
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.

4 participants