refactor(foundryup): adopt @metamask/local-node-utils (tentative)#9239
Open
ulissesferreira wants to merge 2 commits into
Open
refactor(foundryup): adopt @metamask/local-node-utils (tentative)#9239ulissesferreira wants to merge 2 commits into
ulissesferreira wants to merge 2 commits into
Conversation
Use shared MetaMask cache directory resolution, namespaced cache layout, and cache-clean utilities from local-node-utils as a tentative preview of how foundryup could align with the *-up installer packages.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a77d669. Configure here.
|
|
||
| afterEach(() => { | ||
| process.chdir(originalCwd()); | ||
| }); |
There was a problem hiding this comment.
Test teardown saves cwd function
Low Severity
The getCacheDirectory suite stores process.cwd (the function) instead of calling it once to capture the starting directory. Each afterEach then invokes that function and chdirs to whatever directory is current—usually the temp dir from the test—so the process working directory is not restored for later tests.
Reviewed by Cursor Bugbot for commit a77d669. Configure here.
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
Tentative preview of how
@metamask/foundryupcould adopt@metamask/local-node-utils, stacked on the local-node-utils series (#9233 → #9234 → #9235–#9237).This PR only migrates the shared infrastructure that maps cleanly today:
getMetamaskCacheDirectoryreplaces duplicated.yarnrc.ymlcache resolutioncleanInstallerCachescopescache cleanto afoundryupnamespace (instead of wiping the entire MetaMask cache)isFileMissingErrorreplaces inlineENOENTchecks{cache}/foundryup/{key}, matching the namespaced layout used by*-uppackagesIntentionally not migrated (foundryup-specific today):
startDownloadwith agents, HEAD/range requests for zip)tar+unzipper)node_modules/.bin(vs Node wrapper scripts)ArtifactConfigper platform)normalizeSystemArchitecturereturningamd64/arm64enums (vsx64/arm64platform keys)Compatibility assessment
local-node-utilsAPI*-uppackagesfoundryupgetMetamaskCacheDirectorycleanInstallerCachemergeArtifactConfig/resolvePlatformConfigdownloadFileFromUrlextractTarGzArchive/extractTarBz2ArchiveinstallExecutableWrappergetPlatformKey/normalizeSystemArchitecturex64vsamd64)Conclusion:
local-node-utilsis a strong fit for the non-EVM*-upinstaller pattern (pinned artifacts, full-archive extract, Node wrappers).foundryupcan share cache/error helpers today; deeper unification would require extendinglocal-node-utils(e.g. zip extraction, streaming downloads, symlink install) or accepting foundryup as a specialized consumer.Test plan
yarn workspace @metamask/foundryup run testyarn workspace @metamask/foundryup run buildyarn workspace @metamask/foundryup run changelog:validateNote
Medium Risk
Cache path and
cache cleansemantics change (namespaced storage and partial wipe vs full cache delete), which can surprise users with old on-disk caches but reduces risk of clearing other installers' artifacts.Overview
@metamask/foundryupnow depends on@metamask/local-node-utilsfor shared MetaMask installer infrastructure instead of local copies of the same logic.Cache resolution goes through
getMetamaskCacheDirectory(withtoolName: foundryup), so inline.yarnrc.ymlparsing and the directyamldependency are removed. Cache clean usescleanInstallerCacheand only deletes thefoundryupsubtree under the MetaMask cache root, rather than recursively removing the entire cache directory. Downloaded artifacts are stored at{cacheRoot}/foundryup/{sha256-key}instead of{cacheRoot}/{key}, aligning with other*-uppackages; existing entries at the old path will not be reused until re-downloaded.Missing-cache handling uses
isFileMissingErrorinstead of hand-rolledENOENTchecks. Tests were updated to exercise real temp.yarnrc.ymlfiles and to assert namespaced clean/rmbehavior.Reviewed by Cursor Bugbot for commit a77d669. Bugbot is set up for automated code reviews on this repo. Configure here.