ember-codemod-remove-global-styles 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,7 +47,7 @@ pnpx ember-codemod-remove-global-styles --src app/assets/app.css
47
47
 
48
48
  <details>
49
49
 
50
- <summary>Optional: Limit types of files to consider</summary>
50
+ <summary>Optional: Limit type of files to consider</summary>
51
51
 
52
52
  By default, the codemod considers components and routes. Pass `--convert` to consider a subset of these.
53
53
 
@@ -63,19 +63,16 @@ pnpx ember-codemod-remove-global-styles --convert routes
63
63
 
64
64
  <details>
65
65
 
66
- <summary>Optional: Limit folders to consider</summary>
66
+ <summary>Optional: Limit entity to consider</summary>
67
67
 
68
- By default, the codemod considers all files and folders for components and routes. Pass `--folder` to limit the search to 1 folder. (You may use glob patterns to specify multiple folders.)
68
+ By default, the codemod considers all files and folders for components, routes, and tests. Pass `--entity` to limit the search to 1 entity and its sub-entities (if any). You may use curly braces to specify multiple entities.
69
69
 
70
70
  ```sh
71
- # `ui` folder only (search `app/{components,templates}/ui`)
72
- pnpx ember-codemod-remove-global-styles --folder ui
71
+ # `ui/form` only
72
+ pnpx ember-codemod-remove-global-styles --entity ui/form
73
73
 
74
- # `ui/form` folder only (search `app/{components,templates}/ui/form`)
75
- pnpx ember-codemod-remove-global-styles --folder ui/form
76
-
77
- # `route1` and `route2` folders only (search `app/templates/{route1,route2}`)
78
- pnpx ember-codemod-remove-global-styles --convert routes --folder "{route1,route2}"
74
+ # `route1` and `route2` only
75
+ pnpx ember-codemod-remove-global-styles --convert routes --entity "{route1,route2}"
79
76
  ```
80
77
 
81
78
  </details>
@@ -12,8 +12,8 @@ const argv = yargs(hideBin(process.argv))
12
12
  describe: 'Which type of files to consider',
13
13
  type: 'array',
14
14
  })
15
- .option('folder', {
16
- describe: 'Which folder to consider',
15
+ .option('entity', {
16
+ describe: 'Which entity to consider',
17
17
  type: 'string',
18
18
  })
19
19
  .option('root', {
@@ -29,7 +29,7 @@ const argv = yargs(hideBin(process.argv))
29
29
  const DEFAULT_FOR_CONVERT = ['components', 'routes'];
30
30
  const codemodOptions = {
31
31
  convert: new Set(argv['convert'] ?? DEFAULT_FOR_CONVERT),
32
- folder: argv['folder'] ?? '',
32
+ entity: argv['entity'],
33
33
  projectRoot: argv['root'] ?? process.cwd(),
34
34
  src: argv['src'],
35
35
  };
@@ -1,15 +1,15 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { findFiles } from '@codemod-utils/files';
4
- import { normalizedJoin } from '../../utils/files/index.js';
4
+ import { getPatternForComponents } from '../../utils/analyze-project/index.js';
5
5
  import { getEntityData } from './get-entity-data.js';
6
6
  export function analyzeComponents(classNameToStyles, options) {
7
- const { convert, folder, projectRoot } = options;
7
+ const { convert, projectRoot } = options;
8
8
  const components = new Map();
9
9
  if (!convert.components) {
10
10
  return components;
11
11
  }
12
- const filePaths = findFiles(normalizedJoin('app/components', folder, '**/*.{gjs,gts,hbs}'), {
12
+ const filePaths = findFiles(getPatternForComponents(options), {
13
13
  projectRoot,
14
14
  });
15
15
  filePaths.forEach((filePath) => {
@@ -1,15 +1,15 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { findFiles } from '@codemod-utils/files';
4
- import { normalizedJoin } from '../../utils/files/index.js';
4
+ import { getPatternForRoutes } from '../../utils/analyze-project/index.js';
5
5
  import { getEntityData } from './get-entity-data.js';
6
6
  export function analyzeRoutes(classNameToStyles, options) {
7
- const { convert, folder, projectRoot } = options;
7
+ const { convert, projectRoot } = options;
8
8
  const routes = new Map();
9
9
  if (!convert.routes) {
10
10
  return routes;
11
11
  }
12
- const filePaths = findFiles(normalizedJoin('app/templates', folder, '**/*.{gjs,gts,hbs}'), {
12
+ const filePaths = findFiles(getPatternForRoutes(options), {
13
13
  projectRoot,
14
14
  });
15
15
  filePaths.forEach((filePath) => {
@@ -1,11 +1,11 @@
1
1
  export function createOptions(codemodOptions) {
2
- const { convert, folder, projectRoot, src } = codemodOptions;
2
+ const { convert, entity, projectRoot, src } = codemodOptions;
3
3
  return {
4
4
  convert: {
5
5
  components: convert.has('components'),
6
6
  routes: convert.has('routes'),
7
7
  },
8
- folder,
8
+ entity,
9
9
  projectRoot,
10
10
  src,
11
11
  };
@@ -0,0 +1,23 @@
1
+ import { normalizedJoin } from '../files/index.js';
2
+ export function getPatternForComponents(options) {
3
+ const source = 'app';
4
+ const { entity } = options;
5
+ if (entity === undefined) {
6
+ return [`${source}/components/**/*.{gjs,gts,hbs}`];
7
+ }
8
+ return [
9
+ normalizedJoin(source, 'components', `${entity}.{gjs,gts,hbs}`),
10
+ normalizedJoin(source, 'components', entity, '**/*.{gjs,gts,hbs}'),
11
+ ];
12
+ }
13
+ export function getPatternForRoutes(options) {
14
+ const source = 'app';
15
+ const { entity } = options;
16
+ if (entity === undefined) {
17
+ return [`${source}/templates/**/*.{gjs,gts,hbs}`];
18
+ }
19
+ return [
20
+ normalizedJoin(source, 'templates', `${entity}.{gjs,gts,hbs}`),
21
+ normalizedJoin(source, 'templates', entity, '**/*.{gjs,gts,hbs}'),
22
+ ];
23
+ }
@@ -0,0 +1 @@
1
+ export * from './get-pattern.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-codemod-remove-global-styles",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Codemod to localize global styles",
5
5
  "keywords": [
6
6
  "codemod",