es-tooling / module-replacements-codemods

MIT License
188 stars 26 forks source link

Automatically uninstall packages #12

Closed camchenry closed 4 months ago

camchenry commented 4 months ago

This might be a bit of a stretch beyond just editing the JS code, but it would be neat if the CLI for this eventually uninstalled the actual packages themselves. That is, if you have the is-regexp package installed (for example) it would also remove it from:

The end goal being that the CLI will completely purge your project of these modules wherever they might be referenced.

ajkl2533 commented 4 months ago

I think this could work only for direct dependencies mentioned in package.json file because codemods will clean your own codebase but you have no control over third party dependencies. This actually might be task for the CLI (once there will be any) that could perform uninstall after all selected codemods are done. It seems more safe option than touch package.lock or lockfiles directly.

thepassle commented 4 months ago

Yep, agree. Theres a todo in the code somewhere that mentions this. The cli is super barebones right now, its just there to have something, im mainly focused on gathering/implementing the codemods right now. @43081j had some ideas around the cli as well

thepassle commented 4 months ago

I wonder if it would be enough to glob for **/package.json, and just remove the packages from the hits there, since the codemods will already glob for all js/ts/etc files anyway, and that way it would work for monorepos too

thepassle commented 4 months ago

The scope of this repository has changed a bit, and the CLI will be implemented elsewhere. This repo will just be a home for the codemods, so that other tools can use them and do whatever they wish with them, so removing the package from the package.json will be an implementation detail of such tools. So I'll close this issue for now :)