Migration Codemods¶
Automated migration tools and processes for upgrading to PatternFly 6.
Introduction¶
PatternFly 6 provides automated codemods to help migrate your codebase from previous versions. These tools handle most of the mechanical changes required for the upgrade, though manual review and adjustments are still necessary.
Related Files¶
- PatternFly Guidelines - Core development principles
- Styling Standards - Design token migration
- Common Issues - Migration troubleshooting
Mandatory Codemods (Run in Order)¶
1. Class Name Updater¶
Updates class names from pf-v5- to pf-v6- prefix.
What it does:
- Updates all PatternFly class prefixes
- Converts
pf-c-,pf-u-,pf-l-topf-v6-versions - Handles both JSX className and CSS files
2. PatternFly Codemods¶
Updates React component code to PatternFly 6 standards.
What it does:
- Updates component imports and props
- Handles breaking API changes
- Migrates deprecated component patterns
3. Tokens Update¶
Replaces CSS variables with new design tokens.
What it does:
- Converts global CSS variables to semantic design tokens
- Updates
--pf-global-*to--pf-t--global-*format - Identifies tokens that need manual replacement
Codemod Best Practices¶
Before Running Codemods¶
- Commit all changes - Ensure clean git state
- Create a branch - Isolate migration work
- Remove CSS overrides - Temporarily remove custom CSS that targets PatternFly classes
- Document custom patterns - Note any non-standard implementations
Running Codemods¶
- Multiple Passes: Run each codemod multiple times until no new changes are detected
- Order Matters: Always run codemods in the specified order
- Review Changes: Use
git diffto review all modifications - Test Incrementally: Test after each codemod to identify issues early
After Running Codemods¶
- Manual Review: Check for patterns the codemods couldn't handle
- Hot Pink Tokens: Replace any
--pf-t--temp--dev--tbdtokens manually - Test Coverage: Run all tests and fix any failures
- Visual QA: Verify UI appearance matches expectations
Common Codemod Scenarios¶
Component Migration Examples¶
Button Component¶
// Before (v5)
<Button isDisabled={true}>Click me</Button>
// After (v6) - codemod handles this
<Button disabled={true}>Click me</Button>
Select Component¶
Table Component¶
CSS Variable Migration¶
/* Before */
.custom-class {
color: var(--pf-global--Color--100);
margin: var(--pf-global--spacer--md);
}
/* After - codemod result */
.custom-class {
color: var(--pf-t--global--text--color--regular);
margin: var(--pf-t--global--spacer--md);
}
Manual Migration Tasks¶
Tasks Codemods Don't Handle¶
- Component Structure Changes
- New wrapper divs in buttons
- Table component restructuring
-
Select/Dropdown pattern updates
-
Test Updates
- Change
aria-disabledchecks todisabled - Update
byTextqueries tobyRolefor buttons -
Fix breakpoint tests for rem units
-
Custom Patterns
- Non-standard component usage
- Complex CSS overrides
- Custom theme implementations
Hot Pink Token Resolution¶
When you see --pf-t--temp--dev--tbd tokens:
- Identify Context: Understand what the token is styling
- Choose Semantic Token: Select based on meaning, not color
- Use Token Finder: VS Code plugin - type
pft+ keywords - Test Both Themes: Verify in light and dark modes
Example resolution:
/* Hot pink token found */
background: var(--pf-t--temp--dev--tbd);
/* Analyze context - it's a disabled state */
/* Choose appropriate semantic token */
background: var(--pf-t--global--background--color--disabled);
Deprecated Components¶
The following components are deprecated in v6 and require manual migration:
Completely Deprecated¶
- Old Select: Migrate to new Select implementation
- Old Dropdown: Migrate to new Dropdown patterns
- Old Wizard: Use new Wizard component
- Old Table: Update to composable Table components
Changed Components¶
- Button:
isDisabled→disabledprop - Text: Use
Contentcomponent instead - PageHeader: No longer exists, use
PageSection+Title
Testing After Migration¶
Required Test Updates¶
- Button Tests
// Before
expect(button).toHaveAttribute('aria-disabled', 'true')
// After
expect(button).toBeDisabled()
- Text Queries
// Before - may fail due to wrapper divs
screen.getByText('Button text')
// After - more reliable
screen.getByRole('button', { name: 'Button text' })
- Class Name Checks
// Before
expect(element).toHaveClass('pf-c-button')
// After
expect(element).toHaveClass('pf-v6-c-button')
Troubleshooting Codemod Issues¶
Common Problems¶
Codemod Won't Run¶
Partial Updates¶
- Run codemod again on the same path
- Check for syntax errors blocking parsing
- Manually handle complex patterns
TypeScript Errors¶
- Update PatternFly type definitions
- Rebuild TypeScript cache:
npx tsc --build --clean
Rollback Strategy¶
If migration issues are severe:
- Git Reset: Return to pre-migration commit
- Gradual Migration: Migrate components incrementally
- Parallel Versions: Temporarily run both versions (not recommended)
Resources¶
Documentation¶
Tools¶
Support¶
- Slack: PatternFly community Slack
- GitHub Issues: Report codemod bugs
- Discussion Board: Migration questions
Migration Checklist¶
- [ ] Clean git state before starting
- [ ] Remove existing CSS overrides
- [ ] Run class-name-updater codemod
- [ ] Run pf-codemods
- [ ] Run tokens-update codemod
- [ ] Replace hot pink tokens manually
- [ ] Update component tests
- [ ] Fix TypeScript errors
- [ ] Visual regression testing
- [ ] Performance validation
- [ ] Accessibility audit
Remember: Codemods handle ~80% of the migration work. The remaining 20% requires careful manual attention and testing.