jscodeshift is a great tool for running migrations on frontend codebase. It saves days of team syncup, cross team collaboration and prioritization,
my team is looking at building a tool to automatically upgrade applications that consume our libraries, instead of giving an upgrade doc and deadlines.
jscodeshift is a command line interface and works the same way as yeoman’s
The transform script is just an argument.
While this is making it fairly simple for people working in the same environment, I cannot ask every team to install jscodeshift as a pre-requisite (some developers don’t even know what node.js is).
So I decided to dig into the jscodeshift library by myself, to see if I could reuse some modules.
The fact that I am writing that blog post is itself a confirmation.
Here is the piece of – typescript – code that can invoke multiple jscodeshift transforms :
You will need a migrations object, which is a
transform: import('jscodeshift').Transform, patterns: string}
patterns is a list of glob matchers.
With this function you are able to build a tool that can automatically chain multiple migrations in your codebase.
If you combine the tool with a ContinuousIntegration (CI) script that creates a pull request automatically, all you have to do for a migration to complete is to… press a button.