Skip to content

feat: add global install/uninstall support (vlt install -g)#1570

Draft
vltbaudbot wants to merge 8 commits into
vltpkg:mainfrom
vltbaudbot:feat/global-install
Draft

feat: add global install/uninstall support (vlt install -g)#1570
vltbaudbot wants to merge 8 commits into
vltpkg:mainfrom
vltbaudbot:feat/global-install

Conversation

@vltbaudbot

Copy link
Copy Markdown
Contributor

Summary

Add --global / -g flag to vlt install, vlt uninstall, and vlt list commands, enabling global package management similar to npm install -g.

Closes #1567

What this PR does

New --global / -g CLI flag

  • Boolean flag added to the jackspeak config definition with short alias -g
  • When set, operations target the global package directory instead of the current project

Global store directory

  • Uses @vltpkg/xdg for platform-appropriate paths:
    • Linux: ~/.local/share/vlt/global/
    • macOS: ~/Library/Application Support/vlt/global/
    • Windows: %APPDATA%/xdg.data/vlt/global/
  • Auto-initializes with a minimal package.json on first use
  • Reuses the existing install machinery — no changes needed to @vltpkg/graph

Binary linking

  • After global install, scans installed packages for bin entries
  • Creates cross-platform shims via @vltpkg/cmd-shim in the global bin directory (~/.local/share/vlt/bin/)
  • After global uninstall, removes stale bin shims whose targets no longer exist
  • Prints a PATH hint if the global bin directory is not on the user's PATH

Architecture

The key insight is that --global simply redirects projectRoot to the global directory via Config.resetOptions(). The existing install/uninstall pipeline handles everything else. The new src/cli-sdk/src/global.ts module handles:

  • ensureGlobalProject() — create global dir + package.json
  • applyGlobalConfig() — redirect config's projectRoot
  • linkGlobalBins() — create bin shims after install
  • unlinkRemovedBins() — clean up bin shims after uninstall
  • checkPathHint() — warn user if bin dir not on PATH

Commands supported

  • vlt install -g <pkg> — install globally
  • vlt uninstall -g <pkg> — uninstall globally
  • vlt list -g — list globally installed packages

Files changed

  • src/cli-sdk/package.json — added @vltpkg/cmd-shim dependency
  • src/cli-sdk/src/config/definition.ts — added --global flag
  • src/cli-sdk/src/global.ts — new global utilities module
  • src/cli-sdk/src/commands/install.ts — global install + bin linking
  • src/cli-sdk/src/commands/uninstall.ts — global uninstall + bin cleanup
  • src/cli-sdk/src/commands/list.ts — global list support
  • Tests and snapshots updated accordingly

Future work (not in this PR)

  • vlt self-update edge cases
  • Global vlt build for packages with install scripts

Add --global / -g flag to install, uninstall, and list commands.
When set, operations target a global package directory (XDG data path)
instead of the current project. Package binaries are linked to a
global bin directory using cmd-shim for cross-platform support.

- Add --global boolean flag with short alias -g to config definition
- Create src/cli-sdk/src/global.ts with global project management:
  - ensureGlobalProject: auto-init global dir with package.json
  - applyGlobalConfig: redirect projectRoot to global dir
  - linkGlobalBins: link package bins to global bin dir after install
  - unlinkRemovedBins: clean up bin shims after uninstall
  - checkPathHint: warn if global bin dir is not on PATH
- Update install command to link bins after global install
- Update uninstall command to clean bins after global uninstall
- Update list command to show global packages with -g
- Add @vltpkg/cmd-shim dependency to cli-sdk
- Add tests for global.ts and command integration
- Update snapshots for new --global option in usage output

Closes vltpkg#1567

Co-authored-by: Darcy Clarke <[email protected]>
@vercel

vercel Bot commented Mar 27, 2026

Copy link
Copy Markdown

@vltbaudbot is attempting to deploy a commit to the vlt Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Mar 27, 2026

Copy link
Copy Markdown

🐰 Bencher Report

Branchfeat/global-install
Testbedubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
vlt install: vue & cache-lockfile📈 view plot
🚷 view threshold
7,970.42 ms
(-8.49%)Baseline: 8,709.44 ms
9,580.38 ms
(83.20%)
vlt install: vue & cache-lockfile-node-modules📈 view plot
🚷 view threshold
455.16 ms
(-3.17%)Baseline: 470.07 ms
517.08 ms
(88.03%)
vlt install: vue & clean📈 view plot
🚷 view threshold
15,254.68 ms
(-9.01%)Baseline: 16,765.55 ms
18,442.10 ms
(82.72%)
vlt install: vue & lockfile📈 view plot
🚷 view threshold
8,746.15 ms
(-2.90%)Baseline: 9,006.93 ms
9,907.62 ms
(88.28%)
🐰 View full continuous benchmarking report in Bencher

vltbaudbot and others added 7 commits March 27, 2026 22:20
- Use RegExp#exec() instead of String#match()
- Use const for never-reassigned arrays
- Remove unused installLog variable

Co-authored-by: Darcy Clarke <[email protected]>
- Rewrite test/global.ts with comprehensive coverage (100% statements)
- Add tests for linkGlobalBins, readBins, and edge cases
- Fix Windows PATH comparison by using resolve() normalization
- Add c8 ignore comments for unreachable error handlers
- Use isolated testdir per test to avoid state leaks

Co-authored-by: Darcy Clarke <[email protected]>
- Add --global to sorted options in index.ts test snapshot
- Use platform-appropriate PATH separator (: vs ;) in test

Co-authored-by: Darcy Clarke <[email protected]>
- Extract regex match result to variable for proper type narrowing
- Add c8 ignore for Windows-only absolute path branch

Co-authored-by: Darcy Clarke <[email protected]>
The global config branch in list.ts wasn't covered by
the existing list tests. Add c8 ignore since the global
functionality is thoroughly tested in install/uninstall
command tests and test/global.ts.

Co-authored-by: Darcy Clarke <[email protected]>
@darcyclarke darcyclarke added feature feature or request needs-discussion is pending a discussion cli cli specific issues Release 1.0.0 related to/blocker of the v1.0.0 release needs-further-review labels May 7, 2026
@darcyclarke darcyclarke self-assigned this May 7, 2026
@darcyclarke darcyclarke marked this pull request as draft June 3, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli cli specific issues feature feature or request needs-discussion is pending a discussion needs-further-review Release 1.0.0 related to/blocker of the v1.0.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add global install option

2 participants