Skip to content

Conversation

@rohang9000
Copy link
Contributor

@rohang9000 rohang9000 commented Aug 28, 2025

Rohan:

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.

Added additional tests and implemented changes I had requested. There were 40 commits before, and many merge conflicts from #819.

Unit test coverage for init.ts is now 97.65%. Tested by hand for many cases as well.


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

@codecov-commenter
Copy link

codecov-commenter commented Aug 28, 2025

Codecov Report

❌ Patch coverage is 93.46405% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.88%. Comparing base (e46adaf) to head (657aaf0).

Files with missing lines Patch % Lines
packages/aws-cdk/lib/commands/init/init.ts 93.79% 8 Missing ⚠️
packages/aws-cdk/lib/cli/cli.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #820      +/-   ##
==========================================
+ Coverage   82.76%   82.88%   +0.12%     
==========================================
  Files          71       71              
  Lines       10396    10519     +123     
  Branches     1295     1320      +25     
==========================================
+ Hits         8604     8719     +115     
- Misses       1753     1762       +9     
+ Partials       39       38       -1     
Flag Coverage Δ
suite.unit 82.88% <93.46%> (+0.12%) ⬆️

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.

'from-git-url': { type: 'string', desc: 'Git repository URL to clone custom template from', requiresArg: true, conflicts: ['lib-version', 'from-path'] },
'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.


// 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
@iankhou iankhou force-pushed the feat/git-repository-support-for-custom-templates branch from 3c79410 to 0a7ce7b Compare October 9, 2025 21:25
@iankhou iankhou changed the title feat(cli): add git repository support for custom init templates feat(cli): git repository support for custom init templates Oct 9, 2025
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