ember-codemod-pod-to-octane 0.2.0 → 0.3.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/README.md +13 -0
- package/bin/ember-codemod-pod-to-octane.js +6 -0
- package/package.json +2 -2
- package/src/migration/ember-addon/addon/component-classes.js +3 -1
- package/src/migration/ember-addon/addon/component-stylesheets.js +16 -2
- package/src/migration/ember-addon/addon/component-templates.js +3 -1
- package/src/migration/ember-addon/addon/index.js +4 -4
- package/src/migration/ember-addon/app/component-classes.js +3 -1
- package/src/migration/ember-addon/app/component-stylesheets.js +3 -1
- package/src/migration/ember-addon/app/component-templates.js +3 -1
- package/src/migration/ember-addon/app/index.js +4 -4
- package/src/migration/ember-addon/index.js +8 -24
- package/src/migration/ember-addon/tests/components.js +3 -1
- package/src/migration/ember-addon/tests/index.js +2 -2
- package/src/migration/ember-app/app/component-classes.js +13 -7
- package/src/migration/ember-app/app/component-stylesheets.js +23 -5
- package/src/migration/ember-app/app/component-templates.js +11 -5
- package/src/migration/ember-app/app/index.js +12 -12
- package/src/migration/ember-app/app/route-adapters.js +7 -4
- package/src/migration/ember-app/app/route-controllers.js +7 -4
- package/src/migration/ember-app/app/route-models.js +7 -4
- package/src/migration/ember-app/app/route-routes.js +7 -4
- package/src/migration/ember-app/app/route-serializers.js +7 -4
- package/src/migration/ember-app/app/route-stylesheets.js +23 -5
- package/src/migration/ember-app/app/route-templates.js +11 -5
- package/src/migration/ember-app/app/services.js +7 -4
- package/src/migration/ember-app/index.js +5 -14
- package/src/migration/ember-app/tests/components.js +13 -4
- package/src/migration/ember-app/tests/index.js +5 -5
- package/src/migration/ember-app/tests/route-controllers.js +16 -7
- package/src/migration/ember-app/tests/route-routes.js +20 -11
- package/src/migration/ember-app/tests/services.js +12 -6
- package/src/migration/ember-engine/addon/component-classes.js +3 -1
- package/src/migration/ember-engine/addon/component-stylesheets.js +16 -2
- package/src/migration/ember-engine/addon/component-templates.js +3 -1
- package/src/migration/ember-engine/addon/index.js +8 -8
- package/src/migration/ember-engine/addon/route-controllers.js +3 -1
- package/src/migration/ember-engine/addon/route-routes.js +3 -1
- package/src/migration/ember-engine/addon/route-stylesheets.js +16 -2
- package/src/migration/ember-engine/addon/route-templates.js +3 -1
- package/src/migration/ember-engine/index.js +5 -14
- package/src/migration/ember-engine/tests/components.js +3 -1
- package/src/migration/ember-engine/tests/index.js +4 -4
- package/src/migration/ember-engine/tests/route-controllers.js +3 -1
- package/src/migration/ember-engine/tests/route-routes.js +3 -1
- package/src/utils/ember-addon/app/components.js +3 -1
- package/src/utils/move-files.js +21 -9
package/README.md
CHANGED
|
@@ -54,6 +54,19 @@ npx ember-codemod-pod-to-octane --root=<your/project/path>
|
|
|
54
54
|
</details>
|
|
55
55
|
|
|
56
56
|
|
|
57
|
+
<details>
|
|
58
|
+
<summary>Optional: Specify the pod path</summary>
|
|
59
|
+
|
|
60
|
+
Pass `--pod-path` if `podModulePrefix` is set in `config/environment.js` and has a different value than `modulePrefix`. "Subtract" `modulePrefix` from `podModulePrefix` to get the pod path.
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
# If modulePrefix is 'my-app' and podModulePrefix is 'my-app/pods'
|
|
64
|
+
npx ember-codemod-pod-to-octane --pod-path=pods
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
</details>
|
|
68
|
+
|
|
69
|
+
|
|
57
70
|
### Limitations
|
|
58
71
|
|
|
59
72
|
The codemod is designed to cover typical uses of an Ember app, addon, and engine. It is not designed to cover one-off cases.
|
|
@@ -11,6 +11,11 @@ process.title = 'ember-codemod-pod-to-octane';
|
|
|
11
11
|
|
|
12
12
|
// Set codemod options
|
|
13
13
|
const { argv } = yargs(hideBin(process.argv))
|
|
14
|
+
.option('pod-path', {
|
|
15
|
+
default: '',
|
|
16
|
+
describe: 'Namespace used for the pod layout',
|
|
17
|
+
type: 'string',
|
|
18
|
+
})
|
|
14
19
|
.option('root', {
|
|
15
20
|
describe: 'Location of your Ember project',
|
|
16
21
|
type: 'string',
|
|
@@ -28,6 +33,7 @@ const { argv } = yargs(hideBin(process.argv))
|
|
|
28
33
|
});
|
|
29
34
|
|
|
30
35
|
const options = {
|
|
36
|
+
podPath: argv['pod-path'],
|
|
31
37
|
projectRoot: argv['root'] ?? process.cwd(),
|
|
32
38
|
projectType: argv['type'],
|
|
33
39
|
testRun: argv['test'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-pod-to-octane",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Codemod to un-pod Ember apps, addons, and engines",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-codemod",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lint": "eslint . --cache --ext=.cjs,.js",
|
|
29
29
|
"lint:fix": "eslint . --fix",
|
|
30
30
|
"start": "node ./src/index.js",
|
|
31
|
-
"test": "
|
|
31
|
+
"test": "mt tests --quiet"
|
|
32
32
|
},
|
|
33
33
|
"changelog": {
|
|
34
34
|
"labels": {
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForComponentClasses(
|
|
5
|
+
export function migrationStrategyForComponentClasses(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync('addon/components/**/component.{d.ts,js,ts}', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
@@ -2,12 +2,26 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForComponentStylesheets(
|
|
6
|
-
const
|
|
5
|
+
export function migrationStrategyForComponentStylesheets(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
8
|
+
const oldPaths = glob.sync('addon/components/**/styles.{css,scss}', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
9
11
|
|
|
10
12
|
return oldPaths.map((oldPath) => {
|
|
13
|
+
if (oldPath.endsWith('.scss')) {
|
|
14
|
+
return mapPaths(oldPath, {
|
|
15
|
+
find: {
|
|
16
|
+
directory: 'addon/components',
|
|
17
|
+
file: 'styles.scss',
|
|
18
|
+
},
|
|
19
|
+
replace(key) {
|
|
20
|
+
return `addon/components/${key}.scss`;
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
11
25
|
return mapPaths(oldPath, {
|
|
12
26
|
find: {
|
|
13
27
|
directory: 'addon/components',
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForComponentTemplates(
|
|
5
|
+
export function migrationStrategyForComponentTemplates(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync('addon/components/**/template.hbs', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
@@ -2,10 +2,10 @@ import { migrationStrategyForComponentClasses } from './component-classes.js';
|
|
|
2
2
|
import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
|
|
3
3
|
import { migrationStrategyForComponentTemplates } from './component-templates.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForAddonFolder(
|
|
5
|
+
export function migrationStrategyForAddonFolder(options) {
|
|
6
6
|
return new Map([
|
|
7
|
-
...migrationStrategyForComponentClasses(
|
|
8
|
-
...migrationStrategyForComponentStylesheets(
|
|
9
|
-
...migrationStrategyForComponentTemplates(
|
|
7
|
+
...migrationStrategyForComponentClasses(options),
|
|
8
|
+
...migrationStrategyForComponentStylesheets(options),
|
|
9
|
+
...migrationStrategyForComponentTemplates(options),
|
|
10
10
|
]);
|
|
11
11
|
}
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForComponentClasses(
|
|
5
|
+
export function migrationStrategyForComponentClasses(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync('app/components/**/component.js', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForComponentStylesheets(
|
|
5
|
+
export function migrationStrategyForComponentStylesheets(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync('app/components/**/styles.js', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForComponentTemplates(
|
|
5
|
+
export function migrationStrategyForComponentTemplates(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync('app/components/**/template.js', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
@@ -2,10 +2,10 @@ import { migrationStrategyForComponentClasses } from './component-classes.js';
|
|
|
2
2
|
import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
|
|
3
3
|
import { migrationStrategyForComponentTemplates } from './component-templates.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForAppFolder(
|
|
5
|
+
export function migrationStrategyForAppFolder(options) {
|
|
6
6
|
return new Map([
|
|
7
|
-
...migrationStrategyForComponentClasses(
|
|
8
|
-
...migrationStrategyForComponentStylesheets(
|
|
9
|
-
...migrationStrategyForComponentTemplates(
|
|
7
|
+
...migrationStrategyForComponentClasses(options),
|
|
8
|
+
...migrationStrategyForComponentStylesheets(options),
|
|
9
|
+
...migrationStrategyForComponentTemplates(options),
|
|
10
10
|
]);
|
|
11
11
|
}
|
|
@@ -5,13 +5,11 @@ import { migrationStrategyForAppFolder } from './app/index.js';
|
|
|
5
5
|
import { migrationStrategyForTestsFolder } from './tests/index.js';
|
|
6
6
|
|
|
7
7
|
export function migrateEmberAddon(options) {
|
|
8
|
-
const
|
|
8
|
+
const migrationStrategyAddon = migrationStrategyForAddonFolder(options);
|
|
9
|
+
const migrationStrategyApp = migrationStrategyForAppFolder(options);
|
|
10
|
+
const migrationStrategyTests = migrationStrategyForTestsFolder(options);
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
const migrationStrategyApp = migrationStrategyForAppFolder(projectRoot);
|
|
12
|
-
const migrationStrategyTests = migrationStrategyForTestsFolder(projectRoot);
|
|
13
|
-
|
|
14
|
-
if (testRun) {
|
|
12
|
+
if (options.testRun) {
|
|
15
13
|
console.log({
|
|
16
14
|
migrationStrategyAddon,
|
|
17
15
|
migrationStrategyApp,
|
|
@@ -21,23 +19,9 @@ export function migrateEmberAddon(options) {
|
|
|
21
19
|
return;
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
moveFiles(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
moveFiles({
|
|
30
|
-
migrationStrategy: migrationStrategyApp,
|
|
31
|
-
projectRoot,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
moveFiles({
|
|
35
|
-
migrationStrategy: migrationStrategyTests,
|
|
36
|
-
projectRoot,
|
|
37
|
-
});
|
|
22
|
+
moveFiles(migrationStrategyAddon, options);
|
|
23
|
+
moveFiles(migrationStrategyApp, options);
|
|
24
|
+
moveFiles(migrationStrategyTests, options);
|
|
38
25
|
|
|
39
|
-
updatePaths(
|
|
40
|
-
migrationStrategy: migrationStrategyApp,
|
|
41
|
-
projectRoot,
|
|
42
|
-
});
|
|
26
|
+
updatePaths(migrationStrategyApp, options);
|
|
43
27
|
}
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForComponents(
|
|
5
|
+
export function migrationStrategyForComponents(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync(
|
|
7
9
|
'tests/integration/components/**/component-test.{js,ts}',
|
|
8
10
|
{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { migrationStrategyForComponents } from './components.js';
|
|
2
2
|
|
|
3
|
-
export function migrationStrategyForTestsFolder(
|
|
4
|
-
return new Map([...migrationStrategyForComponents(
|
|
3
|
+
export function migrationStrategyForTestsFolder(options) {
|
|
4
|
+
return new Map([...migrationStrategyForComponents(options)]);
|
|
5
5
|
}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForComponentClasses(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export function migrationStrategyForComponentClasses(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(
|
|
10
|
+
join('app', podPath, 'components', '**', 'component.{d.ts,js,ts}'),
|
|
11
|
+
{
|
|
12
|
+
cwd: projectRoot,
|
|
13
|
+
}
|
|
14
|
+
);
|
|
9
15
|
|
|
10
16
|
return oldPaths.map((oldPath) => {
|
|
11
17
|
if (oldPath.endsWith('.d.ts')) {
|
|
12
18
|
return mapPaths(oldPath, {
|
|
13
19
|
find: {
|
|
14
|
-
directory: 'app
|
|
20
|
+
directory: join('app', podPath, 'components'),
|
|
15
21
|
file: 'component.d.ts',
|
|
16
22
|
},
|
|
17
23
|
replace(key) {
|
|
@@ -23,7 +29,7 @@ export function migrationStrategyForComponentClasses(projectRoot) {
|
|
|
23
29
|
if (oldPath.endsWith('.ts')) {
|
|
24
30
|
return mapPaths(oldPath, {
|
|
25
31
|
find: {
|
|
26
|
-
directory: 'app
|
|
32
|
+
directory: join('app', podPath, 'components'),
|
|
27
33
|
file: 'component.ts',
|
|
28
34
|
},
|
|
29
35
|
replace(key) {
|
|
@@ -34,7 +40,7 @@ export function migrationStrategyForComponentClasses(projectRoot) {
|
|
|
34
40
|
|
|
35
41
|
return mapPaths(oldPath, {
|
|
36
42
|
find: {
|
|
37
|
-
directory: 'app
|
|
43
|
+
directory: join('app', podPath, 'components'),
|
|
38
44
|
file: 'component.js',
|
|
39
45
|
},
|
|
40
46
|
replace(key) {
|
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForComponentStylesheets(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export function migrationStrategyForComponentStylesheets(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(
|
|
10
|
+
join('app', podPath, 'components', '**', 'styles.{css,scss}'),
|
|
11
|
+
{
|
|
12
|
+
cwd: projectRoot,
|
|
13
|
+
}
|
|
14
|
+
);
|
|
9
15
|
|
|
10
16
|
return oldPaths.map((oldPath) => {
|
|
17
|
+
if (oldPath.endsWith('.scss')) {
|
|
18
|
+
return mapPaths(oldPath, {
|
|
19
|
+
find: {
|
|
20
|
+
directory: join('app', podPath, 'components'),
|
|
21
|
+
file: 'styles.scss',
|
|
22
|
+
},
|
|
23
|
+
replace(key) {
|
|
24
|
+
return `app/components/${key}.scss`;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
11
29
|
return mapPaths(oldPath, {
|
|
12
30
|
find: {
|
|
13
|
-
directory: 'app
|
|
31
|
+
directory: join('app', podPath, 'components'),
|
|
14
32
|
file: 'styles.css',
|
|
15
33
|
},
|
|
16
34
|
replace(key) {
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForComponentTemplates(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export function migrationStrategyForComponentTemplates(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(
|
|
10
|
+
join('app', podPath, 'components', '**', 'template.hbs'),
|
|
11
|
+
{
|
|
12
|
+
cwd: projectRoot,
|
|
13
|
+
}
|
|
14
|
+
);
|
|
9
15
|
|
|
10
16
|
return oldPaths.map((oldPath) => {
|
|
11
17
|
return mapPaths(oldPath, {
|
|
12
18
|
find: {
|
|
13
|
-
directory: 'app
|
|
19
|
+
directory: join('app', podPath, 'components'),
|
|
14
20
|
file: 'template.hbs',
|
|
15
21
|
},
|
|
16
22
|
replace(key) {
|
|
@@ -10,18 +10,18 @@ import { migrationStrategyForRouteStylesheets } from './route-stylesheets.js';
|
|
|
10
10
|
import { migrationStrategyForRouteTemplates } from './route-templates.js';
|
|
11
11
|
import { migrationStrategyForServices } from './services.js';
|
|
12
12
|
|
|
13
|
-
export function migrationStrategyForAppFolder(
|
|
13
|
+
export function migrationStrategyForAppFolder(options) {
|
|
14
14
|
return new Map([
|
|
15
|
-
...migrationStrategyForComponentClasses(
|
|
16
|
-
...migrationStrategyForComponentStylesheets(
|
|
17
|
-
...migrationStrategyForComponentTemplates(
|
|
18
|
-
...migrationStrategyForRouteAdapters(
|
|
19
|
-
...migrationStrategyForRouteControllers(
|
|
20
|
-
...migrationStrategyForRouteModels(
|
|
21
|
-
...migrationStrategyForRouteRoutes(
|
|
22
|
-
...migrationStrategyForRouteSerializers(
|
|
23
|
-
...migrationStrategyForRouteStylesheets(
|
|
24
|
-
...migrationStrategyForRouteTemplates(
|
|
25
|
-
...migrationStrategyForServices(
|
|
15
|
+
...migrationStrategyForComponentClasses(options),
|
|
16
|
+
...migrationStrategyForComponentStylesheets(options),
|
|
17
|
+
...migrationStrategyForComponentTemplates(options),
|
|
18
|
+
...migrationStrategyForRouteAdapters(options),
|
|
19
|
+
...migrationStrategyForRouteControllers(options),
|
|
20
|
+
...migrationStrategyForRouteModels(options),
|
|
21
|
+
...migrationStrategyForRouteRoutes(options),
|
|
22
|
+
...migrationStrategyForRouteSerializers(options),
|
|
23
|
+
...migrationStrategyForRouteStylesheets(options),
|
|
24
|
+
...migrationStrategyForRouteTemplates(options),
|
|
25
|
+
...migrationStrategyForServices(options),
|
|
26
26
|
]);
|
|
27
27
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForRouteAdapters(
|
|
6
|
-
const
|
|
6
|
+
export function migrationStrategyForRouteAdapters(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(join('app', podPath, '**', 'adapter.{js,ts}'), {
|
|
7
10
|
cwd: projectRoot,
|
|
8
11
|
});
|
|
9
12
|
|
|
@@ -11,7 +14,7 @@ export function migrationStrategyForRouteAdapters(projectRoot) {
|
|
|
11
14
|
if (oldPath.endsWith('.ts')) {
|
|
12
15
|
return mapPaths(oldPath, {
|
|
13
16
|
find: {
|
|
14
|
-
directory: 'app',
|
|
17
|
+
directory: join('app', podPath),
|
|
15
18
|
file: 'adapter.ts',
|
|
16
19
|
},
|
|
17
20
|
replace(key) {
|
|
@@ -22,7 +25,7 @@ export function migrationStrategyForRouteAdapters(projectRoot) {
|
|
|
22
25
|
|
|
23
26
|
return mapPaths(oldPath, {
|
|
24
27
|
find: {
|
|
25
|
-
directory: 'app',
|
|
28
|
+
directory: join('app', podPath),
|
|
26
29
|
file: 'adapter.js',
|
|
27
30
|
},
|
|
28
31
|
replace(key) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForRouteControllers(
|
|
6
|
-
const
|
|
6
|
+
export function migrationStrategyForRouteControllers(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(join('app', podPath, '**', 'controller.{js,ts}'), {
|
|
7
10
|
cwd: projectRoot,
|
|
8
11
|
});
|
|
9
12
|
|
|
@@ -11,7 +14,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
11
14
|
if (oldPath.endsWith('.ts')) {
|
|
12
15
|
return mapPaths(oldPath, {
|
|
13
16
|
find: {
|
|
14
|
-
directory: 'app',
|
|
17
|
+
directory: join('app', podPath),
|
|
15
18
|
file: 'controller.ts',
|
|
16
19
|
},
|
|
17
20
|
replace(key) {
|
|
@@ -22,7 +25,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
22
25
|
|
|
23
26
|
return mapPaths(oldPath, {
|
|
24
27
|
find: {
|
|
25
|
-
directory: 'app',
|
|
28
|
+
directory: join('app', podPath),
|
|
26
29
|
file: 'controller.js',
|
|
27
30
|
},
|
|
28
31
|
replace(key) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForRouteModels(
|
|
6
|
-
const
|
|
6
|
+
export function migrationStrategyForRouteModels(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(join('app', podPath, '**', 'model.{js,ts}'), {
|
|
7
10
|
cwd: projectRoot,
|
|
8
11
|
});
|
|
9
12
|
|
|
@@ -11,7 +14,7 @@ export function migrationStrategyForRouteModels(projectRoot) {
|
|
|
11
14
|
if (oldPath.endsWith('.ts')) {
|
|
12
15
|
return mapPaths(oldPath, {
|
|
13
16
|
find: {
|
|
14
|
-
directory: 'app',
|
|
17
|
+
directory: join('app', podPath),
|
|
15
18
|
file: 'model.ts',
|
|
16
19
|
},
|
|
17
20
|
replace(key) {
|
|
@@ -22,7 +25,7 @@ export function migrationStrategyForRouteModels(projectRoot) {
|
|
|
22
25
|
|
|
23
26
|
return mapPaths(oldPath, {
|
|
24
27
|
find: {
|
|
25
|
-
directory: 'app',
|
|
28
|
+
directory: join('app', podPath),
|
|
26
29
|
file: 'model.js',
|
|
27
30
|
},
|
|
28
31
|
replace(key) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForRouteRoutes(
|
|
6
|
-
const
|
|
6
|
+
export function migrationStrategyForRouteRoutes(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(join('app', podPath, '**', 'route.{js,ts}'), {
|
|
7
10
|
cwd: projectRoot,
|
|
8
11
|
});
|
|
9
12
|
|
|
@@ -11,7 +14,7 @@ export function migrationStrategyForRouteRoutes(projectRoot) {
|
|
|
11
14
|
if (oldPath.endsWith('.ts')) {
|
|
12
15
|
return mapPaths(oldPath, {
|
|
13
16
|
find: {
|
|
14
|
-
directory: 'app',
|
|
17
|
+
directory: join('app', podPath),
|
|
15
18
|
file: 'route.ts',
|
|
16
19
|
},
|
|
17
20
|
replace(key) {
|
|
@@ -22,7 +25,7 @@ export function migrationStrategyForRouteRoutes(projectRoot) {
|
|
|
22
25
|
|
|
23
26
|
return mapPaths(oldPath, {
|
|
24
27
|
find: {
|
|
25
|
-
directory: 'app',
|
|
28
|
+
directory: join('app', podPath),
|
|
26
29
|
file: 'route.js',
|
|
27
30
|
},
|
|
28
31
|
replace(key) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForRouteSerializers(
|
|
6
|
-
const
|
|
6
|
+
export function migrationStrategyForRouteSerializers(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(join('app', podPath, '**', 'serializer.{js,ts}'), {
|
|
7
10
|
cwd: projectRoot,
|
|
8
11
|
});
|
|
9
12
|
|
|
@@ -11,7 +14,7 @@ export function migrationStrategyForRouteSerializers(projectRoot) {
|
|
|
11
14
|
if (oldPath.endsWith('.ts')) {
|
|
12
15
|
return mapPaths(oldPath, {
|
|
13
16
|
find: {
|
|
14
|
-
directory: 'app',
|
|
17
|
+
directory: join('app', podPath),
|
|
15
18
|
file: 'serializer.ts',
|
|
16
19
|
},
|
|
17
20
|
replace(key) {
|
|
@@ -22,7 +25,7 @@ export function migrationStrategyForRouteSerializers(projectRoot) {
|
|
|
22
25
|
|
|
23
26
|
return mapPaths(oldPath, {
|
|
24
27
|
find: {
|
|
25
|
-
directory: 'app',
|
|
28
|
+
directory: join('app', podPath),
|
|
26
29
|
file: 'serializer.js',
|
|
27
30
|
},
|
|
28
31
|
replace(key) {
|
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForRouteStylesheets(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export function migrationStrategyForRouteStylesheets(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(
|
|
10
|
+
join('app', podPath, '!(components)', '**', 'styles.{css,scss}'),
|
|
11
|
+
{
|
|
12
|
+
cwd: projectRoot,
|
|
13
|
+
}
|
|
14
|
+
);
|
|
9
15
|
|
|
10
16
|
return oldPaths.map((oldPath) => {
|
|
17
|
+
if (oldPath.endsWith('.scss')) {
|
|
18
|
+
return mapPaths(oldPath, {
|
|
19
|
+
find: {
|
|
20
|
+
directory: join('app', podPath),
|
|
21
|
+
file: 'styles.scss',
|
|
22
|
+
},
|
|
23
|
+
replace(key) {
|
|
24
|
+
return `app/styles/${key}.scss`;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
11
29
|
return mapPaths(oldPath, {
|
|
12
30
|
find: {
|
|
13
|
-
directory: 'app',
|
|
31
|
+
directory: join('app', podPath),
|
|
14
32
|
file: 'styles.css',
|
|
15
33
|
},
|
|
16
34
|
replace(key) {
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForRouteTemplates(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export function migrationStrategyForRouteTemplates(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(
|
|
10
|
+
join('app', podPath, '!(components)', '**', 'template.hbs'),
|
|
11
|
+
{
|
|
12
|
+
cwd: projectRoot,
|
|
13
|
+
}
|
|
14
|
+
);
|
|
9
15
|
|
|
10
16
|
return oldPaths.map((oldPath) => {
|
|
11
17
|
return mapPaths(oldPath, {
|
|
12
18
|
find: {
|
|
13
|
-
directory: 'app',
|
|
19
|
+
directory: join('app', podPath),
|
|
14
20
|
file: 'template.hbs',
|
|
15
21
|
},
|
|
16
22
|
replace(key) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForServices(
|
|
6
|
-
const
|
|
6
|
+
export function migrationStrategyForServices(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(join('app', podPath, '**', 'service.{js,ts}'), {
|
|
7
10
|
cwd: projectRoot,
|
|
8
11
|
});
|
|
9
12
|
|
|
@@ -11,7 +14,7 @@ export function migrationStrategyForServices(projectRoot) {
|
|
|
11
14
|
if (oldPath.endsWith('.ts')) {
|
|
12
15
|
return mapPaths(oldPath, {
|
|
13
16
|
find: {
|
|
14
|
-
directory: 'app',
|
|
17
|
+
directory: join('app', podPath),
|
|
15
18
|
file: 'service.ts',
|
|
16
19
|
},
|
|
17
20
|
replace(key) {
|
|
@@ -22,7 +25,7 @@ export function migrationStrategyForServices(projectRoot) {
|
|
|
22
25
|
|
|
23
26
|
return mapPaths(oldPath, {
|
|
24
27
|
find: {
|
|
25
|
-
directory: 'app',
|
|
28
|
+
directory: join('app', podPath),
|
|
26
29
|
file: 'service.js',
|
|
27
30
|
},
|
|
28
31
|
replace(key) {
|
|
@@ -3,12 +3,10 @@ import { migrationStrategyForAppFolder } from './app/index.js';
|
|
|
3
3
|
import { migrationStrategyForTestsFolder } from './tests/index.js';
|
|
4
4
|
|
|
5
5
|
export function migrateEmberApp(options) {
|
|
6
|
-
const
|
|
6
|
+
const migrationStrategyApp = migrationStrategyForAppFolder(options);
|
|
7
|
+
const migrationStrategyTests = migrationStrategyForTestsFolder(options);
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
const migrationStrategyTests = migrationStrategyForTestsFolder(projectRoot);
|
|
10
|
-
|
|
11
|
-
if (testRun) {
|
|
9
|
+
if (options.testRun) {
|
|
12
10
|
console.log({
|
|
13
11
|
migrationStrategyApp,
|
|
14
12
|
migrationStrategyTests,
|
|
@@ -17,13 +15,6 @@ export function migrateEmberApp(options) {
|
|
|
17
15
|
return;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
moveFiles(
|
|
21
|
-
|
|
22
|
-
projectRoot,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
moveFiles({
|
|
26
|
-
migrationStrategy: migrationStrategyTests,
|
|
27
|
-
projectRoot,
|
|
28
|
-
});
|
|
18
|
+
moveFiles(migrationStrategyApp, options);
|
|
19
|
+
moveFiles(migrationStrategyTests, options);
|
|
29
20
|
}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForComponents(
|
|
6
|
+
export function migrationStrategyForComponents(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
6
9
|
const oldPaths = glob.sync(
|
|
7
|
-
|
|
10
|
+
join(
|
|
11
|
+
'tests/integration',
|
|
12
|
+
podPath,
|
|
13
|
+
'components',
|
|
14
|
+
'**',
|
|
15
|
+
'component-test.{js,ts}'
|
|
16
|
+
),
|
|
8
17
|
{
|
|
9
18
|
cwd: projectRoot,
|
|
10
19
|
}
|
|
@@ -14,7 +23,7 @@ export function migrationStrategyForComponents(projectRoot) {
|
|
|
14
23
|
if (oldPath.endsWith('.ts')) {
|
|
15
24
|
return mapPaths(oldPath, {
|
|
16
25
|
find: {
|
|
17
|
-
directory: 'tests/integration
|
|
26
|
+
directory: join('tests/integration', podPath, 'components'),
|
|
18
27
|
file: 'component-test.ts',
|
|
19
28
|
},
|
|
20
29
|
replace(key) {
|
|
@@ -25,7 +34,7 @@ export function migrationStrategyForComponents(projectRoot) {
|
|
|
25
34
|
|
|
26
35
|
return mapPaths(oldPath, {
|
|
27
36
|
find: {
|
|
28
|
-
directory: 'tests/integration
|
|
37
|
+
directory: join('tests/integration', podPath, 'components'),
|
|
29
38
|
file: 'component-test.js',
|
|
30
39
|
},
|
|
31
40
|
replace(key) {
|
|
@@ -3,11 +3,11 @@ import { migrationStrategyForRouteControllers } from './route-controllers.js';
|
|
|
3
3
|
import { migrationStrategyForRouteRoutes } from './route-routes.js';
|
|
4
4
|
import { migrationStrategyForServices } from './services.js';
|
|
5
5
|
|
|
6
|
-
export function migrationStrategyForTestsFolder(
|
|
6
|
+
export function migrationStrategyForTestsFolder(options) {
|
|
7
7
|
return new Map([
|
|
8
|
-
...migrationStrategyForComponents(
|
|
9
|
-
...migrationStrategyForRouteControllers(
|
|
10
|
-
...migrationStrategyForRouteRoutes(
|
|
11
|
-
...migrationStrategyForServices(
|
|
8
|
+
...migrationStrategyForComponents(options),
|
|
9
|
+
...migrationStrategyForRouteControllers(options),
|
|
10
|
+
...migrationStrategyForRouteRoutes(options),
|
|
11
|
+
...migrationStrategyForServices(options),
|
|
12
12
|
]);
|
|
13
13
|
}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForRouteControllers(
|
|
6
|
+
export function migrationStrategyForRouteControllers(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
6
9
|
/*
|
|
7
10
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
8
11
|
*/
|
|
9
12
|
const oldPaths1 = glob.sync(
|
|
10
|
-
|
|
13
|
+
join(
|
|
14
|
+
'tests/unit',
|
|
15
|
+
podPath,
|
|
16
|
+
'!(controllers)',
|
|
17
|
+
'**',
|
|
18
|
+
'controller-test.{js,ts}'
|
|
19
|
+
),
|
|
11
20
|
{
|
|
12
21
|
cwd: projectRoot,
|
|
13
22
|
}
|
|
@@ -17,7 +26,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
17
26
|
if (oldPath.endsWith('.ts')) {
|
|
18
27
|
return mapPaths(oldPath, {
|
|
19
28
|
find: {
|
|
20
|
-
directory: 'tests/unit',
|
|
29
|
+
directory: join('tests/unit', podPath),
|
|
21
30
|
file: 'controller-test.ts',
|
|
22
31
|
},
|
|
23
32
|
replace(key) {
|
|
@@ -28,7 +37,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
28
37
|
|
|
29
38
|
return mapPaths(oldPath, {
|
|
30
39
|
find: {
|
|
31
|
-
directory: 'tests/unit',
|
|
40
|
+
directory: join('tests/unit', podPath),
|
|
32
41
|
file: 'controller-test.js',
|
|
33
42
|
},
|
|
34
43
|
replace(key) {
|
|
@@ -41,7 +50,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
41
50
|
Case 2: Passed the --pod flag to Ember CLI
|
|
42
51
|
*/
|
|
43
52
|
const oldPaths2 = glob.sync(
|
|
44
|
-
'tests/unit
|
|
53
|
+
join('tests/unit', podPath, 'controllers/**/controller-test.{js,ts}'),
|
|
45
54
|
{
|
|
46
55
|
cwd: projectRoot,
|
|
47
56
|
}
|
|
@@ -51,7 +60,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
51
60
|
if (oldPath.endsWith('.ts')) {
|
|
52
61
|
return mapPaths(oldPath, {
|
|
53
62
|
find: {
|
|
54
|
-
directory: 'tests/unit
|
|
63
|
+
directory: join('tests/unit', podPath, 'controllers'),
|
|
55
64
|
file: 'controller-test.ts',
|
|
56
65
|
},
|
|
57
66
|
replace(key) {
|
|
@@ -62,7 +71,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
62
71
|
|
|
63
72
|
return mapPaths(oldPath, {
|
|
64
73
|
find: {
|
|
65
|
-
directory: 'tests/unit
|
|
74
|
+
directory: join('tests/unit', podPath, 'controllers'),
|
|
66
75
|
file: 'controller-test.js',
|
|
67
76
|
},
|
|
68
77
|
replace(key) {
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForRouteRoutes(
|
|
6
|
+
export function migrationStrategyForRouteRoutes(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
6
9
|
/*
|
|
7
10
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
8
11
|
*/
|
|
9
|
-
const oldPaths1 = glob.sync(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const oldPaths1 = glob.sync(
|
|
13
|
+
join('tests/unit', podPath, '!(routes)', '**', 'route-test.{js,ts}'),
|
|
14
|
+
{
|
|
15
|
+
cwd: projectRoot,
|
|
16
|
+
}
|
|
17
|
+
);
|
|
12
18
|
|
|
13
19
|
const newPaths1 = oldPaths1.map((oldPath) => {
|
|
14
20
|
if (oldPath.endsWith('.ts')) {
|
|
15
21
|
return mapPaths(oldPath, {
|
|
16
22
|
find: {
|
|
17
|
-
directory: 'tests/unit',
|
|
23
|
+
directory: join('tests/unit', podPath),
|
|
18
24
|
file: 'route-test.ts',
|
|
19
25
|
},
|
|
20
26
|
replace(key) {
|
|
@@ -25,7 +31,7 @@ export function migrationStrategyForRouteRoutes(projectRoot) {
|
|
|
25
31
|
|
|
26
32
|
return mapPaths(oldPath, {
|
|
27
33
|
find: {
|
|
28
|
-
directory: 'tests/unit',
|
|
34
|
+
directory: join('tests/unit', podPath),
|
|
29
35
|
file: 'route-test.js',
|
|
30
36
|
},
|
|
31
37
|
replace(key) {
|
|
@@ -37,15 +43,18 @@ export function migrationStrategyForRouteRoutes(projectRoot) {
|
|
|
37
43
|
/*
|
|
38
44
|
Case 2: Passed the --pod flag to Ember CLI
|
|
39
45
|
*/
|
|
40
|
-
const oldPaths2 = glob.sync(
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
const oldPaths2 = glob.sync(
|
|
47
|
+
join('tests/unit', podPath, 'routes/**/route-test.{js,ts}'),
|
|
48
|
+
{
|
|
49
|
+
cwd: projectRoot,
|
|
50
|
+
}
|
|
51
|
+
);
|
|
43
52
|
|
|
44
53
|
const newPaths2 = oldPaths2.map((oldPath) => {
|
|
45
54
|
if (oldPath.endsWith('.ts')) {
|
|
46
55
|
return mapPaths(oldPath, {
|
|
47
56
|
find: {
|
|
48
|
-
directory: 'tests/unit
|
|
57
|
+
directory: join('tests/unit', podPath, 'routes'),
|
|
49
58
|
file: 'route-test.ts',
|
|
50
59
|
},
|
|
51
60
|
replace(key) {
|
|
@@ -56,7 +65,7 @@ export function migrationStrategyForRouteRoutes(projectRoot) {
|
|
|
56
65
|
|
|
57
66
|
return mapPaths(oldPath, {
|
|
58
67
|
find: {
|
|
59
|
-
directory: 'tests/unit
|
|
68
|
+
directory: join('tests/unit', podPath, 'routes'),
|
|
60
69
|
file: 'route-test.js',
|
|
61
70
|
},
|
|
62
71
|
replace(key) {
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
5
|
|
|
5
|
-
export function migrationStrategyForServices(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export function migrationStrategyForServices(options) {
|
|
7
|
+
const { podPath, projectRoot } = options;
|
|
8
|
+
|
|
9
|
+
const oldPaths = glob.sync(
|
|
10
|
+
join('tests/unit', podPath, '!(services)', '**', 'service-test.{js,ts}'),
|
|
11
|
+
{
|
|
12
|
+
cwd: projectRoot,
|
|
13
|
+
}
|
|
14
|
+
);
|
|
9
15
|
|
|
10
16
|
return oldPaths.map((oldPath) => {
|
|
11
17
|
if (oldPath.endsWith('.ts')) {
|
|
12
18
|
return mapPaths(oldPath, {
|
|
13
19
|
find: {
|
|
14
|
-
directory: 'tests/unit',
|
|
20
|
+
directory: join('tests/unit', podPath),
|
|
15
21
|
file: 'service-test.ts',
|
|
16
22
|
},
|
|
17
23
|
replace(key) {
|
|
@@ -22,7 +28,7 @@ export function migrationStrategyForServices(projectRoot) {
|
|
|
22
28
|
|
|
23
29
|
return mapPaths(oldPath, {
|
|
24
30
|
find: {
|
|
25
|
-
directory: 'tests/unit',
|
|
31
|
+
directory: join('tests/unit', podPath),
|
|
26
32
|
file: 'service-test.js',
|
|
27
33
|
},
|
|
28
34
|
replace(key) {
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForComponentClasses(
|
|
5
|
+
export function migrationStrategyForComponentClasses(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync('addon/components/**/component.{d.ts,js,ts}', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
@@ -2,12 +2,26 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForComponentStylesheets(
|
|
6
|
-
const
|
|
5
|
+
export function migrationStrategyForComponentStylesheets(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
8
|
+
const oldPaths = glob.sync('addon/components/**/styles.{css,scss}', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
9
11
|
|
|
10
12
|
return oldPaths.map((oldPath) => {
|
|
13
|
+
if (oldPath.endsWith('.scss')) {
|
|
14
|
+
return mapPaths(oldPath, {
|
|
15
|
+
find: {
|
|
16
|
+
directory: 'addon/components',
|
|
17
|
+
file: 'styles.scss',
|
|
18
|
+
},
|
|
19
|
+
replace(key) {
|
|
20
|
+
return `addon/components/${key}.scss`;
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
11
25
|
return mapPaths(oldPath, {
|
|
12
26
|
find: {
|
|
13
27
|
directory: 'addon/components',
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForComponentTemplates(
|
|
5
|
+
export function migrationStrategyForComponentTemplates(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync('addon/components/**/template.hbs', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
@@ -6,14 +6,14 @@ import { migrationStrategyForRouteRoutes } from './route-routes.js';
|
|
|
6
6
|
import { migrationStrategyForRouteStylesheets } from './route-stylesheets.js';
|
|
7
7
|
import { migrationStrategyForRouteTemplates } from './route-templates.js';
|
|
8
8
|
|
|
9
|
-
export function migrationStrategyForAddonFolder(
|
|
9
|
+
export function migrationStrategyForAddonFolder(options) {
|
|
10
10
|
return new Map([
|
|
11
|
-
...migrationStrategyForComponentClasses(
|
|
12
|
-
...migrationStrategyForComponentStylesheets(
|
|
13
|
-
...migrationStrategyForComponentTemplates(
|
|
14
|
-
...migrationStrategyForRouteControllers(
|
|
15
|
-
...migrationStrategyForRouteRoutes(
|
|
16
|
-
...migrationStrategyForRouteStylesheets(
|
|
17
|
-
...migrationStrategyForRouteTemplates(
|
|
11
|
+
...migrationStrategyForComponentClasses(options),
|
|
12
|
+
...migrationStrategyForComponentStylesheets(options),
|
|
13
|
+
...migrationStrategyForComponentTemplates(options),
|
|
14
|
+
...migrationStrategyForRouteControllers(options),
|
|
15
|
+
...migrationStrategyForRouteRoutes(options),
|
|
16
|
+
...migrationStrategyForRouteStylesheets(options),
|
|
17
|
+
...migrationStrategyForRouteTemplates(options),
|
|
18
18
|
]);
|
|
19
19
|
}
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForRouteControllers(
|
|
5
|
+
export function migrationStrategyForRouteControllers(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync('addon/**/controller.{js,ts}', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForRouteRoutes(
|
|
5
|
+
export function migrationStrategyForRouteRoutes(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync('addon/**/route.{js,ts}', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
@@ -2,12 +2,26 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForRouteStylesheets(
|
|
6
|
-
const
|
|
5
|
+
export function migrationStrategyForRouteStylesheets(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
8
|
+
const oldPaths = glob.sync('addon/!(components)/**/styles.{css,scss}', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
9
11
|
|
|
10
12
|
return oldPaths.map((oldPath) => {
|
|
13
|
+
if (oldPath.endsWith('.scss')) {
|
|
14
|
+
return mapPaths(oldPath, {
|
|
15
|
+
find: {
|
|
16
|
+
directory: 'addon',
|
|
17
|
+
file: 'styles.scss',
|
|
18
|
+
},
|
|
19
|
+
replace(key) {
|
|
20
|
+
return `addon/styles/${key}.scss`;
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
11
25
|
return mapPaths(oldPath, {
|
|
12
26
|
find: {
|
|
13
27
|
directory: 'addon',
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForRouteTemplates(
|
|
5
|
+
export function migrationStrategyForRouteTemplates(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync('addon/!(components)/**/template.hbs', {
|
|
7
9
|
cwd: projectRoot,
|
|
8
10
|
});
|
|
@@ -3,12 +3,10 @@ import { migrationStrategyForAddonFolder } from './addon/index.js';
|
|
|
3
3
|
import { migrationStrategyForTestsFolder } from './tests/index.js';
|
|
4
4
|
|
|
5
5
|
export function migrateEmberEngine(options) {
|
|
6
|
-
const
|
|
6
|
+
const migrationStrategyAddon = migrationStrategyForAddonFolder(options);
|
|
7
|
+
const migrationStrategyTests = migrationStrategyForTestsFolder(options);
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
const migrationStrategyTests = migrationStrategyForTestsFolder(projectRoot);
|
|
10
|
-
|
|
11
|
-
if (testRun) {
|
|
9
|
+
if (options.testRun) {
|
|
12
10
|
console.log({
|
|
13
11
|
migrationStrategyAddon,
|
|
14
12
|
migrationStrategyTests,
|
|
@@ -17,13 +15,6 @@ export function migrateEmberEngine(options) {
|
|
|
17
15
|
return;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
moveFiles(
|
|
21
|
-
|
|
22
|
-
projectRoot,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
moveFiles({
|
|
26
|
-
migrationStrategy: migrationStrategyTests,
|
|
27
|
-
projectRoot,
|
|
28
|
-
});
|
|
18
|
+
moveFiles(migrationStrategyAddon, options);
|
|
19
|
+
moveFiles(migrationStrategyTests, options);
|
|
29
20
|
}
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForComponents(
|
|
5
|
+
export function migrationStrategyForComponents(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
const oldPaths = glob.sync(
|
|
7
9
|
'tests/integration/components/**/component-test.{js,ts}',
|
|
8
10
|
{
|
|
@@ -2,10 +2,10 @@ import { migrationStrategyForComponents } from './components.js';
|
|
|
2
2
|
import { migrationStrategyForRouteControllers } from './route-controllers.js';
|
|
3
3
|
import { migrationStrategyForRouteRoutes } from './route-routes.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForTestsFolder(
|
|
5
|
+
export function migrationStrategyForTestsFolder(options) {
|
|
6
6
|
return new Map([
|
|
7
|
-
...migrationStrategyForComponents(
|
|
8
|
-
...migrationStrategyForRouteControllers(
|
|
9
|
-
...migrationStrategyForRouteRoutes(
|
|
7
|
+
...migrationStrategyForComponents(options),
|
|
8
|
+
...migrationStrategyForRouteControllers(options),
|
|
9
|
+
...migrationStrategyForRouteRoutes(options),
|
|
10
10
|
]);
|
|
11
11
|
}
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForRouteControllers(
|
|
5
|
+
export function migrationStrategyForRouteControllers(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
/*
|
|
7
9
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
8
10
|
*/
|
|
@@ -2,7 +2,9 @@ import glob from 'glob';
|
|
|
2
2
|
|
|
3
3
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
4
|
|
|
5
|
-
export function migrationStrategyForRouteRoutes(
|
|
5
|
+
export function migrationStrategyForRouteRoutes(options) {
|
|
6
|
+
const { projectRoot } = options;
|
|
7
|
+
|
|
6
8
|
/*
|
|
7
9
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
8
10
|
*/
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
|
|
4
|
-
export function updatePaths(
|
|
4
|
+
export function updatePaths(migrationStrategy, options) {
|
|
5
|
+
const { projectRoot } = options;
|
|
6
|
+
|
|
5
7
|
migrationStrategy.forEach((newPath, oldPath) => {
|
|
6
8
|
// Read file
|
|
7
9
|
const newAbsolutePath = join(projectRoot, newPath);
|
package/src/utils/move-files.js
CHANGED
|
@@ -7,10 +7,28 @@ import {
|
|
|
7
7
|
} from 'node:fs';
|
|
8
8
|
import { dirname, join } from 'node:path';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
function removeDirectoryIfEmpty({ oldPath, projectRoot }) {
|
|
11
|
+
const directories = dirname(oldPath).split('/');
|
|
12
|
+
const depth = directories.length;
|
|
13
|
+
|
|
14
|
+
for (let i = 0; i < depth; i++) {
|
|
15
|
+
const directory = join(projectRoot, ...directories);
|
|
16
|
+
const numFilesLeft = readdirSync(directory).length;
|
|
17
|
+
|
|
18
|
+
if (numFilesLeft > 0) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
rmSync(directory, { recursive: true });
|
|
23
|
+
directories.pop();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function moveFiles(migrationStrategy, options) {
|
|
28
|
+
const { projectRoot } = options;
|
|
29
|
+
|
|
11
30
|
migrationStrategy.forEach((newPath, oldPath) => {
|
|
12
31
|
const oldAbsolutePath = join(projectRoot, oldPath);
|
|
13
|
-
const oldDirectory = dirname(oldAbsolutePath);
|
|
14
32
|
|
|
15
33
|
const newAbsolutePath = join(projectRoot, newPath);
|
|
16
34
|
const newDirectory = dirname(newAbsolutePath);
|
|
@@ -21,12 +39,6 @@ export function moveFiles({ migrationStrategy, projectRoot }) {
|
|
|
21
39
|
}
|
|
22
40
|
|
|
23
41
|
renameSync(oldAbsolutePath, newAbsolutePath);
|
|
24
|
-
|
|
25
|
-
// Clean up directory
|
|
26
|
-
const numFilesLeft = readdirSync(oldDirectory).length;
|
|
27
|
-
|
|
28
|
-
if (numFilesLeft === 0) {
|
|
29
|
-
rmSync(oldDirectory, { recursive: true });
|
|
30
|
-
}
|
|
42
|
+
removeDirectoryIfEmpty({ oldPath, projectRoot });
|
|
31
43
|
});
|
|
32
44
|
}
|