Skip to content

Commit 7c52502

Browse files
fengmk2claudeCopilot
authored
feat(global): add scaffolding command 'vite new' for project creation (#137)
Signed-off-by: MK (fengmk2) <fengmk2@gmail.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent eba179f commit 7c52502

88 files changed

Lines changed: 1309 additions & 938 deletions

Some content is hidden

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

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ jobs:
111111
112112
- name: Publish
113113
run: |
114-
echo "//npm.pkg.github.com/:_authToken=${NPM_TOKEN}" >> ~/.npmrc
115-
echo "@voidzero-dev:registry=https://npm.pkg.github.com/" >> ~/.npmrc
114+
echo "//npm.pkg.github.com/:_authToken=${NPM_TOKEN}" >> ${NPM_CONFIG_USERCONFIG}
115+
echo "@voidzero-dev:registry=https://npm.pkg.github.com/" >> ${NPM_CONFIG_USERCONFIG}
116116
pnpm publish --filter=./packages/global --registry https://npm.pkg.github.com --no-git-checks
117117
pnpm publish --filter=./packages/cli --registry https://npm.pkg.github.com --no-git-checks
118118
env:

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: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
my-lib
68+
69+
> cd my-project && vp new --lib tools/my-tool # add lib new not exists tools directory
70+
Creating new library at tools/my-tool...
71+
✅ Successfully created library at tools/my-tool
72+
73+
Next steps:
74+
vite run ready
75+
76+
> cd my-project && ls tools
77+
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+
}

0 commit comments

Comments
 (0)