Skip to content

refactor(foundryup): adopt @metamask/local-node-utils (tentative)#9239

Open
ulissesferreira wants to merge 2 commits into
solana-test-validator-up-use-local-node-utilsfrom
foundryup-use-local-node-utils
Open

refactor(foundryup): adopt @metamask/local-node-utils (tentative)#9239
ulissesferreira wants to merge 2 commits into
solana-test-validator-up-use-local-node-utilsfrom
foundryup-use-local-node-utils

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Tentative preview of how @metamask/foundryup could 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:

  • getMetamaskCacheDirectory replaces duplicated .yarnrc.yml cache resolution
  • cleanInstallerCache scopes cache clean to a foundryup namespace (instead of wiping the entire MetaMask cache)
  • isFileMissingError replaces inline ENOENT checks
  • Cache artifacts are stored under {cache}/foundryup/{key}, matching the namespaced layout used by *-up packages

Intentionally not migrated (foundryup-specific today):

  • Streaming download (startDownload with agents, HEAD/range requests for zip)
  • Selective tar/zip extraction with per-binary checksums (tar + unzipper)
  • Symlink/copy installation into node_modules/.bin (vs Node wrapper scripts)
  • Dynamic GitHub release URL construction (vs pinned ArtifactConfig per platform)
  • normalizeSystemArchitecture returning amd64/arm64 enums (vs x64/arm64 platform keys)

Compatibility assessment

local-node-utils API *-up packages foundryup
getMetamaskCacheDirectory ✅ adopted ✅ adopted in this PR
cleanInstallerCache ✅ adopted ✅ adopted in this PR
mergeArtifactConfig / resolvePlatformConfig ✅ adopted ❌ uses yargs + dynamic URLs
downloadFileFromUrl ✅ adopted ❌ needs streaming/range downloads
extractTarGzArchive / extractTarBz2Archive ✅ adopted ❌ needs selective binary extraction + zip
installExecutableWrapper ✅ adopted ❌ uses symlinks/copies
getPlatformKey / normalizeSystemArchitecture ✅ adopted ⚠️ partial — Rosetta logic matches, but arch naming differs (x64 vs amd64)

Conclusion: local-node-utils is a strong fit for the non-EVM *-up installer pattern (pinned artifacts, full-archive extract, Node wrappers). foundryup can share cache/error helpers today; deeper unification would require extending local-node-utils (e.g. zip extraction, streaming downloads, symlink install) or accepting foundryup as a specialized consumer.

Test plan

  • yarn workspace @metamask/foundryup run test
  • yarn workspace @metamask/foundryup run build
  • yarn workspace @metamask/foundryup run changelog:validate

Note

Medium Risk
Cache path and cache clean semantics 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/foundryup now depends on @metamask/local-node-utils for shared MetaMask installer infrastructure instead of local copies of the same logic.

Cache resolution goes through getMetamaskCacheDirectory (with toolName: foundryup), so inline .yarnrc.yml parsing and the direct yaml dependency are removed. Cache clean uses cleanInstallerCache and only deletes the foundryup subtree 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 *-up packages; existing entries at the old path will not be reused until re-downloaded.

Missing-cache handling uses isFileMissingError instead of hand-rolled ENOENT checks. Tests were updated to exercise real temp .yarnrc.yml files and to assert namespaced clean/rm behavior.

Reviewed by Cursor Bugbot for commit a77d669. Bugbot is set up for automated code reviews on this repo. Configure here.

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.
@ulissesferreira ulissesferreira requested review from a team as code owners June 23, 2026 13:46

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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());
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a77d669. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant