Codemods


Edit this page on GitHub

About#

Codemodslink takes you to an external page 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 teamlink takes you to an external page. 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.

Usage#

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.

Included Transforms#

barreled-to-unbarreled#

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>

jscodeshift options#

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 optionslink takes you to an external page.

Recast Options#

Options to recastlink takes you to an external page's printer can be provided through jscodeshift's printOptions command line argument

npx @twilio-paste/codemods <transform> <path> --jscodeshift="--printOptions='{\"quote\":\"double\"}'"

Acknowledgements#

This project is heavily inspired from react-codemodslink takes you to an external page.

Support

If you need support, please open a new issue in our GitHub repository. Please try to provide as much detail as possible in your issue.

Contributing

The Paste design system is open source and contributions are welcome. Check out the project on GitHub to learn more about contributing.

Copyright © 2020 Twilio, Inc.