@simplysm/sd-cli 12.5.20 → 12.5.22
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/{build-tools → entry}/SdCliCordova.d.ts +5 -6
- package/dist/{build-tools → entry}/SdCliCordova.js +117 -99
- package/dist/entry/SdCliCordova.js.map +1 -0
- package/dist/entry/SdCliElectron.d.ts +2 -2
- package/dist/entry/SdCliElectron.js +50 -40
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliLocalUpdate.d.ts +1 -2
- package/dist/entry/SdCliLocalUpdate.js +26 -27
- package/dist/entry/SdCliLocalUpdate.js.map +1 -1
- package/dist/entry/SdCliProject.d.ts +1 -5
- package/dist/entry/SdCliProject.js +62 -288
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +23 -17
- package/dist/index.js +23 -17
- package/dist/index.js.map +1 -1
- package/dist/pkg-builders/SdMultiBuildRunner.d.ts +21 -0
- package/dist/pkg-builders/SdMultiBuildRunner.js +174 -0
- package/dist/pkg-builders/SdMultiBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.d.ts +4 -0
- package/dist/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.js +7 -7
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.js.map +1 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +20 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.js +135 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/SdNgBundler.d.ts +29 -0
- package/dist/{build-tools → pkg-builders/client}/SdNgBundler.js +100 -95
- package/dist/pkg-builders/client/SdNgBundler.js.map +1 -0
- package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.d.ts +1 -2
- package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.js +19 -45
- package/dist/pkg-builders/client/SdNgBundlerContext.js.map +1 -0
- package/dist/pkg-builders/client/createSdNgPlugin.d.ts +10 -0
- package/dist/{bundle-plugins/sdNgPlugin.js → pkg-builders/client/createSdNgPlugin.js} +32 -33
- package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -0
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.d.ts +5 -0
- package/dist/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.js +11 -11
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js.map +1 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +16 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +81 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +13 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +89 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +14 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.js +54 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +17 -0
- package/dist/{builders/SdCliServerBuilder.js → pkg-builders/server/SdServerBuildRunner.js} +48 -53
- package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBundler.d.ts +19 -0
- package/dist/{build-tools → pkg-builders/server}/SdServerBundler.js +25 -30
- package/dist/pkg-builders/server/SdServerBundler.js.map +1 -0
- package/dist/pkg-builders/server/createSdServerPlugin.d.ts +10 -0
- package/dist/pkg-builders/server/createSdServerPlugin.js +53 -0
- package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -0
- package/dist/sd-cli.js +61 -54
- package/dist/sd-cli.js.map +1 -1
- package/dist/ts-builder/SdTsCompileWorker.d.ts +9 -0
- package/dist/ts-builder/SdTsCompileWorker.js +16 -0
- package/dist/ts-builder/SdTsCompileWorker.js.map +1 -0
- package/dist/ts-builder/SdTsCompiler.d.ts +7 -0
- package/dist/{build-tools → ts-builder}/SdTsCompiler.js +226 -212
- package/dist/ts-builder/SdTsCompiler.js.map +1 -0
- package/dist/types/build-plugin.type.d.ts +14 -0
- package/dist/types/build-plugin.type.js +2 -0
- package/dist/types/build-plugin.type.js.map +1 -0
- package/dist/types/build.type.d.ts +15 -0
- package/dist/types/build.type.js +2 -0
- package/dist/types/build.type.js.map +1 -0
- package/dist/types/common-configs.type.d.ts +22 -0
- package/dist/types/common-configs.type.js +2 -0
- package/dist/types/common-configs.type.js.map +1 -0
- package/dist/types/sd-configs.type.d.ts +99 -0
- package/dist/types/sd-configs.type.js +2 -0
- package/dist/types/sd-configs.type.js.map +1 -0
- package/dist/types/ts-compiler.type.d.ts +29 -0
- package/dist/types/ts-compiler.type.js +2 -0
- package/dist/types/ts-compiler.type.js.map +1 -0
- package/dist/types/workers.type.d.ts +49 -0
- package/dist/types/workers.type.js +2 -0
- package/dist/types/workers.type.js.map +1 -0
- package/dist/utils/SdCliConvertMessageUtil.d.ts +21 -0
- package/dist/utils/SdCliConvertMessageUtil.js +137 -0
- package/dist/utils/SdCliConvertMessageUtil.js.map +1 -0
- package/dist/workers/compile-worker.js +27 -0
- package/dist/workers/compile-worker.js.map +1 -0
- package/dist/workers/lint-worker.js +36 -0
- package/dist/workers/lint-worker.js.map +1 -0
- package/dist/workers/server-worker.d.ts +1 -0
- package/dist/workers/server-worker.js +49 -0
- package/dist/workers/server-worker.js.map +1 -0
- package/lib/dev-worker.cjs +5 -0
- package/package.json +7 -7
- package/src/entry/SdCliCordova.ts +363 -0
- package/src/entry/SdCliElectron.ts +96 -69
- package/src/entry/SdCliLocalUpdate.ts +43 -44
- package/src/entry/SdCliProject.ts +72 -417
- package/src/index.ts +23 -17
- package/src/pkg-builders/SdMultiBuildRunner.ts +250 -0
- package/src/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.ts +7 -7
- package/src/pkg-builders/client/SdClientBuildRunner.ts +191 -0
- package/src/{build-tools → pkg-builders/client}/SdNgBundler.ts +125 -121
- package/src/pkg-builders/client/SdNgBundlerContext.ts +111 -0
- package/src/{bundle-plugins/sdNgPlugin.ts → pkg-builders/client/createSdNgPlugin.ts} +43 -46
- package/src/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.ts +11 -11
- package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +105 -0
- package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +128 -0
- package/src/pkg-builders/lib/SdTsLibBuilder.ts +69 -0
- package/src/{builders/SdCliServerBuilder.ts → pkg-builders/server/SdServerBuildRunner.ts} +66 -78
- package/src/{build-tools → pkg-builders/server}/SdServerBundler.ts +40 -41
- package/src/pkg-builders/server/createSdServerPlugin.ts +77 -0
- package/src/sd-cli.ts +197 -211
- package/src/ts-builder/SdTsCompileWorker.ts +21 -0
- package/src/ts-builder/SdTsCompiler.ts +758 -0
- package/src/types/build-plugin.type.ts +16 -0
- package/src/types/build.type.ts +17 -0
- package/src/types/common-configs.type.ts +27 -0
- package/src/types/sd-configs.type.ts +114 -0
- package/src/types/ts-compiler.type.ts +29 -0
- package/src/types/workers.type.ts +27 -0
- package/src/utils/SdCliConvertMessageUtil.ts +177 -0
- package/src/workers/compile-worker.ts +31 -0
- package/src/workers/lint-worker.ts +44 -0
- package/src/workers/server-worker.ts +52 -0
- package/tsconfig.json +7 -1
- package/dist/build-cluster.js +0 -201
- package/dist/build-cluster.js.map +0 -1
- package/dist/build-tools/SdCliCordova.js.map +0 -1
- package/dist/build-tools/SdCliIndexFileGenerator.d.ts +0 -5
- package/dist/build-tools/SdCliIndexFileGenerator.js.map +0 -1
- package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +0 -4
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +0 -1
- package/dist/build-tools/SdLinter.d.ts +0 -5
- package/dist/build-tools/SdLinter.js +0 -49
- package/dist/build-tools/SdLinter.js.map +0 -1
- package/dist/build-tools/SdNgBundler.d.ts +0 -29
- package/dist/build-tools/SdNgBundler.js.map +0 -1
- package/dist/build-tools/SdNgBundlerContext.js.map +0 -1
- package/dist/build-tools/SdServerBundler.d.ts +0 -20
- package/dist/build-tools/SdServerBundler.js.map +0 -1
- package/dist/build-tools/SdTsCompiler.d.ts +0 -34
- package/dist/build-tools/SdTsCompiler.js.map +0 -1
- package/dist/build-tools/SdTsLibBundler.d.ts +0 -13
- package/dist/build-tools/SdTsLibBundler.js +0 -58
- package/dist/build-tools/SdTsLibBundler.js.map +0 -1
- package/dist/builders/SdCliClientBuilder.d.ts +0 -18
- package/dist/builders/SdCliClientBuilder.js +0 -151
- package/dist/builders/SdCliClientBuilder.js.map +0 -1
- package/dist/builders/SdCliJsLibLinter.d.ts +0 -13
- package/dist/builders/SdCliJsLibLinter.js +0 -60
- package/dist/builders/SdCliJsLibLinter.js.map +0 -1
- package/dist/builders/SdCliServerBuilder.d.ts +0 -15
- package/dist/builders/SdCliServerBuilder.js.map +0 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +0 -12
- package/dist/builders/SdCliTsLibBuilder.js +0 -90
- package/dist/builders/SdCliTsLibBuilder.js.map +0 -1
- package/dist/bundle-plugins/sdNgPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdNgPlugin.js.map +0 -1
- package/dist/bundle-plugins/sdServerPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdServerPlugin.js +0 -63
- package/dist/bundle-plugins/sdServerPlugin.js.map +0 -1
- package/dist/commons.d.ts +0 -145
- package/dist/commons.js +0 -2
- package/dist/commons.js.map +0 -1
- package/dist/server-worker.js +0 -57
- package/dist/server-worker.js.map +0 -1
- package/dist/utils/SdCliBuildResultUtil.d.ts +0 -16
- package/dist/utils/SdCliBuildResultUtil.js +0 -54
- package/dist/utils/SdCliBuildResultUtil.js.map +0 -1
- package/src/build-cluster.ts +0 -212
- package/src/build-tools/SdCliCordova.ts +0 -340
- package/src/build-tools/SdLinter.ts +0 -65
- package/src/build-tools/SdNgBundlerContext.ts +0 -137
- package/src/build-tools/SdTsCompiler.ts +0 -754
- package/src/build-tools/SdTsLibBundler.ts +0 -72
- package/src/builders/SdCliClientBuilder.ts +0 -211
- package/src/builders/SdCliJsLibLinter.ts +0 -72
- package/src/builders/SdCliTsLibBuilder.ts +0 -126
- package/src/bundle-plugins/sdServerPlugin.ts +0 -94
- package/src/commons.ts +0 -171
- package/src/server-worker.ts +0 -65
- package/src/utils/SdCliBuildResultUtil.ts +0 -63
- /package/dist/{build-cluster.d.ts → workers/compile-worker.d.ts} +0 -0
- /package/dist/{server-worker.d.ts → workers/lint-worker.d.ts} +0 -0
|
@@ -8,7 +8,7 @@ export class SdCliLocalUpdate {
|
|
|
8
8
|
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames);
|
|
9
9
|
if (!projConf.localUpdates)
|
|
10
10
|
return;
|
|
11
|
-
const updatePathInfos =
|
|
11
|
+
const updatePathInfos = this.#getUpdatePathInfos(projConf.localUpdates);
|
|
12
12
|
logger.debug("로컬 업데이트 구성", updatePathInfos);
|
|
13
13
|
logger.log("로컬 라이브러리 업데이트 시작...");
|
|
14
14
|
for (const updatePathInfo of updatePathInfos) {
|
|
@@ -17,7 +17,7 @@ export class SdCliLocalUpdate {
|
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
// 소스경로에서 대상경로로 파일 복사
|
|
20
|
-
|
|
20
|
+
FsUtil.copy(updatePathInfo.source, updatePathInfo.target, (src) => {
|
|
21
21
|
return !src.includes("node_modules") && !src.endsWith("package.json");
|
|
22
22
|
});
|
|
23
23
|
}
|
|
@@ -29,49 +29,48 @@ export class SdCliLocalUpdate {
|
|
|
29
29
|
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames);
|
|
30
30
|
if (!projConf.localUpdates)
|
|
31
31
|
return;
|
|
32
|
-
const updatePathInfos =
|
|
32
|
+
const updatePathInfos = this.#getUpdatePathInfos(projConf.localUpdates);
|
|
33
33
|
logger.debug("로컬 업데이트 구성");
|
|
34
|
-
const watchPaths =
|
|
34
|
+
const watchPaths = updatePathInfos.mapMany((item) => this.#getWatchPaths(item.source)).distinct();
|
|
35
35
|
const watcher = SdFsWatcher.watch(watchPaths);
|
|
36
|
-
watcher.onChange({ delay: 1000 },
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
36
|
+
watcher.onChange({ delay: 1000 }, (changedInfos) => {
|
|
37
|
+
const changedFileInfos = changedInfos.filter((item) => ["add", "change", "unlink"].includes(item.event));
|
|
38
|
+
if (changedFileInfos.length === 0)
|
|
39
39
|
return;
|
|
40
40
|
logger.log("로컬 라이브러리 변경감지...");
|
|
41
|
-
for (const
|
|
42
|
-
if (!FsUtil.exists(changedFilePath))
|
|
43
|
-
continue;
|
|
41
|
+
for (const changedFileInfo of changedFileInfos) {
|
|
44
42
|
for (const updatePathInfo of updatePathInfos) {
|
|
45
|
-
if (!PathUtil.isChildPath(
|
|
43
|
+
if (!PathUtil.isChildPath(changedFileInfo.path, updatePathInfo.source))
|
|
46
44
|
continue;
|
|
47
|
-
const sourceRelPath = path.relative(updatePathInfo.source,
|
|
48
|
-
// if (sourceRelPath.includes("node_modules")) continue;
|
|
49
|
-
// if (sourceRelPath.includes("package.json")) continue;
|
|
45
|
+
const sourceRelPath = path.relative(updatePathInfo.source, changedFileInfo.path);
|
|
50
46
|
const targetFilePath = path.resolve(updatePathInfo.target, sourceRelPath);
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
if (changedFileInfo.event === "unlink") {
|
|
48
|
+
logger.debug(`변경파일감지(삭제): ${targetFilePath}`);
|
|
49
|
+
FsUtil.remove(targetFilePath);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
logger.debug(`변경파일감지(복사): ${changedFileInfo.path} => ${targetFilePath}`);
|
|
53
|
+
FsUtil.copy(changedFileInfo.path, targetFilePath);
|
|
54
|
+
}
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
const watchFileSet = new Set(
|
|
56
|
-
watcher.
|
|
57
|
+
const watchFileSet = new Set(updatePathInfos.mapMany((item) => this.#getWatchPaths(item.source)));
|
|
58
|
+
watcher.replaceWatchPaths(watchFileSet);
|
|
57
59
|
logger.info("로컬 라이브러리 복사 완료");
|
|
58
60
|
});
|
|
59
61
|
}
|
|
60
|
-
static
|
|
62
|
+
static #getUpdatePathInfos(record) {
|
|
61
63
|
const result = [];
|
|
62
64
|
for (const pkgGlobPath of Object.keys(record)) {
|
|
63
65
|
// "node_modules'에서 로컬업데이트 설정에 맞는 패키지를 "glob"하여 대상 패키지경로 목록 가져오기
|
|
64
66
|
const targetPaths = [
|
|
65
|
-
...
|
|
66
|
-
...
|
|
67
|
+
...FsUtil.glob(path.resolve(process.cwd(), "node_modules", pkgGlobPath)),
|
|
68
|
+
...FsUtil.glob(path.resolve(process.cwd(), "packages", "*", "node_modules", pkgGlobPath)),
|
|
67
69
|
];
|
|
68
70
|
result.push(...targetPaths
|
|
69
71
|
.map((targetPath) => {
|
|
70
72
|
// 대상의 명칭 추출
|
|
71
|
-
const regexpText = pkgGlobPath.replace(/[\\/.*]/g, (item) =>
|
|
72
|
-
: item === "." ? "\\."
|
|
73
|
-
: item === "*" ? "(.*)"
|
|
74
|
-
: item));
|
|
73
|
+
const regexpText = pkgGlobPath.replace(/[\\/.*]/g, (item) => item === "/" ? "[\\\\\\/]" : item === "." ? "\\." : item === "*" ? "(.*)" : item);
|
|
75
74
|
const targetNameMatch = new RegExp(regexpText).exec(targetPath);
|
|
76
75
|
if (!targetNameMatch || typeof targetNameMatch[1] === "undefined")
|
|
77
76
|
return undefined;
|
|
@@ -84,8 +83,8 @@ export class SdCliLocalUpdate {
|
|
|
84
83
|
}
|
|
85
84
|
return result;
|
|
86
85
|
}
|
|
87
|
-
static
|
|
88
|
-
return
|
|
86
|
+
static #getWatchPaths(sourcePath) {
|
|
87
|
+
return FsUtil.glob(path.resolve(sourcePath, "**"));
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
90
|
//# sourceMappingURL=SdCliLocalUpdate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SdCliLocalUpdate.js","sourceRoot":"","sources":["../../src/entry/SdCliLocalUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SdCliLocalUpdate.js","sourceRoot":"","sources":["../../src/entry/SdCliLocalUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAGpC,MAAM,OAAO,gBAAgB;IAC3B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAoD;QACxE,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,kBAAkB,EAAE,UAAU,CAAC,CAAC,CAAC;QAElF,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAChC,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAC3G,IAAI,EACJ,GAAG,CAAC,QAAQ,CACO,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,YAAY;YAAE,OAAO;QAEnC,MAAM,eAAe,GAAG,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACxE,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QAE5C,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;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C,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CACjF,CAAC;gBACF,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAChE,IAAI,CAAC,eAAe,IAAI,OAAO,eAAe,CAAC,CAAC,CAAC,KAAK,WAAW;oBAAE,OAAO,SAAS,CAAC;gBACpF,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;gBAEtC,eAAe;gBACf,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;gBAChF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;YACpD,CAAC,CAAC;iBACD,YAAY,EAAE,CAClB,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,UAAkB;QACtC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare class SdCliProject {
|
|
2
|
+
#private;
|
|
2
3
|
static watchAsync(opt: {
|
|
3
4
|
confFileRelPath: string;
|
|
4
5
|
optNames: string[];
|
|
@@ -19,9 +20,4 @@ export declare class SdCliProject {
|
|
|
19
20
|
private static _publishPkgAsync;
|
|
20
21
|
private static _waitSecMessageAsync;
|
|
21
22
|
private static _upgradeVersionAsync;
|
|
22
|
-
private static _logging;
|
|
23
|
-
private static _prepareClusterAsync;
|
|
24
|
-
private static _runCommandAsync;
|
|
25
|
-
private static _closeCluster;
|
|
26
|
-
private static _restartServerAsync;
|
|
27
23
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { FsUtil, Logger, PathUtil, SdProcess } from "@simplysm/sd-core-node";
|
|
3
|
-
import
|
|
4
|
-
import { fileURLToPath, pathToFileURL } from "url";
|
|
5
|
-
import { SdCliBuildResultUtil } from "../utils/SdCliBuildResultUtil";
|
|
3
|
+
import { pathToFileURL } from "url";
|
|
6
4
|
import semver from "semver";
|
|
7
|
-
import {
|
|
5
|
+
import { NeverEntryError, StringUtil, Wait } from "@simplysm/sd-core-common";
|
|
8
6
|
import { SdStorage } from "@simplysm/sd-storage";
|
|
9
7
|
import { SdCliLocalUpdate } from "./SdCliLocalUpdate";
|
|
10
8
|
import xml2js from "xml2js";
|
|
9
|
+
import { SdMultiBuildRunner } from "../pkg-builders/SdMultiBuildRunner";
|
|
10
|
+
import { SdCliConvertMessageUtil } from "../utils/SdCliConvertMessageUtil";
|
|
11
11
|
export class SdCliProject {
|
|
12
12
|
static async watchAsync(opt) {
|
|
13
13
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "watchAsync"]);
|
|
@@ -21,12 +21,15 @@ export class SdCliProject {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
logger.debug("프로젝트 package.json 가져오기...");
|
|
24
|
-
const projNpmConf =
|
|
24
|
+
const projNpmConf = FsUtil.readJson(path.resolve(process.cwd(), "package.json"));
|
|
25
25
|
logger.debug("패키지 목록 구성...");
|
|
26
26
|
if (!projNpmConf.workspaces) {
|
|
27
27
|
throw new Error("프로젝트 package.json에 workspaces가 설정되어있지 않습니다.");
|
|
28
28
|
}
|
|
29
|
-
const allPkgPaths =
|
|
29
|
+
const allPkgPaths = projNpmConf.workspaces
|
|
30
|
+
.mapMany((item) => FsUtil.glob(item))
|
|
31
|
+
.filter((item) => !item.includes("."))
|
|
32
|
+
.map((item) => PathUtil.norm(item));
|
|
30
33
|
let pkgPaths = allPkgPaths.filter((pkgPath) => path.basename(pkgPath) in projConf.packages);
|
|
31
34
|
if (opt.pkgNames.length !== 0) {
|
|
32
35
|
pkgPaths = pkgPaths.filter((pkgPath) => opt.pkgNames.includes(path.basename(pkgPath)));
|
|
@@ -36,185 +39,56 @@ export class SdCliProject {
|
|
|
36
39
|
if (notExistsPkgs.length > 0) {
|
|
37
40
|
throw new Error("패키지를 찾을 수 없습니다. (" + notExistsPkgs.join(", ") + ")");
|
|
38
41
|
}
|
|
39
|
-
logger.debug("빌드 프로세스
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (message.type === "change") {
|
|
47
|
-
if (Array.from(busyReqCntMap.values()).every((v) => v === 0)) {
|
|
48
|
-
logger.log("빌드를 시작합니다...");
|
|
49
|
-
}
|
|
50
|
-
busyReqCntMap.set(message.req.cmd + "|" + message.req.pkgPath, (busyReqCntMap.get(message.req.cmd + "|" + message.req.pkgPath) ?? 0) + 1);
|
|
51
|
-
}
|
|
52
|
-
else if (message.type === "complete") {
|
|
53
|
-
resultCache.delete("none");
|
|
54
|
-
for (const affectedFilePath of message.result.affectedFilePaths) {
|
|
55
|
-
if (PathUtil.isChildPath(affectedFilePath, message.req.pkgPath)) {
|
|
56
|
-
resultCache.delete(affectedFilePath);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
for (const buildResult of message.result.buildResults) {
|
|
60
|
-
// if (buildResult.filePath == null || PathUtil.isChildPath(buildResult.filePath, message.req.pkgPath)) {
|
|
61
|
-
const cacheItem = resultCache.getOrCreate(buildResult.filePath ?? "none", []);
|
|
62
|
-
cacheItem.push(buildResult);
|
|
63
|
-
// }
|
|
64
|
-
}
|
|
65
|
-
const pkgConf = message.req.projConf.packages[path.basename(message.req.pkgPath)];
|
|
66
|
-
if (pkgConf.type === "server") {
|
|
67
|
-
const pkgName = path.basename(message.req.pkgPath);
|
|
68
|
-
const serverInfo = serverInfoMap.getOrCreate(pkgName, {
|
|
69
|
-
hasChanges: true,
|
|
70
|
-
hasClientChanges: false,
|
|
71
|
-
pathProxy: {},
|
|
72
|
-
// changeFilePaths: []
|
|
73
|
-
});
|
|
74
|
-
const serverPkgConf = projConf.packages[pkgName];
|
|
75
|
-
serverInfo.pkgOrOpt = {
|
|
76
|
-
path: message.req.pkgPath,
|
|
77
|
-
conf: serverPkgConf,
|
|
78
|
-
};
|
|
79
|
-
serverInfo.hasChanges = true;
|
|
80
|
-
}
|
|
81
|
-
if (pkgConf.type === "client") {
|
|
82
|
-
const pkgName = path.basename(message.req.pkgPath);
|
|
83
|
-
if (pkgConf.server !== undefined) {
|
|
84
|
-
const serverInfo = serverInfoMap.getOrCreate(typeof pkgConf.server === "string" ? pkgConf.server : pkgConf.server.port.toString(), {
|
|
85
|
-
hasChanges: true,
|
|
86
|
-
hasClientChanges: false,
|
|
87
|
-
pathProxy: {},
|
|
88
|
-
// changeFilePaths: []
|
|
89
|
-
});
|
|
90
|
-
if (typeof pkgConf.server !== "string") {
|
|
91
|
-
serverInfo.pkgOrOpt = pkgConf.server;
|
|
92
|
-
}
|
|
93
|
-
serverInfo.pathProxy[pkgName] = path.resolve(message.req.pkgPath, "dist");
|
|
94
|
-
serverInfo.pathProxy["node_modules"] = path.resolve(process.cwd(), "node_modules");
|
|
95
|
-
// serverInfo.changeFilePaths.push(...message.result!.affectedFilePaths);
|
|
96
|
-
serverInfo.hasClientChanges = true;
|
|
97
|
-
// serverInfo.worker?.send({type: "broadcastReload"});
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
const serverInfo = serverInfoMap.getOrCreate(pkgName, {
|
|
101
|
-
hasChanges: true,
|
|
102
|
-
hasClientChanges: false,
|
|
103
|
-
pathProxy: {},
|
|
104
|
-
// changeFilePaths: []
|
|
105
|
-
});
|
|
106
|
-
// serverInfo.port = message.result!.port;
|
|
107
|
-
// serverInfo.changeFilePaths.push(...message.result!.affectedFilePaths);
|
|
108
|
-
serverInfo.hasClientChanges = true;
|
|
109
|
-
// serverInfo.worker?.send({type: "broadcastReload"});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
setTimeout(async () => {
|
|
113
|
-
busyReqCntMap.set(message.req.cmd + "|" + message.req.pkgPath, (busyReqCntMap.get(message.req.cmd + "|" + message.req.pkgPath) ?? 0) - 1);
|
|
114
|
-
logger.debug("남아있는 예약 빌드", busyReqCntMap);
|
|
115
|
-
if (Array.from(busyReqCntMap.values()).every((v) => v === 0)) {
|
|
116
|
-
for (const serverPkgNameOrPort of serverInfoMap.keys()) {
|
|
117
|
-
const serverInfo = serverInfoMap.get(serverPkgNameOrPort);
|
|
118
|
-
if (serverInfo.pkgOrOpt && serverInfo.hasChanges) {
|
|
119
|
-
logger.debug("서버 재시작...");
|
|
120
|
-
try {
|
|
121
|
-
const restartServerResult = await this._restartServerAsync(serverInfo.pkgOrOpt, serverInfo.worker);
|
|
122
|
-
serverInfo.worker = restartServerResult.worker;
|
|
123
|
-
serverInfo.port = restartServerResult.port;
|
|
124
|
-
serverInfo.hasChanges = false;
|
|
125
|
-
}
|
|
126
|
-
catch (err) {
|
|
127
|
-
logger.error(err);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (serverInfo.worker) {
|
|
131
|
-
logger.debug("클라이언트 설정...");
|
|
132
|
-
serverInfo.worker.send({
|
|
133
|
-
type: "setPathProxy",
|
|
134
|
-
pathProxy: serverInfo.pathProxy,
|
|
135
|
-
});
|
|
136
|
-
if (serverInfo.hasClientChanges) {
|
|
137
|
-
logger.debug("클라이언트 새로고침...");
|
|
138
|
-
serverInfo.worker.send({ type: "broadcastReload" });
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const clientPaths = [];
|
|
143
|
-
for (const serverInfo of serverInfoMap.values()) {
|
|
144
|
-
if (Object.keys(serverInfo.pathProxy).length > 0) {
|
|
145
|
-
for (const proxyPath of Object.keys(serverInfo.pathProxy)) {
|
|
146
|
-
if (proxyPath === "node_modules")
|
|
147
|
-
continue;
|
|
148
|
-
clientPaths.push(`http://localhost:${serverInfo.port}/${proxyPath}/`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
clientPaths.push(`http://localhost:${serverInfo.port}/`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (clientPaths.length > 0) {
|
|
156
|
-
logger.info("클라이언트 개발 서버 접속 주소\n" + clientPaths.join("\n"));
|
|
157
|
-
}
|
|
158
|
-
const buildResults = Array.from(resultCache.values()).mapMany();
|
|
159
|
-
this._logging(buildResults, logger);
|
|
160
|
-
}
|
|
161
|
-
}, 300);
|
|
162
|
-
}
|
|
42
|
+
logger.debug("빌드 프로세스 시작...");
|
|
43
|
+
const multiBuildRunner = new SdMultiBuildRunner()
|
|
44
|
+
.on("change", () => {
|
|
45
|
+
logger.debug("빌드를 시작합니다...");
|
|
46
|
+
})
|
|
47
|
+
.on("complete", (messages) => {
|
|
48
|
+
this.#logging(messages, logger);
|
|
163
49
|
});
|
|
164
|
-
logger.debug("빌드 프로세스 명령 전송...");
|
|
165
|
-
busyReqCntMap.set("all", (busyReqCntMap.get("all") ?? 0) + 1);
|
|
166
|
-
logger.log("빌드를 시작합니다...");
|
|
167
50
|
await pkgPaths.parallelAsync(async (pkgPath) => {
|
|
168
|
-
await
|
|
51
|
+
await multiBuildRunner.runAsync({
|
|
52
|
+
cmd: "watch",
|
|
53
|
+
pkgPath,
|
|
54
|
+
projConf: projConf,
|
|
55
|
+
});
|
|
169
56
|
});
|
|
170
|
-
busyReqCntMap.set("all", (busyReqCntMap.get("all") ?? 0) - 1);
|
|
171
|
-
if (Array.from(busyReqCntMap.values()).every((v) => v === 0)) {
|
|
172
|
-
const buildResults = Array.from(resultCache.values()).mapMany();
|
|
173
|
-
this._logging(buildResults, logger);
|
|
174
|
-
}
|
|
175
57
|
}
|
|
176
58
|
static async buildAsync(opt) {
|
|
177
59
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "buildAsync"]);
|
|
178
60
|
logger.debug("프로젝트 설정 가져오기...");
|
|
179
61
|
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(false, opt.optNames);
|
|
180
62
|
logger.debug("프로젝트 package.json 가져오기...");
|
|
181
|
-
const projNpmConf =
|
|
63
|
+
const projNpmConf = FsUtil.readJson(path.resolve(process.cwd(), "package.json"));
|
|
182
64
|
logger.debug("패키지 목록 구성...");
|
|
183
65
|
if (!projNpmConf.workspaces) {
|
|
184
66
|
throw new Error("프로젝트 package.json에 workspaces가 설정되어있지 않습니다.");
|
|
185
67
|
}
|
|
186
|
-
const allPkgPaths =
|
|
68
|
+
const allPkgPaths = projNpmConf.workspaces.mapMany((item) => FsUtil.glob(item)).map((item) => PathUtil.norm(item));
|
|
187
69
|
let pkgPaths = allPkgPaths.filter((pkgPath) => path.basename(pkgPath) in projConf.packages);
|
|
188
70
|
if (opt.pkgNames.length !== 0) {
|
|
189
71
|
pkgPaths = pkgPaths.filter((pkgPath) => opt.pkgNames.includes(path.basename(pkgPath)));
|
|
190
72
|
}
|
|
191
73
|
logger.debug("프로젝트 및 패키지 버전 설정...");
|
|
192
74
|
await this._upgradeVersionAsync(projNpmConf, allPkgPaths);
|
|
193
|
-
logger.debug("빌드 프로세스
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
}*/
|
|
206
|
-
return await this._runCommandAsync(cluster, "build", projConf, pkgPath);
|
|
207
|
-
})).mapMany();
|
|
208
|
-
logger.debug("빌드 프로세스 닫기...");
|
|
209
|
-
this._closeCluster(cluster);
|
|
210
|
-
this._logging(results, logger);
|
|
75
|
+
logger.debug("빌드 프로세스 시작...");
|
|
76
|
+
const parallelBuildRunner = new SdMultiBuildRunner();
|
|
77
|
+
const messages = await pkgPaths.parallelAsync(async (pkgPath) => {
|
|
78
|
+
return await parallelBuildRunner.runAsync({
|
|
79
|
+
cmd: "build",
|
|
80
|
+
pkgPath,
|
|
81
|
+
projConf: projConf,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
this.#logging(messages.mapMany(), logger);
|
|
211
85
|
}
|
|
212
86
|
static async publishAsync(opt) {
|
|
213
87
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "publishAsync"]);
|
|
214
88
|
logger.debug("프로젝트 설정 가져오기...");
|
|
215
89
|
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(false, opt.optNames);
|
|
216
90
|
logger.debug("프로젝트 package.json 가져오기...");
|
|
217
|
-
const projNpmConf =
|
|
91
|
+
const projNpmConf = FsUtil.readJson(path.resolve(process.cwd(), "package.json"));
|
|
218
92
|
if (opt.noBuild) {
|
|
219
93
|
logger.warn("빌드하지 않고, 배포하는것은 상당히 위험합니다.");
|
|
220
94
|
await this._waitSecMessageAsync("프로세스를 중지하려면, 'CTRL+C'를 누르세요.", 5);
|
|
@@ -231,7 +105,10 @@ export class SdCliProject {
|
|
|
231
105
|
if (!projNpmConf.workspaces) {
|
|
232
106
|
throw new Error("프로젝트 package.json에 workspaces가 설정되어있지 않습니다.");
|
|
233
107
|
}
|
|
234
|
-
const allPkgPaths =
|
|
108
|
+
const allPkgPaths = projNpmConf.workspaces
|
|
109
|
+
.mapMany((item) => FsUtil.glob(item))
|
|
110
|
+
.filter((item) => !item.includes("."))
|
|
111
|
+
.map((item) => PathUtil.norm(item));
|
|
235
112
|
let pkgPaths = allPkgPaths.filter((pkgPath) => path.basename(pkgPath) in projConf.packages);
|
|
236
113
|
if (opt.pkgNames.length !== 0) {
|
|
237
114
|
pkgPaths = pkgPaths.filter((pkgPath) => opt.pkgNames.includes(path.basename(pkgPath)));
|
|
@@ -240,15 +117,16 @@ export class SdCliProject {
|
|
|
240
117
|
await this._upgradeVersionAsync(projNpmConf, allPkgPaths);
|
|
241
118
|
// 빌드
|
|
242
119
|
if (!opt.noBuild) {
|
|
243
|
-
logger.debug("빌드 프로세스
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
120
|
+
logger.debug("빌드 프로세스 시작...");
|
|
121
|
+
const parallelBuildRunner = new SdMultiBuildRunner();
|
|
122
|
+
const messages = await pkgPaths.parallelAsync(async (pkgPath) => {
|
|
123
|
+
return await parallelBuildRunner.runAsync({
|
|
124
|
+
cmd: "build",
|
|
125
|
+
pkgPath,
|
|
126
|
+
projConf: projConf,
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
this.#logging(messages.mapMany(), logger);
|
|
252
130
|
}
|
|
253
131
|
// GIT 사용중일경우, 새 버전 커밋 및 TAG 생성
|
|
254
132
|
if (FsUtil.exists(path.resolve(process.cwd(), ".git"))) {
|
|
@@ -299,7 +177,7 @@ export class SdCliProject {
|
|
|
299
177
|
await SdProcess.spawnAsync("yarn npm publish --access public", { cwd: pkgPath });
|
|
300
178
|
}
|
|
301
179
|
else if (pkgPubConf?.type === "local-directory") {
|
|
302
|
-
const pkgNpmConf =
|
|
180
|
+
const pkgNpmConf = FsUtil.readJson(path.resolve(pkgPath, "package.json"));
|
|
303
181
|
const targetRootPath = pkgPubConf.path.replace(/%([^%]*)%/g, (item) => {
|
|
304
182
|
const envName = item.replace(/%/g, "");
|
|
305
183
|
if (!StringUtil.isNullOrEmpty(pkgNpmConf.version) && envName === "SD_VERSION") {
|
|
@@ -310,15 +188,15 @@ export class SdCliProject {
|
|
|
310
188
|
}
|
|
311
189
|
return process.env[envName] ?? item;
|
|
312
190
|
});
|
|
313
|
-
const filePaths =
|
|
191
|
+
const filePaths = FsUtil.glob(path.resolve(pkgPath, "dist", "**", "*"), {
|
|
314
192
|
dot: true,
|
|
315
193
|
nodir: true,
|
|
316
194
|
});
|
|
317
|
-
|
|
195
|
+
for (const filePath of filePaths) {
|
|
318
196
|
const relativeFilePath = path.relative(path.resolve(pkgPath, "dist"), filePath);
|
|
319
197
|
const targetPath = PathUtil.posix(targetRootPath, relativeFilePath);
|
|
320
|
-
|
|
321
|
-
}
|
|
198
|
+
FsUtil.copy(filePath, targetPath);
|
|
199
|
+
}
|
|
322
200
|
}
|
|
323
201
|
else if (pkgPubConf?.type === "ftp" || pkgPubConf?.type === "ftps" || pkgPubConf?.type === "sftp") {
|
|
324
202
|
const ftp = await SdStorage.connectAsync(pkgPubConf.type, {
|
|
@@ -349,8 +227,8 @@ export class SdCliProject {
|
|
|
349
227
|
// 작업공간 package.json 버전 설정
|
|
350
228
|
const newVersion = semver.inc(projNpmConf.version, "patch");
|
|
351
229
|
projNpmConf.version = newVersion;
|
|
352
|
-
const pkgNames =
|
|
353
|
-
const pkgNpmConf =
|
|
230
|
+
const pkgNames = allPkgPaths.map((pkgPath) => {
|
|
231
|
+
const pkgNpmConf = FsUtil.readJson(path.resolve(pkgPath, "package.json"));
|
|
354
232
|
return pkgNpmConf.name;
|
|
355
233
|
});
|
|
356
234
|
const updateDepVersion = (deps) => {
|
|
@@ -367,27 +245,27 @@ export class SdCliProject {
|
|
|
367
245
|
updateDepVersion(projNpmConf.devDependencies);
|
|
368
246
|
updateDepVersion(projNpmConf.peerDependencies);
|
|
369
247
|
const projNpmConfFilePath = path.resolve(process.cwd(), "package.json");
|
|
370
|
-
|
|
248
|
+
FsUtil.writeJson(projNpmConfFilePath, projNpmConf, { space: 2 });
|
|
371
249
|
// 각 패키지 package.json 버전 설정
|
|
372
250
|
await allPkgPaths.parallelAsync(async (pkgPath) => {
|
|
373
251
|
const pkgNpmConfFilePath = path.resolve(pkgPath, "package.json");
|
|
374
|
-
const pkgNpmConf =
|
|
252
|
+
const pkgNpmConf = FsUtil.readJson(pkgNpmConfFilePath);
|
|
375
253
|
pkgNpmConf.version = newVersion;
|
|
376
254
|
updateDepVersion(pkgNpmConf.dependencies);
|
|
377
255
|
updateDepVersion(pkgNpmConf.optionalDependencies);
|
|
378
256
|
updateDepVersion(pkgNpmConf.devDependencies);
|
|
379
257
|
updateDepVersion(pkgNpmConf.peerDependencies);
|
|
380
|
-
|
|
258
|
+
FsUtil.writeJson(pkgNpmConfFilePath, pkgNpmConf, { space: 2 });
|
|
381
259
|
if (FsUtil.exists(path.resolve(pkgPath, "plugin.xml"))) {
|
|
382
260
|
const cordovaPluginConfFilePath = path.resolve(pkgPath, "plugin.xml");
|
|
383
|
-
const cordovaPluginConfXml = await xml2js.parseStringPromise(
|
|
261
|
+
const cordovaPluginConfXml = await xml2js.parseStringPromise(FsUtil.readFile(cordovaPluginConfFilePath));
|
|
384
262
|
cordovaPluginConfXml.plugin.$.version = newVersion;
|
|
385
|
-
|
|
263
|
+
FsUtil.writeFile(cordovaPluginConfFilePath, new xml2js.Builder().buildObject(cordovaPluginConfXml));
|
|
386
264
|
}
|
|
387
265
|
});
|
|
388
266
|
}
|
|
389
|
-
static
|
|
390
|
-
const messageMap = buildResults.toSetMap((item) => item.severity, (item) =>
|
|
267
|
+
static #logging(buildResults, logger) {
|
|
268
|
+
const messageMap = buildResults.toSetMap((item) => item.severity, (item) => SdCliConvertMessageUtil.getBuildMessageString(item));
|
|
391
269
|
if (messageMap.has("message")) {
|
|
392
270
|
logger.log(`알림\n${[...messageMap.get("message")].join("\n")}`);
|
|
393
271
|
}
|
|
@@ -402,109 +280,5 @@ export class SdCliProject {
|
|
|
402
280
|
}
|
|
403
281
|
logger.info("모든 빌드가 완료되었습니다.");
|
|
404
282
|
}
|
|
405
|
-
// piscina 사용시 ts파일을 못찾으므로 그냥 이렇게..
|
|
406
|
-
static async _prepareClusterAsync() {
|
|
407
|
-
const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "_runBuildClusterAsync"]);
|
|
408
|
-
return await new Promise((resolve, reject) => {
|
|
409
|
-
const cluster = cp.fork(fileURLToPath(import.meta.resolve("../build-cluster")), [], {
|
|
410
|
-
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
411
|
-
env: {
|
|
412
|
-
...process.env,
|
|
413
|
-
// "NG_BUILD_PARALLEL_TS": "0"
|
|
414
|
-
},
|
|
415
|
-
});
|
|
416
|
-
cluster.stdout.pipe(process.stdout);
|
|
417
|
-
cluster.stderr.pipe(process.stderr);
|
|
418
|
-
cluster.on("exit", (code) => {
|
|
419
|
-
if (code != null && code !== 0) {
|
|
420
|
-
const err = new Error(`오류와 함께 닫힘 (${code})`);
|
|
421
|
-
logger.error(err);
|
|
422
|
-
reject(err);
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
cluster.on("error", (err) => {
|
|
427
|
-
logger.error(err);
|
|
428
|
-
reject(err);
|
|
429
|
-
});
|
|
430
|
-
cluster.on("message", (message) => {
|
|
431
|
-
if (message === "ready") {
|
|
432
|
-
logger.debug("빌드 클러스터 프로세스가 준비되었습니다.");
|
|
433
|
-
resolve(cluster);
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
static async _runCommandAsync(cluster, cmd, projConf, pkgPath, execArgs) {
|
|
439
|
-
return await new Promise((resolve) => {
|
|
440
|
-
const cb = (message) => {
|
|
441
|
-
if (cmd === "watch" && message.type === "ready" && message.req.cmd === cmd && message.req.pkgPath === pkgPath) {
|
|
442
|
-
cluster.off("message", cb);
|
|
443
|
-
resolve();
|
|
444
|
-
}
|
|
445
|
-
else if (cmd === "build" &&
|
|
446
|
-
message.type === "complete" &&
|
|
447
|
-
message.req.cmd === cmd &&
|
|
448
|
-
message.req.pkgPath === pkgPath) {
|
|
449
|
-
cluster.off("message", cb);
|
|
450
|
-
resolve(message.result?.buildResults);
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
cluster.on("message", cb);
|
|
454
|
-
cluster.send({
|
|
455
|
-
cmd,
|
|
456
|
-
projConf,
|
|
457
|
-
pkgPath,
|
|
458
|
-
execArgs,
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
static _closeCluster(cluster) {
|
|
463
|
-
cluster.kill("SIGKILL");
|
|
464
|
-
}
|
|
465
|
-
static async _restartServerAsync(pkgOrOpt, prevServerProcess) {
|
|
466
|
-
const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "_restartServerAsync"]);
|
|
467
|
-
if (prevServerProcess) {
|
|
468
|
-
prevServerProcess.kill("SIGKILL");
|
|
469
|
-
}
|
|
470
|
-
const npmConf = "path" in pkgOrOpt
|
|
471
|
-
? (await FsUtil.readJsonAsync(path.resolve(pkgOrOpt.path, "package.json")))
|
|
472
|
-
: undefined;
|
|
473
|
-
return await new Promise((resolve, reject) => {
|
|
474
|
-
const worker = cp.fork(fileURLToPath(import.meta.resolve("../server-worker")), [JsonConvert.stringify("path" in pkgOrOpt ? pkgOrOpt.path : pkgOrOpt)], {
|
|
475
|
-
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
476
|
-
env: {
|
|
477
|
-
...process.env,
|
|
478
|
-
NODE_ENV: "development",
|
|
479
|
-
TZ: "Asia/Seoul",
|
|
480
|
-
SD_VERSION: npmConf?.version ?? "serverless",
|
|
481
|
-
...("path" in pkgOrOpt ? pkgOrOpt.conf.env : {}),
|
|
482
|
-
},
|
|
483
|
-
});
|
|
484
|
-
worker.stdout.pipe(process.stdout);
|
|
485
|
-
worker.stderr.pipe(process.stderr);
|
|
486
|
-
worker.on("exit", (code) => {
|
|
487
|
-
if (code != null && code !== 0) {
|
|
488
|
-
const err = new Error(`오류와 함께 닫힘 (${code})`);
|
|
489
|
-
logger.error(err);
|
|
490
|
-
reject(err);
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
worker.on("error", (err) => {
|
|
495
|
-
logger.error(err);
|
|
496
|
-
reject(err);
|
|
497
|
-
});
|
|
498
|
-
worker.on("message", (message) => {
|
|
499
|
-
if ("port" in message) {
|
|
500
|
-
logger.debug("서버가 시작되었습니다.");
|
|
501
|
-
resolve({
|
|
502
|
-
worker,
|
|
503
|
-
port: message.port,
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
283
|
}
|
|
510
284
|
//# sourceMappingURL=SdCliProject.js.map
|