Skip to content
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

Merged
merged 5 commits into from
Nov 12, 2021

Conversation

JamieMagee
Copy link
Contributor

@JamieMagee JamieMagee commented Feb 23, 2020

Changes:

Initial PR to add deprecated dependency replacement to Renovate.

This PR includes:

See JamieMagee/renovate-deprecation-replacements#8 for a sample PR

Context:

Closes #2223
Closes #5535
Closes #3339

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added unit tests, or
  • No new tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@JamieMagee
Copy link
Contributor Author

@rarkins @viceice The implementation isn't ready for review yet, but I would appreciate your input on the design.

@viceice
Copy link
Member

viceice commented Feb 24, 2020

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

@rarkins
Copy link
Collaborator

rarkins commented Feb 24, 2020

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:

  • Package X got renamed to Y, and & started numbering at the same or earlier version that X got stopped at (change package name only, assuming X is up to date)
  • Package X got renamed to Y, but Y started numbering after (needs to be both a rename and an upgrade)

Nice to support:

  • "we want to replace all Docker Hub library images with our internal equivalent, e.g. node with mycompany/node. Easiest if we simply ignore versions/tags here, let it be their problem not our problem.. but it could cause problems if there isn't a match.

Logically, "renaming" feels similar to "pinning", in that it might exist independently of upgrade PRs that also co-exist. e.g. then updateType could be "replaceDep" for example.

@JamieMagee any particular "design decisions" you want to discuss?

@JamieMagee
Copy link
Contributor Author

@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.

@viceice
Copy link
Member

viceice commented Feb 25, 2020

@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.

@rarkins
Copy link
Collaborator

rarkins commented Feb 25, 2020

@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:

  • As few new config options added as possible
  • Make it packageRule-able so that any "community" mappings could be moved into a community preset, consisting of essentially just regular packageRules, meanwhile people with their own custom rules (such as moving from a public Docker Hub image to their own custom ones) could also use very similar package rules

@JamieMagee JamieMagee force-pushed the feat/replace-deprecated-dependencies branch from 044baaa to 917fac2 Compare March 2, 2020 20:36
@JamieMagee
Copy link
Contributor Author

So with the new changes, the rules are now packageRule-able. So for my example above it would be

"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 updateDependency()

Copy link
Member

@viceice viceice left a 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.

@JamieMagee
Copy link
Contributor Author

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 😄

@ChristianMurphy
Copy link
Contributor

With new generic replacement it should work for all new managers an those ported to simple replacement

This would be helpful for #5667

@JamieMagee JamieMagee force-pushed the feat/replace-deprecated-dependencies branch from 917fac2 to c242686 Compare March 9, 2020 20:45
@JamieMagee
Copy link
Contributor Author

Okay, so I think I have a dependency cycle somewhere 🤦

@JamieMagee JamieMagee force-pushed the feat/replace-deprecated-dependencies branch from c242686 to 63a4d67 Compare March 10, 2020 15:56
@JamieMagee JamieMagee marked this pull request as ready for review March 19, 2020 20:06
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

Needs coverage fixes.

@JamieMagee JamieMagee force-pushed the feat/replace-deprecated-dependencies branch 2 times, most recently from 779a6ac to cc5e078 Compare March 30, 2020 20:05
@JamieMagee JamieMagee force-pushed the feat/replace-deprecated-dependencies branch 2 times, most recently from 9048f60 to bd1bec4 Compare April 8, 2020 18:11
@JamieMagee
Copy link
Contributor Author

@rarkins Trying my best to get the number of PRs down 👍

Sample PR here.

Ready for further review (maybe even merge!)

@JamieMagee JamieMagee requested a review from viceice April 8, 2020 18:46
lib/datasource/index.ts Outdated Show resolved Hide resolved
@JamieMagee JamieMagee force-pushed the feat/replace-deprecated-dependencies branch from 86ebf22 to cc7d8d0 Compare April 9, 2020 14:21
@rarkins
Copy link
Collaborator

rarkins commented Apr 9, 2020

@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.

@JamieMagee
Copy link
Contributor Author

@rarkins no worries. I'll move this back to draft for now.

@JamieMagee JamieMagee force-pushed the feat/replace-deprecated-dependencies branch from cc7d8d0 to a8752ec Compare April 10, 2020 14:20
@JamieMagee
Copy link
Contributor Author

JamieMagee commented Apr 10, 2020

Squashed all the commits to make rebasing/merging with updated main easier in the future. Moving this PR to draft.

@JamieMagee JamieMagee marked this pull request as draft April 10, 2020 14:22
@JamieMagee JamieMagee force-pushed the feat/replace-deprecated-dependencies branch from 6515576 to 9d96003 Compare November 10, 2021 03:50
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

Otherwiese LGTM

lib/manager/npm/update/dependency/index.ts Show resolved Hide resolved
@HonkingGoose
Copy link
Collaborator

I think this PR also resolves issue #3339?

@JamieMagee
Copy link
Contributor Author

I think this PR also resolves issue #3339?

I agree. I've added it to the list of issues this PR closes.

@JamieMagee JamieMagee requested a review from viceice November 11, 2021 05:34
@JamieMagee
Copy link
Contributor Author

@rarkins there is still 1 unresolved comment, but I can't actually get to it from the GitHub UI 🤔

@HonkingGoose
Copy link
Collaborator

@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.

@viceice
Copy link
Member

viceice commented Nov 11, 2021

@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 😉

@JamieMagee
Copy link
Contributor Author

@rarkins Looks like we're ready for merge with this 🤯

@JamieMagee JamieMagee enabled auto-merge (squash) November 11, 2021 23:07
@JamieMagee JamieMagee merged commit 98e7029 into main Nov 12, 2021
@JamieMagee JamieMagee deleted the feat/replace-deprecated-dependencies branch November 12, 2021 08:10
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 29.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@voxpelli
Copy link

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?

@rarkins
Copy link
Collaborator

rarkins commented Nov 12, 2021

@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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
10 participants