ember-codemod-remove-inject-as-service 2.0.1 → 2.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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
function getSrc(projectType) {
|
|
2
2
|
switch (projectType) {
|
|
3
3
|
case 'app': {
|
|
4
|
-
return ['app/**/*.{
|
|
4
|
+
return ['{app,tests}/**/*.{gjs,gts,js,ts}'];
|
|
5
5
|
}
|
|
6
6
|
case 'v1-addon': {
|
|
7
|
-
return ['addon/**/*.{
|
|
7
|
+
return ['{addon,tests}/**/*.{gjs,gts,js,ts}'];
|
|
8
8
|
}
|
|
9
9
|
case 'v2-addon': {
|
|
10
|
-
return ['src/**/*.{js,ts}'];
|
|
10
|
+
return ['src/**/*.{gjs,gts,js,ts}'];
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -93,7 +93,8 @@ function updateServiceDecorators(file, data) {
|
|
|
93
93
|
});
|
|
94
94
|
return AST.print(ast);
|
|
95
95
|
}
|
|
96
|
-
export function updateClass(file,
|
|
96
|
+
export function updateClass(file, data) {
|
|
97
|
+
const { isTypeScript } = data;
|
|
97
98
|
// eslint-disable-next-line prefer-const
|
|
98
99
|
let { localName, newFile } = updateImportStatement(file, {
|
|
99
100
|
isTypeScript,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { updateJavaScript } from '@codemod-utils/ast-template-tag';
|
|
3
4
|
import { findFiles } from '@codemod-utils/files';
|
|
4
5
|
import { updateClass } from './update-project/update-class.js';
|
|
6
|
+
function isTypeScript(filePath) {
|
|
7
|
+
return filePath.endsWith('.gts') || filePath.endsWith('.ts');
|
|
8
|
+
}
|
|
5
9
|
export function updateProject(options) {
|
|
6
10
|
const { projectRoot, src } = options;
|
|
7
11
|
const filePaths = findFiles(src, {
|
|
@@ -9,9 +13,18 @@ export function updateProject(options) {
|
|
|
9
13
|
});
|
|
10
14
|
filePaths.forEach((filePath) => {
|
|
11
15
|
const oldPath = join(projectRoot, filePath);
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
16
|
+
let newFile = readFileSync(oldPath, 'utf8');
|
|
17
|
+
const data = {
|
|
18
|
+
isTypeScript: isTypeScript(filePath),
|
|
19
|
+
};
|
|
20
|
+
if (filePath.endsWith('.js') || filePath.endsWith('.ts')) {
|
|
21
|
+
newFile = updateClass(newFile, data);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
newFile = updateJavaScript(newFile, (code) => {
|
|
25
|
+
return updateClass(code, data);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
15
28
|
writeFileSync(oldPath, newFile, 'utf8');
|
|
16
29
|
});
|
|
17
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-remove-inject-as-service",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Codemod to remove `inject as service`",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -23,33 +23,36 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@codemod-utils/ast-javascript": "^2.0.
|
|
27
|
-
"@codemod-utils/
|
|
26
|
+
"@codemod-utils/ast-javascript": "^2.0.6",
|
|
27
|
+
"@codemod-utils/ast-template-tag": "^0.1.0",
|
|
28
|
+
"@codemod-utils/files": "^3.0.4",
|
|
28
29
|
"yargs": "^18.0.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@changesets/cli": "^2.29.
|
|
32
|
+
"@changesets/cli": "^2.29.6",
|
|
32
33
|
"@changesets/get-github-info": "^0.6.0",
|
|
33
|
-
"@codemod-utils/tests": "^2.0.
|
|
34
|
-
"@ijlee2-frontend-configs/eslint-config-node": "^1.2
|
|
35
|
-
"@ijlee2-frontend-configs/prettier": "^1.
|
|
34
|
+
"@codemod-utils/tests": "^2.0.3",
|
|
35
|
+
"@ijlee2-frontend-configs/eslint-config-node": "^2.1.2",
|
|
36
|
+
"@ijlee2-frontend-configs/prettier": "^2.1.1",
|
|
36
37
|
"@sondr3/minitest": "^0.1.2",
|
|
37
|
-
"@tsconfig/node20": "^20.1.
|
|
38
|
+
"@tsconfig/node20": "^20.1.6",
|
|
38
39
|
"@tsconfig/strictest": "^2.0.5",
|
|
39
|
-
"@types/node": "^20.
|
|
40
|
+
"@types/node": "^20.19.13",
|
|
40
41
|
"@types/yargs": "^17.0.33",
|
|
41
|
-
"concurrently": "^9.1
|
|
42
|
-
"eslint": "^9.
|
|
43
|
-
"prettier": "^3.
|
|
44
|
-
"typescript": "^5.
|
|
42
|
+
"concurrently": "^9.2.1",
|
|
43
|
+
"eslint": "^9.35.0",
|
|
44
|
+
"prettier": "^3.6.2",
|
|
45
|
+
"typescript": "^5.9.2"
|
|
45
46
|
},
|
|
46
47
|
"engines": {
|
|
47
48
|
"node": "20.* || >= 22"
|
|
48
49
|
},
|
|
49
50
|
"scripts": {
|
|
50
51
|
"build": "./build.sh --production",
|
|
52
|
+
"format": "prettier . --cache --write",
|
|
51
53
|
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\"",
|
|
52
|
-
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\"",
|
|
54
|
+
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" && pnpm format",
|
|
55
|
+
"lint:format": "prettier . --cache --check",
|
|
53
56
|
"lint:js": "eslint . --cache",
|
|
54
57
|
"lint:js:fix": "eslint . --fix",
|
|
55
58
|
"lint:types": "tsc --noEmit",
|