-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat: replace deprecated dependencies with their replacements #5558
Conversation
Shouldn't we do this in a more general way, so we can support all managers? Moving the deprecation list to presets is fine for me. But how to manage them? Maybe we can do this as a comunity preset too, like for the docker image regex versioning? renovatebot/presets#44 |
I'll just start by saying there's demons in these lands! I hit so many edge cases when I started this previously that I stopped, although our code has improved a lot since then. Use cases:
Nice to support:
Logically, "renaming" feels similar to "pinning", in that it might exist independently of upgrade PRs that also co-exist. e.g. then @JamieMagee any particular "design decisions" you want to discuss? |
@viceice You mean something like not tying it to the deprecation message (currently only supported in npm and cargo), and instead just doing the check for deprecation somewhere like https://github.com/renovatebot/renovate/blob/master/lib/datasource/index.ts#L37-L39 The deprecation list would have to be manually managed, similar to how the group presets are done right now. Can you show me what you mean by the docker regex? @rarkins Haha, yeah I've been trying to go through a lot of the backlog recently and fix a lot of issues that have been open for a long time. In my opinion this one could bring a lot of value. The design decision I wanted to discuss were around how the renaming and version change would work. I think I can cover your 2 use cases (somewhat). My idea is that whenever we define a dependency replacement, we have to define the new package name, and new package version. The new package version should be the lowest stable version of the replacement package, in order to minimise the possibility of breaking changes. Subsequent runs of Renovate can then update the replacement package versions. A psuedo-code version would look something like {
'jade': {
'name': 'pug',
'version': '2.0.0'
},
... I think this might also cover your 'nice-to-have' use case as well, although it's not the main priority. |
@JamieMagee yes, we want to add some comunity presets with rules eg from renovatebot/config-help#529. so we can also add custom deprecation rules there too. So we can deprecate packages for any datasource, if a rule forces this. |
@JamieMagee defining the minimum dependency you can switch to would be good. Renovate could apply logic like for vulnerability alerts currently where it deliberately picks the first satisfying version, i.e. the minimum risk. BTW ideally:
|
044baaa
to
917fac2
Compare
So with the new changes, the rules are now "packageRules": {
"packageNames": ["jade"],
"replacementName": "pug",
"replacementVersion": "2.0.0"
} I think this is as generic as I can make it. Managers will still need to handle the actual replacement in |
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.
With new generic replacement it should work for all new managers an those ported to simple replacement.
Yeah, and we can backport the functionality to the other managers as required. I'm almost certain that npm will be ~50% of use cases though 😄 |
This would be helpful for #5667 |
917fac2
to
c242686
Compare
Okay, so I think I have a dependency cycle somewhere 🤦 |
c242686
to
63a4d67
Compare
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.
Needs coverage fixes.
779a6ac
to
cc5e078
Compare
9048f60
to
bd1bec4
Compare
86ebf22
to
cc7d8d0
Compare
@JamieMagee Sorry, I need some time to think if this has unintended consequences for my plans for autoReplace and refactoring of updates in general. Let's not merge quite yet. |
@rarkins no worries. I'll move this back to draft for now. |
cc7d8d0
to
a8752ec
Compare
Squashed all the commits to make rebasing/merging with updated main easier in the future. Moving this PR to draft. |
6515576
to
9d96003
Compare
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.
Otherwiese LGTM
I think this PR also resolves issue #3339? |
I agree. I've added it to the list of issues this PR closes. |
@rarkins there is still 1 unresolved comment, but I can't actually get to it from the GitHub UI 🤔 |
I think that's because the commit is gone from the branch, and GitHub can't find the correct place to display the unresolved comment. |
found and resolved, you need to check the hidden pr comments 😉 |
@rarkins Looks like we're ready for merge with this 🤯 |
🎉 This PR is included in version 29.6.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Is this something you would be able to consume from npm eventually? If people were to start providing this in their package.json when they are deprecating a package? |
@voxpelli in theory yes, but in practice I think that the volume of deprecations is reasonably low and so maintaining the list in presets is pretty manageable |
Changes:
Initial PR to add deprecated dependency replacement to Renovate.
This PR includes:
replacement
replacementName
andreplacementVersion
, designed to be used inpackageRules
newName
property in a few places, that's used in conjunction with the existingnewVersion
A small refactoring in thenpm
managerto extract twice repeated logic, instead of repeating it a third timeSee refactor(npm): extract replacement to a private function #11195See JamieMagee/renovate-deprecation-replacements#8 for a sample PR
Context:
Closes #2223
Closes #5535
Closes #3339
Documentation (please check one with an [x])
How I've tested my work (please tick one)
I have verified these changes via: