feat: add global install/uninstall support (vlt install -g)#1570
Draft
vltbaudbot wants to merge 8 commits into
Draft
feat: add global install/uninstall support (vlt install -g)#1570vltbaudbot wants to merge 8 commits into
vltbaudbot wants to merge 8 commits into
Conversation
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]>
|
@vltbaudbot is attempting to deploy a commit to the vlt Team on Vercel. A member of the Team first needs to authorize it. |
|
| Branch | feat/global-install |
| Testbed | ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark 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%) |
Co-authored-by: Darcy Clarke <[email protected]>
- 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]>
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]>
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
Add
--global/-gflag tovlt install,vlt uninstall, andvlt listcommands, enabling global package management similar tonpm install -g.Closes #1567
What this PR does
New
--global/-gCLI flag-gGlobal store directory
@vltpkg/xdgfor platform-appropriate paths:~/.local/share/vlt/global/~/Library/Application Support/vlt/global/%APPDATA%/xdg.data/vlt/global/package.jsonon first use@vltpkg/graphBinary linking
binentries@vltpkg/cmd-shimin the global bin directory (~/.local/share/vlt/bin/)Architecture
The key insight is that
--globalsimply redirectsprojectRootto the global directory viaConfig.resetOptions(). The existing install/uninstall pipeline handles everything else. The newsrc/cli-sdk/src/global.tsmodule handles:ensureGlobalProject()— create global dir + package.jsonapplyGlobalConfig()— redirect config's projectRootlinkGlobalBins()— create bin shims after installunlinkRemovedBins()— clean up bin shims after uninstallcheckPathHint()— warn user if bin dir not on PATHCommands supported
vlt install -g <pkg>— install globallyvlt uninstall -g <pkg>— uninstall globallyvlt list -g— list globally installed packagesFiles changed
src/cli-sdk/package.json— added@vltpkg/cmd-shimdependencysrc/cli-sdk/src/config/definition.ts— added--globalflagsrc/cli-sdk/src/global.ts— new global utilities modulesrc/cli-sdk/src/commands/install.ts— global install + bin linkingsrc/cli-sdk/src/commands/uninstall.ts— global uninstall + bin cleanupsrc/cli-sdk/src/commands/list.ts— global list supportFuture work (not in this PR)
vltself-update edge casesvlt buildfor packages with install scripts