ember-codemod-pod-to-octane 1.2.7 → 1.2.9

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 (60) hide show
  1. package/README.md +8 -8
  2. package/dist/src/index.js +0 -3
  3. package/dist/src/migration/ember-addon/index.js +7 -17
  4. package/dist/src/migration/ember-addon/steps/create-file-path-maps/addon/index.js +10 -0
  5. package/dist/src/migration/ember-addon/{addon/component-classes.js → steps/create-file-path-maps/addon/map-component-classes.js} +1 -1
  6. package/dist/src/migration/{ember-engine/addon/component-stylesheets.js → ember-addon/steps/create-file-path-maps/addon/map-component-stylesheets.js} +1 -1
  7. package/dist/src/migration/ember-addon/{addon/component-templates.js → steps/create-file-path-maps/addon/map-component-templates.js} +1 -1
  8. package/dist/src/migration/ember-addon/steps/create-file-path-maps/app/index.js +10 -0
  9. package/dist/src/migration/ember-addon/{app/component-classes.js → steps/create-file-path-maps/app/map-component-classes.js} +1 -1
  10. package/dist/src/migration/ember-addon/{app/component-stylesheets.js → steps/create-file-path-maps/app/map-component-stylesheets.js} +1 -1
  11. package/dist/src/migration/ember-addon/{app/component-templates.js → steps/create-file-path-maps/app/map-component-templates.js} +1 -1
  12. package/dist/src/migration/ember-addon/steps/create-file-path-maps/tests/index.js +4 -0
  13. package/dist/src/migration/ember-addon/{tests/components.js → steps/create-file-path-maps/tests/map-components.js} +1 -1
  14. package/dist/src/migration/ember-addon/steps/create-file-path-maps.js +10 -0
  15. package/dist/src/migration/ember-addon/steps/index.js +2 -0
  16. package/dist/src/migration/ember-addon/steps/update-paths-in-app-folder.js +13 -0
  17. package/dist/src/migration/ember-app/index.js +5 -11
  18. package/dist/src/migration/ember-app/steps/create-file-path-maps/app/index.js +26 -0
  19. package/dist/src/migration/ember-app/{app/component-classes.js → steps/create-file-path-maps/app/map-component-classes.js} +1 -1
  20. package/dist/src/migration/ember-app/{app/component-stylesheets.js → steps/create-file-path-maps/app/map-component-stylesheets.js} +1 -1
  21. package/dist/src/migration/ember-app/{app/component-templates.js → steps/create-file-path-maps/app/map-component-templates.js} +1 -1
  22. package/dist/src/migration/ember-app/{app/route-adapters.js → steps/create-file-path-maps/app/map-route-adapters.js} +1 -1
  23. package/dist/src/migration/ember-app/{app/route-controllers.js → steps/create-file-path-maps/app/map-route-controllers.js} +1 -1
  24. package/dist/src/migration/ember-app/{app/route-models.js → steps/create-file-path-maps/app/map-route-models.js} +1 -1
  25. package/dist/src/migration/ember-app/{app/route-routes.js → steps/create-file-path-maps/app/map-route-routes.js} +1 -1
  26. package/dist/src/migration/ember-app/{app/route-serializers.js → steps/create-file-path-maps/app/map-route-serializers.js} +1 -1
  27. package/dist/src/migration/ember-app/{app/route-stylesheets.js → steps/create-file-path-maps/app/map-route-stylesheets.js} +1 -1
  28. package/dist/src/migration/ember-app/{app/route-templates.js → steps/create-file-path-maps/app/map-route-templates.js} +1 -1
  29. package/dist/src/migration/ember-app/{app/services.js → steps/create-file-path-maps/app/map-services.js} +1 -1
  30. package/dist/src/migration/ember-app/steps/create-file-path-maps/tests/index.js +12 -0
  31. package/dist/src/migration/ember-app/{tests/components.js → steps/create-file-path-maps/tests/map-components.js} +1 -1
  32. package/dist/src/migration/ember-app/{tests/route-controllers.js → steps/create-file-path-maps/tests/map-route-controllers.js} +1 -1
  33. package/dist/src/migration/ember-app/{tests/route-routes.js → steps/create-file-path-maps/tests/map-route-routes.js} +1 -1
  34. package/dist/src/migration/ember-app/{tests/services.js → steps/create-file-path-maps/tests/map-services.js} +1 -1
  35. package/dist/src/migration/ember-app/steps/create-file-path-maps.js +8 -0
  36. package/dist/src/migration/ember-app/steps/index.js +1 -0
  37. package/dist/src/migration/ember-engine/index.js +5 -12
  38. package/dist/src/migration/ember-engine/steps/create-file-path-maps/addon/index.js +18 -0
  39. package/dist/src/migration/ember-engine/{addon/component-classes.js → steps/create-file-path-maps/addon/map-component-classes.js} +1 -1
  40. package/dist/src/migration/{ember-addon/addon/component-stylesheets.js → ember-engine/steps/create-file-path-maps/addon/map-component-stylesheets.js} +1 -1
  41. package/dist/src/migration/ember-engine/{addon/component-templates.js → steps/create-file-path-maps/addon/map-component-templates.js} +1 -1
  42. package/dist/src/migration/ember-engine/{addon/route-controllers.js → steps/create-file-path-maps/addon/map-route-controllers.js} +1 -1
  43. package/dist/src/migration/ember-engine/{addon/route-routes.js → steps/create-file-path-maps/addon/map-route-routes.js} +1 -1
  44. package/dist/src/migration/ember-engine/{addon/route-stylesheets.js → steps/create-file-path-maps/addon/map-route-stylesheets.js} +1 -1
  45. package/dist/src/migration/ember-engine/{addon/route-templates.js → steps/create-file-path-maps/addon/map-route-templates.js} +1 -1
  46. package/dist/src/migration/ember-engine/steps/create-file-path-maps/tests/index.js +10 -0
  47. package/dist/src/migration/ember-engine/{tests/components.js → steps/create-file-path-maps/tests/map-components.js} +1 -1
  48. package/dist/src/migration/ember-engine/{tests/route-controllers.js → steps/create-file-path-maps/tests/map-route-controllers.js} +1 -1
  49. package/dist/src/migration/ember-engine/{tests/route-routes.js → steps/create-file-path-maps/tests/map-route-routes.js} +1 -1
  50. package/dist/src/migration/ember-engine/steps/create-file-path-maps.js +8 -0
  51. package/dist/src/migration/ember-engine/steps/index.js +1 -0
  52. package/package.json +13 -13
  53. package/dist/src/migration/ember-addon/addon/index.js +0 -10
  54. package/dist/src/migration/ember-addon/app/index.js +0 -10
  55. package/dist/src/migration/ember-addon/tests/index.js +0 -4
  56. package/dist/src/migration/ember-app/app/index.js +0 -26
  57. package/dist/src/migration/ember-app/tests/index.js +0 -12
  58. package/dist/src/migration/ember-engine/addon/index.js +0 -18
  59. package/dist/src/migration/ember-engine/tests/index.js +0 -10
  60. package/dist/src/utils/ember-addon/app/components.js +0 -19
package/README.md CHANGED
@@ -32,9 +32,9 @@ Step 3. Update references originating from, as well as pointing to, the moved fi
32
32
  You must pass `--type` to indicate what type of project you have.
33
33
 
34
34
  ```sh
35
- npx ember-codemod-pod-to-octane --type=app
36
- npx ember-codemod-pod-to-octane --type=addon
37
- npx ember-codemod-pod-to-octane --type=engine
35
+ npx ember-codemod-pod-to-octane --type app
36
+ npx ember-codemod-pod-to-octane --type addon
37
+ npx ember-codemod-pod-to-octane --type engine
38
38
  ```
39
39
 
40
40
 
@@ -56,14 +56,14 @@ npx ember-codemod-pod-to-octane --test
56
56
  Pass `--root` to run the codemod on a project somewhere else (i.e. not in the current directory).
57
57
 
58
58
  ```sh
59
- npx ember-codemod-pod-to-octane --root=<path/to/your/project>
59
+ npx ember-codemod-pod-to-octane --root <path/to/your/project>
60
60
  ```
61
61
 
62
62
  Note, you can use `--root` to un-pod the demo app of an Ember addon.
63
63
 
64
64
  ```sh
65
65
  # If the current directory is the addon root
66
- npx ember-codemod-pod-to-octane --type=app --root=tests/dummy
66
+ npx ember-codemod-pod-to-octane --type app --root tests/dummy
67
67
  ```
68
68
 
69
69
  </details>
@@ -76,7 +76,7 @@ Pass `--pod-path` if `podModulePrefix` has been set in `config/environment.js`.
76
76
 
77
77
  ```sh
78
78
  # If modulePrefix is 'my-app' and podModulePrefix is 'my-app/pods'
79
- npx ember-codemod-pod-to-octane --pod-path=pods
79
+ npx ember-codemod-pod-to-octane --pod-path pods
80
80
  ```
81
81
 
82
82
  </details>
@@ -120,13 +120,13 @@ cd <path/to/cloned/repo>
120
120
  pnpm build
121
121
 
122
122
  # Run codemod
123
- ./dist/bin/ember-codemod-pod-to-octane.js --root=<path/to/your/project>
123
+ ./dist/bin/ember-codemod-pod-to-octane.js --root <path/to/your/project>
124
124
  ```
125
125
 
126
126
 
127
127
  ## Compatibility
128
128
 
129
- * Node.js v16 or above
129
+ - Node.js v16 or above
130
130
 
131
131
 
132
132
  ## Contributing
package/dist/src/index.js CHANGED
@@ -13,8 +13,5 @@ export function runCodemod(codemodOptions) {
13
13
  migrateEmberEngine(codemodOptions);
14
14
  break;
15
15
  }
16
- default: {
17
- console.error(`Unknown project type: ${codemodOptions.projectType}`);
18
- }
19
16
  }
20
17
  }
@@ -1,24 +1,14 @@
1
1
  import { moveFiles } from '@codemod-utils/files';
2
- import { updatePathsInAppFolder } from '../../utils/ember-addon/app/components.js';
3
- import { migrationStrategyForAddonFolder } from './addon/index.js';
4
- import { migrationStrategyForAppFolder } from './app/index.js';
5
- import { createOptions } from './steps/index.js';
6
- import { migrationStrategyForTestsFolder } from './tests/index.js';
2
+ import { createFilePathMaps, createOptions, updatePathsInAppFolder, } from './steps/index.js';
7
3
  export function migrateEmberAddon(codemodOptions) {
8
4
  const options = createOptions(codemodOptions);
9
- const migrationStrategyAddon = migrationStrategyForAddonFolder(options);
10
- const migrationStrategyApp = migrationStrategyForAppFolder(options);
11
- const migrationStrategyTests = migrationStrategyForTestsFolder(options);
5
+ const filePathMaps = createFilePathMaps(options);
12
6
  if (options.testRun) {
13
- console.log({
14
- migrationStrategyAddon,
15
- migrationStrategyApp,
16
- migrationStrategyTests,
17
- });
7
+ console.log(filePathMaps);
18
8
  return;
19
9
  }
20
- moveFiles(migrationStrategyAddon, options);
21
- moveFiles(migrationStrategyApp, options);
22
- moveFiles(migrationStrategyTests, options);
23
- updatePathsInAppFolder(migrationStrategyApp, options);
10
+ moveFiles(filePathMaps.addon, options);
11
+ moveFiles(filePathMaps.app, options);
12
+ moveFiles(filePathMaps.tests, options);
13
+ updatePathsInAppFolder(filePathMaps.app, options);
24
14
  }
@@ -0,0 +1,10 @@
1
+ import { mapComponentClasses } from './map-component-classes.js';
2
+ import { mapComponentStylesheets } from './map-component-stylesheets.js';
3
+ import { mapComponentTemplates } from './map-component-templates.js';
4
+ export function mapAddonFolder(options) {
5
+ return new Map([
6
+ ...mapComponentClasses(options),
7
+ ...mapComponentStylesheets(options),
8
+ ...mapComponentTemplates(options),
9
+ ]);
10
+ }
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForComponentClasses(options) {
2
+ export function mapComponentClasses(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('addon/components/**/component.{d.ts,js,ts}', {
5
5
  projectRoot,
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForComponentStylesheets(options) {
2
+ export function mapComponentStylesheets(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('addon/components/**/styles.{css,scss}', {
5
5
  projectRoot,
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForComponentTemplates(options) {
2
+ export function mapComponentTemplates(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('addon/components/**/template.hbs', {
5
5
  projectRoot,
@@ -0,0 +1,10 @@
1
+ import { mapComponentClasses } from './map-component-classes.js';
2
+ import { mapComponentStylesheets } from './map-component-stylesheets.js';
3
+ import { mapComponentTemplates } from './map-component-templates.js';
4
+ export function mapAppFolder(options) {
5
+ return new Map([
6
+ ...mapComponentClasses(options),
7
+ ...mapComponentStylesheets(options),
8
+ ...mapComponentTemplates(options),
9
+ ]);
10
+ }
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForComponentClasses(options) {
2
+ export function mapComponentClasses(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('app/components/**/component.js', {
5
5
  projectRoot,
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForComponentStylesheets(options) {
2
+ export function mapComponentStylesheets(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('app/components/**/styles.js', {
5
5
  projectRoot,
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForComponentTemplates(options) {
2
+ export function mapComponentTemplates(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('app/components/**/template.js', {
5
5
  projectRoot,
@@ -0,0 +1,4 @@
1
+ import { mapComponents } from './map-components.js';
2
+ export function mapTestsFolder(options) {
3
+ return new Map([...mapComponents(options)]);
4
+ }
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForComponents(options) {
2
+ export function mapComponents(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('tests/integration/components/**/component-test.{js,ts}', {
5
5
  projectRoot,
@@ -0,0 +1,10 @@
1
+ import { mapAddonFolder } from './create-file-path-maps/addon/index.js';
2
+ import { mapAppFolder } from './create-file-path-maps/app/index.js';
3
+ import { mapTestsFolder } from './create-file-path-maps/tests/index.js';
4
+ export function createFilePathMaps(options) {
5
+ return {
6
+ addon: mapAddonFolder(options),
7
+ app: mapAppFolder(options),
8
+ tests: mapTestsFolder(options),
9
+ };
10
+ }
@@ -1 +1,3 @@
1
+ export * from './create-file-path-maps.js';
1
2
  export * from './create-options.js';
3
+ export * from './update-paths-in-app-folder.js';
@@ -0,0 +1,13 @@
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ export function updatePathsInAppFolder(filePathMap, options) {
4
+ const { projectRoot } = options;
5
+ filePathMap.forEach((newFilePath, oldFilePath) => {
6
+ const newAbsolutePath = join(projectRoot, newFilePath);
7
+ const file = readFileSync(newAbsolutePath, 'utf8');
8
+ const text = oldFilePath.replace(/^app\//, '').replace(/\.js$/, '');
9
+ const newText = newFilePath.replace(/^app\//, '').replace(/\.js$/, '');
10
+ const newFile = file.replace(new RegExp(text), newText);
11
+ writeFileSync(newAbsolutePath, newFile, 'utf8');
12
+ });
13
+ }
@@ -1,18 +1,12 @@
1
1
  import { moveFiles } from '@codemod-utils/files';
2
- import { migrationStrategyForAppFolder } from './app/index.js';
3
- import { createOptions } from './steps/index.js';
4
- import { migrationStrategyForTestsFolder } from './tests/index.js';
2
+ import { createFilePathMaps, createOptions } from './steps/index.js';
5
3
  export function migrateEmberApp(codemodOptions) {
6
4
  const options = createOptions(codemodOptions);
7
- const migrationStrategyApp = migrationStrategyForAppFolder(options);
8
- const migrationStrategyTests = migrationStrategyForTestsFolder(options);
5
+ const filePathMaps = createFilePathMaps(options);
9
6
  if (options.testRun) {
10
- console.log({
11
- migrationStrategyApp,
12
- migrationStrategyTests,
13
- });
7
+ console.log(filePathMaps);
14
8
  return;
15
9
  }
16
- moveFiles(migrationStrategyApp, options);
17
- moveFiles(migrationStrategyTests, options);
10
+ moveFiles(filePathMaps.app, options);
11
+ moveFiles(filePathMaps.tests, options);
18
12
  }
@@ -0,0 +1,26 @@
1
+ import { mapComponentClasses } from './map-component-classes.js';
2
+ import { mapComponentStylesheets } from './map-component-stylesheets.js';
3
+ import { mapComponentTemplates } from './map-component-templates.js';
4
+ import { mapRouteAdapters } from './map-route-adapters.js';
5
+ import { mapRouteControllers } from './map-route-controllers.js';
6
+ import { mapRouteModels } from './map-route-models.js';
7
+ import { mapRouteRoutes } from './map-route-routes.js';
8
+ import { mapRouteSerializers } from './map-route-serializers.js';
9
+ import { mapRouteStylesheets } from './map-route-stylesheets.js';
10
+ import { mapRouteTemplates } from './map-route-templates.js';
11
+ import { mapServices } from './map-services.js';
12
+ export function mapAppFolder(options) {
13
+ return new Map([
14
+ ...mapComponentClasses(options),
15
+ ...mapComponentStylesheets(options),
16
+ ...mapComponentTemplates(options),
17
+ ...mapRouteAdapters(options),
18
+ ...mapRouteControllers(options),
19
+ ...mapRouteModels(options),
20
+ ...mapRouteRoutes(options),
21
+ ...mapRouteSerializers(options),
22
+ ...mapRouteStylesheets(options),
23
+ ...mapRouteTemplates(options),
24
+ ...mapServices(options),
25
+ ]);
26
+ }
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForComponentClasses(options) {
3
+ export function mapComponentClasses(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('app', podPath, 'components', '**', 'component.{d.ts,js,ts}'), {
6
6
  projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForComponentStylesheets(options) {
3
+ export function mapComponentStylesheets(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('app', podPath, 'components', '**', 'styles.{css,scss}'), {
6
6
  projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForComponentTemplates(options) {
3
+ export function mapComponentTemplates(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('app', podPath, 'components', '**', 'template.hbs'), {
6
6
  projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForRouteAdapters(options) {
3
+ export function mapRouteAdapters(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('app', podPath, '**', 'adapter.{js,ts}'), {
6
6
  projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForRouteControllers(options) {
3
+ export function mapRouteControllers(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('app', podPath, '**', 'controller.{js,ts}'), {
6
6
  projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForRouteModels(options) {
3
+ export function mapRouteModels(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('app', podPath, '**', 'model.{js,ts}'), {
6
6
  projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForRouteRoutes(options) {
3
+ export function mapRouteRoutes(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('app', podPath, '**', 'route.{js,ts}'), {
6
6
  projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForRouteSerializers(options) {
3
+ export function mapRouteSerializers(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('app', podPath, '**', 'serializer.{js,ts}'), {
6
6
  projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForRouteStylesheets(options) {
3
+ export function mapRouteStylesheets(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('app', podPath, '!(components)', '**', 'styles.{css,scss}'), {
6
6
  projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForRouteTemplates(options) {
3
+ export function mapRouteTemplates(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('app', podPath, '!(components)', '**', 'template.hbs'), {
6
6
  projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForServices(options) {
3
+ export function mapServices(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('app', podPath, '**', 'service.{js,ts}'), {
6
6
  projectRoot,
@@ -0,0 +1,12 @@
1
+ import { mapComponents } from './map-components.js';
2
+ import { mapRouteControllers } from './map-route-controllers.js';
3
+ import { mapRouteRoutes } from './map-route-routes.js';
4
+ import { mapServices } from './map-services.js';
5
+ export function mapTestsFolder(options) {
6
+ return new Map([
7
+ ...mapComponents(options),
8
+ ...mapRouteControllers(options),
9
+ ...mapRouteRoutes(options),
10
+ ...mapServices(options),
11
+ ]);
12
+ }
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForComponents(options) {
3
+ export function mapComponents(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('tests/integration', podPath, 'components', '**', 'component-test.{js,ts}'), {
6
6
  projectRoot,
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForRouteControllers(options) {
3
+ export function mapRouteControllers(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  /*
6
6
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForRouteRoutes(options) {
3
+ export function mapRouteRoutes(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  /*
6
6
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
- export function migrationStrategyForServices(options) {
3
+ export function mapServices(options) {
4
4
  const { podPath, projectRoot } = options;
5
5
  const filePaths = findFiles(join('tests/unit', podPath, '!(services)', '**', 'service-test.{js,ts}'), {
6
6
  projectRoot,
@@ -0,0 +1,8 @@
1
+ import { mapAppFolder } from './create-file-path-maps/app/index.js';
2
+ import { mapTestsFolder } from './create-file-path-maps/tests/index.js';
3
+ export function createFilePathMaps(options) {
4
+ return {
5
+ app: mapAppFolder(options),
6
+ tests: mapTestsFolder(options),
7
+ };
8
+ }
@@ -1 +1,2 @@
1
+ export * from './create-file-path-maps.js';
1
2
  export * from './create-options.js';
@@ -1,20 +1,13 @@
1
1
  import { moveFiles } from '@codemod-utils/files';
2
- import { migrationStrategyForAddonFolder } from './addon/index.js';
3
- import { createOptions } from './steps/index.js';
4
- import { migrationStrategyForTestsFolder } from './tests/index.js';
2
+ import { createFilePathMaps, createOptions } from './steps/index.js';
5
3
  export function migrateEmberEngine(codemodOptions) {
6
4
  const options = createOptions(codemodOptions);
7
- const migrationStrategyAddon = migrationStrategyForAddonFolder(options);
8
- const migrationStrategyTests = migrationStrategyForTestsFolder(options);
9
- const migrationStrategy = new Map([
10
- ...migrationStrategyAddon,
11
- ...migrationStrategyTests,
12
- ]);
5
+ const filePathMaps = createFilePathMaps(options);
13
6
  if (options.testRun) {
14
- console.log(migrationStrategy);
7
+ console.log(filePathMaps);
15
8
  return;
16
9
  }
17
10
  // Preserve code
18
- moveFiles(migrationStrategyAddon, options);
19
- moveFiles(migrationStrategyTests, options);
11
+ moveFiles(filePathMaps.addon, options);
12
+ moveFiles(filePathMaps.tests, options);
20
13
  }
@@ -0,0 +1,18 @@
1
+ import { mapComponentClasses } from './map-component-classes.js';
2
+ import { mapComponentStylesheets } from './map-component-stylesheets.js';
3
+ import { mapComponentTemplates } from './map-component-templates.js';
4
+ import { mapRouteControllers } from './map-route-controllers.js';
5
+ import { mapRouteRoutes } from './map-route-routes.js';
6
+ import { mapRouteStylesheets } from './map-route-stylesheets.js';
7
+ import { mapRouteTemplates } from './map-route-templates.js';
8
+ export function mapAddonFolder(options) {
9
+ return new Map([
10
+ ...mapComponentClasses(options),
11
+ ...mapComponentStylesheets(options),
12
+ ...mapComponentTemplates(options),
13
+ ...mapRouteControllers(options),
14
+ ...mapRouteRoutes(options),
15
+ ...mapRouteStylesheets(options),
16
+ ...mapRouteTemplates(options),
17
+ ]);
18
+ }
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForComponentClasses(options) {
2
+ export function mapComponentClasses(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('addon/components/**/component.{d.ts,js,ts}', {
5
5
  projectRoot,
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForComponentStylesheets(options) {
2
+ export function mapComponentStylesheets(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('addon/components/**/styles.{css,scss}', {
5
5
  projectRoot,
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForComponentTemplates(options) {
2
+ export function mapComponentTemplates(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('addon/components/**/template.hbs', {
5
5
  projectRoot,
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForRouteControllers(options) {
2
+ export function mapRouteControllers(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('addon/**/controller.{js,ts}', {
5
5
  projectRoot,
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForRouteRoutes(options) {
2
+ export function mapRouteRoutes(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('addon/**/route.{js,ts}', {
5
5
  projectRoot,
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForRouteStylesheets(options) {
2
+ export function mapRouteStylesheets(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('addon/!(components)/**/styles.{css,scss}', {
5
5
  projectRoot,
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForRouteTemplates(options) {
2
+ export function mapRouteTemplates(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('addon/!(components)/**/template.hbs', {
5
5
  projectRoot,
@@ -0,0 +1,10 @@
1
+ import { mapComponents } from './map-components.js';
2
+ import { mapRouteControllers } from './map-route-controllers.js';
3
+ import { mapRouteRoutes } from './map-route-routes.js';
4
+ export function mapTestsFolder(options) {
5
+ return new Map([
6
+ ...mapComponents(options),
7
+ ...mapRouteControllers(options),
8
+ ...mapRouteRoutes(options),
9
+ ]);
10
+ }
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForComponents(options) {
2
+ export function mapComponents(options) {
3
3
  const { projectRoot } = options;
4
4
  const filePaths = findFiles('tests/integration/components/**/component-test.{js,ts}', {
5
5
  projectRoot,
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForRouteControllers(options) {
2
+ export function mapRouteControllers(options) {
3
3
  const { projectRoot } = options;
4
4
  /*
5
5
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
@@ -1,5 +1,5 @@
1
1
  import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
- export function migrationStrategyForRouteRoutes(options) {
2
+ export function mapRouteRoutes(options) {
3
3
  const { projectRoot } = options;
4
4
  /*
5
5
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
@@ -0,0 +1,8 @@
1
+ import { mapAddonFolder } from './create-file-path-maps/addon/index.js';
2
+ import { mapTestsFolder } from './create-file-path-maps/tests/index.js';
3
+ export function createFilePathMaps(options) {
4
+ return {
5
+ addon: mapAddonFolder(options),
6
+ tests: mapTestsFolder(options),
7
+ };
8
+ }
@@ -1 +1,2 @@
1
+ export * from './create-file-path-maps.js';
1
2
  export * from './create-options.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-codemod-pod-to-octane",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "Codemod to un-pod Ember apps, addons, and engines",
5
5
  "keywords": [
6
6
  "codemod",
@@ -24,32 +24,32 @@
24
24
  "dist"
25
25
  ],
26
26
  "dependencies": {
27
- "@codemod-utils/files": "^0.5.0",
27
+ "@codemod-utils/files": "^0.5.2",
28
28
  "yargs": "^17.7.2"
29
29
  },
30
30
  "devDependencies": {
31
- "@babel/core": "^7.22.5",
32
- "@codemod-utils/tests": "^0.2.3",
31
+ "@babel/core": "^7.22.8",
32
+ "@codemod-utils/tests": "^0.2.5",
33
33
  "@sondr3/minitest": "^0.1.1",
34
- "@tsconfig/esm": "^1.0.3",
35
- "@tsconfig/node16": "^1.0.4",
34
+ "@tsconfig/esm": "^1.0.4",
35
+ "@tsconfig/node16": "^16.1.0",
36
36
  "@tsconfig/strictest": "^2.0.1",
37
37
  "@types/node": "^16.11.7",
38
38
  "@types/yargs": "^17.0.24",
39
- "@typescript-eslint/eslint-plugin": "^5.60.0",
40
- "@typescript-eslint/parser": "^5.60.0",
39
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
40
+ "@typescript-eslint/parser": "^6.0.0",
41
41
  "concurrently": "^8.2.0",
42
- "eslint": "^8.43.0",
42
+ "eslint": "^8.44.0",
43
43
  "eslint-config-prettier": "^8.8.0",
44
44
  "eslint-import-resolver-typescript": "^3.5.5",
45
45
  "eslint-plugin-import": "^2.27.5",
46
- "eslint-plugin-n": "^16.0.0",
47
- "eslint-plugin-prettier": "^4.2.1",
46
+ "eslint-plugin-n": "^16.0.1",
47
+ "eslint-plugin-prettier": "^5.0.0",
48
48
  "eslint-plugin-simple-import-sort": "^10.0.0",
49
49
  "eslint-plugin-typescript-sort-keys": "^2.3.0",
50
50
  "lerna-changelog": "^2.2.0",
51
- "prettier": "^2.8.8",
52
- "typescript": "^5.1.3"
51
+ "prettier": "^3.0.0",
52
+ "typescript": "^5.1.6"
53
53
  },
54
54
  "engines": {
55
55
  "node": ">= 16"
@@ -1,10 +0,0 @@
1
- import { migrationStrategyForComponentClasses } from './component-classes.js';
2
- import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
3
- import { migrationStrategyForComponentTemplates } from './component-templates.js';
4
- export function migrationStrategyForAddonFolder(options) {
5
- return new Map([
6
- ...migrationStrategyForComponentClasses(options),
7
- ...migrationStrategyForComponentStylesheets(options),
8
- ...migrationStrategyForComponentTemplates(options),
9
- ]);
10
- }
@@ -1,10 +0,0 @@
1
- import { migrationStrategyForComponentClasses } from './component-classes.js';
2
- import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
3
- import { migrationStrategyForComponentTemplates } from './component-templates.js';
4
- export function migrationStrategyForAppFolder(options) {
5
- return new Map([
6
- ...migrationStrategyForComponentClasses(options),
7
- ...migrationStrategyForComponentStylesheets(options),
8
- ...migrationStrategyForComponentTemplates(options),
9
- ]);
10
- }
@@ -1,4 +0,0 @@
1
- import { migrationStrategyForComponents } from './components.js';
2
- export function migrationStrategyForTestsFolder(options) {
3
- return new Map([...migrationStrategyForComponents(options)]);
4
- }
@@ -1,26 +0,0 @@
1
- import { migrationStrategyForComponentClasses } from './component-classes.js';
2
- import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
3
- import { migrationStrategyForComponentTemplates } from './component-templates.js';
4
- import { migrationStrategyForRouteAdapters } from './route-adapters.js';
5
- import { migrationStrategyForRouteControllers } from './route-controllers.js';
6
- import { migrationStrategyForRouteModels } from './route-models.js';
7
- import { migrationStrategyForRouteRoutes } from './route-routes.js';
8
- import { migrationStrategyForRouteSerializers } from './route-serializers.js';
9
- import { migrationStrategyForRouteStylesheets } from './route-stylesheets.js';
10
- import { migrationStrategyForRouteTemplates } from './route-templates.js';
11
- import { migrationStrategyForServices } from './services.js';
12
- export function migrationStrategyForAppFolder(options) {
13
- return new Map([
14
- ...migrationStrategyForComponentClasses(options),
15
- ...migrationStrategyForComponentStylesheets(options),
16
- ...migrationStrategyForComponentTemplates(options),
17
- ...migrationStrategyForRouteAdapters(options),
18
- ...migrationStrategyForRouteControllers(options),
19
- ...migrationStrategyForRouteModels(options),
20
- ...migrationStrategyForRouteRoutes(options),
21
- ...migrationStrategyForRouteSerializers(options),
22
- ...migrationStrategyForRouteStylesheets(options),
23
- ...migrationStrategyForRouteTemplates(options),
24
- ...migrationStrategyForServices(options),
25
- ]);
26
- }
@@ -1,12 +0,0 @@
1
- import { migrationStrategyForComponents } from './components.js';
2
- import { migrationStrategyForRouteControllers } from './route-controllers.js';
3
- import { migrationStrategyForRouteRoutes } from './route-routes.js';
4
- import { migrationStrategyForServices } from './services.js';
5
- export function migrationStrategyForTestsFolder(options) {
6
- return new Map([
7
- ...migrationStrategyForComponents(options),
8
- ...migrationStrategyForRouteControllers(options),
9
- ...migrationStrategyForRouteRoutes(options),
10
- ...migrationStrategyForServices(options),
11
- ]);
12
- }
@@ -1,18 +0,0 @@
1
- import { migrationStrategyForComponentClasses } from './component-classes.js';
2
- import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
3
- import { migrationStrategyForComponentTemplates } from './component-templates.js';
4
- import { migrationStrategyForRouteControllers } from './route-controllers.js';
5
- import { migrationStrategyForRouteRoutes } from './route-routes.js';
6
- import { migrationStrategyForRouteStylesheets } from './route-stylesheets.js';
7
- import { migrationStrategyForRouteTemplates } from './route-templates.js';
8
- export function migrationStrategyForAddonFolder(options) {
9
- return new Map([
10
- ...migrationStrategyForComponentClasses(options),
11
- ...migrationStrategyForComponentStylesheets(options),
12
- ...migrationStrategyForComponentTemplates(options),
13
- ...migrationStrategyForRouteControllers(options),
14
- ...migrationStrategyForRouteRoutes(options),
15
- ...migrationStrategyForRouteStylesheets(options),
16
- ...migrationStrategyForRouteTemplates(options),
17
- ]);
18
- }
@@ -1,10 +0,0 @@
1
- import { migrationStrategyForComponents } from './components.js';
2
- import { migrationStrategyForRouteControllers } from './route-controllers.js';
3
- import { migrationStrategyForRouteRoutes } from './route-routes.js';
4
- export function migrationStrategyForTestsFolder(options) {
5
- return new Map([
6
- ...migrationStrategyForComponents(options),
7
- ...migrationStrategyForRouteControllers(options),
8
- ...migrationStrategyForRouteRoutes(options),
9
- ]);
10
- }
@@ -1,19 +0,0 @@
1
- import { readFileSync, writeFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- export function updatePathsInAppFolder(migrationStrategy, options) {
4
- const { projectRoot } = options;
5
- migrationStrategy.forEach((newFilePath, oldFilePath) => {
6
- // Read file
7
- const newAbsolutePath = join(projectRoot, newFilePath);
8
- const file = readFileSync(newAbsolutePath, 'utf8');
9
- // Update file
10
- const oldRelativePath = oldFilePath
11
- .replace(/^app\//, '')
12
- .replace(/\.js$/, '');
13
- const newRelativePath = newFilePath
14
- .replace(/^app\//, '')
15
- .replace(/\.js$/, '');
16
- const newFile = file.replace(new RegExp(oldRelativePath), newRelativePath);
17
- writeFileSync(newAbsolutePath, newFile, 'utf8');
18
- });
19
- }