Skip to content

Commit 4ce01b0

Browse files
committed
fix(cli): address Codex review round 6
- defaultPackage is consulted only at the invocation root: a member package's own config never redirects (or fails) a command already running in that member; regression case pins a member config pointing at a missing directory - inline --env.NAME=value pack flags no longer consume the next token, so an explicit entry after them stays a positional - complete the pack value-flag table from pack-bin.ts: --root, -F/--filter, -c/--config; add cac kebab-case twins to the Vite table - mark the two mid-case expected-failure steps continue-on-failure per the harness's new shell-like && semantics
1 parent c7215df commit 4ce01b0

12 files changed

Lines changed: 287 additions & 11 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// A member package declaring defaultPackage: ignored below the workspace
2+
// root, where the current directory already identifies the target.
3+
export default {
4+
defaultPackage: "./does-not-exist",
5+
};

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,13 @@ as an open map might hide defaultPackage behind the spread, but that must
2626
not fail the command. Bare vp build falls through and runs in place.
2727
"""
2828
steps = [{ argv = ["vp", "build"], cwd = "spread", tty = false }]
29+
30+
[[case]]
31+
name = "member_config_ignored"
32+
vp = ["local", "global"]
33+
comment = """
34+
defaultPackage is a root-pointer concept: a member package's own config
35+
declaring it (here pointing at a missing directory) must not redirect or
36+
fail a command already running in that member.
37+
"""
38+
steps = [{ argv = ["vp", "pack"], cwd = "packages/ui", tty = false }]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# member_config_ignored
2+
3+
defaultPackage is a root-pointer concept: a member package's own config
4+
declaring it (here pointing at a missing directory) must not redirect or
5+
fail a command already running in that member.
6+
7+
## `cd packages/ui && vp pack`
8+
9+
**Exit code:** 1
10+
11+
```
12+
error: defaultPackage points to a missing directory: ./does-not-exist
13+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# member_config_ignored
2+
3+
defaultPackage is a root-pointer concept: a member package's own config
4+
declaring it (here pointing at a missing directory) must not redirect or
5+
fail a command already running in that member.
6+
7+
## `cd packages/ui && vp pack`
8+
9+
**Exit code:** 1
10+
11+
```
12+
error: defaultPackage points to a missing directory: ./does-not-exist
13+
```

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ the ranked package listing with -C hints and exits 1 instead of building the
77
root (rfcs/cwd-flag.md).
88
"""
99
steps = [
10-
{ argv = ["vp", "build"], tty = false },
10+
{ argv = ["vp", "build"], tty = false, continue-on-failure = true },
1111
{ argv = ["vp", "dev"], tty = false, comment = "dev at the root no longer starts a server against the root" },
1212
]
1313

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# listing
2+
3+
A bare app command at a workspace root without an interactive terminal prints
4+
the ranked package listing with -C hints and exits 1 instead of building the
5+
root (rfcs/cwd-flag.md).
6+
7+
## `vp build`
8+
9+
**Exit code:** 1
10+
11+
```
12+
error: `vp build` at the workspace root needs a target package.
13+
14+
Packages in this workspace:
15+
admin apps/admin
16+
web apps/web
17+
ui packages/ui
18+
19+
Pass a directory: vp -C apps/admin build
20+
Or run every package's build script: vp run -r build
21+
```
22+
23+
*(remaining steps skipped: step failed)*
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# listing
2+
3+
A bare app command at a workspace root without an interactive terminal prints
4+
the ranked package listing with -C hints and exits 1 instead of building the
5+
root (rfcs/cwd-flag.md).
6+
7+
## `vp build`
8+
9+
**Exit code:** 1
10+
11+
```
12+
error: `vp build` at the workspace root needs a target package.
13+
14+
Packages in this workspace:
15+
admin apps/admin
16+
web apps/web
17+
ui packages/ui
18+
19+
Pass a directory: vp -C apps/admin build
20+
Or run every package's build script: vp run -r build
21+
```
22+
23+
*(remaining steps skipped: step failed)*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ steps = [
1414
{ argv = ["vp", "pack"], cwd = "packages/hello", comment = "the cd form is equivalent" },
1515
{ argv = ["vp", "-C", "packages/hello", "run", "where"], comment = "-C applies to vp run as well" },
1616
{ argv = ["vp", "run", "where"], cwd = "packages/hello", comment = "equivalent cd form for run" },
17-
{ argv = ["vp", "-C", "packages/missing", "build"], comment = "missing directory errors" },
17+
{ argv = ["vp", "-C", "packages/missing", "build"], comment = "missing directory errors", continue-on-failure = true },
1818
{ argv = ["vp", "pack", "packages/hello"], comment = "positional stays a tsdown entry resolved from the invocation directory" },
1919
{ argv = ["vpt", "list-dir", "dist"], comment = "upstream semantics: output lands at the invocation directory" },
2020
{ argv = ["vp", "run", "where:hello"], comment = "a script whose command starts with vp -C runs verbatim and honors the directory" },
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# cwd_flag
2+
3+
The global -C flag runs any command as if vp was started in the directory:
4+
pack and run behave byte-identically to the cd forms, a missing directory
5+
errors, and the positional keeps upstream tsdown entry semantics
6+
(rfcs/cwd-flag.md).
7+
8+
## `vp -C packages/hello pack`
9+
10+
-C packs the package from the workspace root
11+
12+
```
13+
VITE+ - The Unified Toolchain for the Web
14+
15+
ℹ entry: src/index.ts
16+
ℹ Build start
17+
ℹ dist/index.mjs <size> kB │ gzip: <size> kB
18+
ℹ 1 files, total: <size> kB
19+
✔ Build complete in <duration>
20+
```
21+
22+
## `vpt list-dir packages/hello/dist`
23+
24+
output lands in the target package
25+
26+
```
27+
index.mjs
28+
```
29+
30+
## `vpt rm -rf packages/hello/dist`
31+
32+
reset so both forms produce identical output
33+
34+
```
35+
```
36+
37+
## `cd packages/hello && vp pack`
38+
39+
the cd form is equivalent
40+
41+
```
42+
VITE+ - The Unified Toolchain for the Web
43+
44+
ℹ entry: src/index.ts
45+
ℹ Build start
46+
ℹ dist/index.mjs <size> kB │ gzip: <size> kB
47+
ℹ 1 files, total: <size> kB
48+
✔ Build complete in <duration>
49+
```
50+
51+
## `vp -C packages/hello run where`
52+
53+
-C applies to vp run as well
54+
55+
```
56+
VITE+ - The Unified Toolchain for the Web
57+
58+
~/packages/hello$ node -e "console.log('cwd base: ' + require('node:path').basename(process.cwd()))" ⊘ cache disabled
59+
cwd base: hello
60+
```
61+
62+
## `cd packages/hello && vp run where`
63+
64+
equivalent cd form for run
65+
66+
```
67+
VITE+ - The Unified Toolchain for the Web
68+
69+
~/packages/hello$ node -e "console.log('cwd base: ' + require('node:path').basename(process.cwd()))" ⊘ cache disabled
70+
cwd base: hello
71+
```
72+
73+
## `vp -C packages/missing build`
74+
75+
missing directory errors
76+
77+
**Exit code:** 1
78+
79+
```
80+
directory not found: packages/missing
81+
```
82+
83+
*(remaining steps skipped: step failed)*
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# cwd_flag
2+
3+
The global -C flag runs any command as if vp was started in the directory:
4+
pack and run behave byte-identically to the cd forms, a missing directory
5+
errors, and the positional keeps upstream tsdown entry semantics
6+
(rfcs/cwd-flag.md).
7+
8+
## `vp -C packages/hello pack`
9+
10+
-C packs the package from the workspace root
11+
12+
```
13+
ℹ entry: src/index.ts
14+
ℹ Build start
15+
ℹ dist/index.mjs <size> kB │ gzip: <size> kB
16+
ℹ 1 files, total: <size> kB
17+
✔ Build complete in <duration>
18+
```
19+
20+
## `vpt list-dir packages/hello/dist`
21+
22+
output lands in the target package
23+
24+
```
25+
index.mjs
26+
```
27+
28+
## `vpt rm -rf packages/hello/dist`
29+
30+
reset so both forms produce identical output
31+
32+
```
33+
```
34+
35+
## `cd packages/hello && vp pack`
36+
37+
the cd form is equivalent
38+
39+
```
40+
ℹ entry: src/index.ts
41+
ℹ Build start
42+
ℹ dist/index.mjs <size> kB │ gzip: <size> kB
43+
ℹ 1 files, total: <size> kB
44+
✔ Build complete in <duration>
45+
```
46+
47+
## `vp -C packages/hello run where`
48+
49+
-C applies to vp run as well
50+
51+
```
52+
~/packages/hello$ node -e "console.log('cwd base: ' + require('node:path').basename(process.cwd()))" ⊘ cache disabled
53+
cwd base: hello
54+
```
55+
56+
## `cd packages/hello && vp run where`
57+
58+
equivalent cd form for run
59+
60+
```
61+
~/packages/hello$ node -e "console.log('cwd base: ' + require('node:path').basename(process.cwd()))" ⊘ cache disabled
62+
cwd base: hello
63+
```
64+
65+
## `vp -C packages/missing build`
66+
67+
missing directory errors
68+
69+
**Exit code:** 1
70+
71+
```
72+
error: directory not found: packages/missing
73+
```
74+
75+
*(remaining steps skipped: step failed)*

0 commit comments

Comments
 (0)