Ignore invalid unrelated package.json fields in JS detection - #161
Closed
tomdale wants to merge 1 commit into
Closed
Ignore invalid unrelated package.json fields in JS detection#161tomdale wants to merge 1 commit into
tomdale wants to merge 1 commit into
Conversation
Parse package.json as raw JSON during JavaScript tool version detection so unrelated malformed version fields do not prevent valid Node, Bun, or package manager fields from being discovered. Add pnpm coverage for the moonrepo#159 regression and devEngines packageManager arrays. Fixes moonrepo#159
Contributor
|
Thanks for the contribution, but I'd rather just fix |
Contributor
|
@tomdale Patched here if you want to pull it in milesj/rust-js-ecosystem#30 Edit: actually bumping here #162 |
Author
|
Thank you! |
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
JavaScript tool version detection reads several
package.jsonfields in priority order, includingdevEngines,packageManager, Volta, andengines. The detection path parsed the entire manifest throughnodejs_package_json::PackageJsonbefore looking at those individual fields, so one malformed version-like field could prevent discovery from reaching an unrelated valid field.This PR changes detection to parse
package.jsonas raw JSON first, then extract only the candidate strings relevant to the active tool. Node, Bun, and node-depman keep their existing source precedence, and the selected candidate is still parsed throughUnresolvedVersionSpec, so malformed authoritative values for the active tool still fail.The shared extraction covers
devEnginesobject and array forms,engines,packageManagervalues with Corepack hashes, and Volta includingextends. The affected crates no longer depend directly onnodejs_package_jsonfor detection.Fixes #159.
Verification
cargo build -p node_tool -p node_depman_tool -p bun_tool --target wasm32-wasip1cargo test -p node_tool --no-default-features --test versions_testcargo test -p node_depman_tool --no-default-features --test versions_testcargo test -p bun_tool --no-default-features --test versions_test