Codemods are a collection of scripts that update your codebase from old patterns to new patterns automatically. In this way we can effectively move APIs and patterns to newer versions without incurring tech debt across the Twilio organization.
A notable user of this approach is the React team. They provide similar automation to downstream users when they introduce breaking changes in React, which helps to alleviate the pain points and provide a path forward.
We hope these codemods make your experience using and maintaining the latest version of Paste easy and enjoyable.
npx @twilio-paste/codemods [...options]
Options:
--dry
for a dry-run (doesn't change the files, just reports the status)--print
to print the output for comparison
This will start an interactive wizard, and then run the specified transform.
Converts old-style core imports to the new unbarreled style. (i.e.: import {Button} from '@twilio-paste/core'
becomes import {Button} from '@twilio-paste/core/button'
)
npx @twilio-paste/codemods barreled-to-unbarreled <path>
To pass more options directly to jscodeshift, use --jscodeshift="..."
. For example:
npx @twilio-paste/codemods --jscodeshift="--run-in-band --verbose=2"
See all available jscodeshift options.
Options to recast's printer can be provided
through jscodeshift's printOptions
command line argument
npx @twilio-paste/codemods <transform> <path> --jscodeshift="--printOptions='{\"quote\":\"double\"}'"
This project is heavily inspired from react-codemods.