ember-codemod-remove-inject-as-service 1.0.1 → 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.
- package/README.md +3 -8
- package/dist/src/index.js +3 -15
- package/dist/src/steps/create-options.js +20 -0
- package/dist/src/steps/index.js +2 -0
- package/dist/src/{utils/steps → steps}/update-project.js +2 -2
- package/package.json +11 -11
- package/dist/src/migration/ember-app/index.js +0 -6
- package/dist/src/migration/ember-v1-addon/index.js +0 -6
- package/dist/src/migration/ember-v2-addon/index.js +0 -6
- package/dist/src/migration/index.js +0 -3
- package/dist/src/utils/steps/create-options.js +0 -7
- /package/dist/src/{utils/steps → steps}/update-project/update-class.js +0 -0
package/README.md
CHANGED
|
@@ -41,15 +41,10 @@ npx ember-codemod-remove-inject-as-service <arguments>
|
|
|
41
41
|
|
|
42
42
|
Step 2. Fix formatting issues.
|
|
43
43
|
|
|
44
|
-
- Optional: Do a find-and-replace-all in TS files, if you want to place `@service
|
|
44
|
+
- Optional: Do a find-and-replace-all in TS files, if you want to place `@service` and `declare` on the same line whenever possible.
|
|
45
45
|
|
|
46
|
-
- Find: `@service\(
|
|
47
|
-
- Replace: `@service
|
|
48
|
-
|
|
49
|
-
- Optional: Do a find-and-replace-all in TS files, if you want to place `@service` and `declare` on the same line when possible.
|
|
50
|
-
|
|
51
|
-
- Find: `@service[\n\s]+declare`
|
|
52
|
-
- Replace: `@service declare`
|
|
46
|
+
- Find: `@service(\(.*\))?[\n\s]+declare`
|
|
47
|
+
- Replace: `@service$1 declare`
|
|
53
48
|
|
|
54
49
|
- Run `lint:js:fix` (i.e. autofix from `eslint` and `prettier`).
|
|
55
50
|
|
package/dist/src/index.js
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createOptions, updateProject } from './steps/index.js';
|
|
2
2
|
export function runCodemod(codemodOptions) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
migrateEmberApp(codemodOptions);
|
|
6
|
-
break;
|
|
7
|
-
}
|
|
8
|
-
case 'v1-addon': {
|
|
9
|
-
migrateEmberV1Addon(codemodOptions);
|
|
10
|
-
break;
|
|
11
|
-
}
|
|
12
|
-
case 'v2-addon': {
|
|
13
|
-
migrateEmberV2Addon(codemodOptions);
|
|
14
|
-
break;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
3
|
+
const options = createOptions(codemodOptions);
|
|
4
|
+
updateProject(options);
|
|
17
5
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function getSrc(projectType) {
|
|
2
|
+
switch (projectType) {
|
|
3
|
+
case 'app': {
|
|
4
|
+
return ['app/**/*.{js,ts}', 'tests/**/*.{js,ts}'];
|
|
5
|
+
}
|
|
6
|
+
case 'v1-addon': {
|
|
7
|
+
return ['addon/**/*.{js,ts}', 'tests/**/*.{js,ts}'];
|
|
8
|
+
}
|
|
9
|
+
case 'v2-addon': {
|
|
10
|
+
return ['src/**/*.{js,ts}'];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function createOptions(codemodOptions) {
|
|
15
|
+
const { projectRoot, projectType } = codemodOptions;
|
|
16
|
+
return {
|
|
17
|
+
projectRoot,
|
|
18
|
+
src: getSrc(projectType),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -2,8 +2,8 @@ import { readFileSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
import { updateClass } from './update-project/update-class.js';
|
|
5
|
-
export function updateProject(
|
|
6
|
-
const { projectRoot } = options;
|
|
5
|
+
export function updateProject(options) {
|
|
6
|
+
const { projectRoot, src } = options;
|
|
7
7
|
const filePaths = findFiles(src, {
|
|
8
8
|
projectRoot,
|
|
9
9
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-remove-inject-as-service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Codemod to remove `inject as service`",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -23,32 +23,32 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@codemod-utils/ast-javascript": "^1.2.
|
|
27
|
-
"@codemod-utils/files": "^2.0.
|
|
26
|
+
"@codemod-utils/ast-javascript": "^1.2.6",
|
|
27
|
+
"@codemod-utils/files": "^2.0.2",
|
|
28
28
|
"yargs": "^17.7.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@babel/core": "^7.24.
|
|
32
|
-
"@changesets/cli": "^2.27.
|
|
31
|
+
"@babel/core": "^7.24.7",
|
|
32
|
+
"@changesets/cli": "^2.27.5",
|
|
33
33
|
"@changesets/get-github-info": "^0.6.0",
|
|
34
|
-
"@codemod-utils/tests": "^1.1.
|
|
34
|
+
"@codemod-utils/tests": "^1.1.5",
|
|
35
35
|
"@sondr3/minitest": "^0.1.2",
|
|
36
36
|
"@tsconfig/node18": "^18.2.4",
|
|
37
37
|
"@tsconfig/strictest": "^2.0.5",
|
|
38
|
-
"@types/node": "^18.19.
|
|
38
|
+
"@types/node": "^18.19.34",
|
|
39
39
|
"@types/yargs": "^17.0.32",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
41
|
-
"@typescript-eslint/parser": "^7.
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
|
41
|
+
"@typescript-eslint/parser": "^7.12.0",
|
|
42
42
|
"concurrently": "^8.2.2",
|
|
43
43
|
"eslint": "^8.57.0",
|
|
44
44
|
"eslint-config-prettier": "^9.1.0",
|
|
45
45
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
46
46
|
"eslint-plugin-import": "^2.29.1",
|
|
47
|
-
"eslint-plugin-n": "^17.
|
|
47
|
+
"eslint-plugin-n": "^17.8.1",
|
|
48
48
|
"eslint-plugin-prettier": "^5.1.3",
|
|
49
49
|
"eslint-plugin-simple-import-sort": "^12.1.0",
|
|
50
50
|
"eslint-plugin-typescript-sort-keys": "^3.2.0",
|
|
51
|
-
"prettier": "^3.
|
|
51
|
+
"prettier": "^3.3.1",
|
|
52
52
|
"typescript": "^5.4.5"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createOptions } from '../../utils/steps/create-options.js';
|
|
2
|
-
import { updateProject } from '../../utils/steps/update-project.js';
|
|
3
|
-
export function migrateEmberApp(codemodOptions) {
|
|
4
|
-
const options = createOptions(codemodOptions);
|
|
5
|
-
updateProject(['app/**/*.{js,ts}'], options);
|
|
6
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createOptions } from '../../utils/steps/create-options.js';
|
|
2
|
-
import { updateProject } from '../../utils/steps/update-project.js';
|
|
3
|
-
export function migrateEmberV1Addon(codemodOptions) {
|
|
4
|
-
const options = createOptions(codemodOptions);
|
|
5
|
-
updateProject(['addon/**/*.{js,ts}', 'tests/dummy/app/**/*.{js,ts}'], options);
|
|
6
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createOptions } from '../../utils/steps/create-options.js';
|
|
2
|
-
import { updateProject } from '../../utils/steps/update-project.js';
|
|
3
|
-
export function migrateEmberV2Addon(codemodOptions) {
|
|
4
|
-
const options = createOptions(codemodOptions);
|
|
5
|
-
updateProject(['src/**/*.{js,ts}'], options);
|
|
6
|
-
}
|
|
File without changes
|