refactor: extract shared primitives into vite_powershell crate#368
Merged
refactor: extract shared primitives into vite_powershell crate#368
Conversation
Pull `POWERSHELL_PREFIX`, `powershell_host()`, and `find_ps1_sibling()` out of `vite_task_plan::ps1_shim` and into a new `vite_powershell` crate so vite-plus can reuse them for its package-manager command spawn path. `vite_task_plan::ps1_shim` keeps its workspace + `node_modules/.bin` scope check and cwd-relative arg conversion; only the platform-shared primitives moved. Companion change in vite-plus: `vite_command::ps1_shim` (added in voidzero-dev/vite-plus#1489 to fix Ctrl+C terminal corruption for pm commands) will switch to `vite_powershell` once this lands.
Restore the pre-extraction zero-clone path for vite_task_plan: caching
the host as Arc<AbsolutePath> means rewrite_with_host can do
Arc::clone(host) instead of allocating a fresh PathBuf+Arc on every
.cmd shim rewrite. Callers that need an owned AbsolutePathBuf
(e.g. vite-plus's vite_command::ps1_shim) call to_absolute_path_buf()
themselves.
Also drop the awkward `let Some(_) = parents.next() else { ... }` for
the discarded shim-filename component in is_in_workspace_node_modules_bin
in favor of a plain `parents.next();`.
Two CI failures from the previous commit: 1. `cargo shear` flagged `tracing` as unused in `vite_powershell` — the `tracing::debug!` call lives in callers (vite_task_plan and vite-plus's vite_command), not in the shared crate. Drop the dep. 2. Windows build flagged `use vite_path::AbsolutePathBuf` as unused under `#[cfg(any(windows, test))]`. Pre-extraction the production Windows path of `rewrite_with_host` and `find_ps1_sibling` named the type; after extraction only tests do. Tighten the gate to `#[cfg(test)]`.
fengmk2
commented
Apr 29, 2026
Member
Author
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 1e2b791. Configure here.
…module Per review on #368: instead of `#[cfg(test)] use vite_path::AbsolutePathBuf;` at module level (and re-importing through `super::AbsolutePathBuf` in the test module), import directly inside `mod tests` where it's used.
fengmk2
added a commit
to voidzero-dev/vite-plus
that referenced
this pull request
Apr 29, 2026
Switch `vite_command::ps1_shim` to depend on the new `vite_powershell` crate (companion change in voidzero-dev/vite-task#368) for the PowerShell host lookup, the fixed argument prefix, and the sibling-`.ps1` discovery. This module now just composes those primitives with vp's own conventions: absolute `.ps1` path in args and `Vec<OsString>` return type to match the spawn API. Bumps the vite-task git rev across all pinned crates to pick up the extraction.
fengmk2
added a commit
to voidzero-dev/vite-plus
that referenced
this pull request
Apr 29, 2026
Picks up the test-only AbsolutePathBuf import move from voidzero-dev/vite-task#368 review feedback.
branchseer
approved these changes
Apr 29, 2026
fengmk2
added a commit
to voidzero-dev/vite-plus
that referenced
this pull request
Apr 30, 2026
Switch `vite_command::ps1_shim` to depend on the new `vite_powershell` crate (companion change in voidzero-dev/vite-task#368) for the PowerShell host lookup, the fixed argument prefix, and the sibling-`.ps1` discovery. This module now just composes those primitives with vp's own conventions: absolute `.ps1` path in args and `Vec<OsString>` return type to match the spawn API. Bumps the vite-task git rev across all pinned crates to pick up the extraction.
fengmk2
added a commit
to voidzero-dev/vite-plus
that referenced
this pull request
Apr 30, 2026
Picks up the test-only AbsolutePathBuf import move from voidzero-dev/vite-task#368 review feedback.
fengmk2
added a commit
to voidzero-dev/vite-plus
that referenced
this pull request
Apr 30, 2026
Picks up the squash-merged voidzero-dev/vite-task#368 (the `vite_powershell` crate extraction). Replaces the draft-branch SHA `957278df` with the merged-to-main SHA across all 7 vite-task crate pins (fspy, vite_glob, vite_path, vite_powershell, vite_str, vite_task, vite_workspace).
fengmk2
added a commit
to voidzero-dev/vite-plus
that referenced
this pull request
Apr 30, 2026
Switch `vite_command::ps1_shim` to depend on the new `vite_powershell` crate (companion change in voidzero-dev/vite-task#368) for the PowerShell host lookup, the fixed argument prefix, and the sibling-`.ps1` discovery. This module now just composes those primitives with vp's own conventions: absolute `.ps1` path in args and `Vec<OsString>` return type to match the spawn API. Bumps the vite-task git rev across all pinned crates to pick up the extraction.
fengmk2
added a commit
to voidzero-dev/vite-plus
that referenced
this pull request
Apr 30, 2026
Picks up the test-only AbsolutePathBuf import move from voidzero-dev/vite-task#368 review feedback.
fengmk2
added a commit
to voidzero-dev/vite-plus
that referenced
this pull request
Apr 30, 2026
Picks up the squash-merged voidzero-dev/vite-task#368 (the `vite_powershell` crate extraction). Replaces the draft-branch SHA `957278df` with the merged-to-main SHA across all 7 vite-task crate pins (fspy, vite_glob, vite_path, vite_powershell, vite_str, vite_task, vite_workspace).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vite_powershellcrate owns the platform-shared primitives previously inlined invite_task_plan::ps1_shim:POWERSHELL_PREFIX,powershell_host()(LazyLock-cachedpwsh.exe/powershell.exelookup), andfind_ps1_sibling()(case-insensitive.cmd→ sibling.ps1resolution).vite_task_plan::ps1_shimkeeps its task-specific layers — workspace +node_modules/.binscope check, cwd-relative arg conversion,Arc<AbsolutePath>/Arc<[Str]>return types — and now imports the primitives fromvite_powershell.Why
vite-plus is adding
vite_command::ps1_shim(see voidzero-dev/vite-plus#1489) to fix the same Ctrl+C terminal-corruption symptom for package-manager-routed commands (vp dlx,vp add,vp update, etc.). Without this extraction it would have to copy the constant, the host-discovery LazyLock, and the sibling-.ps1check. With this extraction both task scripts (vite-task) and pm commands (vp) compose the same primitives with their own scope rules.The two callers diverge intentionally and don't share enough to merge into one helper:
(Arc<AbsolutePath>, Arc<[Str]>)with cwd-relative.ps1paths because the args become part of the task graph's spawn fingerprint and must stay portable across machines.vite_command) produces(AbsolutePathBuf, Vec<OsString>)with absolute.ps1paths because there's no cache fingerprint at spawn time.Test plan
cargo test -p vite_powershell— 5 new tests pass (sibling found, case-insensitive.CMD, no-sibling, non-.cmd, no-extension)cargo test -p vite_task_plan— 39 unit + 45 integration tests pass; the existing rewrite snapshot tests are preservedcargo clippy -p vite_powershell -p vite_task_plan --all-targets— cleanvite_command::ps1_shimto depend onvite_powershellonce this lands and a new vite-task SHA is pinnedNote
Low Risk
Mostly a dependency extraction/refactor with tests; behavior should remain the same aside from potential edge-case differences in
.cmd/.ps1detection on Windows.Overview
Extracts the Windows
.cmd→.ps1PowerShell-shim primitives into a newvite_powershellcrate, including thePOWERSHELL_PREFIXargs, cachedpwsh.exe/powershell.exehost discovery, and sibling-.ps1lookup.Updates
vite_task_plan::ps1_shimto depend on and call these shared helpers while keeping its workspace/node_modules/.binscoping and cwd-relative argument rewrite logic, and adds unit tests for the new crate. WorkspaceCargo.toml/Cargo.lockare updated to include the new crate and dependency.Reviewed by Cursor Bugbot for commit 1e2b791. Configure here.