Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ vt_snapshot_test = { git = "https://github.com/voidzero-dev/vite-task.git", rev
vt_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "6a23096aa2f04eb59225c6467b15c2965ee6ae33" }
vt_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "6a23096aa2f04eb59225c6467b15c2965ee6ae33" }
walkdir = "2.5.0"
wax = "0.7.0"
webpki-root-certs = "1.0.10"
which = "8.0.6"
winreg = "0.56.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "check-cache-enabled-test",
"type": "module",
"scripts": {
"check": "vp check"
"check": "vp check",
"check:chdir": "vp -C . check"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ steps = [
{ argv = ["vp", "run", "check"], comment = "third run should be cache miss after new file added", continue-on-failure = true },
{ argv = ["vp", "run", "check"], envs = [["VP_SKIP_STATIC_CONFIG", "1"]], comment = "changing VP_SKIP_STATIC_CONFIG should be a cache miss", continue-on-failure = true },
]

[[case]]
name = "check_cache_chdir"
vp = "local"
skip-platforms = ["windows"]
comment = "A leading -C keeps the cache config of vp check, so its tracked env still invalidates the cache (#3503)."
steps = [
{ argv = ["vp", "run", "check:chdir"], comment = "first run should be cache miss", continue-on-failure = true },
{ argv = ["vp", "run", "check:chdir"], envs = [["VP_SKIP_STATIC_CONFIG", "1"]], comment = "changing VP_SKIP_STATIC_CONFIG should be a cache miss", continue-on-failure = true },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# check_cache_chdir

A leading -C keeps the cache config of vp check, so its tracked env still invalidates the cache (#3503).

## `vp run check:chdir`

first run should be cache miss

```
$ vp -C . check
pass: All 3 files are correctly formatted (<duration>, <n> threads)
pass: Found no warnings or lint errors in 2 files (<duration>, <n> threads)
```

## `VP_SKIP_STATIC_CONFIG=1 vp run check:chdir`

changing VP_SKIP_STATIC_CONFIG should be a cache miss

```
$ vp -C . check ○ cache miss: env 'VP_SKIP_STATIC_CONFIG' changed, executing
pass: All 3 files are correctly formatted (<duration>, <n> threads)
pass: Found no warnings or lint errors in 2 files (<duration>, <n> threads)
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "command-init-inline-config",
"version": "0.0.0",
"private": true
"private": true,
"scripts": {
"fmt:init": "vp -C . fmt --init"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ steps = [
{ argv = ["vpt", "print-file", "vite.config.ts"], continue-on-failure = true },
{ argv = ["vpt", "stat-file", ".oxfmtrc.json", "--assert-not", "file"], comment = "check .oxfmtrc.json is removed", continue-on-failure = true },
]

[[case]]
name = "command_init_inline_config_chdir_script"
vp = "local"
comment = "An init command after vp -C in a task script merges its config into vite.config.ts like a direct call."
steps = [
{ argv = ["vp", "run", "fmt:init"], continue-on-failure = true },
{ argv = ["vpt", "print-file", "vite.config.ts"], continue-on-failure = true },
{ argv = ["vpt", "stat-file", ".oxfmtrc.json", "--assert-not", "file"], comment = "check .oxfmtrc.json is removed", continue-on-failure = true },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# command_init_inline_config_chdir_script

An init command after vp -C in a task script merges its config into vite.config.ts like a direct call.

## `vp run fmt:init`

```
$ vp -C . fmt --init ⊘ cache disabled
Added 'fmt' to 'vite.config.ts'.
```

## `vpt print-file vite.config.ts`

```
import { defineConfig } from "vite-plus";
export default defineConfig({
fmt: {
ignorePatterns: [],
},
});
```

## `vpt stat-file .oxfmtrc.json --assert-not file`

check .oxfmtrc.json is removed

```
.oxfmtrc.json: missing
```
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"packages/*"
],
"scripts": {
"where:hello": "vp -C packages/hello run where"
"where:hello": "vp -C packages/hello run where",
"build:missing": "vp -C packages/missing build",
"version:chdir": "vp -C packages/hello --version",
"help:chdir": "vp -C packages/hello"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ steps = [
{ argv = ["vp", "pack", "packages/hello"], comment = "positional stays a tsdown entry resolved from the invocation directory" },
{ argv = ["vpt", "list-dir", "dist"], comment = "upstream semantics: output lands at the invocation directory" },
{ argv = ["vp", "run", "where:hello"], comment = "a script whose command starts with vp -C runs verbatim and honors the directory" },
{ argv = ["vp", "run", "version:chdir"], comment = "a script with --version after -C runs verbatim, so vp prints versions like a direct invocation" },
{ argv = ["vp", "run", "help:chdir"], snapshot = false, tty = false, comment = "a script with only -C runs in a child vp, which shows help like a direct invocation" },
{ argv = ["vp", "run", "build:missing"], comment = "a script with a missing -C directory runs in a child vp, which reports it like a direct invocation", continue-on-failure = true },
]

# Regression guard for the -C direct-exec PWD gap: a command run through
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,50 @@ VITE+ - The Unified Toolchain for the Web
~/packages/hello$ node -e "console.log('cwd base: ' + require('node:path').basename(process.cwd()))" ⊘ cache disabled
cwd base: hello
```

## `vp run version:chdir`

a script with --version after -C runs verbatim, so vp prints versions like a direct invocation

```
VITE+ - The Unified Toolchain for the Web
$ vp -C packages/hello --version ⊘ cache disabled
VITE+ - The Unified Toolchain for the Web
vp <version>
Local vite-plus:
vite-plus <version>
Tools:
vite <version>
rolldown <version>
vitest <version>
oxfmt <version>
oxlint <version>
tsrs <version>
tsdown <version>
Environment:
Package manager Not found
Node.js <version>
```

## `vp run help:chdir`

a script with only -C runs in a child vp, which shows help like a direct invocation


## `vp run build:missing`

a script with a missing -C directory runs in a child vp, which reports it like a direct invocation

**Exit code:** 1

```
VITE+ - The Unified Toolchain for the Web
$ vp -C packages/missing build ⊘ cache disabled
directory not found: packages/missing
```
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,33 @@ $ vp -C packages/hello run where ⊘ cache disabled
~/packages/hello$ node -e "console.log('cwd base: ' + require('node:path').basename(process.cwd()))" ⊘ cache disabled
cwd base: hello
```

## `vp run version:chdir`

a script with --version after -C runs verbatim, so vp prints versions like a direct invocation

```
$ vp -C packages/hello --version ⊘ cache disabled
VITE+ - The Unified Toolchain for the Web
vp <version>
Local vite-plus:
vite-plus Not found
```

## `vp run help:chdir`

a script with only -C runs in a child vp, which shows help like a direct invocation


## `vp run build:missing`

a script with a missing -C directory runs in a child vp, which reports it like a direct invocation

**Exit code:** 1

```
$ vp -C packages/missing build ⊘ cache disabled
error: directory not found: packages/missing
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "cwd-flag-script-pack-cache",
"private": true,
"type": "module",
"workspaces": [
"packages/*"
],
"scripts": {
"pack:app": "vp -C packages/app pack"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "app",
"private": true,
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { value } from '../../../dist/shared.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[case]]
name = "cwd_flag_script_pack_cache"
vp = "local"
skip-platforms = ["windows"]
comment = """
A cached root task runs vp -C packages/app pack. Pack excludes its own dist
output from the cache inputs, and that exclusion must apply to packages/app/dist
rather than the root dist, which the package reads as an input.
"""
steps = [
{ argv = ["vpt", "write-file", "dist/shared.js", "export const value = 'shared-one';\n"], comment = "dist is ignored by git, so the root input is created here" },
{ argv = ["vp", "run", "pack:app"], comment = "first run is a cache miss" },
{ argv = ["vp", "run", "pack:app"], comment = "second run without changes is a cache hit" },
["vpt", "write-file", "dist/shared.js", "export const value = 'shared-two';\n"],
{ argv = ["vp", "run", "pack:app"], comment = "changing the root dist input is a cache miss" },
["vpt", "grep-file", "packages/app/dist/index.mjs", "shared-two"],
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# cwd_flag_script_pack_cache

A cached root task runs vp -C packages/app pack. Pack excludes its own dist
output from the cache inputs, and that exclusion must apply to packages/app/dist
rather than the root dist, which the package reads as an input.

## `vpt write-file dist/shared.js 'export const value = '\''shared-one'\'';
'`

dist is ignored by git, so the root input is created here

```
```

## `vp run pack:app`

first run is a cache miss

```
$ vp -C packages/app pack
ℹ entry: src/index.ts
ℹ Build start
ℹ dist/index.mjs <size> kB │ gzip: <size> kB
ℹ 1 files, total: <size> kB
✔ Build complete in <duration>
```

## `vp run pack:app`

second run without changes is a cache hit

```
$ vp -C packages/app pack ◉ cache hit, replaying
ℹ entry: src/index.ts
ℹ Build start
ℹ dist/index.mjs <size> kB │ gzip: <size> kB
ℹ 1 files, total: <size> kB
✔ Build complete in <duration>

---
vp run: cache hit, <duration> saved.
```

## `vpt write-file dist/shared.js 'export const value = '\''shared-two'\'';
'`

```
```

## `vp run pack:app`

changing the root dist input is a cache miss

```
$ vp -C packages/app pack ○ cache miss: 'dist/shared.js' modified, executing
ℹ entry: src/index.ts
ℹ Build start
ℹ Cleaning <n> files
ℹ dist/index.mjs <size> kB │ gzip: <size> kB
ℹ 1 files, total: <size> kB
✔ Build complete in <duration>
```

## `vpt grep-file packages/app/dist/index.mjs shared-two`

```
packages/app/dist/index.mjs: found "shared-two"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
run: {
cache: true,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22.23.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "cwd-flag-script-runtime",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"build:app": "vp -C packages/app build"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24.22.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html><body><script type="module">console.log(1)</script></body></html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "app",
"private": true,
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { writeFileSync } from 'node:fs';

// The task runner also loads this config, so only the build records its runtime.
if (process.argv.includes('build')) {
writeFileSync('node-major.txt', `node ${process.versions.node.split('.')[0]}`);
}

export default {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[[case]]
name = "cwd_flag_script_runtime"
vp = "global"
comment = """
A task script that starts with vp -C runs in a child vp, which selects the
target directory's Node runtime like a direct invocation. The root pins
Node 22 and the target package pins Node 24.
"""
steps = [
{ argv = ["vp", "run", "build:app"], snapshot = false },
["vpt", "grep-file", "packages/app/node-major.txt", "node 24"],
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# cwd_flag_script_runtime

A task script that starts with vp -C runs in a child vp, which selects the
target directory's Node runtime like a direct invocation. The root pins
Node 22 and the target package pins Node 24.

## `vp run build:app`


## `vpt grep-file packages/app/node-major.txt 'node 24'`

```
packages/app/node-major.txt: found "node 24"
```
Loading
Loading