ember-codemod-pod-to-octane 1.1.5 → 1.2.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.
Files changed (100) hide show
  1. package/{bin → dist/bin}/ember-codemod-pod-to-octane.js +14 -20
  2. package/dist/src/index.js +20 -0
  3. package/dist/src/migration/ember-addon/addon/component-classes.js +19 -0
  4. package/dist/src/migration/ember-addon/addon/component-stylesheets.js +19 -0
  5. package/dist/src/migration/ember-addon/addon/component-templates.js +19 -0
  6. package/{src → dist/src}/migration/ember-addon/addon/index.js +5 -6
  7. package/dist/src/migration/ember-addon/app/component-classes.js +19 -0
  8. package/dist/src/migration/ember-addon/app/component-stylesheets.js +19 -0
  9. package/dist/src/migration/ember-addon/app/component-templates.js +19 -0
  10. package/{src → dist/src}/migration/ember-addon/app/index.js +5 -6
  11. package/dist/src/migration/ember-addon/index.js +24 -0
  12. package/dist/src/migration/ember-addon/steps/create-options.js +15 -0
  13. package/dist/src/migration/ember-addon/tests/components.js +19 -0
  14. package/{src → dist/src}/migration/ember-addon/tests/index.js +1 -2
  15. package/dist/src/migration/ember-app/app/component-classes.js +20 -0
  16. package/dist/src/migration/ember-app/app/component-stylesheets.js +20 -0
  17. package/dist/src/migration/ember-app/app/component-templates.js +20 -0
  18. package/{src → dist/src}/migration/ember-app/app/index.js +13 -14
  19. package/dist/src/migration/ember-app/app/route-adapters.js +20 -0
  20. package/dist/src/migration/ember-app/app/route-controllers.js +20 -0
  21. package/dist/src/migration/ember-app/app/route-models.js +20 -0
  22. package/dist/src/migration/ember-app/app/route-routes.js +20 -0
  23. package/dist/src/migration/ember-app/app/route-serializers.js +20 -0
  24. package/dist/src/migration/ember-app/app/route-stylesheets.js +20 -0
  25. package/dist/src/migration/ember-app/app/route-templates.js +20 -0
  26. package/dist/src/migration/ember-app/app/services.js +20 -0
  27. package/dist/src/migration/ember-app/index.js +18 -0
  28. package/dist/src/migration/ember-app/steps/create-options.js +15 -0
  29. package/dist/src/migration/ember-app/tests/components.js +20 -0
  30. package/{src → dist/src}/migration/ember-app/tests/index.js +6 -7
  31. package/dist/src/migration/ember-app/tests/route-controllers.js +42 -0
  32. package/dist/src/migration/ember-app/tests/route-routes.js +42 -0
  33. package/dist/src/migration/ember-app/tests/services.js +20 -0
  34. package/dist/src/migration/ember-engine/addon/component-classes.js +19 -0
  35. package/dist/src/migration/ember-engine/addon/component-stylesheets.js +19 -0
  36. package/dist/src/migration/ember-engine/addon/component-templates.js +19 -0
  37. package/{src → dist/src}/migration/ember-engine/addon/index.js +9 -10
  38. package/dist/src/migration/ember-engine/addon/route-controllers.js +19 -0
  39. package/dist/src/migration/ember-engine/addon/route-routes.js +19 -0
  40. package/dist/src/migration/ember-engine/addon/route-stylesheets.js +19 -0
  41. package/dist/src/migration/ember-engine/addon/route-templates.js +19 -0
  42. package/dist/src/migration/ember-engine/index.js +25 -0
  43. package/dist/src/migration/ember-engine/steps/create-options.js +16 -0
  44. package/dist/src/migration/ember-engine/steps/update-absolute-paths.js +73 -0
  45. package/dist/src/migration/ember-engine/steps/use-absolute-paths.js +41 -0
  46. package/dist/src/migration/ember-engine/steps/use-relative-paths.js +85 -0
  47. package/dist/src/migration/ember-engine/tests/components.js +19 -0
  48. package/{src → dist/src}/migration/ember-engine/tests/index.js +5 -6
  49. package/dist/src/migration/ember-engine/tests/route-controllers.js +41 -0
  50. package/dist/src/migration/ember-engine/tests/route-routes.js +41 -0
  51. package/dist/src/types/index.js +1 -0
  52. package/dist/src/utils/ember-addon/app/components.js +19 -0
  53. package/package.json +38 -16
  54. package/src/index.js +0 -28
  55. package/src/migration/ember-addon/addon/component-classes.js +0 -23
  56. package/src/migration/ember-addon/addon/component-stylesheets.js +0 -23
  57. package/src/migration/ember-addon/addon/component-templates.js +0 -23
  58. package/src/migration/ember-addon/app/component-classes.js +0 -23
  59. package/src/migration/ember-addon/app/component-stylesheets.js +0 -23
  60. package/src/migration/ember-addon/app/component-templates.js +0 -23
  61. package/src/migration/ember-addon/index.js +0 -31
  62. package/src/migration/ember-addon/steps/create-options.js +0 -19
  63. package/src/migration/ember-addon/tests/components.js +0 -26
  64. package/src/migration/ember-app/app/component-classes.js +0 -28
  65. package/src/migration/ember-app/app/component-stylesheets.js +0 -28
  66. package/src/migration/ember-app/app/component-templates.js +0 -28
  67. package/src/migration/ember-app/app/route-adapters.js +0 -25
  68. package/src/migration/ember-app/app/route-controllers.js +0 -28
  69. package/src/migration/ember-app/app/route-models.js +0 -25
  70. package/src/migration/ember-app/app/route-routes.js +0 -25
  71. package/src/migration/ember-app/app/route-serializers.js +0 -28
  72. package/src/migration/ember-app/app/route-stylesheets.js +0 -28
  73. package/src/migration/ember-app/app/route-templates.js +0 -28
  74. package/src/migration/ember-app/app/services.js +0 -25
  75. package/src/migration/ember-app/index.js +0 -24
  76. package/src/migration/ember-app/steps/create-options.js +0 -19
  77. package/src/migration/ember-app/tests/components.js +0 -34
  78. package/src/migration/ember-app/tests/route-controllers.js +0 -63
  79. package/src/migration/ember-app/tests/route-routes.js +0 -57
  80. package/src/migration/ember-app/tests/services.js +0 -28
  81. package/src/migration/ember-engine/addon/component-classes.js +0 -23
  82. package/src/migration/ember-engine/addon/component-stylesheets.js +0 -23
  83. package/src/migration/ember-engine/addon/component-templates.js +0 -23
  84. package/src/migration/ember-engine/addon/route-controllers.js +0 -23
  85. package/src/migration/ember-engine/addon/route-routes.js +0 -23
  86. package/src/migration/ember-engine/addon/route-stylesheets.js +0 -23
  87. package/src/migration/ember-engine/addon/route-templates.js +0 -23
  88. package/src/migration/ember-engine/index.js +0 -39
  89. package/src/migration/ember-engine/steps/create-options.js +0 -21
  90. package/src/migration/ember-engine/steps/update-absolute-paths.js +0 -102
  91. package/src/migration/ember-engine/steps/use-absolute-paths.js +0 -58
  92. package/src/migration/ember-engine/steps/use-relative-paths.js +0 -110
  93. package/src/migration/ember-engine/tests/components.js +0 -26
  94. package/src/migration/ember-engine/tests/route-controllers.js +0 -55
  95. package/src/migration/ember-engine/tests/route-routes.js +0 -49
  96. package/src/utils/ember-addon/app/components.js +0 -24
  97. /package/{src → dist/src}/migration/ember-addon/steps/index.js +0 -0
  98. /package/{src → dist/src}/migration/ember-app/steps/index.js +0 -0
  99. /package/{src → dist/src}/migration/ember-engine/steps/index.js +0 -0
  100. /package/{src → dist/src}/migration/index.js +0 -0
@@ -1,42 +1,36 @@
1
- #!/usr/bin/env node
2
1
  'use strict';
3
-
4
2
  import yargs from 'yargs';
5
3
  import { hideBin } from 'yargs/helpers';
6
-
7
4
  import { runCodemod } from '../src/index.js';
8
-
9
5
  // Provide a title to the process in `ps`
10
6
  process.title = 'ember-codemod-pod-to-octane';
11
-
12
7
  // Set codemod options
13
- const { argv } = yargs(hideBin(process.argv))
14
- .option('pod-path', {
8
+ const argv = yargs(hideBin(process.argv))
9
+ .option('pod-path', {
15
10
  default: '',
16
11
  describe: 'Namespace used for the pod layout',
17
12
  type: 'string',
18
- })
19
- .option('root', {
13
+ })
14
+ .option('root', {
20
15
  describe: 'Location of your Ember project',
21
16
  type: 'string',
22
- })
23
- .option('test', {
17
+ })
18
+ .option('test', {
24
19
  default: false,
25
20
  describe: 'Do a test run?',
26
21
  type: 'boolean',
27
- })
28
- .option('type', {
22
+ })
23
+ .option('type', {
29
24
  choices: ['addon', 'app', 'engine'],
30
25
  demandOption: true,
31
26
  describe: 'Type of your Ember project',
32
27
  type: 'string',
33
- });
34
-
28
+ })
29
+ .parseSync();
35
30
  const codemodOptions = {
36
- podPath: argv['pod-path'],
37
- projectRoot: argv['root'] ?? process.cwd(),
38
- projectType: argv['type'],
39
- testRun: argv['test'],
31
+ podPath: argv['pod-path'],
32
+ projectRoot: argv['root'] ?? process.cwd(),
33
+ projectType: argv['type'],
34
+ testRun: argv['test'],
40
35
  };
41
-
42
36
  runCodemod(codemodOptions);
@@ -0,0 +1,20 @@
1
+ import { migrateEmberAddon, migrateEmberApp, migrateEmberEngine, } from './migration/index.js';
2
+ export function runCodemod(codemodOptions) {
3
+ switch (codemodOptions.projectType) {
4
+ case 'addon': {
5
+ migrateEmberAddon(codemodOptions);
6
+ break;
7
+ }
8
+ case 'app': {
9
+ migrateEmberApp(codemodOptions);
10
+ break;
11
+ }
12
+ case 'engine': {
13
+ migrateEmberEngine(codemodOptions);
14
+ break;
15
+ }
16
+ default: {
17
+ console.error(`Unknown project type: ${codemodOptions.projectType}`);
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,19 @@
1
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ export function migrationStrategyForComponentClasses(options) {
3
+ const { projectRoot } = options;
4
+ const filePaths = findFiles('addon/components/**/component.{d.ts,js,ts}', {
5
+ projectRoot,
6
+ });
7
+ return filePaths.map((oldFilePath) => {
8
+ const newFilePath = renamePathByFile(oldFilePath, {
9
+ find: {
10
+ directory: 'addon/components',
11
+ file: 'component',
12
+ },
13
+ replace: (key) => {
14
+ return `addon/components/${key}`;
15
+ },
16
+ });
17
+ return [oldFilePath, newFilePath];
18
+ });
19
+ }
@@ -0,0 +1,19 @@
1
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ export function migrationStrategyForComponentStylesheets(options) {
3
+ const { projectRoot } = options;
4
+ const filePaths = findFiles('addon/components/**/styles.{css,scss}', {
5
+ projectRoot,
6
+ });
7
+ return filePaths.map((oldFilePath) => {
8
+ const newFilePath = renamePathByFile(oldFilePath, {
9
+ find: {
10
+ directory: 'addon/components',
11
+ file: 'styles',
12
+ },
13
+ replace: (key) => {
14
+ return `addon/components/${key}`;
15
+ },
16
+ });
17
+ return [oldFilePath, newFilePath];
18
+ });
19
+ }
@@ -0,0 +1,19 @@
1
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ export function migrationStrategyForComponentTemplates(options) {
3
+ const { projectRoot } = options;
4
+ const filePaths = findFiles('addon/components/**/template.hbs', {
5
+ projectRoot,
6
+ });
7
+ return filePaths.map((oldFilePath) => {
8
+ const newFilePath = renamePathByFile(oldFilePath, {
9
+ find: {
10
+ directory: 'addon/components',
11
+ file: 'template',
12
+ },
13
+ replace: (key) => {
14
+ return `addon/components/${key}`;
15
+ },
16
+ });
17
+ return [oldFilePath, newFilePath];
18
+ });
19
+ }
@@ -1,11 +1,10 @@
1
1
  import { migrationStrategyForComponentClasses } from './component-classes.js';
2
2
  import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
3
3
  import { migrationStrategyForComponentTemplates } from './component-templates.js';
4
-
5
4
  export function migrationStrategyForAddonFolder(options) {
6
- return new Map([
7
- ...migrationStrategyForComponentClasses(options),
8
- ...migrationStrategyForComponentStylesheets(options),
9
- ...migrationStrategyForComponentTemplates(options),
10
- ]);
5
+ return new Map([
6
+ ...migrationStrategyForComponentClasses(options),
7
+ ...migrationStrategyForComponentStylesheets(options),
8
+ ...migrationStrategyForComponentTemplates(options),
9
+ ]);
11
10
  }
@@ -0,0 +1,19 @@
1
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ export function migrationStrategyForComponentClasses(options) {
3
+ const { projectRoot } = options;
4
+ const filePaths = findFiles('app/components/**/component.js', {
5
+ projectRoot,
6
+ });
7
+ return filePaths.map((oldFilePath) => {
8
+ const newFilePath = renamePathByFile(oldFilePath, {
9
+ find: {
10
+ directory: 'app/components',
11
+ file: 'component',
12
+ },
13
+ replace: (key) => {
14
+ return `app/components/${key}`;
15
+ },
16
+ });
17
+ return [oldFilePath, newFilePath];
18
+ });
19
+ }
@@ -0,0 +1,19 @@
1
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ export function migrationStrategyForComponentStylesheets(options) {
3
+ const { projectRoot } = options;
4
+ const filePaths = findFiles('app/components/**/styles.js', {
5
+ projectRoot,
6
+ });
7
+ return filePaths.map((oldFilePath) => {
8
+ const newFilePath = renamePathByFile(oldFilePath, {
9
+ find: {
10
+ directory: 'app/components',
11
+ file: 'styles',
12
+ },
13
+ replace: (key) => {
14
+ return `app/components/${key}`;
15
+ },
16
+ });
17
+ return [oldFilePath, newFilePath];
18
+ });
19
+ }
@@ -0,0 +1,19 @@
1
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ export function migrationStrategyForComponentTemplates(options) {
3
+ const { projectRoot } = options;
4
+ const filePaths = findFiles('app/components/**/template.js', {
5
+ projectRoot,
6
+ });
7
+ return filePaths.map((oldFilePath) => {
8
+ const newFilePath = renamePathByFile(oldFilePath, {
9
+ find: {
10
+ directory: 'app/components',
11
+ file: 'template',
12
+ },
13
+ replace: (key) => {
14
+ return `app/components/${key}`;
15
+ },
16
+ });
17
+ return [oldFilePath, newFilePath];
18
+ });
19
+ }
@@ -1,11 +1,10 @@
1
1
  import { migrationStrategyForComponentClasses } from './component-classes.js';
2
2
  import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
3
3
  import { migrationStrategyForComponentTemplates } from './component-templates.js';
4
-
5
4
  export function migrationStrategyForAppFolder(options) {
6
- return new Map([
7
- ...migrationStrategyForComponentClasses(options),
8
- ...migrationStrategyForComponentStylesheets(options),
9
- ...migrationStrategyForComponentTemplates(options),
10
- ]);
5
+ return new Map([
6
+ ...migrationStrategyForComponentClasses(options),
7
+ ...migrationStrategyForComponentStylesheets(options),
8
+ ...migrationStrategyForComponentTemplates(options),
9
+ ]);
11
10
  }
@@ -0,0 +1,24 @@
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';
7
+ export function migrateEmberAddon(codemodOptions) {
8
+ const options = createOptions(codemodOptions);
9
+ const migrationStrategyAddon = migrationStrategyForAddonFolder(options);
10
+ const migrationStrategyApp = migrationStrategyForAppFolder(options);
11
+ const migrationStrategyTests = migrationStrategyForTestsFolder(options);
12
+ if (options.testRun) {
13
+ console.log({
14
+ migrationStrategyAddon,
15
+ migrationStrategyApp,
16
+ migrationStrategyTests,
17
+ });
18
+ return;
19
+ }
20
+ moveFiles(migrationStrategyAddon, options);
21
+ moveFiles(migrationStrategyApp, options);
22
+ moveFiles(migrationStrategyTests, options);
23
+ updatePathsInAppFolder(migrationStrategyApp, options);
24
+ }
@@ -0,0 +1,15 @@
1
+ import { readPackageJson } from '@codemod-utils/json';
2
+ function analyzePackageJson(codemodOptions) {
3
+ const packageJson = readPackageJson(codemodOptions);
4
+ return packageJson.name;
5
+ }
6
+ export function createOptions(codemodOptions) {
7
+ const projectName = analyzePackageJson(codemodOptions);
8
+ return {
9
+ podPath: codemodOptions.podPath,
10
+ projectName,
11
+ projectRoot: codemodOptions.projectRoot,
12
+ projectType: codemodOptions.projectType,
13
+ testRun: codemodOptions.testRun,
14
+ };
15
+ }
@@ -0,0 +1,19 @@
1
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
2
+ export function migrationStrategyForComponents(options) {
3
+ const { projectRoot } = options;
4
+ const filePaths = findFiles('tests/integration/components/**/component-test.{js,ts}', {
5
+ projectRoot,
6
+ });
7
+ return filePaths.map((oldFilePath) => {
8
+ const newFilePath = renamePathByFile(oldFilePath, {
9
+ find: {
10
+ directory: 'tests/integration/components',
11
+ file: 'component-test',
12
+ },
13
+ replace: (key) => {
14
+ return `tests/integration/components/${key}-test`;
15
+ },
16
+ });
17
+ return [oldFilePath, newFilePath];
18
+ });
19
+ }
@@ -1,5 +1,4 @@
1
1
  import { migrationStrategyForComponents } from './components.js';
2
-
3
2
  export function migrationStrategyForTestsFolder(options) {
4
- return new Map([...migrationStrategyForComponents(options)]);
3
+ return new Map([...migrationStrategyForComponents(options)]);
5
4
  }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForComponentClasses(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('app', podPath, 'components', '**', 'component.{d.ts,js,ts}'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('app', podPath, 'components'),
12
+ file: 'component',
13
+ },
14
+ replace: (key) => {
15
+ return `app/components/${key}`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForComponentStylesheets(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('app', podPath, 'components', '**', 'styles.{css,scss}'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('app', podPath, 'components'),
12
+ file: 'styles',
13
+ },
14
+ replace: (key) => {
15
+ return `app/components/${key}`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForComponentTemplates(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('app', podPath, 'components', '**', 'template.hbs'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('app', podPath, 'components'),
12
+ file: 'template',
13
+ },
14
+ replace: (key) => {
15
+ return `app/components/${key}`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -9,19 +9,18 @@ import { migrationStrategyForRouteSerializers } from './route-serializers.js';
9
9
  import { migrationStrategyForRouteStylesheets } from './route-stylesheets.js';
10
10
  import { migrationStrategyForRouteTemplates } from './route-templates.js';
11
11
  import { migrationStrategyForServices } from './services.js';
12
-
13
12
  export function migrationStrategyForAppFolder(options) {
14
- return new Map([
15
- ...migrationStrategyForComponentClasses(options),
16
- ...migrationStrategyForComponentStylesheets(options),
17
- ...migrationStrategyForComponentTemplates(options),
18
- ...migrationStrategyForRouteAdapters(options),
19
- ...migrationStrategyForRouteControllers(options),
20
- ...migrationStrategyForRouteModels(options),
21
- ...migrationStrategyForRouteRoutes(options),
22
- ...migrationStrategyForRouteSerializers(options),
23
- ...migrationStrategyForRouteStylesheets(options),
24
- ...migrationStrategyForRouteTemplates(options),
25
- ...migrationStrategyForServices(options),
26
- ]);
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
+ ]);
27
26
  }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForRouteAdapters(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('app', podPath, '**', 'adapter.{js,ts}'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('app', podPath),
12
+ file: 'adapter',
13
+ },
14
+ replace: (key) => {
15
+ return `app/adapters/${key}`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForRouteControllers(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('app', podPath, '**', 'controller.{js,ts}'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('app', podPath),
12
+ file: 'controller',
13
+ },
14
+ replace: (key) => {
15
+ return `app/controllers/${key}`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForRouteModels(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('app', podPath, '**', 'model.{js,ts}'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('app', podPath),
12
+ file: 'model',
13
+ },
14
+ replace: (key) => {
15
+ return `app/models/${key}`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForRouteRoutes(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('app', podPath, '**', 'route.{js,ts}'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('app', podPath),
12
+ file: 'route',
13
+ },
14
+ replace: (key) => {
15
+ return `app/routes/${key}`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForRouteSerializers(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('app', podPath, '**', 'serializer.{js,ts}'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('app', podPath),
12
+ file: 'serializer',
13
+ },
14
+ replace: (key) => {
15
+ return `app/serializers/${key}`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForRouteStylesheets(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('app', podPath, '!(components)', '**', 'styles.{css,scss}'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('app', podPath),
12
+ file: 'styles',
13
+ },
14
+ replace: (key) => {
15
+ return `app/styles/${key}`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForRouteTemplates(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('app', podPath, '!(components)', '**', 'template.hbs'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('app', podPath),
12
+ file: 'template',
13
+ },
14
+ replace: (key) => {
15
+ return `app/templates/${key}`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForServices(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('app', podPath, '**', 'service.{js,ts}'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('app', podPath),
12
+ file: 'service',
13
+ },
14
+ replace: (key) => {
15
+ return `app/services/${key}`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -0,0 +1,18 @@
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';
5
+ export function migrateEmberApp(codemodOptions) {
6
+ const options = createOptions(codemodOptions);
7
+ const migrationStrategyApp = migrationStrategyForAppFolder(options);
8
+ const migrationStrategyTests = migrationStrategyForTestsFolder(options);
9
+ if (options.testRun) {
10
+ console.log({
11
+ migrationStrategyApp,
12
+ migrationStrategyTests,
13
+ });
14
+ return;
15
+ }
16
+ moveFiles(migrationStrategyApp, options);
17
+ moveFiles(migrationStrategyTests, options);
18
+ }
@@ -0,0 +1,15 @@
1
+ import { readPackageJson } from '@codemod-utils/json';
2
+ function analyzePackageJson(codemodOptions) {
3
+ const packageJson = readPackageJson(codemodOptions);
4
+ return packageJson.name;
5
+ }
6
+ export function createOptions(codemodOptions) {
7
+ const projectName = analyzePackageJson(codemodOptions);
8
+ return {
9
+ podPath: codemodOptions.podPath,
10
+ projectName,
11
+ projectRoot: codemodOptions.projectRoot,
12
+ projectType: codemodOptions.projectType,
13
+ testRun: codemodOptions.testRun,
14
+ };
15
+ }
@@ -0,0 +1,20 @@
1
+ import { join } from 'node:path';
2
+ import { findFiles, renamePathByFile } from '@codemod-utils/files';
3
+ export function migrationStrategyForComponents(options) {
4
+ const { podPath, projectRoot } = options;
5
+ const filePaths = findFiles(join('tests/integration', podPath, 'components', '**', 'component-test.{js,ts}'), {
6
+ projectRoot,
7
+ });
8
+ return filePaths.map((oldFilePath) => {
9
+ const newFilePath = renamePathByFile(oldFilePath, {
10
+ find: {
11
+ directory: join('tests/integration', podPath, 'components'),
12
+ file: 'component-test',
13
+ },
14
+ replace: (key) => {
15
+ return `tests/integration/components/${key}-test`;
16
+ },
17
+ });
18
+ return [oldFilePath, newFilePath];
19
+ });
20
+ }
@@ -2,12 +2,11 @@ import { migrationStrategyForComponents } from './components.js';
2
2
  import { migrationStrategyForRouteControllers } from './route-controllers.js';
3
3
  import { migrationStrategyForRouteRoutes } from './route-routes.js';
4
4
  import { migrationStrategyForServices } from './services.js';
5
-
6
5
  export function migrationStrategyForTestsFolder(options) {
7
- return new Map([
8
- ...migrationStrategyForComponents(options),
9
- ...migrationStrategyForRouteControllers(options),
10
- ...migrationStrategyForRouteRoutes(options),
11
- ...migrationStrategyForServices(options),
12
- ]);
6
+ return new Map([
7
+ ...migrationStrategyForComponents(options),
8
+ ...migrationStrategyForRouteControllers(options),
9
+ ...migrationStrategyForRouteRoutes(options),
10
+ ...migrationStrategyForServices(options),
11
+ ]);
13
12
  }