@simplysm/sd-cli 11.1.44 → 11.1.46

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 (58) hide show
  1. package/dist/build-cluster.js +124 -105
  2. package/dist/build-cluster.js.map +1 -1
  3. package/dist/build-tools/SdCliCordova.js.map +1 -1
  4. package/dist/build-tools/SdCliIndexFileGenerator.js.map +1 -1
  5. package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +1 -1
  6. package/dist/build-tools/SdLinter.js.map +1 -1
  7. package/dist/build-tools/SdNgBundler.d.ts +1 -1
  8. package/dist/build-tools/SdNgBundler.js +8 -5
  9. package/dist/build-tools/SdNgBundler.js.map +1 -1
  10. package/dist/build-tools/SdNgBundlerContext.js.map +1 -1
  11. package/dist/build-tools/SdServerBundler.js +1 -1
  12. package/dist/build-tools/SdServerBundler.js.map +1 -1
  13. package/dist/build-tools/SdTsCompiler.d.ts +5 -21
  14. package/dist/build-tools/SdTsCompiler.js +211 -188
  15. package/dist/build-tools/SdTsCompiler.js.map +1 -1
  16. package/dist/build-tools2/SdTsCompiler2.d.ts +26 -0
  17. package/dist/build-tools2/SdTsCompiler2.js +280 -0
  18. package/dist/build-tools2/SdTsCompiler2.js.map +1 -0
  19. package/dist/builders/SdCliClientBuilder.js.map +1 -1
  20. package/dist/builders/SdCliServerBuilder.js.map +1 -1
  21. package/dist/builders/SdCliTsLibBuilder.js +7 -12
  22. package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
  23. package/dist/bundle-plugins/sdNgPlugin.d.ts +3 -3
  24. package/dist/bundle-plugins/sdNgPlugin.js +23 -213
  25. package/dist/bundle-plugins/sdNgPlugin.js.map +1 -1
  26. package/dist/bundle-plugins/sdServerPlugin.d.ts +2 -2
  27. package/dist/bundle-plugins/sdServerPlugin.js +17 -110
  28. package/dist/bundle-plugins/sdServerPlugin.js.map +1 -1
  29. package/dist/commons.d.ts +1 -0
  30. package/dist/entry/SdCliElectron.js.map +1 -1
  31. package/dist/entry/SdCliLocalUpdate.js.map +1 -1
  32. package/dist/entry/SdCliProject.d.ts +1 -0
  33. package/dist/entry/SdCliProject.js +20 -37
  34. package/dist/entry/SdCliProject.js.map +1 -1
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.js +1 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/sd-cli.js +7 -1
  39. package/dist/sd-cli.js.map +1 -1
  40. package/dist/server-worker.js.map +1 -1
  41. package/dist/utils/SdCliBuildResultUtil.d.ts +10 -0
  42. package/dist/utils/SdCliBuildResultUtil.js +17 -1
  43. package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
  44. package/package.json +16 -16
  45. package/src/build-cluster.ts +152 -132
  46. package/src/build-tools/SdNgBundler.ts +7 -4
  47. package/src/build-tools/SdServerBundler.ts +2 -2
  48. package/src/build-tools/SdTsCompiler.ts +64 -94
  49. package/src/build-tools2/SdTsCompiler2.ts +427 -0
  50. package/src/builders/SdCliTsLibBuilder.ts +7 -12
  51. package/src/bundle-plugins/sdNgPlugin.ts +26 -320
  52. package/src/bundle-plugins/sdServerPlugin.ts +20 -168
  53. package/src/commons.ts +1 -0
  54. package/src/entry/SdCliProject.ts +33 -38
  55. package/src/index.ts +1 -0
  56. package/src/sd-cli.ts +7 -1
  57. package/src/server-worker.ts +3 -3
  58. package/src/utils/SdCliBuildResultUtil.ts +22 -3
@@ -2,7 +2,6 @@ import path from "path";
2
2
  import {FsUtil, Logger, PathUtil, SdProcess} from "@simplysm/sd-core-node";
3
3
  import {
4
4
  INpmConfig,
5
- ISdCliBuildClusterReqMessage,
6
5
  ISdCliBuildClusterResMessage,
7
6
  ISdCliConfig,
8
7
  ISdCliPackageBuildResult,
@@ -23,6 +22,7 @@ export class SdCliProject {
23
22
  confFileRelPath: string;
24
23
  optNames: string[];
25
24
  pkgNames: string[];
25
+ inspectNames: string[];
26
26
  }): Promise<void> {
27
27
  const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "watchAsync"]);
28
28
 
@@ -61,7 +61,7 @@ export class SdCliProject {
61
61
 
62
62
  logger.debug("빌드 프로세스 이벤트 준비...");
63
63
  const resultCache = new Map<string, ISdCliPackageBuildResult[]>();
64
- let busyCount = 0;
64
+ let busyReqCntMap = new Map<string, number>();
65
65
  const serverInfoMap = new Map<string, {
66
66
  // server
67
67
  pkgOrOpt?: { path: string; conf: ISdCliServerPackageConfig } | { port: number }; // persist
@@ -76,10 +76,13 @@ export class SdCliProject {
76
76
  }>();
77
77
  cluster.on("message", (message: ISdCliBuildClusterResMessage) => {
78
78
  if (message.type === "change") {
79
- if (busyCount === 0) {
79
+ if (Array.from(busyReqCntMap.values()).every(v => v === 0)) {
80
80
  logger.log("빌드를 시작합니다...");
81
81
  }
82
- busyCount++;
82
+ busyReqCntMap.set(
83
+ message.req.cmd + "|" + message.req.pkgPath,
84
+ (busyReqCntMap.get(message.req.cmd + "|" + message.req.pkgPath) ?? 0) + 1
85
+ );
83
86
  }
84
87
  else if (message.type === "complete") {
85
88
  resultCache.delete("none");
@@ -149,8 +152,12 @@ export class SdCliProject {
149
152
  }
150
153
 
151
154
  setTimeout(async () => {
152
- busyCount--;
153
- if (busyCount === 0) {
155
+ busyReqCntMap.set(
156
+ message.req.cmd + "|" + message.req.pkgPath,
157
+ (busyReqCntMap.get(message.req.cmd + "|" + message.req.pkgPath) ?? 0) - 1
158
+ );
159
+ logger.debug("남아있는 예약 빌드", busyReqCntMap);
160
+ if (Array.from(busyReqCntMap.values()).every(v => v === 0)) {
154
161
  for (const serverPkgNameOrPort of serverInfoMap.keys()) {
155
162
  const serverInfo = serverInfoMap.get(serverPkgNameOrPort)!;
156
163
  if (serverInfo.pkgOrOpt && serverInfo.hasChanges) {
@@ -206,24 +213,21 @@ export class SdCliProject {
206
213
  });
207
214
 
208
215
  logger.debug("빌드 프로세스 명령 전송...");
209
- busyCount++;
216
+ busyReqCntMap.set(
217
+ "all",
218
+ (busyReqCntMap.get("all") ?? 0) + 1
219
+ );
210
220
  logger.log("빌드를 시작합니다...");
211
221
 
212
222
  await pkgPaths.parallelAsync(async (pkgPath) => {
213
- const pkgConf = projConf.packages[path.basename(pkgPath)]!;
214
- if (pkgConf.type === "client") {
215
- const builderKeys = Object.keys(pkgConf.builder ?? {web: {}});
216
- await builderKeys.parallelAsync(async (builderKey) => {
217
- await this._runCommandAsync(cluster, "watch", projConf, pkgPath, builderKey);
218
- });
219
- }
220
- else {
221
- await this._runCommandAsync(cluster, "watch", projConf, pkgPath);
222
- }
223
+ await this._runCommandAsync(cluster, "watch", projConf, pkgPath, opt.inspectNames.includes(path.basename(pkgPath)) ? ["--inspect"] : []);
223
224
  });
224
225
 
225
- busyCount--;
226
- if (busyCount === 0) {
226
+ busyReqCntMap.set(
227
+ "all",
228
+ (busyReqCntMap.get("all") ?? 0) - 1
229
+ );
230
+ if (Array.from(busyReqCntMap.values()).every(v => v === 0)) {
227
231
  const buildResults = Array.from(resultCache.values()).mapMany();
228
232
  this._logging(buildResults, logger);
229
233
  }
@@ -261,7 +265,7 @@ export class SdCliProject {
261
265
  logger.debug("빌드 프로세스 명령 전달...");
262
266
  const results = (
263
267
  await pkgPaths.parallelAsync(async (pkgPath) => {
264
- const pkgConf = projConf.packages[path.basename(pkgPath)]!;
268
+ /*const pkgConf = projConf.packages[path.basename(pkgPath)]!;
265
269
  if (pkgConf.type === "client") {
266
270
  const builderKeys = Object.keys(pkgConf.builder ?? {web: {}});
267
271
  return (await builderKeys.parallelAsync(async (builderKey) => {
@@ -269,8 +273,8 @@ export class SdCliProject {
269
273
  })).mapMany();
270
274
  }
271
275
  else {
272
- return await this._runCommandAsync(cluster, "build", projConf, pkgPath);
273
- }
276
+ }*/
277
+ return await this._runCommandAsync(cluster, "build", projConf, pkgPath);
274
278
  })
275
279
  ).mapMany();
276
280
 
@@ -329,16 +333,7 @@ export class SdCliProject {
329
333
  logger.debug("빌드 프로세스 명령 전달...");
330
334
  const results = (
331
335
  await pkgPaths.parallelAsync(async (pkgPath) => {
332
- const pkgConf = projConf.packages[path.basename(pkgPath)]!;
333
- if (pkgConf.type === "client") {
334
- const builderKeys = Object.keys(pkgConf.builder ?? {web: {}});
335
- return (await builderKeys.parallelAsync(async (builderKey) => {
336
- return await this._runCommandAsync(cluster, "build", projConf, pkgPath, builderKey);
337
- })).mapMany();
338
- }
339
- else {
340
- return await this._runCommandAsync(cluster, "build", projConf, pkgPath);
341
- }
336
+ return await this._runCommandAsync(cluster, "build", projConf, pkgPath);
342
337
  })
343
338
  ).mapMany();
344
339
 
@@ -564,9 +559,9 @@ export class SdCliProject {
564
559
  });
565
560
  }
566
561
 
567
- private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch", projConf: ISdCliConfig, pkgPath: string, builderKey?: string): Promise<void>;
568
- private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "build", projConf: ISdCliConfig, pkgPath: string, builderKey?: string): Promise<ISdCliPackageBuildResult[]>;
569
- private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch" | "build", projConf: ISdCliConfig, pkgPath: string, builderKey?: string): Promise<ISdCliPackageBuildResult[] | void> {
562
+ private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch", projConf: ISdCliConfig, pkgPath: string, execArgs: string[]): Promise<void>;
563
+ private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "build", projConf: ISdCliConfig, pkgPath: string): Promise<ISdCliPackageBuildResult[]>;
564
+ private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch" | "build", projConf: ISdCliConfig, pkgPath: string, execArgs?: string[]): Promise<ISdCliPackageBuildResult[] | void> {
570
565
  return await new Promise<ISdCliPackageBuildResult[] | void>((resolve) => {
571
566
  const cb = (message: ISdCliBuildClusterResMessage): void => {
572
567
  if (cmd === "watch" && message.type === "ready" && message.req.cmd === cmd && message.req.pkgPath === pkgPath) {
@@ -584,8 +579,8 @@ export class SdCliProject {
584
579
  cmd,
585
580
  projConf,
586
581
  pkgPath,
587
- builderKey
588
- } as ISdCliBuildClusterReqMessage);
582
+ execArgs
583
+ });
589
584
  });
590
585
  }
591
586
 
@@ -654,4 +649,4 @@ export class SdCliProject {
654
649
  });
655
650
  });
656
651
  }
657
- }
652
+ }
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from "./build-tools/SdNgBundler";
6
6
  export * from "./build-tools/SdNgBundlerContext";
7
7
  export * from "./build-tools/SdServerBundler";
8
8
  export * from "./build-tools/SdTsCompiler";
9
+ export * from "./build-tools2/SdTsCompiler2";
9
10
  export * from "./builders/SdCliClientBuilder";
10
11
  export * from "./builders/SdCliJsLibLinter";
11
12
  export * from "./builders/SdCliServerBuilder";
package/src/sd-cli.ts CHANGED
@@ -57,6 +57,11 @@ const argv = (
57
57
  string: true,
58
58
  array: true,
59
59
  describe: "수행할 패키지 설정"
60
+ },
61
+ inspects: {
62
+ string: true,
63
+ array: true,
64
+ describe: "크롬 inspect를 수행할 패키지 설정"
60
65
  }
61
66
  })
62
67
  )
@@ -197,7 +202,8 @@ else if (argv._[0] === "watch") {
197
202
  .watchAsync({
198
203
  confFileRelPath: argv.config ?? "simplysm.cjs",
199
204
  optNames: argv.options ?? [],
200
- pkgNames: argv.packages ?? []
205
+ pkgNames: argv.packages ?? [],
206
+ inspectNames: argv.inspects ?? []
201
207
  });
202
208
  }
203
209
  else if (argv._[0] === "build") {
@@ -52,14 +52,14 @@ else {
52
52
 
53
53
 
54
54
  server.on("ready", () => {
55
- process.send!({port: server!.options.port});
55
+ process.send!({port: server.options.port});
56
56
  });
57
57
 
58
58
  process.on("message", (message: any) => {
59
59
  if (message.type === "setPathProxy") {
60
- server!.pathProxy = message.pathProxy;
60
+ server.pathProxy = message.pathProxy;
61
61
  }
62
62
  if (message.type === "broadcastReload") {
63
- server!.broadcastReload();
63
+ server.broadcastReload();
64
64
  }
65
65
  });
@@ -2,9 +2,10 @@ import ts from "typescript";
2
2
  import os from "os";
3
3
  import path from "path";
4
4
  import {ISdCliPackageBuildResult} from "../commons";
5
+ import {PartialMessage} from "esbuild";
5
6
 
6
7
  export class SdCliBuildResultUtil {
7
- public static convertFromTsDiag(diag: ts.Diagnostic, type: "build" | "check"): ISdCliPackageBuildResult {
8
+ static convertFromTsDiag(diag: ts.Diagnostic, type: "build" | "check"): ISdCliPackageBuildResult {
8
9
  const severity = diag.category === ts.DiagnosticCategory.Error ? "error" as const
9
10
  : diag.category === ts.DiagnosticCategory.Warning ? "warning" as const
10
11
  : diag.category === ts.DiagnosticCategory.Suggestion ? "suggestion" as const
@@ -19,7 +20,7 @@ export class SdCliBuildResultUtil {
19
20
  const char = position ? position.character + 1 : undefined;
20
21
 
21
22
  return {
22
- filePath: filePath !== undefined ? path.resolve(filePath) : undefined,
23
+ filePath,
23
24
  line,
24
25
  char,
25
26
  code,
@@ -29,7 +30,25 @@ export class SdCliBuildResultUtil {
29
30
  };
30
31
  }
31
32
 
32
- public static getMessage(result: ISdCliPackageBuildResult): string {
33
+ static convertFromEsbuildResult(msg: PartialMessage, type: "build" | "check", severity: "warning" | "error") {
34
+ const filePath = msg.location?.file != null ? path.resolve(msg.location.file) : undefined;
35
+ const line = msg.location?.line;
36
+ const char = msg.location?.column;
37
+ const code = msg.text?.slice(0, msg.text.indexOf(":"));
38
+ const message = `${msg.pluginName != null ? `(${msg.pluginName}) ` : ""} ${msg.text?.slice(msg.text.indexOf(":") + 1)}`;
39
+
40
+ return {
41
+ filePath,
42
+ line,
43
+ char,
44
+ code,
45
+ severity,
46
+ message,
47
+ type
48
+ };
49
+ }
50
+
51
+ static getMessage(result: ISdCliPackageBuildResult): string {
33
52
  let str = "";
34
53
  if (result.filePath !== undefined) {
35
54
  str += `${result.filePath}(${result.line ?? 0}, ${result.char ?? 0}): `;