ember-codemod-pod-to-octane 3.0.0 → 3.1.1

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 (36) hide show
  1. package/README.md +37 -1
  2. package/dist/src/migration/app/steps/create-file-path-maps/app/map-component-classes.js +3 -2
  3. package/dist/src/migration/app/steps/create-file-path-maps/app/map-component-stylesheets.js +3 -2
  4. package/dist/src/migration/app/steps/create-file-path-maps/app/map-component-templates.js +3 -2
  5. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-adapters.js +3 -2
  6. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-controllers.js +3 -2
  7. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-models.js +3 -2
  8. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-routes.js +3 -2
  9. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-serializers.js +3 -2
  10. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.js +4 -2
  11. package/dist/src/migration/app/steps/create-file-path-maps/app/map-route-templates.js +4 -2
  12. package/dist/src/migration/app/steps/create-file-path-maps/app/map-services.js +3 -2
  13. package/dist/src/migration/app/steps/create-file-path-maps/tests/map-components.js +3 -2
  14. package/dist/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.js +7 -4
  15. package/dist/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.js +7 -4
  16. package/dist/src/migration/app/steps/create-file-path-maps/tests/map-services.js +4 -2
  17. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-classes.js +3 -2
  18. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-stylesheets.js +3 -2
  19. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-templates.js +3 -2
  20. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-controllers.js +3 -2
  21. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-routes.js +3 -2
  22. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-stylesheets.js +4 -2
  23. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-templates.js +4 -2
  24. package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-services.js +3 -2
  25. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-classes.js +3 -2
  26. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-templates.js +3 -2
  27. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-controllers.js +3 -2
  28. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-routes.js +3 -2
  29. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-templates.js +4 -2
  30. package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-services.js +3 -2
  31. package/dist/src/migration/v1-addon/steps/create-file-path-maps/tests/map-components.js +3 -2
  32. package/dist/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-controllers.js +7 -4
  33. package/dist/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-routes.js +7 -4
  34. package/dist/src/migration/v1-addon/steps/create-file-path-maps/tests/map-services.js +4 -2
  35. package/dist/src/utils/files/rename-pod-path.js +4 -4
  36. package/package.json +15 -15
package/README.md CHANGED
@@ -20,11 +20,28 @@ cd <path/to/your/project>
20
20
  npx ember-codemod-pod-to-octane <arguments>
21
21
  ```
22
22
 
23
+ > [!NOTE]
24
+ >
25
+ > By default, Octane assumes the **flat component structure**. So does this codemod to help different Ember projects converge to one layout. If you want the **nested component structure** (also supported by Octane), you can run [`ember-flat-to-nested`](https://github.com/bertdeblock/ember-flat-to-nested) afterwards.
26
+
23
27
  Step 2. Remove `podModulePrefix` from `config/environment.js` and `usePods` from `.ember-cli`.
24
28
 
25
29
  Step 3. Update references originating from, as well as pointing to, the moved files. These can include `import` statement, `composes` property from `ember-css-modules`, etc.
26
30
 
27
- <sup>1. By default, Octane assumes the **flat component structure**. So does this codemod to help different Ember projects converge to one layout. If you want the **nested component structure** (also supported by Octane), you can run [`ember-flat-to-nested`](https://github.com/bertdeblock/ember-flat-to-nested) afterwards.</sup>
31
+ > [!TIP]
32
+ >
33
+ > Linters can help you find the files that need to be updated.
34
+ >
35
+ > ```sh
36
+ > # With eslint-plugin-import
37
+ > [lint:js] /my-v1-addon/addon/index.ts
38
+ > [lint:js] 1:49 error Unable to resolve path to module './components/navigation-menu/component' import/no-unresolved
39
+ >
40
+ > # With typescript
41
+ > [lint:types] addon/index.ts:1:49 - error TS2307: Cannot find module './components/navigation-menu/component' or its corresponding type declarations.
42
+ > [lint:types]
43
+ > [lint:types] 1 export { default as NavigationMenu } from './components/navigation-menu/component';
44
+ > ```
28
45
 
29
46
 
30
47
  ### Arguments
@@ -122,6 +139,25 @@ pnpm build
122
139
  ./dist/bin/ember-codemod-pod-to-octane.js --root <path/to/your/project>
123
140
  ```
124
141
 
142
+ > [!TIP]
143
+ >
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
+ >
146
+ > ```diff
147
+ > export function mapComponentClasses(options: Options): FilePathMapEntries {
148
+ > const { podPath, projectRoot } = options;
149
+ >
150
+ > const podDir = join('app', podPath, 'components');
151
+ >
152
+ > - const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
153
+ > + const filePaths = findFiles(`${podDir}/navigation-menu/**/component.{d.ts,js,ts}`, {
154
+ >
155
+ > // ...
156
+ > }
157
+ > ```
158
+ >
159
+ > That is, look for `findFiles(`, then insert the component or route name between `podDir` and `**`.
160
+
125
161
 
126
162
  ## Compatibility
127
163
 
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapComponentClasses(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('app', podPath, 'components/**/component.{d.ts,js,ts}'), {
6
+ const podDir = join('app', podPath, 'components');
7
+ const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
7
8
  projectRoot,
8
9
  });
9
10
  return filePaths.map((oldFilePath) => {
10
11
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('app', podPath, 'components'),
12
+ podDir,
12
13
  replace: (key) => {
13
14
  return `app/components/${key}`;
14
15
  },
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapComponentStylesheets(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('app', podPath, 'components/**/styles.{css,scss}'), {
6
+ const podDir = join('app', podPath, 'components');
7
+ const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
7
8
  projectRoot,
8
9
  });
9
10
  return filePaths.map((oldFilePath) => {
10
11
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('app', podPath, 'components'),
12
+ podDir,
12
13
  replace: (key) => {
13
14
  return `app/components/${key}`;
14
15
  },
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapComponentTemplates(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('app', podPath, 'components/**/template.hbs'), {
6
+ const podDir = join('app', podPath, 'components');
7
+ const filePaths = findFiles(`${podDir}/**/template.hbs`, {
7
8
  projectRoot,
8
9
  });
9
10
  return filePaths.map((oldFilePath) => {
10
11
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('app', podPath, 'components'),
12
+ podDir,
12
13
  replace: (key) => {
13
14
  return `app/components/${key}`;
14
15
  },
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapRouteAdapters(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('app', podPath, '**/adapter.{js,ts}'), {
6
+ const podDir = join('app', podPath);
7
+ const filePaths = findFiles(`${podDir}/**/adapter.{js,ts}`, {
7
8
  projectRoot,
8
9
  });
9
10
  return filePaths.map((oldFilePath) => {
10
11
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('app', podPath),
12
+ podDir,
12
13
  replace: (key) => {
13
14
  return `app/adapters/${key}`;
14
15
  },
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapRouteControllers(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('app', podPath, '**/controller.{js,ts}'), {
6
+ const podDir = join('app', podPath);
7
+ const filePaths = findFiles(`${podDir}/**/controller.{js,ts}`, {
7
8
  projectRoot,
8
9
  });
9
10
  return filePaths.map((oldFilePath) => {
10
11
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('app', podPath),
12
+ podDir,
12
13
  replace: (key) => {
13
14
  return `app/controllers/${key}`;
14
15
  },
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapRouteModels(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('app', podPath, '**/model.{js,ts}'), {
6
+ const podDir = join('app', podPath);
7
+ const filePaths = findFiles(`${podDir}/**/model.{js,ts}`, {
7
8
  projectRoot,
8
9
  });
9
10
  return filePaths.map((oldFilePath) => {
10
11
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('app', podPath),
12
+ podDir,
12
13
  replace: (key) => {
13
14
  return `app/models/${key}`;
14
15
  },
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapRouteRoutes(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('app', podPath, '**/route.{js,ts}'), {
6
+ const podDir = join('app', podPath);
7
+ const filePaths = findFiles(`${podDir}/**/route.{js,ts}`, {
7
8
  projectRoot,
8
9
  });
9
10
  return filePaths.map((oldFilePath) => {
10
11
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('app', podPath),
12
+ podDir,
12
13
  replace: (key) => {
13
14
  return `app/routes/${key}`;
14
15
  },
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapRouteSerializers(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('app', podPath, '**/serializer.{js,ts}'), {
6
+ const podDir = join('app', podPath);
7
+ const filePaths = findFiles(`${podDir}/**/serializer.{js,ts}`, {
7
8
  projectRoot,
8
9
  });
9
10
  return filePaths.map((oldFilePath) => {
10
11
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('app', podPath),
12
+ podDir,
12
13
  replace: (key) => {
13
14
  return `app/serializers/${key}`;
14
15
  },
@@ -3,12 +3,14 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapRouteStylesheets(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('app', podPath, '!(components)/**/styles.{css,scss}'), {
6
+ const podDir = join('app', podPath);
7
+ const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
8
+ ignoreList: [join('app', podPath, 'components/**')],
7
9
  projectRoot,
8
10
  });
9
11
  return filePaths.map((oldFilePath) => {
10
12
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('app', podPath),
13
+ podDir,
12
14
  replace: (key) => {
13
15
  return `app/styles/${key}`;
14
16
  },
@@ -3,12 +3,14 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapRouteTemplates(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('app', podPath, '!(components)/**/template.hbs'), {
6
+ const podDir = join('app', podPath);
7
+ const filePaths = findFiles(`${podDir}/**/template.hbs`, {
8
+ ignoreList: [join('app', podPath, 'components/**')],
7
9
  projectRoot,
8
10
  });
9
11
  return filePaths.map((oldFilePath) => {
10
12
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('app', podPath),
13
+ podDir,
12
14
  replace: (key) => {
13
15
  return `app/templates/${key}`;
14
16
  },
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapServices(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('app', podPath, '**/service.{js,ts}'), {
6
+ const podDir = join('app', podPath);
7
+ const filePaths = findFiles(`${podDir}/**/service.{js,ts}`, {
7
8
  projectRoot,
8
9
  });
9
10
  return filePaths.map((oldFilePath) => {
10
11
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('app', podPath),
12
+ podDir,
12
13
  replace: (key) => {
13
14
  return `app/services/${key}`;
14
15
  },
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapComponents(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('tests/integration', podPath, 'components/**/component-test.{js,ts}'), {
6
+ const podDir = join('tests/integration', podPath, 'components');
7
+ const filePaths = findFiles(`${podDir}/**/component-test.{js,ts}`, {
7
8
  projectRoot,
8
9
  });
9
10
  return filePaths.map((oldFilePath) => {
10
11
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('tests/integration', podPath, 'components'),
12
+ podDir,
12
13
  replace: (key) => {
13
14
  return `tests/integration/components/${key}-test`;
14
15
  },
@@ -6,12 +6,14 @@ export function mapRouteControllers(options) {
6
6
  /*
7
7
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
8
8
  */
9
- const filePaths1 = findFiles(join('tests/unit', podPath, '!(controllers)/**/controller-test.{js,ts}'), {
9
+ const podDir1 = join('tests/unit', podPath);
10
+ const filePaths1 = findFiles(`${podDir1}/**/controller-test.{js,ts}`, {
11
+ ignoreList: [join('tests/unit', podPath, 'controllers/**')],
10
12
  projectRoot,
11
13
  });
12
14
  const filePathMap1 = filePaths1.map((oldFilePath) => {
13
15
  const newFilePath = renamePodPath(oldFilePath, {
14
- entityDir: join('tests/unit', podPath),
16
+ podDir: podDir1,
15
17
  replace: (key) => {
16
18
  return `tests/unit/controllers/${key}-test`;
17
19
  },
@@ -21,12 +23,13 @@ export function mapRouteControllers(options) {
21
23
  /*
22
24
  Case 2: Passed the --pod flag to Ember CLI
23
25
  */
24
- const filePaths2 = findFiles(join('tests/unit', podPath, 'controllers/**/controller-test.{js,ts}'), {
26
+ const podDir2 = join('tests/unit', podPath, 'controllers');
27
+ const filePaths2 = findFiles(`${podDir2}/**/controller-test.{js,ts}`, {
25
28
  projectRoot,
26
29
  });
27
30
  const filePathMap2 = filePaths2.map((oldFilePath) => {
28
31
  const newFilePath = renamePodPath(oldFilePath, {
29
- entityDir: join('tests/unit', podPath, 'controllers'),
32
+ podDir: podDir2,
30
33
  replace: (key) => {
31
34
  return `tests/unit/controllers/${key}-test`;
32
35
  },
@@ -6,12 +6,14 @@ export function mapRouteRoutes(options) {
6
6
  /*
7
7
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
8
8
  */
9
- const filePaths1 = findFiles(join('tests/unit', podPath, '!(routes)/**/route-test.{js,ts}'), {
9
+ const podDir1 = join('tests/unit', podPath);
10
+ const filePaths1 = findFiles(`${podDir1}/**/route-test.{js,ts}`, {
11
+ ignoreList: [join('tests/unit', podPath, 'routes/**')],
10
12
  projectRoot,
11
13
  });
12
14
  const filePathMap1 = filePaths1.map((oldFilePath) => {
13
15
  const newFilePath = renamePodPath(oldFilePath, {
14
- entityDir: join('tests/unit', podPath),
16
+ podDir: podDir1,
15
17
  replace: (key) => {
16
18
  return `tests/unit/routes/${key}-test`;
17
19
  },
@@ -21,12 +23,13 @@ export function mapRouteRoutes(options) {
21
23
  /*
22
24
  Case 2: Passed the --pod flag to Ember CLI
23
25
  */
24
- const filePaths2 = findFiles(join('tests/unit', podPath, 'routes/**/route-test.{js,ts}'), {
26
+ const podDir2 = join('tests/unit', podPath, 'routes');
27
+ const filePaths2 = findFiles(`${podDir2}/**/route-test.{js,ts}`, {
25
28
  projectRoot,
26
29
  });
27
30
  const filePathMap2 = filePaths2.map((oldFilePath) => {
28
31
  const newFilePath = renamePodPath(oldFilePath, {
29
- entityDir: join('tests/unit', podPath, 'routes'),
32
+ podDir: podDir2,
30
33
  replace: (key) => {
31
34
  return `tests/unit/routes/${key}-test`;
32
35
  },
@@ -3,12 +3,14 @@ import { findFiles } from '@codemod-utils/files';
3
3
  import { renamePodPath } from '../../../../../utils/files/index.js';
4
4
  export function mapServices(options) {
5
5
  const { podPath, projectRoot } = options;
6
- const filePaths = findFiles(join('tests/unit', podPath, '!(services)/**/service-test.{js,ts}'), {
6
+ const podDir = join('tests/unit', podPath);
7
+ const filePaths = findFiles(`${podDir}/**/service-test.{js,ts}`, {
8
+ ignoreList: [join('tests/unit', podPath, 'services/**')],
7
9
  projectRoot,
8
10
  });
9
11
  return filePaths.map((oldFilePath) => {
10
12
  const newFilePath = renamePodPath(oldFilePath, {
11
- entityDir: join('tests/unit', podPath),
13
+ podDir,
12
14
  replace: (key) => {
13
15
  return `tests/unit/services/${key}-test`;
14
16
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapComponentClasses(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('addon/components/**/component.{d.ts,js,ts}', {
5
+ const podDir = 'addon/components';
6
+ const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'addon/components',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `addon/components/${key}`;
13
14
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapComponentStylesheets(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('addon/components/**/styles.{css,scss}', {
5
+ const podDir = 'addon/components';
6
+ const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'addon/components',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `addon/components/${key}`;
13
14
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapComponentTemplates(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('addon/components/**/template.hbs', {
5
+ const podDir = 'addon/components';
6
+ const filePaths = findFiles(`${podDir}/**/template.hbs`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'addon/components',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `addon/components/${key}`;
13
14
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapRouteControllers(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('addon/**/controller.{js,ts}', {
5
+ const podDir = 'addon';
6
+ const filePaths = findFiles(`${podDir}/**/controller.{js,ts}`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'addon',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `addon/controllers/${key}`;
13
14
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapRouteRoutes(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('addon/**/route.{js,ts}', {
5
+ const podDir = 'addon';
6
+ const filePaths = findFiles(`${podDir}/**/route.{js,ts}`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'addon',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `addon/routes/${key}`;
13
14
  },
@@ -2,12 +2,14 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapRouteStylesheets(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('addon/!(components)/**/styles.{css,scss}', {
5
+ const podDir = 'addon';
6
+ const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
7
+ ignoreList: ['addon/components/**'],
6
8
  projectRoot,
7
9
  });
8
10
  return filePaths.map((oldFilePath) => {
9
11
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'addon',
12
+ podDir,
11
13
  replace: (key) => {
12
14
  return `addon/styles/${key}`;
13
15
  },
@@ -2,12 +2,14 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapRouteTemplates(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('addon/!(components)/**/template.hbs', {
5
+ const podDir = 'addon';
6
+ const filePaths = findFiles(`${podDir}/**/template.hbs`, {
7
+ ignoreList: ['addon/components/**'],
6
8
  projectRoot,
7
9
  });
8
10
  return filePaths.map((oldFilePath) => {
9
11
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'addon',
12
+ podDir,
11
13
  replace: (key) => {
12
14
  return `addon/templates/${key}`;
13
15
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapServices(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('addon/**/service.{js,ts}', {
5
+ const podDir = 'addon';
6
+ const filePaths = findFiles(`${podDir}/**/service.{js,ts}`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'addon',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `addon/services/${key}`;
13
14
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapComponentClasses(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('app/components/**/component.js', {
5
+ const podDir = 'app/components';
6
+ const filePaths = findFiles(`${podDir}/**/component.js`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'app/components',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `app/components/${key}`;
13
14
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapComponentTemplates(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('app/components/**/template.js', {
5
+ const podDir = 'app/components';
6
+ const filePaths = findFiles(`${podDir}/**/template.js`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'app/components',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `app/components/${key}`;
13
14
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapRouteControllers(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('app/**/controller.js', {
5
+ const podDir = 'app';
6
+ const filePaths = findFiles(`${podDir}/**/controller.js`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'app',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `app/controllers/${key}`;
13
14
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapRouteRoutes(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('app/**/route.js', {
5
+ const podDir = 'app';
6
+ const filePaths = findFiles(`${podDir}/**/route.js`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'app',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `app/routes/${key}`;
13
14
  },
@@ -2,12 +2,14 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapRouteTemplates(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('app/!(components)/**/template.js', {
5
+ const podDir = 'app';
6
+ const filePaths = findFiles(`${podDir}/**/template.js`, {
7
+ ignoreList: ['app/components/**'],
6
8
  projectRoot,
7
9
  });
8
10
  return filePaths.map((oldFilePath) => {
9
11
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'app',
12
+ podDir,
11
13
  replace: (key) => {
12
14
  return `app/templates/${key}`;
13
15
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapServices(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('app/**/service.js', {
5
+ const podDir = 'app';
6
+ const filePaths = findFiles(`${podDir}/**/service.js`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'app',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `app/services/${key}`;
13
14
  },
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapComponents(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('tests/integration/components/**/component-test.{js,ts}', {
5
+ const podDir = 'tests/integration/components';
6
+ const filePaths = findFiles(`${podDir}/**/component-test.{js,ts}`, {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
10
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'tests/integration/components',
11
+ podDir,
11
12
  replace: (key) => {
12
13
  return `tests/integration/components/${key}-test`;
13
14
  },
@@ -5,12 +5,14 @@ export function mapRouteControllers(options) {
5
5
  /*
6
6
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
7
7
  */
8
- const filePaths1 = findFiles('tests/unit/!(controllers)/**/controller-test.{js,ts}', {
8
+ const podDir1 = 'tests/unit';
9
+ const filePaths1 = findFiles(`${podDir1}/**/controller-test.{js,ts}`, {
10
+ ignoreList: ['tests/unit/controllers/**'],
9
11
  projectRoot,
10
12
  });
11
13
  const filePathMap1 = filePaths1.map((oldFilePath) => {
12
14
  const newFilePath = renamePodPath(oldFilePath, {
13
- entityDir: 'tests/unit',
15
+ podDir: podDir1,
14
16
  replace: (key) => {
15
17
  return `tests/unit/controllers/${key}-test`;
16
18
  },
@@ -20,12 +22,13 @@ export function mapRouteControllers(options) {
20
22
  /*
21
23
  Case 2: Passed the --pod flag to Ember CLI
22
24
  */
23
- const filePaths2 = findFiles('tests/unit/controllers/**/controller-test.{js,ts}', {
25
+ const podDir2 = 'tests/unit/controllers';
26
+ const filePaths2 = findFiles(`${podDir2}/**/controller-test.{js,ts}`, {
24
27
  projectRoot,
25
28
  });
26
29
  const filePathMap2 = filePaths2.map((oldFilePath) => {
27
30
  const newFilePath = renamePodPath(oldFilePath, {
28
- entityDir: 'tests/unit/controllers',
31
+ podDir: podDir2,
29
32
  replace: (key) => {
30
33
  return `tests/unit/controllers/${key}-test`;
31
34
  },
@@ -5,12 +5,14 @@ export function mapRouteRoutes(options) {
5
5
  /*
6
6
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
7
7
  */
8
- const filePaths1 = findFiles('tests/unit/!(routes)/**/route-test.{js,ts}', {
8
+ const podDir1 = 'tests/unit';
9
+ const filePaths1 = findFiles(`${podDir1}/**/route-test.{js,ts}`, {
10
+ ignoreList: ['tests/unit/routes/**'],
9
11
  projectRoot,
10
12
  });
11
13
  const filePathMap1 = filePaths1.map((oldFilePath) => {
12
14
  const newFilePath = renamePodPath(oldFilePath, {
13
- entityDir: 'tests/unit',
15
+ podDir: podDir1,
14
16
  replace: (key) => {
15
17
  return `tests/unit/routes/${key}-test`;
16
18
  },
@@ -20,12 +22,13 @@ export function mapRouteRoutes(options) {
20
22
  /*
21
23
  Case 2: Passed the --pod flag to Ember CLI
22
24
  */
23
- const filePaths2 = findFiles('tests/unit/routes/**/route-test.{js,ts}', {
25
+ const podDir2 = 'tests/unit/routes';
26
+ const filePaths2 = findFiles(`${podDir2}/**/route-test.{js,ts}`, {
24
27
  projectRoot,
25
28
  });
26
29
  const filePathMap2 = filePaths2.map((oldFilePath) => {
27
30
  const newFilePath = renamePodPath(oldFilePath, {
28
- entityDir: 'tests/unit/routes',
31
+ podDir: podDir2,
29
32
  replace: (key) => {
30
33
  return `tests/unit/routes/${key}-test`;
31
34
  },
@@ -2,12 +2,14 @@ import { findFiles } from '@codemod-utils/files';
2
2
  import { renamePodPath } from '../../../../../utils/files/index.js';
3
3
  export function mapServices(options) {
4
4
  const { projectRoot } = options;
5
- const filePaths = findFiles('tests/unit/!(services)/**/service-test.{js,ts}', {
5
+ const podDir = 'tests/unit';
6
+ const filePaths = findFiles(`${podDir}/**/service-test.{js,ts}`, {
7
+ ignoreList: ['tests/unit/services/**'],
6
8
  projectRoot,
7
9
  });
8
10
  return filePaths.map((oldFilePath) => {
9
11
  const newFilePath = renamePodPath(oldFilePath, {
10
- entityDir: 'tests/unit',
12
+ podDir,
11
13
  replace: (key) => {
12
14
  return `tests/unit/services/${key}-test`;
13
15
  },
@@ -1,12 +1,12 @@
1
1
  import { parseFilePath } from '@codemod-utils/files';
2
2
  export function renamePodPath(filePath, options) {
3
3
  const { dir, ext, name } = parseFilePath(filePath);
4
- const { entityDir, replace } = options;
5
- if (!dir.startsWith(entityDir)) {
6
- throw new RangeError(`ERROR: The provided path \`${filePath}\` doesn't match the directory pattern \`${entityDir}\`.\n`);
4
+ const { podDir, replace } = options;
5
+ if (!dir.startsWith(podDir)) {
6
+ throw new RangeError(`ERROR: The provided path \`${filePath}\` doesn't match the directory pattern \`${podDir}\`.\n`);
7
7
  }
8
8
  const key = filePath
9
- .replace(new RegExp(`^${entityDir}/`), '')
9
+ .replace(new RegExp(`^${podDir}/`), '')
10
10
  .replace(new RegExp(`/${name}${ext}$`), '');
11
11
  return `${replace(key)}${ext}`;
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-codemod-pod-to-octane",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "description": "Codemod to un-pod Ember apps, addons, and engines",
5
5
  "keywords": [
6
6
  "codemod",
@@ -24,31 +24,31 @@
24
24
  "dist"
25
25
  ],
26
26
  "dependencies": {
27
- "@codemod-utils/files": "^2.0.4",
27
+ "@codemod-utils/files": "^2.0.5",
28
28
  "yargs": "^17.7.2"
29
29
  },
30
30
  "devDependencies": {
31
- "@babel/core": "^7.25.2",
32
- "@codemod-utils/tests": "^1.1.7",
31
+ "@babel/core": "^7.26.0",
32
+ "@codemod-utils/tests": "^1.1.8",
33
33
  "@sondr3/minitest": "^0.1.2",
34
34
  "@tsconfig/node18": "^18.2.4",
35
35
  "@tsconfig/strictest": "^2.0.5",
36
- "@types/node": "^18.19.47",
36
+ "@types/node": "^18.19.68",
37
37
  "@types/yargs": "^17.0.33",
38
- "@typescript-eslint/eslint-plugin": "^8.3.0",
39
- "@typescript-eslint/parser": "^8.3.0",
40
- "concurrently": "^8.2.2",
41
- "eslint": "^8.57.0",
38
+ "@typescript-eslint/eslint-plugin": "^8.18.2",
39
+ "@typescript-eslint/parser": "^8.18.2",
40
+ "concurrently": "^9.1.0",
41
+ "eslint": "^8.57.1",
42
42
  "eslint-config-prettier": "^9.1.0",
43
- "eslint-import-resolver-typescript": "^3.6.3",
44
- "eslint-plugin-import": "^2.29.1",
45
- "eslint-plugin-n": "^17.10.2",
43
+ "eslint-import-resolver-typescript": "^3.7.0",
44
+ "eslint-plugin-import": "^2.31.0",
45
+ "eslint-plugin-n": "^17.15.1",
46
46
  "eslint-plugin-prettier": "^5.2.1",
47
47
  "eslint-plugin-simple-import-sort": "^12.1.1",
48
- "eslint-plugin-typescript-sort-keys": "^3.2.0",
48
+ "eslint-plugin-typescript-sort-keys": "^3.3.0",
49
49
  "lerna-changelog": "^2.2.0",
50
- "prettier": "^3.3.3",
51
- "typescript": "^5.5.4"
50
+ "prettier": "^3.4.2",
51
+ "typescript": "^5.7.2"
52
52
  },
53
53
  "engines": {
54
54
  "node": "18.* || >= 20"