Skip to content

Commit bb0f097

Browse files
authored
feat: add vite_command crate for command execution (#296)
### TL;DR Add a new `vite_command` crate for executing commands with file system access tracking. ### What changed? - Created a new `vite_command` crate that provides utilities for running commands with file system access tracking using `fspy` - Added JavaScript bindings to expose this functionality to the CLI - Implemented `runCommand()` function that can be imported from `@voidzero-dev/vite-plus/binding` - Updated CI workflow to run the new tests - Fixed stdio streams on Unix platforms to prevent issues with file descriptors ### How to test? 1. Run the new tests: ``` pnpm --filter=@voidzero-dev/vite-plus test ``` 2. Try using the new API in JavaScript: ```js import { runCommand } from '@voidzero-dev/vite-plus/binding'; const result = await runCommand({ binName: 'node', args: ['-e', 'console.log("Hello, world!")'], envs: { PATH: process.env.PATH }, cwd: process.cwd(), }); console.log(`Exit code: ${result.exitCode}`); console.log(`Path accesses:`, result.pathAccesses); ``` ### Why make this change? This change provides a robust way to track file system accesses made by child processes, which is essential for features like dependency tracking, caching, and build optimization. By exposing this functionality through JavaScript bindings, it enables the CLI to implement more intelligent build tools that can understand exactly which files are being read or written during command execution.
1 parent 9d300ba commit bb0f097

19 files changed

Lines changed: 707 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215
- name: Run CLI E2E tests
216216
if: ${{ matrix.os == 'windows-latest' }}
217217
run: |
218-
RUST_BACKTRACE=1 pnpm -r snap-test
218+
RUST_BACKTRACE=1 pnpm --filter=@voidzero-dev/vite-plus test && pnpm -r snap-test
219219
git diff --exit-code
220220
221221
install-e2e-test:

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ criterion = { version = "0.7", features = ["html_reports"] }
4141
crossterm = { version = "0.29.0", features = ["event-stream"] }
4242
directories = "6.0.0"
4343
flate2 = "1.0.35"
44+
fspy = { git = "https://github.com/voidzero-dev/vite-task", rev = "96bd2eba19cdbfd7612057b41debc0fbb692d1be" }
4445
futures-util = "0.3.31"
4546
hex = "0.4.3"
4647
httpmock = "0.7"
@@ -64,6 +65,7 @@ thiserror = "2"
6465
tokio = "1.48.0"
6566
tracing = "0.1.41"
6667
tracing-subscriber = { version = "0.3.19", features = ["env-filter", "serde"] }
68+
vite_command = { path = "crates/vite_command" }
6769
vite_error = { path = "crates/vite_error" }
6870
vite_glob = { git = "https://github.com/voidzero-dev/vite-task", rev = "96bd2eba19cdbfd7612057b41debc0fbb692d1be" }
6971
vite_install = { path = "crates/vite_install" }

crates/vite_command/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "vite_command"
3+
version = "0.0.0"
4+
authors.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
rust-version.workspace = true
8+
9+
[dependencies]
10+
fspy = { workspace = true }
11+
tokio = { workspace = true }
12+
tracing = { workspace = true }
13+
vite_error = { workspace = true }
14+
vite_path = { workspace = true }
15+
which = { workspace = true, features = ["tracing"] }
16+
17+
[target.'cfg(not(target_os = "windows"))'.dependencies]
18+
nix = { workspace = true }
19+
20+
[dev-dependencies]
21+
tempfile = { workspace = true }
22+
23+
[lints]
24+
workspace = true

0 commit comments

Comments
 (0)