Skip to contentSkip to navigationSkip to topbar
Figma
Star

Codemods

Version 0.7.0Github

A collection of codemods for maintaining projects built with Paste.


About

About page anchor

Codemods(link 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 team(link 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.

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

Included Transforms page anchor

barreled-to-unbarreled

barreled-to-unbarreled page anchor

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(link takes you to an external page).

Options to recast(link 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\"}'"

This project is heavily inspired from react-codemods(link takes you to an external page).