-
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
Enable config migration by default #16359
Comments
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
I think we should first try to get more use of this feature by prompting people in the dependency dashboard that to open the migration PR "on demand": #19783 |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I don't think this is ready until we can reduce the amount of unnecessary formatting changes, e.g. https://github.com/renovate-reproductions/migrate1/pull/2/files The amount of green/red makes it hard to see the actual changes |
The good news is that adding a Bad news is that doesn't fix for non-prettier cases |
fixing that without knowledge about the current formatting (like prettier) is pretty much impossible. |
You would need to parse the JSON while persisting formatting data, you could maybe use |
Another idea: parse the git diff output, then compare chunk by chunk. Parse each removed/added chunk and if they are equal then revert that change. A challenge would be where multiple changes are adjacent because then git groups them together. |
I would think that's acceptable on the first enable of the migration, and after that the formatting and migrations would be kept up to date by smaller trivial PRs. That said, I would love to option to keep my JSON formatting style and if adding a config for it is the way, then be it, but I wouldn't want it to affect JSON files other than than Renovate config, if that's possible. I like @voxpelli's approach, clean and targeted. Keep in mind JSON5 and other formats though. |
@rarkins would adding the prettierrc temporarily in the clone, without actually committing it, work? |
There's this parser from @ota-meshi that supports JSON5, JSONC and plain JSON: https://github.com/ota-meshi/jsonc-eslint-parser Though it seems to currently only do parsing, not serializing. Ideally there would be a JSON Patch library built on top of such a white-space preserved AST and then a serialization of that AST. |
Sorry for the spam here, but I did some more searching and found this module by @noahsug which seems to do the trick: https://www.npmjs.com/package/json5-writer It didn't like Should be possible to make use of without that many adaptions either. |
@TWiStErRob unfortunately not a good idea to do that by default either, because most repos don't use prettier styling (especially if not from the JS ecosystem). While we could try to detect if a repo's config looks like it's prettier-formatted, I think it's reasonable for Renovate to look for any prettier config file instead. |
@voxpelli I like the idea of that library, but it's got some major challenges before we could adopt it:
|
@rarkins My belief is that you can give the full modified JS object to But yeah, would probably need to be forked and self-published unless the original author shows up. |
Adapting their example in this repo:
It resulted in the renovate.json being fully wiped and only the new data remaining. If simply reading and writing it (i.e. dropping the |
@rarkins Either providing values for all keys, or values for all updates keys and setting the rest as |
So is their example in the README flawed? Why read in a file if you'll just blindly override it. |
If you look at the diff after the example code you can see that their But yes, one can argue that the example could be better and likewise the API, but it could be a good start 😌 I still think the ideal solution would be a JSON Patch library built on top of a white-space preserving AST they can then be serialized, but I also think that could be way out of scope for you to build here and that module was the closest my googling skills could find. |
FWIW: I for one am far less concerned with unwanted but easily remedied formatting changes (assuming my project is set up with linters and formatters to begin with wink 😉) than I am with my devs getting config migration proposals. |
Let's add this in the next major (v38) |
@rarkins earlier you said you wanted issue #19783 done before making config migration the default:
I guess #19783 is not blocking this issue anymore, because you removed the Just checking if we're really good to go to make config migration the default behavior soon. 😄 |
Yes, I think we can |
I also notice that Config migration PRs removes any existing Json 5 comments in the existing config file, see https://github.com/orange-cloudfoundry/k3s-packages-boshrelease/pull/87/files#diff-31b1aa2b93afe11792d84c6cb5057a064b5a3294fa0caab92d7570ea604f759f This therefore requires manual merge of this change to restore json5 comments |
To summarize, I think we want to work on these issues before we start on the main issue?
I see users opening discussions and referring to old names ( It would be easier for us if Renovate users always used up-to-date terms and presets. Also it's easier for users to debug themselves when config and docs match. I'll let the maintainers decide what we need to do, and when. |
Marking this as blocked as should enable opt-in via dashboard first |
What would you like Renovate to be able to do?
Right now users can opt-in to get config migration PRs by setting
configMigration=true
. I propose we make getting config migration PRs the default behavior for all users.Benefits:
Drawbacks:
Opting out by users
Users can opt-out of this new feature by setting
configMigration=false
in their repository'srenovate.json
. Organizations can opt-out via their global.github/renovate
repository.If you have any ideas on how this should be implemented, please tell us here.
Maybe add
configMigration=true
to ourconfig:recommended
andconfig:best-practice
presets? Or maybe you want to hard-code this in deeper in the code?Related issues
We may want to finish these before making config migration the default behavior:
applyPrettierFormatting
to later in code #17336extends
#21456configMigration
feature on our own repositories, make sure it's good and bug-freeIs this a feature you are interested in implementing yourself?
No
The text was updated successfully, but these errors were encountered: