ember-codemod-pod-to-octane 2.0.3 → 2.0.4

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/LICENSE.md +1 -1
  2. package/dist/src/migration/ember-addon/steps/create-file-path-maps/addon/map-component-classes.js +4 -6
  3. package/dist/src/migration/ember-addon/steps/create-file-path-maps/addon/map-component-stylesheets.js +4 -6
  4. package/dist/src/migration/ember-addon/steps/create-file-path-maps/addon/map-component-templates.js +4 -6
  5. package/dist/src/migration/ember-addon/steps/create-file-path-maps/app/map-component-classes.js +4 -6
  6. package/dist/src/migration/ember-addon/steps/create-file-path-maps/app/map-component-stylesheets.js +4 -6
  7. package/dist/src/migration/ember-addon/steps/create-file-path-maps/app/map-component-templates.js +4 -6
  8. package/dist/src/migration/ember-addon/steps/create-file-path-maps/tests/map-components.js +4 -6
  9. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/map-component-classes.js +4 -6
  10. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/map-component-stylesheets.js +4 -6
  11. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/map-component-templates.js +4 -6
  12. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/map-route-adapters.js +4 -6
  13. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/map-route-controllers.js +4 -6
  14. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/map-route-models.js +4 -6
  15. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/map-route-routes.js +4 -6
  16. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/map-route-serializers.js +4 -6
  17. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/map-route-stylesheets.js +4 -6
  18. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/map-route-templates.js +4 -6
  19. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/map-services.js +4 -6
  20. package/dist/src/migration/ember-app/steps/create-file-path-maps/tests/map-components.js +4 -6
  21. package/dist/src/migration/ember-app/steps/create-file-path-maps/tests/map-route-controllers.js +6 -11
  22. package/dist/src/migration/ember-app/steps/create-file-path-maps/tests/map-route-routes.js +6 -11
  23. package/dist/src/migration/ember-app/steps/create-file-path-maps/tests/map-services.js +4 -6
  24. package/dist/src/migration/ember-engine/steps/create-file-path-maps/addon/map-component-classes.js +4 -6
  25. package/dist/src/migration/ember-engine/steps/create-file-path-maps/addon/map-component-stylesheets.js +4 -6
  26. package/dist/src/migration/ember-engine/steps/create-file-path-maps/addon/map-component-templates.js +4 -6
  27. package/dist/src/migration/ember-engine/steps/create-file-path-maps/addon/map-route-controllers.js +4 -6
  28. package/dist/src/migration/ember-engine/steps/create-file-path-maps/addon/map-route-routes.js +4 -6
  29. package/dist/src/migration/ember-engine/steps/create-file-path-maps/addon/map-route-stylesheets.js +4 -6
  30. package/dist/src/migration/ember-engine/steps/create-file-path-maps/addon/map-route-templates.js +4 -6
  31. package/dist/src/migration/ember-engine/steps/create-file-path-maps/tests/map-components.js +4 -6
  32. package/dist/src/migration/ember-engine/steps/create-file-path-maps/tests/map-route-controllers.js +6 -11
  33. package/dist/src/migration/ember-engine/steps/create-file-path-maps/tests/map-route-routes.js +6 -11
  34. package/dist/src/utils/files/index.js +1 -0
  35. package/dist/src/utils/files/rename-pod-path.js +12 -0
  36. package/package.json +10 -10
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2023 Isaac J. Lee
3
+ Copyright (c) 2024 Isaac J. Lee
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapComponentClasses(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('addon/components/**/component.{d.ts,js,ts}', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'addon/components',
11
- file: 'component',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'addon/components',
13
11
  replace: (key) => {
14
12
  return `addon/components/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapComponentStylesheets(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('addon/components/**/styles.{css,scss}', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'addon/components',
11
- file: 'styles',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'addon/components',
13
11
  replace: (key) => {
14
12
  return `addon/components/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapComponentTemplates(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('addon/components/**/template.hbs', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'addon/components',
11
- file: 'template',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'addon/components',
13
11
  replace: (key) => {
14
12
  return `addon/components/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapComponentClasses(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('app/components/**/component.js', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'app/components',
11
- file: 'component',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'app/components',
13
11
  replace: (key) => {
14
12
  return `app/components/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapComponentStylesheets(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('app/components/**/styles.js', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'app/components',
11
- file: 'styles',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'app/components',
13
11
  replace: (key) => {
14
12
  return `app/components/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapComponentTemplates(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('app/components/**/template.js', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'app/components',
11
- file: 'template',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'app/components',
13
11
  replace: (key) => {
14
12
  return `app/components/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapComponents(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('tests/integration/components/**/component-test.{js,ts}', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'tests/integration/components',
11
- file: 'component-test',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'tests/integration/components',
13
11
  replace: (key) => {
14
12
  return `tests/integration/components/${key}-test`;
15
13
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapComponentClasses(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('app', podPath, 'components', '**', 'component.{d.ts,js,ts}'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('app', podPath, 'components'),
12
- file: 'component',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('app', podPath, 'components'),
14
12
  replace: (key) => {
15
13
  return `app/components/${key}`;
16
14
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapComponentStylesheets(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('app', podPath, 'components', '**', 'styles.{css,scss}'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('app', podPath, 'components'),
12
- file: 'styles',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('app', podPath, 'components'),
14
12
  replace: (key) => {
15
13
  return `app/components/${key}`;
16
14
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapComponentTemplates(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('app', podPath, 'components', '**', 'template.hbs'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('app', podPath, 'components'),
12
- file: 'template',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('app', podPath, 'components'),
14
12
  replace: (key) => {
15
13
  return `app/components/${key}`;
16
14
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapRouteAdapters(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('app', podPath, '**', 'adapter.{js,ts}'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('app', podPath),
12
- file: 'adapter',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('app', podPath),
14
12
  replace: (key) => {
15
13
  return `app/adapters/${key}`;
16
14
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapRouteControllers(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('app', podPath, '**', 'controller.{js,ts}'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('app', podPath),
12
- file: 'controller',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('app', podPath),
14
12
  replace: (key) => {
15
13
  return `app/controllers/${key}`;
16
14
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapRouteModels(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('app', podPath, '**', 'model.{js,ts}'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('app', podPath),
12
- file: 'model',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('app', podPath),
14
12
  replace: (key) => {
15
13
  return `app/models/${key}`;
16
14
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapRouteRoutes(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('app', podPath, '**', 'route.{js,ts}'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('app', podPath),
12
- file: 'route',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('app', podPath),
14
12
  replace: (key) => {
15
13
  return `app/routes/${key}`;
16
14
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapRouteSerializers(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('app', podPath, '**', 'serializer.{js,ts}'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('app', podPath),
12
- file: 'serializer',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('app', podPath),
14
12
  replace: (key) => {
15
13
  return `app/serializers/${key}`;
16
14
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapRouteStylesheets(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('app', podPath, '!(components)', '**', 'styles.{css,scss}'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('app', podPath),
12
- file: 'styles',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('app', podPath),
14
12
  replace: (key) => {
15
13
  return `app/styles/${key}`;
16
14
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapRouteTemplates(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('app', podPath, '!(components)', '**', 'template.hbs'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('app', podPath),
12
- file: 'template',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('app', podPath),
14
12
  replace: (key) => {
15
13
  return `app/templates/${key}`;
16
14
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapServices(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('app', podPath, '**', 'service.{js,ts}'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('app', podPath),
12
- file: 'service',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('app', podPath),
14
12
  replace: (key) => {
15
13
  return `app/services/${key}`;
16
14
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapComponents(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('tests/integration', podPath, 'components', '**', 'component-test.{js,ts}'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('tests/integration', podPath, 'components'),
12
- file: 'component-test',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('tests/integration', podPath, 'components'),
14
12
  replace: (key) => {
15
13
  return `tests/integration/components/${key}-test`;
16
14
  },
@@ -1,5 +1,6 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapRouteControllers(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  /*
@@ -9,11 +10,8 @@ export function mapRouteControllers(options) {
9
10
  projectRoot,
10
11
  });
11
12
  const filePathMap1 = filePaths1.map((oldFilePath) => {
12
- const newFilePath = renamePathByFile(oldFilePath, {
13
- find: {
14
- directory: join('tests/unit', podPath),
15
- file: 'controller-test',
16
- },
13
+ const newFilePath = renamePodPath(oldFilePath, {
14
+ entityDir: join('tests/unit', podPath),
17
15
  replace: (key) => {
18
16
  return `tests/unit/controllers/${key}-test`;
19
17
  },
@@ -27,11 +25,8 @@ export function mapRouteControllers(options) {
27
25
  projectRoot,
28
26
  });
29
27
  const filePathMap2 = filePaths2.map((oldFilePath) => {
30
- const newFilePath = renamePathByFile(oldFilePath, {
31
- find: {
32
- directory: join('tests/unit', podPath, 'controllers'),
33
- file: 'controller-test',
34
- },
28
+ const newFilePath = renamePodPath(oldFilePath, {
29
+ entityDir: join('tests/unit', podPath, 'controllers'),
35
30
  replace: (key) => {
36
31
  return `tests/unit/controllers/${key}-test`;
37
32
  },
@@ -1,5 +1,6 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapRouteRoutes(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  /*
@@ -9,11 +10,8 @@ export function mapRouteRoutes(options) {
9
10
  projectRoot,
10
11
  });
11
12
  const filePathMap1 = filePaths1.map((oldFilePath) => {
12
- const newFilePath = renamePathByFile(oldFilePath, {
13
- find: {
14
- directory: join('tests/unit', podPath),
15
- file: 'route-test',
16
- },
13
+ const newFilePath = renamePodPath(oldFilePath, {
14
+ entityDir: join('tests/unit', podPath),
17
15
  replace: (key) => {
18
16
  return `tests/unit/routes/${key}-test`;
19
17
  },
@@ -27,11 +25,8 @@ export function mapRouteRoutes(options) {
27
25
  projectRoot,
28
26
  });
29
27
  const filePathMap2 = filePaths2.map((oldFilePath) => {
30
- const newFilePath = renamePathByFile(oldFilePath, {
31
- find: {
32
- directory: join('tests/unit', podPath, 'routes'),
33
- file: 'route-test',
34
- },
28
+ const newFilePath = renamePodPath(oldFilePath, {
29
+ entityDir: join('tests/unit', podPath, 'routes'),
35
30
  replace: (key) => {
36
31
  return `tests/unit/routes/${key}-test`;
37
32
  },
@@ -1,16 +1,14 @@
1
1
  import { join } from 'node:path';
2
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ import { findFiles } from '@codemod-utils/files';
3
+ import { renamePodPath } from '../../../../../utils/files/index.js';
3
4
  export function mapServices(options) {
4
5
  const { podPath, projectRoot } = options;
5
6
  const filePaths = findFiles(join('tests/unit', podPath, '!(services)', '**', 'service-test.{js,ts}'), {
6
7
  projectRoot,
7
8
  });
8
9
  return filePaths.map((oldFilePath) => {
9
- const newFilePath = renamePathByFile(oldFilePath, {
10
- find: {
11
- directory: join('tests/unit', podPath),
12
- file: 'service-test',
13
- },
10
+ const newFilePath = renamePodPath(oldFilePath, {
11
+ entityDir: join('tests/unit', podPath),
14
12
  replace: (key) => {
15
13
  return `tests/unit/services/${key}-test`;
16
14
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapComponentClasses(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('addon/components/**/component.{d.ts,js,ts}', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'addon/components',
11
- file: 'component',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'addon/components',
13
11
  replace: (key) => {
14
12
  return `addon/components/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapComponentStylesheets(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('addon/components/**/styles.{css,scss}', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'addon/components',
11
- file: 'styles',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'addon/components',
13
11
  replace: (key) => {
14
12
  return `addon/components/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapComponentTemplates(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('addon/components/**/template.hbs', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'addon/components',
11
- file: 'template',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'addon/components',
13
11
  replace: (key) => {
14
12
  return `addon/components/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapRouteControllers(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('addon/**/controller.{js,ts}', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'addon',
11
- file: 'controller',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'addon',
13
11
  replace: (key) => {
14
12
  return `addon/controllers/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapRouteRoutes(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('addon/**/route.{js,ts}', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'addon',
11
- file: 'route',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'addon',
13
11
  replace: (key) => {
14
12
  return `addon/routes/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapRouteStylesheets(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('addon/!(components)/**/styles.{css,scss}', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'addon',
11
- file: 'styles',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'addon',
13
11
  replace: (key) => {
14
12
  return `addon/styles/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapRouteTemplates(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('addon/!(components)/**/template.hbs', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'addon',
11
- file: 'template',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'addon',
13
11
  replace: (key) => {
14
12
  return `addon/templates/${key}`;
15
13
  },
@@ -1,15 +1,13 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapComponents(options) {
3
4
  const { projectRoot } = options;
4
5
  const filePaths = findFiles('tests/integration/components/**/component-test.{js,ts}', {
5
6
  projectRoot,
6
7
  });
7
8
  return filePaths.map((oldFilePath) => {
8
- const newFilePath = renamePathByFile(oldFilePath, {
9
- find: {
10
- directory: 'tests/integration/components',
11
- file: 'component-test',
12
- },
9
+ const newFilePath = renamePodPath(oldFilePath, {
10
+ entityDir: 'tests/integration/components',
13
11
  replace: (key) => {
14
12
  return `tests/integration/components/${key}-test`;
15
13
  },
@@ -1,4 +1,5 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapRouteControllers(options) {
3
4
  const { projectRoot } = options;
4
5
  /*
@@ -8,11 +9,8 @@ export function mapRouteControllers(options) {
8
9
  projectRoot,
9
10
  });
10
11
  const filePathMap1 = filePaths1.map((oldFilePath) => {
11
- const newFilePath = renamePathByFile(oldFilePath, {
12
- find: {
13
- directory: 'tests/unit',
14
- file: 'controller-test',
15
- },
12
+ const newFilePath = renamePodPath(oldFilePath, {
13
+ entityDir: 'tests/unit',
16
14
  replace: (key) => {
17
15
  return `tests/unit/controllers/${key}-test`;
18
16
  },
@@ -26,11 +24,8 @@ export function mapRouteControllers(options) {
26
24
  projectRoot,
27
25
  });
28
26
  const filePathMap2 = filePaths2.map((oldFilePath) => {
29
- const newFilePath = renamePathByFile(oldFilePath, {
30
- find: {
31
- directory: 'tests/unit/controllers',
32
- file: 'controller-test',
33
- },
27
+ const newFilePath = renamePodPath(oldFilePath, {
28
+ entityDir: 'tests/unit/controllers',
34
29
  replace: (key) => {
35
30
  return `tests/unit/controllers/${key}-test`;
36
31
  },
@@ -1,4 +1,5 @@
1
- import { findFiles, renamePathByFile } from '@codemod-utils/files';
1
+ import { findFiles } from '@codemod-utils/files';
2
+ import { renamePodPath } from '../../../../../utils/files/index.js';
2
3
  export function mapRouteRoutes(options) {
3
4
  const { projectRoot } = options;
4
5
  /*
@@ -8,11 +9,8 @@ export function mapRouteRoutes(options) {
8
9
  projectRoot,
9
10
  });
10
11
  const filePathMap1 = filePaths1.map((oldFilePath) => {
11
- const newFilePath = renamePathByFile(oldFilePath, {
12
- find: {
13
- directory: 'tests/unit',
14
- file: 'route-test',
15
- },
12
+ const newFilePath = renamePodPath(oldFilePath, {
13
+ entityDir: 'tests/unit',
16
14
  replace: (key) => {
17
15
  return `tests/unit/routes/${key}-test`;
18
16
  },
@@ -26,11 +24,8 @@ export function mapRouteRoutes(options) {
26
24
  projectRoot,
27
25
  });
28
26
  const filePathMap2 = filePaths2.map((oldFilePath) => {
29
- const newFilePath = renamePathByFile(oldFilePath, {
30
- find: {
31
- directory: 'tests/unit/routes',
32
- file: 'route-test',
33
- },
27
+ const newFilePath = renamePodPath(oldFilePath, {
28
+ entityDir: 'tests/unit/routes',
34
29
  replace: (key) => {
35
30
  return `tests/unit/routes/${key}-test`;
36
31
  },
@@ -0,0 +1 @@
1
+ export * from './rename-pod-path.js';
@@ -0,0 +1,12 @@
1
+ import { parseFilePath } from '@codemod-utils/files';
2
+ export function renamePodPath(filePath, options) {
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`);
7
+ }
8
+ const key = filePath
9
+ .replace(new RegExp(`^${entityDir}/`), '')
10
+ .replace(new RegExp(`/${name}${ext}$`), '');
11
+ return `${replace(key)}${ext}`;
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-codemod-pod-to-octane",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
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": "^1.1.1",
27
+ "@codemod-utils/files": "^2.0.0",
28
28
  "yargs": "^17.7.2"
29
29
  },
30
30
  "devDependencies": {
31
- "@babel/core": "^7.23.9",
32
- "@codemod-utils/tests": "^1.1.2",
31
+ "@babel/core": "^7.24.0",
32
+ "@codemod-utils/tests": "^1.1.3",
33
33
  "@sondr3/minitest": "^0.1.2",
34
34
  "@tsconfig/node18": "^18.2.2",
35
35
  "@tsconfig/strictest": "^2.0.3",
36
- "@types/node": "^18.19.17",
36
+ "@types/node": "^18.19.24",
37
37
  "@types/yargs": "^17.0.32",
38
- "@typescript-eslint/eslint-plugin": "^7.0.2",
39
- "@typescript-eslint/parser": "^7.0.2",
38
+ "@typescript-eslint/eslint-plugin": "^7.2.0",
39
+ "@typescript-eslint/parser": "^7.2.0",
40
40
  "concurrently": "^8.2.2",
41
- "eslint": "^8.56.0",
41
+ "eslint": "^8.57.0",
42
42
  "eslint-config-prettier": "^9.1.0",
43
43
  "eslint-import-resolver-typescript": "^3.6.1",
44
44
  "eslint-plugin-import": "^2.29.1",
45
45
  "eslint-plugin-n": "^16.6.2",
46
46
  "eslint-plugin-prettier": "^5.1.3",
47
47
  "eslint-plugin-simple-import-sort": "^12.0.0",
48
- "eslint-plugin-typescript-sort-keys": "^3.1.0",
48
+ "eslint-plugin-typescript-sort-keys": "^3.2.0",
49
49
  "lerna-changelog": "^2.2.0",
50
50
  "prettier": "^3.2.5",
51
- "typescript": "^5.3.3"
51
+ "typescript": "^5.4.2"
52
52
  },
53
53
  "engines": {
54
54
  "node": "18.* || >= 20"