ember-codemod-pod-to-octane 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +10 -3
  2. package/package.json +10 -10
  3. package/src/migration/ember-addon/addon/component-classes.js +2 -4
  4. package/src/migration/ember-addon/addon/component-stylesheets.js +2 -4
  5. package/src/migration/ember-addon/addon/component-templates.js +2 -4
  6. package/src/migration/ember-addon/app/component-classes.js +2 -4
  7. package/src/migration/ember-addon/app/component-stylesheets.js +2 -4
  8. package/src/migration/ember-addon/app/component-templates.js +2 -4
  9. package/src/migration/ember-addon/steps/create-options.js +2 -2
  10. package/src/migration/ember-addon/tests/components.js +3 -5
  11. package/src/migration/ember-app/app/component-classes.js +3 -5
  12. package/src/migration/ember-app/app/component-stylesheets.js +3 -5
  13. package/src/migration/ember-app/app/component-templates.js +3 -5
  14. package/src/migration/ember-app/app/route-adapters.js +2 -4
  15. package/src/migration/ember-app/app/route-controllers.js +2 -4
  16. package/src/migration/ember-app/app/route-models.js +2 -4
  17. package/src/migration/ember-app/app/route-routes.js +2 -4
  18. package/src/migration/ember-app/app/route-serializers.js +2 -4
  19. package/src/migration/ember-app/app/route-stylesheets.js +3 -5
  20. package/src/migration/ember-app/app/route-templates.js +3 -5
  21. package/src/migration/ember-app/app/services.js +2 -4
  22. package/src/migration/ember-app/steps/create-options.js +2 -2
  23. package/src/migration/ember-app/tests/components.js +4 -6
  24. package/src/migration/ember-app/tests/route-controllers.js +6 -8
  25. package/src/migration/ember-app/tests/route-routes.js +5 -7
  26. package/src/migration/ember-app/tests/services.js +3 -5
  27. package/src/migration/ember-engine/addon/component-classes.js +2 -4
  28. package/src/migration/ember-engine/addon/component-stylesheets.js +2 -4
  29. package/src/migration/ember-engine/addon/component-templates.js +2 -4
  30. package/src/migration/ember-engine/addon/route-controllers.js +2 -4
  31. package/src/migration/ember-engine/addon/route-routes.js +2 -4
  32. package/src/migration/ember-engine/addon/route-stylesheets.js +2 -4
  33. package/src/migration/ember-engine/addon/route-templates.js +2 -4
  34. package/src/migration/ember-engine/steps/create-options.js +2 -2
  35. package/src/migration/ember-engine/steps/update-absolute-paths.js +3 -5
  36. package/src/migration/ember-engine/steps/use-absolute-paths.js +3 -5
  37. package/src/migration/ember-engine/steps/use-relative-paths.js +5 -11
  38. package/src/migration/ember-engine/tests/components.js +3 -5
  39. package/src/migration/ember-engine/tests/route-controllers.js +5 -7
  40. package/src/migration/ember-engine/tests/route-routes.js +3 -5
  41. package/src/utils/files/find-files.js +28 -0
  42. package/src/utils/files/map-file-path.js +1 -1
  43. package/src/utils/files.js +1 -0
package/README.md CHANGED
@@ -5,6 +5,12 @@
5
5
  _Codemod to un-pod Ember apps, addons, and engines_
6
6
 
7
7
 
8
+ ## Features
9
+
10
+ - Preserves your code whenever possible
11
+ - Supports [`ember-css-modules`](https://github.com/salsify/ember-css-modules)
12
+
13
+
8
14
  ## Usage
9
15
 
10
16
  Step 1. Quickly return to [default Octane](https://cli.emberjs.com/release/advanced-use/project-layouts/#classiclayout).<sup>1</sup>
@@ -35,7 +41,7 @@ npx ember-codemod-pod-to-octane --type=engine
35
41
  <details>
36
42
  <summary>Optional: Do a test run</summary>
37
43
 
38
- Pass `--test` to preview how the codemod will move files around.
44
+ Pass `--test` to preview how the codemod will move files.
39
45
 
40
46
  ```sh
41
47
  npx ember-codemod-pod-to-octane --test
@@ -116,12 +122,13 @@ cd <your/cloned/repo>
116
122
  ## Compatibility
117
123
 
118
124
  * Node.js v16 or above
119
- * [`ember-css-modules`](https://github.com/salsify/ember-css-modules)
120
125
 
121
126
 
122
127
  ## Contributing
123
128
 
124
- To provide feedback, you can reach out to me on [Discord](https://discord.gg/emberjs) at `ijlee2`. Please star this project so that I can gauge its importance to you and the Ember community. ⭐
129
+ See the [Contributing](CONTRIBUTING.md) guide for details.
130
+
131
+ If you have an open-sourced app or addon that I can use as a reference, reach out to me on [Discord](https://discord.gg/emberjs) at `ijlee2`. Please star this project so that I can gauge its importance to you and the Ember community. ⭐
125
132
 
126
133
 
127
134
  ## Credits
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "ember-codemod-pod-to-octane",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Codemod to un-pod Ember apps, addons, and engines",
5
5
  "keywords": [
6
+ "codemod",
6
7
  "ember-codemod",
7
8
  "ember-octane",
8
9
  "emberjs"
@@ -27,26 +28,25 @@
27
28
  "changelog": "lerna-changelog",
28
29
  "lint": "eslint . --cache",
29
30
  "lint:fix": "eslint . --fix",
30
- "start": "node ./src/index.js",
31
31
  "test": "mt tests --quiet"
32
32
  },
33
33
  "dependencies": {
34
- "@babel/core": "^7.21.0",
35
- "@babel/eslint-parser": "^7.19.1",
36
- "glob": "^8.1.0",
37
- "yargs": "^17.7.1"
34
+ "glob": "~10.1.0",
35
+ "yargs": "^17.7.2"
38
36
  },
39
37
  "devDependencies": {
38
+ "@babel/core": "^7.21.8",
39
+ "@babel/eslint-parser": "^7.21.8",
40
40
  "@sondr3/minitest": "^0.1.1",
41
- "eslint": "^8.34.0",
42
- "eslint-config-prettier": "^8.6.0",
41
+ "eslint": "^8.39.0",
42
+ "eslint-config-prettier": "^8.8.0",
43
43
  "eslint-plugin-import": "^2.27.5",
44
- "eslint-plugin-n": "^15.6.1",
44
+ "eslint-plugin-n": "^15.7.0",
45
45
  "eslint-plugin-prettier": "^4.2.1",
46
46
  "eslint-plugin-simple-import-sort": "^10.0.0",
47
47
  "fixturify": "^3.0.0",
48
48
  "lerna-changelog": "^2.2.0",
49
- "prettier": "^2.8.4"
49
+ "prettier": "^2.8.8"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">= 16"
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForComponentClasses(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('addon/components/**/component.{d.ts,js,ts}', {
6
+ const oldPaths = findFiles('addon/components/**/component.{d.ts,js,ts}', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForComponentStylesheets(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('addon/components/**/styles.{css,scss}', {
6
+ const oldPaths = findFiles('addon/components/**/styles.{css,scss}', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForComponentTemplates(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('addon/components/**/template.hbs', {
6
+ const oldPaths = findFiles('addon/components/**/template.hbs', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForComponentClasses(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('app/components/**/component.js', {
6
+ const oldPaths = findFiles('app/components/**/component.js', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForComponentStylesheets(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('app/components/**/styles.js', {
6
+ const oldPaths = findFiles('app/components/**/styles.js', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForComponentTemplates(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('app/components/**/template.js', {
6
+ const oldPaths = findFiles('app/components/**/template.js', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -7,7 +7,7 @@ function analyzePackageJson(codemodOptions) {
7
7
  try {
8
8
  const packageJsonFile = readFileSync(
9
9
  join(projectRoot, 'package.json'),
10
- 'utf8'
10
+ 'utf8',
11
11
  );
12
12
 
13
13
  const { name } = JSON.parse(packageJsonFile);
@@ -28,7 +28,7 @@ function analyzePackageJson(codemodOptions) {
28
28
  return name;
29
29
  } catch (e) {
30
30
  throw new SyntaxError(
31
- `ERROR: package.json is missing or is not valid. (${e.message})\n`
31
+ `ERROR: package.json is missing or is not valid. (${e.message})\n`,
32
32
  );
33
33
  }
34
34
  }
@@ -1,15 +1,13 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForComponents(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync(
6
+ const oldPaths = findFiles(
9
7
  'tests/integration/components/**/component-test.{js,ts}',
10
8
  {
11
9
  cwd: projectRoot,
12
- }
10
+ },
13
11
  );
14
12
 
15
13
  return oldPaths.map((oldPath) => {
@@ -1,17 +1,15 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForComponentClasses(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(
8
+ const oldPaths = findFiles(
11
9
  join('app', podPath, 'components', '**', 'component.{d.ts,js,ts}'),
12
10
  {
13
11
  cwd: projectRoot,
14
- }
12
+ },
15
13
  );
16
14
 
17
15
  return oldPaths.map((oldPath) => {
@@ -1,17 +1,15 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForComponentStylesheets(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(
8
+ const oldPaths = findFiles(
11
9
  join('app', podPath, 'components', '**', 'styles.{css,scss}'),
12
10
  {
13
11
  cwd: projectRoot,
14
- }
12
+ },
15
13
  );
16
14
 
17
15
  return oldPaths.map((oldPath) => {
@@ -1,17 +1,15 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForComponentTemplates(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(
8
+ const oldPaths = findFiles(
11
9
  join('app', podPath, 'components', '**', 'template.hbs'),
12
10
  {
13
11
  cwd: projectRoot,
14
- }
12
+ },
15
13
  );
16
14
 
17
15
  return oldPaths.map((oldPath) => {
@@ -1,13 +1,11 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForRouteAdapters(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(join('app', podPath, '**', 'adapter.{js,ts}'), {
8
+ const oldPaths = findFiles(join('app', podPath, '**', 'adapter.{js,ts}'), {
11
9
  cwd: projectRoot,
12
10
  });
13
11
 
@@ -1,13 +1,11 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForRouteControllers(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(join('app', podPath, '**', 'controller.{js,ts}'), {
8
+ const oldPaths = findFiles(join('app', podPath, '**', 'controller.{js,ts}'), {
11
9
  cwd: projectRoot,
12
10
  });
13
11
 
@@ -1,13 +1,11 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForRouteModels(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(join('app', podPath, '**', 'model.{js,ts}'), {
8
+ const oldPaths = findFiles(join('app', podPath, '**', 'model.{js,ts}'), {
11
9
  cwd: projectRoot,
12
10
  });
13
11
 
@@ -1,13 +1,11 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForRouteRoutes(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(join('app', podPath, '**', 'route.{js,ts}'), {
8
+ const oldPaths = findFiles(join('app', podPath, '**', 'route.{js,ts}'), {
11
9
  cwd: projectRoot,
12
10
  });
13
11
 
@@ -1,13 +1,11 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForRouteSerializers(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(join('app', podPath, '**', 'serializer.{js,ts}'), {
8
+ const oldPaths = findFiles(join('app', podPath, '**', 'serializer.{js,ts}'), {
11
9
  cwd: projectRoot,
12
10
  });
13
11
 
@@ -1,17 +1,15 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForRouteStylesheets(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(
8
+ const oldPaths = findFiles(
11
9
  join('app', podPath, '!(components)', '**', 'styles.{css,scss}'),
12
10
  {
13
11
  cwd: projectRoot,
14
- }
12
+ },
15
13
  );
16
14
 
17
15
  return oldPaths.map((oldPath) => {
@@ -1,17 +1,15 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForRouteTemplates(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(
8
+ const oldPaths = findFiles(
11
9
  join('app', podPath, '!(components)', '**', 'template.hbs'),
12
10
  {
13
11
  cwd: projectRoot,
14
- }
12
+ },
15
13
  );
16
14
 
17
15
  return oldPaths.map((oldPath) => {
@@ -1,13 +1,11 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForServices(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(join('app', podPath, '**', 'service.{js,ts}'), {
8
+ const oldPaths = findFiles(join('app', podPath, '**', 'service.{js,ts}'), {
11
9
  cwd: projectRoot,
12
10
  });
13
11
 
@@ -7,7 +7,7 @@ function analyzePackageJson(codemodOptions) {
7
7
  try {
8
8
  const packageJsonFile = readFileSync(
9
9
  join(projectRoot, 'package.json'),
10
- 'utf8'
10
+ 'utf8',
11
11
  );
12
12
 
13
13
  const { name } = JSON.parse(packageJsonFile);
@@ -28,7 +28,7 @@ function analyzePackageJson(codemodOptions) {
28
28
  return name;
29
29
  } catch (e) {
30
30
  throw new SyntaxError(
31
- `ERROR: package.json is missing or is not valid. (${e.message})\n`
31
+ `ERROR: package.json is missing or is not valid. (${e.message})\n`,
32
32
  );
33
33
  }
34
34
  }
@@ -1,23 +1,21 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForComponents(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(
8
+ const oldPaths = findFiles(
11
9
  join(
12
10
  'tests/integration',
13
11
  podPath,
14
12
  'components',
15
13
  '**',
16
- 'component-test.{js,ts}'
14
+ 'component-test.{js,ts}',
17
15
  ),
18
16
  {
19
17
  cwd: projectRoot,
20
- }
18
+ },
21
19
  );
22
20
 
23
21
  return oldPaths.map((oldPath) => {
@@ -1,8 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForRouteControllers(options) {
8
6
  const { podPath, projectRoot } = options;
@@ -10,17 +8,17 @@ export function migrationStrategyForRouteControllers(options) {
10
8
  /*
11
9
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
12
10
  */
13
- const oldPaths1 = glob.sync(
11
+ const oldPaths1 = findFiles(
14
12
  join(
15
13
  'tests/unit',
16
14
  podPath,
17
15
  '!(controllers)',
18
16
  '**',
19
- 'controller-test.{js,ts}'
17
+ 'controller-test.{js,ts}',
20
18
  ),
21
19
  {
22
20
  cwd: projectRoot,
23
- }
21
+ },
24
22
  );
25
23
 
26
24
  const newPaths1 = oldPaths1.map((oldPath) => {
@@ -50,11 +48,11 @@ export function migrationStrategyForRouteControllers(options) {
50
48
  /*
51
49
  Case 2: Passed the --pod flag to Ember CLI
52
50
  */
53
- const oldPaths2 = glob.sync(
51
+ const oldPaths2 = findFiles(
54
52
  join('tests/unit', podPath, 'controllers/**/controller-test.{js,ts}'),
55
53
  {
56
54
  cwd: projectRoot,
57
- }
55
+ },
58
56
  );
59
57
 
60
58
  const newPaths2 = oldPaths2.map((oldPath) => {
@@ -1,8 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForRouteRoutes(options) {
8
6
  const { podPath, projectRoot } = options;
@@ -10,11 +8,11 @@ export function migrationStrategyForRouteRoutes(options) {
10
8
  /*
11
9
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
12
10
  */
13
- const oldPaths1 = glob.sync(
11
+ const oldPaths1 = findFiles(
14
12
  join('tests/unit', podPath, '!(routes)', '**', 'route-test.{js,ts}'),
15
13
  {
16
14
  cwd: projectRoot,
17
- }
15
+ },
18
16
  );
19
17
 
20
18
  const newPaths1 = oldPaths1.map((oldPath) => {
@@ -44,11 +42,11 @@ export function migrationStrategyForRouteRoutes(options) {
44
42
  /*
45
43
  Case 2: Passed the --pod flag to Ember CLI
46
44
  */
47
- const oldPaths2 = glob.sync(
45
+ const oldPaths2 = findFiles(
48
46
  join('tests/unit', podPath, 'routes/**/route-test.{js,ts}'),
49
47
  {
50
48
  cwd: projectRoot,
51
- }
49
+ },
52
50
  );
53
51
 
54
52
  const newPaths2 = oldPaths2.map((oldPath) => {
@@ -1,17 +1,15 @@
1
1
  import { join } from 'node:path';
2
2
 
3
- import glob from 'glob';
4
-
5
- import { mapFilePath } from '../../../utils/files.js';
3
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
6
4
 
7
5
  export function migrationStrategyForServices(options) {
8
6
  const { podPath, projectRoot } = options;
9
7
 
10
- const oldPaths = glob.sync(
8
+ const oldPaths = findFiles(
11
9
  join('tests/unit', podPath, '!(services)', '**', 'service-test.{js,ts}'),
12
10
  {
13
11
  cwd: projectRoot,
14
- }
12
+ },
15
13
  );
16
14
 
17
15
  return oldPaths.map((oldPath) => {
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForComponentClasses(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('addon/components/**/component.{d.ts,js,ts}', {
6
+ const oldPaths = findFiles('addon/components/**/component.{d.ts,js,ts}', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForComponentStylesheets(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('addon/components/**/styles.{css,scss}', {
6
+ const oldPaths = findFiles('addon/components/**/styles.{css,scss}', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForComponentTemplates(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('addon/components/**/template.hbs', {
6
+ const oldPaths = findFiles('addon/components/**/template.hbs', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForRouteControllers(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('addon/**/controller.{js,ts}', {
6
+ const oldPaths = findFiles('addon/**/controller.{js,ts}', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForRouteRoutes(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('addon/**/route.{js,ts}', {
6
+ const oldPaths = findFiles('addon/**/route.{js,ts}', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForRouteStylesheets(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('addon/!(components)/**/styles.{css,scss}', {
6
+ const oldPaths = findFiles('addon/!(components)/**/styles.{css,scss}', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -1,11 +1,9 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForRouteTemplates(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync('addon/!(components)/**/template.hbs', {
6
+ const oldPaths = findFiles('addon/!(components)/**/template.hbs', {
9
7
  cwd: projectRoot,
10
8
  });
11
9
 
@@ -7,7 +7,7 @@ function analyzePackageJson(codemodOptions) {
7
7
  try {
8
8
  const packageJsonFile = readFileSync(
9
9
  join(projectRoot, 'package.json'),
10
- 'utf8'
10
+ 'utf8',
11
11
  );
12
12
 
13
13
  const { name } = JSON.parse(packageJsonFile);
@@ -28,7 +28,7 @@ function analyzePackageJson(codemodOptions) {
28
28
  return name;
29
29
  } catch (e) {
30
30
  throw new SyntaxError(
31
- `ERROR: package.json is missing or is not valid. (${e.message})\n`
31
+ `ERROR: package.json is missing or is not valid. (${e.message})\n`,
32
32
  );
33
33
  }
34
34
  }
@@ -1,7 +1,7 @@
1
1
  import { readFileSync, writeFileSync } from 'node:fs';
2
2
  import { join, parse } from 'node:path';
3
3
 
4
- import glob from 'glob';
4
+ import { findFiles } from '../../../utils/files.js';
5
5
 
6
6
  function removeFileExtension(path) {
7
7
  const { dir, name } = parse(path);
@@ -16,7 +16,7 @@ function createMapping(migrationStrategy) {
16
16
  const after = removeFileExtension(newPath);
17
17
 
18
18
  return [before, after];
19
- })
19
+ }),
20
20
  );
21
21
  }
22
22
 
@@ -73,10 +73,8 @@ function updatePaths(mapping, options) {
73
73
 
74
74
  // File extensions had been specified, partly to encode assumptions
75
75
  // about Ember, and partly to avoid corrupting non-text files
76
- const filePaths = glob.sync('{addon,tests}/**/*.{d.ts,js,ts}', {
76
+ const filePaths = findFiles('{addon,tests}/**/*.{d.ts,js,ts}', {
77
77
  cwd: projectRoot,
78
- dot: true,
79
- nodir: true,
80
78
  });
81
79
 
82
80
  filePaths.forEach((filePath) => {
@@ -1,7 +1,7 @@
1
1
  import { readFileSync, writeFileSync } from 'node:fs';
2
2
  import { dirname, join, relative, resolve } from 'node:path';
3
3
 
4
- import glob from 'glob';
4
+ import { findFiles } from '../../../utils/files.js';
5
5
 
6
6
  function removeRelativePaths(oldFile, { filePath, projectName, projectRoot }) {
7
7
  const regex = new RegExp(`(?:'|")(.{1,2}/(.*))(?:'|")`, 'g');
@@ -15,7 +15,7 @@ function removeRelativePaths(oldFile, { filePath, projectName, projectRoot }) {
15
15
 
16
16
  let newPath = relative(
17
17
  projectRoot,
18
- resolve(projectRoot, dirname(filePath), oldPath)
18
+ resolve(projectRoot, dirname(filePath), oldPath),
19
19
  );
20
20
 
21
21
  if (newPath.startsWith('addon')) {
@@ -35,10 +35,8 @@ function updatePaths(options) {
35
35
 
36
36
  // File extensions had been specified, partly to encode assumptions
37
37
  // about Ember, and partly to avoid corrupting non-text files
38
- const filePaths = glob.sync('{addon,tests}/**/*.{d.ts,js,ts}', {
38
+ const filePaths = findFiles('{addon,tests}/**/*.{d.ts,js,ts}', {
39
39
  cwd: projectRoot,
40
- dot: true,
41
- nodir: true,
42
40
  });
43
41
 
44
42
  filePaths.forEach((filePath) => {
@@ -1,7 +1,7 @@
1
1
  import { readFileSync, writeFileSync } from 'node:fs';
2
2
  import { dirname, join, relative } from 'node:path';
3
3
 
4
- import glob from 'glob';
4
+ import { findFiles } from '../../../utils/files.js';
5
5
 
6
6
  function normalizeRelativePath(relativePath) {
7
7
  if (relativePath.startsWith('..')) {
@@ -38,10 +38,8 @@ function useRelativePathInAddonFolder(options) {
38
38
 
39
39
  // File extensions had been specified, partly to encode assumptions
40
40
  // about Ember, and partly to avoid corrupting non-text files
41
- const filePaths = glob.sync('addon/**/*.{d.ts,js,ts}', {
41
+ const filePaths = findFiles('addon/**/*.{d.ts,js,ts}', {
42
42
  cwd: projectRoot,
43
- dot: true,
44
- nodir: true,
45
43
  });
46
44
 
47
45
  filePaths.forEach((filePath) => {
@@ -63,11 +61,9 @@ function useRelativePathInTestsFolder(options) {
63
61
 
64
62
  // File extensions had been specified, partly to encode assumptions
65
63
  // about Ember, and partly to avoid corrupting non-text files
66
- const filePaths = glob.sync('tests/**/*.{d.ts,js,ts}', {
64
+ const filePaths = findFiles('tests/**/*.{d.ts,js,ts}', {
67
65
  cwd: projectRoot,
68
- dot: true,
69
- ignore: 'tests/dummy/**/*',
70
- nodir: true,
66
+ ignoreList: ['tests/dummy/**/*'],
71
67
  });
72
68
 
73
69
  filePaths.forEach((filePath) => {
@@ -89,10 +85,8 @@ function useRelativePathInTestsDummyFolder(options) {
89
85
 
90
86
  // File extensions had been specified, partly to encode assumptions
91
87
  // about Ember, and partly to avoid corrupting non-text files
92
- const filePaths = glob.sync('tests/dummy/**/*.{d.ts,js,ts}', {
88
+ const filePaths = findFiles('tests/dummy/**/*.{d.ts,js,ts}', {
93
89
  cwd: projectRoot,
94
- dot: true,
95
- nodir: true,
96
90
  });
97
91
 
98
92
  filePaths.forEach((filePath) => {
@@ -1,15 +1,13 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForComponents(options) {
6
4
  const { projectRoot } = options;
7
5
 
8
- const oldPaths = glob.sync(
6
+ const oldPaths = findFiles(
9
7
  'tests/integration/components/**/component-test.{js,ts}',
10
8
  {
11
9
  cwd: projectRoot,
12
- }
10
+ },
13
11
  );
14
12
 
15
13
  return oldPaths.map((oldPath) => {
@@ -1,6 +1,4 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForRouteControllers(options) {
6
4
  const { projectRoot } = options;
@@ -8,11 +6,11 @@ export function migrationStrategyForRouteControllers(options) {
8
6
  /*
9
7
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
10
8
  */
11
- const oldPaths1 = glob.sync(
9
+ const oldPaths1 = findFiles(
12
10
  'tests/unit/!(controllers)/**/controller-test.{js,ts}',
13
11
  {
14
12
  cwd: projectRoot,
15
- }
13
+ },
16
14
  );
17
15
 
18
16
  const newPaths1 = oldPaths1.map((oldPath) => {
@@ -42,11 +40,11 @@ export function migrationStrategyForRouteControllers(options) {
42
40
  /*
43
41
  Case 2: Passed the --pod flag to Ember CLI
44
42
  */
45
- const oldPaths2 = glob.sync(
43
+ const oldPaths2 = findFiles(
46
44
  'tests/unit/controllers/**/controller-test.{js,ts}',
47
45
  {
48
46
  cwd: projectRoot,
49
- }
47
+ },
50
48
  );
51
49
 
52
50
  const newPaths2 = oldPaths2.map((oldPath) => {
@@ -1,6 +1,4 @@
1
- import glob from 'glob';
2
-
3
- import { mapFilePath } from '../../../utils/files.js';
1
+ import { findFiles, mapFilePath } from '../../../utils/files.js';
4
2
 
5
3
  export function migrationStrategyForRouteRoutes(options) {
6
4
  const { projectRoot } = options;
@@ -8,7 +6,7 @@ export function migrationStrategyForRouteRoutes(options) {
8
6
  /*
9
7
  Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
10
8
  */
11
- const oldPaths1 = glob.sync('tests/unit/!(routes)/**/route-test.{js,ts}', {
9
+ const oldPaths1 = findFiles('tests/unit/!(routes)/**/route-test.{js,ts}', {
12
10
  cwd: projectRoot,
13
11
  });
14
12
 
@@ -39,7 +37,7 @@ export function migrationStrategyForRouteRoutes(options) {
39
37
  /*
40
38
  Case 2: Passed the --pod flag to Ember CLI
41
39
  */
42
- const oldPaths2 = glob.sync('tests/unit/routes/**/route-test.{js,ts}', {
40
+ const oldPaths2 = findFiles('tests/unit/routes/**/route-test.{js,ts}', {
43
41
  cwd: projectRoot,
44
42
  });
45
43
 
@@ -0,0 +1,28 @@
1
+ import { globSync } from 'glob';
2
+
3
+ export function findFiles(pattern, { cwd, ignoreList = [] }) {
4
+ if (!pattern) {
5
+ throw new RangeError('ERROR: The glob pattern is unknown.\n');
6
+ }
7
+
8
+ if (!cwd) {
9
+ throw new RangeError('ERROR: The current working directory is unknown.\n');
10
+ }
11
+
12
+ const filePaths = globSync(pattern, {
13
+ cwd,
14
+ dot: true,
15
+ ignore: ignoreList,
16
+ nodir: true,
17
+ });
18
+
19
+ return filePaths.sort();
20
+ }
21
+
22
+ export function unionize(files) {
23
+ if (files.length <= 1) {
24
+ return files.join(',');
25
+ }
26
+
27
+ return `{${files.join(',')}}`;
28
+ }
@@ -3,7 +3,7 @@ export function mapFilePath(oldPath, { find, replace }) {
3
3
 
4
4
  if (!oldPath.endsWith(file)) {
5
5
  throw new RangeError(
6
- `ERROR: The provided path \`${oldPath}\` does not end with \`${file}\`.\n`
6
+ `ERROR: The provided path \`${oldPath}\` does not end with \`${file}\`.\n`,
7
7
  );
8
8
  }
9
9
 
@@ -1,3 +1,4 @@
1
+ export * from './files/find-files.js';
1
2
  export * from './files/map-file-path.js';
2
3
  export * from './files/move-files.js';
3
4
  export * from './files/remove-directory-if-empty.js';