feat: remove VP_HOME and default installers to the split XDG layout - #2349
Closed
forehalo wants to merge 5 commits into
Closed
feat: remove VP_HOME and default installers to the split XDG layout#2349forehalo wants to merge 5 commits into
forehalo wants to merge 5 commits into
Conversation
Add vp_shared::Dirs as the single owner of on-disk placement decisions. An internal DirsInner enum selects the layout once per resolution (first match wins): - Home (legacy monolithic root): VP_HOME is set, the vp binary self-locates at <root>/current/bin/vp, a legacy layout is found on PATH, or ~/.vite-plus exists on disk. Existing installs keep working untouched, byte-identical paths. - Custom (split XDG layout, fresh installs): each category resolves through its own VP_*_DIR override -> XDG_* -> platform-default chain (bin: VP_BIN_DIR -> XDG_BIN_HOME -> XDG_DATA_HOME/../bin -> ~/.local/bin, mirroring uv). Only VP_BIN_DIR/VP_DATA_DIR/VP_CACHE_DIR exist as dedicated overrides; config and state rely on XDG_CONFIG_HOME / XDG_STATE_HOME. Relative values are ignored per the spec. XDG_* names are defined alongside vp's own variables in env_vars.rs, but only vp_* path overrides live in EnvConfig; Dirs reads XDG vars itself behind an injectable, parallel-safe resolution core (no env mutation or serial_test anywhere in Dirs tests; test helpers live in a #[cfg(test)] impl block, and cross-crate tests sandbox through EnvConfig::for_test_with_home). Migrate every Rust call site to Dirs category accessors and named helpers, delete get_vp_home() and the home.rs module (folded into dirs.rs), and drop per-crate wrapper helpers so Dirs is the sole path source. bins/*.json metadata moves to the data category. On the TS side, the global CLI injects the resolved VP_BIN_DIR / VP_DATA_DIR / VP_CACHE_DIR into JS child processes under the split layout only (never overriding user-set vars); org-tarball.ts prefers VP_CACHE_DIR; generated git hook scripts fall back through VP_BIN_DIR, VP_HOME/bin, ~/.vite-plus/bin, ~/.local/bin. VP_HOME, the installers, and the generated env* shell scripts are unchanged in behavior: fresh installs still land in ~/.vite-plus, so the split layout is opt-in via VP_*_DIR/XDG until the follow-up stack removes the legacy variables and switches installer defaults. Groundwork for voidzero-dev#827.
The CLI no longer reads VP_HOME. Custom-location installs are located without it, via (in priority order): executable self-location (<root>/current/bin/vp, covering IDE and trampoline launches), legacy PATH inference, and the grandfathered ~/.vite-plus existence check. The Windows trampoline and vp_installer no longer set VP_HOME for child processes; the snapshot runner keeps injecting it only for generated env scripts and fixtures that still reference it (removed with the installer cutover later in this stack).
Make the split XDG layout fully functional for fresh installs: - dirs.rs: layout detection now distinguishes legacy from split installs via a DetectedLayout enum. Both executable self-location and PATH inference canonicalize into the <X>/current/bin/vp shape and classify: <X>/bin/vp exists -> legacy root, otherwise X is the split data dir (pinning the data category to the running binary's payload). - env setup scripts no longer export VP_HOME; they prepend the resolved bin dir only. vp-use.cmd gains the split-layout fallback path. - The Windows trampoline locates vp.exe at ../current/bin (legacy) or ../data/current/bin (split). - vp implode removes the split layout: data/config/state/cache dirs plus only the vp-owned shim names from the bin dir (a shared ~/.local/bin is never removed), and strips profile lines referencing the env-scripts dir. - vp_installer resolves an InstallLayout (install/bin/env-scripts dirs) from Dirs, creates the bin wrapper in the resolved bin dir, and prints split-aware PATH guidance. Explicit --install-dir/VP_HOME still selects the legacy layout for compatibility.
install.sh and install.ps1 now install fresh setups into the split layout: versions and the current symlink under the data dir (~/.local/share/vite-plus, %LOCALAPPDATA%\vite-plus\data), the vp wrapper and shims in the bin dir (~/.local/bin, %LOCALAPPDATA%\vite-plus \bin), and env scripts in the config dir (~/.config/vite-plus, %APPDATA%\vite-plus). Explicit VP_HOME/--install-dir or an existing ~/.vite-plus keeps the legacy monolithic layout, so upgrades of existing installs continue in place. Relative XDG values are ignored per spec. The Dockerfile drops VP_HOME and uses the split layout. Docs now describe the split layout as the fresh-install default, VP_HOME as an installer-only override, and implode as handling both layouts. The snapshot runner keeps injecting VP_HOME because fixtures expand it in vpt argv.
The snapshot runner now provisions the complete legacy install shape (bin/vp alongside current/bin/vp) so layout detection classifies the case home as a legacy install before vp env setup regenerates shims. Two fixtures targeted isolated installs through per-step VP_HOME, which the CLI no longer reads. They now model the same isolation with real on-disk layouts: the corepack fixture builds an isolated legacy install at home/.vite-plus and drives it through its own binary, and the external-vp fixture uses a full second legacy install at external/, asserting env setup self-locates and links shims into the invoking install. The git-hooks migration snapshot picks up the new hook-script PATH fallback chain (VP_BIN_DIR first, ~/.local/bin last).
✅ Deploy Preview for viteplus-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
Author
|
Consolidated into #2346 — the stack is now a single PR: the Dirs abstraction commit plus the squashed installer-cutover commit (with VP_HOME kept as DEPRECATED_VP_HOME instead of removed outright). |
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.
Stacked on #2346 — only the top 4 commits are new. Close #827 on merge of this stack.
Summary
Flips fresh installs to the split XDG layout and removes the
VP_HOMEvariable, completing #827. Existing installs are untouched: a legacy monolithic root is still detected (executable self-location,PATHinference, or an existing~/.vite-plus) and keeps working byte-for-byte.Commit 1: remove
VP_HOMEThe CLI no longer reads
VP_HOME. Custom-location installs are located without it via executable self-location (<root>/current/bin/vp, covering IDE and trampoline launches), legacyPATHinference, and the grandfathered~/.vite-pluscheck. The Windows trampoline andvp_installerstop setting it.Commit 2: split-aware detection, env scripts, implode, installer core
dirs.rs: detection now distinguishes legacy from split installs via aDetectedLayoutenum — a<X>/current/bin/vpshape classifies as legacy when<X>/bin/vpexists, otherwise as a split install whose data dir isX(pinning data to the running binary's payload).PATHinference canonicalizesvpentries through the same shape check.env/env.fish/env.nu/env.ps1no longer exportVP_HOME; they only prepend the resolved bin dir.vp-use.cmdgains the split fallback path.vp.exeat../current/bin(legacy) or../data/current/bin(split).vp imploderemoves the split layout: data/config/state/cache dirs plus only the vp-owned shim names from the bin dir — a shared~/.local/binand foreign files are never touched. Profile stripping catches the env-scripts dir in both layouts.vp_installerresolves anInstallLayoutfromDirs, creates the bin wrapper in the resolved bin dir, and prints split-aware guidance. Explicit--install-dir/VP_HOMEstill selects the legacy layout.Commit 3: installers default to the split layout
install.sh/install.ps1: fresh installs place versions +currentunder the data dir (~/.local/share/vite-plus,%LOCALAPPDATA%\vite-plus\data), thevpwrapper and shims in the bin dir (~/.local/bin,%LOCALAPPDATA%\vite-plus\bin), and env scripts in the config dir (~/.config/vite-plus,%APPDATA%\vite-plus). ExplicitVP_HOMEor an existing~/.vite-pluskeeps the legacy layout, so re-running the installer upgrades existing installs in place. Relative XDG values are ignored per spec.VP_HOMEand uses the split layout.VP_HOMEas an installer-only override.Commit 4: snapshot fixtures
bin/vpalongsidecurrent/bin/vp) so detection classifies case homes as legacy installs.VP_HOMEnow model the same isolation with real on-disk layouts driven through their own binaries (self-location).Migration impact
~/.vite-plusinstalls: zero impact (grandfathered; detection is byte-identical in behavior).VP_HOMEinstalls: keep working — the running binary self-locates from its own path. The variable itself is ignored by the CLI and no longer exported by generated env scripts.~/.local/binis the only PATH entry needed.Validation
cargo check/clippy --workspace --all-targets: zero warnings;cargo fmtcleancargo teston all touched crates: green