ember-codemod-pod-to-octane 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/README.md +112 -0
- package/bin/ember-codemod-pod-to-octane.js +36 -0
- package/package.json +62 -0
- package/src/index.js +28 -0
- package/src/migration/ember-addon/addon/component-classes.js +45 -0
- package/src/migration/ember-addon/addon/component-stylesheets.js +21 -0
- package/src/migration/ember-addon/addon/component-templates.js +21 -0
- package/src/migration/ember-addon/addon/index.js +11 -0
- package/src/migration/ember-addon/app/component-classes.js +21 -0
- package/src/migration/ember-addon/app/component-stylesheets.js +21 -0
- package/src/migration/ember-addon/app/component-templates.js +21 -0
- package/src/migration/ember-addon/app/index.js +11 -0
- package/src/migration/ember-addon/index.js +43 -0
- package/src/migration/ember-addon/tests/components.js +36 -0
- package/src/migration/ember-addon/tests/index.js +5 -0
- package/src/migration/ember-app/app/component-classes.js +45 -0
- package/src/migration/ember-app/app/component-stylesheets.js +21 -0
- package/src/migration/ember-app/app/component-templates.js +21 -0
- package/src/migration/ember-app/app/index.js +25 -0
- package/src/migration/ember-app/app/route-adapters.js +33 -0
- package/src/migration/ember-app/app/route-controllers.js +33 -0
- package/src/migration/ember-app/app/route-models.js +33 -0
- package/src/migration/ember-app/app/route-routes.js +33 -0
- package/src/migration/ember-app/app/route-serializers.js +33 -0
- package/src/migration/ember-app/app/route-stylesheets.js +21 -0
- package/src/migration/ember-app/app/route-templates.js +21 -0
- package/src/migration/ember-app/index.js +29 -0
- package/src/migration/ember-app/tests/components.js +36 -0
- package/src/migration/ember-app/tests/index.js +11 -0
- package/src/migration/ember-app/tests/route-controllers.js +75 -0
- package/src/migration/ember-app/tests/route-routes.js +69 -0
- package/src/migration/ember-engine/addon/component-classes.js +45 -0
- package/src/migration/ember-engine/addon/component-stylesheets.js +21 -0
- package/src/migration/ember-engine/addon/component-templates.js +21 -0
- package/src/migration/ember-engine/addon/index.js +19 -0
- package/src/migration/ember-engine/addon/route-controllers.js +33 -0
- package/src/migration/ember-engine/addon/route-routes.js +33 -0
- package/src/migration/ember-engine/addon/route-stylesheets.js +21 -0
- package/src/migration/ember-engine/addon/route-templates.js +21 -0
- package/src/migration/ember-engine/index.js +29 -0
- package/src/migration/ember-engine/tests/components.js +36 -0
- package/src/migration/ember-engine/tests/index.js +11 -0
- package/src/migration/ember-engine/tests/route-controllers.js +75 -0
- package/src/migration/ember-engine/tests/route-routes.js +69 -0
- package/src/migration/index.js +3 -0
- package/src/utils/ember-addon/app/components.js +17 -0
- package/src/utils/map-paths.js +15 -0
- package/src/utils/move-files.js +32 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Isaac J. Lee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
[](https://github.com/ijlee2/ember-codemod-pod-to-octane/actions/workflows/ci.yml)
|
|
2
|
+
|
|
3
|
+
# ember-codemod-pod-to-octane
|
|
4
|
+
|
|
5
|
+
_Codemod to un-pod Ember apps, addons, and engines_
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
Step 1. Quickly return to [default Octane](https://cli.emberjs.com/release/advanced-use/project-layouts/#classiclayout).
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
cd <your/project/path>
|
|
14
|
+
npx ember-codemod-pod-to-octane <arguments>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Step 2. Remove `podModulePrefix` from `app/app.js` and `usePods` from `.ember-cli`.
|
|
18
|
+
|
|
19
|
+
Step 3. Update relative paths in `import` statements.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Arguments
|
|
23
|
+
|
|
24
|
+
You must pass `--type` to indicate what type of project you have.
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx ember-codemod-pod-to-octane --type=app
|
|
28
|
+
npx ember-codemod-pod-to-octane --type=addon
|
|
29
|
+
npx ember-codemod-pod-to-octane --type=engine
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
<details>
|
|
34
|
+
<summary>Optional: Do a test run</summary>
|
|
35
|
+
|
|
36
|
+
Pass `--test` to preview how the codemod will move files around.
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npx ember-codemod-pod-to-octane --test
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
</details>
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
<details>
|
|
46
|
+
<summary>Optional: Specify the project root</summary>
|
|
47
|
+
|
|
48
|
+
Pass `--root` to run the codemod against (1) a project somewhere else or (2) multiple projects (assuming you have an automation script).
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
npx ember-codemod-pod-to-octane --root=<your/project/path>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
</details>
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Limitations
|
|
58
|
+
|
|
59
|
+
The codemod is designed to cover typical uses of an Ember app, addon, and engine. It is not designed to cover one-off cases.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
<details>
|
|
63
|
+
<summary>Apps</summary>
|
|
64
|
+
|
|
65
|
+
To account for a bug (found when Ember CLI is combined with Ember Data), the codemod doesn't consider unit tests for adapters, models, and serializers. You will need to manually move the test files.
|
|
66
|
+
|
|
67
|
+
</details>
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
<details>
|
|
71
|
+
<summary>Addons</summary>
|
|
72
|
+
|
|
73
|
+
The codemod assumes that an addon is used to define components (not models or routes).
|
|
74
|
+
|
|
75
|
+
</details>
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
<details>
|
|
79
|
+
<summary>Engines</summary>
|
|
80
|
+
|
|
81
|
+
The codemod assumes that an engine is used to define routes and route-specific components.
|
|
82
|
+
|
|
83
|
+
</details>
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
To better meet your needs, consider forking the repo and running the codemod locally.
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
cd <your/forked/repo>
|
|
90
|
+
./bin/ember-codemod-pod-to-octane <arguments>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## Compatibility
|
|
95
|
+
|
|
96
|
+
* Node.js v16 or above
|
|
97
|
+
* [`ember-css-modules`](https://github.com/salsify/ember-css-modules)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## Contributing
|
|
101
|
+
|
|
102
|
+
To provide feedback, you can reach out to me on [Discord](https://discord.gg/emberjs) at `ijlee2`. Please star this project so that I can gauge its importance to you and the Ember community. ⭐
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
## Credits
|
|
106
|
+
|
|
107
|
+
Thanks goes to FlashRecruit, Imago, and CLARK, who gave me the necessary Ember experience. Some code is based on [`ember-component-template-colocation-migrator`](https://github.com/ember-codemods/ember-component-template-colocation-migrator).
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
This project is licensed under the [MIT License](LICENSE.md).
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import yargs from 'yargs';
|
|
5
|
+
import { hideBin } from 'yargs/helpers';
|
|
6
|
+
|
|
7
|
+
import { runCodemod } from '../src/index.js';
|
|
8
|
+
|
|
9
|
+
// Provide a title to the process in `ps`
|
|
10
|
+
process.title = 'ember-codemod-pod-to-octane';
|
|
11
|
+
|
|
12
|
+
// Set codemod options
|
|
13
|
+
const { argv } = yargs(hideBin(process.argv))
|
|
14
|
+
.option('root', {
|
|
15
|
+
describe: 'Location of your Ember project',
|
|
16
|
+
type: 'string',
|
|
17
|
+
})
|
|
18
|
+
.option('test', {
|
|
19
|
+
default: false,
|
|
20
|
+
describe: 'Do a test run?',
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
})
|
|
23
|
+
.option('type', {
|
|
24
|
+
choices: ['addon', 'app', 'engine'],
|
|
25
|
+
demandOption: true,
|
|
26
|
+
describe: 'Type of your Ember project',
|
|
27
|
+
type: 'string',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const options = {
|
|
31
|
+
projectRoot: argv['root'] ?? process.cwd(),
|
|
32
|
+
projectType: argv['type'],
|
|
33
|
+
testRun: argv['test'],
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
runCodemod(options);
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ember-codemod-pod-to-octane",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Codemod to un-pod Ember apps, addons, and engines",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ember-codemod",
|
|
7
|
+
"ember-octane",
|
|
8
|
+
"emberjs"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/ijlee2/ember-codemod-pods-to-octane.git"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Isaac J. Lee",
|
|
16
|
+
"main": "src/index.js",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"bin": "./bin/ember-codemod-pod-to-octane.js",
|
|
19
|
+
"files": [
|
|
20
|
+
"bin/",
|
|
21
|
+
"src/"
|
|
22
|
+
],
|
|
23
|
+
"directories": {
|
|
24
|
+
"test": "tests"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"changelog": "lerna-changelog",
|
|
28
|
+
"lint": "eslint . --cache --ext=.cjs,.js",
|
|
29
|
+
"lint:fix": "eslint . --fix",
|
|
30
|
+
"start": "node ./src/index.js",
|
|
31
|
+
"test": "node ./node_modules/@sondr3/minitest/bin/mt.mjs tests --quiet"
|
|
32
|
+
},
|
|
33
|
+
"changelog": {
|
|
34
|
+
"labels": {
|
|
35
|
+
"breaking": "Breaking Change",
|
|
36
|
+
"bug": "Bug Fix",
|
|
37
|
+
"enhance: code": "Enhancement",
|
|
38
|
+
"enhance: dependency": "Internal",
|
|
39
|
+
"enhance: documentation": "Documentation",
|
|
40
|
+
"user feedback": "User Feedback"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@babel/core": "^7.18.9",
|
|
45
|
+
"@babel/eslint-parser": "^7.18.9",
|
|
46
|
+
"glob": "^8.0.3",
|
|
47
|
+
"yargs": "^17.5.1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@sondr3/minitest": "^0.1.1",
|
|
51
|
+
"eslint": "^8.20.0",
|
|
52
|
+
"eslint-config-prettier": "^8.5.0",
|
|
53
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
54
|
+
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
55
|
+
"fixturify": "^2.1.1",
|
|
56
|
+
"lerna-changelog": "^2.2.0",
|
|
57
|
+
"prettier": "^2.7.1"
|
|
58
|
+
},
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">= 16"
|
|
61
|
+
}
|
|
62
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
migrateEmberAddon,
|
|
3
|
+
migrateEmberApp,
|
|
4
|
+
migrateEmberEngine,
|
|
5
|
+
} from './migration/index.js';
|
|
6
|
+
|
|
7
|
+
export function runCodemod(options) {
|
|
8
|
+
switch (options.projectType) {
|
|
9
|
+
case 'addon': {
|
|
10
|
+
migrateEmberAddon(options);
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
case 'app': {
|
|
15
|
+
migrateEmberApp(options);
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
case 'engine': {
|
|
20
|
+
migrateEmberEngine(options);
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
default: {
|
|
25
|
+
console.error(`Unknown project type: ${options.projectType}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForComponentClasses(projectRoot) {
|
|
6
|
+
const oldPaths = glob.sync('addon/components/**/component.{d.ts,js,ts}', {
|
|
7
|
+
cwd: projectRoot,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return oldPaths.map((oldPath) => {
|
|
11
|
+
if (oldPath.endsWith('.d.ts')) {
|
|
12
|
+
return mapPaths(oldPath, {
|
|
13
|
+
find: {
|
|
14
|
+
directory: 'addon/components',
|
|
15
|
+
file: 'component.d.ts',
|
|
16
|
+
},
|
|
17
|
+
replace(key) {
|
|
18
|
+
return `addon/components/${key}.d.ts`;
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (oldPath.endsWith('.ts')) {
|
|
24
|
+
return mapPaths(oldPath, {
|
|
25
|
+
find: {
|
|
26
|
+
directory: 'addon/components',
|
|
27
|
+
file: 'component.ts',
|
|
28
|
+
},
|
|
29
|
+
replace(key) {
|
|
30
|
+
return `addon/components/${key}.ts`;
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return mapPaths(oldPath, {
|
|
36
|
+
find: {
|
|
37
|
+
directory: 'addon/components',
|
|
38
|
+
file: 'component.js',
|
|
39
|
+
},
|
|
40
|
+
replace(key) {
|
|
41
|
+
return `addon/components/${key}.js`;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForComponentStylesheets(projectRoot) {
|
|
6
|
+
const oldPaths = glob.sync('addon/components/**/styles.css', {
|
|
7
|
+
cwd: projectRoot,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return oldPaths.map((oldPath) => {
|
|
11
|
+
return mapPaths(oldPath, {
|
|
12
|
+
find: {
|
|
13
|
+
directory: 'addon/components',
|
|
14
|
+
file: 'styles.css',
|
|
15
|
+
},
|
|
16
|
+
replace(key) {
|
|
17
|
+
return `addon/components/${key}.css`;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForComponentTemplates(projectRoot) {
|
|
6
|
+
const oldPaths = glob.sync('addon/components/**/template.hbs', {
|
|
7
|
+
cwd: projectRoot,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return oldPaths.map((oldPath) => {
|
|
11
|
+
return mapPaths(oldPath, {
|
|
12
|
+
find: {
|
|
13
|
+
directory: 'addon/components',
|
|
14
|
+
file: 'template.hbs',
|
|
15
|
+
},
|
|
16
|
+
replace(key) {
|
|
17
|
+
return `addon/components/${key}.hbs`;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { migrationStrategyForComponentClasses } from './component-classes.js';
|
|
2
|
+
import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
|
|
3
|
+
import { migrationStrategyForComponentTemplates } from './component-templates.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForAddonFolder(projectRoot) {
|
|
6
|
+
return new Map([
|
|
7
|
+
...migrationStrategyForComponentClasses(projectRoot),
|
|
8
|
+
...migrationStrategyForComponentStylesheets(projectRoot),
|
|
9
|
+
...migrationStrategyForComponentTemplates(projectRoot),
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForComponentClasses(projectRoot) {
|
|
6
|
+
const oldPaths = glob.sync('app/components/**/component.js', {
|
|
7
|
+
cwd: projectRoot,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return oldPaths.map((oldPath) => {
|
|
11
|
+
return mapPaths(oldPath, {
|
|
12
|
+
find: {
|
|
13
|
+
directory: 'app/components',
|
|
14
|
+
file: 'component.js',
|
|
15
|
+
},
|
|
16
|
+
replace(key) {
|
|
17
|
+
return `app/components/${key}.js`;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForComponentStylesheets(projectRoot) {
|
|
6
|
+
const oldPaths = glob.sync('app/components/**/styles.js', {
|
|
7
|
+
cwd: projectRoot,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return oldPaths.map((oldPath) => {
|
|
11
|
+
return mapPaths(oldPath, {
|
|
12
|
+
find: {
|
|
13
|
+
directory: 'app/components',
|
|
14
|
+
file: 'styles.js',
|
|
15
|
+
},
|
|
16
|
+
replace(key) {
|
|
17
|
+
return `app/components/${key}.js`;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForComponentTemplates(projectRoot) {
|
|
6
|
+
const oldPaths = glob.sync('app/components/**/template.js', {
|
|
7
|
+
cwd: projectRoot,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return oldPaths.map((oldPath) => {
|
|
11
|
+
return mapPaths(oldPath, {
|
|
12
|
+
find: {
|
|
13
|
+
directory: 'app/components',
|
|
14
|
+
file: 'template.js',
|
|
15
|
+
},
|
|
16
|
+
replace(key) {
|
|
17
|
+
return `app/components/${key}.js`;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { migrationStrategyForComponentClasses } from './component-classes.js';
|
|
2
|
+
import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
|
|
3
|
+
import { migrationStrategyForComponentTemplates } from './component-templates.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForAppFolder(projectRoot) {
|
|
6
|
+
return new Map([
|
|
7
|
+
...migrationStrategyForComponentClasses(projectRoot),
|
|
8
|
+
...migrationStrategyForComponentStylesheets(projectRoot),
|
|
9
|
+
...migrationStrategyForComponentTemplates(projectRoot),
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { updatePaths } from '../../utils/ember-addon/app/components.js';
|
|
2
|
+
import { moveFiles } from '../../utils/move-files.js';
|
|
3
|
+
import { migrationStrategyForAddonFolder } from './addon/index.js';
|
|
4
|
+
import { migrationStrategyForAppFolder } from './app/index.js';
|
|
5
|
+
import { migrationStrategyForTestsFolder } from './tests/index.js';
|
|
6
|
+
|
|
7
|
+
export function migrateEmberAddon(options) {
|
|
8
|
+
const { projectRoot, testRun } = options;
|
|
9
|
+
|
|
10
|
+
const migrationStrategyAddon = migrationStrategyForAddonFolder(projectRoot);
|
|
11
|
+
const migrationStrategyApp = migrationStrategyForAppFolder(projectRoot);
|
|
12
|
+
const migrationStrategyTests = migrationStrategyForTestsFolder(projectRoot);
|
|
13
|
+
|
|
14
|
+
if (testRun) {
|
|
15
|
+
console.log({
|
|
16
|
+
migrationStrategyAddon,
|
|
17
|
+
migrationStrategyApp,
|
|
18
|
+
migrationStrategyTests,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
moveFiles({
|
|
25
|
+
migrationStrategy: migrationStrategyAddon,
|
|
26
|
+
projectRoot,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
moveFiles({
|
|
30
|
+
migrationStrategy: migrationStrategyApp,
|
|
31
|
+
projectRoot,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
moveFiles({
|
|
35
|
+
migrationStrategy: migrationStrategyTests,
|
|
36
|
+
projectRoot,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
updatePaths({
|
|
40
|
+
migrationStrategy: migrationStrategyApp,
|
|
41
|
+
projectRoot,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForComponents(projectRoot) {
|
|
6
|
+
const oldPaths = glob.sync(
|
|
7
|
+
'tests/integration/components/**/component-test.{js,ts}',
|
|
8
|
+
{
|
|
9
|
+
cwd: projectRoot,
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
return oldPaths.map((oldPath) => {
|
|
14
|
+
if (oldPath.endsWith('.ts')) {
|
|
15
|
+
return mapPaths(oldPath, {
|
|
16
|
+
find: {
|
|
17
|
+
directory: 'tests/integration/components',
|
|
18
|
+
file: 'component-test.ts',
|
|
19
|
+
},
|
|
20
|
+
replace(key) {
|
|
21
|
+
return `tests/integration/components/${key}-test.ts`;
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return mapPaths(oldPath, {
|
|
27
|
+
find: {
|
|
28
|
+
directory: 'tests/integration/components',
|
|
29
|
+
file: 'component-test.js',
|
|
30
|
+
},
|
|
31
|
+
replace(key) {
|
|
32
|
+
return `tests/integration/components/${key}-test.js`;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForComponentClasses(projectRoot) {
|
|
6
|
+
const oldPaths = glob.sync('app/components/**/component.{d.ts,js,ts}', {
|
|
7
|
+
cwd: projectRoot,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return oldPaths.map((oldPath) => {
|
|
11
|
+
if (oldPath.endsWith('.d.ts')) {
|
|
12
|
+
return mapPaths(oldPath, {
|
|
13
|
+
find: {
|
|
14
|
+
directory: 'app/components',
|
|
15
|
+
file: 'component.d.ts',
|
|
16
|
+
},
|
|
17
|
+
replace(key) {
|
|
18
|
+
return `app/components/${key}.d.ts`;
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (oldPath.endsWith('.ts')) {
|
|
24
|
+
return mapPaths(oldPath, {
|
|
25
|
+
find: {
|
|
26
|
+
directory: 'app/components',
|
|
27
|
+
file: 'component.ts',
|
|
28
|
+
},
|
|
29
|
+
replace(key) {
|
|
30
|
+
return `app/components/${key}.ts`;
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return mapPaths(oldPath, {
|
|
36
|
+
find: {
|
|
37
|
+
directory: 'app/components',
|
|
38
|
+
file: 'component.js',
|
|
39
|
+
},
|
|
40
|
+
replace(key) {
|
|
41
|
+
return `app/components/${key}.js`;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForComponentStylesheets(projectRoot) {
|
|
6
|
+
const oldPaths = glob.sync('app/components/**/styles.css', {
|
|
7
|
+
cwd: projectRoot,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return oldPaths.map((oldPath) => {
|
|
11
|
+
return mapPaths(oldPath, {
|
|
12
|
+
find: {
|
|
13
|
+
directory: 'app/components',
|
|
14
|
+
file: 'styles.css',
|
|
15
|
+
},
|
|
16
|
+
replace(key) {
|
|
17
|
+
return `app/components/${key}.css`;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForComponentTemplates(projectRoot) {
|
|
6
|
+
const oldPaths = glob.sync('app/components/**/template.hbs', {
|
|
7
|
+
cwd: projectRoot,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return oldPaths.map((oldPath) => {
|
|
11
|
+
return mapPaths(oldPath, {
|
|
12
|
+
find: {
|
|
13
|
+
directory: 'app/components',
|
|
14
|
+
file: 'template.hbs',
|
|
15
|
+
},
|
|
16
|
+
replace(key) {
|
|
17
|
+
return `app/components/${key}.hbs`;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { migrationStrategyForComponentClasses } from './component-classes.js';
|
|
2
|
+
import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
|
|
3
|
+
import { migrationStrategyForComponentTemplates } from './component-templates.js';
|
|
4
|
+
import { migrationStrategyForRouteAdapters } from './route-adapters.js';
|
|
5
|
+
import { migrationStrategyForRouteControllers } from './route-controllers.js';
|
|
6
|
+
import { migrationStrategyForRouteModels } from './route-models.js';
|
|
7
|
+
import { migrationStrategyForRouteRoutes } from './route-routes.js';
|
|
8
|
+
import { migrationStrategyForRouteSerializers } from './route-serializers.js';
|
|
9
|
+
import { migrationStrategyForRouteStylesheets } from './route-stylesheets.js';
|
|
10
|
+
import { migrationStrategyForRouteTemplates } from './route-templates.js';
|
|
11
|
+
|
|
12
|
+
export function migrationStrategyForAppFolder(projectRoot) {
|
|
13
|
+
return new Map([
|
|
14
|
+
...migrationStrategyForComponentClasses(projectRoot),
|
|
15
|
+
...migrationStrategyForComponentStylesheets(projectRoot),
|
|
16
|
+
...migrationStrategyForComponentTemplates(projectRoot),
|
|
17
|
+
...migrationStrategyForRouteAdapters(projectRoot),
|
|
18
|
+
...migrationStrategyForRouteControllers(projectRoot),
|
|
19
|
+
...migrationStrategyForRouteModels(projectRoot),
|
|
20
|
+
...migrationStrategyForRouteRoutes(projectRoot),
|
|
21
|
+
...migrationStrategyForRouteSerializers(projectRoot),
|
|
22
|
+
...migrationStrategyForRouteStylesheets(projectRoot),
|
|
23
|
+
...migrationStrategyForRouteTemplates(projectRoot),
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
|
|
3
|
+
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
|
+
|
|
5
|
+
export function migrationStrategyForRouteAdapters(projectRoot) {
|
|
6
|
+
const oldPaths = glob.sync('app/**/adapter.{js,ts}', {
|
|
7
|
+
cwd: projectRoot,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return oldPaths.map((oldPath) => {
|
|
11
|
+
if (oldPath.endsWith('.ts')) {
|
|
12
|
+
return mapPaths(oldPath, {
|
|
13
|
+
find: {
|
|
14
|
+
directory: 'app',
|
|
15
|
+
file: 'adapter.ts',
|
|
16
|
+
},
|
|
17
|
+
replace(key) {
|
|
18
|
+
return `app/adapters/${key}.ts`;
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return mapPaths(oldPath, {
|
|
24
|
+
find: {
|
|
25
|
+
directory: 'app',
|
|
26
|
+
file: 'adapter.js',
|
|
27
|
+
},
|
|
28
|
+
replace(key) {
|
|
29
|
+
return `app/adapters/${key}.js`;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|