Skip to content

Commit c0a640e

Browse files
fengmk2claude
andcommitted
feat(global): add scaffolding command 'vite new' for project creation
- Add interactive 'vite new' command for creating Vite+ projects - Support both MonoRepo and SingleRepo project types - MonoRepo is the default option (can press Enter to select) - Allow skipping prompts with CLI arguments: 'vite new <name> <type>' - Support flags: --monorepo/-m, --singlerepo/-s for project type - Add --app and --lib flags for adding packages to existing monorepos - Implement Ctrl+C handling for graceful exit during prompts - Copy templates without node_modules directory - Auto-detect monorepo root via pnpm-workspace.yaml or package.json workspaces - Update package.json with actual project/package names Usage examples: vite new # Interactive mode vite new my-project # Prompt for type only vite new my-project monorepo # No prompts vite new my-project --singlerepo # Using flags vite new --app apps/my-app # Add app to monorepo vite new --lib packages/my-lib # Add lib to monorepo 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ed8bc14 commit c0a640e

83 files changed

Lines changed: 1412 additions & 935 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/global/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ Use 1Password CLI:
2828
GITHUB_TOKEN=$(op read "op://YOUR_GITHUB_TOKEN_PATH") npm install -g @voidzero-dev/global
2929
```
3030

31+
## Get Started
32+
33+
### Scaffolding your first Vite+ project
34+
35+
Use the `vite new` command to start, it will ask you a few questions to help you scaffold your project, supports both `MonoRepo` and `SingleRepo`.
36+
37+
```bash
38+
vite new
39+
```
40+
41+
If you select `Monorepo`, you can add new `app` or `lib` to your project.
42+
43+
```bash
44+
vite new --app apps/website
45+
vite new --lib packages/utils
46+
```
47+
3148
## Overview
3249

3350
```bash

packages/global/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"url": "https://github.com/voidzero-dev/vite-plus.git"
88
},
99
"bin": {
10-
"vite": "./bin/vp",
11-
"vite-plus": "./bin/vp",
12-
"vp": "./bin/vp",
13-
"vite-plus-dev": "./bin/vp-dev"
10+
"vite": "./bin/vite",
11+
"vite-plus": "./bin/vite",
12+
"vp": "./bin/vite",
13+
"vite-plus-dev": "./bin/vite-dev"
1414
},
1515
"files": [
1616
"bin",

packages/global/snap-tests/new-monorepo/snap.txt

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
> vite new -h # show help
2+
3+
vite new - Create a new Vite+ project
4+
5+
Usage:
6+
vite new [project-name] [project-type] [options]
7+
vite new --app <path> Add an app to existing monorepo
8+
vite new --lib <path> Add a library to existing monorepo
9+
10+
Arguments:
11+
project-name Name of the project to create
12+
project-type Type of project: monorepo, mono, singlerepo, single
13+
14+
Options:
15+
--monorepo, -m Create a monorepo project
16+
--singlerepo, -s Create a singlerepo project
17+
--app <path> Add an app package to existing monorepo
18+
--lib <path> Add a library package to existing monorepo
19+
--help, -h Show this help message
20+
21+
Examples:
22+
vite new Interactive mode (prompts for all options)
23+
vite new my-project Create project with prompts for type
24+
vite new my-project monorepo Create monorepo without prompts
25+
vite new my-project -s Create singlerepo using flag
26+
vite new --app apps/my-app Add app to current monorepo
27+
vite new --lib packages/utils Add library to current monorepo
28+
29+
Notes:
30+
- MonoRepo is the default when prompted (press Enter to select)
31+
- Press Ctrl+C to exit during prompts
32+
33+
34+
> vite new my-project monorepo # create monorepo
35+
36+
Creating monorepo project: my-project...
37+
✅ Successfully created monorepo project: my-project
38+
39+
Next steps:
40+
cd my-project
41+
vite run ready
42+
vite dev
43+
44+
To add new packages to your monorepo:
45+
vite new --app apps/my-app
46+
vite new --lib packages/my-lib
47+
48+
> cd my-project && git init # avoid oxlint https://github.com/oxc-project/oxc/issues/13793
49+
Initialized empty Git repository in /private<cwd>/my-project/.git/
50+
51+
> cd my-project && vite run ready # run ready task
52+
Cache not found
53+
Scope: all <variable> workspace projects
54+
Progress: resolved 1, reused 0, downloaded 0, added 0
55+
Progress: resolved 105, reused 69, downloaded 0, added 0
56+
 WARN  Skip adding vite to the default catalog because it already exists as npm:@voidzero-dev/vite-plus. Please use `pnpm update` to update the catalogs.
57+
 WARN  Skip adding @voidzero-dev/vite-plus to the default catalog because it already exists as latest. Please use `pnpm update` to update the catalogs.
58+
 WARN  Skip adding vitest to the default catalog because it already exists as beta. Please use `pnpm update` to update the catalogs.
59+
 WARN  Skip adding vite to the default catalog because it already exists as npm:@voidzero-dev/vite-plus. Please use `pnpm update` to update the catalogs.
60+
Packages: +<variable>
61+
+<repeat>
62+
Progress: resolved <variable>, reused <variable>, downloaded <variable>, added <variable>, done
63+
64+
devDependencies:
65+
+ @voidzero-dev/vite-plus <semver>
66+
+ vitest <semver>
67+
68+
╭ Warning ─────────────────────────────────────────────────────────────────────╮
69+
│ │
70+
│ Ignored build scripts: esbuild. │
71+
│ Run "pnpm approve-builds" to pick which dependencies should be allowed │
72+
│ to run scripts. │
73+
│ │
74+
╰──────────────────────────────────────────────────────────────────────────────╯
75+
76+
Done in <variable>ms using pnpm v<semver>
77+
Cache not found
78+
Cache not found
79+
Cache not found
80+
Cache not found
81+
Cache not found
82+
Cache not found
83+
Cache not found
84+
Cache not found
85+
Cache not found
86+
rolldown-vite v<semver> building for production...
87+
transforming...✓ 7 modules transformed.
88+
rendering chunks...
89+
computing gzip size...
90+
dist/index.html 0.45 kB │ gzip: 0.29 kB
91+
dist/assets/index-BAKMvvYC.css 1.37 kB │ gzip: 0.65 kB
92+
dist/assets/index-vM1AmoRk.js 3.04 kB │ gzip: 1.64 kB
93+
✓ built in <variable>ms
94+
95+
> cd my-project && vite new --app apps/my-app # add app
96+
Creating new app at apps/my-app...
97+
✅ Successfully created app at apps/my-app
98+
99+
Next steps:
100+
cd apps/my-app
101+
vite run ready
102+
vite dev
103+
104+
> cd my-project && vite new --lib packages/my-lib # add lib
105+
Creating new library at packages/my-lib...
106+
✅ Successfully created library at packages/my-lib
107+
108+
Next steps:
109+
cd packages/my-lib
110+
vite run ready
111+
112+
> cd my-project && vite run ready # run ready task after add app and lib
113+
Cache miss: apps content changed
114+
Scope: all <variable> workspace projects
115+
Progress: resolved 1, reused 0, downloaded 0, added 0
116+
Progress: resolved 120, reused 61, downloaded 0, added 0
117+
 WARN  Skip adding typescript to the default catalog because it already exists as ^5.9.2. Please use `pnpm update` to update the catalogs.
118+
 WARN  Skip adding vite to the default catalog because it already exists as npm:@voidzero-dev/vite-plus. Please use `pnpm update` to update the catalogs.
119+
 WARN  Skip adding typescript to the default catalog because it already exists as ^5.9.2. Please use `pnpm update` to update the catalogs.
120+
 WARN  Skip adding vite to the default catalog because it already exists as npm:@voidzero-dev/vite-plus. Please use `pnpm update` to update the catalogs.
121+
 WARN  Skip adding @voidzero-dev/vite-plus to the default catalog because it already exists as latest. Please use `pnpm update` to update the catalogs.
122+
 WARN  Skip adding vitest to the default catalog because it already exists as beta. Please use `pnpm update` to update the catalogs.
123+
 WARN  Skip adding vite to the default catalog because it already exists as npm:@voidzero-dev/vite-plus. Please use `pnpm update` to update the catalogs.
124+
Already up to date
125+
Progress: resolved <variable>, reused <variable>, downloaded <variable>, added <variable>, done
126+
127+
Done in <variable>ms using pnpm v<semver>
128+
Cache not found
129+
Cache not found
130+
Cache not found
131+
Cache not found
132+
Cache not found
133+
Cache not found
134+
Cache not found
135+
Cache not found
136+
Cache not found
137+
rolldown-vite v<semver> building for production...
138+
transforming...✓ 7 modules transformed.
139+
rendering chunks...
140+
computing gzip size...
141+
dist/index.html 0.45 kB │ gzip: 0.29 kB
142+
dist/assets/index-BAKMvvYC.css 1.37 kB │ gzip: 0.65 kB
143+
dist/assets/index-vM1AmoRk.js 3.04 kB │ gzip: 1.64 kB
144+
✓ built in <variable>ms
145+
Cache not found
146+
Cache hit, replaying
147+
rolldown-vite v<semver> building for production...
148+
transforming...✓ 7 modules transformed.
149+
rendering chunks...
150+
computing gzip size...
151+
dist/index.html 0.45 kB │ gzip: 0.29 kB
152+
dist/assets/index-BAKMvvYC.css 1.37 kB │ gzip: 0.65 kB
153+
dist/assets/index-vM1AmoRk.js 3.04 kB │ gzip: 1.64 kB
154+
✓ built in <variable>ms
155+
156+
> cd my-project && vite new --lib tools/my-tool # add lib new not exists tools directory
157+
Creating new library at tools/my-tool...
158+
✅ Successfully created library at tools/my-tool
159+
160+
Next steps:
161+
cd tools/my-tool
162+
vite run ready
163+
164+
> cd my-project && vite run ready # run ready task after add lib
165+
Cache miss: apps/my-app content changed
166+
Scope: all <variable> workspace projects
167+
Lockfile is up to date, resolution step is skipped
168+
Already up to date
169+
170+
Done in <variable>ms using pnpm v<semver>
171+
Cache not found
172+
Cache not found
173+
Cache not found
174+
Cache not found
175+
Cache not found
176+
Cache not found
177+
Cache not found
178+
Cache not found
179+
Cache hit, replaying
180+
rolldown-vite v<semver> building for production...
181+
transforming...✓ 7 modules transformed.
182+
rendering chunks...
183+
computing gzip size...
184+
dist/index.html 0.45 kB │ gzip: 0.29 kB
185+
dist/assets/index-BAKMvvYC.css 1.37 kB │ gzip: 0.65 kB
186+
dist/assets/index-vM1AmoRk.js 3.04 kB │ gzip: 1.64 kB
187+
✓ built in <variable>ms
188+
Cache not found
189+
Cache hit, replaying
190+
rolldown-vite v<semver> building for production...
191+
transforming...✓ 7 modules transformed.
192+
rendering chunks...
193+
computing gzip size...
194+
dist/index.html 0.45 kB │ gzip: 0.29 kB
195+
dist/assets/index-BAKMvvYC.css 1.37 kB │ gzip: 0.65 kB
196+
dist/assets/index-vM1AmoRk.js 3.04 kB │ gzip: 1.64 kB
197+
✓ built in <variable>ms
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"commands": [
3+
"vite new -h # show help",
4+
"vite new my-project monorepo # create monorepo",
5+
"cd my-project && git init # avoid oxlint https://github.com/oxc-project/oxc/issues/13793",
6+
"cd my-project && vite run ready # run ready task",
7+
"cd my-project && vite new --app apps/my-app # add app",
8+
"cd my-project && vite new --lib packages/my-lib # add lib",
9+
"cd my-project && vite run ready # run ready task after add app and lib",
10+
"cd my-project && vite new --lib tools/my-tool # add lib new not exists tools directory",
11+
"cd my-project && vite run ready # run ready task after add lib"
12+
]
13+
}

packages/global/snap-tests/new-singlerepo/snap.txt

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
> vite new my-project singlerepo # create singlerepo
2+
3+
Creating singlerepo project: my-project...
4+
✅ Successfully created singlerepo project: my-project
5+
6+
Next steps:
7+
cd my-project
8+
vite run ready
9+
vite dev
10+
11+
> cd my-project && vite run ready # run ready task
12+
Non-interactive environment detected. Using default package manager: pnpm
13+
Cache not found
14+
Progress: resolved 1, reused 0, downloaded 0, added 0
15+
Progress: resolved 82, reused 46, downloaded 0, added 0
16+
Packages: +<variable>
17+
+<repeat>
18+
Progress: resolved <variable>, reused <variable>, downloaded <variable>, added <variable>, done
19+
20+
dependencies:
21+
+ vite <- @voidzero-dev/vite-plus <semver>
22+
23+
devDependencies:
24+
+ typescript <semver>
25+
26+
╭ Warning ─────────────────────────────────────────────────────────────────────╮
27+
│ │
28+
│ Ignored build scripts: esbuild. │
29+
│ Run "pnpm approve-builds" to pick which dependencies should be allowed │
30+
│ to run scripts. │
31+
│ │
32+
╰──────────────────────────────────────────────────────────────────────────────╯
33+
34+
Done in <variable>ms using pnpm v<semver>
35+
Cache not found
36+
Cache not found
37+
Cache not found
38+
Cache not found
39+
rolldown-vite v<semver> building for production...
40+
transforming...✓ 7 modules transformed.
41+
rendering chunks...
42+
computing gzip size...
43+
dist/index.html 0.45 kB │ gzip: 0.29 kB
44+
dist/assets/index-BAKMvvYC.css 1.37 kB │ gzip: 0.65 kB
45+
dist/assets/index-BJ8qKvJC.js 3.04 kB │ gzip: 1.64 kB
46+
✓ built in <variable>ms
47+
48+
> cd my-project && vite run ready # run ready task second time to check cache
49+
Cache miss: content changed
50+
Lockfile is up to date, resolution step is skipped
51+
Already up to date
52+
53+
╭ Warning ─────────────────────────────────────────────────────────────────────╮
54+
│ │
55+
│ Ignored build scripts: esbuild. │
56+
│ Run "pnpm approve-builds" to pick which dependencies should be allowed │
57+
│ to run scripts. │
58+
│ │
59+
╰──────────────────────────────────────────────────────────────────────────────╯
60+
61+
Done in <variable>ms using pnpm v<semver>
62+
Cache not found
63+
Cache not found
64+
Cache not found
65+
Cache hit, replaying
66+
rolldown-vite v<semver> building for production...
67+
transforming...✓ 7 modules transformed.
68+
rendering chunks...
69+
computing gzip size...
70+
dist/index.html 0.45 kB │ gzip: 0.29 kB
71+
dist/assets/index-BAKMvvYC.css 1.37 kB │ gzip: 0.65 kB
72+
dist/assets/index-BJ8qKvJC.js 3.04 kB │ gzip: 1.64 kB
73+
✓ built in <variable>ms
74+
75+
> cd my-project && vite run ready # run ready task third time to check cache
76+
Cache not found
77+
Cache not found
78+
Cache not found
79+
Cache hit, replaying
80+
rolldown-vite v<semver> building for production...
81+
transforming...✓ 7 modules transformed.
82+
rendering chunks...
83+
computing gzip size...
84+
dist/index.html 0.45 kB │ gzip: 0.29 kB
85+
dist/assets/index-BAKMvvYC.css 1.37 kB │ gzip: 0.65 kB
86+
dist/assets/index-BJ8qKvJC.js 3.04 kB │ gzip: 1.64 kB
87+
✓ built in <variable>ms
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"env": {
3+
},
4+
"commands": [
5+
"vite new my-project singlerepo # create singlerepo",
6+
"cd my-project && vite run ready # run ready task",
7+
"cd my-project && vite run ready # run ready task second time to check cache",
8+
"cd my-project && vite run ready # run ready task third time to check cache"
9+
]
10+
}

packages/global/snap-tests/new/snap.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/global/snap-tests/new/steps.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)