Commit 0e3c352
fix(create): show helpful error for unknown vite: templates (#1130)
### Linked issue
<!-- resolves # -->
resolves #1128
### Description
When an unknown template with a vite: prefix (e.g., vite:test) was
specified in the vp create command, the CLI would crash with an
unhandled ENOENT error instead of displaying a user-friendly error
message.
This happened because the vite:application command is rewritten to
create-vite@latest before being passed to subsequent logic.
Consequently, any vite:* command remaining at the fall-through stage is
inevitably an unknown command. By detecting this and implementing an
early return, we have prevented both the crash and the confusing error
message.
Additionally, this fix adds protection to the setPackageName call by
checking the exit code. This prevents the function from attempting to
read package.json from a directory that was never created.
### Manual Verification Results
Specifying an unknown template -> An error message is displayed
```bash
❯ vp create vite:test
Using default package name: remaining-very
"vite:test" is an unknown built-in template. Run vp create --list to see available templates.
```
Specifying an existing template -> Completes successfully (no
regression)
```bash
❯ vp create vite:library
VITE+ - Integrated toolchain for the web
◇ Package name:
receive-weigh
◇ Select package manager to use:
pnpm
...
◇ Finished scaffolding receive-weigh as a TypeScript library
• Node 24.14.0 pnpm 10.33.0
✓ Dependencies installed successfully (4.1s)
→ Next steps: cd receive-weigh && vp run dev
```
---------
Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>1 parent c09c5a9 commit 0e3c352
File tree
2 files changed
+85
-0
lines changed- packages/cli/src/create
- __tests__
- templates
2 files changed
+85
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
5 | 8 | | |
6 | 9 | | |
| |||
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
49 | 65 | | |
50 | 66 | | |
51 | 67 | | |
| |||
54 | 70 | | |
55 | 71 | | |
56 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
57 | 76 | | |
58 | 77 | | |
59 | 78 | | |
| |||
0 commit comments