@simplysm/sd-cli 12.5.21 → 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.
Files changed (195) hide show
  1. package/dist/{build-tools → entry}/SdCliCordova.d.ts +5 -6
  2. package/dist/{build-tools → entry}/SdCliCordova.js +117 -99
  3. package/dist/entry/SdCliCordova.js.map +1 -0
  4. package/dist/entry/SdCliElectron.d.ts +2 -2
  5. package/dist/entry/SdCliElectron.js +50 -40
  6. package/dist/entry/SdCliElectron.js.map +1 -1
  7. package/dist/entry/SdCliLocalUpdate.d.ts +1 -2
  8. package/dist/entry/SdCliLocalUpdate.js +26 -27
  9. package/dist/entry/SdCliLocalUpdate.js.map +1 -1
  10. package/dist/entry/SdCliProject.d.ts +1 -5
  11. package/dist/entry/SdCliProject.js +62 -288
  12. package/dist/entry/SdCliProject.js.map +1 -1
  13. package/dist/index.d.ts +23 -20
  14. package/dist/index.js +23 -20
  15. package/dist/index.js.map +1 -1
  16. package/dist/pkg-builders/SdMultiBuildRunner.d.ts +21 -0
  17. package/dist/pkg-builders/SdMultiBuildRunner.js +174 -0
  18. package/dist/pkg-builders/SdMultiBuildRunner.js.map +1 -0
  19. package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.d.ts +4 -0
  20. package/dist/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.js +7 -7
  21. package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.js.map +1 -0
  22. package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +20 -0
  23. package/dist/pkg-builders/client/SdClientBuildRunner.js +135 -0
  24. package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -0
  25. package/dist/pkg-builders/client/SdNgBundler.d.ts +29 -0
  26. package/dist/{build-tools → pkg-builders/client}/SdNgBundler.js +100 -95
  27. package/dist/pkg-builders/client/SdNgBundler.js.map +1 -0
  28. package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.d.ts +1 -2
  29. package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.js +19 -45
  30. package/dist/pkg-builders/client/SdNgBundlerContext.js.map +1 -0
  31. package/dist/pkg-builders/client/createSdNgPlugin.d.ts +10 -0
  32. package/dist/{bundle-plugins/sdNgPlugin.js → pkg-builders/client/createSdNgPlugin.js} +32 -33
  33. package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -0
  34. package/dist/pkg-builders/lib/SdCliIndexFileGenerator.d.ts +5 -0
  35. package/dist/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.js +11 -11
  36. package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js.map +1 -0
  37. package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +16 -0
  38. package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +81 -0
  39. package/dist/pkg-builders/lib/SdJsLibBuildRunner.js.map +1 -0
  40. package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +13 -0
  41. package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +89 -0
  42. package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -0
  43. package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +14 -0
  44. package/dist/pkg-builders/lib/SdTsLibBuilder.js +54 -0
  45. package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -0
  46. package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +17 -0
  47. package/dist/{builders/SdCliServerBuilder.js → pkg-builders/server/SdServerBuildRunner.js} +48 -53
  48. package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -0
  49. package/dist/pkg-builders/server/SdServerBundler.d.ts +19 -0
  50. package/dist/{build-tools → pkg-builders/server}/SdServerBundler.js +25 -30
  51. package/dist/pkg-builders/server/SdServerBundler.js.map +1 -0
  52. package/dist/pkg-builders/server/createSdServerPlugin.d.ts +10 -0
  53. package/dist/pkg-builders/server/createSdServerPlugin.js +53 -0
  54. package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -0
  55. package/dist/sd-cli.js +61 -54
  56. package/dist/sd-cli.js.map +1 -1
  57. package/dist/ts-builder/SdTsCompileWorker.d.ts +9 -0
  58. package/dist/ts-builder/SdTsCompileWorker.js +16 -0
  59. package/dist/ts-builder/SdTsCompileWorker.js.map +1 -0
  60. package/dist/ts-builder/SdTsCompiler.d.ts +7 -0
  61. package/dist/{build-tools → ts-builder}/SdTsCompiler.js +226 -212
  62. package/dist/ts-builder/SdTsCompiler.js.map +1 -0
  63. package/dist/types/build-plugin.type.d.ts +14 -0
  64. package/dist/types/build-plugin.type.js +2 -0
  65. package/dist/types/build-plugin.type.js.map +1 -0
  66. package/dist/types/build.type.d.ts +15 -0
  67. package/dist/types/build.type.js +2 -0
  68. package/dist/types/build.type.js.map +1 -0
  69. package/dist/types/common-configs.type.d.ts +22 -0
  70. package/dist/types/common-configs.type.js +2 -0
  71. package/dist/types/common-configs.type.js.map +1 -0
  72. package/dist/types/sd-configs.type.d.ts +99 -0
  73. package/dist/types/sd-configs.type.js +2 -0
  74. package/dist/types/sd-configs.type.js.map +1 -0
  75. package/dist/types/ts-compiler.type.d.ts +29 -0
  76. package/dist/types/ts-compiler.type.js +2 -0
  77. package/dist/types/ts-compiler.type.js.map +1 -0
  78. package/dist/types/workers.type.d.ts +49 -0
  79. package/dist/types/workers.type.js +2 -0
  80. package/dist/types/workers.type.js.map +1 -0
  81. package/dist/utils/SdCliConvertMessageUtil.d.ts +21 -0
  82. package/dist/utils/SdCliConvertMessageUtil.js +137 -0
  83. package/dist/utils/SdCliConvertMessageUtil.js.map +1 -0
  84. package/dist/workers/compile-worker.js +27 -0
  85. package/dist/workers/compile-worker.js.map +1 -0
  86. package/dist/workers/lint-worker.js +36 -0
  87. package/dist/workers/lint-worker.js.map +1 -0
  88. package/dist/workers/server-worker.d.ts +1 -0
  89. package/dist/workers/server-worker.js +49 -0
  90. package/dist/workers/server-worker.js.map +1 -0
  91. package/lib/dev-worker.cjs +5 -0
  92. package/package.json +7 -10
  93. package/src/entry/SdCliCordova.ts +363 -0
  94. package/src/entry/SdCliElectron.ts +96 -69
  95. package/src/entry/SdCliLocalUpdate.ts +43 -44
  96. package/src/entry/SdCliProject.ts +72 -417
  97. package/src/index.ts +23 -20
  98. package/src/pkg-builders/SdMultiBuildRunner.ts +250 -0
  99. package/src/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.ts +7 -7
  100. package/src/pkg-builders/client/SdClientBuildRunner.ts +191 -0
  101. package/src/{build-tools → pkg-builders/client}/SdNgBundler.ts +125 -121
  102. package/src/pkg-builders/client/SdNgBundlerContext.ts +111 -0
  103. package/src/{bundle-plugins/sdNgPlugin.ts → pkg-builders/client/createSdNgPlugin.ts} +43 -46
  104. package/src/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.ts +11 -11
  105. package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +105 -0
  106. package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +128 -0
  107. package/src/pkg-builders/lib/SdTsLibBuilder.ts +69 -0
  108. package/src/{builders/SdCliServerBuilder.ts → pkg-builders/server/SdServerBuildRunner.ts} +66 -78
  109. package/src/{build-tools → pkg-builders/server}/SdServerBundler.ts +40 -41
  110. package/src/pkg-builders/server/createSdServerPlugin.ts +77 -0
  111. package/src/sd-cli.ts +197 -211
  112. package/src/ts-builder/SdTsCompileWorker.ts +21 -0
  113. package/src/ts-builder/SdTsCompiler.ts +758 -0
  114. package/src/types/build-plugin.type.ts +16 -0
  115. package/src/types/build.type.ts +17 -0
  116. package/src/types/common-configs.type.ts +27 -0
  117. package/src/types/sd-configs.type.ts +114 -0
  118. package/src/types/ts-compiler.type.ts +29 -0
  119. package/src/types/workers.type.ts +27 -0
  120. package/src/utils/SdCliConvertMessageUtil.ts +177 -0
  121. package/src/workers/compile-worker.ts +31 -0
  122. package/src/workers/lint-worker.ts +44 -0
  123. package/src/workers/server-worker.ts +52 -0
  124. package/tsconfig.json +7 -1
  125. package/dist/build-cluster.js +0 -201
  126. package/dist/build-cluster.js.map +0 -1
  127. package/dist/build-tools/SdCliCordova.js.map +0 -1
  128. package/dist/build-tools/SdCliIndexFileGenerator.d.ts +0 -5
  129. package/dist/build-tools/SdCliIndexFileGenerator.js.map +0 -1
  130. package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +0 -4
  131. package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +0 -1
  132. package/dist/build-tools/SdLinter.d.ts +0 -5
  133. package/dist/build-tools/SdLinter.js +0 -49
  134. package/dist/build-tools/SdLinter.js.map +0 -1
  135. package/dist/build-tools/SdNgBundler.d.ts +0 -29
  136. package/dist/build-tools/SdNgBundler.js.map +0 -1
  137. package/dist/build-tools/SdNgBundlerContext.js.map +0 -1
  138. package/dist/build-tools/SdReactBundler.d.ts +0 -25
  139. package/dist/build-tools/SdReactBundler.js +0 -295
  140. package/dist/build-tools/SdReactBundler.js.map +0 -1
  141. package/dist/build-tools/SdReactBundlerContext.d.ts +0 -14
  142. package/dist/build-tools/SdReactBundlerContext.js +0 -59
  143. package/dist/build-tools/SdReactBundlerContext.js.map +0 -1
  144. package/dist/build-tools/SdServerBundler.d.ts +0 -20
  145. package/dist/build-tools/SdServerBundler.js.map +0 -1
  146. package/dist/build-tools/SdTsCompiler.d.ts +0 -34
  147. package/dist/build-tools/SdTsCompiler.js.map +0 -1
  148. package/dist/build-tools/SdTsLibBundler.d.ts +0 -13
  149. package/dist/build-tools/SdTsLibBundler.js +0 -58
  150. package/dist/build-tools/SdTsLibBundler.js.map +0 -1
  151. package/dist/builders/SdCliClientBuilder.d.ts +0 -18
  152. package/dist/builders/SdCliClientBuilder.js +0 -172
  153. package/dist/builders/SdCliClientBuilder.js.map +0 -1
  154. package/dist/builders/SdCliJsLibLinter.d.ts +0 -13
  155. package/dist/builders/SdCliJsLibLinter.js +0 -60
  156. package/dist/builders/SdCliJsLibLinter.js.map +0 -1
  157. package/dist/builders/SdCliServerBuilder.d.ts +0 -15
  158. package/dist/builders/SdCliServerBuilder.js.map +0 -1
  159. package/dist/builders/SdCliTsLibBuilder.d.ts +0 -12
  160. package/dist/builders/SdCliTsLibBuilder.js +0 -90
  161. package/dist/builders/SdCliTsLibBuilder.js.map +0 -1
  162. package/dist/bundle-plugins/sdNgPlugin.d.ts +0 -16
  163. package/dist/bundle-plugins/sdNgPlugin.js.map +0 -1
  164. package/dist/bundle-plugins/sdReactPlugin.d.ts +0 -16
  165. package/dist/bundle-plugins/sdReactPlugin.js +0 -117
  166. package/dist/bundle-plugins/sdReactPlugin.js.map +0 -1
  167. package/dist/bundle-plugins/sdServerPlugin.d.ts +0 -16
  168. package/dist/bundle-plugins/sdServerPlugin.js +0 -63
  169. package/dist/bundle-plugins/sdServerPlugin.js.map +0 -1
  170. package/dist/commons.d.ts +0 -145
  171. package/dist/commons.js +0 -2
  172. package/dist/commons.js.map +0 -1
  173. package/dist/server-worker.js +0 -57
  174. package/dist/server-worker.js.map +0 -1
  175. package/dist/utils/SdCliBuildResultUtil.d.ts +0 -16
  176. package/dist/utils/SdCliBuildResultUtil.js +0 -54
  177. package/dist/utils/SdCliBuildResultUtil.js.map +0 -1
  178. package/src/build-cluster.ts +0 -212
  179. package/src/build-tools/SdCliCordova.ts +0 -340
  180. package/src/build-tools/SdLinter.ts +0 -65
  181. package/src/build-tools/SdNgBundlerContext.ts +0 -137
  182. package/src/build-tools/SdReactBundler.ts +0 -372
  183. package/src/build-tools/SdReactBundlerContext.ts +0 -71
  184. package/src/build-tools/SdTsCompiler.ts +0 -754
  185. package/src/build-tools/SdTsLibBundler.ts +0 -72
  186. package/src/builders/SdCliClientBuilder.ts +0 -233
  187. package/src/builders/SdCliJsLibLinter.ts +0 -72
  188. package/src/builders/SdCliTsLibBuilder.ts +0 -126
  189. package/src/bundle-plugins/sdReactPlugin.ts +0 -164
  190. package/src/bundle-plugins/sdServerPlugin.ts +0 -94
  191. package/src/commons.ts +0 -171
  192. package/src/server-worker.ts +0 -65
  193. package/src/utils/SdCliBuildResultUtil.ts +0 -63
  194. /package/dist/{build-cluster.d.ts → workers/compile-worker.d.ts} +0 -0
  195. /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 = await this._getUpdatePathInfosAsync(projConf.localUpdates);
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
- await FsUtil.copyAsync(updatePathInfo.source, updatePathInfo.target, (src) => {
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 = await this._getUpdatePathInfosAsync(projConf.localUpdates);
32
+ const updatePathInfos = this.#getUpdatePathInfos(projConf.localUpdates);
33
33
  logger.debug("로컬 업데이트 구성");
34
- const watchPaths = (await updatePathInfos.mapManyAsync(async (item) => await this._getWatchPathsAsync(item.source))).distinct();
34
+ const watchPaths = updatePathInfos.mapMany((item) => this.#getWatchPaths(item.source)).distinct();
35
35
  const watcher = SdFsWatcher.watch(watchPaths);
36
- watcher.onChange({ delay: 1000 }, async (changedInfos) => {
37
- const changeFilePaths = changedInfos.filter((item) => ["add", "change", "unlink"].includes(item.event)).map((item) => item.path);
38
- if (changeFilePaths.length === 0)
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 changedFilePath of changeFilePaths) {
42
- if (!FsUtil.exists(changedFilePath))
43
- continue;
41
+ for (const changedFileInfo of changedFileInfos) {
44
42
  for (const updatePathInfo of updatePathInfos) {
45
- if (!PathUtil.isChildPath(changedFilePath, updatePathInfo.source))
43
+ if (!PathUtil.isChildPath(changedFileInfo.path, updatePathInfo.source))
46
44
  continue;
47
- const sourceRelPath = path.relative(updatePathInfo.source, changedFilePath);
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
- logger.debug(`변경파일감지(복사): ${changedFilePath} => ${targetFilePath}`);
52
- await FsUtil.copyAsync(changedFilePath, targetFilePath);
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(await updatePathInfos.mapManyAsync(async (item) => await this._getWatchPathsAsync(item.source)));
56
- watcher.add(watchFileSet);
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 async _getUpdatePathInfosAsync(record) {
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
- ...await FsUtil.globAsync(path.resolve(process.cwd(), "node_modules", pkgGlobPath)),
66
- ...await FsUtil.globAsync(path.resolve(process.cwd(), "packages", "*", "node_modules", pkgGlobPath))
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) => (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 async _getWatchPathsAsync(sourcePath) {
88
- return await FsUtil.globAsync(path.resolve(sourcePath, "**"));
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,EAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAC7E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM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,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,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 cp from "child_process";
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 { JsonConvert, NeverEntryError, StringUtil, Wait } from "@simplysm/sd-core-common";
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 = (await FsUtil.readJsonAsync(path.resolve(process.cwd(), "package.json")));
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 = (await projNpmConf.workspaces.mapManyAsync(async (item) => await FsUtil.globAsync(item))).filter((item) => !item.includes("."));
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 cluster = await this._prepareClusterAsync();
41
- logger.debug("빌드 프로세스 이벤트 준비...");
42
- const resultCache = new Map();
43
- let busyReqCntMap = new Map();
44
- const serverInfoMap = new Map();
45
- cluster.on("message", (message) => {
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 this._runCommandAsync(cluster, "watch", projConf, pkgPath, opt.inspectNames.includes(path.basename(pkgPath)) ? ["--inspect"] : []);
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 = (await FsUtil.readJsonAsync(path.resolve(process.cwd(), "package.json")));
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 = await projNpmConf.workspaces.mapManyAsync(async (item) => await FsUtil.globAsync(item));
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 cluster = await this._prepareClusterAsync();
195
- logger.debug("빌드 프로세스 명령 전달...");
196
- const results = (await pkgPaths.parallelAsync(async (pkgPath) => {
197
- /*const pkgConf = projConf.packages[path.basename(pkgPath)]!;
198
- if (pkgConf.type === "client") {
199
- const builderKeys = Object.keys(pkgConf.builder ?? {web: {}});
200
- return (await builderKeys.parallelAsync(async (builderKey) => {
201
- return await this._runCommandAsync(cluster, "build", projConf, pkgPath, builderKey);
202
- })).mapMany();
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 = (await FsUtil.readJsonAsync(path.resolve(process.cwd(), "package.json")));
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 = (await projNpmConf.workspaces.mapManyAsync(async (item) => await FsUtil.globAsync(item))).filter((item) => !item.includes("."));
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 cluster = await this._prepareClusterAsync();
245
- logger.debug("빌드 프로세스 명령 전달...");
246
- const results = (await pkgPaths.parallelAsync(async (pkgPath) => {
247
- return await this._runCommandAsync(cluster, "build", projConf, pkgPath);
248
- })).mapMany();
249
- logger.debug("빌드 프로세스 닫기...");
250
- this._closeCluster(cluster);
251
- this._logging(results, logger);
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 = (await FsUtil.readJsonAsync(path.resolve(pkgPath, "package.json")));
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 = await FsUtil.globAsync(path.resolve(pkgPath, "dist", "**", "*"), {
191
+ const filePaths = FsUtil.glob(path.resolve(pkgPath, "dist", "**", "*"), {
314
192
  dot: true,
315
193
  nodir: true,
316
194
  });
317
- await filePaths.parallelAsync(async (filePath) => {
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
- await FsUtil.copyAsync(filePath, targetPath);
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 = await allPkgPaths.mapAsync(async (pkgPath) => {
353
- const pkgNpmConf = await FsUtil.readJsonAsync(path.resolve(pkgPath, "package.json"));
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
- await FsUtil.writeJsonAsync(projNpmConfFilePath, projNpmConf, { space: 2 });
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 = await FsUtil.readJsonAsync(pkgNpmConfFilePath);
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
- await FsUtil.writeJsonAsync(pkgNpmConfFilePath, pkgNpmConf, { space: 2 });
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(await FsUtil.readFileAsync(cordovaPluginConfFilePath));
261
+ const cordovaPluginConfXml = await xml2js.parseStringPromise(FsUtil.readFile(cordovaPluginConfFilePath));
384
262
  cordovaPluginConfXml.plugin.$.version = newVersion;
385
- await FsUtil.writeFileAsync(cordovaPluginConfFilePath, new xml2js.Builder().buildObject(cordovaPluginConfXml));
263
+ FsUtil.writeFile(cordovaPluginConfFilePath, new xml2js.Builder().buildObject(cordovaPluginConfXml));
386
264
  }
387
265
  });
388
266
  }
389
- static _logging(buildResults, logger) {
390
- const messageMap = buildResults.toSetMap((item) => item.severity, (item) => SdCliBuildResultUtil.getMessage(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