ember-codemod-pod-to-octane 5.0.4 → 5.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.
Files changed (45) hide show
  1. package/README.md +3 -3
  2. package/dist/src/index.js +2 -1
  3. package/dist/src/migration/app/steps/create-file-path-maps/app/index.js +13 -20
  4. package/dist/src/migration/app/steps/create-file-path-maps/app/map-components-1.js +31 -0
  5. package/dist/src/migration/app/steps/create-file-path-maps/app/map-components-2.js +45 -0
  6. package/dist/src/migration/app/steps/create-file-path-maps/app/map-routes.js +73 -0
  7. package/dist/src/migration/app/steps/create-file-path-maps/tests/index.js +4 -4
  8. package/dist/src/migration/app/steps/create-file-path-maps/tests/map-routes-1.js +38 -0
  9. package/dist/src/migration/app/steps/create-file-path-maps/tests/map-routes-2.js +36 -0
  10. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/index.js +4 -14
  11. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-components.js +28 -0
  12. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-routes.js +52 -0
  13. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/index.js +4 -10
  14. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/{map-component-classes.js → map-components.js} +6 -3
  15. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-routes.js +44 -0
  16. package/dist/src/migration/v1-addon/steps/create-file-path-maps/tests/index.js +4 -4
  17. package/dist/src/migration/v1-addon/steps/create-file-path-maps/tests/map-routes-1.js +38 -0
  18. package/dist/src/migration/v1-addon/steps/create-file-path-maps/tests/map-routes-2.js +36 -0
  19. package/package.json +6 -6
  20. package/dist/src/migration/app/steps/create-file-path-maps/app/map-component-classes.js +0 -18
  21. package/dist/src/migration/app/steps/create-file-path-maps/app/map-component-stylesheets.js +0 -18
  22. package/dist/src/migration/app/steps/create-file-path-maps/app/map-component-templates.js +0 -18
  23. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-adapters.js +0 -18
  24. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-controllers.js +0 -18
  25. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-models.js +0 -18
  26. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-routes.js +0 -18
  27. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-serializers.js +0 -18
  28. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.js +0 -19
  29. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-templates.js +0 -19
  30. package/dist/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.js +0 -39
  31. package/dist/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.js +0 -39
  32. package/dist/src/migration/index.js +0 -2
  33. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-classes.js +0 -18
  34. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-stylesheets.js +0 -18
  35. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-templates.js +0 -18
  36. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-controllers.js +0 -18
  37. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-routes.js +0 -18
  38. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-stylesheets.js +0 -19
  39. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-templates.js +0 -19
  40. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-templates.js +0 -18
  41. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-controllers.js +0 -18
  42. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-routes.js +0 -18
  43. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-templates.js +0 -19
  44. package/dist/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-controllers.js +0 -39
  45. package/dist/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-routes.js +0 -39
package/README.md CHANGED
@@ -144,13 +144,13 @@ pnpm build
144
144
  > You might clone the repo to migrate the project one component or one route at a time. For example, to migrate only the `<NavigationMenu>` component (and its subcomponents, if they exist), update the related file(s) in the `src` folder like this:
145
145
  >
146
146
  > ```diff
147
- > export function mapComponentClasses(options: Options): FilePathMapEntries {
147
+ > export function mapComponents1(options: Options): FilePathMapEntries {
148
148
  > const { podPath, projectRoot } = options;
149
149
  >
150
150
  > const podDir = normalizedJoin('app', podPath, 'components');
151
151
  >
152
- > - const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
153
- > + const filePaths = findFiles(`${podDir}/navigation-menu/**/component.{d.ts,js,ts}`, {
152
+ > - const filePathsForClass = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
153
+ > + const filePathsForClass = findFiles(`${podDir}/navigation-menu/**/component.{d.ts,js,ts}`, {
154
154
  >
155
155
  > // ...
156
156
  > }
package/dist/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import { migrateApp, migrateV1Addon } from './migration/index.js';
1
+ import { migrateApp } from './migration/app/index.js';
2
+ import { migrateV1Addon } from './migration/v1-addon/index.js';
2
3
  export function runCodemod(codemodOptions) {
3
4
  switch (codemodOptions.projectType) {
4
5
  case 'app': {
@@ -1,26 +1,19 @@
1
- import { mapComponentClasses } from './map-component-classes.js';
2
- import { mapComponentStylesheets } from './map-component-stylesheets.js';
3
- import { mapComponentTemplates } from './map-component-templates.js';
4
- import { mapRouteAdapters } from './map-route-adapters.js';
5
- import { mapRouteControllers } from './map-route-controllers.js';
6
- import { mapRouteModels } from './map-route-models.js';
7
- import { mapRouteRoutes } from './map-route-routes.js';
8
- import { mapRouteSerializers } from './map-route-serializers.js';
9
- import { mapRouteStylesheets } from './map-route-stylesheets.js';
10
- import { mapRouteTemplates } from './map-route-templates.js';
1
+ import { sep } from 'node:path';
2
+ import { mapComponents1 } from './map-components-1.js';
3
+ import { mapComponents2 } from './map-components-2.js';
4
+ import { mapRoutes } from './map-routes.js';
11
5
  import { mapServices } from './map-services.js';
12
6
  export function mapAppFolder(options) {
7
+ const mapEntriesForComponents = [
8
+ ...mapComponents1(options),
9
+ ...mapComponents2(options),
10
+ ];
11
+ const filePathsForComponents = mapEntriesForComponents.map(([oldFilePath]) => {
12
+ return oldFilePath.replaceAll(sep, '/');
13
+ });
13
14
  return new Map([
14
- ...mapComponentClasses(options),
15
- ...mapComponentStylesheets(options),
16
- ...mapComponentTemplates(options),
17
- ...mapRouteAdapters(options),
18
- ...mapRouteControllers(options),
19
- ...mapRouteModels(options),
20
- ...mapRouteRoutes(options),
21
- ...mapRouteSerializers(options),
22
- ...mapRouteStylesheets(options),
23
- ...mapRouteTemplates(options),
15
+ ...mapEntriesForComponents,
16
+ ...mapRoutes(filePathsForComponents, options),
24
17
  ...mapServices(options),
25
18
  ]);
26
19
  }
@@ -0,0 +1,31 @@
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
+ /*
4
+ Case 1: Placed component files in /components
5
+ */
6
+ export function mapComponents1(options) {
7
+ const { podPath, projectRoot } = options;
8
+ const podDir = normalizedJoin('app', podPath, 'components');
9
+ const filePathsForClass = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
10
+ projectRoot,
11
+ });
12
+ const filePathsForStylesheet = findFiles(`${podDir}/**/styles.{css,scss}`, {
13
+ projectRoot,
14
+ });
15
+ const filePathsForTemplate = findFiles(`${podDir}/**/template.hbs`, {
16
+ projectRoot,
17
+ });
18
+ return [
19
+ ...filePathsForClass,
20
+ ...filePathsForStylesheet,
21
+ ...filePathsForTemplate,
22
+ ].map((oldFilePath) => {
23
+ const newFilePath = renamePodPath(oldFilePath, {
24
+ podDir,
25
+ replace: (dir) => {
26
+ return `app/components/${dir}`;
27
+ },
28
+ });
29
+ return [oldFilePath, newFilePath];
30
+ });
31
+ }
@@ -0,0 +1,45 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { findFiles, parseFilePath } from '@codemod-utils/files';
4
+ import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
5
+ /*
6
+ Case 2: Placed component files outside of /components
7
+ */
8
+ export function mapComponents2(options) {
9
+ const { podPath, projectRoot } = options;
10
+ const podDir = normalizedJoin('app', podPath);
11
+ const filePathsForClass = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
12
+ ignoreList: [normalizedJoin('app', podPath, 'components/**')],
13
+ projectRoot,
14
+ });
15
+ const filePathsForStylesheet = [];
16
+ const filePathsForTemplate = [];
17
+ filePathsForClass.forEach((filePath) => {
18
+ const { dir } = parseFilePath(filePath);
19
+ let filePathForStylesheet = join(dir, 'styles.css');
20
+ if (existsSync(join(projectRoot, filePathForStylesheet))) {
21
+ filePathsForStylesheet.push(filePathForStylesheet);
22
+ }
23
+ filePathForStylesheet = join(dir, 'styles.scss');
24
+ if (existsSync(join(projectRoot, filePathForStylesheet))) {
25
+ filePathsForStylesheet.push(filePathForStylesheet);
26
+ }
27
+ const filePathForTemplate = join(dir, 'template.hbs');
28
+ if (existsSync(join(projectRoot, filePathForTemplate))) {
29
+ filePathsForTemplate.push(filePathForTemplate);
30
+ }
31
+ });
32
+ return [
33
+ ...filePathsForClass,
34
+ ...filePathsForStylesheet,
35
+ ...filePathsForTemplate,
36
+ ].map((oldFilePath) => {
37
+ const newFilePath = renamePodPath(oldFilePath, {
38
+ podDir,
39
+ replace: (dir) => {
40
+ return `app/components/${dir}`;
41
+ },
42
+ });
43
+ return [oldFilePath, newFilePath];
44
+ });
45
+ }
@@ -0,0 +1,73 @@
1
+ import { findFiles, parseFilePath } from '@codemod-utils/files';
2
+ import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
+ function getFileName(filePath) {
4
+ const { name } = parseFilePath(filePath);
5
+ return name;
6
+ }
7
+ export function mapRoutes(filePathsForComponents, options) {
8
+ const { podPath, projectRoot } = options;
9
+ const podDir = normalizedJoin('app', podPath);
10
+ const filePathsForAdapter = findFiles(`${podDir}/**/adapter.{js,ts}`, {
11
+ projectRoot,
12
+ });
13
+ const filePathsForController = findFiles(`${podDir}/**/controller.{js,ts}`, {
14
+ projectRoot,
15
+ });
16
+ const filePathsForModel = findFiles(`${podDir}/**/model.{js,ts}`, {
17
+ projectRoot,
18
+ });
19
+ const filePathsForRoute = findFiles(`${podDir}/**/route.{js,ts}`, {
20
+ projectRoot,
21
+ });
22
+ const filePathsForSerializer = findFiles(`${podDir}/**/serializer.{js,ts}`, {
23
+ projectRoot,
24
+ });
25
+ const filePathsForStylesheet = findFiles(`${podDir}/**/styles.{css,scss}`, {
26
+ ignoreList: filePathsForComponents,
27
+ projectRoot,
28
+ });
29
+ const filePathsForTemplate = findFiles(`${podDir}/**/template.hbs`, {
30
+ ignoreList: filePathsForComponents,
31
+ projectRoot,
32
+ });
33
+ return [
34
+ ...filePathsForAdapter,
35
+ ...filePathsForController,
36
+ ...filePathsForModel,
37
+ ...filePathsForRoute,
38
+ ...filePathsForSerializer,
39
+ ...filePathsForStylesheet,
40
+ ...filePathsForTemplate,
41
+ ].map((oldFilePath) => {
42
+ const fileName = getFileName(oldFilePath);
43
+ const newFilePath = renamePodPath(oldFilePath, {
44
+ podDir,
45
+ replace: (dir) => {
46
+ switch (fileName) {
47
+ case 'adapter': {
48
+ return `app/adapters/${dir}`;
49
+ }
50
+ case 'controller': {
51
+ return `app/controllers/${dir}`;
52
+ }
53
+ case 'model': {
54
+ return `app/models/${dir}`;
55
+ }
56
+ case 'route': {
57
+ return `app/routes/${dir}`;
58
+ }
59
+ case 'serializer': {
60
+ return `app/serializers/${dir}`;
61
+ }
62
+ case 'styles': {
63
+ return `app/styles/${dir}`;
64
+ }
65
+ case 'template': {
66
+ return `app/templates/${dir}`;
67
+ }
68
+ }
69
+ },
70
+ });
71
+ return [oldFilePath, newFilePath];
72
+ });
73
+ }
@@ -1,12 +1,12 @@
1
1
  import { mapComponents } from './map-components.js';
2
- import { mapRouteControllers } from './map-route-controllers.js';
3
- import { mapRouteRoutes } from './map-route-routes.js';
2
+ import { mapRoutes1 } from './map-routes-1.js';
3
+ import { mapRoutes2 } from './map-routes-2.js';
4
4
  import { mapServices } from './map-services.js';
5
5
  export function mapTestsFolder(options) {
6
6
  return new Map([
7
7
  ...mapComponents(options),
8
- ...mapRouteControllers(options),
9
- ...mapRouteRoutes(options),
8
+ ...mapRoutes1(options),
9
+ ...mapRoutes2(options),
10
10
  ...mapServices(options),
11
11
  ]);
12
12
  }
@@ -0,0 +1,38 @@
1
+ import { findFiles, parseFilePath } from '@codemod-utils/files';
2
+ import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
+ function getFileName(filePath) {
4
+ const { name } = parseFilePath(filePath);
5
+ return name;
6
+ }
7
+ /*
8
+ Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
9
+ */
10
+ export function mapRoutes1(options) {
11
+ const { podPath, projectRoot } = options;
12
+ const podDir = normalizedJoin('tests/unit', podPath);
13
+ const filePathsForController = findFiles(`${podDir}/**/controller-test.{js,ts}`, {
14
+ ignoreList: [normalizedJoin('tests/unit', podPath, 'controllers/**')],
15
+ projectRoot,
16
+ });
17
+ const filePathsForRoute = findFiles(`${podDir}/**/route-test.{js,ts}`, {
18
+ ignoreList: [normalizedJoin('tests/unit', podPath, 'routes/**')],
19
+ projectRoot,
20
+ });
21
+ return [...filePathsForController, ...filePathsForRoute].map((oldFilePath) => {
22
+ const fileName = getFileName(oldFilePath);
23
+ const newFilePath = renamePodPath(oldFilePath, {
24
+ podDir,
25
+ replace: (dir) => {
26
+ switch (fileName) {
27
+ case 'controller-test': {
28
+ return `tests/unit/controllers/${dir}-test`;
29
+ }
30
+ case 'route-test': {
31
+ return `tests/unit/routes/${dir}-test`;
32
+ }
33
+ }
34
+ },
35
+ });
36
+ return [oldFilePath, newFilePath];
37
+ });
38
+ }
@@ -0,0 +1,36 @@
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
+ /*
4
+ Case 2: Passed the --pod flag to Ember CLI
5
+ */
6
+ export function mapRoutes2(options) {
7
+ const { podPath, projectRoot } = options;
8
+ const podDirForController = normalizedJoin('tests/unit', podPath, 'controllers');
9
+ const filePathsForController = findFiles(`${podDirForController}/**/controller-test.{js,ts}`, {
10
+ projectRoot,
11
+ });
12
+ const podDirForRoute = normalizedJoin('tests/unit', podPath, 'routes');
13
+ const filePathsForRoute = findFiles(`${podDirForRoute}/**/route-test.{js,ts}`, {
14
+ projectRoot,
15
+ });
16
+ return [
17
+ ...filePathsForController.map((oldFilePath) => {
18
+ const newFilePath = renamePodPath(oldFilePath, {
19
+ podDir: podDirForController,
20
+ replace: (dir) => {
21
+ return `tests/unit/controllers/${dir}-test`;
22
+ },
23
+ });
24
+ return [oldFilePath, newFilePath];
25
+ }),
26
+ ...filePathsForRoute.map((oldFilePath) => {
27
+ const newFilePath = renamePodPath(oldFilePath, {
28
+ podDir: podDirForRoute,
29
+ replace: (dir) => {
30
+ return `tests/unit/routes/${dir}-test`;
31
+ },
32
+ });
33
+ return [oldFilePath, newFilePath];
34
+ }),
35
+ ];
36
+ }
@@ -1,20 +1,10 @@
1
- import { mapComponentClasses } from './map-component-classes.js';
2
- import { mapComponentStylesheets } from './map-component-stylesheets.js';
3
- import { mapComponentTemplates } from './map-component-templates.js';
4
- import { mapRouteControllers } from './map-route-controllers.js';
5
- import { mapRouteRoutes } from './map-route-routes.js';
6
- import { mapRouteStylesheets } from './map-route-stylesheets.js';
7
- import { mapRouteTemplates } from './map-route-templates.js';
1
+ import { mapComponents } from './map-components.js';
2
+ import { mapRoutes } from './map-routes.js';
8
3
  import { mapServices } from './map-services.js';
9
4
  export function mapAddonFolder(options) {
10
5
  return new Map([
11
- ...mapComponentClasses(options),
12
- ...mapComponentStylesheets(options),
13
- ...mapComponentTemplates(options),
14
- ...mapRouteControllers(options),
15
- ...mapRouteRoutes(options),
16
- ...mapRouteStylesheets(options),
17
- ...mapRouteTemplates(options),
6
+ ...mapComponents(options),
7
+ ...mapRoutes(options),
18
8
  ...mapServices(options),
19
9
  ]);
20
10
  }
@@ -0,0 +1,28 @@
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
+ export function mapComponents(options) {
4
+ const { projectRoot } = options;
5
+ const podDir = 'addon/components';
6
+ const filePathsForClass = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
7
+ projectRoot,
8
+ });
9
+ const filePathsForStylesheet = findFiles(`${podDir}/**/styles.{css,scss}`, {
10
+ projectRoot,
11
+ });
12
+ const filePathsForTemplate = findFiles(`${podDir}/**/template.hbs`, {
13
+ projectRoot,
14
+ });
15
+ return [
16
+ ...filePathsForClass,
17
+ ...filePathsForStylesheet,
18
+ ...filePathsForTemplate,
19
+ ].map((oldFilePath) => {
20
+ const newFilePath = renamePodPath(oldFilePath, {
21
+ podDir,
22
+ replace: (dir) => {
23
+ return `addon/components/${dir}`;
24
+ },
25
+ });
26
+ return [oldFilePath, newFilePath];
27
+ });
28
+ }
@@ -0,0 +1,52 @@
1
+ import { findFiles, parseFilePath } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
+ function getFileName(filePath) {
4
+ const { name } = parseFilePath(filePath);
5
+ return name;
6
+ }
7
+ export function mapRoutes(options) {
8
+ const { projectRoot } = options;
9
+ const podDir = 'addon';
10
+ const filePathsForController = findFiles(`${podDir}/**/controller.{js,ts}`, {
11
+ projectRoot,
12
+ });
13
+ const filePathsForRoute = findFiles(`${podDir}/**/route.{js,ts}`, {
14
+ projectRoot,
15
+ });
16
+ const filePathsForStylesheet = findFiles(`${podDir}/**/styles.{css,scss}`, {
17
+ ignoreList: ['addon/components/**'],
18
+ projectRoot,
19
+ });
20
+ const filePathsForTemplate = findFiles(`${podDir}/**/template.hbs`, {
21
+ ignoreList: ['addon/components/**'],
22
+ projectRoot,
23
+ });
24
+ return [
25
+ ...filePathsForController,
26
+ ...filePathsForRoute,
27
+ ...filePathsForStylesheet,
28
+ ...filePathsForTemplate,
29
+ ].map((oldFilePath) => {
30
+ const fileName = getFileName(oldFilePath);
31
+ const newFilePath = renamePodPath(oldFilePath, {
32
+ podDir,
33
+ replace: (dir) => {
34
+ switch (fileName) {
35
+ case 'controller': {
36
+ return `addon/controllers/${dir}`;
37
+ }
38
+ case 'route': {
39
+ return `addon/routes/${dir}`;
40
+ }
41
+ case 'styles': {
42
+ return `addon/styles/${dir}`;
43
+ }
44
+ case 'template': {
45
+ return `addon/templates/${dir}`;
46
+ }
47
+ }
48
+ },
49
+ });
50
+ return [oldFilePath, newFilePath];
51
+ });
52
+ }
@@ -1,16 +1,10 @@
1
- import { mapComponentClasses } from './map-component-classes.js';
2
- import { mapComponentTemplates } from './map-component-templates.js';
3
- import { mapRouteControllers } from './map-route-controllers.js';
4
- import { mapRouteRoutes } from './map-route-routes.js';
5
- import { mapRouteTemplates } from './map-route-templates.js';
1
+ import { mapComponents } from './map-components.js';
2
+ import { mapRoutes } from './map-routes.js';
6
3
  import { mapServices } from './map-services.js';
7
4
  export function mapAppFolder(options) {
8
5
  return new Map([
9
- ...mapComponentClasses(options),
10
- ...mapComponentTemplates(options),
11
- ...mapRouteControllers(options),
12
- ...mapRouteRoutes(options),
13
- ...mapRouteTemplates(options),
6
+ ...mapComponents(options),
7
+ ...mapRoutes(options),
14
8
  ...mapServices(options),
15
9
  ]);
16
10
  }
@@ -1,12 +1,15 @@
1
1
  import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapComponentClasses(options) {
3
+ export function mapComponents(options) {
4
4
  const { projectRoot } = options;
5
5
  const podDir = 'app/components';
6
- const filePaths = findFiles(`${podDir}/**/component.js`, {
6
+ const filePathsForClass = findFiles(`${podDir}/**/component.js`, {
7
7
  projectRoot,
8
8
  });
9
- return filePaths.map((oldFilePath) => {
9
+ const filePathsForTemplate = findFiles(`${podDir}/**/template.js`, {
10
+ projectRoot,
11
+ });
12
+ return [...filePathsForClass, ...filePathsForTemplate].map((oldFilePath) => {
10
13
  const newFilePath = renamePodPath(oldFilePath, {
11
14
  podDir,
12
15
  replace: (dir) => {
@@ -0,0 +1,44 @@
1
+ import { findFiles, parseFilePath } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
+ function getFileName(filePath) {
4
+ const { name } = parseFilePath(filePath);
5
+ return name;
6
+ }
7
+ export function mapRoutes(options) {
8
+ const { projectRoot } = options;
9
+ const podDir = 'app';
10
+ const filePathsForController = findFiles(`${podDir}/**/controller.js`, {
11
+ projectRoot,
12
+ });
13
+ const filePathsForRoute = findFiles(`${podDir}/**/route.js`, {
14
+ projectRoot,
15
+ });
16
+ const filePathsForTemplate = findFiles(`${podDir}/**/template.js`, {
17
+ ignoreList: ['app/components/**'],
18
+ projectRoot,
19
+ });
20
+ return [
21
+ ...filePathsForController,
22
+ ...filePathsForRoute,
23
+ ...filePathsForTemplate,
24
+ ].map((oldFilePath) => {
25
+ const fileName = getFileName(oldFilePath);
26
+ const newFilePath = renamePodPath(oldFilePath, {
27
+ podDir,
28
+ replace: (dir) => {
29
+ switch (fileName) {
30
+ case 'controller': {
31
+ return `app/controllers/${dir}`;
32
+ }
33
+ case 'route': {
34
+ return `app/routes/${dir}`;
35
+ }
36
+ case 'template': {
37
+ return `app/templates/${dir}`;
38
+ }
39
+ }
40
+ },
41
+ });
42
+ return [oldFilePath, newFilePath];
43
+ });
44
+ }
@@ -1,12 +1,12 @@
1
1
  import { mapComponents } from './map-components.js';
2
- import { mapRouteControllers } from './map-route-controllers.js';
3
- import { mapRouteRoutes } from './map-route-routes.js';
2
+ import { mapRoutes1 } from './map-routes-1.js';
3
+ import { mapRoutes2 } from './map-routes-2.js';
4
4
  import { mapServices } from './map-services.js';
5
5
  export function mapTestsFolder(options) {
6
6
  return new Map([
7
7
  ...mapComponents(options),
8
- ...mapRouteControllers(options),
9
- ...mapRouteRoutes(options),
8
+ ...mapRoutes1(options),
9
+ ...mapRoutes2(options),
10
10
  ...mapServices(options),
11
11
  ]);
12
12
  }
@@ -0,0 +1,38 @@
1
+ import { findFiles, parseFilePath } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
+ function getFileName(filePath) {
4
+ const { name } = parseFilePath(filePath);
5
+ return name;
6
+ }
7
+ /*
8
+ Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
9
+ */
10
+ export function mapRoutes1(options) {
11
+ const { projectRoot } = options;
12
+ const podDir = 'tests/unit';
13
+ const filePathsForController = findFiles(`${podDir}/**/controller-test.{js,ts}`, {
14
+ ignoreList: ['tests/unit/controllers/**'],
15
+ projectRoot,
16
+ });
17
+ const filePathsForRoute = findFiles(`${podDir}/**/route-test.{js,ts}`, {
18
+ ignoreList: ['tests/unit/routes/**'],
19
+ projectRoot,
20
+ });
21
+ return [...filePathsForController, ...filePathsForRoute].map((oldFilePath) => {
22
+ const fileName = getFileName(oldFilePath);
23
+ const newFilePath = renamePodPath(oldFilePath, {
24
+ podDir,
25
+ replace: (dir) => {
26
+ switch (fileName) {
27
+ case 'controller-test': {
28
+ return `tests/unit/controllers/${dir}-test`;
29
+ }
30
+ case 'route-test': {
31
+ return `tests/unit/routes/${dir}-test`;
32
+ }
33
+ }
34
+ },
35
+ });
36
+ return [oldFilePath, newFilePath];
37
+ });
38
+ }
@@ -0,0 +1,36 @@
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
+ /*
4
+ Case 2: Passed the --pod flag to Ember CLI
5
+ */
6
+ export function mapRoutes2(options) {
7
+ const { projectRoot } = options;
8
+ const podDirForController = 'tests/unit/controllers';
9
+ const filePathsForController = findFiles(`${podDirForController}/**/controller-test.{js,ts}`, {
10
+ projectRoot,
11
+ });
12
+ const podDirForRoute = 'tests/unit/routes';
13
+ const filePathsForRoute = findFiles(`${podDirForRoute}/**/route-test.{js,ts}`, {
14
+ projectRoot,
15
+ });
16
+ return [
17
+ ...filePathsForController.map((oldFilePath) => {
18
+ const newFilePath = renamePodPath(oldFilePath, {
19
+ podDir: podDirForController,
20
+ replace: (dir) => {
21
+ return `tests/unit/controllers/${dir}-test`;
22
+ },
23
+ });
24
+ return [oldFilePath, newFilePath];
25
+ }),
26
+ ...filePathsForRoute.map((oldFilePath) => {
27
+ const newFilePath = renamePodPath(oldFilePath, {
28
+ podDir: podDirForRoute,
29
+ replace: (dir) => {
30
+ return `tests/unit/routes/${dir}-test`;
31
+ },
32
+ });
33
+ return [oldFilePath, newFilePath];
34
+ }),
35
+ ];
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-codemod-pod-to-octane",
3
- "version": "5.0.4",
3
+ "version": "5.1.0",
4
4
  "description": "Codemod to un-pod Ember apps, addons, and engines",
5
5
  "keywords": [
6
6
  "codemod",
@@ -28,16 +28,16 @@
28
28
  "@changesets/cli": "^2.31.0",
29
29
  "@codemod-utils/tests": "^3.0.2",
30
30
  "@ijlee2-frontend-configs/changesets": "^2.1.1",
31
- "@ijlee2-frontend-configs/eslint-config-node": "^3.4.0",
32
- "@ijlee2-frontend-configs/prettier": "^3.1.1",
31
+ "@ijlee2-frontend-configs/eslint-config-node": "^3.4.4",
32
+ "@ijlee2-frontend-configs/prettier": "^3.2.0",
33
33
  "@sondr3/minitest": "^0.1.2",
34
34
  "@tsconfig/node22": "^22.0.5",
35
35
  "@tsconfig/strictest": "^2.0.8",
36
- "@types/node": "^22.19.18",
36
+ "@types/node": "^22.20.0",
37
37
  "@types/yargs": "^17.0.35",
38
- "concurrently": "^9.2.1",
38
+ "concurrently": "^10.0.3",
39
39
  "eslint": "^9.39.4",
40
- "prettier": "^3.8.3",
40
+ "prettier": "^3.8.4",
41
41
  "typescript": "^5.9.3"
42
42
  },
43
43
  "engines": {
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapComponentClasses(options) {
4
- const { podPath, projectRoot } = options;
5
- const podDir = normalizedJoin('app', podPath, 'components');
6
- const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `app/components/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapComponentStylesheets(options) {
4
- const { podPath, projectRoot } = options;
5
- const podDir = normalizedJoin('app', podPath, 'components');
6
- const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `app/components/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapComponentTemplates(options) {
4
- const { podPath, projectRoot } = options;
5
- const podDir = normalizedJoin('app', podPath, 'components');
6
- const filePaths = findFiles(`${podDir}/**/template.hbs`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `app/components/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapRouteAdapters(options) {
4
- const { podPath, projectRoot } = options;
5
- const podDir = normalizedJoin('app', podPath);
6
- const filePaths = findFiles(`${podDir}/**/adapter.{js,ts}`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `app/adapters/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapRouteControllers(options) {
4
- const { podPath, projectRoot } = options;
5
- const podDir = normalizedJoin('app', podPath);
6
- const filePaths = findFiles(`${podDir}/**/controller.{js,ts}`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `app/controllers/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapRouteModels(options) {
4
- const { podPath, projectRoot } = options;
5
- const podDir = normalizedJoin('app', podPath);
6
- const filePaths = findFiles(`${podDir}/**/model.{js,ts}`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `app/models/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapRouteRoutes(options) {
4
- const { podPath, projectRoot } = options;
5
- const podDir = normalizedJoin('app', podPath);
6
- const filePaths = findFiles(`${podDir}/**/route.{js,ts}`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `app/routes/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapRouteSerializers(options) {
4
- const { podPath, projectRoot } = options;
5
- const podDir = normalizedJoin('app', podPath);
6
- const filePaths = findFiles(`${podDir}/**/serializer.{js,ts}`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `app/serializers/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,19 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapRouteStylesheets(options) {
4
- const { podPath, projectRoot } = options;
5
- const podDir = normalizedJoin('app', podPath);
6
- const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
7
- ignoreList: [normalizedJoin('app', podPath, 'components/**')],
8
- projectRoot,
9
- });
10
- return filePaths.map((oldFilePath) => {
11
- const newFilePath = renamePodPath(oldFilePath, {
12
- podDir,
13
- replace: (dir) => {
14
- return `app/styles/${dir}`;
15
- },
16
- });
17
- return [oldFilePath, newFilePath];
18
- });
19
- }
@@ -1,19 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapRouteTemplates(options) {
4
- const { podPath, projectRoot } = options;
5
- const podDir = normalizedJoin('app', podPath);
6
- const filePaths = findFiles(`${podDir}/**/template.hbs`, {
7
- ignoreList: [normalizedJoin('app', podPath, 'components/**')],
8
- projectRoot,
9
- });
10
- return filePaths.map((oldFilePath) => {
11
- const newFilePath = renamePodPath(oldFilePath, {
12
- podDir,
13
- replace: (dir) => {
14
- return `app/templates/${dir}`;
15
- },
16
- });
17
- return [oldFilePath, newFilePath];
18
- });
19
- }
@@ -1,39 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapRouteControllers(options) {
4
- const { podPath, projectRoot } = options;
5
- /*
6
- Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
7
- */
8
- const podDir1 = normalizedJoin('tests/unit', podPath);
9
- const filePaths1 = findFiles(`${podDir1}/**/controller-test.{js,ts}`, {
10
- ignoreList: [normalizedJoin('tests/unit', podPath, 'controllers/**')],
11
- projectRoot,
12
- });
13
- const filePathMap1 = filePaths1.map((oldFilePath) => {
14
- const newFilePath = renamePodPath(oldFilePath, {
15
- podDir: podDir1,
16
- replace: (dir) => {
17
- return `tests/unit/controllers/${dir}-test`;
18
- },
19
- });
20
- return [oldFilePath, newFilePath];
21
- });
22
- /*
23
- Case 2: Passed the --pod flag to Ember CLI
24
- */
25
- const podDir2 = normalizedJoin('tests/unit', podPath, 'controllers');
26
- const filePaths2 = findFiles(`${podDir2}/**/controller-test.{js,ts}`, {
27
- projectRoot,
28
- });
29
- const filePathMap2 = filePaths2.map((oldFilePath) => {
30
- const newFilePath = renamePodPath(oldFilePath, {
31
- podDir: podDir2,
32
- replace: (dir) => {
33
- return `tests/unit/controllers/${dir}-test`;
34
- },
35
- });
36
- return [oldFilePath, newFilePath];
37
- });
38
- return [...filePathMap1, ...filePathMap2];
39
- }
@@ -1,39 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapRouteRoutes(options) {
4
- const { podPath, projectRoot } = options;
5
- /*
6
- Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
7
- */
8
- const podDir1 = normalizedJoin('tests/unit', podPath);
9
- const filePaths1 = findFiles(`${podDir1}/**/route-test.{js,ts}`, {
10
- ignoreList: [normalizedJoin('tests/unit', podPath, 'routes/**')],
11
- projectRoot,
12
- });
13
- const filePathMap1 = filePaths1.map((oldFilePath) => {
14
- const newFilePath = renamePodPath(oldFilePath, {
15
- podDir: podDir1,
16
- replace: (dir) => {
17
- return `tests/unit/routes/${dir}-test`;
18
- },
19
- });
20
- return [oldFilePath, newFilePath];
21
- });
22
- /*
23
- Case 2: Passed the --pod flag to Ember CLI
24
- */
25
- const podDir2 = normalizedJoin('tests/unit', podPath, 'routes');
26
- const filePaths2 = findFiles(`${podDir2}/**/route-test.{js,ts}`, {
27
- projectRoot,
28
- });
29
- const filePathMap2 = filePaths2.map((oldFilePath) => {
30
- const newFilePath = renamePodPath(oldFilePath, {
31
- podDir: podDir2,
32
- replace: (dir) => {
33
- return `tests/unit/routes/${dir}-test`;
34
- },
35
- });
36
- return [oldFilePath, newFilePath];
37
- });
38
- return [...filePathMap1, ...filePathMap2];
39
- }
@@ -1,2 +0,0 @@
1
- export * from './app/index.js';
2
- export * from './v1-addon/index.js';
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapComponentClasses(options) {
4
- const { projectRoot } = options;
5
- const podDir = 'addon/components';
6
- const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `addon/components/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapComponentStylesheets(options) {
4
- const { projectRoot } = options;
5
- const podDir = 'addon/components';
6
- const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `addon/components/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapComponentTemplates(options) {
4
- const { projectRoot } = options;
5
- const podDir = 'addon/components';
6
- const filePaths = findFiles(`${podDir}/**/template.hbs`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `addon/components/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapRouteControllers(options) {
4
- const { projectRoot } = options;
5
- const podDir = 'addon';
6
- const filePaths = findFiles(`${podDir}/**/controller.{js,ts}`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `addon/controllers/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapRouteRoutes(options) {
4
- const { projectRoot } = options;
5
- const podDir = 'addon';
6
- const filePaths = findFiles(`${podDir}/**/route.{js,ts}`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `addon/routes/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,19 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapRouteStylesheets(options) {
4
- const { projectRoot } = options;
5
- const podDir = 'addon';
6
- const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
7
- ignoreList: ['addon/components/**'],
8
- projectRoot,
9
- });
10
- return filePaths.map((oldFilePath) => {
11
- const newFilePath = renamePodPath(oldFilePath, {
12
- podDir,
13
- replace: (dir) => {
14
- return `addon/styles/${dir}`;
15
- },
16
- });
17
- return [oldFilePath, newFilePath];
18
- });
19
- }
@@ -1,19 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapRouteTemplates(options) {
4
- const { projectRoot } = options;
5
- const podDir = 'addon';
6
- const filePaths = findFiles(`${podDir}/**/template.hbs`, {
7
- ignoreList: ['addon/components/**'],
8
- projectRoot,
9
- });
10
- return filePaths.map((oldFilePath) => {
11
- const newFilePath = renamePodPath(oldFilePath, {
12
- podDir,
13
- replace: (dir) => {
14
- return `addon/templates/${dir}`;
15
- },
16
- });
17
- return [oldFilePath, newFilePath];
18
- });
19
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapComponentTemplates(options) {
4
- const { projectRoot } = options;
5
- const podDir = 'app/components';
6
- const filePaths = findFiles(`${podDir}/**/template.js`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `app/components/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapRouteControllers(options) {
4
- const { projectRoot } = options;
5
- const podDir = 'app';
6
- const filePaths = findFiles(`${podDir}/**/controller.js`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `app/controllers/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,18 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapRouteRoutes(options) {
4
- const { projectRoot } = options;
5
- const podDir = 'app';
6
- const filePaths = findFiles(`${podDir}/**/route.js`, {
7
- projectRoot,
8
- });
9
- return filePaths.map((oldFilePath) => {
10
- const newFilePath = renamePodPath(oldFilePath, {
11
- podDir,
12
- replace: (dir) => {
13
- return `app/routes/${dir}`;
14
- },
15
- });
16
- return [oldFilePath, newFilePath];
17
- });
18
- }
@@ -1,19 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapRouteTemplates(options) {
4
- const { projectRoot } = options;
5
- const podDir = 'app';
6
- const filePaths = findFiles(`${podDir}/**/template.js`, {
7
- ignoreList: ['app/components/**'],
8
- projectRoot,
9
- });
10
- return filePaths.map((oldFilePath) => {
11
- const newFilePath = renamePodPath(oldFilePath, {
12
- podDir,
13
- replace: (dir) => {
14
- return `app/templates/${dir}`;
15
- },
16
- });
17
- return [oldFilePath, newFilePath];
18
- });
19
- }
@@ -1,39 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapRouteControllers(options) {
4
- const { projectRoot } = options;
5
- /*
6
- Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
7
- */
8
- const podDir1 = 'tests/unit';
9
- const filePaths1 = findFiles(`${podDir1}/**/controller-test.{js,ts}`, {
10
- ignoreList: ['tests/unit/controllers/**'],
11
- projectRoot,
12
- });
13
- const filePathMap1 = filePaths1.map((oldFilePath) => {
14
- const newFilePath = renamePodPath(oldFilePath, {
15
- podDir: podDir1,
16
- replace: (dir) => {
17
- return `tests/unit/controllers/${dir}-test`;
18
- },
19
- });
20
- return [oldFilePath, newFilePath];
21
- });
22
- /*
23
- Case 2: Passed the --pod flag to Ember CLI
24
- */
25
- const podDir2 = 'tests/unit/controllers';
26
- const filePaths2 = findFiles(`${podDir2}/**/controller-test.{js,ts}`, {
27
- projectRoot,
28
- });
29
- const filePathMap2 = filePaths2.map((oldFilePath) => {
30
- const newFilePath = renamePodPath(oldFilePath, {
31
- podDir: podDir2,
32
- replace: (dir) => {
33
- return `tests/unit/controllers/${dir}-test`;
34
- },
35
- });
36
- return [oldFilePath, newFilePath];
37
- });
38
- return [...filePathMap1, ...filePathMap2];
39
- }
@@ -1,39 +0,0 @@
1
- import { findFiles } from '@codemod-utils/files';
2
- import { renamePodPath } from '../../../../../utils/files/index.js';
3
- export function mapRouteRoutes(options) {
4
- const { projectRoot } = options;
5
- /*
6
- Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
7
- */
8
- const podDir1 = 'tests/unit';
9
- const filePaths1 = findFiles(`${podDir1}/**/route-test.{js,ts}`, {
10
- ignoreList: ['tests/unit/routes/**'],
11
- projectRoot,
12
- });
13
- const filePathMap1 = filePaths1.map((oldFilePath) => {
14
- const newFilePath = renamePodPath(oldFilePath, {
15
- podDir: podDir1,
16
- replace: (dir) => {
17
- return `tests/unit/routes/${dir}-test`;
18
- },
19
- });
20
- return [oldFilePath, newFilePath];
21
- });
22
- /*
23
- Case 2: Passed the --pod flag to Ember CLI
24
- */
25
- const podDir2 = 'tests/unit/routes';
26
- const filePaths2 = findFiles(`${podDir2}/**/route-test.{js,ts}`, {
27
- projectRoot,
28
- });
29
- const filePathMap2 = filePaths2.map((oldFilePath) => {
30
- const newFilePath = renamePodPath(oldFilePath, {
31
- podDir: podDir2,
32
- replace: (dir) => {
33
- return `tests/unit/routes/${dir}-test`;
34
- },
35
- });
36
- return [oldFilePath, newFilePath];
37
- });
38
- return [...filePathMap1, ...filePathMap2];
39
- }