From 114d3c3dce22c4cbafe682a7642ffd9f8a8fdae8 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Fri, 11 Oct 2024 20:04:52 +0200 Subject: [PATCH] refactor: Removed unnecessary joins --- .../create-file-path-maps/app/map-component-classes.ts | 2 +- .../app/map-component-stylesheets.ts | 2 +- .../create-file-path-maps/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 | 9 +++------ .../steps/create-file-path-maps/app/map-route-models.ts | 2 +- .../steps/create-file-path-maps/app/map-route-routes.ts | 2 +- .../create-file-path-maps/app/map-route-serializers.ts | 9 +++------ .../create-file-path-maps/app/map-route-stylesheets.ts | 2 +- .../create-file-path-maps/app/map-route-templates.ts | 2 +- .../app/steps/create-file-path-maps/app/map-services.ts | 2 +- .../steps/create-file-path-maps/tests/map-components.ts | 8 +------- .../create-file-path-maps/tests/map-route-controllers.ts | 8 +------- .../create-file-path-maps/tests/map-route-routes.ts | 2 +- .../steps/create-file-path-maps/tests/map-services.ts | 2 +- .../steps/create-file-path-maps/tests/map-services.ts | 4 +--- 16 files changed, 20 insertions(+), 40 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 febf752..6874c4e 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 @@ -12,7 +12,7 @@ export function mapComponentClasses(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; const filePaths = findFiles( - join('app', podPath, 'components', '**', 'component.{d.ts,js,ts}'), + join('app', podPath, 'components/**/component.{d.ts,js,ts}'), { projectRoot, }, 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 c9f86d9..8d414e1 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 @@ -12,7 +12,7 @@ export function mapComponentStylesheets(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; const filePaths = findFiles( - join('app', podPath, 'components', '**', 'styles.{css,scss}'), + join('app', podPath, 'components/**/styles.{css,scss}'), { projectRoot, }, 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 f4d2df4..0ff9150 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 @@ -12,7 +12,7 @@ export function mapComponentTemplates(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; const filePaths = findFiles( - join('app', podPath, 'components', '**', 'template.hbs'), + join('app', podPath, 'components/**/template.hbs'), { projectRoot, }, 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 8bed120..c210b6f 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,7 +11,7 @@ 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 filePaths = findFiles(join('app', podPath, '**/adapter.{js,ts}'), { projectRoot, }); 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 f8f86d4..06cac4e 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,12 +11,9 @@ 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}'), - { - projectRoot, - }, - ); + const filePaths = findFiles(join('app', podPath, '**/controller.{js,ts}'), { + projectRoot, + }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { 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 86d9273..76956e1 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,7 +11,7 @@ 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 filePaths = findFiles(join('app', podPath, '**/model.{js,ts}'), { projectRoot, }); 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 34baa5e..77c798a 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,7 +11,7 @@ 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 filePaths = findFiles(join('app', podPath, '**/route.{js,ts}'), { projectRoot, }); 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 3024cc0..1405c17 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,12 +11,9 @@ 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}'), - { - projectRoot, - }, - ); + const filePaths = findFiles(join('app', podPath, '**/serializer.{js,ts}'), { + projectRoot, + }); return filePaths.map((oldFilePath) => { const newFilePath = renamePodPath(oldFilePath, { 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 61273bd..a6e66e8 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, '!(components)', '**', 'styles.{css,scss}'), + join('app', podPath, '!(components)/**/styles.{css,scss}'), { 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 96f4843..267d8bd 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, '!(components)', '**', 'template.hbs'), + join('app', podPath, '!(components)/**/template.hbs'), { projectRoot, }, 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 554c6ca..b801142 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,7 +11,7 @@ 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 filePaths = findFiles(join('app', podPath, '**/service.{js,ts}'), { projectRoot, }); 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 d6e8bcf..420648e 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 @@ -12,13 +12,7 @@ export function mapComponents(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; const filePaths = findFiles( - join( - 'tests/integration', - podPath, - 'components', - '**', - 'component-test.{js,ts}', - ), + join('tests/integration', podPath, 'components/**/component-test.{js,ts}'), { 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 ccf8b9b..0dac7a7 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 @@ -15,13 +15,7 @@ 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, - '!(controllers)', - '**', - 'controller-test.{js,ts}', - ), + join('tests/unit', podPath, '!(controllers)/**/controller-test.{js,ts}'), { 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 acf795e..f7fbdf6 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 @@ -15,7 +15,7 @@ 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, '!(routes)', '**', 'route-test.{js,ts}'), + join('tests/unit', podPath, '!(routes)/**/route-test.{js,ts}'), { 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 eb42cd2..edb8257 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 @@ -12,7 +12,7 @@ export function mapServices(options: Options): FilePathMapEntries { const { podPath, projectRoot } = options; const filePaths = findFiles( - join('tests/unit', podPath, '!(services)', '**', 'service-test.{js,ts}'), + join('tests/unit', podPath, '!(services)/**/service-test.{js,ts}'), { projectRoot, }, 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 75af438..2212d0d 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 @@ -1,5 +1,3 @@ -import { join } from 'node:path'; - import { findFiles } from '@codemod-utils/files'; import type { @@ -12,7 +10,7 @@ export function mapServices(options: Options): FilePathMapEntries { const { projectRoot } = options; const filePaths = findFiles( - join('tests/unit/!(services)/**/service-test.{js,ts}'), + 'tests/unit/!(services)/**/service-test.{js,ts}', { projectRoot, },