fix: clean up legacy shim files and stale tmp files on upgrade#934
Merged
fix: clean up legacy shim files and stale tmp files on upgrade#934
Conversation
Add cleanup steps to fetch-adapters.js that run on every version upgrade: 1. Remove legacy compat shim files from ~/.opencli/ (registry.js, errors.js, utils.js, etc.) that were created by an older approach using file:// re-exports. Current approach uses node_modules symlink. Only deletes files containing "export * from 'file://" to avoid removing user-created files. 2. Remove legacy compat shim directories (browser/, download/, errors/, etc.) using the same safety check. 3. Clean up stale .plugins.lock.json.tmp-* files left behind by crashed processes. These accumulate over time (108 found on one machine) and clutter ~/.opencli/.
Instead of checking only the first file and deleting the entire directory, now checks each file individually and only deletes files matching the shim pattern. Directory is removed only if empty after individual file cleanup.
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
Fixes the cluttered
~/.opencli/directory reported by @WAWQAQ. Adds cleanup steps tofetch-adapters.jsthat run on every version upgrade:registry.js,errors.js,utils.js,launcher.js,logger.js,types.jswere created by an older approach usingfile://re-exports. Current approach usesnode_modules/@jackwener/openclisymlink. Safety check: only deletes files containingexport * from 'file://browser/,download/,errors/,launcher/,logger/,pipeline/,registry/,types/,utils/— same safety check.plugins.lock.json.tmp-*files — left behind by crashed processes, accumulating over time (108 found on one machine)All cleanup runs as part of the existing
fetchAdapters()flow, triggered by version change onnpm install -g.Test plan
src/plugin.test.ts— 72 tests passed (lock file logic unchanged)export * from 'file://pattern