@simplysm/sd-cli 7.0.249 → 7.0.267
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 +95 -0
- package/assets/client-files/assets/icons/icon-128x128.png +0 -0
- package/assets/client-files/assets/icons/icon-144x144.png +0 -0
- package/assets/client-files/assets/icons/icon-152x152.png +0 -0
- package/assets/client-files/assets/icons/icon-192x192.png +0 -0
- package/assets/client-files/assets/icons/icon-384x384.png +0 -0
- package/assets/client-files/assets/icons/icon-512x512.png +0 -0
- package/assets/client-files/assets/icons/icon-72x72.png +0 -0
- package/assets/client-files/assets/icons/icon-96x96.png +0 -0
- package/assets/client-files/favicon.ico +0 -0
- package/dist/bin/sd-cli.mjs +212 -15
- package/dist/build-tool/SdCliCordova.mjs +3 -3
- package/dist/build-tool/SdCliElectron.mjs +3 -2
- package/dist/build-tool/SdCliIndexFileGenerator.mjs +2 -3
- package/dist/builder/SdCliClientBuilder.d.ts +2 -0
- package/dist/builder/SdCliClientBuilder.mjs +57 -20
- package/dist/builder/SdCliServerBuilder.d.ts +2 -0
- package/dist/builder/SdCliServerBuilder.mjs +27 -13
- package/dist/builder/SdCliTsLibBuilder.mjs +18 -12
- package/dist/commons.d.ts +6 -1
- package/dist/entry-points/SdCliPrepare.mjs +34 -34
- package/dist/entry-points/SdCliProjectGenerator.d.ts +44 -0
- package/dist/entry-points/SdCliProjectGenerator.mjs +320 -0
- package/dist/entry-points/SdCliWorkspace.d.ts +6 -6
- package/dist/entry-points/SdCliWorkspace.mjs +61 -107
- package/dist/entry-points/file/base/fc_package_eslintrc.d.ts +3 -0
- package/dist/entry-points/file/base/fc_package_eslintrc.mjs +31 -0
- package/dist/entry-points/file/base/fc_package_npmconfig.d.ts +9 -0
- package/dist/entry-points/file/base/fc_package_npmconfig.mjs +32 -0
- package/dist/entry-points/file/base/fc_package_tsconfig.d.ts +5 -0
- package/dist/entry-points/file/base/fc_package_tsconfig.mjs +13 -0
- package/dist/entry-points/file/client/fc_package_AppModule.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_AppModule.mjs +37 -0
- package/dist/entry-points/file/client/fc_package_AppPage.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_AppPage.mjs +14 -0
- package/dist/entry-points/file/client/fc_package_Page.d.ts +4 -0
- package/dist/entry-points/file/client/fc_package_Page.mjs +19 -0
- package/dist/entry-points/file/client/fc_package_client_main.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_client_main.mjs +19 -0
- package/dist/entry-points/file/client/fc_package_index.d.ts +3 -0
- package/dist/entry-points/file/client/fc_package_index.mjs +88 -0
- package/dist/entry-points/file/client/fc_package_manifest.d.ts +5 -0
- package/dist/entry-points/file/client/fc_package_manifest.mjs +54 -0
- package/dist/entry-points/file/client/fc_package_polyfills.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_polyfills.mjs +11 -0
- package/dist/entry-points/file/client/fc_package_styles.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_styles.mjs +7 -0
- package/dist/entry-points/file/db/fc_package_DbContext.d.ts +3 -0
- package/dist/entry-points/file/db/fc_package_DbContext.mjs +14 -0
- package/dist/entry-points/file/db/fc_package_DbModel.d.ts +4 -0
- package/dist/entry-points/file/db/fc_package_DbModel.mjs +12 -0
- package/dist/entry-points/file/project/fc_project_editor_config.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_editor_config.mjs +22 -0
- package/dist/entry-points/file/project/fc_project_eslintrc.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_eslintrc.mjs +30 -0
- package/dist/entry-points/file/project/fc_project_gitattributes.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_gitattributes.mjs +6 -0
- package/dist/entry-points/file/project/fc_project_gitignore.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_gitignore.mjs +17 -0
- package/dist/entry-points/file/project/fc_project_npmconfig.d.ts +7 -0
- package/dist/entry-points/file/project/fc_project_npmconfig.mjs +35 -0
- package/dist/entry-points/file/project/fc_project_readme.d.ts +3 -0
- package/dist/entry-points/file/project/fc_project_readme.mjs +13 -0
- package/dist/entry-points/file/project/fc_project_simplysm.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_simplysm.mjs +2 -0
- package/dist/entry-points/file/project/fc_project_tsconfig.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_tsconfig.mjs +25 -0
- package/dist/entry-points/file/server/fc_package_server_main.d.ts +4 -0
- package/dist/entry-points/file/server/fc_package_server_main.mjs +60 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.mjs +24 -1
- package/dist/ng-tools/SdCliNgModuleGenerator.mjs +35 -36
- package/dist/packages/SdCliPackage.d.ts +1 -0
- package/dist/packages/SdCliPackage.mjs +69 -63
- package/dist/utils/SdCliBuildResultUtil.mjs +2 -2
- package/docs/client-add-page.md +8 -0
- package/docs/client-router.md +85 -0
- package/docs/client-sw.md +101 -0
- package/docs/conf-orm.md +81 -0
- package/docs/conf-usage.md +5 -0
- package/docs/lib-local-update.md +50 -0
- package/docs/lib-ts-paths.md +25 -0
- package/package.json +10 -8
- package/src/SdCliBuildResultError.ts +9 -9
- package/src/bin/sd-cli.ts +244 -15
- package/src/build-tool/SdCliCacheCompilerHost.ts +77 -77
- package/src/build-tool/SdCliCordova.ts +2 -2
- package/src/build-tool/SdCliElectron.ts +2 -1
- package/src/build-tool/SdCliGithubApi.ts +110 -110
- package/src/build-tool/SdCliIndexFileGenerator.ts +79 -80
- package/src/build-tool/SdCliNgCacheCompilerHost.ts +58 -58
- package/src/build-tool/SdCliPackageLinter.ts +74 -74
- package/src/builder/SdCliClientBuilder.ts +73 -22
- package/src/builder/SdCliJsLibBuilder.ts +70 -70
- package/src/builder/SdCliServerBuilder.ts +34 -14
- package/src/builder/SdCliTsLibBuilder.ts +450 -445
- package/src/commons.ts +6 -1
- package/src/entry-points/SdCliFileCrypto.ts +87 -87
- package/src/entry-points/SdCliPrepare.ts +55 -55
- package/src/entry-points/SdCliProjectGenerator.ts +395 -0
- package/src/entry-points/SdCliWorkspace.ts +74 -122
- package/src/entry-points/file/base/fc_package_eslintrc.ts +30 -0
- package/src/entry-points/file/base/fc_package_npmconfig.ts +43 -0
- package/src/entry-points/file/base/fc_package_tsconfig.ts +12 -0
- package/src/entry-points/file/client/fc_package_AppModule.ts +36 -0
- package/src/entry-points/file/client/fc_package_AppPage.ts +13 -0
- package/src/entry-points/file/client/fc_package_Page.ts +19 -0
- package/src/entry-points/file/client/fc_package_client_main.ts +18 -0
- package/src/entry-points/file/client/fc_package_index.ts +87 -0
- package/src/entry-points/file/client/fc_package_manifest.ts +53 -0
- package/src/entry-points/file/client/fc_package_polyfills.ts +10 -0
- package/src/entry-points/file/client/fc_package_styles.ts +6 -0
- package/src/entry-points/file/db/fc_package_DbContext.ts +14 -0
- package/src/entry-points/file/db/fc_package_DbModel.ts +11 -0
- package/src/entry-points/file/project/fc_project_editor_config.ts +21 -0
- package/src/entry-points/file/project/fc_project_eslintrc.ts +29 -0
- package/src/entry-points/file/project/fc_project_gitattributes.ts +5 -0
- package/src/entry-points/file/project/fc_project_gitignore.ts +16 -0
- package/src/entry-points/file/project/fc_project_npmconfig.ts +34 -0
- package/src/entry-points/file/project/fc_project_readme.ts +12 -0
- package/src/entry-points/file/project/fc_project_simplysm.ts +1 -0
- package/src/entry-points/file/project/fc_project_tsconfig.ts +24 -0
- package/src/entry-points/file/server/fc_package_server_main.ts +62 -0
- package/src/index.ts +55 -32
- package/src/ng-tools/SdCliNgModuleGenerator.ts +639 -640
- package/src/ng-tools/babel/SdCliBbFileMetadata.ts +568 -568
- package/src/ng-tools/babel/SdCliBbRootMetadata.ts +239 -239
- package/src/ng-tools/babel/SdCliBbUtil.ts +15 -15
- package/src/ng-tools/babel/TSdCliBbNgMetadata.ts +234 -234
- package/src/ng-tools/babel/TSdCliBbTypeMetadata.ts +177 -177
- package/src/ng-tools/commons.ts +3 -3
- package/src/ng-tools/typescript/SdCliTsFileMetadata.ts +384 -384
- package/src/ng-tools/typescript/SdCliTsRootMetadata.ts +32 -32
- package/src/ng-tools/typescript/SdCliTsUtil.ts +29 -29
- package/src/packages/SdCliPackage.ts +76 -59
- package/src/utils/SdCliBuildResultUtil.ts +76 -76
- package/src/utils/SdCliConfigUtil.ts +94 -94
- package/src/utils/SdCliNpmConfigUtil.ts +16 -16
package/src/commons.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface INpmConfig {
|
|
|
4
4
|
description?: string;
|
|
5
5
|
author?: string;
|
|
6
6
|
license?: string;
|
|
7
|
-
repository
|
|
7
|
+
repository?: {
|
|
8
8
|
type: string;
|
|
9
9
|
url: string;
|
|
10
10
|
directory?: string;
|
|
@@ -27,6 +27,8 @@ export interface INpmConfig {
|
|
|
27
27
|
|
|
28
28
|
export interface ITsconfig {
|
|
29
29
|
compilerOptions?: {
|
|
30
|
+
module?: string;
|
|
31
|
+
lib?: string[];
|
|
30
32
|
outDir?: string;
|
|
31
33
|
baseUrl?: string;
|
|
32
34
|
paths?: Record<string, string[]>;
|
|
@@ -109,9 +111,11 @@ export interface ISdCliGithubPublishConfig {
|
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
export interface ISdCliClientBuilderWebConfig {
|
|
114
|
+
env?: Record<string, string>;
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
export interface ISdCliClientBuilderCordovaConfig {
|
|
118
|
+
env?: Record<string, string>;
|
|
115
119
|
appId: string;
|
|
116
120
|
appName: string;
|
|
117
121
|
plugins?: string[];
|
|
@@ -136,4 +140,5 @@ export interface ISdCliClientBuilderElectronConfig {
|
|
|
136
140
|
appId: string;
|
|
137
141
|
icon?: string;
|
|
138
142
|
installerIcon?: string;
|
|
143
|
+
env?: Record<string, string>;
|
|
139
144
|
}
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import readline from "readline";
|
|
2
|
-
import { Writable } from "stream";
|
|
3
|
-
import crypto from "crypto";
|
|
4
|
-
import { FsUtil } from "@simplysm/sd-core-node";
|
|
5
|
-
import os from "os";
|
|
6
|
-
|
|
7
|
-
export class SdCliFileCrypto {
|
|
8
|
-
public async encryptAsync(filePath: string): Promise<void> {
|
|
9
|
-
if (!FsUtil.exists(filePath)) {
|
|
10
|
-
throw new Error(`파일 '${filePath}'을 찾을 수 없습니다.`);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const key = await this._readKeyAsync("password: ");
|
|
14
|
-
if (!key) {
|
|
15
|
-
throw new Error("암호화키를 반드시 입력해야 합니다.");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const confirmKey = await this._readKeyAsync("confirm password: ");
|
|
19
|
-
if (key !== confirmKey) {
|
|
20
|
-
throw new Error("암호화키가 서로 다릅니다.");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
this._encryptFile(filePath, key, filePath + ".enc");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public async decryptAsync(encFilePath: string): Promise<void> {
|
|
27
|
-
if (!FsUtil.exists(encFilePath)) {
|
|
28
|
-
throw new Error(`파일 '${encFilePath}'을 찾을 수 없습니다.`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (!encFilePath.endsWith(".enc")) {
|
|
32
|
-
throw new Error(`파일 ${encFilePath}의 확장자가 '.enc'가 아닙니다.`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const resultFilePath = encFilePath.slice(0, -4);
|
|
36
|
-
if (FsUtil.exists(resultFilePath)) {
|
|
37
|
-
process.stdout.write(`복호화 시, 현재 존재하는 '${resultFilePath}'파일을 덮어씁니다.${os.EOL}`, "utf-8");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const key = await this._readKeyAsync("password: ");
|
|
41
|
-
if (!key) {
|
|
42
|
-
throw new Error("암호화키를 반드시 입력해야 합니다.");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this._decryptFile(encFilePath, key, resultFilePath);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
private _encryptFile(filePath: string, key: string, encFilePath: string): void {
|
|
49
|
-
const iv = Buffer.alloc(16, 0);
|
|
50
|
-
const cipheriv = crypto.createCipheriv("aes-192-cbc", crypto.scryptSync(key, "salt", 24), iv);
|
|
51
|
-
|
|
52
|
-
const input = FsUtil.createReadStream(filePath);
|
|
53
|
-
const output = FsUtil.createWriteStream(encFilePath);
|
|
54
|
-
input.pipe(cipheriv).pipe(output);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private _decryptFile(encFilePath: string, key: string, filePath: string): void {
|
|
58
|
-
const iv = Buffer.alloc(16, 0);
|
|
59
|
-
const cipheriv = crypto.createDecipheriv("aes-192-cbc", crypto.scryptSync(key, "salt", 24), iv);
|
|
60
|
-
|
|
61
|
-
const input = FsUtil.createReadStream(encFilePath);
|
|
62
|
-
const output = FsUtil.createWriteStream(filePath);
|
|
63
|
-
input.pipe(cipheriv).pipe(output);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private async _readKeyAsync(message: string): Promise<string> {
|
|
67
|
-
process.stdout.write(message, "utf-8");
|
|
68
|
-
|
|
69
|
-
return await new Promise((resolve) => {
|
|
70
|
-
const rl = readline.createInterface({
|
|
71
|
-
input: process.stdin,
|
|
72
|
-
output: new Writable({
|
|
73
|
-
write: (chunk, encoding, callback) => {
|
|
74
|
-
callback();
|
|
75
|
-
}
|
|
76
|
-
}),
|
|
77
|
-
terminal: true
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
rl.question(message, (answer) => {
|
|
81
|
-
process.stdout.write(os.EOL, "utf-8");
|
|
82
|
-
resolve(answer);
|
|
83
|
-
rl.close();
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
1
|
+
import readline from "readline";
|
|
2
|
+
import { Writable } from "stream";
|
|
3
|
+
import crypto from "crypto";
|
|
4
|
+
import { FsUtil } from "@simplysm/sd-core-node";
|
|
5
|
+
import os from "os";
|
|
6
|
+
|
|
7
|
+
export class SdCliFileCrypto {
|
|
8
|
+
public async encryptAsync(filePath: string): Promise<void> {
|
|
9
|
+
if (!FsUtil.exists(filePath)) {
|
|
10
|
+
throw new Error(`파일 '${filePath}'을 찾을 수 없습니다.`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const key = await this._readKeyAsync("password: ");
|
|
14
|
+
if (!key) {
|
|
15
|
+
throw new Error("암호화키를 반드시 입력해야 합니다.");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const confirmKey = await this._readKeyAsync("confirm password: ");
|
|
19
|
+
if (key !== confirmKey) {
|
|
20
|
+
throw new Error("암호화키가 서로 다릅니다.");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
this._encryptFile(filePath, key, filePath + ".enc");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public async decryptAsync(encFilePath: string): Promise<void> {
|
|
27
|
+
if (!FsUtil.exists(encFilePath)) {
|
|
28
|
+
throw new Error(`파일 '${encFilePath}'을 찾을 수 없습니다.`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!encFilePath.endsWith(".enc")) {
|
|
32
|
+
throw new Error(`파일 ${encFilePath}의 확장자가 '.enc'가 아닙니다.`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const resultFilePath = encFilePath.slice(0, -4);
|
|
36
|
+
if (FsUtil.exists(resultFilePath)) {
|
|
37
|
+
process.stdout.write(`복호화 시, 현재 존재하는 '${resultFilePath}'파일을 덮어씁니다.${os.EOL}`, "utf-8");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const key = await this._readKeyAsync("password: ");
|
|
41
|
+
if (!key) {
|
|
42
|
+
throw new Error("암호화키를 반드시 입력해야 합니다.");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this._decryptFile(encFilePath, key, resultFilePath);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private _encryptFile(filePath: string, key: string, encFilePath: string): void {
|
|
49
|
+
const iv = Buffer.alloc(16, 0);
|
|
50
|
+
const cipheriv = crypto.createCipheriv("aes-192-cbc", crypto.scryptSync(key, "salt", 24), iv);
|
|
51
|
+
|
|
52
|
+
const input = FsUtil.createReadStream(filePath);
|
|
53
|
+
const output = FsUtil.createWriteStream(encFilePath);
|
|
54
|
+
input.pipe(cipheriv).pipe(output);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private _decryptFile(encFilePath: string, key: string, filePath: string): void {
|
|
58
|
+
const iv = Buffer.alloc(16, 0);
|
|
59
|
+
const cipheriv = crypto.createDecipheriv("aes-192-cbc", crypto.scryptSync(key, "salt", 24), iv);
|
|
60
|
+
|
|
61
|
+
const input = FsUtil.createReadStream(encFilePath);
|
|
62
|
+
const output = FsUtil.createWriteStream(filePath);
|
|
63
|
+
input.pipe(cipheriv).pipe(output);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private async _readKeyAsync(message: string): Promise<string> {
|
|
67
|
+
process.stdout.write(message, "utf-8");
|
|
68
|
+
|
|
69
|
+
return await new Promise((resolve) => {
|
|
70
|
+
const rl = readline.createInterface({
|
|
71
|
+
input: process.stdin,
|
|
72
|
+
output: new Writable({
|
|
73
|
+
write: (chunk, encoding, callback) => {
|
|
74
|
+
callback();
|
|
75
|
+
}
|
|
76
|
+
}),
|
|
77
|
+
terminal: true
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
rl.question(message, (answer) => {
|
|
81
|
+
process.stdout.write(os.EOL, "utf-8");
|
|
82
|
+
resolve(answer);
|
|
83
|
+
rl.close();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { FsUtil, Logger } from "@simplysm/sd-core-node";
|
|
2
|
-
import { fileURLToPath } from "url";
|
|
3
|
-
|
|
4
|
-
export class SdCliPrepare {
|
|
5
|
-
private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
|
|
6
|
-
|
|
7
|
-
public async prepareAsync(): Promise<void> {
|
|
8
|
-
// 타입체크 속도 지연 메시지 추가
|
|
9
|
-
const r1 = await this._modifyTypescriptCodeForTypeCheckPerformanceWarning();
|
|
10
|
-
this._logger.log(`[모듈수정] 타입체크 속도 지연 메시지 추가 (${r1 ? "O" : "X"})`);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
private async _modifyTypescriptCodeForTypeCheckPerformanceWarning(): Promise<boolean> {
|
|
14
|
-
const fileUrl = await import.meta.resolve!("typescript");
|
|
15
|
-
const filePath = fileURLToPath(fileUrl);
|
|
16
|
-
const fileContent = await FsUtil.readFileAsync(filePath);
|
|
17
|
-
const modifiedFileContent = fileContent.replace(`
|
|
18
|
-
function checkSourceElement(node) {
|
|
19
|
-
if (node) {
|
|
20
|
-
var saveCurrentNode = currentNode;
|
|
21
|
-
currentNode = node;
|
|
22
|
-
instantiationCount = 0;
|
|
23
|
-
checkSourceElementWorker(node);
|
|
24
|
-
currentNode = saveCurrentNode;
|
|
25
|
-
}
|
|
26
|
-
}`, `
|
|
27
|
-
function checkSourceElement(node) {
|
|
28
|
-
if (node) {
|
|
29
|
-
const prevUsage = process.cpuUsage();
|
|
30
|
-
|
|
31
|
-
var saveCurrentNode = currentNode;
|
|
32
|
-
currentNode = node;
|
|
33
|
-
instantiationCount = 0;
|
|
34
|
-
checkSourceElementWorker(node);
|
|
35
|
-
currentNode = saveCurrentNode;
|
|
36
|
-
|
|
37
|
-
const usage = process.cpuUsage(prevUsage);
|
|
38
|
-
if (node.hasChildPerformanceWarning) {
|
|
39
|
-
node.parent.hasChildPerformanceWarning = true;
|
|
40
|
-
}
|
|
41
|
-
else if (usage.user + usage.system > 1000 * 1000 && node.kind !== 253) {
|
|
42
|
-
error(node, {
|
|
43
|
-
code: 9000,
|
|
44
|
-
category: ts.DiagnosticCategory.Warning,
|
|
45
|
-
key: "simplysm_check_source_element_performance_slow",
|
|
46
|
-
message: "소스코드 타입분석에 너무 오랜 시간이 소요됩니다. [" + Math.round((usage.user + usage.system) / 1000) + "ms/cpu, KIND: " + node.kind + "]"
|
|
47
|
-
});
|
|
48
|
-
node.parent.hasChildPerformanceWarning = true;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}`);
|
|
52
|
-
await FsUtil.writeFileAsync(filePath, modifiedFileContent);
|
|
53
|
-
return modifiedFileContent.includes("const prevUsage = process.cpuUsage();");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
import { FsUtil, Logger } from "@simplysm/sd-core-node";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
|
|
4
|
+
export class SdCliPrepare {
|
|
5
|
+
private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
|
|
6
|
+
|
|
7
|
+
public async prepareAsync(): Promise<void> {
|
|
8
|
+
// 타입체크 속도 지연 메시지 추가
|
|
9
|
+
const r1 = await this._modifyTypescriptCodeForTypeCheckPerformanceWarning();
|
|
10
|
+
this._logger.log(`[모듈수정] 타입체크 속도 지연 메시지 추가 (${r1 ? "O" : "X"})`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
private async _modifyTypescriptCodeForTypeCheckPerformanceWarning(): Promise<boolean> {
|
|
14
|
+
const fileUrl = await import.meta.resolve!("typescript");
|
|
15
|
+
const filePath = fileURLToPath(fileUrl);
|
|
16
|
+
const fileContent = await FsUtil.readFileAsync(filePath);
|
|
17
|
+
const modifiedFileContent = fileContent.replace(`
|
|
18
|
+
function checkSourceElement(node) {
|
|
19
|
+
if (node) {
|
|
20
|
+
var saveCurrentNode = currentNode;
|
|
21
|
+
currentNode = node;
|
|
22
|
+
instantiationCount = 0;
|
|
23
|
+
checkSourceElementWorker(node);
|
|
24
|
+
currentNode = saveCurrentNode;
|
|
25
|
+
}
|
|
26
|
+
}`, `
|
|
27
|
+
function checkSourceElement(node) {
|
|
28
|
+
if (node) {
|
|
29
|
+
const prevUsage = process.cpuUsage();
|
|
30
|
+
|
|
31
|
+
var saveCurrentNode = currentNode;
|
|
32
|
+
currentNode = node;
|
|
33
|
+
instantiationCount = 0;
|
|
34
|
+
checkSourceElementWorker(node);
|
|
35
|
+
currentNode = saveCurrentNode;
|
|
36
|
+
|
|
37
|
+
const usage = process.cpuUsage(prevUsage);
|
|
38
|
+
if (node.hasChildPerformanceWarning) {
|
|
39
|
+
node.parent.hasChildPerformanceWarning = true;
|
|
40
|
+
}
|
|
41
|
+
else if (usage.user + usage.system > 1000 * 1000 && node.kind !== 253) {
|
|
42
|
+
error(node, {
|
|
43
|
+
code: 9000,
|
|
44
|
+
category: ts.DiagnosticCategory.Warning,
|
|
45
|
+
key: "simplysm_check_source_element_performance_slow",
|
|
46
|
+
message: "소스코드 타입분석에 너무 오랜 시간이 소요됩니다. [" + Math.round((usage.user + usage.system) / 1000) + "ms/cpu, KIND: " + node.kind + "]"
|
|
47
|
+
});
|
|
48
|
+
node.parent.hasChildPerformanceWarning = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}`);
|
|
52
|
+
await FsUtil.writeFileAsync(filePath, modifiedFileContent);
|
|
53
|
+
return modifiedFileContent.includes("const prevUsage = process.cpuUsage();");
|
|
54
|
+
}
|
|
55
|
+
}
|