fix: do not move packages that are not shared to catalog#6
Conversation
|
Same observation here. This codemod did the exact opposite of what it said it would do. It "catalogged" all the packages that were used once, and none of those used 2+ times. |
|
I think moving everything to catalogs is also a valuable feature. Do codemods support flags or options to support both? |
@zkochan I've not worked with codemods before this PR, but a quick glance at their docs seem to indicate that yes, arguments are supported. Would you like me to update this PR with argument(s) to support both the current behavior of moving all packages and the docs-stated behavior of moving duplicated packages? If so, do you have any preferences on the argument names and/or defaults? Some sort of "threshold" argument would be easy to tack on to this PR without much fuss - i.e. "if [N] or more packages have this dependency, move it to the catalog" |
|
I guess it depends on what will be the default. We could have something like |
|
"Only duplicates" was the behavior I was seeking out as a user to try catalogs for the first time. I think it's a sensible default while the catalogs feature is still relatively new and isn't fully integrated into stuff like That being said, as long as both are possible I don't much mind either way. I defer to your judgement if you feel "all dependencies" is a better default |
|
I wasn't the one who created the codemod. If the README says that only duplicates are moved to catalogs, then I am OK with that being the default. |
|
I investigated this last night, and I couldn't figure out how to get arguments working. I'm not familiar with codemods, and their docs are kind of non-existent (in favor of upsells and pushing to AI tooling) Accordingly, I do not intend to make any more updates to this PR. If you'd like to merge it as is to make the behavior match the documentation, please do! Otherwise feel free to close it (and maybe update the docs) |
|
Thanks for the work. UPDATE: meanwhile, here is what you can do
|
Until such time as pnpm/codemod#6 is merged, the pnpm/codemod has behavior that is not consistent with its own [README](https://github.com/pnpm/codemod/blob/main/catalog/README.md), nor reasonable/expected. Therefore it should not be recommended on the official docs page.
|
@zkochan are you able to merge this PR? 🙏🏻 |
|
Hey I noticed that this PR was merged, but it doesnt seem to have been released on Codemod yet: The latest version available is 1.0.7, which was published about a year ago |
Hello, thanks for this codemod! I tried it out in a monorepo, and noticed this aspect of the docs was not true:
Instead, the codemod moved all dependencies to the catalog, which wasn't what I wanted. In case the difference was unintentional, this PR updates the codemod to behave according to the docs. In addition to tracking the version count, it also tracks the dependent count, so we only select dependencies that have a single version used across multiple dependencies