feat: add npm template support#118
Merged
chenjiahan merged 2 commits intorstackjs:mainfrom Apr 29, 2026
Merged
Conversation
chenjiahan
reviewed
Apr 1, 2026
Member
|
Cloud you resolve the conflicts and fix the CI? |
Add support for using npm packages as templates when creating new projects. This feature allows users to specify custom templates from npm registry with optional version control. - Support multiple npm template formats (npm:, @scope/package, package-name) - Add --template-version flag for version specification - Implement smart caching mechanism (.temp-templates/) - Support flexible template structures (template/, templates/app/, root) - Export utility functions for downstream projects
ae8312c to
dc97f47
Compare
Contributor
Author
|
Rebased onto latest main and resolved conflicts. The branch was rewritten to cleanly apply the npm template feature on top of current main (including the skill selection from #117). Changes:
|
Contributor
Author
|
@chenjiahan Conflicts resolved and CI should be fixed now. Ready for re-review! |
Member
|
@codex code review |
chenjiahan
reviewed
Apr 28, 2026
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc97f4701e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Fix P1 command injection: replace execSync with execFileSync + args array, add input validation for package names and version specifiers - Fix P2 stale cache: clear templateDir contents before re-copying to prevent leftover files from older template versions - Fix concurrent install races: isolate npm install per cache key (.install subdirectory) instead of shared installRoot - Include npm stderr (first 5 lines) in error messages for easier debugging of install failures - Move template-manager import above executable statements - Extract logNextStepsAndOutro helper to remove duplicated code - Add template-manager unit tests covering validation, cache reuse, cache bypass for latest, and resolveCustomTemplate routing
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for using npm packages as templates when creating new projects. This feature allows users to specify custom templates from npm registry with optional version control.
Key Features
npm:,@scope/package,package-name)--template-versionflag for version specification.temp-templates/)template/,templates/app/, root)Usage Examples
Implementation Details
Template Package Structure
The npm template package should have one of the following structures:
Caching Strategy
latestversion are always re-installed to ensure the latest version.temp-templates/for faster reuseAPI Exports
Testing
This feature has been successfully integrated and tested in:
Related
Inspired by sparkling's npm template implementation.
Checklist