ember-codemod-pod-to-octane 1.0.0 → 1.0.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 (42) hide show
  1. package/LICENSE.md +1 -1
  2. package/package.json +24 -24
  3. package/src/migration/ember-addon/addon/component-classes.js +4 -4
  4. package/src/migration/ember-addon/addon/component-stylesheets.js +3 -3
  5. package/src/migration/ember-addon/addon/component-templates.js +2 -2
  6. package/src/migration/ember-addon/app/component-classes.js +2 -2
  7. package/src/migration/ember-addon/app/component-stylesheets.js +2 -2
  8. package/src/migration/ember-addon/app/component-templates.js +2 -2
  9. package/src/migration/ember-addon/index.js +1 -1
  10. package/src/migration/ember-addon/tests/components.js +3 -3
  11. package/src/migration/ember-app/app/component-classes.js +4 -4
  12. package/src/migration/ember-app/app/component-stylesheets.js +3 -3
  13. package/src/migration/ember-app/app/component-templates.js +2 -2
  14. package/src/migration/ember-app/app/route-adapters.js +3 -3
  15. package/src/migration/ember-app/app/route-controllers.js +3 -3
  16. package/src/migration/ember-app/app/route-models.js +3 -3
  17. package/src/migration/ember-app/app/route-routes.js +3 -3
  18. package/src/migration/ember-app/app/route-serializers.js +3 -3
  19. package/src/migration/ember-app/app/route-stylesheets.js +3 -3
  20. package/src/migration/ember-app/app/route-templates.js +2 -2
  21. package/src/migration/ember-app/app/services.js +3 -3
  22. package/src/migration/ember-app/index.js +1 -1
  23. package/src/migration/ember-app/tests/components.js +3 -3
  24. package/src/migration/ember-app/tests/route-controllers.js +5 -5
  25. package/src/migration/ember-app/tests/route-routes.js +5 -5
  26. package/src/migration/ember-app/tests/services.js +3 -3
  27. package/src/migration/ember-engine/addon/component-classes.js +4 -4
  28. package/src/migration/ember-engine/addon/component-stylesheets.js +3 -3
  29. package/src/migration/ember-engine/addon/component-templates.js +2 -2
  30. package/src/migration/ember-engine/addon/route-controllers.js +3 -3
  31. package/src/migration/ember-engine/addon/route-routes.js +3 -3
  32. package/src/migration/ember-engine/addon/route-stylesheets.js +3 -3
  33. package/src/migration/ember-engine/addon/route-templates.js +2 -2
  34. package/src/migration/ember-engine/index.js +1 -1
  35. package/src/migration/ember-engine/tests/components.js +3 -3
  36. package/src/migration/ember-engine/tests/route-controllers.js +5 -5
  37. package/src/migration/ember-engine/tests/route-routes.js +5 -5
  38. package/src/utils/{map-paths.js → files/map-file-path.js} +4 -2
  39. package/src/utils/files/move-files.js +22 -0
  40. package/src/utils/files/remove-directory-if-empty.js +19 -0
  41. package/src/utils/files.js +3 -0
  42. package/src/utils/move-files.js +0 -44
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2022 Isaac J. Lee
3
+ Copyright (c) 2023 Isaac J. Lee
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-codemod-pod-to-octane",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Codemod to un-pod Ember apps, addons, and engines",
5
5
  "keywords": [
6
6
  "ember-codemod",
@@ -13,50 +13,50 @@
13
13
  },
14
14
  "license": "MIT",
15
15
  "author": "Isaac J. Lee",
16
- "main": "src/index.js",
17
16
  "type": "module",
17
+ "main": "src/index.js",
18
18
  "bin": "./bin/ember-codemod-pod-to-octane.js",
19
+ "directories": {
20
+ "test": "tests"
21
+ },
19
22
  "files": [
20
23
  "bin/",
21
24
  "src/"
22
25
  ],
23
- "directories": {
24
- "test": "tests"
25
- },
26
26
  "scripts": {
27
27
  "changelog": "lerna-changelog",
28
28
  "lint": "eslint . --cache --ext=.cjs,.js",
29
- "lint:fix": "eslint . --fix",
29
+ "lint:fix": "eslint . --ext=.cjs,.js --fix",
30
30
  "start": "node ./src/index.js",
31
31
  "test": "mt tests --quiet"
32
32
  },
33
- "changelog": {
34
- "labels": {
35
- "breaking": "Breaking Change",
36
- "bug": "Bug Fix",
37
- "enhance: code": "Enhancement",
38
- "enhance: dependency": "Internal",
39
- "enhance: documentation": "Documentation",
40
- "user feedback": "User Feedback"
41
- }
42
- },
43
33
  "dependencies": {
44
- "@babel/core": "^7.19.6",
34
+ "@babel/core": "^7.20.12",
45
35
  "@babel/eslint-parser": "^7.19.1",
46
- "glob": "^8.0.3",
47
- "yargs": "^17.6.0"
36
+ "glob": "^8.1.0",
37
+ "yargs": "^17.6.2"
48
38
  },
49
39
  "devDependencies": {
50
40
  "@sondr3/minitest": "^0.1.1",
51
- "eslint": "^8.26.0",
52
- "eslint-config-prettier": "^8.5.0",
41
+ "eslint": "^8.32.0",
42
+ "eslint-config-prettier": "^8.6.0",
53
43
  "eslint-plugin-prettier": "^4.2.1",
54
- "eslint-plugin-simple-import-sort": "^8.0.0",
55
- "fixturify": "^2.1.1",
44
+ "eslint-plugin-simple-import-sort": "^9.0.0",
45
+ "fixturify": "^3.0.0",
56
46
  "lerna-changelog": "^2.2.0",
57
- "prettier": "^2.7.1"
47
+ "prettier": "^2.8.3"
58
48
  },
59
49
  "engines": {
60
50
  "node": ">= 16"
51
+ },
52
+ "changelog": {
53
+ "labels": {
54
+ "breaking": "Breaking Change",
55
+ "bug": "Bug Fix",
56
+ "enhance: code": "Enhancement",
57
+ "enhance: dependency": "Internal",
58
+ "enhance: documentation": "Documentation",
59
+ "user feedback": "User Feedback"
60
+ }
61
61
  }
62
62
  }
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForComponentClasses(options) {
6
6
  const { projectRoot } = options;
@@ -11,7 +11,7 @@ export function migrationStrategyForComponentClasses(options) {
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
13
  if (oldPath.endsWith('.d.ts')) {
14
- return mapPaths(oldPath, {
14
+ return mapFilePath(oldPath, {
15
15
  find: {
16
16
  directory: 'addon/components',
17
17
  file: 'component.d.ts',
@@ -23,7 +23,7 @@ export function migrationStrategyForComponentClasses(options) {
23
23
  }
24
24
 
25
25
  if (oldPath.endsWith('.ts')) {
26
- return mapPaths(oldPath, {
26
+ return mapFilePath(oldPath, {
27
27
  find: {
28
28
  directory: 'addon/components',
29
29
  file: 'component.ts',
@@ -34,7 +34,7 @@ export function migrationStrategyForComponentClasses(options) {
34
34
  });
35
35
  }
36
36
 
37
- return mapPaths(oldPath, {
37
+ return mapFilePath(oldPath, {
38
38
  find: {
39
39
  directory: 'addon/components',
40
40
  file: 'component.js',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForComponentStylesheets(options) {
6
6
  const { projectRoot } = options;
@@ -11,7 +11,7 @@ export function migrationStrategyForComponentStylesheets(options) {
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
13
  if (oldPath.endsWith('.scss')) {
14
- return mapPaths(oldPath, {
14
+ return mapFilePath(oldPath, {
15
15
  find: {
16
16
  directory: 'addon/components',
17
17
  file: 'styles.scss',
@@ -22,7 +22,7 @@ export function migrationStrategyForComponentStylesheets(options) {
22
22
  });
23
23
  }
24
24
 
25
- return mapPaths(oldPath, {
25
+ return mapFilePath(oldPath, {
26
26
  find: {
27
27
  directory: 'addon/components',
28
28
  file: 'styles.css',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForComponentTemplates(options) {
6
6
  const { projectRoot } = options;
@@ -10,7 +10,7 @@ export function migrationStrategyForComponentTemplates(options) {
10
10
  });
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
- return mapPaths(oldPath, {
13
+ return mapFilePath(oldPath, {
14
14
  find: {
15
15
  directory: 'addon/components',
16
16
  file: 'template.hbs',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForComponentClasses(options) {
6
6
  const { projectRoot } = options;
@@ -10,7 +10,7 @@ export function migrationStrategyForComponentClasses(options) {
10
10
  });
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
- return mapPaths(oldPath, {
13
+ return mapFilePath(oldPath, {
14
14
  find: {
15
15
  directory: 'app/components',
16
16
  file: 'component.js',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForComponentStylesheets(options) {
6
6
  const { projectRoot } = options;
@@ -10,7 +10,7 @@ export function migrationStrategyForComponentStylesheets(options) {
10
10
  });
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
- return mapPaths(oldPath, {
13
+ return mapFilePath(oldPath, {
14
14
  find: {
15
15
  directory: 'app/components',
16
16
  file: 'styles.js',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForComponentTemplates(options) {
6
6
  const { projectRoot } = options;
@@ -10,7 +10,7 @@ export function migrationStrategyForComponentTemplates(options) {
10
10
  });
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
- return mapPaths(oldPath, {
13
+ return mapFilePath(oldPath, {
14
14
  find: {
15
15
  directory: 'app/components',
16
16
  file: 'template.js',
@@ -1,5 +1,5 @@
1
1
  import { updatePaths } from '../../utils/ember-addon/app/components.js';
2
- import { moveFiles } from '../../utils/move-files.js';
2
+ import { moveFiles } from '../../utils/files.js';
3
3
  import { migrationStrategyForAddonFolder } from './addon/index.js';
4
4
  import { migrationStrategyForAppFolder } from './app/index.js';
5
5
  import { migrationStrategyForTestsFolder } from './tests/index.js';
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForComponents(options) {
6
6
  const { projectRoot } = options;
@@ -14,7 +14,7 @@ export function migrationStrategyForComponents(options) {
14
14
 
15
15
  return oldPaths.map((oldPath) => {
16
16
  if (oldPath.endsWith('.ts')) {
17
- return mapPaths(oldPath, {
17
+ return mapFilePath(oldPath, {
18
18
  find: {
19
19
  directory: 'tests/integration/components',
20
20
  file: 'component-test.ts',
@@ -25,7 +25,7 @@ export function migrationStrategyForComponents(options) {
25
25
  });
26
26
  }
27
27
 
28
- return mapPaths(oldPath, {
28
+ return mapFilePath(oldPath, {
29
29
  find: {
30
30
  directory: 'tests/integration/components',
31
31
  file: 'component-test.js',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForComponentClasses(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -16,7 +16,7 @@ export function migrationStrategyForComponentClasses(options) {
16
16
 
17
17
  return oldPaths.map((oldPath) => {
18
18
  if (oldPath.endsWith('.d.ts')) {
19
- return mapPaths(oldPath, {
19
+ return mapFilePath(oldPath, {
20
20
  find: {
21
21
  directory: join('app', podPath, 'components'),
22
22
  file: 'component.d.ts',
@@ -28,7 +28,7 @@ export function migrationStrategyForComponentClasses(options) {
28
28
  }
29
29
 
30
30
  if (oldPath.endsWith('.ts')) {
31
- return mapPaths(oldPath, {
31
+ return mapFilePath(oldPath, {
32
32
  find: {
33
33
  directory: join('app', podPath, 'components'),
34
34
  file: 'component.ts',
@@ -39,7 +39,7 @@ export function migrationStrategyForComponentClasses(options) {
39
39
  });
40
40
  }
41
41
 
42
- return mapPaths(oldPath, {
42
+ return mapFilePath(oldPath, {
43
43
  find: {
44
44
  directory: join('app', podPath, 'components'),
45
45
  file: 'component.js',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForComponentStylesheets(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -16,7 +16,7 @@ export function migrationStrategyForComponentStylesheets(options) {
16
16
 
17
17
  return oldPaths.map((oldPath) => {
18
18
  if (oldPath.endsWith('.scss')) {
19
- return mapPaths(oldPath, {
19
+ return mapFilePath(oldPath, {
20
20
  find: {
21
21
  directory: join('app', podPath, 'components'),
22
22
  file: 'styles.scss',
@@ -27,7 +27,7 @@ export function migrationStrategyForComponentStylesheets(options) {
27
27
  });
28
28
  }
29
29
 
30
- return mapPaths(oldPath, {
30
+ return mapFilePath(oldPath, {
31
31
  find: {
32
32
  directory: join('app', podPath, 'components'),
33
33
  file: 'styles.css',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForComponentTemplates(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -15,7 +15,7 @@ export function migrationStrategyForComponentTemplates(options) {
15
15
  );
16
16
 
17
17
  return oldPaths.map((oldPath) => {
18
- return mapPaths(oldPath, {
18
+ return mapFilePath(oldPath, {
19
19
  find: {
20
20
  directory: join('app', podPath, 'components'),
21
21
  file: 'template.hbs',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForRouteAdapters(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -13,7 +13,7 @@ export function migrationStrategyForRouteAdapters(options) {
13
13
 
14
14
  return oldPaths.map((oldPath) => {
15
15
  if (oldPath.endsWith('.ts')) {
16
- return mapPaths(oldPath, {
16
+ return mapFilePath(oldPath, {
17
17
  find: {
18
18
  directory: join('app', podPath),
19
19
  file: 'adapter.ts',
@@ -24,7 +24,7 @@ export function migrationStrategyForRouteAdapters(options) {
24
24
  });
25
25
  }
26
26
 
27
- return mapPaths(oldPath, {
27
+ return mapFilePath(oldPath, {
28
28
  find: {
29
29
  directory: join('app', podPath),
30
30
  file: 'adapter.js',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForRouteControllers(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -13,7 +13,7 @@ export function migrationStrategyForRouteControllers(options) {
13
13
 
14
14
  return oldPaths.map((oldPath) => {
15
15
  if (oldPath.endsWith('.ts')) {
16
- return mapPaths(oldPath, {
16
+ return mapFilePath(oldPath, {
17
17
  find: {
18
18
  directory: join('app', podPath),
19
19
  file: 'controller.ts',
@@ -24,7 +24,7 @@ export function migrationStrategyForRouteControllers(options) {
24
24
  });
25
25
  }
26
26
 
27
- return mapPaths(oldPath, {
27
+ return mapFilePath(oldPath, {
28
28
  find: {
29
29
  directory: join('app', podPath),
30
30
  file: 'controller.js',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForRouteModels(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -13,7 +13,7 @@ export function migrationStrategyForRouteModels(options) {
13
13
 
14
14
  return oldPaths.map((oldPath) => {
15
15
  if (oldPath.endsWith('.ts')) {
16
- return mapPaths(oldPath, {
16
+ return mapFilePath(oldPath, {
17
17
  find: {
18
18
  directory: join('app', podPath),
19
19
  file: 'model.ts',
@@ -24,7 +24,7 @@ export function migrationStrategyForRouteModels(options) {
24
24
  });
25
25
  }
26
26
 
27
- return mapPaths(oldPath, {
27
+ return mapFilePath(oldPath, {
28
28
  find: {
29
29
  directory: join('app', podPath),
30
30
  file: 'model.js',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForRouteRoutes(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -13,7 +13,7 @@ export function migrationStrategyForRouteRoutes(options) {
13
13
 
14
14
  return oldPaths.map((oldPath) => {
15
15
  if (oldPath.endsWith('.ts')) {
16
- return mapPaths(oldPath, {
16
+ return mapFilePath(oldPath, {
17
17
  find: {
18
18
  directory: join('app', podPath),
19
19
  file: 'route.ts',
@@ -24,7 +24,7 @@ export function migrationStrategyForRouteRoutes(options) {
24
24
  });
25
25
  }
26
26
 
27
- return mapPaths(oldPath, {
27
+ return mapFilePath(oldPath, {
28
28
  find: {
29
29
  directory: join('app', podPath),
30
30
  file: 'route.js',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForRouteSerializers(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -13,7 +13,7 @@ export function migrationStrategyForRouteSerializers(options) {
13
13
 
14
14
  return oldPaths.map((oldPath) => {
15
15
  if (oldPath.endsWith('.ts')) {
16
- return mapPaths(oldPath, {
16
+ return mapFilePath(oldPath, {
17
17
  find: {
18
18
  directory: join('app', podPath),
19
19
  file: 'serializer.ts',
@@ -24,7 +24,7 @@ export function migrationStrategyForRouteSerializers(options) {
24
24
  });
25
25
  }
26
26
 
27
- return mapPaths(oldPath, {
27
+ return mapFilePath(oldPath, {
28
28
  find: {
29
29
  directory: join('app', podPath),
30
30
  file: 'serializer.js',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForRouteStylesheets(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -16,7 +16,7 @@ export function migrationStrategyForRouteStylesheets(options) {
16
16
 
17
17
  return oldPaths.map((oldPath) => {
18
18
  if (oldPath.endsWith('.scss')) {
19
- return mapPaths(oldPath, {
19
+ return mapFilePath(oldPath, {
20
20
  find: {
21
21
  directory: join('app', podPath),
22
22
  file: 'styles.scss',
@@ -27,7 +27,7 @@ export function migrationStrategyForRouteStylesheets(options) {
27
27
  });
28
28
  }
29
29
 
30
- return mapPaths(oldPath, {
30
+ return mapFilePath(oldPath, {
31
31
  find: {
32
32
  directory: join('app', podPath),
33
33
  file: 'styles.css',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForRouteTemplates(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -15,7 +15,7 @@ export function migrationStrategyForRouteTemplates(options) {
15
15
  );
16
16
 
17
17
  return oldPaths.map((oldPath) => {
18
- return mapPaths(oldPath, {
18
+ return mapFilePath(oldPath, {
19
19
  find: {
20
20
  directory: join('app', podPath),
21
21
  file: 'template.hbs',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForServices(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -13,7 +13,7 @@ export function migrationStrategyForServices(options) {
13
13
 
14
14
  return oldPaths.map((oldPath) => {
15
15
  if (oldPath.endsWith('.ts')) {
16
- return mapPaths(oldPath, {
16
+ return mapFilePath(oldPath, {
17
17
  find: {
18
18
  directory: join('app', podPath),
19
19
  file: 'service.ts',
@@ -24,7 +24,7 @@ export function migrationStrategyForServices(options) {
24
24
  });
25
25
  }
26
26
 
27
- return mapPaths(oldPath, {
27
+ return mapFilePath(oldPath, {
28
28
  find: {
29
29
  directory: join('app', podPath),
30
30
  file: 'service.js',
@@ -1,4 +1,4 @@
1
- import { moveFiles } from '../../utils/move-files.js';
1
+ import { moveFiles } from '../../utils/files.js';
2
2
  import { migrationStrategyForAppFolder } from './app/index.js';
3
3
  import { migrationStrategyForTestsFolder } from './tests/index.js';
4
4
 
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForComponents(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -22,7 +22,7 @@ export function migrationStrategyForComponents(options) {
22
22
 
23
23
  return oldPaths.map((oldPath) => {
24
24
  if (oldPath.endsWith('.ts')) {
25
- return mapPaths(oldPath, {
25
+ return mapFilePath(oldPath, {
26
26
  find: {
27
27
  directory: join('tests/integration', podPath, 'components'),
28
28
  file: 'component-test.ts',
@@ -33,7 +33,7 @@ export function migrationStrategyForComponents(options) {
33
33
  });
34
34
  }
35
35
 
36
- return mapPaths(oldPath, {
36
+ return mapFilePath(oldPath, {
37
37
  find: {
38
38
  directory: join('tests/integration', podPath, 'components'),
39
39
  file: 'component-test.js',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForRouteControllers(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -25,7 +25,7 @@ export function migrationStrategyForRouteControllers(options) {
25
25
 
26
26
  const newPaths1 = oldPaths1.map((oldPath) => {
27
27
  if (oldPath.endsWith('.ts')) {
28
- return mapPaths(oldPath, {
28
+ return mapFilePath(oldPath, {
29
29
  find: {
30
30
  directory: join('tests/unit', podPath),
31
31
  file: 'controller-test.ts',
@@ -36,7 +36,7 @@ export function migrationStrategyForRouteControllers(options) {
36
36
  });
37
37
  }
38
38
 
39
- return mapPaths(oldPath, {
39
+ return mapFilePath(oldPath, {
40
40
  find: {
41
41
  directory: join('tests/unit', podPath),
42
42
  file: 'controller-test.js',
@@ -59,7 +59,7 @@ export function migrationStrategyForRouteControllers(options) {
59
59
 
60
60
  const newPaths2 = oldPaths2.map((oldPath) => {
61
61
  if (oldPath.endsWith('.ts')) {
62
- return mapPaths(oldPath, {
62
+ return mapFilePath(oldPath, {
63
63
  find: {
64
64
  directory: join('tests/unit', podPath, 'controllers'),
65
65
  file: 'controller-test.ts',
@@ -70,7 +70,7 @@ export function migrationStrategyForRouteControllers(options) {
70
70
  });
71
71
  }
72
72
 
73
- return mapPaths(oldPath, {
73
+ return mapFilePath(oldPath, {
74
74
  find: {
75
75
  directory: join('tests/unit', podPath, 'controllers'),
76
76
  file: 'controller-test.js',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForRouteRoutes(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -19,7 +19,7 @@ export function migrationStrategyForRouteRoutes(options) {
19
19
 
20
20
  const newPaths1 = oldPaths1.map((oldPath) => {
21
21
  if (oldPath.endsWith('.ts')) {
22
- return mapPaths(oldPath, {
22
+ return mapFilePath(oldPath, {
23
23
  find: {
24
24
  directory: join('tests/unit', podPath),
25
25
  file: 'route-test.ts',
@@ -30,7 +30,7 @@ export function migrationStrategyForRouteRoutes(options) {
30
30
  });
31
31
  }
32
32
 
33
- return mapPaths(oldPath, {
33
+ return mapFilePath(oldPath, {
34
34
  find: {
35
35
  directory: join('tests/unit', podPath),
36
36
  file: 'route-test.js',
@@ -53,7 +53,7 @@ export function migrationStrategyForRouteRoutes(options) {
53
53
 
54
54
  const newPaths2 = oldPaths2.map((oldPath) => {
55
55
  if (oldPath.endsWith('.ts')) {
56
- return mapPaths(oldPath, {
56
+ return mapFilePath(oldPath, {
57
57
  find: {
58
58
  directory: join('tests/unit', podPath, 'routes'),
59
59
  file: 'route-test.ts',
@@ -64,7 +64,7 @@ export function migrationStrategyForRouteRoutes(options) {
64
64
  });
65
65
  }
66
66
 
67
- return mapPaths(oldPath, {
67
+ return mapFilePath(oldPath, {
68
68
  find: {
69
69
  directory: join('tests/unit', podPath, 'routes'),
70
70
  file: 'route-test.js',
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
 
3
3
  import glob from 'glob';
4
4
 
5
- import { mapPaths } from '../../../utils/map-paths.js';
5
+ import { mapFilePath } from '../../../utils/files.js';
6
6
 
7
7
  export function migrationStrategyForServices(options) {
8
8
  const { podPath, projectRoot } = options;
@@ -16,7 +16,7 @@ export function migrationStrategyForServices(options) {
16
16
 
17
17
  return oldPaths.map((oldPath) => {
18
18
  if (oldPath.endsWith('.ts')) {
19
- return mapPaths(oldPath, {
19
+ return mapFilePath(oldPath, {
20
20
  find: {
21
21
  directory: join('tests/unit', podPath),
22
22
  file: 'service-test.ts',
@@ -27,7 +27,7 @@ export function migrationStrategyForServices(options) {
27
27
  });
28
28
  }
29
29
 
30
- return mapPaths(oldPath, {
30
+ return mapFilePath(oldPath, {
31
31
  find: {
32
32
  directory: join('tests/unit', podPath),
33
33
  file: 'service-test.js',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForComponentClasses(options) {
6
6
  const { projectRoot } = options;
@@ -11,7 +11,7 @@ export function migrationStrategyForComponentClasses(options) {
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
13
  if (oldPath.endsWith('.d.ts')) {
14
- return mapPaths(oldPath, {
14
+ return mapFilePath(oldPath, {
15
15
  find: {
16
16
  directory: 'addon/components',
17
17
  file: 'component.d.ts',
@@ -23,7 +23,7 @@ export function migrationStrategyForComponentClasses(options) {
23
23
  }
24
24
 
25
25
  if (oldPath.endsWith('.ts')) {
26
- return mapPaths(oldPath, {
26
+ return mapFilePath(oldPath, {
27
27
  find: {
28
28
  directory: 'addon/components',
29
29
  file: 'component.ts',
@@ -34,7 +34,7 @@ export function migrationStrategyForComponentClasses(options) {
34
34
  });
35
35
  }
36
36
 
37
- return mapPaths(oldPath, {
37
+ return mapFilePath(oldPath, {
38
38
  find: {
39
39
  directory: 'addon/components',
40
40
  file: 'component.js',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForComponentStylesheets(options) {
6
6
  const { projectRoot } = options;
@@ -11,7 +11,7 @@ export function migrationStrategyForComponentStylesheets(options) {
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
13
  if (oldPath.endsWith('.scss')) {
14
- return mapPaths(oldPath, {
14
+ return mapFilePath(oldPath, {
15
15
  find: {
16
16
  directory: 'addon/components',
17
17
  file: 'styles.scss',
@@ -22,7 +22,7 @@ export function migrationStrategyForComponentStylesheets(options) {
22
22
  });
23
23
  }
24
24
 
25
- return mapPaths(oldPath, {
25
+ return mapFilePath(oldPath, {
26
26
  find: {
27
27
  directory: 'addon/components',
28
28
  file: 'styles.css',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForComponentTemplates(options) {
6
6
  const { projectRoot } = options;
@@ -10,7 +10,7 @@ export function migrationStrategyForComponentTemplates(options) {
10
10
  });
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
- return mapPaths(oldPath, {
13
+ return mapFilePath(oldPath, {
14
14
  find: {
15
15
  directory: 'addon/components',
16
16
  file: 'template.hbs',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForRouteControllers(options) {
6
6
  const { projectRoot } = options;
@@ -11,7 +11,7 @@ export function migrationStrategyForRouteControllers(options) {
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
13
  if (oldPath.endsWith('.ts')) {
14
- return mapPaths(oldPath, {
14
+ return mapFilePath(oldPath, {
15
15
  find: {
16
16
  directory: 'addon',
17
17
  file: 'controller.ts',
@@ -22,7 +22,7 @@ export function migrationStrategyForRouteControllers(options) {
22
22
  });
23
23
  }
24
24
 
25
- return mapPaths(oldPath, {
25
+ return mapFilePath(oldPath, {
26
26
  find: {
27
27
  directory: 'addon',
28
28
  file: 'controller.js',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForRouteRoutes(options) {
6
6
  const { projectRoot } = options;
@@ -11,7 +11,7 @@ export function migrationStrategyForRouteRoutes(options) {
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
13
  if (oldPath.endsWith('.ts')) {
14
- return mapPaths(oldPath, {
14
+ return mapFilePath(oldPath, {
15
15
  find: {
16
16
  directory: 'addon',
17
17
  file: 'route.ts',
@@ -22,7 +22,7 @@ export function migrationStrategyForRouteRoutes(options) {
22
22
  });
23
23
  }
24
24
 
25
- return mapPaths(oldPath, {
25
+ return mapFilePath(oldPath, {
26
26
  find: {
27
27
  directory: 'addon',
28
28
  file: 'route.js',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForRouteStylesheets(options) {
6
6
  const { projectRoot } = options;
@@ -11,7 +11,7 @@ export function migrationStrategyForRouteStylesheets(options) {
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
13
  if (oldPath.endsWith('.scss')) {
14
- return mapPaths(oldPath, {
14
+ return mapFilePath(oldPath, {
15
15
  find: {
16
16
  directory: 'addon',
17
17
  file: 'styles.scss',
@@ -22,7 +22,7 @@ export function migrationStrategyForRouteStylesheets(options) {
22
22
  });
23
23
  }
24
24
 
25
- return mapPaths(oldPath, {
25
+ return mapFilePath(oldPath, {
26
26
  find: {
27
27
  directory: 'addon',
28
28
  file: 'styles.css',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForRouteTemplates(options) {
6
6
  const { projectRoot } = options;
@@ -10,7 +10,7 @@ export function migrationStrategyForRouteTemplates(options) {
10
10
  });
11
11
 
12
12
  return oldPaths.map((oldPath) => {
13
- return mapPaths(oldPath, {
13
+ return mapFilePath(oldPath, {
14
14
  find: {
15
15
  directory: 'addon',
16
16
  file: 'template.hbs',
@@ -1,4 +1,4 @@
1
- import { moveFiles } from '../../utils/move-files.js';
1
+ import { moveFiles } from '../../utils/files.js';
2
2
  import { migrationStrategyForAddonFolder } from './addon/index.js';
3
3
  import { migrationStrategyForTestsFolder } from './tests/index.js';
4
4
 
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForComponents(options) {
6
6
  const { projectRoot } = options;
@@ -14,7 +14,7 @@ export function migrationStrategyForComponents(options) {
14
14
 
15
15
  return oldPaths.map((oldPath) => {
16
16
  if (oldPath.endsWith('.ts')) {
17
- return mapPaths(oldPath, {
17
+ return mapFilePath(oldPath, {
18
18
  find: {
19
19
  directory: 'tests/integration/components',
20
20
  file: 'component-test.ts',
@@ -25,7 +25,7 @@ export function migrationStrategyForComponents(options) {
25
25
  });
26
26
  }
27
27
 
28
- return mapPaths(oldPath, {
28
+ return mapFilePath(oldPath, {
29
29
  find: {
30
30
  directory: 'tests/integration/components',
31
31
  file: 'component-test.js',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForRouteControllers(options) {
6
6
  const { projectRoot } = options;
@@ -17,7 +17,7 @@ export function migrationStrategyForRouteControllers(options) {
17
17
 
18
18
  const newPaths1 = oldPaths1.map((oldPath) => {
19
19
  if (oldPath.endsWith('.ts')) {
20
- return mapPaths(oldPath, {
20
+ return mapFilePath(oldPath, {
21
21
  find: {
22
22
  directory: 'tests/unit',
23
23
  file: 'controller-test.ts',
@@ -28,7 +28,7 @@ export function migrationStrategyForRouteControllers(options) {
28
28
  });
29
29
  }
30
30
 
31
- return mapPaths(oldPath, {
31
+ return mapFilePath(oldPath, {
32
32
  find: {
33
33
  directory: 'tests/unit',
34
34
  file: 'controller-test.js',
@@ -51,7 +51,7 @@ export function migrationStrategyForRouteControllers(options) {
51
51
 
52
52
  const newPaths2 = oldPaths2.map((oldPath) => {
53
53
  if (oldPath.endsWith('.ts')) {
54
- return mapPaths(oldPath, {
54
+ return mapFilePath(oldPath, {
55
55
  find: {
56
56
  directory: 'tests/unit/controllers',
57
57
  file: 'controller-test.ts',
@@ -62,7 +62,7 @@ export function migrationStrategyForRouteControllers(options) {
62
62
  });
63
63
  }
64
64
 
65
- return mapPaths(oldPath, {
65
+ return mapFilePath(oldPath, {
66
66
  find: {
67
67
  directory: 'tests/unit/controllers',
68
68
  file: 'controller-test.js',
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
 
3
- import { mapPaths } from '../../../utils/map-paths.js';
3
+ import { mapFilePath } from '../../../utils/files.js';
4
4
 
5
5
  export function migrationStrategyForRouteRoutes(options) {
6
6
  const { projectRoot } = options;
@@ -14,7 +14,7 @@ export function migrationStrategyForRouteRoutes(options) {
14
14
 
15
15
  const newPaths1 = oldPaths1.map((oldPath) => {
16
16
  if (oldPath.endsWith('.ts')) {
17
- return mapPaths(oldPath, {
17
+ return mapFilePath(oldPath, {
18
18
  find: {
19
19
  directory: 'tests/unit',
20
20
  file: 'route-test.ts',
@@ -25,7 +25,7 @@ export function migrationStrategyForRouteRoutes(options) {
25
25
  });
26
26
  }
27
27
 
28
- return mapPaths(oldPath, {
28
+ return mapFilePath(oldPath, {
29
29
  find: {
30
30
  directory: 'tests/unit',
31
31
  file: 'route-test.js',
@@ -45,7 +45,7 @@ export function migrationStrategyForRouteRoutes(options) {
45
45
 
46
46
  const newPaths2 = oldPaths2.map((oldPath) => {
47
47
  if (oldPath.endsWith('.ts')) {
48
- return mapPaths(oldPath, {
48
+ return mapFilePath(oldPath, {
49
49
  find: {
50
50
  directory: 'tests/unit/routes',
51
51
  file: 'route-test.ts',
@@ -56,7 +56,7 @@ export function migrationStrategyForRouteRoutes(options) {
56
56
  });
57
57
  }
58
58
 
59
- return mapPaths(oldPath, {
59
+ return mapFilePath(oldPath, {
60
60
  find: {
61
61
  directory: 'tests/unit/routes',
62
62
  file: 'route-test.js',
@@ -1,8 +1,10 @@
1
- export function mapPaths(oldPath, { find, replace }) {
1
+ export function mapFilePath(oldPath, { find, replace }) {
2
2
  const { directory, file } = find;
3
3
 
4
4
  if (!oldPath.endsWith(file)) {
5
- return;
5
+ throw new RangeError(
6
+ `ERROR: The provided path \`${oldPath}\` does not end with \`${file}\`.\n`
7
+ );
6
8
  }
7
9
 
8
10
  const key = oldPath
@@ -0,0 +1,22 @@
1
+ import { existsSync, mkdirSync, renameSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+
4
+ import { removeDirectoryIfEmpty } from './remove-directory-if-empty.js';
5
+
6
+ export function moveFiles(pathMapping, options) {
7
+ const { projectRoot } = options;
8
+
9
+ pathMapping.forEach((newPath, oldPath) => {
10
+ const oldAbsolutePath = join(projectRoot, oldPath);
11
+
12
+ const newAbsolutePath = join(projectRoot, newPath);
13
+ const newDirectory = dirname(newAbsolutePath);
14
+
15
+ if (!existsSync(newDirectory)) {
16
+ mkdirSync(newDirectory, { recursive: true });
17
+ }
18
+
19
+ renameSync(oldAbsolutePath, newAbsolutePath);
20
+ removeDirectoryIfEmpty({ oldPath, projectRoot });
21
+ });
22
+ }
@@ -0,0 +1,19 @@
1
+ import { readdirSync, rmSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+
4
+ export function removeDirectoryIfEmpty({ oldPath, projectRoot }) {
5
+ const directories = dirname(oldPath).split('/');
6
+ const depth = directories.length;
7
+
8
+ for (let i = 0; i < depth; i++) {
9
+ const directory = join(projectRoot, ...directories);
10
+ const numFilesLeft = readdirSync(directory).length;
11
+
12
+ if (numFilesLeft > 0) {
13
+ continue;
14
+ }
15
+
16
+ rmSync(directory, { recursive: true });
17
+ directories.pop();
18
+ }
19
+ }
@@ -0,0 +1,3 @@
1
+ export * from './files/map-file-path.js';
2
+ export * from './files/move-files.js';
3
+ export * from './files/remove-directory-if-empty.js';
@@ -1,44 +0,0 @@
1
- import {
2
- existsSync,
3
- mkdirSync,
4
- readdirSync,
5
- renameSync,
6
- rmSync,
7
- } from 'node:fs';
8
- import { dirname, join } from 'node:path';
9
-
10
- function removeDirectoryIfEmpty({ oldPath, projectRoot }) {
11
- const directories = dirname(oldPath).split('/');
12
- const depth = directories.length;
13
-
14
- for (let i = 0; i < depth; i++) {
15
- const directory = join(projectRoot, ...directories);
16
- const numFilesLeft = readdirSync(directory).length;
17
-
18
- if (numFilesLeft > 0) {
19
- continue;
20
- }
21
-
22
- rmSync(directory, { recursive: true });
23
- directories.pop();
24
- }
25
- }
26
-
27
- export function moveFiles(migrationStrategy, options) {
28
- const { projectRoot } = options;
29
-
30
- migrationStrategy.forEach((newPath, oldPath) => {
31
- const oldAbsolutePath = join(projectRoot, oldPath);
32
-
33
- const newAbsolutePath = join(projectRoot, newPath);
34
- const newDirectory = dirname(newAbsolutePath);
35
-
36
- // Move file
37
- if (!existsSync(newDirectory)) {
38
- mkdirSync(newDirectory, { recursive: true });
39
- }
40
-
41
- renameSync(oldAbsolutePath, newAbsolutePath);
42
- removeDirectoryIfEmpty({ oldPath, projectRoot });
43
- });
44
- }