@simplysm/sd-cli 14.0.11 → 14.0.13

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 (265) hide show
  1. package/README.md +58 -253
  2. package/dist/angular/client-transform-stylesheet.js +1 -1
  3. package/dist/angular/client-transform-stylesheet.js.map +1 -1
  4. package/dist/angular/vite-angular-plugin.d.ts +4 -2
  5. package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
  6. package/dist/angular/vite-angular-plugin.js +73 -36
  7. package/dist/angular/vite-angular-plugin.js.map +1 -1
  8. package/dist/angular/vite-postcss-inline-plugin.d.ts +1 -1
  9. package/dist/angular/vite-postcss-inline-plugin.js +1 -1
  10. package/dist/capacitor/capacitor.d.ts +20 -2
  11. package/dist/capacitor/capacitor.d.ts.map +1 -1
  12. package/dist/capacitor/capacitor.js +155 -28
  13. package/dist/capacitor/capacitor.js.map +1 -1
  14. package/dist/commands/build.d.ts +3 -10
  15. package/dist/commands/build.d.ts.map +1 -1
  16. package/dist/commands/build.js +3 -10
  17. package/dist/commands/build.js.map +1 -1
  18. package/dist/commands/check.js +3 -3
  19. package/dist/commands/check.js.map +1 -1
  20. package/dist/commands/dev.d.ts +3 -9
  21. package/dist/commands/dev.d.ts.map +1 -1
  22. package/dist/commands/dev.js +3 -9
  23. package/dist/commands/dev.js.map +1 -1
  24. package/dist/commands/device.d.ts +3 -3
  25. package/dist/commands/device.js +5 -5
  26. package/dist/commands/device.js.map +1 -1
  27. package/dist/commands/publish.d.ts +1 -1
  28. package/dist/commands/publish.d.ts.map +1 -1
  29. package/dist/commands/publish.js +24 -26
  30. package/dist/commands/publish.js.map +1 -1
  31. package/dist/commands/replace-deps.d.ts +3 -3
  32. package/dist/commands/replace-deps.d.ts.map +1 -1
  33. package/dist/commands/replace-deps.js +1 -1
  34. package/dist/commands/typecheck.d.ts +4 -3
  35. package/dist/commands/typecheck.d.ts.map +1 -1
  36. package/dist/commands/typecheck.js +5 -11
  37. package/dist/commands/typecheck.js.map +1 -1
  38. package/dist/commands/watch.d.ts +9 -9
  39. package/dist/commands/watch.js +9 -9
  40. package/dist/electron/electron.d.ts.map +1 -1
  41. package/dist/electron/electron.js +42 -3
  42. package/dist/electron/electron.js.map +1 -1
  43. package/dist/engines/BaseEngine.d.ts +1 -1
  44. package/dist/engines/BaseEngine.d.ts.map +1 -1
  45. package/dist/engines/BaseEngine.js +3 -1
  46. package/dist/engines/BaseEngine.js.map +1 -1
  47. package/dist/engines/NgtscEngine.d.ts +7 -7
  48. package/dist/engines/NgtscEngine.d.ts.map +1 -1
  49. package/dist/engines/NgtscEngine.js +3 -3
  50. package/dist/engines/ServerEsbuildEngine.d.ts +7 -7
  51. package/dist/engines/ServerEsbuildEngine.d.ts.map +1 -1
  52. package/dist/engines/ServerEsbuildEngine.js +3 -3
  53. package/dist/engines/TscEngine.d.ts +7 -7
  54. package/dist/engines/TscEngine.d.ts.map +1 -1
  55. package/dist/engines/TscEngine.js +3 -3
  56. package/dist/engines/ViteEngine.d.ts +7 -1
  57. package/dist/engines/ViteEngine.d.ts.map +1 -1
  58. package/dist/engines/ViteEngine.js +13 -12
  59. package/dist/engines/ViteEngine.js.map +1 -1
  60. package/dist/engines/index.d.ts +9 -5
  61. package/dist/engines/index.d.ts.map +1 -1
  62. package/dist/engines/index.js +7 -5
  63. package/dist/engines/index.js.map +1 -1
  64. package/dist/engines/types.d.ts +20 -20
  65. package/dist/engines/types.d.ts.map +1 -1
  66. package/dist/infra/ResultCollector.d.ts +9 -9
  67. package/dist/infra/ResultCollector.js +8 -8
  68. package/dist/infra/SignalHandler.d.ts +7 -7
  69. package/dist/infra/SignalHandler.js +7 -7
  70. package/dist/infra/WorkerManager.d.ts +14 -14
  71. package/dist/infra/WorkerManager.js +14 -14
  72. package/dist/orchestrators/BuildOrchestrator.d.ts +25 -25
  73. package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
  74. package/dist/orchestrators/BuildOrchestrator.js +34 -30
  75. package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
  76. package/dist/orchestrators/DevWatchOrchestrator.d.ts +7 -7
  77. package/dist/orchestrators/DevWatchOrchestrator.d.ts.map +1 -1
  78. package/dist/orchestrators/DevWatchOrchestrator.js +34 -34
  79. package/dist/orchestrators/DevWatchOrchestrator.js.map +1 -1
  80. package/dist/sd-cli-entry.d.ts +2 -2
  81. package/dist/sd-cli-entry.d.ts.map +1 -1
  82. package/dist/sd-cli-entry.js +15 -8
  83. package/dist/sd-cli-entry.js.map +1 -1
  84. package/dist/sd-cli.d.ts +3 -3
  85. package/dist/sd-cli.js +16 -16
  86. package/dist/sd-cli.js.map +1 -1
  87. package/dist/sd-config.types.d.ts +105 -105
  88. package/dist/sd-config.types.d.ts.map +1 -1
  89. package/dist/utils/angular-compiler.js +5 -5
  90. package/dist/utils/angular-compiler.js.map +1 -1
  91. package/dist/utils/build-env.d.ts +1 -1
  92. package/dist/utils/build-env.js +1 -1
  93. package/dist/utils/concurrency.d.ts +7 -7
  94. package/dist/utils/concurrency.js +7 -7
  95. package/dist/utils/copy-public.d.ts +9 -9
  96. package/dist/utils/copy-public.js +17 -17
  97. package/dist/utils/copy-public.js.map +1 -1
  98. package/dist/utils/copy-src.d.ts +9 -9
  99. package/dist/utils/copy-src.js +11 -11
  100. package/dist/utils/copy-src.js.map +1 -1
  101. package/dist/utils/engine-stop.d.ts +8 -9
  102. package/dist/utils/engine-stop.d.ts.map +1 -1
  103. package/dist/utils/engine-stop.js +9 -10
  104. package/dist/utils/engine-stop.js.map +1 -1
  105. package/dist/utils/esbuild-config.d.ts +23 -23
  106. package/dist/utils/esbuild-config.d.ts.map +1 -1
  107. package/dist/utils/esbuild-config.js +25 -25
  108. package/dist/utils/esbuild-config.js.map +1 -1
  109. package/dist/utils/lint-with-program.d.ts +15 -15
  110. package/dist/utils/lint-with-program.d.ts.map +1 -1
  111. package/dist/utils/lint-with-program.js +29 -29
  112. package/dist/utils/lint-with-program.js.map +1 -1
  113. package/dist/utils/ngtsc-build-core.d.ts +8 -8
  114. package/dist/utils/ngtsc-build-core.d.ts.map +1 -1
  115. package/dist/utils/ngtsc-build-core.js +14 -14
  116. package/dist/utils/ngtsc-build-core.js.map +1 -1
  117. package/dist/utils/output-path-rewriter.d.ts +14 -14
  118. package/dist/utils/output-path-rewriter.js +18 -18
  119. package/dist/utils/output-path-rewriter.js.map +1 -1
  120. package/dist/utils/output-utils.d.ts +6 -6
  121. package/dist/utils/output-utils.js +11 -11
  122. package/dist/utils/output-utils.js.map +1 -1
  123. package/dist/utils/package-utils.d.ts +21 -21
  124. package/dist/utils/package-utils.d.ts.map +1 -1
  125. package/dist/utils/package-utils.js +56 -45
  126. package/dist/utils/package-utils.js.map +1 -1
  127. package/dist/utils/replace-deps.d.ts +25 -25
  128. package/dist/utils/replace-deps.d.ts.map +1 -1
  129. package/dist/utils/replace-deps.js +84 -65
  130. package/dist/utils/replace-deps.js.map +1 -1
  131. package/dist/utils/sd-config.d.ts +3 -3
  132. package/dist/utils/sd-config.js +3 -3
  133. package/dist/utils/tsc-build.d.ts +13 -13
  134. package/dist/utils/tsc-build.d.ts.map +1 -1
  135. package/dist/utils/tsc-build.js +9 -9
  136. package/dist/utils/tsc-build.js.map +1 -1
  137. package/dist/utils/tsconfig.d.ts +11 -9
  138. package/dist/utils/tsconfig.d.ts.map +1 -1
  139. package/dist/utils/tsconfig.js +11 -9
  140. package/dist/utils/tsconfig.js.map +1 -1
  141. package/dist/utils/typecheck-non-package.d.ts +5 -6
  142. package/dist/utils/typecheck-non-package.d.ts.map +1 -1
  143. package/dist/utils/typecheck-non-package.js +7 -8
  144. package/dist/utils/typecheck-non-package.js.map +1 -1
  145. package/dist/utils/typecheck-serialization.d.ts +8 -8
  146. package/dist/utils/typecheck-serialization.d.ts.map +1 -1
  147. package/dist/utils/typecheck-serialization.js +12 -16
  148. package/dist/utils/typecheck-serialization.js.map +1 -1
  149. package/dist/utils/vite-config.d.ts +12 -5
  150. package/dist/utils/vite-config.d.ts.map +1 -1
  151. package/dist/utils/vite-config.js +95 -41
  152. package/dist/utils/vite-config.js.map +1 -1
  153. package/dist/utils/vite-scope-watch-plugin.d.ts.map +1 -1
  154. package/dist/utils/vite-scope-watch-plugin.js +1 -1
  155. package/dist/utils/vite-scope-watch-plugin.js.map +1 -1
  156. package/dist/utils/worker-events.d.ts +12 -12
  157. package/dist/utils/worker-events.d.ts.map +1 -1
  158. package/dist/utils/worker-events.js +10 -10
  159. package/dist/utils/worker-events.js.map +1 -1
  160. package/dist/utils/worker-utils.d.ts +12 -13
  161. package/dist/utils/worker-utils.d.ts.map +1 -1
  162. package/dist/utils/worker-utils.js +12 -13
  163. package/dist/utils/worker-utils.js.map +1 -1
  164. package/dist/vitest-plugin.d.ts.map +1 -1
  165. package/dist/vitest-plugin.js +5 -7
  166. package/dist/vitest-plugin.js.map +1 -1
  167. package/dist/workers/client.worker.d.ts +8 -2
  168. package/dist/workers/client.worker.d.ts.map +1 -1
  169. package/dist/workers/client.worker.js +215 -6
  170. package/dist/workers/client.worker.js.map +1 -1
  171. package/dist/workers/library-build.worker.d.ts +1 -1
  172. package/dist/workers/library-build.worker.d.ts.map +1 -1
  173. package/dist/workers/library-build.worker.js +7 -7
  174. package/dist/workers/library-build.worker.js.map +1 -1
  175. package/dist/workers/lint.worker.d.ts +2 -2
  176. package/dist/workers/lint.worker.js +2 -2
  177. package/dist/workers/ngtsc-build.worker.js +30 -30
  178. package/dist/workers/ngtsc-build.worker.js.map +1 -1
  179. package/dist/workers/server-build.worker.d.ts +17 -17
  180. package/dist/workers/server-build.worker.d.ts.map +1 -1
  181. package/dist/workers/server-build.worker.js +46 -46
  182. package/dist/workers/server-build.worker.js.map +1 -1
  183. package/dist/workers/server-runtime.worker.d.ts +7 -7
  184. package/dist/workers/server-runtime.worker.d.ts.map +1 -1
  185. package/dist/workers/server-runtime.worker.js +17 -17
  186. package/dist/workers/server-runtime.worker.js.map +1 -1
  187. package/docs/config.md +340 -0
  188. package/docs/publish-configuration-types.md +87 -0
  189. package/docs/pwa-configuration-types.md +55 -0
  190. package/docs/vitest-plugin.md +47 -0
  191. package/package.json +9 -7
  192. package/src/angular/client-transform-stylesheet.ts +1 -1
  193. package/src/angular/vite-angular-plugin.ts +89 -39
  194. package/src/angular/vite-postcss-inline-plugin.ts +1 -1
  195. package/src/capacitor/capacitor.ts +185 -38
  196. package/src/commands/build.ts +3 -10
  197. package/src/commands/check.ts +3 -3
  198. package/src/commands/dev.ts +3 -9
  199. package/src/commands/device.ts +5 -5
  200. package/src/commands/publish.ts +30 -26
  201. package/src/commands/replace-deps.ts +3 -3
  202. package/src/commands/typecheck.ts +7 -13
  203. package/src/commands/watch.ts +9 -9
  204. package/src/electron/electron.ts +49 -4
  205. package/src/engines/BaseEngine.ts +4 -1
  206. package/src/engines/NgtscEngine.ts +7 -7
  207. package/src/engines/ServerEsbuildEngine.ts +7 -7
  208. package/src/engines/TscEngine.ts +7 -7
  209. package/src/engines/ViteEngine.ts +18 -13
  210. package/src/engines/index.ts +11 -5
  211. package/src/engines/types.ts +20 -20
  212. package/src/infra/ResultCollector.ts +9 -9
  213. package/src/infra/SignalHandler.ts +7 -7
  214. package/src/infra/WorkerManager.ts +14 -14
  215. package/src/orchestrators/BuildOrchestrator.ts +42 -38
  216. package/src/orchestrators/DevWatchOrchestrator.ts +36 -36
  217. package/src/sd-cli-entry.ts +15 -8
  218. package/src/sd-cli.ts +16 -16
  219. package/src/sd-config.types.ts +107 -107
  220. package/src/utils/angular-compiler.ts +5 -5
  221. package/src/utils/build-env.ts +1 -1
  222. package/src/utils/concurrency.ts +7 -7
  223. package/src/utils/copy-public.ts +17 -17
  224. package/src/utils/copy-src.ts +11 -11
  225. package/src/utils/engine-stop.ts +9 -10
  226. package/src/utils/esbuild-config.ts +29 -29
  227. package/src/utils/lint-with-program.ts +34 -34
  228. package/src/utils/ngtsc-build-core.ts +17 -17
  229. package/src/utils/output-path-rewriter.ts +18 -18
  230. package/src/utils/output-utils.ts +11 -11
  231. package/src/utils/package-utils.ts +57 -45
  232. package/src/utils/replace-deps.ts +92 -67
  233. package/src/utils/sd-config.ts +3 -3
  234. package/src/utils/tsc-build.ts +18 -18
  235. package/src/utils/tsconfig.ts +11 -9
  236. package/src/utils/typecheck-non-package.ts +7 -8
  237. package/src/utils/typecheck-serialization.ts +13 -15
  238. package/src/utils/vite-config.ts +108 -46
  239. package/src/utils/vite-scope-watch-plugin.ts +6 -1
  240. package/src/utils/worker-events.ts +16 -16
  241. package/src/utils/worker-utils.ts +12 -13
  242. package/src/vitest-plugin.ts +5 -8
  243. package/src/workers/client.worker.ts +246 -7
  244. package/src/workers/library-build.worker.ts +8 -8
  245. package/src/workers/lint.worker.ts +2 -2
  246. package/src/workers/ngtsc-build.worker.ts +31 -31
  247. package/src/workers/server-build.worker.ts +60 -60
  248. package/src/workers/server-runtime.worker.ts +22 -22
  249. package/tests/angular/vite-angular-plugin-hmr-fallback.spec.ts +1 -0
  250. package/tests/angular/vite-angular-plugin-hmr.spec.ts +78 -0
  251. package/tests/angular/vite-angular-plugin.spec.ts +67 -0
  252. package/tests/capacitor/capacitor-build.spec.ts +93 -11
  253. package/tests/capacitor/capacitor-icon.spec.ts +7 -5
  254. package/tests/capacitor/capacitor-init.spec.ts +124 -10
  255. package/tests/capacitor/capacitor-run.spec.ts +14 -17
  256. package/tests/capacitor/capacitor-workspace.spec.ts +5 -3
  257. package/tests/commands/check.spec.ts +2 -2
  258. package/tests/commands/publish.spec.ts +2 -2
  259. package/tests/commands/typecheck.spec.ts +8 -0
  260. package/tests/electron/electron.spec.ts +12 -10
  261. package/tests/engines/base-engine.spec.ts +37 -0
  262. package/tests/engines/vite-engine.spec.ts +115 -3
  263. package/tests/utils/vite-config.spec.ts +162 -90
  264. package/tests/workers/client-worker.spec.ts +690 -0
  265. package/tests/workers/server-build-worker.spec.ts +3 -3
@@ -3,15 +3,15 @@ import { loadSdConfig } from "../utils/sd-config";
3
3
  import { setupReplaceDeps } from "../utils/replace-deps";
4
4
 
5
5
  /**
6
- * replace-deps command options
6
+ * replace-deps 명령어 옵션
7
7
  */
8
8
  export interface ReplaceDepsOptions {
9
- /** Additional options to pass to sd.config.ts */
9
+ /** sd.config.ts 전달할 추가 옵션 */
10
10
  options: string[];
11
11
  }
12
12
 
13
13
  /**
14
- * Replace node_modules packages with symlinks to local source based on replaceDeps config in sd.config.ts.
14
+ * sd.config.ts의 replaceDeps 설정에 따라 node_modules 패키지를 로컬 소스 심볼릭 링크로 교체한다.
15
15
  */
16
16
  export async function runReplaceDeps(opts: ReplaceDepsOptions): Promise<void> {
17
17
  const cwd = process.cwd();
@@ -2,7 +2,6 @@ import ts from "typescript";
2
2
  import { err as errNs } from "@simplysm/core-common";
3
3
  import { pathx } from "@simplysm/core-node";
4
4
  import { consola } from "consola";
5
- import type { SdConfig } from "../sd-config.types";
6
5
  import { loadSdConfig } from "../utils/sd-config";
7
6
  import { deserializeDiagnostic } from "../utils/typecheck-serialization";
8
7
  import { createBuildEngine } from "../engines/index";
@@ -35,14 +34,14 @@ export interface TypecheckResult {
35
34
  errorCount: number;
36
35
  warningCount: number;
37
36
  formattedOutput: string;
38
- /** Lint result (present when TypecheckOptions.lint is true) */
37
+ /** lint 결과 (TypecheckOptions.lint true일 때 존재) */
39
38
  lint?: {
40
39
  success: boolean;
41
40
  errorCount: number;
42
41
  warningCount: number;
43
42
  formattedOutput: string;
44
43
  };
45
- /** Paths of scripts packages that were skipped (for separate lint) */
44
+ /** 건너뛴 scripts 패키지 경로 (별도 lint) */
46
45
  scriptsPackagePaths?: string[];
47
46
  }
48
47
 
@@ -75,7 +74,8 @@ function extractTargetPackageNames(targets: string[]): Set<string> {
75
74
  *
76
75
  * sd.config.ts의 각 패키지에 대해:
77
76
  * - 라이브러리/서버 패키지 → BuildEngine.run({js:false, dts:false})
78
- * - 스크립트/클라이언트 패키지 → 제외
77
+ * - client 패키지 → browser target으로 변환하여 포함
78
+ * - scripts 패키지 → 타입체크 제외 (별도 lint만 수행)
79
79
  * 비패키지 파일 → typecheckNonPackageFiles 유틸리티
80
80
  *
81
81
  * @param options - 타입체크 실행 옵션
@@ -97,14 +97,8 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
97
97
  };
98
98
 
99
99
  // sd.config.ts 로드
100
- let sdConfig: SdConfig;
101
- try {
102
- sdConfig = await loadSdConfig({ cwd, dev: false, options: options.options });
103
- logger.debug("sd.config.ts 로드 완료");
104
- } catch {
105
- sdConfig = { packages: {} };
106
- logger.debug("sd.config.ts 로드 실패, 기본값 사용");
107
- }
100
+ const sdConfig = await loadSdConfig({ cwd, dev: false, options: options.options });
101
+ logger.debug("sd.config.ts 로드 완료");
108
102
 
109
103
  // 워크스페이스 패키지 탐색 및 tests/를 설정에 병합
110
104
  const workspacePackages = discoverWorkspacePackages(cwd);
@@ -278,7 +272,7 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
278
272
  formattedOutput = ts.formatDiagnosticsWithColorAndContext(uniqueDiagnostics, formatHost);
279
273
  }
280
274
 
281
- // Build lint result if lint was requested
275
+ // lint 요청된 경우 lint 결과 생성
282
276
  const lintResult = options.lint === true
283
277
  ? {
284
278
  success: lintSuccess,
@@ -4,17 +4,17 @@ import {
4
4
  } from "../orchestrators/DevWatchOrchestrator";
5
5
 
6
6
  /**
7
- * Build all packages in watch mode.
7
+ * DevWatchOrchestrator를 통해 모든 패키지를 watch 모드로 빌드한다.
8
8
  *
9
- * - Load `sd.config.ts` to check build target info per package (required)
10
- * - `node`/`browser`/`neutral` target: build in esbuild watch mode + generate .d.ts
11
- * - `server` target: build in esbuild watch mode (no runtime)
12
- * - `scripts` target with watch config: run hook on file changes
13
- * - Auto rebuild on file changes
14
- * - Terminate with SIGINT/SIGTERM signals
9
+ * - `sd.config.ts`를 로드하여 패키지별 빌드 대상 정보를 확인한다
10
+ * - `node`/`browser`/`neutral` target: esbuild watch 모드 빌드 + .d.ts 생성
11
+ * - `server` target: esbuild watch 모드 빌드 (런타임 없음)
12
+ * - `scripts` target (watch 설정 있을 때): 파일 변경 hook 실행
13
+ * - 파일 변경 자동 재빌드
14
+ * - SIGINT/SIGTERM 시그널로 종료
15
15
  *
16
- * @param options - watch execution options (targets, options)
17
- * @returns resolves on termination signal
16
+ * @param options - watch 실행 옵션 (targets, options)
17
+ * @returns 종료 시그널 수신 시 resolve
18
18
  */
19
19
  export async function runWatch(options: Omit<DevWatchOrchestratorOptions, "mode">): Promise<void> {
20
20
  const orchestrator = new DevWatchOrchestrator({ mode: "watch", ...options });
@@ -2,7 +2,7 @@ import os from "os";
2
2
  import fs from "fs";
3
3
  import module from "module";
4
4
  import { cpx, fsx, pathx } from "@simplysm/core-node";
5
- import { consola } from "consola";
5
+ import { consola, LogLevels } from "consola";
6
6
  import type { SdElectronConfig } from "../sd-config.types.js";
7
7
  import { createEnvBanner } from "../utils/esbuild-config.js";
8
8
 
@@ -55,7 +55,13 @@ export class Electron {
55
55
  env?: Record<string, string>,
56
56
  ): Promise<string> {
57
57
  Electron._logger.debug(`실행: ${cmd} ${args.join(" ")}`);
58
- const { stdout: result } = await cpx.exec(cmd, args, { cwd, env, shell: true });
58
+ const isDebug = consola.level >= LogLevels.debug;
59
+ const { stdout: result } = await cpx.spawn(cmd, args, {
60
+ cwd,
61
+ env,
62
+ shell: true,
63
+ ...(isDebug ? { stdio: "inherit" } : {}),
64
+ });
59
65
  Electron._logger.debug(`결과: ${result}`);
60
66
  return result;
61
67
  }
@@ -63,18 +69,28 @@ export class Electron {
63
69
  //#region Public Methods
64
70
 
65
71
  async initialize(): Promise<void> {
72
+ Electron._logger.debug("initialize 시작");
66
73
  const srcPath = pathx.posixResolve(this._electronPath, "src");
67
74
 
75
+ Electron._logger.debug("package.json 설정 시작");
68
76
  await this._setupPackageJson(srcPath);
77
+ Electron._logger.debug("package.json 설정 완료");
78
+
79
+ Electron._logger.debug("npm install 시작");
69
80
  await this._exec("npm", ["install"], srcPath);
81
+ Electron._logger.debug("npm install 완료");
70
82
 
71
83
  const reinstallDeps = this._config.reinstallDependencies ?? [];
72
84
  if (reinstallDeps.length > 0) {
85
+ Electron._logger.debug(`electron-rebuild 시작 (${reinstallDeps.join(", ")})`);
73
86
  await this._exec(this._localBin("electron-rebuild"), [], srcPath);
87
+ Electron._logger.debug("electron-rebuild 완료");
74
88
  }
89
+ Electron._logger.debug("initialize 완료");
75
90
  }
76
91
 
77
92
  async run(url: string): Promise<void> {
93
+ Electron._logger.debug(`run 시작 (url: ${url})`);
78
94
  const srcPath = pathx.posixResolve(this._electronPath, "src");
79
95
 
80
96
  await this.initialize();
@@ -90,12 +106,13 @@ export class Electron {
90
106
  const reinstallDeps = this._config.reinstallDependencies ?? [];
91
107
  await fsx.mkdir(srcPath);
92
108
 
93
- let currentElectron: cpx.ExecProcess | null = null;
109
+ let currentElectron: cpx.SpawnProcess | null = null;
94
110
  let isRestarting = false;
95
111
  let resolveTermination: (() => void) | null = null;
96
112
 
97
113
  const spawnElectron = () => {
98
- currentElectron = cpx.exec(this._localBin("electron"), ["."], {
114
+ Electron._logger.debug("Electron 프로세스 시작");
115
+ currentElectron = cpx.spawn(this._localBin("electron"), ["."], {
99
116
  cwd: srcPath,
100
117
  stdio: "inherit",
101
118
  reject: false,
@@ -112,6 +129,7 @@ export class Electron {
112
129
 
113
130
  const envBanner = createEnvBanner({ ELECTRON_DEV_URL: url, ...this._config.env });
114
131
 
132
+ Electron._logger.debug("esbuild context 생성 시작");
115
133
  const ctx = await esbuild.context({
116
134
  entryPoints: [entryPoint],
117
135
  outfile: pathx.posixResolve(srcPath, "electron-main.js"),
@@ -131,8 +149,11 @@ export class Electron {
131
149
  return;
132
150
  }
133
151
 
152
+ Electron._logger.debug("esbuild 번들링 완료");
153
+
134
154
  if (currentElectron != null) {
135
155
  isRestarting = true;
156
+ Electron._logger.debug("기존 Electron 프로세스 종료 시작");
136
157
  currentElectron.kill();
137
158
  try {
138
159
  await currentElectron;
@@ -149,8 +170,11 @@ export class Electron {
149
170
  },
150
171
  ],
151
172
  });
173
+ Electron._logger.debug("esbuild context 생성 완료");
152
174
 
175
+ Electron._logger.debug("esbuild watch 시작");
153
176
  await ctx.watch();
177
+ Electron._logger.debug("esbuild watch 시작 완료, 종료 대기 중");
154
178
 
155
179
  await new Promise<void>((resolve) => {
156
180
  let disposed = false;
@@ -158,6 +182,7 @@ export class Electron {
158
182
  const cleanup = () => {
159
183
  if (disposed) return;
160
184
  disposed = true;
185
+ Electron._logger.debug("cleanup 시작");
161
186
  process.removeListener("SIGINT", signalHandler);
162
187
  process.removeListener("SIGTERM", signalHandler);
163
188
  void ctx.dispose();
@@ -167,6 +192,7 @@ export class Electron {
167
192
  resolveTermination = cleanup;
168
193
 
169
194
  const signalHandler = () => {
195
+ Electron._logger.debug("시그널 수신, Electron 종료 중");
170
196
  if (currentElectron != null) currentElectron.kill();
171
197
  cleanup();
172
198
  };
@@ -174,15 +200,30 @@ export class Electron {
174
200
  process.once("SIGINT", signalHandler);
175
201
  process.once("SIGTERM", signalHandler);
176
202
  });
203
+ Electron._logger.debug("run 완료");
177
204
  }
178
205
 
179
206
  async build(outPath: string): Promise<void> {
207
+ Electron._logger.debug("build 시작");
180
208
  const srcPath = pathx.posixResolve(this._electronPath, "src");
181
209
 
210
+ Electron._logger.debug("메인 프로세스 번들링 시작");
182
211
  await this._bundleMainProcess(srcPath);
212
+ Electron._logger.debug("메인 프로세스 번들링 완료");
213
+
214
+ Electron._logger.debug("웹 에셋 복사 시작");
183
215
  await this._copyWebAssets(outPath, srcPath);
216
+ Electron._logger.debug("웹 에셋 복사 완료");
217
+
218
+ Electron._logger.debug("electron-builder 실행 시작");
184
219
  await this._runElectronBuilder(srcPath);
220
+ Electron._logger.debug("electron-builder 실행 완료");
221
+
222
+ Electron._logger.debug("빌드 산출물 복사 시작");
185
223
  await this._copyBuildOutput(outPath);
224
+ Electron._logger.debug("빌드 산출물 복사 완료");
225
+
226
+ Electron._logger.debug("build 완료");
186
227
  }
187
228
 
188
229
  //#endregion
@@ -245,6 +286,7 @@ export class Electron {
245
286
 
246
287
  const envBanner = createEnvBanner(this._config.env);
247
288
 
289
+ Electron._logger.debug(`esbuild 번들링: ${entryPoint}`);
248
290
  await esbuild.build({
249
291
  entryPoints: [entryPoint],
250
292
  outfile: pathx.posixResolve(outDir, "electron-main.js"),
@@ -322,6 +364,7 @@ export class Electron {
322
364
  const configFilePath = pathx.posixResolve(this._electronPath, "builder-config.json");
323
365
  await fsx.writeJson(configFilePath, builderConfig, { space: 2 });
324
366
 
367
+ Electron._logger.debug(`electron-builder 설정: ${configFilePath}`);
325
368
  await this._exec(
326
369
  this._localBin("electron-builder"),
327
370
  ["--win", "--config", configFilePath],
@@ -340,6 +383,7 @@ export class Electron {
340
383
  const isPortable = this._config.portable === true;
341
384
 
342
385
  // exe 파일 동적 탐색 — Setup 또는 portable exe를 우선 선택
386
+ Electron._logger.debug(`빌드 산출물 탐색: ${distPath}`);
343
387
  const allExeFiles = await fsx.glob(pathx.posixResolve(distPath, "*.exe"));
344
388
  if (allExeFiles.length === 0) {
345
389
  Electron._logger.warn(`빌드 산출물(.exe)을 찾을 수 없습니다: ${distPath}`);
@@ -348,6 +392,7 @@ export class Electron {
348
392
  const keyword = isPortable ? "portable" : "Setup";
349
393
  const sourcePath =
350
394
  allExeFiles.find((f) => f.toLowerCase().includes(keyword.toLowerCase())) ?? allExeFiles[0];
395
+ Electron._logger.debug(`빌드 산출물: ${sourcePath}`);
351
396
 
352
397
  const latestFileName = `${safeName}${isPortable ? "-portable" : ""}-latest.exe`;
353
398
  await fsx.copy(sourcePath, pathx.posixResolve(electronOutPath, latestFileName));
@@ -53,7 +53,7 @@ export interface BaseEngineOptions<TPkg extends PackageInfo> {
53
53
  * 이벤트 처리)이 여기에 위치하며, 서브클래스는 추상 메서드를 통해
54
54
  * 워커 경로, 빌드/워치 호출 파라미터, 타겟 결정을 제공한다.
55
55
  *
56
- * ViteEngine은 이 계층에 포함되지 않음 — 워커 이벤트 구조가 다름.
56
+ * ViteEngine은 이 계층에 포함되지 않음 — serverReady 이벤트, port 관리 등 생명주기가 다름.
57
57
  */
58
58
  export abstract class BaseEngine<
59
59
  TPkg extends PackageInfo,
@@ -189,6 +189,9 @@ export abstract class BaseEngine<
189
189
  };
190
190
  this._resultCollector?.add(result);
191
191
 
192
+ resolver?.();
193
+ resolver = undefined;
194
+
192
195
  // 에러 경로: 항상 resolve (reject하지 않음) — 호출자가 ResultCollector에서 상태를 확인
193
196
  if (isInitialBuild) {
194
197
  isInitialBuild = false;
@@ -8,24 +8,24 @@ import { consola } from "consola";
8
8
  const logger = consola.withTag("sd:cli:engine:ngtsc");
9
9
 
10
10
  /**
11
- * NgtscEngine options
11
+ * NgtscEngine 옵션
12
12
  */
13
13
  export interface NgtscEngineOptions {
14
14
  cwd: string;
15
15
  pkg: BuildPackageInfo;
16
- /** replaceDeps configuration from sd.config.ts */
16
+ /** sd.config.ts replaceDeps 설정 */
17
17
  replaceDeps?: Record<string, string>;
18
- /** ResultCollector for watch mode rebuild reporting */
18
+ /** 워치 모드 리빌드 보고용 ResultCollector */
19
19
  resultCollector?: ResultCollector;
20
- /** RebuildManager for watch mode batch coordination */
20
+ /** 워치 모드 배치 조정용 RebuildManager */
21
21
  rebuildManager?: RebuildManager;
22
22
  }
23
23
 
24
24
  /**
25
- * NgtscProgram-based build engine for Angular Library packages
25
+ * NgtscProgram 기반 Angular 라이브러리 패키지용 빌드 엔진
26
26
  *
27
- * Wraps a single ngtsc-build.worker that uses NgtscProgram for AOT compilation.
28
- * Angular packages are detected by the presence of angularCompilerOptions in tsconfig.json.
27
+ * NgtscProgram을 사용하여 AOT 컴파일을 수행하는 ngtsc-build.worker 래핑한다.
28
+ * package.json에 @angular/core 의존성이 있는 Angular 패키지용.
29
29
  */
30
30
  export class NgtscEngine extends BaseEngine<
31
31
  BuildPackageInfo,
@@ -8,24 +8,24 @@ import { consola } from "consola";
8
8
  const logger = consola.withTag("sd:cli:engine:server");
9
9
 
10
10
  /**
11
- * ServerEsbuildEngine options
11
+ * ServerEsbuildEngine 옵션
12
12
  */
13
13
  export interface ServerEsbuildEngineOptions {
14
14
  cwd: string;
15
15
  pkg: ServerPackageInfo;
16
- /** replaceDeps configuration from sd.config.ts */
16
+ /** sd.config.ts replaceDeps 설정 */
17
17
  replaceDeps?: Record<string, string>;
18
- /** ResultCollector for watch mode rebuild reporting */
18
+ /** 워치 모드 리빌드 보고용 ResultCollector */
19
19
  resultCollector?: ResultCollector;
20
- /** RebuildManager for watch mode batch coordination */
20
+ /** 워치 모드 배치 조정용 RebuildManager */
21
21
  rebuildManager?: RebuildManager;
22
22
  }
23
23
 
24
24
  /**
25
- * Esbuild-based build engine for Server packages
25
+ * esbuild 기반 서버 패키지용 빌드 엔진
26
26
  *
27
- * Wraps a single server-build.worker that combines esbuild (JS bundle)
28
- * + tsc (typecheck) in one Worker thread.
27
+ * esbuild(JS 번들) + tsc(타입체크)를 하나의 Worker 스레드에서 결합하는
28
+ * server-build.worker를 래핑한다.
29
29
  */
30
30
  export class ServerEsbuildEngine extends BaseEngine<
31
31
  ServerPackageInfo,
@@ -8,24 +8,24 @@ import { consola } from "consola";
8
8
  const logger = consola.withTag("sd:cli:engine:tsc");
9
9
 
10
10
  /**
11
- * TscEngine options
11
+ * TscEngine 옵션
12
12
  */
13
13
  export interface TscEngineOptions {
14
14
  cwd: string;
15
15
  pkg: BuildPackageInfo;
16
- /** replaceDeps configuration from sd.config.ts */
16
+ /** sd.config.ts replaceDeps 설정 */
17
17
  replaceDeps?: Record<string, string>;
18
- /** ResultCollector for watch mode rebuild reporting */
18
+ /** 워치 모드 리빌드 보고용 ResultCollector */
19
19
  resultCollector?: ResultCollector;
20
- /** RebuildManager for watch mode batch coordination */
20
+ /** 워치 모드 배치 조정용 RebuildManager */
21
21
  rebuildManager?: RebuildManager;
22
22
  }
23
23
 
24
24
  /**
25
- * tsc-based build engine for Library packages (node/browser/neutral)
25
+ * tsc 기반 라이브러리 패키지(node/browser/neutral)용 빌드 엔진
26
26
  *
27
- * Wraps a single library-build.worker that uses tsc for JS + DTS emit
28
- * in one Worker thread.
27
+ * tsc 사용하여 JS + DTS emit하는 library-build.worker를
28
+ * 하나의 Worker 스레드에서 래핑한다.
29
29
  */
30
30
  export class TscEngine extends BaseEngine<
31
31
  BuildPackageInfo,
@@ -20,6 +20,10 @@ export interface ViteEngineOptions {
20
20
  rebuildManager?: RebuildManager;
21
21
  /** sdScopeWatchPlugin용 replaceDeps 항목 */
22
22
  replaceDeps?: Array<{ packageName: string; sourcePath: string }>;
23
+ /** 빌드 출력 경로 (미설정 시 pkgDir/dist) */
24
+ outDir?: string;
25
+ /** Vite base 경로 (미설정 시 /{pkgName}/) */
26
+ base?: string;
23
27
  }
24
28
 
25
29
  /**
@@ -34,6 +38,8 @@ export class ViteEngine implements BuildEngine {
34
38
  private readonly _resultCollector: ResultCollector | undefined;
35
39
  private readonly _rebuildManager: RebuildManager | undefined;
36
40
  private readonly _replaceDeps: Array<{ packageName: string; sourcePath: string }> | undefined;
41
+ private readonly _outDir: string | undefined;
42
+ private readonly _base: string | undefined;
37
43
 
38
44
  private _worker: WorkerProxy<typeof ClientWorkerModule> | undefined;
39
45
  private _isWatchMode = false;
@@ -47,6 +53,8 @@ export class ViteEngine implements BuildEngine {
47
53
  this._resultCollector = options.resultCollector;
48
54
  this._rebuildManager = options.rebuildManager;
49
55
  this._replaceDeps = options.replaceDeps;
56
+ this._outDir = options.outDir;
57
+ this._base = options.base;
50
58
  }
51
59
 
52
60
  /**
@@ -64,6 +72,9 @@ export class ViteEngine implements BuildEngine {
64
72
  configs: this._pkg.config.configs,
65
73
  browserSupport: this._pkg.config.browserSupport,
66
74
  enableLint: output.lint,
75
+ exclude: this._pkg.config.exclude,
76
+ outDir: this._outDir,
77
+ base: this._base,
67
78
  });
68
79
 
69
80
  logger.debug(`[${this._pkg.name}] ViteEngine.run 완료 (success: ${result.success})`);
@@ -81,7 +92,7 @@ export class ViteEngine implements BuildEngine {
81
92
 
82
93
  /**
83
94
  * 워치 모드 시작 (Vite 개발 서버)
84
- * 개발 서버가 준비되면 Promise가 resolve된다.
95
+ * worker의 startWatch()가 완료되면 Promise가 resolve된다.
85
96
  */
86
97
  async startWatch(output: BuildOutput): Promise<void> {
87
98
  logger.debug(`[${this._pkg.name}] ViteEngine.startWatch 시작`);
@@ -94,7 +105,7 @@ export class ViteEngine implements BuildEngine {
94
105
  this.port = event.port;
95
106
  });
96
107
 
97
- // 리빌드 이벤트 처리 (Feature 3.3 HMR)
108
+ // 리빌드 이벤트 처리 (HMR)
98
109
  let resolver: (() => void) | undefined;
99
110
  const workerKey = `vite:${this._pkg.name}`;
100
111
 
@@ -152,6 +163,9 @@ export class ViteEngine implements BuildEngine {
152
163
  message: event.message,
153
164
  };
154
165
  this._resultCollector?.add(buildResult);
166
+
167
+ resolver?.();
168
+ resolver = undefined;
155
169
  });
156
170
 
157
171
  const port =
@@ -159,7 +173,7 @@ export class ViteEngine implements BuildEngine {
159
173
  ? this._pkg.config.server
160
174
  : undefined;
161
175
 
162
- const result = await this._worker!.startWatch({
176
+ await this._worker!.startWatch({
163
177
  name: this._pkg.name,
164
178
  cwd: this._cwd,
165
179
  pkgDir: this._pkg.dir,
@@ -169,17 +183,8 @@ export class ViteEngine implements BuildEngine {
169
183
  replaceDeps: this._replaceDeps,
170
184
  browserSupport: this._pkg.config.browserSupport,
171
185
  enableLint: output.lint,
186
+ exclude: this._pkg.config.exclude,
172
187
  });
173
-
174
- // 초기 빌드 결과 보고
175
- const buildResult: BuildResult = {
176
- name: this._pkg.name,
177
- target: "client",
178
- type: "build",
179
- status: result.success ? "success" : "error",
180
- message: result.errors?.join("\n"),
181
- };
182
- this._resultCollector?.add(buildResult);
183
188
  }
184
189
 
185
190
  /**
@@ -23,12 +23,12 @@ export type { ViteEngineOptions } from "./ViteEngine";
23
23
  export type { BuildEngine, BuildOutput, BuildPackageInfo, ClientPackageInfo, EngineResult, PackageInfo, ServerPackageInfo } from "./types";
24
24
 
25
25
  /**
26
- * Create a BuildEngine for the given package.
26
+ * 주어진 패키지에 맞는 BuildEngine 생성한다.
27
27
  *
28
- * Client packages use ViteEngine (Angular buildApplicationInternal / serveWithVite).
29
- * Server packages use ServerEsbuildEngine.
30
- * Angular Library packages (detected by @angular/core in package.json) use NgtscEngine.
31
- * Other Library packages (node/browser/neutral) use TscEngine.
28
+ * 클라이언트 패키지는 ViteEngine 사용한다.
29
+ * 서버 패키지는 ServerEsbuildEngine을 사용한다.
30
+ * Angular 라이브러리 패키지(package.json에 @angular/core 의존성 감지) NgtscEngine을 사용한다.
31
+ * 기타 라이브러리 패키지(node/browser/neutral) TscEngine을 사용한다.
32
32
  */
33
33
  export function createBuildEngine(
34
34
  pkg: BuildPackageInfo | ServerPackageInfo | ClientPackageInfo,
@@ -38,6 +38,10 @@ export function createBuildEngine(
38
38
  resolvedReplaceDeps?: Array<{ packageName: string; sourcePath: string }>;
39
39
  resultCollector?: ResultCollector;
40
40
  rebuildManager?: RebuildManager;
41
+ /** 클라이언트 빌드 출력 경로 (ViteEngine에만 적용) */
42
+ outDir?: string;
43
+ /** Vite base 경로 (ViteEngine에만 적용, 미설정 시 /{pkgName}/) */
44
+ base?: string;
41
45
  },
42
46
  ): BuildEngine {
43
47
  if (pkg.config.target === "client") {
@@ -48,6 +52,8 @@ export function createBuildEngine(
48
52
  resultCollector: options.resultCollector,
49
53
  rebuildManager: options.rebuildManager,
50
54
  replaceDeps: options.resolvedReplaceDeps,
55
+ outDir: options.outDir,
56
+ base: options.base,
51
57
  });
52
58
  }
53
59
 
@@ -4,7 +4,7 @@ import type { TypecheckEnv } from "../utils/tsconfig";
4
4
  import type { LintWithProgramResult } from "../utils/lint-with-program";
5
5
 
6
6
  /**
7
- * Package information
7
+ * 패키지 정보
8
8
  */
9
9
  export interface PackageInfo {
10
10
  name: string;
@@ -13,36 +13,36 @@ export interface PackageInfo {
13
13
  }
14
14
 
15
15
  /**
16
- * PackageInfo narrowed for build packages (node/browser/neutral)
16
+ * 빌드 패키지(node/browser/neutral)로 좁혀진 PackageInfo
17
17
  */
18
18
  export type BuildPackageInfo = PackageInfo & { config: SdBuildPackageConfig };
19
19
 
20
20
  /**
21
- * PackageInfo narrowed for server packages
21
+ * 서버 패키지로 좁혀진 PackageInfo
22
22
  */
23
23
  export type ServerPackageInfo = PackageInfo & { config: SdServerPackageConfig };
24
24
 
25
25
  /**
26
- * PackageInfo narrowed for client packages
26
+ * 클라이언트 패키지로 좁혀진 PackageInfo
27
27
  */
28
28
  export type ClientPackageInfo = PackageInfo & { config: SdClientPackageConfig };
29
29
 
30
30
  /**
31
- * Build output control flags
31
+ * 빌드 출력 제어 플래그
32
32
  */
33
33
  export interface BuildOutput {
34
34
  js: boolean;
35
35
  dts: boolean;
36
- /** When true, run ESLint using the ts.Program created during typecheck. */
36
+ /** true 때, 타입체크 생성된 ts.Program으로 ESLint를 실행한다. */
37
37
  lint?: boolean;
38
- /** Typecheck environment. When set, adjusts compilerOptions via getCompilerOptionsForEnv(). */
38
+ /** 타입체크 환경. 설정 getCompilerOptionsForEnv()를 통해 compilerOptions 조정한다. */
39
39
  env?: TypecheckEnv;
40
- /** Include tests/ files in typecheck scope. Only used by check command. */
40
+ /** 타입체크 범위에 tests/ 파일을 포함한다. check 커맨드에서만 사용된다. */
41
41
  includeTests?: boolean;
42
42
  }
43
43
 
44
44
  /**
45
- * BuildEngine.run() return value
45
+ * BuildEngine.run() 반환값
46
46
  */
47
47
  export interface EngineResult {
48
48
  success: boolean;
@@ -52,33 +52,33 @@ export interface EngineResult {
52
52
  warnings: string[];
53
53
  diagnostics: SerializedDiagnostic[];
54
54
  };
55
- /** Lint result (present when BuildOutput.lint is true) */
55
+ /** 린트 결과 (BuildOutput.lint true일 때 존재) */
56
56
  lint?: LintWithProgramResult;
57
57
  }
58
58
 
59
59
  /**
60
- * Build engine interface
60
+ * 빌드 엔진 인터페이스
61
61
  *
62
- * Common contract for all build engines.
63
- * typecheck (diagnostics) is always included — not optional.
62
+ * 모든 빌드 엔진의 공통 계약.
63
+ * 타입체크(diagnostics) 항상 포함되며 선택사항이 아니다.
64
64
  */
65
65
  export interface BuildEngine {
66
66
  /**
67
- * One-time build (for production builds)
68
- * Creates workers, runs build, returns combined result.
69
- * Call stop() after to clean up resources.
67
+ * 일회성 빌드 (프로덕션)
68
+ * Worker를 생성하고, 빌드를 실행하고, 결합된 결과를 반환한다.
69
+ * 호출 stop()으로 리소스를 정리한다.
70
70
  */
71
71
  run(output: BuildOutput): Promise<EngineResult>;
72
72
 
73
73
  /**
74
- * Start watch mode
75
- * Promise resolves when initial build is complete.
76
- * Subsequent rebuilds are reported via injected ResultCollector.
74
+ * 워치 모드 시작
75
+ * 초기 빌드가 완료되면 Promise가 resolve된다.
76
+ * 이후 리빌드는 주입된 ResultCollector를 통해 보고된다.
77
77
  */
78
78
  startWatch(output: BuildOutput): Promise<void>;
79
79
 
80
80
  /**
81
- * Stop engine and clean up resources (workers, esbuild contexts)
81
+ * 엔진을 중지하고 리소스(Worker, esbuild context 등)를 정리한다
82
82
  */
83
83
  stop(): Promise<void>;
84
84
  }