-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(manger/npm): apply config.npmrc during extraction, not in post-update #19812
Conversation
Another approach I thought of to fix this would be to always set the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a unit test
that would probably the better solution. |
It shall be done.
Agreed, I just wasn't entirely sure how to do that, but doing the other approach would make that easier as well I think. |
Force-pushed because this is a complete rewrite of the patch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good so far. please create some sample repos to do some real tests. this change is risky to break something.
What do you mean by that? I didn't see any repos as part of the test suite, did I miss something? EDIT: If you mean that I should test it on real repos, I have done that. I tested extensively against our private repo before pushing the changes, and I have confirmed that it fixes the issue described in #12891, and that the |
yes, real repo tests was my intention. thanks for confirming. |
🎉 This PR is included in version 34.107.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Changes
This moves the application of the global
npmrc
config option from thepost-update
phase to theextract
phase.Context
Sub-packages in monorepos sometimes have their own
.npmrc
files. These should not be shared between packages. This fixes a particularly nasty bug, reported in #12891.Here's what is actually happening to cause #12891:
foo
andbar
.npmrc
file tofoo
with the contentslegacy-peer-deps=true
foo
When Renovate runs it will execute
branchifyUpgrades()
, which, in turn, callsflattenUpdates
, which will return a branch config object with{ npmrc: "legacy-peer-deps=true" }
. Later on in the process that config is passed towriteExistingFiles
for each package, which dutifully creates a.npmrc
file withlegacy-peer-deps=true
in each subpackage. This is the real bug, since nowlegacy-peer-deps
has been turned on for packagebar
, even though it's only defined infoo
. Then, when the updates are finished Renovate runslerna bootstrap
to update the lockfiles. When Lerna runs withlegacy-peer-deps=true
it regenerates the lock files, likely because the dependency resolution graph is different since it can meet peer requirements more easily.To fix this issue, we now apple the
npmrc
config when extracting per-package-file configs, and write the result to diskwriteExistingFiles
.Closes #12891
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via: