Recipe Components
Every recipe consists of several required files that work together: | File | Purpose | |------|---------|| |README.md | Description, purpose, and usage instructions |
| package.json | Package manifest with dependencies |
| src/workflow.ts | Main transformation logic using jssg API |
| codemod.yaml | Codemod metadata and configuration |
| workflow.yaml | Workflow definition with transformation steps |
| tests/ | Test suite with input and expected output files |
| tsconfig.json | TypeScript configuration |
The
workflow.ts naming is conventional but can be changed. For multi-step codemods, use descriptive names like enroll-to-set-timeout.ts or cleanup-imports.ts.Creating a Recipe
1
Create the recipe directory
Create a new directory under
recipes/ with a descriptive name:2
Create package.json
Set up the package manifest:
package.json
3
Create codemod.yaml
Define the codemod metadata:
codemod.yaml
4
Create workflow.yaml
Define the transformation workflow:
workflow.yaml
5
Write the transformation
Create
src/workflow.ts with your transformation logic:src/workflow.ts
6
Create tests
Set up test input and expected output files:Create test cases in Create expected output in
tests/input/:tests/input/file-0.js
tests/expected/:tests/expected/file-0.js
7
Add README documentation
Create
README.md with usage examples showing before/after code:README.md
Multi-Step Transformations
For complex migrations requiring multiple transformation passes, create separate files for each step:workflow.yaml:
workflow.yaml
Common Patterns
Finding Imports and Requires
Resolving Bindings
Removing Bindings
Testing Your Recipe
Run tests for your recipe:Next Steps
Testing Guide
Learn about testing requirements and best practices
Development Workflow
Understand the PR process and pre-commit checks