@simplysm/sd-cli 12.11.3 → 12.11.5
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/dist/fix/convert-flat-pages-to-flat-menus.d.ts +1 -0
- package/dist/fix/convert-flat-pages-to-flat-menus.js +68 -0
- package/dist/fix/convert-flat-pages-to-flat-menus.js.map +1 -0
- package/dist/fix/convert-get-menus-to-usable-menus.d.ts +1 -0
- package/dist/fix/convert-get-menus-to-usable-menus.js +48 -0
- package/dist/fix/convert-get-menus-to-usable-menus.js.map +1 -0
- package/dist/fix/convert-to-use-perms-signal.d.ts +1 -0
- package/dist/fix/convert-to-use-perms-signal.js +99 -0
- package/dist/fix/convert-to-use-perms-signal.js.map +1 -0
- package/dist/fix/remove-unused-imports.d.ts +1 -0
- package/dist/fix/remove-unused-imports.js +42 -0
- package/dist/fix/remove-unused-imports.js.map +1 -0
- package/dist/fix/remove-unused-injects.d.ts +1 -0
- package/dist/fix/remove-unused-injects.js +38 -0
- package/dist/fix/remove-unused-injects.js.map +1 -0
- package/dist/sd-cli-entry.js +12 -1
- package/dist/sd-cli-entry.js.map +1 -1
- package/package.json +12 -11
- package/src/fix/convert-flat-pages-to-flat-menus.ts +83 -0
- package/src/fix/convert-get-menus-to-usable-menus.ts +60 -0
- package/src/fix/convert-to-use-perms-signal.ts +133 -0
- package/src/fix/remove-unused-imports.ts +50 -0
- package/src/fix/remove-unused-injects.ts +50 -0
- package/src/sd-cli-entry.ts +13 -1
- package/tests/deps/sd-dependency-cache.spec.ts +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function convertFlatPagesToUsableFlatMenus(): void;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { SyntaxKind } from "ts-morph";
|
|
3
|
+
import getTsMorphSourceFiles from "./core/get-ts-morph-source-files";
|
|
4
|
+
export function convertFlatPagesToUsableFlatMenus() {
|
|
5
|
+
const sourceFiles = getTsMorphSourceFiles();
|
|
6
|
+
let totalChanged = 0;
|
|
7
|
+
for (const sourceFile of sourceFiles) {
|
|
8
|
+
let changed = false;
|
|
9
|
+
for (const cls of sourceFile.getClasses()) {
|
|
10
|
+
// 1. flatPages property 선언 확인
|
|
11
|
+
const prop = cls.getInstanceProperty("flatPages")?.asKind(SyntaxKind.PropertyDeclaration);
|
|
12
|
+
if (!prop)
|
|
13
|
+
continue;
|
|
14
|
+
const initializer = prop.getInitializer();
|
|
15
|
+
if (!initializer)
|
|
16
|
+
continue;
|
|
17
|
+
const callExpr = initializer.asKind(SyntaxKind.CallExpression);
|
|
18
|
+
if (!callExpr)
|
|
19
|
+
continue;
|
|
20
|
+
const expr = callExpr.getExpression();
|
|
21
|
+
if (expr.getKind() === SyntaxKind.PropertyAccessExpression &&
|
|
22
|
+
expr.getText() === "this._sdAppStructure.getFlatPages") {
|
|
23
|
+
// 2. 선언 변경
|
|
24
|
+
prop.rename("flatMenus");
|
|
25
|
+
prop.setInitializer("this._sdAppStructure.usableFlatMenus()");
|
|
26
|
+
changed = true;
|
|
27
|
+
console.log(`[변환됨] ${sourceFile.getBaseName()} → flatPages 선언 → flatMenus`);
|
|
28
|
+
}
|
|
29
|
+
// 3. 클래스 내 this.flatPages → this.flatMenus 치환
|
|
30
|
+
cls.forEachDescendant((node) => {
|
|
31
|
+
if (node.getKind() === SyntaxKind.PropertyAccessExpression) {
|
|
32
|
+
const propAccess = node.asKind(SyntaxKind.PropertyAccessExpression);
|
|
33
|
+
if (propAccess.getExpression().getKind() === SyntaxKind.ThisKeyword &&
|
|
34
|
+
propAccess.getName() === "flatPages") {
|
|
35
|
+
propAccess.replaceWithText("this.flatMenus");
|
|
36
|
+
changed = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
// 4. @Component의 template 내 문자열 치환
|
|
41
|
+
const componentDecorator = cls.getDecorator("Component");
|
|
42
|
+
const arg = componentDecorator?.getArguments()[0]?.asKind(SyntaxKind.ObjectLiteralExpression);
|
|
43
|
+
const templateProp = arg?.getProperty("template")?.asKind(SyntaxKind.PropertyAssignment);
|
|
44
|
+
const templateInit = templateProp?.getInitializer();
|
|
45
|
+
if (templateInit &&
|
|
46
|
+
(templateInit.getKind() === SyntaxKind.NoSubstitutionTemplateLiteral ||
|
|
47
|
+
templateInit.getKind() === SyntaxKind.StringLiteral ||
|
|
48
|
+
templateInit.getKind() === SyntaxKind.TemplateExpression)) {
|
|
49
|
+
const originalText = templateInit.getText();
|
|
50
|
+
const newText = originalText.replace(/\bflatPages\b/g, "flatMenus");
|
|
51
|
+
if (newText !== originalText) {
|
|
52
|
+
templateInit.replaceWithText(newText);
|
|
53
|
+
changed = true;
|
|
54
|
+
console.log(`[변환됨] ${sourceFile.getBaseName()} → 템플릿 내 flatPages → flatMenus`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (changed) {
|
|
59
|
+
sourceFile.saveSync();
|
|
60
|
+
totalChanged++;
|
|
61
|
+
console.log(`[updated] ${sourceFile.getBaseName()} :: flatMenus 변환 완료`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
console.log(totalChanged > 0
|
|
65
|
+
? `\n[완료] flatPages → flatMenus 전체 변환 완료 (총 ${totalChanged}개)`
|
|
66
|
+
: `[완료] 변환 대상 없음`);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=convert-flat-pages-to-flat-menus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-flat-pages-to-flat-menus.js","sourceRoot":"","sources":["../../src/fix/convert-flat-pages-to-flat-menus.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,qBAAqB,MAAM,kCAAkC,CAAC;AAErE,MAAM,UAAU,iCAAiC;IAC/C,MAAM,WAAW,GAAG,qBAAqB,EAAE,CAAC;IAC5C,IAAI,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AAU,CAAC,QAAQ,EAAE,CAAC;YACtB,YAAY,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,aAAa,UAAU,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CACT,YAAY,GAAG,CAAC;QACd,CAAC,CAAC,4CAA4C,YAAY,IAAI;QAC9D,CAAC,CAAC,eAAe,CACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function convertGetMenusToUsableMenus(): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { SyntaxKind } from "ts-morph";
|
|
3
|
+
import getTsMorphSourceFiles from "./core/get-ts-morph-source-files";
|
|
4
|
+
export function convertGetMenusToUsableMenus() {
|
|
5
|
+
const sourceFiles = getTsMorphSourceFiles();
|
|
6
|
+
let totalChanged = 0;
|
|
7
|
+
for (const sourceFile of sourceFiles) {
|
|
8
|
+
let changed = false;
|
|
9
|
+
for (const cls of sourceFile.getClasses()) {
|
|
10
|
+
const menusProp = cls.getInstanceProperty("menus")?.asKind(SyntaxKind.PropertyDeclaration);
|
|
11
|
+
if (!menusProp)
|
|
12
|
+
continue;
|
|
13
|
+
const initializer = menusProp.getInitializer()?.asKind(SyntaxKind.CallExpression);
|
|
14
|
+
if (!initializer ||
|
|
15
|
+
initializer.getFirstChildByKind(SyntaxKind.Identifier)?.getText() !== "$computed") {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const arrowFn = initializer
|
|
19
|
+
.asKind(SyntaxKind.CallExpression)
|
|
20
|
+
?.getArguments()
|
|
21
|
+
.first()
|
|
22
|
+
?.asKind(SyntaxKind.ArrowFunction);
|
|
23
|
+
if (!arrowFn)
|
|
24
|
+
continue;
|
|
25
|
+
const body = arrowFn.getBody().asKind(SyntaxKind.CallExpression);
|
|
26
|
+
if (!body || !body.getText().includes("this._sdAppStructure.getMenus")) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const callExpr = body.asKind(SyntaxKind.CallExpression);
|
|
30
|
+
const calleeExpr = callExpr.getExpression();
|
|
31
|
+
if (calleeExpr.getKind() === SyntaxKind.PropertyAccessExpression &&
|
|
32
|
+
calleeExpr.getText() === "this._sdAppStructure.getMenus") {
|
|
33
|
+
// 수정 실행: getMenus → usableMenus
|
|
34
|
+
calleeExpr.replaceWithText("this._sdAppStructure.usableMenus");
|
|
35
|
+
changed = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (changed) {
|
|
39
|
+
sourceFile.saveSync();
|
|
40
|
+
totalChanged++;
|
|
41
|
+
console.log(`[updated] ${sourceFile.getBaseName()} :: menus → usableMenus 변경 완료`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
console.log(totalChanged > 0
|
|
45
|
+
? `\n[완료] usableMenus 변경 완료 (총 ${totalChanged}개)`
|
|
46
|
+
: `[완료] 변환 대상 없음`);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=convert-get-menus-to-usable-menus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-get-menus-to-usable-menus.js","sourceRoot":"","sources":["../../src/fix/convert-get-menus-to-usable-menus.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,qBAAqB,MAAM,kCAAkC,CAAC;AAErE,MAAM,UAAU,4BAA4B;IAC1C,MAAM,WAAW,GAAG,qBAAqB,EAAE,CAAC;IAC5C,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,OAAO,GAAG,KAAK,CAAC;QAEpB,KAAK,MAAM,GAAG,IAAI,UAAU,CAAC,UAAU,EAAE,EAAE,CAAC;YAC1C,MAAM,SAAS,GAAG,GAAG,CAAC,m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C;YACtB,YAAY,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,aAAa,UAAU,CAAC,WAAW,EAAE,+BAA+B,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CACT,YAAY,GAAG,CAAC;QACd,CAAC,CAAC,+BAA+B,YAAY,IAAI;QACjD,CAAC,CAAC,eAAe,CACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function convertToUsePermsSignal(): void;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { SyntaxKind, } from "ts-morph";
|
|
3
|
+
import getTsMorphSourceFiles from "./core/get-ts-morph-source-files";
|
|
4
|
+
export function convertToUsePermsSignal() {
|
|
5
|
+
const sourceFiles = getTsMorphSourceFiles();
|
|
6
|
+
let totalChanged = 0;
|
|
7
|
+
for (const sourceFile of sourceFiles) {
|
|
8
|
+
let changed = false;
|
|
9
|
+
for (const cls of sourceFile.getClasses()) {
|
|
10
|
+
try {
|
|
11
|
+
const result = processClass(cls);
|
|
12
|
+
if (result.success) {
|
|
13
|
+
changed = true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
console.error(`[오류] ${sourceFile.getBaseName()} 클래스 처리 중 오류:`, error);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (changed) {
|
|
21
|
+
addImportIfNeeded(sourceFile);
|
|
22
|
+
sourceFile.saveSync();
|
|
23
|
+
totalChanged++;
|
|
24
|
+
console.log(`[updated] ${sourceFile.getBaseName()} :: usePermsSignal 변환 완료`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
console.log(totalChanged > 0 ? `\n[완료] 변환 완료 (총 ${totalChanged}개)` : `[완료] 변환 대상 없음`);
|
|
28
|
+
}
|
|
29
|
+
function processClass(cls) {
|
|
30
|
+
const viewCodesProp = getPropertyDeclaration(cls, "viewCodes");
|
|
31
|
+
const permsProp = getPropertyDeclaration(cls, "perms");
|
|
32
|
+
if (!viewCodesProp || !permsProp) {
|
|
33
|
+
return { success: false, reason: "필수 프로퍼티 없음" };
|
|
34
|
+
}
|
|
35
|
+
const viewCodesInit = viewCodesProp.getInitializer();
|
|
36
|
+
const permsInit = permsProp.getInitializer();
|
|
37
|
+
if (!isValidViewCodesInit(viewCodesInit) || !isValidPermsInit(permsInit)) {
|
|
38
|
+
return { success: false, reason: "초기화 값이 유효하지 않음" };
|
|
39
|
+
}
|
|
40
|
+
const permsCallExpr = permsInit;
|
|
41
|
+
const arrowFunction = getArrowFunction(permsCallExpr);
|
|
42
|
+
if (!arrowFunction) {
|
|
43
|
+
return { success: false, reason: "Arrow function을 찾을 수 없음" };
|
|
44
|
+
}
|
|
45
|
+
const callExpression = getPermsCallExpression(arrowFunction);
|
|
46
|
+
if (!callExpression) {
|
|
47
|
+
return { success: false, reason: "getViewPerms 호출을 찾을 수 없음" };
|
|
48
|
+
}
|
|
49
|
+
const args = callExpression.getArguments();
|
|
50
|
+
if (args.length !== 2) {
|
|
51
|
+
return { success: false, reason: "인자 개수가 맞지 않음" };
|
|
52
|
+
}
|
|
53
|
+
// 변환 실행
|
|
54
|
+
const viewCodesText = viewCodesInit.getText();
|
|
55
|
+
const permsText = args[1].getText();
|
|
56
|
+
permsProp.setInitializer(`usePermsSignal(${viewCodesText}, ${permsText})`);
|
|
57
|
+
viewCodesProp.remove();
|
|
58
|
+
return { success: true };
|
|
59
|
+
}
|
|
60
|
+
function getPropertyDeclaration(cls, name) {
|
|
61
|
+
const prop = cls.getInstanceProperty(name);
|
|
62
|
+
return prop?.getKind() === SyntaxKind.PropertyDeclaration ? prop : undefined;
|
|
63
|
+
}
|
|
64
|
+
function isValidViewCodesInit(init) {
|
|
65
|
+
return init?.getKind() === SyntaxKind.ArrayLiteralExpression;
|
|
66
|
+
}
|
|
67
|
+
function isValidPermsInit(init) {
|
|
68
|
+
return init?.getKind() === SyntaxKind.CallExpression;
|
|
69
|
+
}
|
|
70
|
+
function getArrowFunction(callExpr) {
|
|
71
|
+
const firstArg = callExpr.getArguments().first();
|
|
72
|
+
return firstArg?.getKind() === SyntaxKind.ArrowFunction ? firstArg : undefined;
|
|
73
|
+
}
|
|
74
|
+
function getPermsCallExpression(arrowFn) {
|
|
75
|
+
const body = arrowFn.getBody();
|
|
76
|
+
if (body.getKind() !== SyntaxKind.CallExpression) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
const callExpr = body;
|
|
80
|
+
return callExpr.getText().includes("this._sdAppStructure.getViewPerms") ? callExpr : undefined;
|
|
81
|
+
}
|
|
82
|
+
function addImportIfNeeded(sourceFile) {
|
|
83
|
+
const sdAngularImport = sourceFile.getImportDeclaration((d) => d.getModuleSpecifierValue() === "@simplysm/sd-angular");
|
|
84
|
+
if (sdAngularImport) {
|
|
85
|
+
const hasImport = sdAngularImport
|
|
86
|
+
.getNamedImports()
|
|
87
|
+
.some((n) => n.getName() === "usePermsSignal");
|
|
88
|
+
if (!hasImport) {
|
|
89
|
+
sdAngularImport.addNamedImport("usePermsSignal");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
sourceFile.addImportDeclaration({
|
|
94
|
+
namedImports: ["usePermsSignal"],
|
|
95
|
+
moduleSpecifier: "@simplysm/sd-angular",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=convert-to-use-perms-signal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-to-use-perms-signal.js","sourceRoot":"","sources":["../../src/fix/convert-to-use-perms-signal.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAKL,UAAU,GACX,MAAM,UAAU,CAAC;AAClB,OAAO,qBAAqB,MAAM,kCAAkC,CAAC;AAErE,MAAM,UAAU,uBAAuB;IACrC,MAAM,WAAW,GAAG,qBAAqB,EAAE,CA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E;aACjB,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,gBAAgB,CAAC,CAAC;QAEtD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,eAAe,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,oBAAoB,CAAC;YAC9B,YAAY,EAAE,CAAC,gBAAgB,CAAC;YAChC,eAAe,EAAE,sBAAsB;SACxC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function removeUnusedImports(): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { SyntaxKind } from "ts-morph";
|
|
3
|
+
import getTsMorphSourceFiles from "./core/get-ts-morph-source-files";
|
|
4
|
+
export function removeUnusedImports() {
|
|
5
|
+
const sourceFiles = getTsMorphSourceFiles();
|
|
6
|
+
let totalChanged = 0;
|
|
7
|
+
for (const sourceFile of sourceFiles) {
|
|
8
|
+
let changed = false;
|
|
9
|
+
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
10
|
+
// ⚠️ 사이드이펙트 import는 유지
|
|
11
|
+
if (importDecl.getNamedImports().length === 0) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
// ⚙️ Named import 제거
|
|
15
|
+
for (const namedImport of importDecl.getNamedImports()) {
|
|
16
|
+
const name = namedImport.getName();
|
|
17
|
+
const used = sourceFile
|
|
18
|
+
.getDescendantsOfKind(SyntaxKind.Identifier)
|
|
19
|
+
.some((id) => id.getText() === name && id !== namedImport.getNameNode());
|
|
20
|
+
if (!used) {
|
|
21
|
+
namedImport.remove();
|
|
22
|
+
changed = true;
|
|
23
|
+
console.log(`[정리됨] ${sourceFile.getBaseName()} → 미사용 import: ${name}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// 모든 import가 제거된 경우 전체 import 선언 제거
|
|
27
|
+
if (importDecl.getNamedImports().length === 0) {
|
|
28
|
+
importDecl.remove();
|
|
29
|
+
changed = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (changed) {
|
|
33
|
+
sourceFile.saveSync();
|
|
34
|
+
totalChanged++;
|
|
35
|
+
console.log(`[updated] ${sourceFile.getBaseName()} :: import 정리 완료`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
console.log(totalChanged > 0
|
|
39
|
+
? `\n[완료] 미사용 import 정리 완료 (총 ${totalChanged}개)`
|
|
40
|
+
: `[완료] 정리 대상 없음`);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=remove-unused-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-unused-imports.js","sourceRoot":"","sources":["../../src/fix/remove-unused-imports.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,qBAAqB,MAAM,kCAAkC,CAAC;AAErE,MAAM,UAAU,mBAAmB;IACjC,MAAM,WAAW,GAAG,qBAAqB,EAAE,CAAC;IAC5C,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,OAAO,GAAG,KAAK,CAAC;QAEpB,KAAK,MAAM,UAAU,IAAI,UAAU,CAAC,qBAAqB,EAAE,EAAE,CAAC;YAC5D,uBAAuB;YACvB,IAAI,UAAU,CAAC,eAAe,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9C,SAAS;YACX,CAAC;YAED,qBAAqB;YACrB,KAAK,MAAM,WAAW,IAAI,UAAU,CAAC,eAAe,EAAE,EAAE,CAAC;gBACvD,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,EAAE,CAAC;gBACnC,MAAM,IAAI,GAAG,UAAU;qBACpB,oBAAoB,CAAC,UAAU,CAAC,UAAU,CAAC;qBAC3C,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC;gBAC3E,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,WAAW,CAAC,MAAM,EAAE,CAAC;oBACrB,OAAO,GAAG,IAAI,CAAC;oBACf,OAAO,CAAC,GAAG,CAAC,SAAS,UAAU,CAAC,WAAW,EAAE,kBAAkB,IAAI,EAAE,CAAC,CAAC;gBACzE,CAAC;YACH,CAAC;YAED,oCAAoC;YACpC,IAAI,UAAU,CAAC,eAAe,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9C,UAAU,CAAC,MAAM,EAAE,CAAC;gBACpB,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;QACH,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,UAAU,CAAC,QAAQ,EAAE,CAAC;YACtB,YAAY,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,aAAa,UAAU,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CACT,YAAY,GAAG,CAAC;QACd,CAAC,CAAC,8BAA8B,YAAY,IAAI;QAChD,CAAC,CAAC,eAAe,CACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function removeUnusedInjects(): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { SyntaxKind } from "ts-morph";
|
|
3
|
+
import getTsMorphSourceFiles from "./core/get-ts-morph-source-files";
|
|
4
|
+
export function removeUnusedInjects() {
|
|
5
|
+
const sourceFiles = getTsMorphSourceFiles();
|
|
6
|
+
let totalChanged = 0;
|
|
7
|
+
for (const sourceFile of sourceFiles) {
|
|
8
|
+
let changed = false;
|
|
9
|
+
for (const cls of sourceFile.getClasses()) {
|
|
10
|
+
const injectVars = cls
|
|
11
|
+
.getInstanceProperties()
|
|
12
|
+
.filter((p) => p.isKind(SyntaxKind.PropertyDeclaration) &&
|
|
13
|
+
p.getInitializer()?.isKind(SyntaxKind.CallExpression) &&
|
|
14
|
+
p.getInitializer().getText().startsWith("inject("));
|
|
15
|
+
for (const propDecl of injectVars) {
|
|
16
|
+
const name = propDecl.getName();
|
|
17
|
+
// 클래스 전체에서 해당 변수명이 참조되고 있는지 확인
|
|
18
|
+
const references = cls
|
|
19
|
+
.getDescendants()
|
|
20
|
+
.filter((desc) => desc.getText() === name && desc !== propDecl.getNameNode());
|
|
21
|
+
if (references.length === 0) {
|
|
22
|
+
propDecl.remove();
|
|
23
|
+
changed = true;
|
|
24
|
+
console.log(`[정리됨] ${sourceFile.getBaseName()} → 미사용 inject: ${name}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (changed) {
|
|
29
|
+
sourceFile.saveSync();
|
|
30
|
+
totalChanged++;
|
|
31
|
+
console.log(`[updated] ${sourceFile.getBaseName()} :: inject 정리 완료`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
console.log(totalChanged > 0
|
|
35
|
+
? `\n[완료] 미사용 inject 정리 완료 (총 ${totalChanged}개)`
|
|
36
|
+
: `[완료] 정리 대상 없음`);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=remove-unused-injects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-unused-injects.js","sourceRoot":"","sources":["../../src/fix/remove-unused-injects.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,qBAAqB,MAAM,kCAAkC,CAAC;AAErE,MAAM,UAAU,mBAAmB;IACjC,MAAM,WAAW,GAAG,qBAAqB,EAAE,CAAC;IAC5C,I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CAAC;QACvE,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CACT,YAAY,GAAG,CAAC;QACd,CAAC,CAAC,8BAA8B,YAAY,IAAI;QAChD,CAAC,CAAC,eAAe,CACpB,CAAC;AACJ,CAAC"}
|
package/dist/sd-cli-entry.js
CHANGED
|
@@ -20,6 +20,11 @@ import prefixUnderscoreForAccessModifiers from "./fix/prefix-underscore-for-acce
|
|
|
20
20
|
import removeSdAngularSymbolNames from "./fix/remove-sd-angular-symbol-names";
|
|
21
21
|
import { convertExtendsSdPrintTemplateBaseToInterface } from "./fix/convert-extends-sd-print-template-base-to-interface";
|
|
22
22
|
import convertPrintParams from "./fix/convert-print-params";
|
|
23
|
+
import { convertToUsePermsSignal } from "./fix/convert-to-use-perms-signal";
|
|
24
|
+
import { convertGetMenusToUsableMenus } from "./fix/convert-get-menus-to-usable-menus";
|
|
25
|
+
import { removeUnusedInjects } from "./fix/remove-unused-injects";
|
|
26
|
+
import { removeUnusedImports } from "./fix/remove-unused-imports";
|
|
27
|
+
import { convertFlatPagesToUsableFlatMenus } from "./fix/convert-flat-pages-to-flat-menus";
|
|
23
28
|
Error.stackTraceLimit = Infinity;
|
|
24
29
|
EventEmitter.defaultMaxListeners = 0;
|
|
25
30
|
await yargs(hideBin(process.argv))
|
|
@@ -211,9 +216,15 @@ await yargs(hideBin(process.argv))
|
|
|
211
216
|
convertModalShowParams();
|
|
212
217
|
convertExtendsSdPrintTemplateBaseToInterface();
|
|
213
218
|
convertPrintParams();
|
|
214
|
-
|
|
219
|
+
convertToUsePermsSignal();
|
|
220
|
+
convertGetMenusToUsableMenus();
|
|
221
|
+
convertFlatPagesToUsableFlatMenus();
|
|
222
|
+
//-- 심볼정리
|
|
215
223
|
removeSdAngularSymbolNames();
|
|
216
224
|
convertSdAngularSymbolNames();
|
|
225
|
+
//-- inject/import 정리
|
|
226
|
+
removeUnusedInjects();
|
|
227
|
+
removeUnusedImports();
|
|
217
228
|
})
|
|
218
229
|
.strict()
|
|
219
230
|
.recommendCommands()
|
package/dist/sd-cli-entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sd-cli-entry.js","sourceRoot":"","sources":["../src/sd-cli-entry.ts"],"names":[],"mappings":";AAEA,+BAA+B;AAE/B,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,6BAA6B,MAAM,0CAA0C,CAAC;AACrF,OAAO,EACL,oCAAoC,EACrC,MAAM,kDAAkD,CAAC;AAC1D,OAAO,sBAAsB,MAAM,iCAAiC,CAAC;AACrE,OAAO,2BAA2B,MAAM,uCAAuC,CAAC;AAChF,OAAO,sCAAsC,MACtC,mDAAmD,CAAC;AAC3D,OAAO,6CAA6C,MAC7C,4DAA4D,CAAC;AACpE,OAAO,kCAAkC,MAAM,8CAA8C,CAAC;AAC9F,OAAO,0BAA0B,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EACL,4CAA4C,EAC7C,MAAM,2DAA2D,CAAC;AACnE,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"sd-cli-entry.js","sourceRoot":"","sources":["../src/sd-cli-entry.ts"],"names":[],"mappings":";AAEA,+BAA+B;AAE/B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AAC;IACZ,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACzB,GAAG,CAAC,QAAQ,EAAE,CAAC;IACf,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;KACD,UAAU,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/sd-cli",
|
|
3
|
-
"version": "12.11.
|
|
3
|
+
"version": "12.11.5",
|
|
4
4
|
"description": "심플리즘 패키지 - CLI",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"repository": {
|
|
@@ -12,19 +12,19 @@
|
|
|
12
12
|
"bin": "./dist/sd-cli.js",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@angular/build": "^
|
|
16
|
-
"@angular/compiler": "^
|
|
17
|
-
"@angular/compiler-cli": "^
|
|
15
|
+
"@angular/build": "^20.0.0",
|
|
16
|
+
"@angular/compiler": "^20.0.0",
|
|
17
|
+
"@angular/compiler-cli": "^20.0.0",
|
|
18
18
|
"@anthropic-ai/sdk": "^0.52.0",
|
|
19
19
|
"@electron/rebuild": "^4.0.1",
|
|
20
|
-
"@simplysm/sd-core-common": "12.11.
|
|
21
|
-
"@simplysm/sd-core-node": "12.11.
|
|
22
|
-
"@simplysm/sd-service-server": "12.11.
|
|
23
|
-
"@simplysm/sd-storage": "12.11.
|
|
24
|
-
"browserslist": "^4.
|
|
20
|
+
"@simplysm/sd-core-common": "12.11.5",
|
|
21
|
+
"@simplysm/sd-core-node": "12.11.5",
|
|
22
|
+
"@simplysm/sd-service-server": "12.11.5",
|
|
23
|
+
"@simplysm/sd-storage": "12.11.5",
|
|
24
|
+
"browserslist": "^4.25.0",
|
|
25
25
|
"cordova": "^12.0.0",
|
|
26
26
|
"css-has-pseudo": "^7.0.2",
|
|
27
|
-
"electron": "^36.3.
|
|
27
|
+
"electron": "^36.3.2",
|
|
28
28
|
"electron-builder": "26.0.15",
|
|
29
29
|
"esbuild": "^0.25.5",
|
|
30
30
|
"eslint": "^9.27.0",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"semver": "^7.7.2",
|
|
37
37
|
"specifier-resolution-node": "^1.1.4",
|
|
38
38
|
"ts-morph": "^26.0.0",
|
|
39
|
-
"
|
|
39
|
+
"tslib": "^2.8.1",
|
|
40
|
+
"typescript": "~5.8.3",
|
|
40
41
|
"yargs": "^18.0.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { SyntaxKind } from "ts-morph";
|
|
3
|
+
import getTsMorphSourceFiles from "./core/get-ts-morph-source-files";
|
|
4
|
+
|
|
5
|
+
export function convertFlatPagesToUsableFlatMenus() {
|
|
6
|
+
const sourceFiles = getTsMorphSourceFiles();
|
|
7
|
+
let totalChanged = 0;
|
|
8
|
+
|
|
9
|
+
for (const sourceFile of sourceFiles) {
|
|
10
|
+
let changed = false;
|
|
11
|
+
|
|
12
|
+
for (const cls of sourceFile.getClasses()) {
|
|
13
|
+
// 1. flatPages property 선언 확인
|
|
14
|
+
const prop = cls.getInstanceProperty("flatPages")?.asKind(SyntaxKind.PropertyDeclaration);
|
|
15
|
+
if (!prop) continue;
|
|
16
|
+
|
|
17
|
+
const initializer = prop.getInitializer();
|
|
18
|
+
if (!initializer) continue;
|
|
19
|
+
|
|
20
|
+
const callExpr = initializer.asKind(SyntaxKind.CallExpression);
|
|
21
|
+
if (!callExpr) continue;
|
|
22
|
+
|
|
23
|
+
const expr = callExpr.getExpression();
|
|
24
|
+
if (
|
|
25
|
+
expr.getKind() === SyntaxKind.PropertyAccessExpression &&
|
|
26
|
+
expr.getText() === "this._sdAppStructure.getFlatPages"
|
|
27
|
+
) {
|
|
28
|
+
// 2. 선언 변경
|
|
29
|
+
prop.rename("flatMenus");
|
|
30
|
+
prop.setInitializer("this._sdAppStructure.usableFlatMenus()");
|
|
31
|
+
changed = true;
|
|
32
|
+
console.log(`[변환됨] ${sourceFile.getBaseName()} → flatPages 선언 → flatMenus`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 3. 클래스 내 this.flatPages → this.flatMenus 치환
|
|
36
|
+
cls.forEachDescendant((node) => {
|
|
37
|
+
if (node.getKind() === SyntaxKind.PropertyAccessExpression) {
|
|
38
|
+
const propAccess = node.asKind(SyntaxKind.PropertyAccessExpression)!;
|
|
39
|
+
if (
|
|
40
|
+
propAccess.getExpression().getKind() === SyntaxKind.ThisKeyword &&
|
|
41
|
+
propAccess.getName() === "flatPages"
|
|
42
|
+
) {
|
|
43
|
+
propAccess.replaceWithText("this.flatMenus");
|
|
44
|
+
changed = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// 4. @Component의 template 내 문자열 치환
|
|
50
|
+
const componentDecorator = cls.getDecorator("Component");
|
|
51
|
+
const arg = componentDecorator?.getArguments()[0]?.asKind(SyntaxKind.ObjectLiteralExpression);
|
|
52
|
+
const templateProp = arg?.getProperty("template")?.asKind(SyntaxKind.PropertyAssignment);
|
|
53
|
+
const templateInit = templateProp?.getInitializer();
|
|
54
|
+
if (
|
|
55
|
+
templateInit &&
|
|
56
|
+
(templateInit.getKind() === SyntaxKind.NoSubstitutionTemplateLiteral ||
|
|
57
|
+
templateInit.getKind() === SyntaxKind.StringLiteral ||
|
|
58
|
+
templateInit.getKind() === SyntaxKind.TemplateExpression)
|
|
59
|
+
) {
|
|
60
|
+
const originalText = templateInit.getText();
|
|
61
|
+
const newText = originalText.replace(/\bflatPages\b/g, "flatMenus");
|
|
62
|
+
|
|
63
|
+
if (newText !== originalText) {
|
|
64
|
+
templateInit.replaceWithText(newText);
|
|
65
|
+
changed = true;
|
|
66
|
+
console.log(`[변환됨] ${sourceFile.getBaseName()} → 템플릿 내 flatPages → flatMenus`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (changed) {
|
|
72
|
+
sourceFile.saveSync();
|
|
73
|
+
totalChanged++;
|
|
74
|
+
console.log(`[updated] ${sourceFile.getBaseName()} :: flatMenus 변환 완료`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log(
|
|
79
|
+
totalChanged > 0
|
|
80
|
+
? `\n[완료] flatPages → flatMenus 전체 변환 완료 (총 ${totalChanged}개)`
|
|
81
|
+
: `[완료] 변환 대상 없음`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { SyntaxKind } from "ts-morph";
|
|
3
|
+
import getTsMorphSourceFiles from "./core/get-ts-morph-source-files";
|
|
4
|
+
|
|
5
|
+
export function convertGetMenusToUsableMenus() {
|
|
6
|
+
const sourceFiles = getTsMorphSourceFiles();
|
|
7
|
+
let totalChanged = 0;
|
|
8
|
+
|
|
9
|
+
for (const sourceFile of sourceFiles) {
|
|
10
|
+
let changed = false;
|
|
11
|
+
|
|
12
|
+
for (const cls of sourceFile.getClasses()) {
|
|
13
|
+
const menusProp = cls.getInstanceProperty("menus")?.asKind(SyntaxKind.PropertyDeclaration);
|
|
14
|
+
if (!menusProp) continue;
|
|
15
|
+
|
|
16
|
+
const initializer = menusProp.getInitializer()?.asKind(SyntaxKind.CallExpression);
|
|
17
|
+
if (
|
|
18
|
+
!initializer ||
|
|
19
|
+
initializer.getFirstChildByKind(SyntaxKind.Identifier)?.getText() !== "$computed"
|
|
20
|
+
) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const arrowFn = initializer
|
|
25
|
+
.asKind(SyntaxKind.CallExpression)
|
|
26
|
+
?.getArguments()
|
|
27
|
+
.first()
|
|
28
|
+
?.asKind(SyntaxKind.ArrowFunction);
|
|
29
|
+
if (!arrowFn) continue;
|
|
30
|
+
|
|
31
|
+
const body = arrowFn.getBody().asKind(SyntaxKind.CallExpression);
|
|
32
|
+
if (!body || !body.getText().includes("this._sdAppStructure.getMenus")) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const callExpr = body.asKind(SyntaxKind.CallExpression)!;
|
|
37
|
+
const calleeExpr = callExpr.getExpression();
|
|
38
|
+
if (
|
|
39
|
+
calleeExpr.getKind() === SyntaxKind.PropertyAccessExpression &&
|
|
40
|
+
calleeExpr.getText() === "this._sdAppStructure.getMenus"
|
|
41
|
+
) {
|
|
42
|
+
// 수정 실행: getMenus → usableMenus
|
|
43
|
+
calleeExpr.replaceWithText("this._sdAppStructure.usableMenus");
|
|
44
|
+
changed = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (changed) {
|
|
49
|
+
sourceFile.saveSync();
|
|
50
|
+
totalChanged++;
|
|
51
|
+
console.log(`[updated] ${sourceFile.getBaseName()} :: menus → usableMenus 변경 완료`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
console.log(
|
|
56
|
+
totalChanged > 0
|
|
57
|
+
? `\n[완료] usableMenus 변경 완료 (총 ${totalChanged}개)`
|
|
58
|
+
: `[완료] 변환 대상 없음`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import {
|
|
3
|
+
ArrowFunction,
|
|
4
|
+
CallExpression,
|
|
5
|
+
PropertyDeclaration,
|
|
6
|
+
SourceFile,
|
|
7
|
+
SyntaxKind,
|
|
8
|
+
} from "ts-morph";
|
|
9
|
+
import getTsMorphSourceFiles from "./core/get-ts-morph-source-files";
|
|
10
|
+
|
|
11
|
+
export function convertToUsePermsSignal() {
|
|
12
|
+
const sourceFiles = getTsMorphSourceFiles();
|
|
13
|
+
let totalChanged = 0;
|
|
14
|
+
|
|
15
|
+
for (const sourceFile of sourceFiles) {
|
|
16
|
+
let changed = false;
|
|
17
|
+
|
|
18
|
+
for (const cls of sourceFile.getClasses()) {
|
|
19
|
+
try {
|
|
20
|
+
const result = processClass(cls);
|
|
21
|
+
if (result.success) {
|
|
22
|
+
changed = true;
|
|
23
|
+
}
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error(`[오류] ${sourceFile.getBaseName()} 클래스 처리 중 오류:`, error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (changed) {
|
|
30
|
+
addImportIfNeeded(sourceFile);
|
|
31
|
+
sourceFile.saveSync();
|
|
32
|
+
totalChanged++;
|
|
33
|
+
console.log(`[updated] ${sourceFile.getBaseName()} :: usePermsSignal 변환 완료`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log(
|
|
38
|
+
totalChanged > 0 ? `\n[완료] 변환 완료 (총 ${totalChanged}개)` : `[완료] 변환 대상 없음`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function processClass(cls: any) {
|
|
43
|
+
const viewCodesProp = getPropertyDeclaration(cls, "viewCodes");
|
|
44
|
+
const permsProp = getPropertyDeclaration(cls, "perms");
|
|
45
|
+
|
|
46
|
+
if (!viewCodesProp || !permsProp) {
|
|
47
|
+
return { success: false, reason: "필수 프로퍼티 없음" };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const viewCodesInit = viewCodesProp.getInitializer();
|
|
51
|
+
const permsInit = permsProp.getInitializer();
|
|
52
|
+
|
|
53
|
+
if (!isValidViewCodesInit(viewCodesInit) || !isValidPermsInit(permsInit)) {
|
|
54
|
+
return { success: false, reason: "초기화 값이 유효하지 않음" };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const permsCallExpr = permsInit as CallExpression;
|
|
58
|
+
const arrowFunction = getArrowFunction(permsCallExpr);
|
|
59
|
+
|
|
60
|
+
if (!arrowFunction) {
|
|
61
|
+
return { success: false, reason: "Arrow function을 찾을 수 없음" };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const callExpression = getPermsCallExpression(arrowFunction);
|
|
65
|
+
|
|
66
|
+
if (!callExpression) {
|
|
67
|
+
return { success: false, reason: "getViewPerms 호출을 찾을 수 없음" };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const args = callExpression.getArguments();
|
|
71
|
+
if (args.length !== 2) {
|
|
72
|
+
return { success: false, reason: "인자 개수가 맞지 않음" };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 변환 실행
|
|
76
|
+
const viewCodesText = viewCodesInit!.getText();
|
|
77
|
+
const permsText = args[1].getText();
|
|
78
|
+
|
|
79
|
+
permsProp.setInitializer(`usePermsSignal(${viewCodesText}, ${permsText})`);
|
|
80
|
+
viewCodesProp.remove();
|
|
81
|
+
|
|
82
|
+
return { success: true };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function getPropertyDeclaration(cls: any, name: string): PropertyDeclaration | undefined {
|
|
86
|
+
const prop = cls.getInstanceProperty(name);
|
|
87
|
+
return prop?.getKind() === SyntaxKind.PropertyDeclaration ? prop : undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function isValidViewCodesInit(init: any): boolean {
|
|
91
|
+
return init?.getKind() === SyntaxKind.ArrayLiteralExpression;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function isValidPermsInit(init: any): boolean {
|
|
95
|
+
return init?.getKind() === SyntaxKind.CallExpression;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getArrowFunction(callExpr: CallExpression): ArrowFunction | undefined {
|
|
99
|
+
const firstArg = callExpr.getArguments().first();
|
|
100
|
+
return firstArg?.getKind() === SyntaxKind.ArrowFunction ? (firstArg as ArrowFunction) : undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getPermsCallExpression(arrowFn: ArrowFunction): CallExpression | undefined {
|
|
104
|
+
const body = arrowFn.getBody();
|
|
105
|
+
|
|
106
|
+
if (body.getKind() !== SyntaxKind.CallExpression) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const callExpr = body as CallExpression;
|
|
111
|
+
return callExpr.getText().includes("this._sdAppStructure.getViewPerms") ? callExpr : undefined;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function addImportIfNeeded(sourceFile: SourceFile) {
|
|
115
|
+
const sdAngularImport = sourceFile.getImportDeclaration(
|
|
116
|
+
(d: any) => d.getModuleSpecifierValue() === "@simplysm/sd-angular",
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
if (sdAngularImport) {
|
|
120
|
+
const hasImport = sdAngularImport
|
|
121
|
+
.getNamedImports()
|
|
122
|
+
.some((n: any) => n.getName() === "usePermsSignal");
|
|
123
|
+
|
|
124
|
+
if (!hasImport) {
|
|
125
|
+
sdAngularImport.addNamedImport("usePermsSignal");
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
sourceFile.addImportDeclaration({
|
|
129
|
+
namedImports: ["usePermsSignal"],
|
|
130
|
+
moduleSpecifier: "@simplysm/sd-angular",
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { SyntaxKind } from "ts-morph";
|
|
3
|
+
import getTsMorphSourceFiles from "./core/get-ts-morph-source-files";
|
|
4
|
+
|
|
5
|
+
export function removeUnusedImports() {
|
|
6
|
+
const sourceFiles = getTsMorphSourceFiles();
|
|
7
|
+
let totalChanged = 0;
|
|
8
|
+
|
|
9
|
+
for (const sourceFile of sourceFiles) {
|
|
10
|
+
let changed = false;
|
|
11
|
+
|
|
12
|
+
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
13
|
+
// ⚠️ 사이드이펙트 import는 유지
|
|
14
|
+
if (importDecl.getNamedImports().length === 0) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ⚙️ Named import 제거
|
|
19
|
+
for (const namedImport of importDecl.getNamedImports()) {
|
|
20
|
+
const name = namedImport.getName();
|
|
21
|
+
const used = sourceFile
|
|
22
|
+
.getDescendantsOfKind(SyntaxKind.Identifier)
|
|
23
|
+
.some((id) => id.getText() === name && id !== namedImport.getNameNode());
|
|
24
|
+
if (!used) {
|
|
25
|
+
namedImport.remove();
|
|
26
|
+
changed = true;
|
|
27
|
+
console.log(`[정리됨] ${sourceFile.getBaseName()} → 미사용 import: ${name}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 모든 import가 제거된 경우 전체 import 선언 제거
|
|
32
|
+
if (importDecl.getNamedImports().length === 0) {
|
|
33
|
+
importDecl.remove();
|
|
34
|
+
changed = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (changed) {
|
|
39
|
+
sourceFile.saveSync();
|
|
40
|
+
totalChanged++;
|
|
41
|
+
console.log(`[updated] ${sourceFile.getBaseName()} :: import 정리 완료`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log(
|
|
46
|
+
totalChanged > 0
|
|
47
|
+
? `\n[완료] 미사용 import 정리 완료 (총 ${totalChanged}개)`
|
|
48
|
+
: `[완료] 정리 대상 없음`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { SyntaxKind } from "ts-morph";
|
|
3
|
+
import getTsMorphSourceFiles from "./core/get-ts-morph-source-files";
|
|
4
|
+
|
|
5
|
+
export function removeUnusedInjects() {
|
|
6
|
+
const sourceFiles = getTsMorphSourceFiles();
|
|
7
|
+
let totalChanged = 0;
|
|
8
|
+
|
|
9
|
+
for (const sourceFile of sourceFiles) {
|
|
10
|
+
let changed = false;
|
|
11
|
+
|
|
12
|
+
for (const cls of sourceFile.getClasses()) {
|
|
13
|
+
const injectVars = cls
|
|
14
|
+
.getInstanceProperties()
|
|
15
|
+
.filter(
|
|
16
|
+
(p) =>
|
|
17
|
+
p.isKind(SyntaxKind.PropertyDeclaration) &&
|
|
18
|
+
p.getInitializer()?.isKind(SyntaxKind.CallExpression) &&
|
|
19
|
+
p.getInitializer()!.getText().startsWith("inject("),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
for (const propDecl of injectVars) {
|
|
23
|
+
const name = propDecl.getName();
|
|
24
|
+
|
|
25
|
+
// 클래스 전체에서 해당 변수명이 참조되고 있는지 확인
|
|
26
|
+
const references = cls
|
|
27
|
+
.getDescendants()
|
|
28
|
+
.filter((desc) => desc.getText() === name && desc !== propDecl.getNameNode());
|
|
29
|
+
|
|
30
|
+
if (references.length === 0) {
|
|
31
|
+
propDecl.remove();
|
|
32
|
+
changed = true;
|
|
33
|
+
console.log(`[정리됨] ${sourceFile.getBaseName()} → 미사용 inject: ${name}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (changed) {
|
|
39
|
+
sourceFile.saveSync();
|
|
40
|
+
totalChanged++;
|
|
41
|
+
console.log(`[updated] ${sourceFile.getBaseName()} :: inject 정리 완료`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log(
|
|
46
|
+
totalChanged > 0
|
|
47
|
+
? `\n[완료] 미사용 inject 정리 완료 (총 ${totalChanged}개)`
|
|
48
|
+
: `[완료] 정리 대상 없음`,
|
|
49
|
+
);
|
|
50
|
+
}
|
package/src/sd-cli-entry.ts
CHANGED
|
@@ -28,6 +28,11 @@ import {
|
|
|
28
28
|
convertExtendsSdPrintTemplateBaseToInterface
|
|
29
29
|
} from "./fix/convert-extends-sd-print-template-base-to-interface";
|
|
30
30
|
import convertPrintParams from "./fix/convert-print-params";
|
|
31
|
+
import { convertToUsePermsSignal } from "./fix/convert-to-use-perms-signal";
|
|
32
|
+
import { convertGetMenusToUsableMenus } from "./fix/convert-get-menus-to-usable-menus";
|
|
33
|
+
import { removeUnusedInjects } from "./fix/remove-unused-injects";
|
|
34
|
+
import { removeUnusedImports } from "./fix/remove-unused-imports";
|
|
35
|
+
import { convertFlatPagesToUsableFlatMenus } from "./fix/convert-flat-pages-to-flat-menus";
|
|
31
36
|
|
|
32
37
|
Error.stackTraceLimit = Infinity;
|
|
33
38
|
EventEmitter.defaultMaxListeners = 0;
|
|
@@ -277,10 +282,17 @@ await yargs(hideBin(process.argv))
|
|
|
277
282
|
convertModalShowParams();
|
|
278
283
|
convertExtendsSdPrintTemplateBaseToInterface();
|
|
279
284
|
convertPrintParams();
|
|
285
|
+
convertToUsePermsSignal();
|
|
286
|
+
convertGetMenusToUsableMenus();
|
|
287
|
+
convertFlatPagesToUsableFlatMenus();
|
|
280
288
|
|
|
281
|
-
//--
|
|
289
|
+
//-- 심볼정리
|
|
282
290
|
removeSdAngularSymbolNames();
|
|
283
291
|
convertSdAngularSymbolNames();
|
|
292
|
+
|
|
293
|
+
//-- inject/import 정리
|
|
294
|
+
removeUnusedInjects();
|
|
295
|
+
removeUnusedImports();
|
|
284
296
|
},
|
|
285
297
|
)
|
|
286
298
|
.strict()
|
|
@@ -11,7 +11,7 @@ describe("SdDependencyCache", () => {
|
|
|
11
11
|
const b = PathUtils.norm("/b.ts");
|
|
12
12
|
const c = PathUtils.norm("/c.ts");
|
|
13
13
|
const html = PathUtils.norm("/comp.html");
|
|
14
|
-
const style = PathUtils.norm("/style.scss");
|
|
14
|
+
// const style = PathUtils.norm("/style.scss");
|
|
15
15
|
|
|
16
16
|
let depCache: SdDependencyCache;
|
|
17
17
|
|
|
@@ -127,10 +127,10 @@ describe("SdDependencyCache", () => {
|
|
|
127
127
|
const trees = depCache.getAffectedFileTree(new Set([a]));
|
|
128
128
|
|
|
129
129
|
expect(trees.length).toBeGreaterThan(0);
|
|
130
|
-
const aNode = trees.find(t => t.fileNPath === a)!;
|
|
131
|
-
expect(aNode.children.some(c1 => c1.fileNPath === b)).toBeTruthy();
|
|
132
|
-
const bNode = aNode.children.find(c1 => c1.fileNPath === b)!;
|
|
133
|
-
expect(bNode.children.some(c2 => c2.fileNPath === c)).toBeTruthy();
|
|
130
|
+
const aNode = trees.find((t) => t.fileNPath === a)!;
|
|
131
|
+
expect(aNode.children.some((c1) => c1.fileNPath === b)).toBeTruthy();
|
|
132
|
+
const bNode = aNode.children.find((c1) => c1.fileNPath === b)!;
|
|
133
|
+
expect(bNode.children.some((c2) => c2.fileNPath === c)).toBeTruthy();
|
|
134
134
|
|
|
135
135
|
const printTree = (node: ISdAffectedFileTreeNode, indent = "") => {
|
|
136
136
|
console.log(indent + node.fileNPath);
|