From fa9ada20bb00eaafba89f7664cf7b6c8353f6ba5 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Tue, 15 Oct 2024 08:34:05 +0200 Subject: [PATCH 1/6] Documented the use of linters to help with migration --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8218719..6b674dd 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,28 @@ cd npx ember-codemod-pod-to-octane ``` +> [!NOTE] +> +> 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. + Step 2. Remove `podModulePrefix` from `config/environment.js` and `usePods` from `.ember-cli`. 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. -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. +> [!TIP] +> +> Linters can help you find the files that need to be updated. +> +> ```sh +> # With eslint-plugin-import +> [lint:js] /my-v1-addon/addon/index.ts +> [lint:js] 1:49 error Unable to resolve path to module './components/navigation-menu/component' import/no-unresolved +> +> # With typescript +> [lint:types] addon/index.ts:1:49 - error TS2307: Cannot find module './components/navigation-menu/component' or its corresponding type declarations. +> [lint:types] +> [lint:types] 1 export { default as NavigationMenu } from './components/navigation-menu/component'; +> ``` ### Arguments From c7b0606131f996548feaea522033ab0b63a2e43b Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Tue, 15 Oct 2024 08:37:42 +0200 Subject: [PATCH 2/6] refactor: Removed unnecessary joins --- .../steps/create-file-path-maps/app/map-route-stylesheets.ts | 2 +- .../app/steps/create-file-path-maps/app/map-route-templates.ts | 2 +- .../steps/create-file-path-maps/tests/map-route-controllers.ts | 2 +- .../app/steps/create-file-path-maps/tests/map-route-routes.ts | 2 +- .../app/steps/create-file-path-maps/tests/map-services.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts index d2ce98d..3af89a6 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts @@ -12,7 +12,7 @@ export function mapRouteStylesheets(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; const filePaths = findFiles(join('app', podPath, '**/styles.{css,scss}'), { - ignoreList: [join('app', podPath, 'components', '**')], + ignoreList: [join('app', podPath, 'components/**')], projectRoot, }); diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts index 90815ee..a4d2124 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts @@ -12,7 +12,7 @@ export function mapRouteTemplates(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; const filePaths = findFiles(join('app', podPath, '**/template.hbs'), { - ignoreList: [join('app', podPath, 'components', '**')], + ignoreList: [join('app', podPath, 'components/**')], projectRoot, }); diff --git a/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts b/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts index b91e050..9151fbb 100644 --- a/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts +++ b/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts @@ -17,7 +17,7 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { const filePaths1 = findFiles( join('tests/unit', podPath, '**/controller-test.{js,ts}'), { - ignoreList: [join('tests/unit', podPath, 'controllers', '**')], + ignoreList: [join('tests/unit', podPath, 'controllers/**')], projectRoot, }, ); diff --git a/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts b/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts index 318c415..6ef3acd 100644 --- a/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts +++ b/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts @@ -17,7 +17,7 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { const filePaths1 = findFiles( join('tests/unit', podPath, '**/route-test.{js,ts}'), { - ignoreList: [join('tests/unit', podPath, 'routes', '**')], + ignoreList: [join('tests/unit', podPath, 'routes/**')], projectRoot, }, ); diff --git a/src/migration/app/steps/create-file-path-maps/tests/map-services.ts b/src/migration/app/steps/create-file-path-maps/tests/map-services.ts index 4ac0669..d16465e 100644 --- a/src/migration/app/steps/create-file-path-maps/tests/map-services.ts +++ b/src/migration/app/steps/create-file-path-maps/tests/map-services.ts @@ -14,7 +14,7 @@ export function mapServices(options: Options): FilePathMapEntries { const filePaths = findFiles( join('tests/unit', podPath, '**/service-test.{js,ts}'), { - ignoreList: [join('tests/unit', podPath, 'services', '**')], + ignoreList: [join('tests/unit', podPath, 'services/**')], projectRoot, }, ); From 830cd34018e752cd078b3eb9cddbe93a255523b1 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Tue, 15 Oct 2024 08:44:59 +0200 Subject: [PATCH 3/6] refactor: Simplified `target` for findFiles() to help end-developers change the value (app) --- .../app/map-component-classes.ts | 13 ++++----- .../app/map-component-stylesheets.ts | 13 ++++----- .../app/map-component-templates.ts | 13 ++++----- .../app/map-route-adapters.ts | 6 ++-- .../app/map-route-controllers.ts | 6 ++-- .../app/map-route-models.ts | 6 ++-- .../app/map-route-routes.ts | 6 ++-- .../app/map-route-serializers.ts | 6 ++-- .../app/map-route-stylesheets.ts | 6 ++-- .../app/map-route-templates.ts | 6 ++-- .../create-file-path-maps/app/map-services.ts | 6 ++-- .../tests/map-components.ts | 13 ++++----- .../tests/map-route-controllers.ts | 28 +++++++++---------- .../tests/map-route-routes.ts | 28 +++++++++---------- .../tests/map-services.ts | 15 +++++----- 15 files changed, 89 insertions(+), 82 deletions(-) diff --git a/src/migration/app/steps/create-file-path-maps/app/map-component-classes.ts b/src/migration/app/steps/create-file-path-maps/app/map-component-classes.ts index 6874c4e..94cf9db 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-component-classes.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-component-classes.ts @@ -11,16 +11,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapComponentClasses(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles( - join('app', podPath, 'components/**/component.{d.ts,js,ts}'), - { - projectRoot, - }, - ); + const podDir = join('app', podPath, 'components'); + + const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, { + projectRoot, + }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('app', podPath, 'components'), + entityDir: podDir, replace: (key: string) => { return `app/components/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-component-stylesheets.ts b/src/migration/app/steps/create-file-path-maps/app/map-component-stylesheets.ts index 8d414e1..104608c 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-component-stylesheets.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-component-stylesheets.ts @@ -11,16 +11,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapComponentStylesheets(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles( - join('app', podPath, 'components/**/styles.{css,scss}'), - { - projectRoot, - }, - ); + const podDir = join('app', podPath, 'components'); + + const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, { + projectRoot, + }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('app', podPath, 'components'), + entityDir: podDir, replace: (key: string) => { return `app/components/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-component-templates.ts b/src/migration/app/steps/create-file-path-maps/app/map-component-templates.ts index 0ff9150..aad22d0 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-component-templates.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-component-templates.ts @@ -11,16 +11,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapComponentTemplates(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles( - join('app', podPath, 'components/**/template.hbs'), - { - projectRoot, - }, - ); + const podDir = join('app', podPath, 'components'); + + const filePaths = findFiles(`${podDir}/**/template.hbs`, { + projectRoot, + }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('app', podPath, 'components'), + entityDir: podDir, replace: (key: string) => { return `app/components/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-adapters.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-adapters.ts index c210b6f..c3cf8eb 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-adapters.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-adapters.ts @@ -11,13 +11,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteAdapters(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles(join('app', podPath, '**/adapter.{js,ts}'), { + const podDir = join('app', podPath); + + const filePaths = findFiles(`${podDir}/**/adapter.{js,ts}`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('app', podPath), + entityDir: podDir, replace: (key: string) => { return `app/adapters/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-controllers.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-controllers.ts index 06cac4e..5cf1b14 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-controllers.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-controllers.ts @@ -11,13 +11,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteControllers(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles(join('app', podPath, '**/controller.{js,ts}'), { + const podDir = join('app', podPath); + + const filePaths = findFiles(`${podDir}/**/controller.{js,ts}`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('app', podPath), + entityDir: podDir, replace: (key: string) => { return `app/controllers/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-models.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-models.ts index 76956e1..b0fe776 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-models.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-models.ts @@ -11,13 +11,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteModels(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles(join('app', podPath, '**/model.{js,ts}'), { + const podDir = join('app', podPath); + + const filePaths = findFiles(`${podDir}/**/model.{js,ts}`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('app', podPath), + entityDir: podDir, replace: (key: string) => { return `app/models/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-routes.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-routes.ts index 77c798a..83443e7 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-routes.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-routes.ts @@ -11,13 +11,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteRoutes(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles(join('app', podPath, '**/route.{js,ts}'), { + const podDir = join('app', podPath); + + const filePaths = findFiles(`${podDir}/**/route.{js,ts}`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('app', podPath), + entityDir: podDir, replace: (key: string) => { return `app/routes/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-serializers.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-serializers.ts index 1405c17..d128620 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-serializers.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-serializers.ts @@ -11,13 +11,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteSerializers(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles(join('app', podPath, '**/serializer.{js,ts}'), { + const podDir = join('app', podPath); + + const filePaths = findFiles(`${podDir}/**/serializer.{js,ts}`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('app', podPath), + entityDir: podDir, replace: (key: string) => { return `app/serializers/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts index 3af89a6..a226a57 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts @@ -11,14 +11,16 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteStylesheets(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles(join('app', podPath, '**/styles.{css,scss}'), { + const podDir = join('app', podPath); + + const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, { ignoreList: [join('app', podPath, 'components/**')], projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('app', podPath), + entityDir: podDir, replace: (key: string) => { return `app/styles/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts index a4d2124..6b3bef3 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts @@ -11,14 +11,16 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteTemplates(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles(join('app', podPath, '**/template.hbs'), { + const podDir = join('app', podPath); + + const filePaths = findFiles(`${podDir}/**/template.hbs`, { ignoreList: [join('app', podPath, 'components/**')], projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('app', podPath), + entityDir: podDir, replace: (key: string) => { return `app/templates/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-services.ts b/src/migration/app/steps/create-file-path-maps/app/map-services.ts index b801142..63d0986 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-services.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-services.ts @@ -11,13 +11,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapServices(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles(join('app', podPath, '**/service.{js,ts}'), { + const podDir = join('app', podPath); + + const filePaths = findFiles(`${podDir}/**/service.{js,ts}`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('app', podPath), + entityDir: podDir, replace: (key: string) => { return `app/services/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/tests/map-components.ts b/src/migration/app/steps/create-file-path-maps/tests/map-components.ts index 420648e..b1b7487 100644 --- a/src/migration/app/steps/create-file-path-maps/tests/map-components.ts +++ b/src/migration/app/steps/create-file-path-maps/tests/map-components.ts @@ -11,16 +11,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapComponents(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles( - join('tests/integration', podPath, 'components/**/component-test.{js,ts}'), - { - projectRoot, - }, - ); + const podDir = join('tests/integration', podPath, 'components'); + + const filePaths = findFiles(`${podDir}/**/component-test.{js,ts}`, { + projectRoot, + }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('tests/integration', podPath, 'components'), + entityDir: podDir, replace: (key: string) => { return `tests/integration/components/${key}-test`; }, diff --git a/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts b/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts index 9151fbb..c906ad0 100644 --- a/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts +++ b/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts @@ -14,17 +14,16 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { /* Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli */ - const filePaths1 = findFiles( - join('tests/unit', podPath, '**/controller-test.{js,ts}'), - { - ignoreList: [join('tests/unit', podPath, 'controllers/**')], - projectRoot, - }, - ); + const podDir1 = join('tests/unit', podPath); + + const filePaths1 = findFiles(`${podDir1}/**/controller-test.{js,ts}`, { + ignoreList: [join('tests/unit', podPath, 'controllers/**')], + projectRoot, + }); const filePathMap1 = filePaths1.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('tests/unit', podPath), + entityDir: podDir1, replace: (key: string) => { return `tests/unit/controllers/${key}-test`; }, @@ -36,16 +35,15 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { /* Case 2: Passed the --pod flag to Ember CLI */ - const filePaths2 = findFiles( - join('tests/unit', podPath, 'controllers/**/controller-test.{js,ts}'), - { - projectRoot, - }, - ); + const podDir2 = join('tests/unit', podPath, 'controllers'); + + const filePaths2 = findFiles(`${podDir2}/**/controller-test.{js,ts}`, { + projectRoot, + }); const filePathMap2 = filePaths2.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('tests/unit', podPath, 'controllers'), + entityDir: podDir2, replace: (key: string) => { return `tests/unit/controllers/${key}-test`; }, diff --git a/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts b/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts index 6ef3acd..adb5b7d 100644 --- a/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts +++ b/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts @@ -14,17 +14,16 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { /* Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli */ - const filePaths1 = findFiles( - join('tests/unit', podPath, '**/route-test.{js,ts}'), - { - ignoreList: [join('tests/unit', podPath, 'routes/**')], - projectRoot, - }, - ); + const podDir1 = join('tests/unit', podPath); + + const filePaths1 = findFiles(`${podDir1}/**/route-test.{js,ts}`, { + ignoreList: [join('tests/unit', podPath, 'routes/**')], + projectRoot, + }); const filePathMap1 = filePaths1.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('tests/unit', podPath), + entityDir: podDir1, replace: (key: string) => { return `tests/unit/routes/${key}-test`; }, @@ -36,16 +35,15 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { /* Case 2: Passed the --pod flag to Ember CLI */ - const filePaths2 = findFiles( - join('tests/unit', podPath, 'routes/**/route-test.{js,ts}'), - { - projectRoot, - }, - ); + const podDir2 = join('tests/unit', podPath, 'routes'); + + const filePaths2 = findFiles(`${podDir2}/**/route-test.{js,ts}`, { + projectRoot, + }); const filePathMap2 = filePaths2.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('tests/unit', podPath, 'routes'), + entityDir: podDir2, replace: (key: string) => { return `tests/unit/routes/${key}-test`; }, diff --git a/src/migration/app/steps/create-file-path-maps/tests/map-services.ts b/src/migration/app/steps/create-file-path-maps/tests/map-services.ts index d16465e..cc78e33 100644 --- a/src/migration/app/steps/create-file-path-maps/tests/map-services.ts +++ b/src/migration/app/steps/create-file-path-maps/tests/map-services.ts @@ -11,17 +11,16 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapServices(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; - const filePaths = findFiles( - join('tests/unit', podPath, '**/service-test.{js,ts}'), - { - ignoreList: [join('tests/unit', podPath, 'services/**')], - projectRoot, - }, - ); + const podDir = join('tests/unit', podPath); + + const filePaths = findFiles(`${podDir}/**/service-test.{js,ts}`, { + ignoreList: [join('tests/unit', podPath, 'services/**')], + projectRoot, + }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: join('tests/unit', podPath), + entityDir: podDir, replace: (key: string) => { return `tests/unit/services/${key}-test`; }, From 630fc077f178c6aeca894f247791932140f02fdf Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Tue, 15 Oct 2024 08:48:06 +0200 Subject: [PATCH 4/6] refactor: Simplified `target` for findFiles() to help end-developers change the value (v1-addon) --- .../addon/map-component-classes.ts | 6 ++++-- .../addon/map-component-stylesheets.ts | 6 ++++-- .../addon/map-component-templates.ts | 6 ++++-- .../addon/map-route-controllers.ts | 6 ++++-- .../addon/map-route-routes.ts | 6 ++++-- .../addon/map-route-stylesheets.ts | 6 ++++-- .../addon/map-route-templates.ts | 6 ++++-- .../addon/map-services.ts | 6 ++++-- .../app/map-component-classes.ts | 6 ++++-- .../app/map-component-templates.ts | 6 ++++-- .../app/map-route-controllers.ts | 6 ++++-- .../app/map-route-routes.ts | 6 ++++-- .../app/map-route-templates.ts | 6 ++++-- .../create-file-path-maps/app/map-services.ts | 6 ++++-- .../tests/map-components.ts | 13 ++++++------- .../tests/map-route-controllers.ts | 19 ++++++++++--------- .../tests/map-route-routes.ts | 12 ++++++++---- .../tests/map-services.ts | 6 ++++-- 18 files changed, 84 insertions(+), 50 deletions(-) diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-classes.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-classes.ts index d976c3c..0ea1ac5 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-classes.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-classes.ts @@ -9,13 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapComponentClasses(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('addon/components/**/component.{d.ts,js,ts}', { + const podDir = 'addon/components'; + + const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'addon/components', + entityDir: podDir, replace: (key: string) => { return `addon/components/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-stylesheets.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-stylesheets.ts index 877682a..9c704ae 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-stylesheets.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-stylesheets.ts @@ -9,13 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapComponentStylesheets(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('addon/components/**/styles.{css,scss}', { + const podDir = 'addon/components'; + + const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'addon/components', + entityDir: podDir, replace: (key: string) => { return `addon/components/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-templates.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-templates.ts index 956a535..ef222c2 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-templates.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-templates.ts @@ -9,13 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapComponentTemplates(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('addon/components/**/template.hbs', { + const podDir = 'addon/components'; + + const filePaths = findFiles(`${podDir}/**/template.hbs`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'addon/components', + entityDir: podDir, replace: (key: string) => { return `addon/components/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-controllers.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-controllers.ts index 96b4704..b05a791 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-controllers.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-controllers.ts @@ -9,13 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteControllers(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('addon/**/controller.{js,ts}', { + const podDir = 'addon'; + + const filePaths = findFiles(`${podDir}/**/controller.{js,ts}`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'addon', + entityDir: podDir, replace: (key: string) => { return `addon/controllers/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-routes.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-routes.ts index 3009a9f..00834f5 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-routes.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-routes.ts @@ -9,13 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteRoutes(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('addon/**/route.{js,ts}', { + const podDir = 'addon'; + + const filePaths = findFiles(`${podDir}/**/route.{js,ts}`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'addon', + entityDir: podDir, replace: (key: string) => { return `addon/routes/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-stylesheets.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-stylesheets.ts index 91876b5..47ebcf4 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-stylesheets.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-stylesheets.ts @@ -9,14 +9,16 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteStylesheets(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('addon/**/styles.{css,scss}', { + const podDir = 'addon'; + + const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, { ignoreList: ['addon/components/**'], projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'addon', + entityDir: podDir, replace: (key: string) => { return `addon/styles/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-templates.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-templates.ts index 6bf26c2..d8fb76b 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-templates.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-templates.ts @@ -9,14 +9,16 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteTemplates(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('addon/**/template.hbs', { + const podDir = 'addon'; + + const filePaths = findFiles(`${podDir}/**/template.hbs`, { ignoreList: ['addon/components/**'], projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'addon', + entityDir: podDir, replace: (key: string) => { return `addon/templates/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-services.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-services.ts index e225ad9..8191b32 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-services.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-services.ts @@ -9,13 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapServices(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('addon/**/service.{js,ts}', { + const podDir = 'addon'; + + const filePaths = findFiles(`${podDir}/**/service.{js,ts}`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'addon', + entityDir: podDir, replace: (key: string) => { return `addon/services/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-classes.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-classes.ts index 4c49e7e..2a9cbf7 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-classes.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-classes.ts @@ -9,13 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapComponentClasses(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('app/components/**/component.js', { + const podDir = 'app/components'; + + const filePaths = findFiles(`${podDir}/**/component.js`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'app/components', + entityDir: podDir, replace: (key: string) => { return `app/components/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-templates.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-templates.ts index e02e024..7792dd5 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-templates.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-templates.ts @@ -9,13 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapComponentTemplates(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('app/components/**/template.js', { + const podDir = 'app/components'; + + const filePaths = findFiles(`${podDir}/**/template.js`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'app/components', + entityDir: podDir, replace: (key: string) => { return `app/components/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-controllers.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-controllers.ts index a84d4bd..44ccfbe 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-controllers.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-controllers.ts @@ -9,13 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteControllers(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('app/**/controller.js', { + const podDir = 'app'; + + const filePaths = findFiles(`${podDir}/**/controller.js`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'app', + entityDir: podDir, replace: (key: string) => { return `app/controllers/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-routes.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-routes.ts index f0f1f14..5685a03 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-routes.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-routes.ts @@ -9,13 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteRoutes(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('app/**/route.js', { + const podDir = 'app'; + + const filePaths = findFiles(`${podDir}/**/route.js`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'app', + entityDir: podDir, replace: (key: string) => { return `app/routes/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-templates.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-templates.ts index 6f25706..37a065d 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-templates.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-templates.ts @@ -9,14 +9,16 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapRouteTemplates(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('app/**/template.js', { + const podDir = 'app'; + + const filePaths = findFiles(`${podDir}/**/template.js`, { ignoreList: ['app/components/**'], projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'app', + entityDir: podDir, replace: (key: string) => { return `app/templates/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-services.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-services.ts index 48de26e..e7690c3 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-services.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-services.ts @@ -9,13 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapServices(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('app/**/service.js', { + const podDir = 'app'; + + const filePaths = findFiles(`${podDir}/**/service.js`, { projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'app', + entityDir: podDir, replace: (key: string) => { return `app/services/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-components.ts b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-components.ts index 95f2658..cd94631 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-components.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-components.ts @@ -9,16 +9,15 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapComponents(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles( - 'tests/integration/components/**/component-test.{js,ts}', - { - projectRoot, - }, - ); + const podDir = 'tests/integration/components'; + + const filePaths = findFiles(`${podDir}/**/component-test.{js,ts}`, { + projectRoot, + }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'tests/integration/components', + entityDir: podDir, replace: (key: string) => { return `tests/integration/components/${key}-test`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-controllers.ts b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-controllers.ts index 8614c37..4cfdae2 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-controllers.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-controllers.ts @@ -12,14 +12,16 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { /* Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli */ - const filePaths1 = findFiles('tests/unit/**/controller-test.{js,ts}', { + const podDir1 = 'tests/unit'; + + const filePaths1 = findFiles(`${podDir1}/**/controller-test.{js,ts}`, { ignoreList: ['tests/unit/controllers/**'], projectRoot, }); const filePathMap1 = filePaths1.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'tests/unit', + entityDir: podDir1, replace: (key: string) => { return `tests/unit/controllers/${key}-test`; }, @@ -31,16 +33,15 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { /* Case 2: Passed the --pod flag to Ember CLI */ - const filePaths2 = findFiles( - 'tests/unit/controllers/**/controller-test.{js,ts}', - { - projectRoot, - }, - ); + const podDir2 = 'tests/unit/controllers'; + + const filePaths2 = findFiles(`${podDir2}/**/controller-test.{js,ts}`, { + projectRoot, + }); const filePathMap2 = filePaths2.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'tests/unit/controllers', + entityDir: podDir2, replace: (key: string) => { return `tests/unit/controllers/${key}-test`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-routes.ts b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-routes.ts index b936fb3..98a7a25 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-routes.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-routes.ts @@ -12,14 +12,16 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { /* Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli */ - const filePaths1 = findFiles('tests/unit/**/route-test.{js,ts}', { + const podDir1 = 'tests/unit'; + + const filePaths1 = findFiles(`${podDir1}/**/route-test.{js,ts}`, { ignoreList: ['tests/unit/routes/**'], projectRoot, }); const filePathMap1 = filePaths1.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'tests/unit', + entityDir: podDir1, replace: (key: string) => { return `tests/unit/routes/${key}-test`; }, @@ -31,13 +33,15 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { /* Case 2: Passed the --pod flag to Ember CLI */ - const filePaths2 = findFiles('tests/unit/routes/**/route-test.{js,ts}', { + const podDir2 = 'tests/unit/routes'; + + const filePaths2 = findFiles(`${podDir2}/**/route-test.{js,ts}`, { projectRoot, }); const filePathMap2 = filePaths2.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'tests/unit/routes', + entityDir: podDir2, replace: (key: string) => { return `tests/unit/routes/${key}-test`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-services.ts b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-services.ts index b5f8582..5b9d9fe 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-services.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-services.ts @@ -9,14 +9,16 @@ import { renamePodPath } from '../../../../../utils/files/index.js'; export function mapServices(options: Options): FilePathMapEntries { const { projectRoot } = options; - const filePaths = findFiles('tests/unit/**/service-test.{js,ts}', { + const podDir = 'tests/unit'; + + const filePaths = findFiles(`${podDir}/**/service-test.{js,ts}`, { ignoreList: ['tests/unit/services/**'], projectRoot, }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'tests/unit', + entityDir: podDir, replace: (key: string) => { return `tests/unit/services/${key}-test`; }, From 4c76c971b2f9093d22607ee60505fd9612663b40 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Tue, 15 Oct 2024 09:21:36 +0200 Subject: [PATCH 5/6] refactor: Renamed entityDir to podDir --- .../create-file-path-maps/app/map-component-classes.ts | 2 +- .../app/map-component-stylesheets.ts | 2 +- .../app/map-component-templates.ts | 2 +- .../create-file-path-maps/app/map-route-adapters.ts | 2 +- .../create-file-path-maps/app/map-route-controllers.ts | 2 +- .../create-file-path-maps/app/map-route-models.ts | 2 +- .../create-file-path-maps/app/map-route-routes.ts | 2 +- .../create-file-path-maps/app/map-route-serializers.ts | 2 +- .../create-file-path-maps/app/map-route-stylesheets.ts | 2 +- .../create-file-path-maps/app/map-route-templates.ts | 2 +- .../steps/create-file-path-maps/app/map-services.ts | 2 +- .../create-file-path-maps/tests/map-components.ts | 2 +- .../tests/map-route-controllers.ts | 4 ++-- .../create-file-path-maps/tests/map-route-routes.ts | 4 ++-- .../steps/create-file-path-maps/tests/map-services.ts | 2 +- .../addon/map-component-classes.ts | 2 +- .../addon/map-component-stylesheets.ts | 2 +- .../addon/map-component-templates.ts | 2 +- .../addon/map-route-controllers.ts | 2 +- .../create-file-path-maps/addon/map-route-routes.ts | 2 +- .../addon/map-route-stylesheets.ts | 2 +- .../create-file-path-maps/addon/map-route-templates.ts | 2 +- .../steps/create-file-path-maps/addon/map-services.ts | 2 +- .../create-file-path-maps/app/map-component-classes.ts | 2 +- .../app/map-component-templates.ts | 2 +- .../create-file-path-maps/app/map-route-controllers.ts | 2 +- .../create-file-path-maps/app/map-route-routes.ts | 2 +- .../create-file-path-maps/app/map-route-templates.ts | 2 +- .../steps/create-file-path-maps/app/map-services.ts | 2 +- .../create-file-path-maps/tests/map-components.ts | 2 +- .../tests/map-route-controllers.ts | 4 ++-- .../create-file-path-maps/tests/map-route-routes.ts | 4 ++-- .../steps/create-file-path-maps/tests/map-services.ts | 2 +- src/utils/files/rename-pod-path.ts | 10 +++++----- tests/utils/files/rename-pod-path/base-case.test.ts | 2 +- .../edge-case-replace-suffixes-file-name.test.ts | 2 +- .../error-handling-directory-does-not-match.test.ts | 2 +- 37 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/migration/app/steps/create-file-path-maps/app/map-component-classes.ts b/src/migration/app/steps/create-file-path-maps/app/map-component-classes.ts index 94cf9db..6b9c5b2 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-component-classes.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-component-classes.ts @@ -19,7 +19,7 @@ export function mapComponentClasses(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/components/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-component-stylesheets.ts b/src/migration/app/steps/create-file-path-maps/app/map-component-stylesheets.ts index 104608c..222844c 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-component-stylesheets.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-component-stylesheets.ts @@ -19,7 +19,7 @@ export function mapComponentStylesheets(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/components/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-component-templates.ts b/src/migration/app/steps/create-file-path-maps/app/map-component-templates.ts index aad22d0..68ab0ce 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-component-templates.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-component-templates.ts @@ -19,7 +19,7 @@ export function mapComponentTemplates(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/components/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-adapters.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-adapters.ts index c3cf8eb..015ff7a 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-adapters.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-adapters.ts @@ -19,7 +19,7 @@ export function mapRouteAdapters(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/adapters/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-controllers.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-controllers.ts index 5cf1b14..18e4ed6 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-controllers.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-controllers.ts @@ -19,7 +19,7 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/controllers/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-models.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-models.ts index b0fe776..371d49c 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-models.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-models.ts @@ -19,7 +19,7 @@ export function mapRouteModels(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/models/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-routes.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-routes.ts index 83443e7..d1d9a9b 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-routes.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-routes.ts @@ -19,7 +19,7 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/routes/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-serializers.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-serializers.ts index d128620..73b0eb8 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-serializers.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-serializers.ts @@ -19,7 +19,7 @@ export function mapRouteSerializers(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/serializers/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts index a226a57..15bee39 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-stylesheets.ts @@ -20,7 +20,7 @@ export function mapRouteStylesheets(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/styles/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts b/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts index 6b3bef3..7fcba21 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-route-templates.ts @@ -20,7 +20,7 @@ export function mapRouteTemplates(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/templates/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/app/map-services.ts b/src/migration/app/steps/create-file-path-maps/app/map-services.ts index 63d0986..640d356 100644 --- a/src/migration/app/steps/create-file-path-maps/app/map-services.ts +++ b/src/migration/app/steps/create-file-path-maps/app/map-services.ts @@ -19,7 +19,7 @@ export function mapServices(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/services/${key}`; }, diff --git a/src/migration/app/steps/create-file-path-maps/tests/map-components.ts b/src/migration/app/steps/create-file-path-maps/tests/map-components.ts index b1b7487..2c44cad 100644 --- a/src/migration/app/steps/create-file-path-maps/tests/map-components.ts +++ b/src/migration/app/steps/create-file-path-maps/tests/map-components.ts @@ -19,7 +19,7 @@ export function mapComponents(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `tests/integration/components/${key}-test`; }, diff --git a/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts b/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts index c906ad0..53a6b92 100644 --- a/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts +++ b/src/migration/app/steps/create-file-path-maps/tests/map-route-controllers.ts @@ -23,7 +23,7 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { const filePathMap1 = filePaths1.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir1, + podDir: podDir1, replace: (key: string) => { return `tests/unit/controllers/${key}-test`; }, @@ -43,7 +43,7 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { const filePathMap2 = filePaths2.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir2, + podDir: podDir2, replace: (key: string) => { return `tests/unit/controllers/${key}-test`; }, diff --git a/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts b/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts index adb5b7d..c2b34f3 100644 --- a/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts +++ b/src/migration/app/steps/create-file-path-maps/tests/map-route-routes.ts @@ -23,7 +23,7 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { const filePathMap1 = filePaths1.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir1, + podDir: podDir1, replace: (key: string) => { return `tests/unit/routes/${key}-test`; }, @@ -43,7 +43,7 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { const filePathMap2 = filePaths2.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir2, + podDir: podDir2, replace: (key: string) => { return `tests/unit/routes/${key}-test`; }, diff --git a/src/migration/app/steps/create-file-path-maps/tests/map-services.ts b/src/migration/app/steps/create-file-path-maps/tests/map-services.ts index cc78e33..d42bfc0 100644 --- a/src/migration/app/steps/create-file-path-maps/tests/map-services.ts +++ b/src/migration/app/steps/create-file-path-maps/tests/map-services.ts @@ -20,7 +20,7 @@ export function mapServices(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `tests/unit/services/${key}-test`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-classes.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-classes.ts index 0ea1ac5..b03c699 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-classes.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-classes.ts @@ -17,7 +17,7 @@ export function mapComponentClasses(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `addon/components/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-stylesheets.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-stylesheets.ts index 9c704ae..60415b3 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-stylesheets.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-stylesheets.ts @@ -17,7 +17,7 @@ export function mapComponentStylesheets(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `addon/components/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-templates.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-templates.ts index ef222c2..2376530 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-templates.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-component-templates.ts @@ -17,7 +17,7 @@ export function mapComponentTemplates(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `addon/components/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-controllers.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-controllers.ts index b05a791..9e96d2c 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-controllers.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-controllers.ts @@ -17,7 +17,7 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `addon/controllers/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-routes.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-routes.ts index 00834f5..7f9c59b 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-routes.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-routes.ts @@ -17,7 +17,7 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `addon/routes/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-stylesheets.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-stylesheets.ts index 47ebcf4..7598c58 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-stylesheets.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-stylesheets.ts @@ -18,7 +18,7 @@ export function mapRouteStylesheets(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `addon/styles/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-templates.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-templates.ts index d8fb76b..e3fe96f 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-templates.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-route-templates.ts @@ -18,7 +18,7 @@ export function mapRouteTemplates(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `addon/templates/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-services.ts b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-services.ts index 8191b32..2c0db25 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/addon/map-services.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/addon/map-services.ts @@ -17,7 +17,7 @@ export function mapServices(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `addon/services/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-classes.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-classes.ts index 2a9cbf7..a78655f 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-classes.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-classes.ts @@ -17,7 +17,7 @@ export function mapComponentClasses(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/components/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-templates.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-templates.ts index 7792dd5..ade18a8 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-templates.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-component-templates.ts @@ -17,7 +17,7 @@ export function mapComponentTemplates(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/components/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-controllers.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-controllers.ts index 44ccfbe..daf5c7f 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-controllers.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-controllers.ts @@ -17,7 +17,7 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/controllers/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-routes.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-routes.ts index 5685a03..f8fa2f4 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-routes.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-routes.ts @@ -17,7 +17,7 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/routes/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-templates.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-templates.ts index 37a065d..a0f5529 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-templates.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-templates.ts @@ -18,7 +18,7 @@ export function mapRouteTemplates(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/templates/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/app/map-services.ts b/src/migration/v1-addon/steps/create-file-path-maps/app/map-services.ts index e7690c3..08406b9 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/app/map-services.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/app/map-services.ts @@ -17,7 +17,7 @@ export function mapServices(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `app/services/${key}`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-components.ts b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-components.ts index cd94631..e7b0df8 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-components.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-components.ts @@ -17,7 +17,7 @@ export function mapComponents(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `tests/integration/components/${key}-test`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-controllers.ts b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-controllers.ts index 4cfdae2..362abf4 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-controllers.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-controllers.ts @@ -21,7 +21,7 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { const filePathMap1 = filePaths1.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir1, + podDir: podDir1, replace: (key: string) => { return `tests/unit/controllers/${key}-test`; }, @@ -41,7 +41,7 @@ export function mapRouteControllers(options: Options): FilePathMapEntries { const filePathMap2 = filePaths2.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir2, + podDir: podDir2, replace: (key: string) => { return `tests/unit/controllers/${key}-test`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-routes.ts b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-routes.ts index 98a7a25..088d470 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-routes.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-route-routes.ts @@ -21,7 +21,7 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { const filePathMap1 = filePaths1.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir1, + podDir: podDir1, replace: (key: string) => { return `tests/unit/routes/${key}-test`; }, @@ -41,7 +41,7 @@ export function mapRouteRoutes(options: Options): FilePathMapEntries { const filePathMap2 = filePaths2.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir2, + podDir: podDir2, replace: (key: string) => { return `tests/unit/routes/${key}-test`; }, diff --git a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-services.ts b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-services.ts index 5b9d9fe..034a4bc 100644 --- a/src/migration/v1-addon/steps/create-file-path-maps/tests/map-services.ts +++ b/src/migration/v1-addon/steps/create-file-path-maps/tests/map-services.ts @@ -18,7 +18,7 @@ export function mapServices(options: Options): FilePathMapEntries { return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { - entityDir: podDir, + podDir, replace: (key: string) => { return `tests/unit/services/${key}-test`; }, diff --git a/src/utils/files/rename-pod-path.ts b/src/utils/files/rename-pod-path.ts index aef07fd..d602aa0 100644 --- a/src/utils/files/rename-pod-path.ts +++ b/src/utils/files/rename-pod-path.ts @@ -3,21 +3,21 @@ import { parseFilePath } from '@codemod-utils/files'; export function renamePodPath( filePath: string, options: { - entityDir: string; + podDir: string; replace: (key: string) => string; }, ): string { const { dir, ext, name } = parseFilePath(filePath); - const { entityDir, replace } = options; + const { podDir, replace } = options; - if (!dir.startsWith(entityDir)) { + if (!dir.startsWith(podDir)) { throw new RangeError( - `ERROR: The provided path \`${filePath}\` doesn't match the directory pattern \`${entityDir}\`.\n`, + `ERROR: The provided path \`${filePath}\` doesn't match the directory pattern \`${podDir}\`.\n`, ); } const key = filePath - .replace(new RegExp(`^${entityDir}/`), '') + .replace(new RegExp(`^${podDir}/`), '') .replace(new RegExp(`/${name}${ext}$`), ''); return `${replace(key)}${ext}`; diff --git a/tests/utils/files/rename-pod-path/base-case.test.ts b/tests/utils/files/rename-pod-path/base-case.test.ts index 91550bb..e63ee00 100644 --- a/tests/utils/files/rename-pod-path/base-case.test.ts +++ b/tests/utils/files/rename-pod-path/base-case.test.ts @@ -6,7 +6,7 @@ test('utils | files | rename-pod-path > base case', function () { const oldFilePath = 'app/pods/components/navigation-menu/component.d.ts'; const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'app/pods/components', + podDir: 'app/pods/components', replace: (key) => { return `app/components/${key}`; }, diff --git a/tests/utils/files/rename-pod-path/edge-case-replace-suffixes-file-name.test.ts b/tests/utils/files/rename-pod-path/edge-case-replace-suffixes-file-name.test.ts index 78e7a03..03f3957 100644 --- a/tests/utils/files/rename-pod-path/edge-case-replace-suffixes-file-name.test.ts +++ b/tests/utils/files/rename-pod-path/edge-case-replace-suffixes-file-name.test.ts @@ -6,7 +6,7 @@ test('utils | files | rename-pod-path > edge case (replace suffixes file name)', const oldFilePath = 'tests/unit/pods/index/controller-test.ts'; const newFilePath = renamePodPath(oldFilePath, { - entityDir: 'tests/unit/pods', + podDir: 'tests/unit/pods', replace: (key) => { return `tests/unit/controllers/${key}-test`; }, diff --git a/tests/utils/files/rename-pod-path/error-handling-directory-does-not-match.test.ts b/tests/utils/files/rename-pod-path/error-handling-directory-does-not-match.test.ts index 7517ade..53bdcb8 100644 --- a/tests/utils/files/rename-pod-path/error-handling-directory-does-not-match.test.ts +++ b/tests/utils/files/rename-pod-path/error-handling-directory-does-not-match.test.ts @@ -8,7 +8,7 @@ test('utils | files | rename-pod-path > error handling (directory does not match assert.throws( () => { renamePodPath(oldFilePath, { - entityDir: 'addon/components', + podDir: 'addon/components', replace: (key) => { return `addon/components/${key}`; }, From 05fefebf97f5456a2d36a7fd7f2aa21e4267ef98 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Tue, 15 Oct 2024 09:38:12 +0200 Subject: [PATCH 6/6] Documented how to migrate the project one component or one route at a time --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 6b674dd..1e8dd30 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,25 @@ pnpm build ./dist/bin/ember-codemod-pod-to-octane.js --root ``` +> [!TIP] +> +> You might clone the repo to migrate the project one component or one route at a time. For example, to migrate only the `` component (and its subcomponents, if they exist), update the related file(s) in the `src` folder like this: +> +> ```diff +> export function mapComponentClasses(options: Options): FilePathMapEntries { +> const { podPath, projectRoot } = options; +> +> const podDir = join('app', podPath, 'components'); +> +> - const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, { +> + const filePaths = findFiles(`${podDir}/navigation-menu/**/component.{d.ts,js,ts}`, { +> +> // ... +> } +> ``` +> +> That is, look for `findFiles(`, then insert the component or route name between `podDir` and `**`. + ## Compatibility