Lorem ipsum dolor sit amet, consectetur adipiscing elit lobortis arcu enim urna adipiscing praesent velit viverra sit semper lorem eu cursus vel hendrerit elementum morbi curabitur etiam nibh justo, lorem aliquet donec sed sit mi dignissim at ante massa mattis.
Vitae congue eu consequat ac felis placerat vestibulum lectus mauris ultrices cursus sit amet dictum sit amet justo donec enim diam porttitor lacus luctus accumsan tortor posuere praesent tristique magna sit amet purus gravida quis blandit turpis.
At risus viverra adipiscing at in tellus integer feugiat nisl pretium fusce id velit ut tortor sagittis orci a scelerisque purus semper eget at lectus urna duis convallis. porta nibh venenatis cras sed felis eget neque laoreet suspendisse interdum consectetur libero id faucibus nisl donec pretium vulputate sapien nec sagittis aliquam nunc lobortis mattis aliquam faucibus purus in.
Nisi quis eleifend quam adipiscing vitae aliquet bibendum enim facilisis gravida neque. Velit euismod in pellentesque massa placerat volutpat lacus laoreet non curabitur gravida odio aenean sed adipiscing diam donec adipiscing tristique risus. amet est placerat in egestas erat imperdiet sed euismod nisi.
“Nisi quis eleifend quam adipiscing vitae aliquet bibendum enim facilisis gravida neque velit euismod in pellentesque massa placerat”
Eget lorem dolor sed viverra ipsum nunc aliquet bibendum felis donec et odio pellentesque diam volutpat commodo sed egestas aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod eu tincidunt tortor aliquam nulla facilisi aenean sed adipiscing diam donec adipiscing ut lectus arcu bibendum at varius vel pharetra nibh venenatis cras sed felis eget dolor cosnectur drolo.
I'm excited to announce we've added the ability to do automated large-scale codebase refactors to Githasx!
We've named this feature Codemod after the open-source tool Facebook created - which is now archived.
Facebook created Codemod to make refactoring their code bases easier by automating the refactoring with scripts. In practice, a developer would create a codemod script and then use a CLI tool to execute the codemod on a repository. This is extremely helpful if you need to upgrade a library which has breaking API changes - you can write a codemod to automate the updates. Vue has created a codemod repository to help developers upgrade their versions of Vue.
Codemods are great, but there is still one point of friction, what happens if you need to apply this same codemod to hundreds of repositories? Well, before today, a developer would need to clone each repo, run the CLI, create a pull request, and wait for it to be merged in. This is the definition of TOIL and I assure you no developer enjoys this type of work.
With the addition of Codemods to Githaxs we have made the first three steps of the process much easier. Using Githaxs the current way to apply codemods to many repos looks like this:
Think of this tool like Dependabot or Renovate Bot, but on steroids. You can now bulk update anything: CircleCI Configs, README templates, .gitignore files, major library upgrades, etc and not just dependencies.
If you haven't already, install the Githaxs GitHub application.
Next, you'll need a repository to store all of your codemods. Think of this repository as a directory that would store your Database migrations but instead stores a history of all codemod scripts you've run. I recommend the following configuration for the repo:
Once this repository is created, login to your Githaxs Dashboard and edit the settings for the Codemod task to run on the repo you created above and save the settings.
Now it's time to see this in action. In your codemod repo add a new yaml file with the following format:
Create a pull request and within a few seconds and you should see a new pull request created on the test repo (i.e. the first repo in the list).
Review this Pull Request to ensure the codemod is doing exactly what you expect. In the Pull Request you will be able to see the codemod commands that were executed as well as any output, if there was any.
Any time you make changes to the pull request with the codemod it will automatically run again the codemod again on the test repo and update the pull request.
The last step is to merge in your codemod. Once this is done Githaxs will run the codemod on the remaining repositories in your list and create a Pull Request for each one. Githaxs will also link all of the created pull requests to the codemod pull request.
Your codemod scripts are able to use standard linux commands, python3.9, and the Jinja CLI to render templates.
Your codemod scripts will also have a variable named CODE_MOD_REPO so you can reference various files in your codemod repo in your codemod scripts. As an example, you can include a jinja template for CircleCI configs named templates/.config.j2 and reference it in your codemod script as $CODE_MOD_REPO/templates/.config.j2.