-
-
Notifications
You must be signed in to change notification settings - Fork 342
feat: enable private GitHub/GitLab repository templates (#1157) #1765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: enable private GitHub/GitLab repository templates (#1157) #1765
Conversation
|
WalkthroughAdds support for templates sourced from Git specifiers by detecting git-style template identifiers, bypassing local cache for git templates, adding tests and mocks, and documenting usage for private Git repositories. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What reviewer looks at during PR reviewThe following are ideal points maintainers look for during review. Reviewing these points yourself beforehand can help streamline the review process and reduce time to merge.
|
|
🚀 Docs preview deployed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/generator/lib/utils.js (1)
107-141: Add support forgit://protocol andbitbucket:shorthand in git specifier detection.npm supports git:// protocol (e.g., git://host/user/repo.git#commit-ish) and host shorthands like bitbucket:user/repo. The current implementation is missing these formats. Consider adding checks for
git://andbitbucket:prefixes to ensure complete coverage of npm-supported git specifiers.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
apps/generator/docs/using-private-template.md(1 hunks)apps/generator/lib/__mocks__/utils.js(1 hunks)apps/generator/lib/generator.js(4 hunks)apps/generator/lib/utils.js(1 hunks)apps/generator/test/__mocks__/requireg.js(1 hunks)apps/generator/test/generator.test.js(1 hunks)apps/generator/test/utils.test.js(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
apps/generator/test/generator.test.js (5)
apps/generator/lib/generator.js (2)
log(7-7)logMessage(51-51)apps/generator/lib/utils.js (3)
log(9-9)utils(15-15)logMessage(13-13)apps/generator/test/utils.test.js (4)
log(4-4)utils(5-5)Generator(3-3)logMessage(7-7)apps/generator/test/__mocks__/loglevel.js (1)
log(1-1)apps/generator/lib/__mocks__/utils.js (1)
utils(1-1)
apps/generator/lib/utils.js (2)
apps/generator/lib/__mocks__/utils.js (2)
utils(1-1)trimmed(31-31)apps/generator/test/utils.test.js (1)
utils(5-5)
apps/generator/lib/__mocks__/utils.js (2)
apps/generator/lib/utils.js (2)
utils(15-15)trimmed(123-123)apps/generator/test/utils.test.js (1)
utils(5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Test generator as dependency with Node 20
- GitHub Check: Test generator as dependency with Node 18
- GitHub Check: Acceptance tests for generated templates
- GitHub Check: Test NodeJS PR - macos-latest
- GitHub Check: Test NodeJS PR - windows-latest
- GitHub Check: preview
🔇 Additional comments (6)
apps/generator/docs/using-private-template.md (1)
42-80: LGTM! Clear documentation for Git-based templates.The new section provides clear guidance on using templates from private Git repositories. The examples cover common git specifier formats, and the authentication guidance appropriately delegates to system git configuration.
apps/generator/test/__mocks__/requireg.js (1)
1-10: LGTM! Mock is correctly implemented.The mock returns a string containing 'index.js' to support the string replacement in generator.js line 11. The implementation is simple and appropriate for test purposes.
apps/generator/test/generator.test.js (1)
431-451: LGTM! Test correctly validates git specifier flow.The test appropriately validates that git specifiers trigger installation from disk and log the expected git-specific message. The TODO comment acknowledges the known Arborist reification testing limitation.
apps/generator/lib/generator.js (2)
574-603: LGTM! Git specifier handling is correctly implemented.The changes appropriately:
- Detect git specifiers using the new utility function
- Bypass local cache lookup for git-based templates (line 576)
- Provide clear debug logging for git template installation
The logic ensures git URLs are always fetched fresh, which is the correct behavior since they can't be resolved through the existing local cache mechanism.
1121-1121: Verify whether this export is intentional.This line exports
listBakedInTemplates, which doesn't appear to be directly related to the git specifier feature. Please confirm whether this export was intentionally included in this PR or should be part of a separate change.apps/generator/lib/__mocks__/utils.js (1)
25-43: LGTM! Mock implementation provides test flexibility.The mock implementation duplicates the production logic while providing an override mechanism via
__isGitSpecifierValue. This duplication is acceptable for test mocks and ensures consistent behavior during testing. The override flag allows tests to control the return value when needed.Note that changes to the production
isGitSpecifierfunction should be synchronized with this mock implementation.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/generator/lib/__mocks__/utils.js (1)
25-43: Consider reducing duplication between mock and real implementation.The mock includes a fallback implementation (lines 30-42) that duplicates the git specifier detection logic from the real
utils.jsmodule. While this pattern is consistent with other mocks in this file and allows tests to work without always setting override values, it does create a maintenance burden—if the real implementation evolves, the mock must be kept in sync.For future consideration, you could:
- Simplify the mock to rely primarily on
__isGitSpecifierValueoverrides in tests, OR- Import and delegate to the real implementation when
__isGitSpecifierValueis false (though Jest mocking may complicate this)Given the established pattern in this codebase and the relatively stable nature of git specifier detection, this approach is acceptable for now.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/generator/docs/using-private-template.md(1 hunks)apps/generator/lib/__mocks__/utils.js(1 hunks)apps/generator/lib/utils.js(1 hunks)apps/generator/test/utils.test.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- apps/generator/test/utils.test.js
- apps/generator/lib/utils.js
- apps/generator/docs/using-private-template.md
🧰 Additional context used
🧬 Code graph analysis (1)
apps/generator/lib/__mocks__/utils.js (2)
apps/generator/lib/utils.js (2)
utils(15-15)trimmed(123-123)apps/generator/test/utils.test.js (1)
utils(5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Test generator as dependency with Node 20
- GitHub Check: Test generator as dependency with Node 18
- GitHub Check: Acceptance tests for generated templates
- GitHub Check: Test NodeJS PR - windows-latest
- GitHub Check: Test NodeJS PR - macos-latest
- GitHub Check: Test NodeJS PR - ubuntu-latest
- GitHub Check: preview
|
adding it to draft as unplanned |



Description
This PR adds support for using AsyncAPI templates from private GitHub and GitLab repositories, resolving a long-standing feature request.
Changes
isGitSpecifier()helper to detect git-based template URLsinstallTemplate()to skip cache lookup for git specs and delegate authentication to system git configurationHow it works
The implementation leverages npm's Arborist (already used for template installation), which natively supports git URLs. Authentication is handled by the system's existing git configuration (SSH keys, HTTPS tokens,
.netrc).Supported formats:
git+ssh://[email protected]/org/repo.gitgit+https://github.com/org/repo.git[email protected]:org/repo.gitgithub:org/repogitlab:org/repoUsage
CLI:
Library:
Demo
demo-private-git-compressed.mp4
Testing
Related issue(s)
Resolves #1157
Summary by CodeRabbit
New Features
Documentation
Tests