ember-codemod-pod-to-octane 5.0.5 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -144,13 +144,13 @@ pnpm build
144
144
  > You might clone the repo to migrate the project one component or one route at a time. For example, to migrate only the `<NavigationMenu>` component (and its subcomponents, if they exist), update the related file(s) in the `src` folder like this:
145
145
  >
146
146
  > ```diff
147
- > export function mapComponentClasses(options: Options): FilePathMapEntries {
147
+ > export function mapComponents1(options: Options): FilePathMapEntries {
148
148
  > const { podPath, projectRoot } = options;
149
149
  >
150
150
  > const podDir = normalizedJoin('app', podPath, 'components');
151
151
  >
152
- > - const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
153
- > + const filePaths = findFiles(`${podDir}/navigation-menu/**/component.{d.ts,js,ts}`, {
152
+ > - const filePathsForClass = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
153
+ > + const filePathsForClass = findFiles(`${podDir}/navigation-menu/**/component.{d.ts,js,ts}`, {
154
154
  >
155
155
  > // ...
156
156
  > }
@@ -1,10 +1,19 @@
1
- import { mapComponents } from './map-components.js';
1
+ import { sep } from 'node:path';
2
+ import { mapComponents1 } from './map-components-1.js';
3
+ import { mapComponents2 } from './map-components-2.js';
2
4
  import { mapRoutes } from './map-routes.js';
3
5
  import { mapServices } from './map-services.js';
4
6
  export function mapAppFolder(options) {
7
+ const mapEntriesForComponents = [
8
+ ...mapComponents1(options),
9
+ ...mapComponents2(options),
10
+ ];
11
+ const filePathsForComponents = mapEntriesForComponents.map(([oldFilePath]) => {
12
+ return oldFilePath.replaceAll(sep, '/');
13
+ });
5
14
  return new Map([
6
- ...mapComponents(options),
7
- ...mapRoutes(options),
15
+ ...mapEntriesForComponents,
16
+ ...mapRoutes(filePathsForComponents, options),
8
17
  ...mapServices(options),
9
18
  ]);
10
19
  }
@@ -1,6 +1,9 @@
1
1
  import { findFiles } from '@codemod-utils/files';
2
2
  import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
3
- export function mapComponents(options) {
3
+ /*
4
+ Case 1: Placed component files in /components
5
+ */
6
+ export function mapComponents1(options) {
4
7
  const { podPath, projectRoot } = options;
5
8
  const podDir = normalizedJoin('app', podPath, 'components');
6
9
  const filePathsForClass = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
@@ -0,0 +1,45 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { findFiles, parseFilePath } from '@codemod-utils/files';
4
+ import { normalizedJoin, renamePodPath, } from '../../../../../utils/files/index.js';
5
+ /*
6
+ Case 2: Placed component files outside of /components
7
+ */
8
+ export function mapComponents2(options) {
9
+ const { podPath, projectRoot } = options;
10
+ const podDir = normalizedJoin('app', podPath);
11
+ const filePathsForClass = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
12
+ ignoreList: [normalizedJoin('app', podPath, 'components/**')],
13
+ projectRoot,
14
+ });
15
+ const filePathsForStylesheet = [];
16
+ const filePathsForTemplate = [];
17
+ filePathsForClass.forEach((filePath) => {
18
+ const { dir } = parseFilePath(filePath);
19
+ let filePathForStylesheet = join(dir, 'styles.css');
20
+ if (existsSync(join(projectRoot, filePathForStylesheet))) {
21
+ filePathsForStylesheet.push(filePathForStylesheet);
22
+ }
23
+ filePathForStylesheet = join(dir, 'styles.scss');
24
+ if (existsSync(join(projectRoot, filePathForStylesheet))) {
25
+ filePathsForStylesheet.push(filePathForStylesheet);
26
+ }
27
+ const filePathForTemplate = join(dir, 'template.hbs');
28
+ if (existsSync(join(projectRoot, filePathForTemplate))) {
29
+ filePathsForTemplate.push(filePathForTemplate);
30
+ }
31
+ });
32
+ return [
33
+ ...filePathsForClass,
34
+ ...filePathsForStylesheet,
35
+ ...filePathsForTemplate,
36
+ ].map((oldFilePath) => {
37
+ const newFilePath = renamePodPath(oldFilePath, {
38
+ podDir,
39
+ replace: (dir) => {
40
+ return `app/components/${dir}`;
41
+ },
42
+ });
43
+ return [oldFilePath, newFilePath];
44
+ });
45
+ }
@@ -4,7 +4,7 @@ function getFileName(filePath) {
4
4
  const { name } = parseFilePath(filePath);
5
5
  return name;
6
6
  }
7
- export function mapRoutes(options) {
7
+ export function mapRoutes(filePathsForComponents, options) {
8
8
  const { podPath, projectRoot } = options;
9
9
  const podDir = normalizedJoin('app', podPath);
10
10
  const filePathsForAdapter = findFiles(`${podDir}/**/adapter.{js,ts}`, {
@@ -23,11 +23,11 @@ export function mapRoutes(options) {
23
23
  projectRoot,
24
24
  });
25
25
  const filePathsForStylesheet = findFiles(`${podDir}/**/styles.{css,scss}`, {
26
- ignoreList: [normalizedJoin('app', podPath, 'components/**')],
26
+ ignoreList: filePathsForComponents,
27
27
  projectRoot,
28
28
  });
29
29
  const filePathsForTemplate = findFiles(`${podDir}/**/template.hbs`, {
30
- ignoreList: [normalizedJoin('app', podPath, 'components/**')],
30
+ ignoreList: filePathsForComponents,
31
31
  projectRoot,
32
32
  });
33
33
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-codemod-pod-to-octane",
3
- "version": "5.0.5",
3
+ "version": "5.1.1",
4
4
  "description": "Codemod to un-pod Ember apps, addons, and engines",
5
5
  "keywords": [
6
6
  "codemod",
@@ -21,24 +21,24 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "@codemod-utils/files": "^4.0.1",
24
+ "@codemod-utils/files": "^4.1.0",
25
25
  "yargs": "^18.0.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@changesets/cli": "^2.31.0",
29
- "@codemod-utils/tests": "^3.0.2",
29
+ "@codemod-utils/tests": "^3.1.0",
30
30
  "@ijlee2-frontend-configs/changesets": "^2.1.1",
31
- "@ijlee2-frontend-configs/eslint-config-node": "^3.4.4",
32
- "@ijlee2-frontend-configs/prettier": "^3.2.0",
31
+ "@ijlee2-frontend-configs/eslint-config-node": "^4.1.0",
32
+ "@ijlee2-frontend-configs/prettier": "^3.3.0",
33
33
  "@sondr3/minitest": "^0.1.2",
34
34
  "@tsconfig/node22": "^22.0.5",
35
35
  "@tsconfig/strictest": "^2.0.8",
36
36
  "@types/node": "^22.20.0",
37
37
  "@types/yargs": "^17.0.35",
38
38
  "concurrently": "^10.0.3",
39
- "eslint": "^9.39.4",
40
- "prettier": "^3.8.4",
41
- "typescript": "^5.9.3"
39
+ "eslint": "^10.6.0",
40
+ "prettier": "^3.9.4",
41
+ "typescript": "^6.0.3"
42
42
  },
43
43
  "engines": {
44
44
  "node": "22.* || >= 24"