Commit d84c313
committed
feat: add npm template support
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:
- 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)
- Isolated installation to prevent workspace conflicts
- Export utility functions for downstream projects
Example usage:
npm create rsbuild@latest my-project -- --template my-template
npm create rsbuild@latest my-project -- --template @scope/template
npm create rsbuild@latest my-project -- --template my-template --template-version 1.2.3
API exports:
- isNpmTemplate()
- resolveCustomTemplate()
- resolveNpmTemplate()
- sanitizeCacheKey()
Inspired by sparkling's npm template implementation.1 parent 6069f60 commit d84c313
3 files changed
Lines changed: 282 additions & 184 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
20 | 79 | | |
21 | 80 | | |
22 | 81 | | |
| |||
0 commit comments