Skip to content

Commit 3dc9bcf

Browse files
Merge pull request #1147 from NullVoxPopuli/add-migration-codemod
Add v6 to v7 codemod
2 parents 7ea156c + 71a39bf commit 3dc9bcf

22 files changed

+5708
-15
lines changed

.github/workflows/ci.yml

+11
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ jobs:
109109
- uses: ./.github/actions/download-built-package
110110
- run: pnpm --filter test-app test:ember
111111

112+
codemod_tests:
113+
name: Codemod Tests
114+
timeout-minutes: 5
115+
runs-on: ubuntu-latest
116+
needs: [build]
117+
steps:
118+
- uses: actions/checkout@v4
119+
- uses: wyvox/action-setup-pnpm@v3
120+
- run: pnpm vitest
121+
working-directory: ./codemod
122+
112123
floating_tests:
113124
name: Floating Deps Test
114125
timeout-minutes: 5

MIGRATIONS.md

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323

2424
## 7.0
2525

26+
Run the migrator to automate this upgrade -- there are no breaking changes, no API changes, only changes in where imports occur.
27+
28+
```bash
29+
npx ember-resources-codemod
30+
```
31+
32+
This codemod runs on all js, ts, gjs, and gts files from within the invoked current working directory.
33+
34+
2635

2736
- Class-based resource implementation moved to [ember-modify-based-class-resource](https://github.com/NullVoxPopuli/ember-modify-based-class-resource/)
2837
- Other utilities moved to [https://reactive.nullvoxpopuli.com/](https://reactive.nullvoxpopuli.com/)

codemod/.eslintrc.cjs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
const { configs } = require('@nullvoxpopuli/eslint-configs');
4+
5+
const config = configs.node();
6+
7+
module.exports = {
8+
...config,
9+
overrides: [
10+
...config.overrides,
11+
{
12+
files: ['**/*'],
13+
rules: {
14+
'n/no-process-exit': 'off',
15+
},
16+
},
17+
{
18+
files: ['**/*.test.ts'],
19+
rules: {
20+
'n/no-unpublished-import': 'off',
21+
},
22+
},
23+
],
24+
};

codemod/.prettierrc.cjs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
3+
module.exports = {
4+
plugins: ['prettier-plugin-ember-template-tag'],
5+
printWidth: 100,
6+
singleQuote: true,
7+
templateSingleQuote: false,
8+
// this was required to make the VSCode + Prettier work correctly with <template>, see https://github.com/gitKrystan/prettier-plugin-ember-template-tag/issues/38
9+
// we should roll this back once that issue has been fixed!
10+
overrides: [
11+
{
12+
files: '*.hbs',
13+
options: {
14+
singleQuote: false,
15+
},
16+
},
17+
{
18+
files: '*.gjs',
19+
options: {
20+
parser: 'ember-template-tag',
21+
},
22+
},
23+
{
24+
files: '*.gts',
25+
options: {
26+
parser: 'ember-template-tag',
27+
},
28+
},
29+
],
30+
};

codemod/bin.mjs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env node
2+
3+
import { run } from './src/all.js';
4+
import { sep, success } from './src/logging.js';
5+
6+
await run();
7+
8+
sep();
9+
success(`✨ Done! ✨`);

codemod/package.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "ember-resources-codemod",
3+
"version": "0.0.3",
4+
"bin": "./bin.mjs",
5+
"type": "module",
6+
"files": [
7+
"bin.mjs",
8+
"src"
9+
],
10+
"scripts": {
11+
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
12+
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
13+
"lint:js": "eslint . --cache",
14+
"lint:prettier": "prettier --check '**/*.{js,ts}'",
15+
"lint:prettier:fix": "prettier --write '**/*.{js,ts}'",
16+
"lint:js:fix": "eslint . --fix"
17+
},
18+
"devDependencies": {
19+
"@babel/core": "^7.25.2",
20+
"@babel/eslint-parser": "^7.19.1",
21+
"@nullvoxpopuli/eslint-configs": "^3.2.0",
22+
"@tsconfig/node22": "^22.0.0",
23+
"@tsconfig/strictest": "^2.0.5",
24+
"@types/node": "^22.5.4",
25+
"@types/semver": "^7.5.8",
26+
"@typescript-eslint/eslint-plugin": "^6.0.0",
27+
"@typescript-eslint/parser": "^6.0.0",
28+
"concurrently": "^8.2.2",
29+
"eslint": "^8.35.0",
30+
"prettier": "^3.1.1",
31+
"typescript": "~5.5.0",
32+
"vitest": "^2.0.5"
33+
},
34+
"dependencies": {
35+
"find-up": "^7.0.0",
36+
"globby": "^14.0.0",
37+
"semver": "^7.6.3"
38+
}
39+
}

0 commit comments

Comments
 (0)