ember-codemod-add-component-signatures 5.0.0 → 5.1.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 +4 -12
- package/dist/bin/ember-codemod-add-component-signatures.js +0 -7
- package/dist/src/steps/analyze-project/find-components.js +2 -2
- package/dist/src/steps/convert-to-typescript.js +1 -1
- package/dist/src/steps/create-options.js +10 -15
- package/dist/src/utils/blueprints/blueprints-root.js +1 -2
- package/dist/src/utils/components/get-class-path.js +2 -2
- package/dist/src/utils/components/get-template-path.js +2 -2
- package/dist/src/utils/ember.js +6 -0
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Step 1. Quickly migrate.
|
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
42
|
cd <path/to/your/project>
|
|
43
|
-
|
|
43
|
+
pnpx ember-codemod-add-component-signatures <arguments>
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Step 2. Review the package.
|
|
@@ -64,14 +64,6 @@ Nice to do:
|
|
|
64
64
|
|
|
65
65
|
### Arguments
|
|
66
66
|
|
|
67
|
-
You must pass `--type` to indicate what type of project you have.
|
|
68
|
-
|
|
69
|
-
```sh
|
|
70
|
-
npx ember-codemod-add-component-signatures --type app
|
|
71
|
-
npx ember-codemod-add-component-signatures --type v1-addon
|
|
72
|
-
npx ember-codemod-add-component-signatures --type v2-addon
|
|
73
|
-
```
|
|
74
|
-
|
|
75
67
|
<details>
|
|
76
68
|
|
|
77
69
|
<summary>Optional: Specify the component structure</summary>
|
|
@@ -79,7 +71,7 @@ npx ember-codemod-add-component-signatures --type v2-addon
|
|
|
79
71
|
By default, an Octane project has the flat component structure. Pass `--component-structure` to indicate otherwise.
|
|
80
72
|
|
|
81
73
|
```sh
|
|
82
|
-
|
|
74
|
+
pnpx ember-codemod-add-component-signatures --component-structure nested
|
|
83
75
|
```
|
|
84
76
|
|
|
85
77
|
</details>
|
|
@@ -91,7 +83,7 @@ npx ember-codemod-add-component-signatures --component-structure nested
|
|
|
91
83
|
By default, the codemod ignores component classes written in `*.{js,gjs}`. Pass `--convert-javascript` to allow the codemod to change the file extension to `*.{ts,gts}` and add the component signature.
|
|
92
84
|
|
|
93
85
|
```sh
|
|
94
|
-
|
|
86
|
+
pnpx ember-codemod-add-component-signatures --convert-javascript
|
|
95
87
|
```
|
|
96
88
|
|
|
97
89
|
</details>
|
|
@@ -103,7 +95,7 @@ npx ember-codemod-add-component-signatures --convert-javascript
|
|
|
103
95
|
Pass `--root` to run the codemod on a project somewhere else (i.e. not in the current directory).
|
|
104
96
|
|
|
105
97
|
```sh
|
|
106
|
-
|
|
98
|
+
pnpx ember-codemod-add-component-signatures --root <path/to/your/project>
|
|
107
99
|
```
|
|
108
100
|
|
|
109
101
|
</details>
|
|
@@ -21,18 +21,11 @@ const argv = yargs(hideBin(process.argv))
|
|
|
21
21
|
.option('root', {
|
|
22
22
|
describe: 'Location of your Ember project',
|
|
23
23
|
type: 'string',
|
|
24
|
-
})
|
|
25
|
-
.option('type', {
|
|
26
|
-
choices: ['app', 'v1-addon', 'v2-addon'],
|
|
27
|
-
demandOption: true,
|
|
28
|
-
describe: 'Type of your Ember project',
|
|
29
|
-
type: 'string',
|
|
30
24
|
})
|
|
31
25
|
.parseSync();
|
|
32
26
|
const codemodOptions = {
|
|
33
27
|
componentStructure: argv['component-structure'],
|
|
34
28
|
convertJavaScript: argv['convert-javascript'],
|
|
35
29
|
projectRoot: argv['root'] ?? process.cwd(),
|
|
36
|
-
projectType: argv['type'],
|
|
37
30
|
};
|
|
38
31
|
runCodemod(codemodOptions);
|
|
@@ -8,12 +8,12 @@ function normalizeComponentNames(extensionMap) {
|
|
|
8
8
|
}
|
|
9
9
|
export function findComponents(options) {
|
|
10
10
|
const { componentStructure, projectRoot, src } = options;
|
|
11
|
-
const filePaths = findFiles(`${src}/**/*.{gjs,gts,hbs,js,ts}`, {
|
|
11
|
+
const filePaths = findFiles(`${src}/components/**/*.{gjs,gts,hbs,js,ts}`, {
|
|
12
12
|
ignoreList: ['**/*.d.ts'],
|
|
13
13
|
projectRoot,
|
|
14
14
|
}).map((filePath) => {
|
|
15
15
|
return renamePathByDirectory(filePath, {
|
|
16
|
-
from: src
|
|
16
|
+
from: `${src}/components`,
|
|
17
17
|
to: '',
|
|
18
18
|
});
|
|
19
19
|
});
|
|
@@ -4,7 +4,7 @@ export function convertToTypeScript(options) {
|
|
|
4
4
|
if (!convertJavaScript) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
|
-
const filePaths = findFiles(`${src}/**/*.{gjs,js}`, {
|
|
7
|
+
const filePaths = findFiles(`${src}/components/**/*.{gjs,js}`, {
|
|
8
8
|
projectRoot,
|
|
9
9
|
});
|
|
10
10
|
const filePathMap = filePaths.reduce((accumulator, filePath) => {
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
case 'app': {
|
|
4
|
-
return 'app/components';
|
|
5
|
-
}
|
|
6
|
-
case 'v1-addon': {
|
|
7
|
-
return 'addon/components';
|
|
8
|
-
}
|
|
9
|
-
case 'v2-addon': {
|
|
10
|
-
return 'src/components';
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
import { getPackageType, readPackageJson } from '@codemod-utils/package-json';
|
|
2
|
+
import { SOURCE_DIRECTORY } from '../utils/ember.js';
|
|
14
3
|
export function createOptions(codemodOptions) {
|
|
15
|
-
const { componentStructure, convertJavaScript, projectRoot
|
|
4
|
+
const { componentStructure, convertJavaScript, projectRoot } = codemodOptions;
|
|
5
|
+
const packageJson = readPackageJson({ projectRoot });
|
|
6
|
+
const packageType = getPackageType(packageJson);
|
|
7
|
+
if (packageType === 'node') {
|
|
8
|
+
throw new Error('Ember package not found');
|
|
9
|
+
}
|
|
10
|
+
const src = SOURCE_DIRECTORY[packageType];
|
|
16
11
|
return {
|
|
17
12
|
componentStructure,
|
|
18
13
|
convertJavaScript,
|
|
19
14
|
projectRoot,
|
|
20
|
-
src
|
|
15
|
+
src,
|
|
21
16
|
};
|
|
22
17
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
import { getFilePath } from '@codemod-utils/blueprints';
|
|
3
|
-
const
|
|
4
|
-
export const blueprintsRoot = join(getFilePath(fileURL), '../../blueprints');
|
|
3
|
+
export const blueprintsRoot = join(getFilePath(import.meta.url), '../../blueprints');
|
|
@@ -2,8 +2,8 @@ import { join } from 'node:path';
|
|
|
2
2
|
export function getClassPath(componentName, extensions, options) {
|
|
3
3
|
const { componentStructure, src } = options;
|
|
4
4
|
const filePath = componentStructure === 'nested'
|
|
5
|
-
? join(src, componentName, 'index')
|
|
6
|
-
: join(src, componentName);
|
|
5
|
+
? join(src, 'components', componentName, 'index')
|
|
6
|
+
: join(src, 'components', componentName);
|
|
7
7
|
if (extensions.has('.gts')) {
|
|
8
8
|
return `${filePath}.gts`;
|
|
9
9
|
}
|
|
@@ -2,8 +2,8 @@ import { join } from 'node:path';
|
|
|
2
2
|
export function getTemplatePath(componentName, extensions, options) {
|
|
3
3
|
const { componentStructure, src } = options;
|
|
4
4
|
const filePath = componentStructure === 'nested'
|
|
5
|
-
? join(src, componentName, 'index')
|
|
6
|
-
: join(src, componentName);
|
|
5
|
+
? join(src, 'components', componentName, 'index')
|
|
6
|
+
: join(src, 'components', componentName);
|
|
7
7
|
if (!extensions.has('.hbs')) {
|
|
8
8
|
throw new RangeError('extensions must include `.hbs`');
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-add-component-signatures",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Codemod to add component signatures",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -27,17 +27,18 @@
|
|
|
27
27
|
"@codemod-utils/ast-javascript": "^3.0.0",
|
|
28
28
|
"@codemod-utils/ast-template": "^3.0.0",
|
|
29
29
|
"@codemod-utils/ast-template-tag": "^2.0.0",
|
|
30
|
-
"@codemod-utils/blueprints": "^3.0.
|
|
31
|
-
"@codemod-utils/ember": "^4.
|
|
30
|
+
"@codemod-utils/blueprints": "^3.0.1",
|
|
31
|
+
"@codemod-utils/ember": "^4.1.0",
|
|
32
32
|
"@codemod-utils/files": "^4.0.0",
|
|
33
|
+
"@codemod-utils/package-json": "^4.0.0",
|
|
33
34
|
"yargs": "^18.0.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@changesets/cli": "^2.29.8",
|
|
37
38
|
"@codemod-utils/tests": "^3.0.0",
|
|
38
39
|
"@ijlee2-frontend-configs/changesets": "^2.0.0",
|
|
39
|
-
"@ijlee2-frontend-configs/eslint-config-node": "^3.0.
|
|
40
|
-
"@ijlee2-frontend-configs/prettier": "^3.0.
|
|
40
|
+
"@ijlee2-frontend-configs/eslint-config-node": "^3.0.1",
|
|
41
|
+
"@ijlee2-frontend-configs/prettier": "^3.0.1",
|
|
41
42
|
"@sondr3/minitest": "^0.1.2",
|
|
42
43
|
"@tsconfig/node22": "^22.0.5",
|
|
43
44
|
"@tsconfig/strictest": "^2.0.8",
|