Codemods

Code migration as-a-service

Presenter:             OTIS

outline

Backstage

React 17

Shell

Starhome

Module

UI

React 18

const Button = ({ size, color }) => {
    return <button style={{ color, fontSize: size }}>Click me</button>;
}

Button.defaultProps = {
    size: '16px',
    color: 'blue'
}
const Button = ({ size = '16px', color = 'blue' }) => {
    return <button style={{ color, fontSize: size }}>Click me</button>;
}

Bot...

Codemod

Let me

What is codemod?

A script used to automate codebase changes, especially during large refactors or migrations

An end-to-end platform for code migrations at scale

BUIld

Codemod learn

Learn from locally changes

2

Scaffold a new codemod package

1. Manually write your own codemod
2. Turn an existing codemod into a Codemod-compatible package.

3

1

Codemod Studio

Online studio

prerequisite

setup

codemod learn

1

Make a change

2

Run `codemod learn`

3

Building the codemod

4

Export/publish the generated codemod

codemod studio

codemod studio

Dependency on git diff

Inconvenient to debug

Poor learning (only 1 example)

Sensitive data can be scanned

codemod STUDIO

1

Add before/after code examples

2

Add natural language descriptions

3

Build codemod with AI

4

Test codemod (and iterate)

5

Exporting codemod

Add before/after code examples

Add natural language descriptions

Build codemod with AI

Can cost money to use AI assistant (PRO version)

Need to describe in detail by writing comments

Can not handle complex cases/ edge cases

Scaffold a new codemod package

1

Verify codemod engine compatibility

2

Initialize codemod package

3

Update transform file content

4

Update package configuration file

5

Publish the codemod

Example

Need knowledge about AST, jscodeshift, codemod scaffold

What is codemod registry

A centralized hub for discovering and sharing Codemods

My

Codemod

user 1

Codemod Registry

user 1

user 2

user 3

Can be shared and reused across projects

Time-saving and free

Change behavior to use AI

Migrating to a new framework or library

Reorganizing a large codebase

Applying new coding standards at scale

Faster migrations and refactoring

Consistency across the codebase

Requires testing to ensure accuracy

Not suitable for minor changes or one-off updates

Q&A

Made with Slides.com