@simplysm/sd-cli 14.0.29 → 14.0.32

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 (626) hide show
  1. package/dist/{utils → angular}/angular-build-pipeline.d.ts +0 -2
  2. package/dist/angular/angular-build-pipeline.d.ts.map +1 -0
  3. package/dist/{utils → angular}/angular-build-pipeline.js +3 -6
  4. package/dist/angular/angular-build-pipeline.js.map +1 -0
  5. package/dist/{utils → angular}/angular-build.d.ts +1 -1
  6. package/dist/angular/angular-build.d.ts.map +1 -0
  7. package/dist/{utils → angular}/angular-build.js +1 -1
  8. package/dist/angular/angular-build.js.map +1 -0
  9. package/dist/{utils → angular}/angular-compiler.d.ts +0 -3
  10. package/dist/angular/angular-compiler.d.ts.map +1 -0
  11. package/dist/{utils → angular}/angular-compiler.js +1 -45
  12. package/dist/angular/angular-compiler.js.map +1 -0
  13. package/dist/angular/client-transform-stylesheet.js +1 -1
  14. package/dist/angular/client-transform-stylesheet.js.map +1 -1
  15. package/dist/{utils → angular}/ngtsc-build-core.d.ts +3 -3
  16. package/dist/angular/ngtsc-build-core.d.ts.map +1 -0
  17. package/dist/angular/ngtsc-build-core.js.map +1 -0
  18. package/dist/angular/scss-compiler.d.ts.map +1 -0
  19. package/dist/angular/scss-compiler.js.map +1 -0
  20. package/dist/angular/vite-angular-plugin.d.ts +2 -10
  21. package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
  22. package/dist/angular/vite-angular-plugin.js +20 -286
  23. package/dist/angular/vite-angular-plugin.js.map +1 -1
  24. package/dist/capacitor/capacitor-build.d.ts +14 -0
  25. package/dist/capacitor/capacitor-build.d.ts.map +1 -0
  26. package/dist/capacitor/capacitor-build.js +105 -0
  27. package/dist/capacitor/capacitor-build.js.map +1 -0
  28. package/dist/capacitor/capacitor-config-writer.d.ts +11 -0
  29. package/dist/capacitor/capacitor-config-writer.d.ts.map +1 -0
  30. package/dist/capacitor/capacitor-config-writer.js +54 -0
  31. package/dist/capacitor/capacitor-config-writer.js.map +1 -0
  32. package/dist/capacitor/capacitor-icon.d.ts +5 -0
  33. package/dist/capacitor/capacitor-icon.d.ts.map +1 -0
  34. package/dist/capacitor/capacitor-icon.js +58 -0
  35. package/dist/capacitor/capacitor-icon.js.map +1 -0
  36. package/dist/capacitor/capacitor-npm-config.d.ts +11 -0
  37. package/dist/capacitor/capacitor-npm-config.d.ts.map +1 -0
  38. package/dist/capacitor/capacitor-npm-config.js +145 -0
  39. package/dist/capacitor/capacitor-npm-config.js.map +1 -0
  40. package/dist/capacitor/capacitor.d.ts +0 -45
  41. package/dist/capacitor/capacitor.d.ts.map +1 -1
  42. package/dist/capacitor/capacitor.js +15 -354
  43. package/dist/capacitor/capacitor.js.map +1 -1
  44. package/dist/commands/check.js +2 -2
  45. package/dist/commands/check.js.map +1 -1
  46. package/dist/commands/dev.d.ts +3 -3
  47. package/dist/commands/dev.d.ts.map +1 -1
  48. package/dist/commands/dev.js +3 -3
  49. package/dist/commands/dev.js.map +1 -1
  50. package/dist/commands/lint.d.ts +1 -1
  51. package/dist/commands/lint.d.ts.map +1 -1
  52. package/dist/commands/lint.js +1 -1
  53. package/dist/commands/lint.js.map +1 -1
  54. package/dist/commands/publish/deployment-phase.d.ts +12 -0
  55. package/dist/commands/publish/deployment-phase.d.ts.map +1 -0
  56. package/dist/commands/publish/deployment-phase.js +94 -0
  57. package/dist/commands/publish/deployment-phase.js.map +1 -0
  58. package/dist/commands/publish/env-utils.d.ts +10 -0
  59. package/dist/commands/publish/env-utils.d.ts.map +1 -0
  60. package/dist/commands/publish/env-utils.js +41 -0
  61. package/dist/commands/publish/env-utils.js.map +1 -0
  62. package/dist/commands/publish/git-phase.d.ts +12 -0
  63. package/dist/commands/publish/git-phase.d.ts.map +1 -0
  64. package/dist/commands/publish/git-phase.js +79 -0
  65. package/dist/commands/publish/git-phase.js.map +1 -0
  66. package/dist/commands/{publish.d.ts → publish/index.d.ts} +1 -1
  67. package/dist/commands/publish/index.d.ts.map +1 -0
  68. package/dist/commands/publish/index.js +211 -0
  69. package/dist/commands/publish/index.js.map +1 -0
  70. package/dist/commands/publish/local-publisher.d.ts +6 -0
  71. package/dist/commands/publish/local-publisher.d.ts.map +1 -0
  72. package/dist/commands/publish/local-publisher.js +16 -0
  73. package/dist/commands/publish/local-publisher.js.map +1 -0
  74. package/dist/commands/publish/npm-publisher.d.ts +6 -0
  75. package/dist/commands/publish/npm-publisher.d.ts.map +1 -0
  76. package/dist/commands/publish/npm-publisher.js +21 -0
  77. package/dist/commands/publish/npm-publisher.js.map +1 -0
  78. package/dist/commands/publish/post-publish-phase.d.ts +8 -0
  79. package/dist/commands/publish/post-publish-phase.d.ts.map +1 -0
  80. package/dist/commands/publish/post-publish-phase.js +34 -0
  81. package/dist/commands/publish/post-publish-phase.js.map +1 -0
  82. package/dist/commands/publish/storage-publisher.d.ts +18 -0
  83. package/dist/commands/publish/storage-publisher.d.ts.map +1 -0
  84. package/dist/commands/publish/storage-publisher.js +173 -0
  85. package/dist/commands/publish/storage-publisher.js.map +1 -0
  86. package/dist/commands/publish/version-upgrade.d.ts +28 -0
  87. package/dist/commands/publish/version-upgrade.d.ts.map +1 -0
  88. package/dist/commands/publish/version-upgrade.js +96 -0
  89. package/dist/commands/publish/version-upgrade.js.map +1 -0
  90. package/dist/commands/replace-deps.js +1 -1
  91. package/dist/commands/replace-deps.js.map +1 -1
  92. package/dist/commands/watch.d.ts +3 -4
  93. package/dist/commands/watch.d.ts.map +1 -1
  94. package/dist/commands/watch.js +3 -4
  95. package/dist/commands/watch.js.map +1 -1
  96. package/dist/deps/replace-deps/collect-deps.d.ts +6 -0
  97. package/dist/deps/replace-deps/collect-deps.d.ts.map +1 -0
  98. package/dist/deps/replace-deps/collect-deps.js +71 -0
  99. package/dist/deps/replace-deps/collect-deps.js.map +1 -0
  100. package/dist/{utils/replace-deps.d.ts → deps/replace-deps/replace-deps-resolve.d.ts} +7 -24
  101. package/dist/deps/replace-deps/replace-deps-resolve.d.ts.map +1 -0
  102. package/dist/{utils/replace-deps.js → deps/replace-deps/replace-deps-resolve.js} +4 -152
  103. package/dist/deps/replace-deps/replace-deps-resolve.js.map +1 -0
  104. package/dist/deps/replace-deps/replace-deps.d.ts +36 -0
  105. package/dist/deps/replace-deps/replace-deps.d.ts.map +1 -0
  106. package/dist/deps/replace-deps/replace-deps.js +155 -0
  107. package/dist/deps/replace-deps/replace-deps.js.map +1 -0
  108. package/dist/{utils → deps/server-externals}/server-production-files.d.ts +1 -1
  109. package/dist/deps/server-externals/server-production-files.d.ts.map +1 -0
  110. package/dist/{utils → deps/server-externals}/server-production-files.js +1 -1
  111. package/dist/deps/server-externals/server-production-files.js.map +1 -0
  112. package/dist/dev-server/dev-http-server.d.ts +23 -0
  113. package/dist/dev-server/dev-http-server.d.ts.map +1 -0
  114. package/dist/dev-server/dev-http-server.js +116 -0
  115. package/dist/dev-server/dev-http-server.js.map +1 -0
  116. package/dist/dev-server/hmr-client-script.d.ts +13 -0
  117. package/dist/dev-server/hmr-client-script.d.ts.map +1 -0
  118. package/dist/dev-server/hmr-client-script.js +73 -0
  119. package/dist/dev-server/hmr-client-script.js.map +1 -0
  120. package/dist/dev-server/hmr-service.d.ts +23 -0
  121. package/dist/dev-server/hmr-service.d.ts.map +1 -0
  122. package/dist/dev-server/hmr-service.js +139 -0
  123. package/dist/dev-server/hmr-service.js.map +1 -0
  124. package/dist/electron/electron.d.ts +5 -0
  125. package/dist/electron/electron.d.ts.map +1 -1
  126. package/dist/electron/electron.js +17 -24
  127. package/dist/electron/electron.js.map +1 -1
  128. package/dist/engines/BaseEngine.d.ts +18 -4
  129. package/dist/engines/BaseEngine.d.ts.map +1 -1
  130. package/dist/engines/BaseEngine.js +45 -66
  131. package/dist/engines/BaseEngine.js.map +1 -1
  132. package/dist/engines/{ViteEngine.d.ts → EsbuildClientEngine.d.ts} +11 -18
  133. package/dist/engines/EsbuildClientEngine.d.ts.map +1 -0
  134. package/dist/engines/{ViteEngine.js → EsbuildClientEngine.js} +28 -55
  135. package/dist/engines/EsbuildClientEngine.js.map +1 -0
  136. package/dist/engines/NgtscEngine.d.ts +2 -2
  137. package/dist/engines/NgtscEngine.d.ts.map +1 -1
  138. package/dist/engines/NgtscEngine.js +1 -9
  139. package/dist/engines/NgtscEngine.js.map +1 -1
  140. package/dist/engines/ServerEsbuildEngine.d.ts +2 -2
  141. package/dist/engines/ServerEsbuildEngine.d.ts.map +1 -1
  142. package/dist/engines/ServerEsbuildEngine.js +1 -9
  143. package/dist/engines/ServerEsbuildEngine.js.map +1 -1
  144. package/dist/engines/TscEngine.d.ts +2 -2
  145. package/dist/engines/TscEngine.d.ts.map +1 -1
  146. package/dist/engines/TscEngine.js +1 -9
  147. package/dist/engines/TscEngine.js.map +1 -1
  148. package/dist/engines/index.d.ts +15 -5
  149. package/dist/engines/index.d.ts.map +1 -1
  150. package/dist/engines/index.js +21 -5
  151. package/dist/engines/index.js.map +1 -1
  152. package/dist/engines/types.d.ts +3 -3
  153. package/dist/engines/types.d.ts.map +1 -1
  154. package/dist/esbuild/esbuild-client-config.d.ts +38 -0
  155. package/dist/esbuild/esbuild-client-config.d.ts.map +1 -0
  156. package/dist/esbuild/esbuild-client-config.js +171 -0
  157. package/dist/esbuild/esbuild-client-config.js.map +1 -0
  158. package/dist/esbuild/esbuild-config.d.ts.map +1 -0
  159. package/dist/{utils → esbuild}/esbuild-config.js +1 -0
  160. package/dist/esbuild/esbuild-config.js.map +1 -0
  161. package/dist/esbuild/esbuild-index-html.d.ts +39 -0
  162. package/dist/esbuild/esbuild-index-html.d.ts.map +1 -0
  163. package/dist/esbuild/esbuild-index-html.js +68 -0
  164. package/dist/esbuild/esbuild-index-html.js.map +1 -0
  165. package/dist/esbuild/esbuild-pwa.d.ts +21 -0
  166. package/dist/esbuild/esbuild-pwa.d.ts.map +1 -0
  167. package/dist/esbuild/esbuild-pwa.js +105 -0
  168. package/dist/esbuild/esbuild-pwa.js.map +1 -0
  169. package/dist/esbuild/esbuild-scss-plugin.d.ts +6 -0
  170. package/dist/esbuild/esbuild-scss-plugin.d.ts.map +1 -0
  171. package/dist/esbuild/esbuild-scss-plugin.js +41 -0
  172. package/dist/esbuild/esbuild-scss-plugin.js.map +1 -0
  173. package/dist/lint/lint-core.d.ts.map +1 -0
  174. package/dist/lint/lint-core.js.map +1 -0
  175. package/dist/lint/lint-utils.d.ts.map +1 -0
  176. package/dist/lint/lint-utils.js.map +1 -0
  177. package/dist/lint/lint-with-program.d.ts.map +1 -0
  178. package/dist/lint/lint-with-program.js.map +1 -0
  179. package/dist/orchestrators/BaseOrchestrator.d.ts +44 -0
  180. package/dist/orchestrators/BaseOrchestrator.d.ts.map +1 -0
  181. package/dist/orchestrators/BaseOrchestrator.js +92 -0
  182. package/dist/orchestrators/BaseOrchestrator.js.map +1 -0
  183. package/dist/orchestrators/BuildOrchestrator.d.ts +45 -3
  184. package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
  185. package/dist/orchestrators/BuildOrchestrator.js +170 -143
  186. package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
  187. package/dist/orchestrators/DevOrchestrator.d.ts +39 -0
  188. package/dist/orchestrators/DevOrchestrator.d.ts.map +1 -0
  189. package/dist/orchestrators/DevOrchestrator.js +249 -0
  190. package/dist/orchestrators/DevOrchestrator.js.map +1 -0
  191. package/dist/orchestrators/ServerRuntimeManager.d.ts +22 -0
  192. package/dist/orchestrators/ServerRuntimeManager.d.ts.map +1 -0
  193. package/dist/orchestrators/ServerRuntimeManager.js +66 -0
  194. package/dist/orchestrators/ServerRuntimeManager.js.map +1 -0
  195. package/dist/orchestrators/TypecheckOrchestrator.d.ts +17 -2
  196. package/dist/orchestrators/TypecheckOrchestrator.d.ts.map +1 -1
  197. package/dist/orchestrators/TypecheckOrchestrator.js +122 -108
  198. package/dist/orchestrators/TypecheckOrchestrator.js.map +1 -1
  199. package/dist/orchestrators/WatchOrchestrator.d.ts +33 -0
  200. package/dist/orchestrators/WatchOrchestrator.d.ts.map +1 -0
  201. package/dist/orchestrators/WatchOrchestrator.js +158 -0
  202. package/dist/orchestrators/WatchOrchestrator.js.map +1 -0
  203. package/dist/orchestrators/types.d.ts +17 -0
  204. package/dist/orchestrators/types.d.ts.map +1 -0
  205. package/dist/orchestrators/types.js +2 -0
  206. package/dist/orchestrators/types.js.map +1 -0
  207. package/dist/runtime/ResultCollector.d.ts.map +1 -0
  208. package/dist/runtime/ResultCollector.js.map +1 -0
  209. package/dist/runtime/SignalHandler.d.ts.map +1 -0
  210. package/dist/runtime/SignalHandler.js.map +1 -0
  211. package/dist/{utils → runtime}/engine-stop.d.ts +1 -1
  212. package/dist/runtime/engine-stop.d.ts.map +1 -0
  213. package/dist/{utils → runtime}/engine-stop.js +1 -1
  214. package/dist/runtime/engine-stop.js.map +1 -0
  215. package/dist/runtime/engine-watch-events.d.ts +43 -0
  216. package/dist/runtime/engine-watch-events.d.ts.map +1 -0
  217. package/dist/runtime/engine-watch-events.js +72 -0
  218. package/dist/runtime/engine-watch-events.js.map +1 -0
  219. package/dist/{utils → runtime}/rebuild-manager.d.ts +1 -0
  220. package/dist/runtime/rebuild-manager.d.ts.map +1 -0
  221. package/dist/{utils → runtime}/rebuild-manager.js +8 -1
  222. package/dist/runtime/rebuild-manager.js.map +1 -0
  223. package/dist/runtime/worker-events.d.ts +22 -0
  224. package/dist/runtime/worker-events.d.ts.map +1 -0
  225. package/dist/runtime/worker-events.js +2 -0
  226. package/dist/runtime/worker-events.js.map +1 -0
  227. package/dist/runtime/worker-utils.d.ts.map +1 -0
  228. package/dist/runtime/worker-utils.js.map +1 -0
  229. package/dist/sd-cli-entry.d.ts.map +1 -1
  230. package/dist/sd-cli-entry.js +61 -54
  231. package/dist/sd-cli-entry.js.map +1 -1
  232. package/dist/sd-cli.js +1 -1
  233. package/dist/sd-cli.js.map +1 -1
  234. package/dist/sd-config.types.d.ts +6 -15
  235. package/dist/sd-config.types.d.ts.map +1 -1
  236. package/dist/typecheck/typecheck-non-package.d.ts.map +1 -0
  237. package/dist/{utils → typecheck}/typecheck-non-package.js +1 -1
  238. package/dist/typecheck/typecheck-non-package.js.map +1 -0
  239. package/dist/typecheck/typecheck-serialization.d.ts.map +1 -0
  240. package/dist/typecheck/typecheck-serialization.js.map +1 -0
  241. package/dist/utils/diagnostic-utils.d.ts +5 -0
  242. package/dist/utils/diagnostic-utils.d.ts.map +1 -1
  243. package/dist/utils/diagnostic-utils.js +15 -0
  244. package/dist/utils/diagnostic-utils.js.map +1 -1
  245. package/dist/utils/orchestrator-utils.d.ts +1 -5
  246. package/dist/utils/orchestrator-utils.d.ts.map +1 -1
  247. package/dist/utils/orchestrator-utils.js +2 -5
  248. package/dist/utils/orchestrator-utils.js.map +1 -1
  249. package/dist/utils/output-utils.d.ts +1 -1
  250. package/dist/utils/output-utils.d.ts.map +1 -1
  251. package/dist/utils/package-classify.d.ts +54 -0
  252. package/dist/utils/package-classify.d.ts.map +1 -0
  253. package/dist/utils/package-classify.js +134 -0
  254. package/dist/utils/package-classify.js.map +1 -0
  255. package/dist/utils/package-utils.d.ts +1 -58
  256. package/dist/utils/package-utils.d.ts.map +1 -1
  257. package/dist/utils/package-utils.js +0 -193
  258. package/dist/utils/package-utils.js.map +1 -1
  259. package/dist/utils/tsc-build.d.ts +1 -1
  260. package/dist/utils/tsc-build.d.ts.map +1 -1
  261. package/dist/utils/tsc-build.js +1 -1
  262. package/dist/utils/tsc-build.js.map +1 -1
  263. package/dist/workers/build-change-filter.d.ts +8 -0
  264. package/dist/workers/build-change-filter.d.ts.map +1 -0
  265. package/dist/workers/build-change-filter.js +16 -0
  266. package/dist/workers/build-change-filter.js.map +1 -0
  267. package/dist/workers/build-watch-paths.d.ts +20 -0
  268. package/dist/workers/build-watch-paths.d.ts.map +1 -0
  269. package/dist/workers/build-watch-paths.js +29 -0
  270. package/dist/workers/build-watch-paths.js.map +1 -0
  271. package/dist/workers/client.worker.d.ts +11 -18
  272. package/dist/workers/client.worker.d.ts.map +1 -1
  273. package/dist/workers/client.worker.js +218 -289
  274. package/dist/workers/client.worker.js.map +1 -1
  275. package/dist/workers/library-build.worker.d.ts +2 -2
  276. package/dist/workers/library-build.worker.d.ts.map +1 -1
  277. package/dist/workers/library-build.worker.js +13 -24
  278. package/dist/workers/library-build.worker.js.map +1 -1
  279. package/dist/workers/lint.worker.d.ts +1 -1
  280. package/dist/workers/lint.worker.d.ts.map +1 -1
  281. package/dist/workers/lint.worker.js +1 -1
  282. package/dist/workers/lint.worker.js.map +1 -1
  283. package/dist/workers/ngtsc-build.worker.d.ts +1 -1
  284. package/dist/workers/ngtsc-build.worker.d.ts.map +1 -1
  285. package/dist/workers/ngtsc-build.worker.js +19 -35
  286. package/dist/workers/ngtsc-build.worker.js.map +1 -1
  287. package/dist/workers/server-build.worker.d.ts +2 -2
  288. package/dist/workers/server-build.worker.d.ts.map +1 -1
  289. package/dist/workers/server-build.worker.js +36 -137
  290. package/dist/workers/server-build.worker.js.map +1 -1
  291. package/dist/workers/server-esbuild-context.d.ts +47 -0
  292. package/dist/workers/server-esbuild-context.d.ts.map +1 -0
  293. package/dist/workers/server-esbuild-context.js +92 -0
  294. package/dist/workers/server-esbuild-context.js.map +1 -0
  295. package/dist/workers/server-runtime.worker.d.ts.map +1 -1
  296. package/dist/workers/server-runtime.worker.js +3 -1
  297. package/dist/workers/server-runtime.worker.js.map +1 -1
  298. package/dist/workers/server-watch-manager.d.ts +44 -0
  299. package/dist/workers/server-watch-manager.d.ts.map +1 -0
  300. package/dist/workers/server-watch-manager.js +87 -0
  301. package/dist/workers/server-watch-manager.js.map +1 -0
  302. package/dist/workers/shared-worker-lifecycle.d.ts +14 -0
  303. package/dist/workers/shared-worker-lifecycle.d.ts.map +1 -0
  304. package/dist/workers/shared-worker-lifecycle.js +17 -0
  305. package/dist/workers/shared-worker-lifecycle.js.map +1 -0
  306. package/package.json +9 -9
  307. package/src/{utils → angular}/angular-build-pipeline.ts +3 -8
  308. package/src/{utils → angular}/angular-build.ts +1 -1
  309. package/src/{utils → angular}/angular-compiler.ts +1 -64
  310. package/src/angular/client-transform-stylesheet.ts +1 -1
  311. package/src/{utils → angular}/ngtsc-build-core.ts +3 -3
  312. package/src/angular/vite-angular-plugin.ts +22 -355
  313. package/src/capacitor/capacitor-build.ts +142 -0
  314. package/src/capacitor/capacitor-config-writer.ts +66 -0
  315. package/src/capacitor/capacitor-icon.ts +75 -0
  316. package/src/capacitor/capacitor-npm-config.ts +192 -0
  317. package/src/capacitor/capacitor.ts +32 -441
  318. package/src/commands/check.ts +2 -2
  319. package/src/commands/dev.ts +6 -6
  320. package/src/commands/lint.ts +1 -1
  321. package/src/commands/publish/deployment-phase.ts +125 -0
  322. package/src/commands/publish/env-utils.ts +44 -0
  323. package/src/commands/publish/git-phase.ts +99 -0
  324. package/src/commands/publish/index.ts +266 -0
  325. package/src/commands/publish/local-publisher.ts +23 -0
  326. package/src/commands/publish/npm-publisher.ts +30 -0
  327. package/src/commands/publish/post-publish-phase.ts +43 -0
  328. package/src/commands/publish/storage-publisher.ts +208 -0
  329. package/src/commands/publish/version-upgrade.ts +132 -0
  330. package/src/commands/replace-deps.ts +1 -1
  331. package/src/commands/watch.ts +6 -7
  332. package/src/deps/replace-deps/collect-deps.ts +92 -0
  333. package/src/{utils/replace-deps.ts → deps/replace-deps/replace-deps-resolve.ts} +4 -188
  334. package/src/deps/replace-deps/replace-deps.ts +193 -0
  335. package/src/{utils → deps/server-externals}/server-production-files.ts +2 -2
  336. package/src/dev-server/dev-http-server.ts +149 -0
  337. package/src/dev-server/hmr-client-script.ts +74 -0
  338. package/src/dev-server/hmr-service.ts +178 -0
  339. package/src/electron/electron.ts +21 -28
  340. package/src/engines/BaseEngine.ts +64 -83
  341. package/src/engines/{ViteEngine.ts → EsbuildClientEngine.ts} +33 -72
  342. package/src/engines/NgtscEngine.ts +3 -11
  343. package/src/engines/ServerEsbuildEngine.ts +3 -11
  344. package/src/engines/TscEngine.ts +3 -11
  345. package/src/engines/index.ts +29 -9
  346. package/src/engines/types.ts +3 -3
  347. package/src/esbuild/esbuild-client-config.ts +230 -0
  348. package/src/{utils → esbuild}/esbuild-config.ts +1 -0
  349. package/src/esbuild/esbuild-index-html.ts +119 -0
  350. package/src/esbuild/esbuild-pwa.ts +139 -0
  351. package/src/esbuild/esbuild-scss-plugin.ts +48 -0
  352. package/src/orchestrators/BaseOrchestrator.ts +118 -0
  353. package/src/orchestrators/BuildOrchestrator.ts +234 -171
  354. package/src/orchestrators/DevOrchestrator.ts +315 -0
  355. package/src/orchestrators/ServerRuntimeManager.ts +85 -0
  356. package/src/orchestrators/TypecheckOrchestrator.ts +166 -117
  357. package/src/orchestrators/WatchOrchestrator.ts +203 -0
  358. package/src/orchestrators/types.ts +18 -0
  359. package/src/{utils → runtime}/engine-stop.ts +1 -1
  360. package/src/runtime/engine-watch-events.ts +121 -0
  361. package/src/{utils → runtime}/rebuild-manager.ts +8 -1
  362. package/src/runtime/worker-events.ts +25 -0
  363. package/src/sd-cli-entry.ts +69 -54
  364. package/src/sd-cli.ts +1 -1
  365. package/src/sd-config.types.ts +6 -16
  366. package/src/{utils → typecheck}/typecheck-non-package.ts +1 -1
  367. package/src/utils/diagnostic-utils.ts +15 -0
  368. package/src/utils/orchestrator-utils.ts +2 -6
  369. package/src/utils/output-utils.ts +1 -1
  370. package/src/utils/package-classify.ts +182 -0
  371. package/src/utils/package-utils.ts +0 -257
  372. package/src/utils/tsc-build.ts +1 -1
  373. package/src/workers/build-change-filter.ts +27 -0
  374. package/src/workers/build-watch-paths.ts +54 -0
  375. package/src/workers/client.worker.ts +258 -328
  376. package/src/workers/library-build.worker.ts +15 -34
  377. package/src/workers/lint.worker.ts +1 -1
  378. package/src/workers/ngtsc-build.worker.ts +19 -46
  379. package/src/workers/server-build.worker.ts +38 -168
  380. package/src/workers/server-esbuild-context.ts +122 -0
  381. package/src/workers/server-runtime.worker.ts +4 -1
  382. package/src/workers/server-watch-manager.ts +124 -0
  383. package/src/workers/shared-worker-lifecycle.ts +24 -0
  384. package/tests/angular/angular-build-pipeline.spec.ts +2 -2
  385. package/tests/angular/angular-compiler-aot.acc.spec.ts +68 -0
  386. package/tests/angular/angular-compiler-aot.spec.ts +80 -0
  387. package/tests/angular/angular-compiler-hmr-removal.verify.md +16 -0
  388. package/tests/angular/vite-angular-plugin-legacy-watch.spec.ts +0 -17
  389. package/tests/angular/vite-angular-plugin-vitest.spec.ts +1 -6
  390. package/tests/angular/vite-angular-plugin-vitest.verify.md +20 -0
  391. package/tests/angular/vite-angular-plugin.spec.ts +4 -178
  392. package/tests/capacitor/capacitor-android.spec.ts +1 -0
  393. package/tests/capacitor/capacitor-build.spec.ts +1 -0
  394. package/tests/capacitor/capacitor-config-writer.acc.spec.ts +108 -0
  395. package/tests/capacitor/capacitor-config-writer.spec.ts +95 -0
  396. package/tests/capacitor/capacitor-icon.spec.ts +1 -0
  397. package/tests/capacitor/capacitor-init.spec.ts +1 -0
  398. package/tests/capacitor/capacitor-npm-config.acc.spec.ts +236 -0
  399. package/tests/capacitor/capacitor-npm-config.spec.ts +132 -0
  400. package/tests/capacitor/capacitor-run.spec.ts +1 -0
  401. package/tests/capacitor/capacitor-workspace.spec.ts +1 -0
  402. package/tests/commands/check.spec.ts +2 -2
  403. package/tests/commands/deployment-phase.acc.spec.ts +142 -0
  404. package/tests/commands/git-phase.acc.spec.ts +158 -0
  405. package/tests/commands/lint.spec.ts +1 -1
  406. package/tests/commands/post-publish-phase.acc.spec.ts +82 -0
  407. package/tests/commands/publish-npm-local-split.verify.md +9 -0
  408. package/tests/commands/publish-responsibility-split.verify.md +13 -0
  409. package/tests/commands/publish-storage-split.verify.md +8 -0
  410. package/tests/commands/publish.spec.ts +1 -1
  411. package/tests/commands/typecheck.spec.ts +18 -18
  412. package/tests/deps/deps-directory-separation.verify.md +15 -0
  413. package/tests/engines/base-engine.spec.ts +65 -6
  414. package/tests/engines/engine-adapter-isolation.spec.ts +11 -18
  415. package/tests/engines/engine-selection.spec.ts +38 -5
  416. package/tests/engines/engine-typecheck-selection.acc.spec.ts +85 -0
  417. package/tests/engines/engine-typecheck-selection.verify.md +8 -0
  418. package/tests/engines/esbuild-client-engine.acc.spec.ts +161 -0
  419. package/tests/engines/esbuild-client-engine.spec.ts +320 -0
  420. package/tests/engines/esbuild-client-engine.verify.md +15 -0
  421. package/tests/engines/normalize-result.verify.md +9 -0
  422. package/tests/engines/vite-dependency-cleanup.verify.md +24 -0
  423. package/tests/orchestrators/build-orchestrator.spec.ts +3 -3
  424. package/tests/orchestrators/dev-orchestrator.spec.ts +799 -0
  425. package/tests/orchestrators/orchestrator-baseenv.verify.md +10 -0
  426. package/tests/orchestrators/orchestrator-diagnostic-formatting.verify.md +10 -0
  427. package/tests/orchestrators/orchestrator-initializemode-signature.verify.md +9 -0
  428. package/tests/orchestrators/typecheck-orchestrator.spec.ts +11 -11
  429. package/tests/orchestrators/watch-orchestrator.spec.ts +511 -0
  430. package/tests/{infra → runtime}/result-collector.spec.ts +1 -1
  431. package/tests/{infra → runtime}/signal-handler.spec.ts +1 -1
  432. package/tests/sd-cli-entry.spec.ts +9 -0
  433. package/tests/utils/angular-build.spec.ts +15 -20
  434. package/tests/utils/angular-compiler-emit.spec.ts +2 -2
  435. package/tests/utils/angular-compiler.spec.ts +2 -2
  436. package/tests/utils/angular-source-file-cache.spec.ts +2 -2
  437. package/tests/utils/concurrency.spec.ts +2 -10
  438. package/tests/utils/dev-http-server.acc.spec.ts +206 -0
  439. package/tests/utils/dev-http-server.spec.ts +181 -0
  440. package/tests/utils/dev-http-server.verify.md +8 -0
  441. package/tests/utils/diagnostic-utils.spec.ts +42 -1
  442. package/tests/utils/engine-stop.spec.ts +1 -1
  443. package/tests/utils/engine-watch-events.acc.spec.ts +217 -0
  444. package/tests/utils/engine-watch-events.spec.ts +141 -0
  445. package/tests/utils/engine-watch-events.verify.md +17 -0
  446. package/tests/utils/esbuild-client-config.acc.spec.ts +443 -0
  447. package/tests/utils/esbuild-client-config.spec.ts +590 -0
  448. package/tests/utils/esbuild-client-config.verify.md +26 -0
  449. package/tests/utils/esbuild-config.spec.ts +11 -1
  450. package/tests/utils/esbuild-index-html.acc.spec.ts +166 -0
  451. package/tests/utils/esbuild-index-html.spec.ts +194 -0
  452. package/tests/utils/esbuild-index-html.verify.md +10 -0
  453. package/tests/utils/esbuild-pwa.acc.spec.ts +203 -0
  454. package/tests/utils/esbuild-pwa.spec.ts +189 -0
  455. package/tests/utils/esbuild-pwa.verify.md +9 -0
  456. package/tests/utils/esbuild-scss-plugin.acc.spec.ts +111 -0
  457. package/tests/utils/esbuild-scss-plugin.spec.ts +150 -0
  458. package/tests/utils/esbuild-scss-plugin.verify.md +8 -0
  459. package/tests/utils/external-modules.spec.ts +1 -1
  460. package/tests/utils/hmr-client-script.acc.spec.ts +128 -0
  461. package/tests/utils/hmr-client-script.spec.ts +44 -0
  462. package/tests/utils/hmr-service-dispatcher.acc.spec.ts +217 -0
  463. package/tests/utils/hmr-service-dispatcher.spec.ts +143 -0
  464. package/tests/utils/hmr-service.acc.spec.ts +139 -0
  465. package/tests/utils/hmr-service.spec.ts +131 -0
  466. package/tests/utils/hmr-service.verify.md +17 -0
  467. package/tests/utils/lint-core.spec.ts +2 -1
  468. package/tests/utils/lint-utils.spec.ts +1 -1
  469. package/tests/utils/lint-with-program.spec.ts +1 -1
  470. package/tests/utils/ngtsc-build-core-write-emit.spec.ts +19 -19
  471. package/tests/utils/ngtsc-build-core.spec.ts +4 -4
  472. package/tests/utils/orchestrator-utils.spec.ts +2 -2
  473. package/tests/utils/output-utils.spec.ts +1 -1
  474. package/tests/utils/package-utils.spec.ts +1 -1
  475. package/tests/utils/rebuild-manager.spec.ts +20 -7
  476. package/tests/utils/replace-deps-split.verify.md +15 -0
  477. package/tests/utils/replace-deps-watch.acc.spec.ts +131 -0
  478. package/tests/utils/replace-deps-watch.spec.ts +91 -0
  479. package/tests/utils/replace-deps-watch.verify.md +9 -0
  480. package/tests/utils/replace-deps.spec.ts +1 -1
  481. package/tests/utils/scss-compiler.spec.ts +1 -1
  482. package/tests/utils/tsc-build.spec.ts +1 -1
  483. package/tests/utils/typecheck-non-package.spec.ts +2 -2
  484. package/tests/utils/worker-utils.spec.ts +2 -1
  485. package/tests/workers/build-change-filter.acc.spec.ts +78 -0
  486. package/tests/workers/build-change-filter.spec.ts +39 -0
  487. package/tests/workers/build-watch-paths-library.verify.md +10 -0
  488. package/tests/workers/build-watch-paths-ngtsc-server.verify.md +12 -0
  489. package/tests/workers/build-watch-paths.acc.spec.ts +101 -0
  490. package/tests/workers/build-watch-paths.spec.ts +121 -0
  491. package/tests/workers/client-worker-browser-support.verify.md +7 -0
  492. package/tests/workers/client-worker-onend-sync.verify.md +7 -0
  493. package/tests/workers/client-worker.acc.spec.ts +185 -0
  494. package/tests/workers/client-worker.spec.ts +91 -178
  495. package/tests/workers/library-build-lint.spec.ts +3 -3
  496. package/tests/workers/library-build-worker.spec.ts +10 -11
  497. package/tests/workers/ngtsc-build-lint.spec.ts +4 -4
  498. package/tests/workers/ngtsc-build-worker.spec.ts +2 -2
  499. package/tests/workers/server-build-lint.spec.ts +4 -4
  500. package/tests/workers/server-build-worker.spec.ts +14 -15
  501. package/tests/workers/server-esbuild-context-integration.verify.md +10 -0
  502. package/tests/workers/server-esbuild-context.acc.spec.ts +98 -0
  503. package/tests/workers/server-esbuild-context.spec.ts +198 -0
  504. package/tests/workers/server-runtime-worker.spec.ts +4 -3
  505. package/tests/workers/server-watch-manager.acc.spec.ts +162 -0
  506. package/tests/workers/server-watch-manager.spec.ts +199 -0
  507. package/tests/workers/shared-worker-lifecycle.acc.spec.ts +27 -0
  508. package/tests/workers/shared-worker-lifecycle.spec.ts +47 -0
  509. package/dist/angular/vite-postcss-inline-plugin.d.ts +0 -18
  510. package/dist/angular/vite-postcss-inline-plugin.d.ts.map +0 -1
  511. package/dist/angular/vite-postcss-inline-plugin.js +0 -108
  512. package/dist/angular/vite-postcss-inline-plugin.js.map +0 -1
  513. package/dist/commands/publish.d.ts.map +0 -1
  514. package/dist/commands/publish.js +0 -689
  515. package/dist/commands/publish.js.map +0 -1
  516. package/dist/engines/ViteEngine.d.ts.map +0 -1
  517. package/dist/engines/ViteEngine.js.map +0 -1
  518. package/dist/infra/ResultCollector.d.ts.map +0 -1
  519. package/dist/infra/ResultCollector.js.map +0 -1
  520. package/dist/infra/SignalHandler.d.ts.map +0 -1
  521. package/dist/infra/SignalHandler.js.map +0 -1
  522. package/dist/orchestrators/DevWatchOrchestrator.d.ts +0 -63
  523. package/dist/orchestrators/DevWatchOrchestrator.d.ts.map +0 -1
  524. package/dist/orchestrators/DevWatchOrchestrator.js +0 -478
  525. package/dist/orchestrators/DevWatchOrchestrator.js.map +0 -1
  526. package/dist/utils/angular-build-pipeline.d.ts.map +0 -1
  527. package/dist/utils/angular-build-pipeline.js.map +0 -1
  528. package/dist/utils/angular-build.d.ts.map +0 -1
  529. package/dist/utils/angular-build.js.map +0 -1
  530. package/dist/utils/angular-compiler.d.ts.map +0 -1
  531. package/dist/utils/angular-compiler.js.map +0 -1
  532. package/dist/utils/engine-stop.d.ts.map +0 -1
  533. package/dist/utils/engine-stop.js.map +0 -1
  534. package/dist/utils/esbuild-config.d.ts.map +0 -1
  535. package/dist/utils/esbuild-config.js.map +0 -1
  536. package/dist/utils/hmr-candidates.d.ts +0 -15
  537. package/dist/utils/hmr-candidates.d.ts.map +0 -1
  538. package/dist/utils/hmr-candidates.js +0 -234
  539. package/dist/utils/hmr-candidates.js.map +0 -1
  540. package/dist/utils/lint-core.d.ts.map +0 -1
  541. package/dist/utils/lint-core.js.map +0 -1
  542. package/dist/utils/lint-utils.d.ts.map +0 -1
  543. package/dist/utils/lint-utils.js.map +0 -1
  544. package/dist/utils/lint-with-program.d.ts.map +0 -1
  545. package/dist/utils/lint-with-program.js.map +0 -1
  546. package/dist/utils/ngtsc-build-core.d.ts.map +0 -1
  547. package/dist/utils/ngtsc-build-core.js.map +0 -1
  548. package/dist/utils/rebuild-manager.d.ts.map +0 -1
  549. package/dist/utils/rebuild-manager.js.map +0 -1
  550. package/dist/utils/replace-deps.d.ts.map +0 -1
  551. package/dist/utils/replace-deps.js.map +0 -1
  552. package/dist/utils/scss-compiler.d.ts.map +0 -1
  553. package/dist/utils/scss-compiler.js.map +0 -1
  554. package/dist/utils/server-production-files.d.ts.map +0 -1
  555. package/dist/utils/server-production-files.js.map +0 -1
  556. package/dist/utils/typecheck-non-package.d.ts.map +0 -1
  557. package/dist/utils/typecheck-non-package.js.map +0 -1
  558. package/dist/utils/typecheck-serialization.d.ts.map +0 -1
  559. package/dist/utils/typecheck-serialization.js.map +0 -1
  560. package/dist/utils/vite-config.d.ts +0 -50
  561. package/dist/utils/vite-config.d.ts.map +0 -1
  562. package/dist/utils/vite-config.js +0 -242
  563. package/dist/utils/vite-config.js.map +0 -1
  564. package/dist/utils/vite-pwa-plugin.d.ts +0 -9
  565. package/dist/utils/vite-pwa-plugin.d.ts.map +0 -1
  566. package/dist/utils/vite-pwa-plugin.js +0 -139
  567. package/dist/utils/vite-pwa-plugin.js.map +0 -1
  568. package/dist/utils/vite-scope-watch-plugin.d.ts +0 -24
  569. package/dist/utils/vite-scope-watch-plugin.d.ts.map +0 -1
  570. package/dist/utils/vite-scope-watch-plugin.js +0 -51
  571. package/dist/utils/vite-scope-watch-plugin.js.map +0 -1
  572. package/dist/utils/worker-events.d.ts +0 -66
  573. package/dist/utils/worker-events.d.ts.map +0 -1
  574. package/dist/utils/worker-events.js +0 -55
  575. package/dist/utils/worker-events.js.map +0 -1
  576. package/dist/utils/worker-utils.d.ts.map +0 -1
  577. package/dist/utils/worker-utils.js.map +0 -1
  578. package/src/angular/vite-postcss-inline-plugin.ts +0 -139
  579. package/src/commands/publish.ts +0 -850
  580. package/src/orchestrators/DevWatchOrchestrator.ts +0 -594
  581. package/src/utils/hmr-candidates.ts +0 -327
  582. package/src/utils/vite-config.ts +0 -318
  583. package/src/utils/vite-pwa-plugin.ts +0 -168
  584. package/src/utils/vite-scope-watch-plugin.ts +0 -77
  585. package/src/utils/worker-events.ts +0 -128
  586. package/tests/angular/angular-compiler-hmr.spec.ts +0 -152
  587. package/tests/angular/hmr-candidates.spec.ts +0 -158
  588. package/tests/angular/linker-disk-cache.spec.ts +0 -171
  589. package/tests/angular/vite-angular-plugin-hmr-fallback.spec.ts +0 -333
  590. package/tests/angular/vite-angular-plugin-hmr.spec.ts +0 -320
  591. package/tests/angular/vite-angular-plugin-scss-hmr.spec.ts +0 -95
  592. package/tests/angular/vite-postcss-inline-plugin.spec.ts +0 -60
  593. package/tests/engines/vite-engine.spec.ts +0 -409
  594. package/tests/orchestrators/dev-watch-orchestrator.spec.ts +0 -1542
  595. package/tests/utils/vite-config.spec.ts +0 -780
  596. package/tests/utils/vite-pwa-plugin.spec.ts +0 -401
  597. package/tests/utils/vite-scope-watch-plugin.spec.ts +0 -218
  598. package/tests/utils/worker-events.spec.ts +0 -147
  599. package/tests/workers/client-worker-legacy.spec.ts +0 -659
  600. /package/dist/{utils → angular}/ngtsc-build-core.js +0 -0
  601. /package/dist/{utils → angular}/scss-compiler.d.ts +0 -0
  602. /package/dist/{utils → angular}/scss-compiler.js +0 -0
  603. /package/dist/{utils → esbuild}/esbuild-config.d.ts +0 -0
  604. /package/dist/{utils → lint}/lint-core.d.ts +0 -0
  605. /package/dist/{utils → lint}/lint-core.js +0 -0
  606. /package/dist/{utils → lint}/lint-utils.d.ts +0 -0
  607. /package/dist/{utils → lint}/lint-utils.js +0 -0
  608. /package/dist/{utils → lint}/lint-with-program.d.ts +0 -0
  609. /package/dist/{utils → lint}/lint-with-program.js +0 -0
  610. /package/dist/{infra → runtime}/ResultCollector.d.ts +0 -0
  611. /package/dist/{infra → runtime}/ResultCollector.js +0 -0
  612. /package/dist/{infra → runtime}/SignalHandler.d.ts +0 -0
  613. /package/dist/{infra → runtime}/SignalHandler.js +0 -0
  614. /package/dist/{utils → runtime}/worker-utils.d.ts +0 -0
  615. /package/dist/{utils → runtime}/worker-utils.js +0 -0
  616. /package/dist/{utils → typecheck}/typecheck-non-package.d.ts +0 -0
  617. /package/dist/{utils → typecheck}/typecheck-serialization.d.ts +0 -0
  618. /package/dist/{utils → typecheck}/typecheck-serialization.js +0 -0
  619. /package/src/{utils → angular}/scss-compiler.ts +0 -0
  620. /package/src/{utils → lint}/lint-core.ts +0 -0
  621. /package/src/{utils → lint}/lint-utils.ts +0 -0
  622. /package/src/{utils → lint}/lint-with-program.ts +0 -0
  623. /package/src/{infra → runtime}/ResultCollector.ts +0 -0
  624. /package/src/{infra → runtime}/SignalHandler.ts +0 -0
  625. /package/src/{utils → runtime}/worker-utils.ts +0 -0
  626. /package/src/{utils → typecheck}/typecheck-serialization.ts +0 -0
@@ -1,850 +0,0 @@
1
- import path from "path";
2
- import semver from "semver";
3
- import { consola } from "consola";
4
- import { StorageFactory } from "@simplysm/storage";
5
- import { cpx, fsx } from "@simplysm/core-node";
6
- import { env, json } from "@simplysm/core-common";
7
- import "@simplysm/core-common";
8
- import type { SdConfig, SdPublishConfig } from "../sd-config.types";
9
- import { loadSdConfig } from "../utils/sd-config";
10
- import { validateTargets } from "../utils/package-utils";
11
- import { runBuild } from "./build";
12
- import { parseWorkspaceGlobs } from "../utils/replace-deps";
13
- import os from "os";
14
- import fs from "fs";
15
- import ssh2 from "ssh2";
16
- import { password as passwordPrompt } from "@inquirer/prompts";
17
-
18
- const { Client: SshClient, utils } = ssh2;
19
-
20
- //#region Types
21
-
22
- /**
23
- * 배포 명령어 옵션
24
- */
25
- export interface PublishOptions {
26
- /** 배포 대상 패키지 필터 (빈 배열이면 publish 설정이 있는 모든 패키지 배포) */
27
- targets: string[];
28
- /** 빌드 없이 배포 (위험) */
29
- noBuild: boolean;
30
- /** 실제 배포 없이 시뮬레이션 */
31
- dryRun: boolean;
32
- /** sd.config.ts에 전달할 추가 옵션 */
33
- options: string[];
34
- }
35
-
36
- /**
37
- * package.json 타입 (필수 필드만)
38
- */
39
- interface PackageJson {
40
- name: string;
41
- version: string;
42
- dependencies?: Record<string, string>;
43
- devDependencies?: Record<string, string>;
44
- peerDependencies?: Record<string, string>;
45
- optionalDependencies?: Record<string, string>;
46
- }
47
-
48
- //#endregion
49
-
50
- //#region Utilities
51
-
52
- /**
53
- * 환경변수 치환 (%VAR% 형식)
54
- * @throws 치환되지 않은 환경변수가 남아있으면 에러를 던진다
55
- */
56
- function replaceEnvVariables(str: string, version: string, projectPath: string): string {
57
- const result = str.replace(/%([^%]+)%/g, (match, envName: string) => {
58
- if (envName === "VER") {
59
- return version;
60
- }
61
- if (envName === "PROJECT") {
62
- return projectPath;
63
- }
64
- return env(envName) ?? match;
65
- });
66
-
67
- // 치환되지 않은 환경변수가 남아있으면 에러 발생
68
- if (/%[^%]+%/.test(result)) {
69
- throw new Error(`환경변수 치환 실패: ${str} → ${result}`);
70
- }
71
-
72
- return result;
73
- }
74
-
75
- /**
76
- * 카운트다운과 함께 대기
77
- */
78
- async function waitWithCountdown(message: string, seconds: number): Promise<void> {
79
- for (let i = seconds; i > 0; i--) {
80
- if (i !== seconds && process.stdout.isTTY) {
81
- process.stdout.cursorTo(0);
82
- }
83
- process.stdout.write(`${message} ${i}`);
84
- await new Promise((resolve) => setTimeout(resolve, 1000));
85
- }
86
-
87
- if (process.stdout.isTTY) {
88
- process.stdout.cursorTo(0);
89
- process.stdout.clearLine(0);
90
- } else {
91
- process.stdout.write("\n");
92
- }
93
- }
94
-
95
- /**
96
- * SSH 키 인증을 사전 검증하고 설정한다
97
- *
98
- * 비밀번호 없는 SFTP 서버의 경우:
99
- * 1. SSH 키 파일이 없으면 생성
100
- * 2. 키 인증을 테스트하고, 실패하면 비밀번호로 공개키를 등록
101
- */
102
- async function ensureSshAuth(
103
- publishPackages: Array<{ name: string; config: SdPublishConfig }>,
104
- logger: ReturnType<typeof consola.withTag>,
105
- ): Promise<void> {
106
- // 비밀번호 없는 SFTP 서버 수집 (user@host 기준 중복 제거)
107
- const sshTargets = new Map<string, { host: string; port?: number; user: string }>();
108
- for (const pkg of publishPackages) {
109
- if (pkg.config.type === "npm") continue;
110
- if (pkg.config.type !== "sftp") continue;
111
- if (pkg.config.password != null) continue;
112
- if (pkg.config.user == null) {
113
- throw new Error(`[${pkg.name}] SFTP 설정에 user가 누락되었습니다.`);
114
- }
115
- const key = `${pkg.config.user}@${pkg.config.host}`;
116
- sshTargets.set(key, {
117
- host: pkg.config.host,
118
- port: pkg.config.port,
119
- user: pkg.config.user,
120
- });
121
- }
122
-
123
- if (sshTargets.size === 0) return;
124
-
125
- // SSH 키 파일 확인/생성
126
- const sshDir = path.join(os.homedir(), ".ssh");
127
- const keyPath = path.join(sshDir, "id_ed25519");
128
- const pubKeyPath = path.join(sshDir, "id_ed25519.pub");
129
-
130
- if (!fs.existsSync(keyPath)) {
131
- logger.info("SSH 키를 찾을 수 없습니다. 생성 중...");
132
-
133
- if (!fs.existsSync(sshDir)) {
134
- fs.mkdirSync(sshDir, { mode: 0o700 });
135
- }
136
-
137
- const keyPair = utils.generateKeyPairSync("ed25519");
138
- fs.writeFileSync(keyPath, keyPair.private, { mode: 0o600 });
139
- fs.writeFileSync(pubKeyPath, keyPair.public + "\n", { mode: 0o644 });
140
-
141
- logger.info(`SSH 키 생성 완료: ${keyPath}`);
142
- }
143
-
144
- const privateKeyData = fs.readFileSync(keyPath);
145
- const publicKey = fs.readFileSync(pubKeyPath, "utf-8").trim();
146
-
147
- // 개인키 파싱 시도 (암호화 또는 형식 오류 시 Error 반환)
148
- const parsed = utils.parseKey(privateKeyData);
149
- const isKeyEncrypted = parsed instanceof Error;
150
- const sshAgent = env("SSH_AUTH_SOCK");
151
-
152
- // 각 서버에 대해 키 인증 검증
153
- for (const [label, target] of sshTargets) {
154
- const canAuth = await testSshKeyAuth(target, {
155
- privateKey: isKeyEncrypted ? undefined : privateKeyData,
156
- agent: sshAgent,
157
- });
158
- if (canAuth) {
159
- logger.debug(`SSH 키 인증 확인됨: ${label}`);
160
- continue;
161
- }
162
-
163
- // 키 인증 실패 → 비밀번호로 공개키 등록
164
- logger.info(`${label}: SSH 키가 서버에 등록되어 있지 않습니다.`);
165
- const pass = await passwordPrompt({
166
- message: `${label} 비밀번호 (공개키 등록용):`,
167
- });
168
-
169
- await registerSshPublicKey(target, pass, publicKey);
170
- logger.info(`SSH 공개키 등록 완료: ${label}`);
171
- }
172
- }
173
-
174
- /**
175
- * SSH 키 인증 테스트 (연결 후 즉시 종료)
176
- */
177
- function testSshKeyAuth(
178
- target: { host: string; port?: number; user: string },
179
- auth: { privateKey?: Buffer; agent?: string },
180
- ): Promise<boolean> {
181
- if (auth.privateKey == null && auth.agent == null) {
182
- return Promise.resolve(false);
183
- }
184
-
185
- return new Promise((resolve) => {
186
- const conn = new SshClient();
187
- conn.on("ready", () => {
188
- conn.end();
189
- resolve(true);
190
- });
191
- conn.on("error", () => {
192
- resolve(false);
193
- });
194
- conn.connect({
195
- host: target.host,
196
- port: target.port ?? 22,
197
- username: target.user,
198
- ...(auth.privateKey != null ? { privateKey: auth.privateKey } : {}),
199
- ...(auth.agent != null ? { agent: auth.agent } : {}),
200
- readyTimeout: 10_000,
201
- });
202
- });
203
- }
204
-
205
- /**
206
- * 비밀번호로 서버에 연결하여 SSH 공개키를 등록한다
207
- */
208
- function registerSshPublicKey(
209
- target: { host: string; port?: number; user: string },
210
- pass: string,
211
- publicKey: string,
212
- ): Promise<void> {
213
- return new Promise((resolve, reject) => {
214
- const conn = new SshClient();
215
- conn.on("ready", () => {
216
- // authorized_keys에 공개키 추가
217
- const escapedKey = publicKey.replace(/'/g, "'\\''");
218
- const cmd = [
219
- "mkdir -p ~/.ssh",
220
- "chmod 700 ~/.ssh",
221
- `echo '${escapedKey}' >> ~/.ssh/authorized_keys`,
222
- "chmod 600 ~/.ssh/authorized_keys",
223
- ].join(" && ");
224
-
225
- conn.exec(cmd, (err, stream) => {
226
- if (err) {
227
- conn.end();
228
- reject(new Error(`SSH 명령 실행 실패: ${err.message}`));
229
- return;
230
- }
231
-
232
- let stderr = "";
233
- stream.on("data", () => {}); // stdout 소비 (소비하지 않으면 스트림이 닫히지 않음)
234
- stream.stderr.on("data", (data: Uint8Array) => {
235
- stderr += data.toString();
236
- });
237
- stream.on("exit", (code: number | null) => {
238
- conn.end();
239
- if (code !== 0) {
240
- reject(new Error(`SSH 공개키 등록 실패 (종료 코드: ${code}): ${stderr}`));
241
- } else {
242
- resolve();
243
- }
244
- });
245
- });
246
- });
247
- conn.on("error", (err) => {
248
- reject(new Error(`SSH 연결 실패 (${target.host}): ${err.message}`));
249
- });
250
- conn.connect({
251
- host: target.host,
252
- port: target.port ?? 22,
253
- username: target.user,
254
- password: pass,
255
- readyTimeout: 10_000,
256
- });
257
- });
258
- }
259
-
260
- //#endregion
261
-
262
- //#region Version Upgrade
263
-
264
- /**
265
- * 프로젝트 및 패키지 버전 업그레이드
266
- * @param dryRun true이면 파일을 수정하지 않고 새 버전만 계산
267
- */
268
- async function upgradeVersion(
269
- cwd: string,
270
- allPkgPaths: string[],
271
- dryRun: boolean,
272
- ): Promise<{ version: string; changedFiles: string[] }> {
273
- const changedFiles: string[] = [];
274
- const projPkgPath = path.resolve(cwd, "package.json");
275
- const projPkg = await fsx.readJson<PackageJson>(projPkgPath);
276
-
277
- const currentVersion = projPkg.version;
278
- const prereleaseInfo = semver.prerelease(currentVersion);
279
-
280
- // 프리릴리스 여부에 따라 증가 전략 결정
281
- const newVersion =
282
- prereleaseInfo !== null
283
- ? semver.inc(currentVersion, "prerelease")!
284
- : semver.inc(currentVersion, "patch")!;
285
-
286
- if (dryRun) {
287
- // dry-run: 파일을 수정하지 않고 새 버전만 반환
288
- return { version: newVersion, changedFiles: [] };
289
- }
290
-
291
- projPkg.version = newVersion;
292
- await fsx.write(projPkgPath, json.stringify(projPkg, { space: 2 }) + "\n");
293
- changedFiles.push(projPkgPath);
294
-
295
- // 각 패키지의 package.json에 버전 설정
296
- for (const pkgPath of allPkgPaths) {
297
- const pkgJsonPath = path.resolve(pkgPath, "package.json");
298
- const pkgJson = await fsx.readJson<PackageJson>(pkgJsonPath);
299
- pkgJson.version = newVersion;
300
- await fsx.write(pkgJsonPath, json.stringify(pkgJson, { space: 2 }) + "\n");
301
- changedFiles.push(pkgJsonPath);
302
- }
303
-
304
- // 템플릿 파일의 @simplysm 패키지 버전 동기화
305
- const templateFiles = await fsx.glob(path.resolve(cwd, "packages/sd-cli/templates/**/*.hbs"));
306
- const versionRegex = /("@simplysm\/[^"]+"\s*:\s*)"~[^"]+"/g;
307
-
308
- for (const templatePath of templateFiles) {
309
- const content = await fsx.read(templatePath);
310
- const newContent = content.replace(versionRegex, `$1"~${newVersion}"`);
311
-
312
- if (content !== newContent) {
313
- await fsx.write(templatePath, newContent);
314
- changedFiles.push(templatePath);
315
- }
316
- }
317
-
318
- return { version: newVersion, changedFiles };
319
- }
320
-
321
- //#endregion
322
-
323
- //#region Package Publishing
324
-
325
- /**
326
- * 개별 패키지 배포
327
- * @param dryRun true이면 실제 배포 없이 시뮬레이션
328
- */
329
- async function publishPackage(
330
- pkgPath: string,
331
- publishConfig: SdPublishConfig,
332
- version: string,
333
- projectPath: string,
334
- logger: ReturnType<typeof consola.withTag>,
335
- dryRun: boolean,
336
- ): Promise<void> {
337
- const pkgName = path.basename(pkgPath);
338
-
339
- if (publishConfig.type === "npm") {
340
- // npm 배포
341
- const prereleaseInfo = semver.prerelease(version);
342
- const args = ["publish", "--access", "public", "--no-git-checks"];
343
-
344
- if (prereleaseInfo !== null && typeof prereleaseInfo[0] === "string") {
345
- args.push("--tag", prereleaseInfo[0]);
346
- }
347
-
348
- if (dryRun) {
349
- args.push("--dry-run");
350
- logger.info(`[DRY-RUN] [${pkgName}] pnpm ${args.join(" ")}`);
351
- } else {
352
- logger.debug(`[${pkgName}] pnpm ${args.join(" ")}`);
353
- }
354
-
355
- await cpx.spawn("pnpm", args, { cwd: pkgPath });
356
- } else if (publishConfig.type === "local-directory") {
357
- // 로컬 디렉토리에 복사
358
- const targetPath = replaceEnvVariables(publishConfig.path, version, projectPath);
359
- const distPath = path.resolve(pkgPath, "dist");
360
-
361
- if (dryRun) {
362
- logger.info(`[DRY-RUN] [${pkgName}] 로컬 복사: ${distPath} → ${targetPath}`);
363
- } else {
364
- logger.debug(`[${pkgName}] 로컬 복사: ${distPath} → ${targetPath}`);
365
- await fsx.copy(distPath, targetPath);
366
- }
367
- } else {
368
- // 스토리지에 업로드
369
- const distPath = path.resolve(pkgPath, "dist");
370
- const remotePath = publishConfig.path ?? "/";
371
-
372
- if (dryRun) {
373
- logger.info(
374
- `[DRY-RUN] [${pkgName}] ${publishConfig.type} 업로드: ${distPath} → ${remotePath}`,
375
- );
376
- } else {
377
- logger.debug(`[${pkgName}] ${publishConfig.type} 업로드: ${distPath} → ${remotePath}`);
378
- await StorageFactory.connect(
379
- publishConfig.type,
380
- {
381
- host: publishConfig.host,
382
- port: publishConfig.port,
383
- user: publishConfig.user,
384
- password: publishConfig.password,
385
- },
386
- async (storage) => {
387
- await storage.uploadDir(distPath, remotePath);
388
- },
389
- );
390
- }
391
- }
392
- }
393
-
394
- //#endregion
395
-
396
- //#region Dependency Levels
397
-
398
- /**
399
- * 배포할 패키지의 의존성 레벨을 계산한다.
400
- * 의존성이 없는 패키지 → Level 0, Level 0에만 의존하는 패키지 → Level 1, ...
401
- */
402
- async function computePublishLevels(
403
- publishPkgs: Array<{ name: string; path: string; config: SdPublishConfig }>,
404
- ): Promise<Array<Array<{ name: string; path: string; config: SdPublishConfig }>>> {
405
- const pkgNames = new Set(publishPkgs.map((p) => p.name));
406
-
407
- // 각 패키지의 워크스페이스 의존성 수집
408
- const depsMap = new Map<string, Set<string>>();
409
- for (const pkg of publishPkgs) {
410
- const pkgJson = await fsx.readJson<PackageJson>(path.resolve(pkg.path, "package.json"));
411
- const allDeps = {
412
- ...pkgJson.dependencies,
413
- ...pkgJson.peerDependencies,
414
- ...pkgJson.optionalDependencies,
415
- };
416
-
417
- const workspaceDeps = new Set<string>();
418
- for (const depName of Object.keys(allDeps)) {
419
- const shortName = depName.replace(/^@simplysm\//, "");
420
- if (shortName !== depName && pkgNames.has(shortName)) {
421
- workspaceDeps.add(shortName);
422
- }
423
- }
424
- depsMap.set(pkg.name, workspaceDeps);
425
- }
426
-
427
- // 위상 정렬로 레벨 분류
428
- const levels: Array<Array<{ name: string; path: string; config: SdPublishConfig }>> = [];
429
- const assigned = new Set<string>();
430
- const remaining = new Map(publishPkgs.map((p) => [p.name, p]));
431
-
432
- while (remaining.size > 0) {
433
- const level: Array<{ name: string; path: string; config: SdPublishConfig }> = [];
434
- for (const [name, pkg] of remaining) {
435
- const deps = depsMap.get(name)!;
436
- if ([...deps].every((d) => assigned.has(d))) {
437
- level.push(pkg);
438
- }
439
- }
440
-
441
- if (level.length === 0) {
442
- // 순환 의존성 — 나머지 패키지를 마지막 레벨에 배치
443
- levels.push([...remaining.values()]);
444
- break;
445
- }
446
-
447
- for (const pkg of level) {
448
- assigned.add(pkg.name);
449
- remaining.delete(pkg.name);
450
- }
451
- levels.push(level);
452
- }
453
-
454
- return levels;
455
- }
456
-
457
- //#endregion
458
-
459
- //#region Main
460
-
461
- /**
462
- * 배포 명령어를 실행한다.
463
- *
464
- * **배포 순서 (안전 우선):**
465
- * 1. 사전 검증 (npm 인증, Git 상태)
466
- * 2. 버전 업그레이드 (package.json + 템플릿)
467
- * 3. 빌드
468
- * 4. Git commit/tag/push (변경된 파일만 명시적으로 스테이징)
469
- * 5. 패키지 배포 (npm/로컬 디렉토리/스토리지)
470
- * 6. postPublish (실패해도 계속 진행)
471
- */
472
- export async function runPublish(options: PublishOptions): Promise<void> {
473
- const { targets, noBuild, dryRun } = options;
474
- const cwd = process.cwd();
475
- const logger = consola.withTag("sd:cli:publish");
476
-
477
- if (dryRun) {
478
- logger.info("[DRY-RUN] 시뮬레이션 모드 - 실제 배포 없음");
479
- }
480
-
481
- logger.debug("배포 시작", { targets, noBuild, dryRun });
482
-
483
- // sd.config.ts 로드
484
- let sdConfig: SdConfig;
485
- try {
486
- sdConfig = await loadSdConfig({ cwd, dev: false, opt: options.options });
487
- logger.debug("sd.config.ts 로드 완료");
488
- } catch (err) {
489
- logger.error(`sd.config.ts 로드 실패: ${err instanceof Error ? err.message : err}`);
490
- process.exitCode = 1;
491
- return;
492
- }
493
-
494
- // 대상 유효성 검사
495
- validateTargets(targets, sdConfig.packages);
496
-
497
- // package.json 로드
498
- const projPkgPath = path.resolve(cwd, "package.json");
499
- const projPkg = await fsx.readJson<PackageJson>(projPkgPath);
500
-
501
- // pnpm-workspace.yaml에서 워크스페이스 패키지 경로 수집
502
- const workspaceYamlPath = path.resolve(cwd, "pnpm-workspace.yaml");
503
- const workspaceGlobs: string[] = [];
504
- if (await fsx.exists(workspaceYamlPath)) {
505
- const yamlContent = await fsx.read(workspaceYamlPath);
506
- workspaceGlobs.push(...parseWorkspaceGlobs(yamlContent));
507
- }
508
-
509
- const allPkgPaths = (
510
- await Promise.all(workspaceGlobs.map((item) => fsx.glob(path.resolve(cwd, item))))
511
- )
512
- .flat()
513
- .filter((item) => fs.existsSync(path.join(item, "package.json")));
514
-
515
- // publish 설정이 있는 패키지 필터링
516
- const publishPackages: Array<{
517
- name: string;
518
- path: string;
519
- config: SdPublishConfig;
520
- }> = [];
521
-
522
- for (const [name, config] of Object.entries(sdConfig.packages)) {
523
- if (config == null) continue;
524
- const pkgConfig = config;
525
- if (pkgConfig.publish == null) continue;
526
-
527
- // targets가 지정되면 해당 패키지만 포함
528
- if (targets.length > 0 && !targets.includes(name)) continue;
529
-
530
- const pkgPath = allPkgPaths.find((p) => path.basename(p) === name);
531
- if (pkgPath == null) {
532
- logger.warn(`패키지를 찾을 수 없음: ${name}`);
533
- continue;
534
- }
535
-
536
- publishPackages.push({
537
- name,
538
- path: pkgPath,
539
- config: pkgConfig.publish,
540
- });
541
- }
542
-
543
- if (publishPackages.length === 0) {
544
- process.stdout.write("✔ 배포할 패키지가 없습니다.\n");
545
- return;
546
- }
547
-
548
- logger.debug(
549
- "배포 대상 패키지",
550
- publishPackages.map((p) => p.name),
551
- );
552
-
553
- // Git 사용 가능 여부 확인
554
- const hasGit = await fsx.exists(path.resolve(cwd, ".git"));
555
-
556
- //#region Phase 1: Pre-validation
557
-
558
- // npm 인증 검증 (npm publish 설정이 있는 경우)
559
- if (publishPackages.some((p) => p.config.type === "npm")) {
560
- logger.debug("npm 인증 검증 중...");
561
- try {
562
- const { stdout: whoami } = await cpx.spawn("npm", ["whoami"]);
563
- if (whoami.trim() === "") {
564
- throw new Error("npm 로그인 정보를 찾을 수 없습니다.");
565
- }
566
- logger.debug(`npm 로그인 확인됨: ${whoami.trim()}`);
567
- } catch {
568
- logger.error(
569
- "npm 인증 실패. 로그인 상태를 확인해주세요.\n" +
570
- " npm whoami # 현재 로그인 확인\n" +
571
- " npm login # 로그인\n" +
572
- " npm config set //registry.npmjs.org/:_authToken <token> # 토큰 직접 설정",
573
- );
574
- process.exitCode = 1;
575
- return;
576
- }
577
- }
578
-
579
- // SSH 키 인증 검증 (비밀번호 없는 SFTP publish 설정이 있는 경우)
580
- try {
581
- await ensureSshAuth(publishPackages, logger);
582
- } catch (err) {
583
- logger.error(`SSH 인증 설정 실패: ${err instanceof Error ? err.message : err}`);
584
- process.exitCode = 1;
585
- return;
586
- }
587
-
588
- // 커밋되지 않은 변경사항 확인 및 자동 커밋 시도 (noBuild가 아닌 경우)
589
- if (!noBuild && hasGit) {
590
- logger.debug("git 커밋 상태 확인 중...");
591
- try {
592
- const { stdout: diff } = await cpx.spawn("git", ["diff", "--name-only"]);
593
- const { stdout: stagedDiff } = await cpx.spawn("git", ["diff", "--cached", "--name-only"]);
594
-
595
- if (diff.trim() !== "" || stagedDiff.trim() !== "") {
596
- logger.info("커밋되지 않은 변경사항 감지. claude로 자동 커밋 시도 중...");
597
- try {
598
- await cpx.spawn(
599
- "claude",
600
- [
601
- "-p",
602
- "/sd-commit",
603
- "--dangerously-skip-permissions",
604
- "--model",
605
- "haiku",
606
- "--no-session-persistence",
607
- "--strict-mcp-config",
608
- ],
609
- {
610
- stdio: "inherit",
611
- env: {
612
- ...process.env,
613
- MCP_CONNECTION_NONBLOCKING: "true",
614
- CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
615
- DISABLE_TELEMETRY: "1",
616
- CLAUDE_CODE_DISABLE_BACKGROUND_TASKS: "1",
617
- CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1",
618
- CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING: "1",
619
- CLAUDE_CODE_DISABLE_SESSION_DATA_UPLOAD: "1",
620
- CLAUDE_CODE_SKIP_PROMPT_HISTORY: "1",
621
- CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS: "1",
622
- },
623
- },
624
- );
625
- } catch (e) {
626
- throw new Error(
627
- "자동 커밋에 실패했습니다. 수동으로 커밋 후 다시 시도해주세요.\n" +
628
- (e instanceof Error ? e.message : String(e)),
629
- );
630
- }
631
- }
632
- } catch (err) {
633
- logger.error(err instanceof Error ? err.message : err);
634
- process.exitCode = 1;
635
- return;
636
- }
637
- }
638
-
639
- //#endregion
640
-
641
- //#region Phase 2 & 3: Build or noBuild warning
642
-
643
- let version = projPkg.version;
644
-
645
- if (noBuild) {
646
- // noBuild 경고
647
- logger.warn("빌드 없이 배포하는 것은 매우 위험합니다.");
648
- await waitWithCountdown("중단하려면 'CTRL+C'를 누르세요.", 5);
649
- } else {
650
- // 버전 업그레이드
651
- logger.debug("버전 업그레이드 중...");
652
- const upgradeResult = await upgradeVersion(cwd, allPkgPaths, dryRun);
653
- version = upgradeResult.version;
654
- const _changedFiles = upgradeResult.changedFiles;
655
- if (dryRun) {
656
- logger.info(`[DRY-RUN] 버전 업그레이드: ${projPkg.version} → ${version} (파일 미수정)`);
657
- } else {
658
- logger.info(`버전 업그레이드: ${projPkg.version} → ${version}`);
659
- }
660
-
661
- // 빌드 실행
662
- if (dryRun) {
663
- logger.info("[DRY-RUN] 빌드 시작 (검증만)...");
664
- } else {
665
- logger.debug("빌드 시작...");
666
- }
667
-
668
- try {
669
- await runBuild({
670
- targets: publishPackages.map((p) => p.name),
671
- options: options.options,
672
- });
673
-
674
- // 빌드 실패 확인
675
- if (process.exitCode === 1) {
676
- throw new Error("빌드 실패");
677
- }
678
- } catch {
679
- if (dryRun) {
680
- logger.error("[DRY-RUN] 빌드 실패");
681
- } else {
682
- logger.error(
683
- "빌드 실패. 수동 복구가 필요할 수 있습니다:\n" +
684
- " 버전 변경을 되돌리려면:\n" +
685
- " git checkout -- package.json packages/*/package.json packages/sd-cli/templates/",
686
- );
687
- }
688
- process.exitCode = 1;
689
- return;
690
- }
691
-
692
- //#region Phase 3: Git commit/tag/push
693
-
694
- if (hasGit) {
695
- if (dryRun) {
696
- logger.info("[DRY-RUN] Git commit/tag/push 시뮬레이션 중...");
697
- logger.info(`[DRY-RUN] git add (${_changedFiles.length}개 파일)`);
698
- logger.info(`[DRY-RUN] git commit -m "v${version}"`);
699
- logger.info(`[DRY-RUN] git tag -a v${version} -m "v${version}"`);
700
- logger.info("[DRY-RUN] 리모트에 push 예정 (건너뜀)");
701
- logger.info("[DRY-RUN] 태그를 리모트에 push 예정 (건너뜀)");
702
- logger.info("[DRY-RUN] Git 작업 시뮬레이션 완료");
703
- } else {
704
- logger.debug("Git commit/tag/push...");
705
- try {
706
- await cpx.spawn("git", ["add", ..._changedFiles]);
707
- await cpx.spawn("git", ["commit", "-m", `v${version}`]);
708
- await cpx.spawn("git", ["tag", "-a", `v${version}`, "-m", `v${version}`]);
709
- await cpx.spawn("git", ["push"]);
710
- await cpx.spawn("git", ["push", "--tags"]);
711
- logger.debug("Git 작업 완료");
712
- } catch (err) {
713
- logger.error(
714
- `Git 작업 실패: ${err instanceof Error ? err.message : err}\n` +
715
- "수동 복구가 필요할 수 있습니다:\n" +
716
- ` git revert HEAD # 버전 커밋 되돌리기\n` +
717
- ` git tag -d v${version} # 태그 삭제`,
718
- );
719
- process.exitCode = 1;
720
- return;
721
- }
722
- }
723
- }
724
-
725
- //#endregion
726
- }
727
-
728
- //#endregion
729
-
730
- //#region Phase 4: Deployment (sequential by dependency level, parallel within level)
731
-
732
- const levels = await computePublishLevels(publishPackages);
733
- const publishedPackages: string[] = [];
734
- let publishFailed = false;
735
-
736
- // 레벨별 순차 실행
737
- for (let levelIdx = 0; levelIdx < levels.length; levelIdx++) {
738
- if (publishFailed) break;
739
-
740
- const levelPkgs = levels[levelIdx];
741
- logger.start(`Level ${levelIdx + 1}/${levels.length}`);
742
-
743
- // 레벨 내 병렬 실행 (Promise.allSettled)
744
- const publishPromises = levelPkgs.map(async (pkg) => {
745
- const maxRetries = 3;
746
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
747
- try {
748
- await publishPackage(pkg.path, pkg.config, version, cwd, logger, dryRun);
749
- logger.debug(dryRun ? `[DRY-RUN] ${pkg.name}` : pkg.name);
750
- publishedPackages.push(pkg.name);
751
- return { status: "success" as const, name: pkg.name };
752
- } catch (err) {
753
- if (attempt < maxRetries) {
754
- const delay = attempt * 5_000;
755
- logger.debug(
756
- dryRun
757
- ? `[DRY-RUN] ${pkg.name} (retry ${attempt + 1}/${maxRetries})`
758
- : `${pkg.name} (retry ${attempt + 1}/${maxRetries})`,
759
- );
760
- await new Promise((resolve) => setTimeout(resolve, delay));
761
- } else {
762
- throw err;
763
- }
764
- }
765
- }
766
- // TypeScript 타입 체커를 위한 폴백 (실제로 도달 불가)
767
- return { status: "error" as const, name: pkg.name, error: new Error("알 수 없는 에러") };
768
- });
769
-
770
- const results = await Promise.allSettled(publishPromises);
771
-
772
- // 레벨 내 실패 확인
773
- const rejectedResults = results.filter(
774
- (r): r is PromiseRejectedResult => r.status === "rejected",
775
- );
776
- if (rejectedResults.length > 0) {
777
- publishFailed = true;
778
- for (const r of rejectedResults) {
779
- logger.error(r.reason instanceof Error ? r.reason.message : r.reason);
780
- }
781
- logger.fail(`Level ${levelIdx + 1}/${levels.length}`);
782
- } else {
783
- logger.success(`Level ${levelIdx + 1}/${levels.length}`);
784
- }
785
- }
786
-
787
- // 실패한 패키지 확인
788
- const allPkgNames = publishPackages.map((p) => p.name);
789
- const publishedSet = new Set(publishedPackages);
790
- const failedPkgNames = allPkgNames.filter((n) => !publishedSet.has(n));
791
-
792
- if (failedPkgNames.length > 0) {
793
- if (publishedPackages.length > 0) {
794
- logger.error(
795
- "배포 중 에러 발생.\n" +
796
- "이미 배포된 패키지:\n" +
797
- publishedPackages.map((n) => ` - ${n}`).join("\n") +
798
- "\n\n수동 복구가 필요할 수 있습니다.\n" +
799
- "npm 패키지는 72시간 이내에 `npm unpublish <pkg>@<version>`으로 삭제할 수 있습니다.",
800
- );
801
- }
802
-
803
- for (const name of failedPkgNames) {
804
- logger.error(`[${name}] 배포 실패`);
805
- }
806
- process.exitCode = 1;
807
- return;
808
- }
809
-
810
- //#endregion
811
-
812
- //#region Phase 5: postPublish
813
-
814
- if (sdConfig.postPublish != null && sdConfig.postPublish.length > 0) {
815
- if (dryRun) {
816
- logger.info("[DRY-RUN] postPublish 스크립트 시뮬레이션 중...");
817
- } else {
818
- logger.debug("postPublish 스크립트 실행 중...");
819
- }
820
-
821
- for (const script of sdConfig.postPublish) {
822
- try {
823
- const cmd = replaceEnvVariables(script.cmd, version, cwd);
824
- const args = script.args.map((arg) => replaceEnvVariables(arg, version, cwd));
825
-
826
- if (dryRun) {
827
- logger.info(`[DRY-RUN] 실행 예정: ${cmd} ${args.join(" ")}`);
828
- } else {
829
- logger.debug(`실행 중: ${cmd} ${args.join(" ")}`);
830
- await cpx.spawn(cmd, args, { cwd });
831
- }
832
- } catch (err) {
833
- // postPublish 실패 시 경고만 출력 (배포 롤백 불가)
834
- logger.warn(
835
- `postPublish 스크립트 실패 (계속 진행): ${err instanceof Error ? err.message : err}`,
836
- );
837
- }
838
- }
839
- }
840
-
841
- //#endregion
842
-
843
- if (dryRun) {
844
- logger.info(`[DRY-RUN] 시뮬레이션 완료. 실제 배포 버전: v${version}`);
845
- } else {
846
- logger.info(`모든 배포 완료. (v${version})`);
847
- }
848
- }
849
-
850
- //#endregion