fix(plugin-npm): limit implicit node-gyp checks to build scripts#7213
Open
ychampion wants to merge 3 commits into
Open
fix(plugin-npm): limit implicit node-gyp checks to build scripts#7213ychampion wants to merge 3 commits into
ychampion wants to merge 3 commits into
Conversation
Member
|
That doesn't work since an install script may reference other scripts |
Author
Looking |
Constraint: Maintainer pointed out install scripts can delegate to other package scripts. Rejected: Only scan preinstall/install/postinstall bodies | Misses install scripts that call build scripts using node-gyp. Confidence: high Scope-risk: narrow Directive: Keep test-only node-gyp references ignored unless an install lifecycle script makes package scripts reachable during install. Tested: corepack yarn jest packages/plugin-npm/tests/NpmSemverResolver.test.ts --runInBand; corepack yarn jest packages/plugin-npm/tests --runInBand; corepack yarn test:lint; corepack yarn constraints; corepack yarn version check; corepack yarn dedupe --check; corepack yarn typecheck:all; YARN_ENABLE_HARDENED_MODE=1 corepack yarn install --immutable --immutable-cache; git diff --check. Not-tested: Netlify docs build, already failing on upstream master for an unrelated schema example issue.
Author
|
Fixed in ae53f78. It now scans all package scripts when an install lifecycle script exists, so Validation:
|
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.
What's the problem this PR addresses?
Closes #3366.
The implicit
node-gypdependency detection scans every package script today, so packages that only mentionnode-gypin non-build scripts can get anode-gypdependency added during resolution.How did you fix it?
The npm semver resolver now checks only the install lifecycle scripts Yarn treats as build scripts:
preinstall,install, andpostinstall.The resolver tests cover both the false-positive non-build script case and the install-script case that should still inject
node-gyp.Validation
corepack yarn jest packages/plugin-npm/tests/NpmSemverResolver.test.ts --runInBandcorepack yarn jest packages/plugin-npm/tests --runInBandcorepack yarn eslint --max-warnings 0 packages/plugin-npm/sources/NpmSemverResolver.ts packages/plugin-npm/tests/NpmSemverResolver.test.tscorepack yarn version checkcorepack yarn typecheck:allgit diff --checkChecklist