Migrates the long-hand size prop values to their short-hand equivalents on
the Pluma components whose size scale dropped the long-hand names in v3:
| Before | After |
|---|---|
size="medium" | size="md" |
size="small" | size="sm" |
size="large" | size="lg" |
Affected components: Button, ButtonGroup, ProgressBar,
SegmentedControl, Select, TextField, Toggle (plus Combobox,
Search, and ToggleButton, which share the same size scale). Components
with their own size scales (e.g. Avatar, Modal, Drawer) are unaffected.
There are two transforms — one for React (.tsx/.ts/.jsx/.js) and one
for Ember (.gts/.gjs/.hbs). Run whichever apply to your app.
Run it through the Pluma CLI from inside your consuming app. Always start with a dry run to review the diff and warning summary before applying:
Both frameworks accept --dry / -d. The React path also forwards standard
jscodeshift flags, so -p prints transformed output.
React. Only JSX elements whose tag resolves (via the import in the same
file) to one of the affected components from
@customerio/pluma-components/react (or the bare @customerio/pluma-components
entry). Aliased imports (import { Button as B } from …) are handled. A local
component named Button that wasn't imported from Pluma is left alone.
Inline string literals are always rewritten (size="small", size={'small'},
size={'small' as const}), along with result-position literals — branches
of a ?:, the right-hand side of ?? / || / &&.
Ember. Only the <PlumaButton …>, <PlumaButtonGroup …>, etc. element
nodes are touched. Inline literals — @size="small", @size={{"small"}} — are
always rewritten, along with result-position literals inside the
if / unless / or / and helpers.
Both transforms print a summary listing every size value they recognized but
couldn't resolve to a literal — dynamic expressions, identifiers/consts, class
members ({{this.x}}), component arguments ({{@arg}}), and unknown helper
calls. They're reported (not auto-rewritten) so you can rename them by hand
where they hold a long-hand value.
After running, you can also grep for any leftover size="small",
size="medium", or size="large" to catch anything the warnings missed.
The React/Ember transform engines and reporting are shared across the
attribute-rename codemods under ../../_shared/; this codemod is a thin
config wrapper. There's a test suite under tests/:
It uses Node's built-in test runner (node --test).