Skip to content

Commit 9029831

Browse files
committed
feat(cli): interactive package picker for bare app commands at the workspace root
Replaces the interim TTY listing with the fuzzy vite_select picker (the vp run selector component): typing filters packages, Enter runs the selection as an implicit -C, Ctrl+C cancels with exit 130. Single-runnable auto-select and the non-interactive listing are unchanged. Every picker render emits a package-select:<query>:<index> milestone so PTY snapshot tests synchronize on real keystrokes (picker_select / picker_cancel / non-TTY listing cases, both flavors). Requires the configurable prompt from voidzero-dev/vite-task#510; the vite-task pin points at that PR's commit and needs a re-bump to vite-task main after it merges.
1 parent 42e469d commit 9029831

12 files changed

Lines changed: 255 additions & 20 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ vite_shared = { path = "crates/vite_shared" }
307307
vite_static_config = { path = "crates/vite_static_config" }
308308
vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "cb580c214bb2314fc1f633a3812782c9b3a1d956" }
309309
vite_powershell = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "cb580c214bb2314fc1f633a3812782c9b3a1d956" }
310+
vite_select = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "cb580c214bb2314fc1f633a3812782c9b3a1d956" }
310311
vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "cb580c214bb2314fc1f633a3812782c9b3a1d956" }
311312
vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "cb580c214bb2314fc1f633a3812782c9b3a1d956" }
312313
vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "cb580c214bb2314fc1f633a3812782c9b3a1d956" }

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_listing/snapshots.toml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,36 @@
22
name = "listing"
33
vp = ["local", "global"]
44
comment = """
5-
A bare app command at a workspace root with several candidate packages prints
5+
A bare app command at a workspace root without an interactive terminal prints
66
the ranked package listing with -C hints and exits 1 instead of building the
7-
root, even in an interactive terminal (rfcs/cwd-flag.md).
7+
root (rfcs/cwd-flag.md).
88
"""
9-
steps = [["vp", "build"]]
9+
steps = [{ argv = ["vp", "build"], tty = false }]
10+
11+
[[case]]
12+
name = "picker_select"
13+
vp = ["local", "global"]
14+
comment = """
15+
A bare app command at a workspace root with several candidates opens the
16+
fuzzy package picker (the vp run selector component); typing filters, Enter
17+
runs the selection as an implicit -C (rfcs/cwd-flag.md).
18+
"""
19+
steps = [
20+
{ argv = ["vp", "build"], interactions = [
21+
{ "expect-milestone" = "package-select::0" },
22+
{ "write" = "web" },
23+
{ "expect-milestone" = "package-select:web:0" },
24+
{ "write-key" = "enter" },
25+
] },
26+
]
27+
28+
[[case]]
29+
name = "picker_cancel"
30+
vp = ["local", "global"]
31+
comment = "Ctrl+C in the package picker cancels with exit 130 and runs nothing."
32+
steps = [
33+
{ argv = ["vp", "build"], interactions = [
34+
{ "expect-milestone" = "package-select::0" },
35+
{ "write-key" = "ctrl-c" },
36+
] },
37+
]

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_listing/snapshots/listing.global.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# listing
22

3-
A bare app command at a workspace root with several candidate packages prints
3+
A bare app command at a workspace root without an interactive terminal prints
44
the ranked package listing with -C hints and exits 1 instead of building the
5-
root, even in an interactive terminal (rfcs/cwd-flag.md).
5+
root (rfcs/cwd-flag.md).
66

77
## `vp build`
88

99
**Exit code:** 1
1010

1111
```
12-
VITE+ - The Unified Toolchain for the Web
13-
14-
error: `vp build` at the workspace root needs a target package.
12+
error: `vp build` at the workspace root needs a target package.
1513
1614
Packages in this workspace:
1715
admin apps/admin

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/app_root_listing/snapshots/listing.local.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# listing
22

3-
A bare app command at a workspace root with several candidate packages prints
3+
A bare app command at a workspace root without an interactive terminal prints
44
the ranked package listing with -C hints and exits 1 instead of building the
5-
root, even in an interactive terminal (rfcs/cwd-flag.md).
5+
root (rfcs/cwd-flag.md).
66

77
## `vp build`
88

99
**Exit code:** 1
1010

1111
```
12-
error: `vp build` at the workspace root needs a target package.
12+
[1m[31merror:[39m[0m `vp build` at the workspace root needs a target package.
1313
1414
Packages in this workspace:
1515
admin apps/admin
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# picker_cancel
2+
3+
Ctrl+C in the package picker cancels with exit 130 and runs nothing.
4+
5+
## `vp build`
6+
7+
**Exit code:** 130
8+
9+
**→ expect-milestone:** `package-select::0`
10+
11+
```
12+
VITE+ - The Unified Toolchain for the Web
13+
14+
Select a package to build (↑/↓, Enter to run, type to search):
15+
16+
› admin apps/admin
17+
web apps/web
18+
ui packages/ui
19+
```
20+
21+
**← write-key:** `ctrl-c`
22+
23+
```
24+
VITE+ - The Unified Toolchain for the Web
25+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# picker_cancel
2+
3+
Ctrl+C in the package picker cancels with exit 130 and runs nothing.
4+
5+
## `vp build`
6+
7+
**Exit code:** 130
8+
9+
**→ expect-milestone:** `package-select::0`
10+
11+
```
12+
Select a package to build (↑/↓, Enter to run, type to search):
13+
14+
› admin apps/admin
15+
web apps/web
16+
ui packages/ui
17+
```
18+
19+
**← write-key:** `ctrl-c`
20+
21+
```
22+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# picker_select
2+
3+
A bare app command at a workspace root with several candidates opens the
4+
fuzzy package picker (the vp run selector component); typing filters, Enter
5+
runs the selection as an implicit -C (rfcs/cwd-flag.md).
6+
7+
## `vp build`
8+
9+
**→ expect-milestone:** `package-select::0`
10+
11+
```
12+
VITE+ - The Unified Toolchain for the Web
13+
14+
Select a package to build (↑/↓, Enter to run, type to search):
15+
16+
› admin apps/admin
17+
web apps/web
18+
ui packages/ui
19+
```
20+
21+
**← write:** `web`
22+
23+
**→ expect-milestone:** `package-select:web:0`
24+
25+
```
26+
VITE+ - The Unified Toolchain for the Web
27+
28+
Select a package to build (↑/↓, Enter to run, type to search): web
29+
30+
› web apps/web
31+
```
32+
33+
**← write-key:** `enter`
34+
35+
```
36+
VITE+ - The Unified Toolchain for the Web
37+
38+
Selected package: web (apps/web)
39+
Tip: run this directly with `vp -C apps/web build`
40+
vite <version> building client environment for production...
41+
✓ 2 modules transformed.
42+
computing gzip size...
43+
dist/index.html 0.06 kB │ gzip: 0.06 kB
44+
45+
✓ built in <duration>
46+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# picker_select
2+
3+
A bare app command at a workspace root with several candidates opens the
4+
fuzzy package picker (the vp run selector component); typing filters, Enter
5+
runs the selection as an implicit -C (rfcs/cwd-flag.md).
6+
7+
## `vp build`
8+
9+
**→ expect-milestone:** `package-select::0`
10+
11+
```
12+
Select a package to build (↑/↓, Enter to run, type to search):
13+
14+
› admin apps/admin
15+
web apps/web
16+
ui packages/ui
17+
```
18+
19+
**← write:** `web`
20+
21+
**→ expect-milestone:** `package-select:web:0`
22+
23+
```
24+
Select a package to build (↑/↓, Enter to run, type to search): web
25+
26+
› web apps/web
27+
```
28+
29+
**← write-key:** `enter`
30+
31+
```
32+
Selected package: web (apps/web)
33+
Tip: run this directly with `vp -C apps/web build`
34+
vite <version> building client environment for production...
35+
✓ 2 modules transformed.
36+
computing gzip size...
37+
dist/index.html 0.06 kB │ gzip: 0.06 kB
38+
39+
✓ built in <duration>
40+
```

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vp_help/snapshots/help.global.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ Documentation: https://viteplus.dev/guide/
5858
5959
Options:
6060
-V, --version Print version
61+
-C <DIR> Run as if vp was started in <DIR> instead of the current working directory
6162
-h, --help Print help
6263
```

docs/guide/monorepo.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,28 @@ Tip: run this directly with `vp -C apps/web dev`
164164
➜ Network: use --host to expose
165165
```
166166

167-
When several packages could be the target, vp lists them with ready-to-copy commands instead of guessing:
167+
When several packages could be the target, vp opens a fuzzy package picker (the same selector as `vp run`). Typing filters, Enter runs the selection, and vp prints the direct command for next time:
168168

169169
```
170170
$ vp build
171+
Select a package to build (↑/↓, Enter to run, type to search):
172+
173+
› admin apps/admin
174+
web apps/web
175+
ui packages/ui
176+
```
177+
178+
```
179+
Selected package: web (apps/web)
180+
Tip: run this directly with `vp -C apps/web build`
181+
182+
✓ built in 187ms
183+
```
184+
185+
In non-interactive shells (CI, pipes, redirection), vp prints the same packages as a plain listing with ready-to-copy commands and exits 1:
186+
187+
```
188+
$ vp build | cat
171189
error: `vp build` at the workspace root needs a target package.
172190
173191
Packages in this workspace:
@@ -179,7 +197,7 @@ error: `vp build` at the workspace root needs a target package.
179197
Or run every package's build script: vp run -r build
180198
```
181199

182-
Packages that look runnable for the command (an `index.html` or `vite.config.*` for `dev` / `build` / `preview`, a library entry for `pack`) are listed first.
200+
Packages that look runnable for the command (an `index.html` or `vite.config.*` for `dev` / `build` / `preview`, a library entry for `pack`) are ranked first in both the picker and the listing.
183201

184202
### Targeting a package with `-C`
185203

0 commit comments

Comments
 (0)