Skip to content

Commit 533ba60

Browse files
committed
docs: list of codemods
1 parent 4fb1e92 commit 533ba60

File tree

4 files changed

+41
-10
lines changed

4 files changed

+41
-10
lines changed

.github/actions/generate-help-docs.mjs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { execSync } from 'node:child_process'
22
import { readFile, writeFile } from 'node:fs/promises'
33
import { join } from 'node:path'
4+
import { TRANSFORM_OPTIONS } from '../../config.js'
45

56
let output = execSync('node ../../index.js --help', {
67
encoding: 'utf-8',
@@ -14,9 +15,16 @@ output = output.replace(
1415
const readmePath = join('..', '..', 'README.md')
1516
const readme = await readFile(readmePath, 'utf-8')
1617

17-
const updatedReadme = readme.replace(
18-
/(?<=<!-- GENERATED START -->\n\n```\n)[\s\S]*?(?=```\n\n<!-- GENERATED END -->)/,
19-
output,
20-
)
18+
let updatedReadme = readme.replace(/(?<=<!-- USAGE START -->\n\n```\n)[\s\S]*?(?=```\n\n<!-- USAGE END -->)/, output)
19+
20+
const codemods = TRANSFORM_OPTIONS.map(({ value, description, version }) => {
21+
return `### ${value.replaceAll('-', ' ')} (v${version})
22+
23+
${description}
24+
25+
`
26+
}).join('')
27+
28+
updatedReadme = updatedReadme.replace(/(?<=<!-- CODEMODS START -->\n\n)[\s\S]*?(?=<!-- CODEMODS END -->)/, codemods)
2129

2230
await writeFile(readmePath, updatedReadme, 'utf-8')

.github/workflows/generate-readme.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
paths:
88
- index.ts
9+
- config.ts
910

1011
jobs:
1112
generate-readme:

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,40 @@ npm i -g @expressjs/codemod # or pnpm, bun, etc.
2727

2828
Use `@expressjs/codemod -h` to explore available command-line options.
2929

30-
<!-- GENERATED START -->
30+
<!-- USAGE START -->
3131

3232
```
3333
Usage: @expressjs/codemod [codemod] [source] [options]
3434
3535
Options:
3636
-v, --version Output the current version of @expressjs/codemod.
3737
-d, --dry Dry run (no changes are made to files)
38+
-p, --print Print transformed files to stdout
39+
--verbose Show more information about the transform process
3840
-h, --help Display this help message.
3941
```
4042

41-
<!-- GENERATED END -->
43+
<!-- USAGE END -->
44+
45+
## Available Codemods
46+
47+
All the available codemods to update your express server:
48+
49+
<!-- CODEMODS START -->
50+
51+
### magic redirect (5.0.0)
52+
53+
Transform the deprecated magic string "back"
54+
55+
### pluralized methods (5.0.0)
56+
57+
Transform the methods to their pluralized versions
58+
59+
### v4 deprecated signatures (5.0.0)
60+
61+
Transform the deprecated signatures in Express v4
62+
63+
<!-- CODEMODS END -->
4264

4365
## Contributing
4466

config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export const TRANSFORM_OPTIONS = [
99
value: 'pluralized-methods',
1010
version: '5.0.0',
1111
},
12-
{
13-
description: 'Transform the deprecated signatures in Express v4',
14-
value: 'v4-deprecated-signatures',
15-
version: '5.0.0'
12+
{
13+
description: 'Transform the deprecated signatures in Express v4',
14+
value: 'v4-deprecated-signatures',
15+
version: '5.0.0',
1616
},
1717
]

0 commit comments

Comments
 (0)