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 +7 -10
- package/dist/bin/ember-codemod-remove-global-styles.js +3 -3
- package/dist/src/steps/analyze-project/analyze-components.js +3 -3
- package/dist/src/steps/analyze-project/analyze-routes.js +3 -3
- package/dist/src/steps/create-options.js +2 -2
- package/dist/src/utils/analyze-project/get-pattern.js +23 -0
- package/dist/src/utils/analyze-project/index.js +1 -0
- package/package.json +1 -1
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
|
|
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
|
|
66
|
+
<summary>Optional: Limit entity to consider</summary>
|
|
67
67
|
|
|
68
|
-
By default, the codemod considers all files and folders for components and
|
|
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`
|
|
72
|
-
pnpx ember-codemod-remove-global-styles --
|
|
71
|
+
# `ui/form` only
|
|
72
|
+
pnpx ember-codemod-remove-global-styles --entity ui/form
|
|
73
73
|
|
|
74
|
-
# `
|
|
75
|
-
pnpx ember-codemod-remove-global-styles --
|
|
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('
|
|
16
|
-
describe: 'Which
|
|
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
|
-
|
|
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 {
|
|
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,
|
|
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(
|
|
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 {
|
|
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,
|
|
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(
|
|
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,
|
|
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
|
-
|
|
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';
|