File tree Expand file tree Collapse file tree 1 file changed +113
-0
lines changed
Expand file tree Collapse file tree 1 file changed +113
-0
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,116 @@ The `package-name` is name of transform. see available transforms below.
1919See the [ codemod CLI doc] ( https://go.codemod.com/cli-docs ) for a full list of available commands.
2020
2121All codemods are also available in the [ Codemod Registry] ( https://go.codemod.com/registry ) .
22+
23+ ## Development
24+
25+ Project structures:
26+
27+ ``` txt
28+ codemods/
29+ ├─ project/
30+ │ ├─ recipes/
31+ │ │ ├─ src/
32+ │ │ │ ├─ feature.ts
33+ │ │ ├─ tests/
34+ │ │ │ ├─ input/
35+ │ │ │ │ ├─ case-1.js
36+ │ │ │ │ ├─ case-2.js
37+ │ │ │ │ ├─ case-x.js
38+ │ │ │ ├─ expected/
39+ │ │ │ │ ├─ case-1.js
40+ │ │ │ │ ├─ case-2.js
41+ │ │ │ │ ├─ case-x.js
42+ │ │ ├─ codemod.yaml
43+ │ │ ├─ package.json
44+ │ │ ├─ README.md
45+ │ │ ├─ workflow.yaml
46+ │ ├─ vx-to-vx/
47+ │ │ ├─ codemod.yaml
48+ │ │ ├─ package.json
49+ │ │ ├─ README.md
50+ │ │ ├─ workflow.yaml
51+ utilities/
52+ ├─ src/
53+ │ ├─ node-utilisies.ts
54+ ├─ package.json
55+ package.json
56+ README.md
57+ ```
58+
59+ - ` codemods ` dir represents the collection of projects
60+ - ` project ` is a placeholder for a project name (eg: ` react ` , ` angular ` , ` vue ` , etc)
61+ - `recipes` is a collection of related codemods (eg: `v18-to-v19`, `react-class-to-function`)
62+ - ` utilities ` is a internal package that provides shared utilities for codemods (eg: ast-grep queries)
63+
64+ ### ` codemod.yaml ` example
65+
66+ ``` yaml
67+ schema_version : " 1.0"
68+ name : " <project>/<codemod-name>"
69+ version : 1.0.0
70+ description : <Your codemod description>
71+ author : <Your Name>
72+ license : MIT
73+ workflow : workflow.yaml
74+ category : migration
75+
76+ targets :
77+ languages :
78+ - javascript
79+ - typescript
80+
81+ keywords :
82+ - transformation
83+ - migration
84+
85+ registry :
86+ access : public
87+ visibility : public
88+ ` ` `
89+
90+ ### ` package.json` example
91+
92+ ` ` ` json
93+ {
94+ "name": "@<project-name>/<migration-name>",
95+ "version": "0.0.1",
96+ "private": true,
97+ "devDependencies": {
98+ "@codemod.com/jssg-types": "catalog:"
99+ },
100+ "scripts": {
101+ "test": "npx codemod jssg test -l typescript ./src/workflow.ts ./"
102+ }
103+ }
104+ ` ` `
105+
106+ # ## `workflow.yaml` example
107+
108+ ` ` ` yaml
109+ # yaml-language-server: $schema=https://raw.githubusercontent.com/codemod/codemod/refs/heads/main/schemas/workflow.json
110+
111+ version: "1"
112+
113+ nodes:
114+ - id: apply-transforms
115+ name: Apply AST Transformations
116+ type: automatic
117+ steps:
118+ - name: Handle DEP0147 via transforming ` fs.rmdir` to `fs.rm`.
119+ js-ast-grep :
120+ js_file : src/workflow.ts
121+ base_path : .
122+ include :
123+ - " **/*.js"
124+ - " **/*.jsx"
125+ - " **/*.mjs"
126+ - " **/*.cjs"
127+ - " **/*.cts"
128+ - " **/*.mts"
129+ - " **/*.ts"
130+ - " **/*.tsx"
131+ exclude :
132+ - " **/node_modules/**"
133+ language : typescript
134+ ` ` `
You can’t perform that action at this time.
0 commit comments