Skip to content

Commit 6bdf47c

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 2396cc0 commit 6bdf47c

12 files changed

Lines changed: 264 additions & 29 deletions

File tree

Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ dunce = "1.0.5"
194194
fast-glob = "1.0.0"
195195
flate2 = { version = "=1.1.9", features = ["zlib-rs"] }
196196
form_urlencoded = "1.2.1"
197-
fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6aae5fca92b128c586c8ff3421e43911b553" }
197+
fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ca55bb232aa8" }
198198
futures = "0.3.31"
199199
futures-util = "0.3.31"
200200
glob = "0.3.2"
@@ -251,8 +251,8 @@ pretty_assertions = "1.4.1"
251251
phf = "0.13.0"
252252
prettyplease = "0.2.32"
253253
proc-macro2 = "1"
254-
pty_terminal_test = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6aae5fca92b128c586c8ff3421e43911b553" }
255-
pty_terminal_test_client = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6aae5fca92b128c586c8ff3421e43911b553" }
254+
pty_terminal_test = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ca55bb232aa8" }
255+
pty_terminal_test_client = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ca55bb232aa8" }
256256
quote = "1"
257257
rayon = "1.10.0"
258258
regex = "1.11.1"
@@ -276,7 +276,7 @@ sha2 = "0.10.9"
276276
shell-escape = "0.1.5"
277277
simdutf8 = "0.1.5"
278278
smallvec = { version = "1.15.1", features = ["union"] }
279-
snapshot_test = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6aae5fca92b128c586c8ff3421e43911b553" }
279+
snapshot_test = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ca55bb232aa8" }
280280
string_cache = "0.9.0"
281281
sugar_path = { version = "2.0.1", features = ["cached_current_dir"] }
282282
supports-color = "3"
@@ -313,11 +313,12 @@ vite_pm_cli = { path = "crates/vite_pm_cli" }
313313
vite_setup = { path = "crates/vite_setup" }
314314
vite_shared = { path = "crates/vite_shared" }
315315
vite_static_config = { path = "crates/vite_static_config" }
316-
vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6aae5fca92b128c586c8ff3421e43911b553" }
317-
vite_powershell = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6aae5fca92b128c586c8ff3421e43911b553" }
318-
vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6aae5fca92b128c586c8ff3421e43911b553" }
319-
vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6aae5fca92b128c586c8ff3421e43911b553" }
320-
vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6aae5fca92b128c586c8ff3421e43911b553" }
316+
vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ca55bb232aa8" }
317+
vite_powershell = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ca55bb232aa8" }
318+
vite_select = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ca55bb232aa8" }
319+
vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ca55bb232aa8" }
320+
vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ca55bb232aa8" }
321+
vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "ca55bb232aa8" }
321322
walkdir = "2.5.0"
322323
wax = "0.6.0"
323324
which = "8.0.0"

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)