ember-codemod-pod-to-octane 0.2.0 → 0.3.2
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 +23 -3
- package/bin/ember-codemod-pod-to-octane.js +6 -0
- package/package.json +5 -5
- 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 +14 -7
- package/src/migration/ember-app/app/component-stylesheets.js +24 -5
- package/src/migration/ember-app/app/component-templates.js +12 -5
- package/src/migration/ember-app/app/index.js +12 -12
- package/src/migration/ember-app/app/route-adapters.js +8 -4
- package/src/migration/ember-app/app/route-controllers.js +8 -4
- package/src/migration/ember-app/app/route-models.js +8 -4
- package/src/migration/ember-app/app/route-routes.js +8 -4
- package/src/migration/ember-app/app/route-serializers.js +8 -4
- package/src/migration/ember-app/app/route-stylesheets.js +24 -5
- package/src/migration/ember-app/app/route-templates.js +12 -5
- package/src/migration/ember-app/app/services.js +8 -4
- package/src/migration/ember-app/index.js +5 -14
- package/src/migration/ember-app/tests/components.js +14 -4
- package/src/migration/ember-app/tests/index.js +5 -5
- package/src/migration/ember-app/tests/route-controllers.js +17 -7
- package/src/migration/ember-app/tests/route-routes.js +21 -11
- package/src/migration/ember-app/tests/services.js +13 -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
|
@@ -1,16 +1,23 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
|
|
1
3
|
import glob from 'glob';
|
|
2
4
|
|
|
3
5
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
6
|
|
|
5
|
-
export function migrationStrategyForRouteTemplates(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
export function migrationStrategyForRouteTemplates(options) {
|
|
8
|
+
const { podPath, projectRoot } = options;
|
|
9
|
+
|
|
10
|
+
const oldPaths = glob.sync(
|
|
11
|
+
join('app', podPath, '!(components)', '**', 'template.hbs'),
|
|
12
|
+
{
|
|
13
|
+
cwd: projectRoot,
|
|
14
|
+
}
|
|
15
|
+
);
|
|
9
16
|
|
|
10
17
|
return oldPaths.map((oldPath) => {
|
|
11
18
|
return mapPaths(oldPath, {
|
|
12
19
|
find: {
|
|
13
|
-
directory: 'app',
|
|
20
|
+
directory: join('app', podPath),
|
|
14
21
|
file: 'template.hbs',
|
|
15
22
|
},
|
|
16
23
|
replace(key) {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
|
|
1
3
|
import glob from 'glob';
|
|
2
4
|
|
|
3
5
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
6
|
|
|
5
|
-
export function migrationStrategyForServices(
|
|
6
|
-
const
|
|
7
|
+
export function migrationStrategyForServices(options) {
|
|
8
|
+
const { podPath, projectRoot } = options;
|
|
9
|
+
|
|
10
|
+
const oldPaths = glob.sync(join('app', podPath, '**', 'service.{js,ts}'), {
|
|
7
11
|
cwd: projectRoot,
|
|
8
12
|
});
|
|
9
13
|
|
|
@@ -11,7 +15,7 @@ export function migrationStrategyForServices(projectRoot) {
|
|
|
11
15
|
if (oldPath.endsWith('.ts')) {
|
|
12
16
|
return mapPaths(oldPath, {
|
|
13
17
|
find: {
|
|
14
|
-
directory: 'app',
|
|
18
|
+
directory: join('app', podPath),
|
|
15
19
|
file: 'service.ts',
|
|
16
20
|
},
|
|
17
21
|
replace(key) {
|
|
@@ -22,7 +26,7 @@ export function migrationStrategyForServices(projectRoot) {
|
|
|
22
26
|
|
|
23
27
|
return mapPaths(oldPath, {
|
|
24
28
|
find: {
|
|
25
|
-
directory: 'app',
|
|
29
|
+
directory: join('app', podPath),
|
|
26
30
|
file: 'service.js',
|
|
27
31
|
},
|
|
28
32
|
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,20 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
|
|
1
3
|
import glob from 'glob';
|
|
2
4
|
|
|
3
5
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
6
|
|
|
5
|
-
export function migrationStrategyForComponents(
|
|
7
|
+
export function migrationStrategyForComponents(options) {
|
|
8
|
+
const { podPath, projectRoot } = options;
|
|
9
|
+
|
|
6
10
|
const oldPaths = glob.sync(
|
|
7
|
-
|
|
11
|
+
join(
|
|
12
|
+
'tests/integration',
|
|
13
|
+
podPath,
|
|
14
|
+
'components',
|
|
15
|
+
'**',
|
|
16
|
+
'component-test.{js,ts}'
|
|
17
|
+
),
|
|
8
18
|
{
|
|
9
19
|
cwd: projectRoot,
|
|
10
20
|
}
|
|
@@ -14,7 +24,7 @@ export function migrationStrategyForComponents(projectRoot) {
|
|
|
14
24
|
if (oldPath.endsWith('.ts')) {
|
|
15
25
|
return mapPaths(oldPath, {
|
|
16
26
|
find: {
|
|
17
|
-
directory: 'tests/integration
|
|
27
|
+
directory: join('tests/integration', podPath, 'components'),
|
|
18
28
|
file: 'component-test.ts',
|
|
19
29
|
},
|
|
20
30
|
replace(key) {
|
|
@@ -25,7 +35,7 @@ export function migrationStrategyForComponents(projectRoot) {
|
|
|
25
35
|
|
|
26
36
|
return mapPaths(oldPath, {
|
|
27
37
|
find: {
|
|
28
|
-
directory: 'tests/integration
|
|
38
|
+
directory: join('tests/integration', podPath, 'components'),
|
|
29
39
|
file: 'component-test.js',
|
|
30
40
|
},
|
|
31
41
|
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,23 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
|
|
1
3
|
import glob from 'glob';
|
|
2
4
|
|
|
3
5
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
6
|
|
|
5
|
-
export function migrationStrategyForRouteControllers(
|
|
7
|
+
export function migrationStrategyForRouteControllers(options) {
|
|
8
|
+
const { podPath, projectRoot } = options;
|
|
9
|
+
|
|
6
10
|
/*
|
|
7
11
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
8
12
|
*/
|
|
9
13
|
const oldPaths1 = glob.sync(
|
|
10
|
-
|
|
14
|
+
join(
|
|
15
|
+
'tests/unit',
|
|
16
|
+
podPath,
|
|
17
|
+
'!(controllers)',
|
|
18
|
+
'**',
|
|
19
|
+
'controller-test.{js,ts}'
|
|
20
|
+
),
|
|
11
21
|
{
|
|
12
22
|
cwd: projectRoot,
|
|
13
23
|
}
|
|
@@ -17,7 +27,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
17
27
|
if (oldPath.endsWith('.ts')) {
|
|
18
28
|
return mapPaths(oldPath, {
|
|
19
29
|
find: {
|
|
20
|
-
directory: 'tests/unit',
|
|
30
|
+
directory: join('tests/unit', podPath),
|
|
21
31
|
file: 'controller-test.ts',
|
|
22
32
|
},
|
|
23
33
|
replace(key) {
|
|
@@ -28,7 +38,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
28
38
|
|
|
29
39
|
return mapPaths(oldPath, {
|
|
30
40
|
find: {
|
|
31
|
-
directory: 'tests/unit',
|
|
41
|
+
directory: join('tests/unit', podPath),
|
|
32
42
|
file: 'controller-test.js',
|
|
33
43
|
},
|
|
34
44
|
replace(key) {
|
|
@@ -41,7 +51,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
41
51
|
Case 2: Passed the --pod flag to Ember CLI
|
|
42
52
|
*/
|
|
43
53
|
const oldPaths2 = glob.sync(
|
|
44
|
-
'tests/unit
|
|
54
|
+
join('tests/unit', podPath, 'controllers/**/controller-test.{js,ts}'),
|
|
45
55
|
{
|
|
46
56
|
cwd: projectRoot,
|
|
47
57
|
}
|
|
@@ -51,7 +61,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
51
61
|
if (oldPath.endsWith('.ts')) {
|
|
52
62
|
return mapPaths(oldPath, {
|
|
53
63
|
find: {
|
|
54
|
-
directory: 'tests/unit
|
|
64
|
+
directory: join('tests/unit', podPath, 'controllers'),
|
|
55
65
|
file: 'controller-test.ts',
|
|
56
66
|
},
|
|
57
67
|
replace(key) {
|
|
@@ -62,7 +72,7 @@ export function migrationStrategyForRouteControllers(projectRoot) {
|
|
|
62
72
|
|
|
63
73
|
return mapPaths(oldPath, {
|
|
64
74
|
find: {
|
|
65
|
-
directory: 'tests/unit
|
|
75
|
+
directory: join('tests/unit', podPath, 'controllers'),
|
|
66
76
|
file: 'controller-test.js',
|
|
67
77
|
},
|
|
68
78
|
replace(key) {
|
|
@@ -1,20 +1,27 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
|
|
1
3
|
import glob from 'glob';
|
|
2
4
|
|
|
3
5
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
6
|
|
|
5
|
-
export function migrationStrategyForRouteRoutes(
|
|
7
|
+
export function migrationStrategyForRouteRoutes(options) {
|
|
8
|
+
const { podPath, projectRoot } = options;
|
|
9
|
+
|
|
6
10
|
/*
|
|
7
11
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
8
12
|
*/
|
|
9
|
-
const oldPaths1 = glob.sync(
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
const oldPaths1 = glob.sync(
|
|
14
|
+
join('tests/unit', podPath, '!(routes)', '**', 'route-test.{js,ts}'),
|
|
15
|
+
{
|
|
16
|
+
cwd: projectRoot,
|
|
17
|
+
}
|
|
18
|
+
);
|
|
12
19
|
|
|
13
20
|
const newPaths1 = oldPaths1.map((oldPath) => {
|
|
14
21
|
if (oldPath.endsWith('.ts')) {
|
|
15
22
|
return mapPaths(oldPath, {
|
|
16
23
|
find: {
|
|
17
|
-
directory: 'tests/unit',
|
|
24
|
+
directory: join('tests/unit', podPath),
|
|
18
25
|
file: 'route-test.ts',
|
|
19
26
|
},
|
|
20
27
|
replace(key) {
|
|
@@ -25,7 +32,7 @@ export function migrationStrategyForRouteRoutes(projectRoot) {
|
|
|
25
32
|
|
|
26
33
|
return mapPaths(oldPath, {
|
|
27
34
|
find: {
|
|
28
|
-
directory: 'tests/unit',
|
|
35
|
+
directory: join('tests/unit', podPath),
|
|
29
36
|
file: 'route-test.js',
|
|
30
37
|
},
|
|
31
38
|
replace(key) {
|
|
@@ -37,15 +44,18 @@ export function migrationStrategyForRouteRoutes(projectRoot) {
|
|
|
37
44
|
/*
|
|
38
45
|
Case 2: Passed the --pod flag to Ember CLI
|
|
39
46
|
*/
|
|
40
|
-
const oldPaths2 = glob.sync(
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
const oldPaths2 = glob.sync(
|
|
48
|
+
join('tests/unit', podPath, 'routes/**/route-test.{js,ts}'),
|
|
49
|
+
{
|
|
50
|
+
cwd: projectRoot,
|
|
51
|
+
}
|
|
52
|
+
);
|
|
43
53
|
|
|
44
54
|
const newPaths2 = oldPaths2.map((oldPath) => {
|
|
45
55
|
if (oldPath.endsWith('.ts')) {
|
|
46
56
|
return mapPaths(oldPath, {
|
|
47
57
|
find: {
|
|
48
|
-
directory: 'tests/unit
|
|
58
|
+
directory: join('tests/unit', podPath, 'routes'),
|
|
49
59
|
file: 'route-test.ts',
|
|
50
60
|
},
|
|
51
61
|
replace(key) {
|
|
@@ -56,7 +66,7 @@ export function migrationStrategyForRouteRoutes(projectRoot) {
|
|
|
56
66
|
|
|
57
67
|
return mapPaths(oldPath, {
|
|
58
68
|
find: {
|
|
59
|
-
directory: 'tests/unit
|
|
69
|
+
directory: join('tests/unit', podPath, 'routes'),
|
|
60
70
|
file: 'route-test.js',
|
|
61
71
|
},
|
|
62
72
|
replace(key) {
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
|
|
1
3
|
import glob from 'glob';
|
|
2
4
|
|
|
3
5
|
import { mapPaths } from '../../../utils/map-paths.js';
|
|
4
6
|
|
|
5
|
-
export function migrationStrategyForServices(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
export function migrationStrategyForServices(options) {
|
|
8
|
+
const { podPath, projectRoot } = options;
|
|
9
|
+
|
|
10
|
+
const oldPaths = glob.sync(
|
|
11
|
+
join('tests/unit', podPath, '!(services)', '**', 'service-test.{js,ts}'),
|
|
12
|
+
{
|
|
13
|
+
cwd: projectRoot,
|
|
14
|
+
}
|
|
15
|
+
);
|
|
9
16
|
|
|
10
17
|
return oldPaths.map((oldPath) => {
|
|
11
18
|
if (oldPath.endsWith('.ts')) {
|
|
12
19
|
return mapPaths(oldPath, {
|
|
13
20
|
find: {
|
|
14
|
-
directory: 'tests/unit',
|
|
21
|
+
directory: join('tests/unit', podPath),
|
|
15
22
|
file: 'service-test.ts',
|
|
16
23
|
},
|
|
17
24
|
replace(key) {
|
|
@@ -22,7 +29,7 @@ export function migrationStrategyForServices(projectRoot) {
|
|
|
22
29
|
|
|
23
30
|
return mapPaths(oldPath, {
|
|
24
31
|
find: {
|
|
25
|
-
directory: 'tests/unit',
|
|
32
|
+
directory: join('tests/unit', podPath),
|
|
26
33
|
file: 'service-test.js',
|
|
27
34
|
},
|
|
28
35
|
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
|
}
|