@simplysm/sd-cli 10.0.37 → 10.0.39
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/SdLinter.js.map +1 -1
- package/dist/SdTsIncrementalBuilder.d.ts +17 -4
- package/dist/SdTsIncrementalBuilder.js +18 -32
- package/dist/SdTsIncrementalBuilder.js.map +1 -1
- package/dist/build-cluster.js +98 -30
- package/dist/build-cluster.js.map +1 -1
- package/dist/builders/SdCliClientBuilder.d.ts +6 -2
- package/dist/builders/SdCliClientBuilder.js +107 -114
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.d.ts +2 -1
- package/dist/builders/SdCliServerBuilder.js +38 -12
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +5 -2
- package/dist/builders/SdCliTsLibBuilder.js +64 -10
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/commons.d.ts +28 -2
- package/dist/entry/SdCliElectron.d.ts +7 -0
- package/dist/entry/SdCliElectron.js +42 -0
- package/dist/entry/SdCliElectron.js.map +1 -0
- package/dist/entry/SdCliLocalUpdate.d.ts +12 -0
- package/dist/entry/SdCliLocalUpdate.js +94 -0
- package/dist/entry/SdCliLocalUpdate.js.map +1 -0
- package/dist/entry/SdCliProject.d.ts +3 -3
- package/dist/entry/SdCliProject.js +87 -31
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/sd-cli.d.ts +1 -1
- package/dist/sd-cli.js +74 -13
- package/dist/sd-cli.js.map +1 -1
- package/dist/utils/SdCliBuildResultUtil.js +1 -1
- package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
- package/dist/utils/SdCliViteElectronMainPlugin.d.ts +6 -0
- package/dist/utils/SdCliViteElectronMainPlugin.js +81 -0
- package/dist/utils/SdCliViteElectronMainPlugin.js.map +1 -0
- package/dist/utils/SdCliViteExternalPlugin.d.ts +7 -0
- package/dist/utils/SdCliViteExternalPlugin.js +98 -0
- package/dist/utils/SdCliViteExternalPlugin.js.map +1 -0
- package/dist/utils/SdCliViteLoggerPlugin.d.ts +6 -0
- package/dist/utils/SdCliViteLoggerPlugin.js +24 -0
- package/dist/utils/SdCliViteLoggerPlugin.js.map +1 -0
- package/dist/utils/SdCliViteNodeGlobalPlugin.d.ts +2 -0
- package/dist/utils/SdCliViteNodeGlobalPlugin.js +29 -0
- package/dist/utils/SdCliViteNodeGlobalPlugin.js.map +1 -0
- package/dist/utils/SdCliViteReactSwcPlugin.d.ts +2 -0
- package/dist/utils/SdCliViteReactSwcPlugin.js +141 -0
- package/dist/utils/SdCliViteReactSwcPlugin.js.map +1 -0
- package/dist/utils/SdCliViteWatchWithResolutionsPlugin.d.ts +2 -0
- package/dist/utils/SdCliViteWatchWithResolutionsPlugin.js +26 -0
- package/dist/utils/SdCliViteWatchWithResolutionsPlugin.js.map +1 -0
- package/dist/utils/getElectronReactExternals.d.ts +1 -0
- package/dist/utils/getElectronReactExternals.js +17 -0
- package/dist/utils/getElectronReactExternals.js.map +1 -0
- package/dist/utils/sdCliTsDefineTransformer.d.ts +4 -0
- package/dist/utils/sdCliTsDefineTransformer.js +26 -0
- package/dist/utils/sdCliTsDefineTransformer.js.map +1 -0
- package/package.json +25 -11
- package/src/SdLinter.ts +2 -2
- package/src/SdTsIncrementalBuilder.ts +116 -105
- package/src/build-cluster.ts +173 -111
- package/src/builders/SdCliClientBuilder.ts +226 -221
- package/src/builders/SdCliServerBuilder.ts +311 -275
- package/src/builders/SdCliTsLibBuilder.ts +160 -89
- package/src/commons.ts +66 -34
- package/src/entry/SdCliElectron.ts +55 -0
- package/src/entry/SdCliLocalUpdate.ts +125 -0
- package/src/entry/SdCliProject.ts +452 -395
- package/src/index.ts +1 -0
- package/src/sd-cli.ts +185 -122
- package/src/utils/SdCliBuildResultUtil.ts +1 -2
- package/src/utils/SdCliViteElectronMainPlugin.ts +86 -0
- package/src/utils/SdCliViteExternalPlugin.ts +112 -0
- package/src/utils/SdCliViteLoggerPlugin.ts +29 -0
- package/src/utils/SdCliViteNodeGlobalPlugin.ts +31 -0
- package/src/utils/SdCliViteReactSwcPlugin.ts +154 -0
- package/src/utils/SdCliViteWatchWithResolutionsPlugin.ts +29 -0
- package/src/utils/getElectronReactExternals.ts +19 -0
- package/src/utils/sdCliTsDefineTransformer.ts +31 -0
- package/.eslintrc.cjs +0 -18
- package/dist/utils/SdCliConfigUtil.d.ts +0 -7
- package/dist/utils/SdCliConfigUtil.js +0 -69
- package/dist/utils/SdCliConfigUtil.js.map +0 -1
- package/src/utils/SdCliConfigUtil.ts +0 -94
|
@@ -1,114 +1,125 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import {SdCliBuildResultUtil} from "./utils/SdCliBuildResultUtil";
|
|
4
|
+
import {FsUtil, Logger, PathUtil} from "@simplysm/sd-core-node";
|
|
5
|
+
import {ISdCliPackageBuildResult} from "./commons";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
interface IOptTransform<T> {
|
|
9
|
+
fn: (_: ts.Program, arg: T) => ts.TransformerFactory<ts.SourceFile>,
|
|
10
|
+
args: T
|
|
11
|
+
}
|
|
6
12
|
|
|
7
13
|
export class SdTsIncrementalBuilder {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const tsCompilerOptions = parsedTsConfig.options.jsx === ts.JsxEmit.ReactJSX && dev ? {
|
|
21
|
-
...parsedTsConfig.options,
|
|
22
|
-
jsx: ts.JsxEmit.ReactJSXDev
|
|
23
|
-
} : parsedTsConfig.options;
|
|
24
|
-
const host = ts.createIncrementalCompilerHost(tsCompilerOptions);
|
|
25
|
-
return new SdTsIncrementalBuilder(pkgPath, tsCompilerOptions, host, emitJs);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public async buildAsync(): Promise<{
|
|
29
|
-
affectedFilePaths: string[];
|
|
30
|
-
results: ISdCliPackageBuildResult[];
|
|
31
|
-
}> {
|
|
32
|
-
const logger = Logger.get(["simplysm", "sd-cli", "SdTsIncrementalBuilder", "buildAsync"]);
|
|
33
|
-
|
|
34
|
-
const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.{ts,tsx}");
|
|
35
|
-
const srcFilePaths = await FsUtil.globAsync(srcGlobPath);
|
|
36
|
-
this.builderProgram = ts.createSemanticDiagnosticsBuilderProgram(
|
|
37
|
-
srcFilePaths,
|
|
38
|
-
this._options,
|
|
39
|
-
this._host,
|
|
40
|
-
this.builderProgram
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const diagnostics: ts.Diagnostic[] = [];
|
|
44
|
-
const affectedFilePaths: string[] = [];
|
|
45
|
-
|
|
46
|
-
diagnostics.push(
|
|
47
|
-
...this.builderProgram.getOptionsDiagnostics(),
|
|
48
|
-
...this.builderProgram.getGlobalDiagnostics(),
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
logger.debug(`[${path.basename(this._pkgPath)}] 영향받는 파일 확인 및 처리중...`);
|
|
52
|
-
const srcFilePathSet = new Set<string>(srcFilePaths);
|
|
53
|
-
while (true) {
|
|
54
|
-
const semanticResult = this.builderProgram.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
|
|
55
|
-
return !srcFilePathSet.has(path.resolve(sourceFile.fileName));
|
|
56
|
-
});
|
|
57
|
-
if (!semanticResult) break;
|
|
58
|
-
diagnostics.push(...semanticResult.result);
|
|
59
|
-
|
|
60
|
-
if ("fileName" in semanticResult.affected) {
|
|
61
|
-
const emitResult = this.builderProgram.emit(semanticResult.affected, (filePath, data, writeByteOrderMark) => {
|
|
62
|
-
let realFilePath = filePath;
|
|
63
|
-
let realData = data;
|
|
64
|
-
if (PathUtil.isChildPath(realFilePath, path.resolve(this._pkgPath, "dist", path.basename(this._pkgPath), "src"))) {
|
|
65
|
-
realFilePath = path.resolve(this._pkgPath, "dist", path.relative(path.resolve(this._pkgPath, "dist", path.basename(this._pkgPath), "src"), realFilePath));
|
|
66
|
-
|
|
67
|
-
if (filePath.endsWith(".js.map")) {
|
|
68
|
-
const sourceMapContents = JSON.parse(realData);
|
|
69
|
-
sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6);
|
|
70
|
-
realData = JSON.stringify(sourceMapContents);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (this._writeFileCache.get(realFilePath) !== realData) {
|
|
75
|
-
this._host.writeFile(realFilePath, realData, writeByteOrderMark);
|
|
76
|
-
}
|
|
77
|
-
this._writeFileCache.set(realFilePath, realData);
|
|
78
|
-
}, undefined, !this._emitJs);
|
|
79
|
-
diagnostics.push(...emitResult.diagnostics);
|
|
80
|
-
|
|
81
|
-
diagnostics.push(...this.builderProgram.getSyntacticDiagnostics(semanticResult.affected));
|
|
82
|
-
affectedFilePaths.push(path.resolve(semanticResult.affected.fileName));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/*const result = this.builderProgram.emitNextAffectedFile((filePath, data, writeByteOrderMark) => {
|
|
86
|
-
let realFilePath = filePath.replace(/\.js$/, ".mjs");
|
|
87
|
-
if (PathUtil.isChildPath(realFilePath, path.resolve(this._pkgPath, "dist", path.basename(this._pkgPath), "src"))) {
|
|
88
|
-
realFilePath = path.resolve(this._pkgPath, "dist", path.relative(path.resolve(this._pkgPath, "dist", path.basename(this._pkgPath), "src"), realFilePath));
|
|
89
|
-
}
|
|
14
|
+
public builderProgram?: ts.SemanticDiagnosticsBuilderProgram;
|
|
15
|
+
private readonly _writeFileCache = new Map<string, string>();
|
|
16
|
+
|
|
17
|
+
public constructor(private readonly _pkgPath: string,
|
|
18
|
+
private readonly _compilerOptions: ts.CompilerOptions,
|
|
19
|
+
private readonly _host: ts.CompilerHost,
|
|
20
|
+
private readonly _opt: {
|
|
21
|
+
emitJs: boolean | string[],
|
|
22
|
+
compilerOptions?: ts.CompilerOptions,
|
|
23
|
+
transforms?: IOptTransform<any>[]
|
|
24
|
+
}) {
|
|
25
|
+
}
|
|
90
26
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
27
|
+
public static async createAsync(pkgPath: string, optFn: (compilerOptions: ts.CompilerOptions) => {
|
|
28
|
+
emitJs: boolean | string[],
|
|
29
|
+
compilerOptions?: ts.CompilerOptions,
|
|
30
|
+
transforms?: IOptTransform<any>[]
|
|
31
|
+
}): Promise<SdTsIncrementalBuilder> {
|
|
32
|
+
const tsConfigFilePath = path.resolve(pkgPath, "tsconfig.json");
|
|
33
|
+
const parsedTsConfig = ts.parseJsonConfigFileContent(await FsUtil.readJsonAsync(tsConfigFilePath), ts.sys, pkgPath);
|
|
34
|
+
const opt = optFn(parsedTsConfig.options);
|
|
35
|
+
const compilerOptions = {
|
|
36
|
+
...parsedTsConfig.options,
|
|
37
|
+
...opt?.compilerOptions
|
|
38
|
+
};
|
|
39
|
+
const host = ts.createIncrementalCompilerHost(compilerOptions);
|
|
40
|
+
return new SdTsIncrementalBuilder(
|
|
41
|
+
pkgPath,
|
|
42
|
+
compilerOptions,
|
|
43
|
+
host,
|
|
44
|
+
opt
|
|
45
|
+
);
|
|
104
46
|
}
|
|
105
|
-
logger.debug(`[${path.basename(this._pkgPath)}] 영향받는 파일 확인 및 처리 완료`, affectedFilePaths);
|
|
106
47
|
|
|
107
|
-
|
|
48
|
+
public async buildAsync(): Promise<{
|
|
49
|
+
affectedFilePaths: string[];
|
|
50
|
+
results: ISdCliPackageBuildResult[];
|
|
51
|
+
}> {
|
|
52
|
+
const logger = Logger.get(["simplysm", "sd-cli", "SdTsIncrementalBuilder", "buildAsync"]);
|
|
53
|
+
|
|
54
|
+
const distPath = this._compilerOptions.outDir ?? path.resolve(this._pkgPath, "dist");
|
|
55
|
+
const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.{ts,tsx}");
|
|
56
|
+
const srcFilePaths = await FsUtil.globAsync(srcGlobPath);
|
|
57
|
+
this.builderProgram = ts.createSemanticDiagnosticsBuilderProgram(
|
|
58
|
+
srcFilePaths,
|
|
59
|
+
this._compilerOptions,
|
|
60
|
+
this._host,
|
|
61
|
+
this.builderProgram
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const diagnostics: ts.Diagnostic[] = [];
|
|
65
|
+
const affectedFilePaths: string[] = [];
|
|
66
|
+
|
|
67
|
+
diagnostics.push(
|
|
68
|
+
...this.builderProgram.getOptionsDiagnostics(),
|
|
69
|
+
...this.builderProgram.getGlobalDiagnostics(),
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const program = this.builderProgram.getProgram();
|
|
73
|
+
|
|
74
|
+
logger.debug(`[${path.basename(this._pkgPath)}] 영향받는 파일 확인 및 처리중...`);
|
|
75
|
+
const srcFilePathSet = new Set<string>(srcFilePaths);
|
|
76
|
+
while (true) {
|
|
77
|
+
const semanticResult = this.builderProgram.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
|
|
78
|
+
return !srcFilePathSet.has(path.resolve(sourceFile.fileName));
|
|
79
|
+
});
|
|
80
|
+
if (!semanticResult) break;
|
|
81
|
+
diagnostics.push(...semanticResult.result);
|
|
82
|
+
|
|
83
|
+
if ("fileName" in semanticResult.affected) {
|
|
84
|
+
const emitResult = this.builderProgram.emit
|
|
85
|
+
(semanticResult.affected,
|
|
86
|
+
(filePath, data, writeByteOrderMark) => {
|
|
87
|
+
let realFilePath = filePath;
|
|
88
|
+
let realData = data;
|
|
89
|
+
if (PathUtil.isChildPath(realFilePath, path.resolve(distPath, path.basename(this._pkgPath), "src"))) {
|
|
90
|
+
realFilePath = path.resolve(distPath, path.relative(path.resolve(distPath, path.basename(this._pkgPath), "src"), realFilePath));
|
|
91
|
+
|
|
92
|
+
if (filePath.endsWith(".js.map")) {
|
|
93
|
+
const sourceMapContents = JSON.parse(realData);
|
|
94
|
+
sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6);
|
|
95
|
+
realData = JSON.stringify(sourceMapContents);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (this._writeFileCache.get(realFilePath) !== realData) {
|
|
100
|
+
this._host.writeFile(realFilePath, realData, writeByteOrderMark);
|
|
101
|
+
}
|
|
102
|
+
this._writeFileCache.set(realFilePath, realData);
|
|
103
|
+
},
|
|
104
|
+
undefined,
|
|
105
|
+
Array.isArray(this._opt.emitJs) ? !this._opt.emitJs.includes(path.resolve(semanticResult.affected.fileName)) : !this._opt.emitJs,
|
|
106
|
+
this._opt.transforms ? {
|
|
107
|
+
before: this._opt.transforms.map((item) => typeof item.fn === "function" ? item.fn(program, item.args) : (item.fn["default"] as any)(program, item.args))
|
|
108
|
+
} : undefined
|
|
109
|
+
);
|
|
110
|
+
diagnostics.push(...emitResult.diagnostics);
|
|
111
|
+
|
|
112
|
+
diagnostics.push(...this.builderProgram.getSyntacticDiagnostics(semanticResult.affected));
|
|
113
|
+
affectedFilePaths.push(path.resolve(semanticResult.affected.fileName));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
logger.debug(`[${path.basename(this._pkgPath)}] 영향받는 파일 확인 및 처리 완료`, affectedFilePaths);
|
|
108
117
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
const buildResults = diagnostics.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item));
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
affectedFilePaths,
|
|
122
|
+
results: buildResults
|
|
123
|
+
};
|
|
124
|
+
}
|
|
114
125
|
}
|
package/src/build-cluster.ts
CHANGED
|
@@ -1,133 +1,195 @@
|
|
|
1
1
|
import cluster from "node:cluster";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import {SdCliTsLibBuilder} from "./builders/SdCliTsLibBuilder";
|
|
3
|
+
import {FsUtil, Logger, LoggerSeverity} from "@simplysm/sd-core-node";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import {SdCliJsLibLinter} from "./builders/SdCliJsLibLinter";
|
|
6
|
+
import {EventEmitter} from "events";
|
|
7
|
+
import {ISdCliBuildClusterReqMessage, ISdCliBuildClusterResMessage} from "./commons";
|
|
8
|
+
import {NeverEntryError} from "@simplysm/sd-core-common";
|
|
9
|
+
import {SdCliServerBuilder} from "./builders/SdCliServerBuilder";
|
|
10
|
+
import {SdCliClientBuilder} from "./builders/SdCliClientBuilder";
|
|
11
11
|
|
|
12
12
|
Error.stackTraceLimit = Infinity;
|
|
13
13
|
EventEmitter.defaultMaxListeners = 0;
|
|
14
14
|
|
|
15
15
|
if (Boolean(process.env["SD_DEBUG"])) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
16
|
+
Logger.setConfig({
|
|
17
|
+
console: {
|
|
18
|
+
level: LoggerSeverity.debug
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
Logger.setConfig({
|
|
23
|
+
dot: true
|
|
24
|
+
});
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
const logger = Logger.get(["simplysm", "sd-cli", "build-cluster"]);
|
|
29
28
|
|
|
30
29
|
if (cluster.isPrimary) {
|
|
31
|
-
|
|
30
|
+
cluster.schedulingPolicy = cluster.SCHED_RR;
|
|
31
|
+
logger.debug(`메인 프로세스 ${process.pid} 시작`);
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
cluster.on("exit", (worker, code) => {
|
|
34
|
+
logger.debug(`워커 프로세스 ${worker.process.pid} 종료 (code: ${code})`);
|
|
35
|
+
});
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
cluster.on("message", (worker, message) => {
|
|
38
|
+
sendMessage(message);
|
|
39
|
+
});
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
process.on("message", (message) => {
|
|
42
|
+
cluster.fork({
|
|
43
|
+
"SD_CLUSTER_MESSAGE": JSON.stringify(message)
|
|
44
|
+
});
|
|
44
45
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
else {
|
|
49
|
-
const message = JSON.parse(process.env["SD_CLUSTER_MESSAGE"]!) as ISdCliBuildClusterReqMessage;
|
|
46
|
+
process.send!("ready");
|
|
47
|
+
} else {
|
|
48
|
+
const message = JSON.parse(process.env["SD_CLUSTER_MESSAGE"]!) as ISdCliBuildClusterReqMessage;
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
50
|
+
if (message.cmd === "watch") {
|
|
51
|
+
// [library] javascript
|
|
52
|
+
if (message.pkgConf.type === "library" && !FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
53
|
+
if (message.withLint) {
|
|
54
|
+
await new SdCliJsLibLinter(message.pkgPath)
|
|
55
|
+
.on("change", () => {
|
|
56
|
+
sendMessage({
|
|
57
|
+
type: "change",
|
|
58
|
+
req: message
|
|
59
|
+
});
|
|
60
|
+
})
|
|
61
|
+
.on("complete", (result) => {
|
|
62
|
+
sendMessage({
|
|
63
|
+
type: "complete",
|
|
64
|
+
result,
|
|
65
|
+
req: message
|
|
66
|
+
});
|
|
67
|
+
})
|
|
68
|
+
.watchAsync();
|
|
69
|
+
}
|
|
70
|
+
sendMessage({
|
|
71
|
+
type: "ready",
|
|
72
|
+
req: message
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// [library] typescript
|
|
76
|
+
else if (message.pkgConf.type === "library" && FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
77
|
+
await new SdCliTsLibBuilder(message.pkgPath, message.pkgConf, message.withLint)
|
|
78
|
+
.on("change", () => {
|
|
79
|
+
sendMessage({
|
|
80
|
+
type: "change",
|
|
81
|
+
req: message
|
|
82
|
+
});
|
|
83
|
+
})
|
|
84
|
+
.on("complete", (result) => {
|
|
85
|
+
sendMessage({
|
|
86
|
+
type: "complete",
|
|
87
|
+
result,
|
|
88
|
+
req: message
|
|
89
|
+
});
|
|
90
|
+
})
|
|
91
|
+
.watchAsync();
|
|
92
|
+
sendMessage({
|
|
93
|
+
type: "ready",
|
|
94
|
+
req: message
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// [server]
|
|
98
|
+
else if (message.pkgConf.type === "server") {
|
|
99
|
+
await new SdCliServerBuilder(message.pkgPath, message.pkgConf, message.withLint)
|
|
100
|
+
.on("change", () => {
|
|
101
|
+
sendMessage({
|
|
102
|
+
type: "change",
|
|
103
|
+
req: message
|
|
104
|
+
});
|
|
105
|
+
})
|
|
106
|
+
.on("complete", (result) => {
|
|
107
|
+
sendMessage({
|
|
108
|
+
type: "complete",
|
|
109
|
+
result,
|
|
110
|
+
req: message
|
|
111
|
+
});
|
|
112
|
+
})
|
|
113
|
+
.watchAsync();
|
|
114
|
+
sendMessage({
|
|
115
|
+
type: "ready",
|
|
116
|
+
req: message
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
// [client]
|
|
120
|
+
else if (message.pkgConf.type === "client") {
|
|
121
|
+
await new SdCliClientBuilder(message.pkgPath, message.pkgConf, message.builderKey ?? "web", message.withLint)
|
|
122
|
+
.on("change", () => {
|
|
123
|
+
sendMessage({
|
|
124
|
+
type: "change",
|
|
125
|
+
req: message
|
|
126
|
+
});
|
|
127
|
+
})
|
|
128
|
+
.on("complete", (result) => {
|
|
129
|
+
sendMessage({
|
|
130
|
+
type: "complete",
|
|
131
|
+
result,
|
|
132
|
+
req: message
|
|
133
|
+
});
|
|
134
|
+
})
|
|
135
|
+
.watchAsync();
|
|
136
|
+
sendMessage({
|
|
137
|
+
type: "ready",
|
|
138
|
+
req: message
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
throw new NeverEntryError();
|
|
142
|
+
}
|
|
143
|
+
} else { // build
|
|
144
|
+
// [library] javascript
|
|
145
|
+
if (message.pkgConf.type === "library" && !FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
146
|
+
if (message.withLint) {
|
|
147
|
+
const result = await new SdCliJsLibLinter(message.pkgPath).buildAsync();
|
|
148
|
+
sendMessage({
|
|
149
|
+
type: "complete",
|
|
150
|
+
result,
|
|
151
|
+
req: message
|
|
152
|
+
});
|
|
153
|
+
} else {
|
|
154
|
+
sendMessage({
|
|
155
|
+
type: "complete",
|
|
156
|
+
result: undefined,
|
|
157
|
+
req: message
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// [library] typescript
|
|
162
|
+
else if (message.pkgConf.type === "library" && FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
163
|
+
const result = await new SdCliTsLibBuilder(message.pkgPath, message.pkgConf, message.withLint).buildAsync();
|
|
164
|
+
sendMessage({
|
|
165
|
+
type: "complete",
|
|
166
|
+
result,
|
|
167
|
+
req: message
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
// [server]
|
|
171
|
+
else if (message.pkgConf.type === "server") {
|
|
172
|
+
const result = await new SdCliServerBuilder(message.pkgPath, message.pkgConf, message.withLint).buildAsync();
|
|
173
|
+
sendMessage({
|
|
174
|
+
type: "complete",
|
|
175
|
+
result,
|
|
176
|
+
req: message
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
// [client]
|
|
180
|
+
else if (message.pkgConf.type === "client") {
|
|
181
|
+
const result = await new SdCliClientBuilder(message.pkgPath, message.pkgConf, message.builderKey ?? "web", message.withLint).buildAsync();
|
|
182
|
+
sendMessage({
|
|
183
|
+
type: "complete",
|
|
184
|
+
result,
|
|
185
|
+
req: message
|
|
186
|
+
});
|
|
187
|
+
} else {
|
|
188
|
+
throw new NeverEntryError();
|
|
189
|
+
}
|
|
127
190
|
}
|
|
128
|
-
}
|
|
129
191
|
}
|
|
130
192
|
|
|
131
193
|
function sendMessage(message: ISdCliBuildClusterResMessage): void {
|
|
132
|
-
|
|
194
|
+
process.send!(message);
|
|
133
195
|
}
|