Skip to content

Commit f08e3a1

Browse files
authored
docs: list of codemods (#4)
* docs: list of codemods * improve generate-help-docs
1 parent 75f33dc commit f08e3a1

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed
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',
@@ -11,12 +12,19 @@ output = output.replace(
1112
'',
1213
)
1314

15+
const codemods = TRANSFORM_OPTIONS.map(({ value, description, version }) => {
16+
return `### ${value.replaceAll('-', ' ')} (v${version})
17+
18+
${description}
19+
20+
`
21+
}).join('')
22+
1423
const readmePath = join('..', '..', 'README.md')
1524
const readme = await readFile(readmePath, 'utf-8')
1625

17-
const updatedReadme = readme.replace(
18-
/(?<=<!-- GENERATED START -->\n\n```\n)[\s\S]*?(?=```\n\n<!-- GENERATED END -->)/,
19-
output,
20-
)
26+
const updatedReadme = readme
27+
.replace(/(?<=<!-- USAGE START -->\n\n```\n)[\s\S]*?(?=```\n\n<!-- USAGE END -->)/, output)
28+
.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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
name: Generate dynamic README
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches:
67
- main
78
paths:
89
- index.ts
10+
- config.ts
911

1012
jobs:
1113
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

0 commit comments

Comments
 (0)