Skip to content

Commit aac0f6d

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 ae9d35e commit aac0f6d

88 files changed

Lines changed: 1312 additions & 939 deletions

Some content is hidden

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

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/binding/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ edition = "2024"
77
clap = { workspace = true }
88
napi = { workspace = true }
99
napi-derive = { workspace = true }
10+
tracing = { workspace = true }
1011
vite_error = { workspace = true }
11-
vite_task = { workspace = true }
1212
vite_path = { workspace = true }
13+
vite_task = { workspace = true }
1314

1415
[build-dependencies]
1516
napi-build = { workspace = true }

packages/cli/binding/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ pub async fn run(options: CliOptions) -> Result<()> {
184184
Error::UserCancelled => std::process::exit(130),
185185
_ => {
186186
// Convert Rust errors to NAPI errors for JavaScript
187+
tracing::error!("Rust error: {:?}", e);
187188
return Err(anyhow::Error::from(e).into());
188189
}
189190
}

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
},
1515
"files": [
1616
"bin",
17-
"dist"
17+
"dist",
18+
"templates"
1819
],
1920
"scripts": {
2021
"build": "rolldown -c rolldown.config.ts",
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
> vp 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+
> vp 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 && vp new --app apps/my-app # add app
49+
Creating new app at apps/my-app...
50+
✅ Successfully created app at apps/my-app
51+
52+
Next steps:
53+
vite run ready
54+
55+
> cd my-project && ls apps
56+
my-app
57+
website
58+
59+
> cd my-project && vp new --lib packages/my-lib # add lib
60+
Creating new library at packages/my-lib...
61+
✅ Successfully created library at packages/my-lib
62+
63+
Next steps:
64+
vite run ready
65+
66+
> cd my-project && ls packages
67+
logger
68+
my-lib
69+
70+
> cd my-project && vp new --lib tools/my-tool # add lib new not exists tools directory
71+
Creating new library at tools/my-tool...
72+
✅ Successfully created library at tools/my-tool
73+
74+
Next steps:
75+
vite run ready
76+
77+
> cd my-project && ls tools
78+
my-tool
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"commands": [
3+
"vp new -h # show help",
4+
"vp new my-project monorepo # create monorepo",
5+
"cd my-project && vp new --app apps/my-app # add app",
6+
"cd my-project && ls apps",
7+
"cd my-project && vp new --lib packages/my-lib # add lib",
8+
"cd my-project && ls packages",
9+
"cd my-project && vp new --lib tools/my-tool # add lib new not exists tools directory",
10+
"cd my-project && ls tools"
11+
]
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
> vp 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
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"commands": [
3+
"vp new my-project singlerepo # create singlerepo"
4+
]
5+
}

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

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

0 commit comments

Comments
 (0)