Skip to content

Commit 634bd07

Browse files
authored
fix(cli): improve workspace app target classification (#2530)
Vite+ now protects exact bare app commands at a workspace root. Any argument passed to `vp dev`, `vp build`, `vp preview`, or `vp pack` is explicit command intent. Vite+ forwards the arguments and runs in the current directory. It does not parse Vite or tsdown options for target selection. For an exact bare command, Vite+ first applies `defaultPackage`. It then checks the root intent signals. A declared `root`, `build`, `input`, `environments`, or `appType` field selects the root. A source `index.html` also selects it. These signals identify the intended target. They do not prove that the command will succeed. Vite+ does not inspect declared values. When no root intent signal exists, the picker and non-interactive list show the workspace root as `.`. This row comes after all member rows. It does not affect automatic selection of one likely-runnable member. `vp -C . <command>` selects the root directly. Local and global snapshots cover bare `vp dev`, `vp build`, and `vp preview`. Other snapshots cover explicit arguments, the root fallback, explicit `-C`, and pack `--root`. The RFC describes these rules. Fixes #2516.
1 parent b2679c5 commit 634bd07

82 files changed

Lines changed: 1276 additions & 422 deletions

File tree

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.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "app-custom-vite-root-test",
3+
"private": true
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "member",
3+
"private": true
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages:
2+
- packages/*
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[[case]]
2+
name = "dev_uses_custom_vite_root"
3+
vp = ["local", "global"]
4+
comment = """
5+
The config sets a static Vite `root`. The `index.html` file is in that directory.
6+
Bare `vp dev` starts the workspace app. The command does not ask the user to
7+
select a member package.
8+
"""
9+
steps = [
10+
{ argv = ["vp", "dev"], interactions = [
11+
{ "expect-milestone" = "dev-server:ready" },
12+
{ "write-line" = "q" },
13+
] },
14+
]
15+
16+
[[case]]
17+
name = "build_and_preview_use_custom_vite_root"
18+
vp = ["local", "global"]
19+
comment = """
20+
The config sets a static Vite `root`. The `index.html` file is in that directory.
21+
Bare `vp build` builds the workspace app. Then `vp preview` serves the build
22+
output.
23+
"""
24+
steps = [
25+
["vp", "build"],
26+
{ argv = ["vp", "preview"], interactions = [
27+
{ "expect-milestone" = "preview-server:ready" },
28+
{ "write-line" = "q" },
29+
] },
30+
]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# build_and_preview_use_custom_vite_root
2+
3+
The config sets a static Vite `root`. The `index.html` file is in that directory.
4+
Bare `vp build` builds the workspace app. Then `vp preview` serves the build
5+
output.
6+
7+
## `vp build`
8+
9+
```
10+
VITE+ - The Unified Toolchain for the Web
11+
12+
✓ 2 modules transformed.
13+
computing gzip size...
14+
src/dist/index.html <size> kB │ gzip: <size> kB
15+
16+
✓ built in <duration>
17+
```
18+
19+
## `vp preview`
20+
21+
**→ expect-milestone:** `preview-server:ready`
22+
23+
```
24+
VITE+ - The Unified Toolchain for the Web
25+
26+
➜ Local: http://127.0.0.1:<port>/
27+
➜ press h + enter to show help
28+
```
29+
30+
**← write-line:** `q`
31+
32+
```
33+
VITE+ - The Unified Toolchain for the Web
34+
35+
➜ Local: http://127.0.0.1:<port>/
36+
➜ press h + enter to show help
37+
q
38+
```
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# build_and_preview_use_custom_vite_root
2+
3+
The config sets a static Vite `root`. The `index.html` file is in that directory.
4+
Bare `vp build` builds the workspace app. Then `vp preview` serves the build
5+
output.
6+
7+
## `vp build`
8+
9+
```
10+
✓ 2 modules transformed.
11+
computing gzip size...
12+
src/dist/index.html <size> kB │ gzip: <size> kB
13+
14+
✓ built in <duration>
15+
```
16+
17+
## `vp preview`
18+
19+
**→ expect-milestone:** `preview-server:ready`
20+
21+
```
22+
➜ Local: http://127.0.0.1:<port>/
23+
➜ press h + enter to show help
24+
```
25+
26+
**← write-line:** `q`
27+
28+
```
29+
➜ Local: http://127.0.0.1:<port>/
30+
➜ press h + enter to show help
31+
q
32+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# dev_uses_custom_vite_root
2+
3+
The config sets a static Vite `root`. The `index.html` file is in that directory.
4+
Bare `vp dev` starts the workspace app. The command does not ask the user to
5+
select a member package.
6+
7+
## `vp dev`
8+
9+
**→ expect-milestone:** `dev-server:ready`
10+
11+
```
12+
VITE+ - The Unified Toolchain for the Web
13+
14+
VITE+ <version>
15+
16+
➜ Local: http://127.0.0.1:<port>/
17+
➜ press h + enter to show help
18+
```
19+
20+
**← write-line:** `q`
21+
22+
```
23+
VITE+ - The Unified Toolchain for the Web
24+
25+
VITE+ <version>
26+
27+
➜ Local: http://127.0.0.1:<port>/
28+
➜ press h + enter to show help
29+
q
30+
```
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# dev_uses_custom_vite_root
2+
3+
The config sets a static Vite `root`. The `index.html` file is in that directory.
4+
Bare `vp dev` starts the workspace app. The command does not ask the user to
5+
select a member package.
6+
7+
## `vp dev`
8+
9+
**→ expect-milestone:** `dev-server:ready`
10+
11+
```
12+
13+
VITE+ <version>
14+
15+
➜ Local: http://127.0.0.1:<port>/
16+
➜ press h + enter to show help
17+
```
18+
19+
**← write-line:** `q`
20+
21+
```
22+
23+
VITE+ <version>
24+
25+
➜ Local: http://127.0.0.1:<port>/
26+
➜ press h + enter to show help
27+
q
28+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Custom Vite root</title>
7+
</head>
8+
<body>
9+
<h1>Custom Vite root</h1>
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)