comp-hub 0.42.8 → 0.43.9

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 (260) hide show
  1. package/README.md +13 -2
  2. package/README.zh-CN.md +144 -0
  3. package/README.zh-Hant.md +144 -0
  4. package/dist/cli.js +44 -0
  5. package/dist/index.js +14 -33
  6. package/dist/master.js +19 -19
  7. package/package.json +16 -18
  8. package/bin/cli.js +0 -59
  9. package/bin/lib/commands.js +0 -173
  10. package/bin/lib/constants.js +0 -22
  11. package/bin/lib/http.js +0 -130
  12. package/bin/lib/startup.js +0 -254
  13. package/bin/lib/utils.js +0 -112
  14. package/dist/website/container/assets/index-BmW7jge6.css +0 -1
  15. package/dist/website/container/assets/index-E15UfKFM.js +0 -33
  16. package/dist/website/container/favicon.ico +0 -0
  17. package/dist/website/container/index.html +0 -39
  18. package/dist/website/container/js/less-compiler.js +0 -41
  19. package/dist/website/container/js/react-jsx-loader.js +0 -233
  20. package/dist/website/container/js/sass-compiler.js +0 -418
  21. package/dist/website/container/js/vue2-sfc-loader.js +0 -261
  22. package/dist/website/container/js/vue3-sfc-loader.js +0 -290
  23. package/dist/website/item/assets/index-CfkvQ31V.css +0 -1
  24. package/dist/website/item/assets/index-CwtVkGPL.js +0 -62
  25. package/dist/website/item/favicon.ico +0 -0
  26. package/dist/website/item/index.html +0 -34
  27. package/dist/website/main/assets/AuthCodeSendBtn.vue_vue_type_script_setup_true_lang-D-jhE3yA.js +0 -1
  28. package/dist/website/main/assets/BaseBadge-BReHrAqs.js +0 -1
  29. package/dist/website/main/assets/BaseBadge-ledSuDnX.css +0 -1
  30. package/dist/website/main/assets/BaseDialog.vue_vue_type_script_setup_true_lang-BK7dbjCA.js +0 -1
  31. package/dist/website/main/assets/BaseSegmented.vue_vue_type_script_setup_true_lang-CcSntY2B.js +0 -1
  32. package/dist/website/main/assets/CanvasAnimation.vue_vue_type_script_setup_true_lang-T5vn0JFD.js +0 -1
  33. package/dist/website/main/assets/CodeMirrorEditor-Cqow8ROO-DYjlZgX9.js +0 -12
  34. package/dist/website/main/assets/EmptyStatusContainer.vue_vue_type_script_setup_true_lang-CNOUTt3S.js +0 -1
  35. package/dist/website/main/assets/GithubCallback-UUNSnoh7.js +0 -1
  36. package/dist/website/main/assets/LoadingWrapper.vue_vue_type_script_setup_true_lang-BYA4gUOI.js +0 -1
  37. package/dist/website/main/assets/ReplyForm.vue_vue_type_script_setup_true_lang-CEqkWYsv.js +0 -1
  38. package/dist/website/main/assets/SiteLogo-Bpm2Ah9F.js +0 -1
  39. package/dist/website/main/assets/SiteLogo-CszHjM2d.css +0 -1
  40. package/dist/website/main/assets/apl-B4CMkyY2.js +0 -1
  41. package/dist/website/main/assets/asciiarmor-Df11BRmG.js +0 -1
  42. package/dist/website/main/assets/asn1-EdZsLKOL.js +0 -1
  43. package/dist/website/main/assets/asterisk-B-8jnY81.js +0 -1
  44. package/dist/website/main/assets/brainfuck-C4LP7Hcl.js +0 -1
  45. package/dist/website/main/assets/clike-B9uivgTg.js +0 -1
  46. package/dist/website/main/assets/clojure-BMjYHr_A.js +0 -1
  47. package/dist/website/main/assets/cloud-upload-BqJFdj_J.js +0 -1
  48. package/dist/website/main/assets/cloud-upload-j3Y0taC9.css +0 -1
  49. package/dist/website/main/assets/cmake-BQqOBYOt.js +0 -1
  50. package/dist/website/main/assets/cobol-CWcv1MsR.js +0 -1
  51. package/dist/website/main/assets/coffeescript-S37ZYGWr.js +0 -1
  52. package/dist/website/main/assets/commonlisp-DBKNyK5s.js +0 -1
  53. package/dist/website/main/assets/crystal-SjHAIU92.js +0 -1
  54. package/dist/website/main/assets/css-BnMrqG3P.js +0 -1
  55. package/dist/website/main/assets/cypher-C_CwsFkJ.js +0 -1
  56. package/dist/website/main/assets/d-pRatUO7H.js +0 -1
  57. package/dist/website/main/assets/diff-DbItnlRl.js +0 -1
  58. package/dist/website/main/assets/dockerfile-BKs6k2Af.js +0 -1
  59. package/dist/website/main/assets/dtd-DF_7sFjM.js +0 -1
  60. package/dist/website/main/assets/dylan-DwRh75JA.js +0 -1
  61. package/dist/website/main/assets/ebnf-CDyGwa7X.js +0 -1
  62. package/dist/website/main/assets/ecl-Cabwm37j.js +0 -1
  63. package/dist/website/main/assets/eiffel-CnydiIhH.js +0 -1
  64. package/dist/website/main/assets/el-card-BAyktVMS.css +0 -1
  65. package/dist/website/main/assets/el-dropdown-item-BeIfAqTO.css +0 -1
  66. package/dist/website/main/assets/el-empty-S7fQQ3B8.css +0 -1
  67. package/dist/website/main/assets/el-link-CPQZ-olG.css +0 -1
  68. package/dist/website/main/assets/el-table-column-B3ZEEuPD.css +0 -1
  69. package/dist/website/main/assets/el-table-column-C2GQUl4R.js +0 -1
  70. package/dist/website/main/assets/elm-vLlmbW-K.js +0 -1
  71. package/dist/website/main/assets/en-DJCBTPEu.js +0 -1
  72. package/dist/website/main/assets/erlang-BNw1qcRV.js +0 -1
  73. package/dist/website/main/assets/factor-kuTfRLto.js +0 -1
  74. package/dist/website/main/assets/fcl-Kvtd6kyn.js +0 -1
  75. package/dist/website/main/assets/forth-Ffai-XNe.js +0 -1
  76. package/dist/website/main/assets/fortran-DYz_wnZ1.js +0 -1
  77. package/dist/website/main/assets/gas-Bneqetm1.js +0 -1
  78. package/dist/website/main/assets/gherkin-heZmZLOM.js +0 -1
  79. package/dist/website/main/assets/groovy-D9Dt4D0W.js +0 -1
  80. package/dist/website/main/assets/haskell-Cw1EW3IL.js +0 -1
  81. package/dist/website/main/assets/haxe-H-WmDvRZ.js +0 -1
  82. package/dist/website/main/assets/home-rounded-B4KVwSYb.css +0 -1
  83. package/dist/website/main/assets/home-rounded-CN0qCDnE.js +0 -1
  84. package/dist/website/main/assets/http-DBlCnlav.js +0 -1
  85. package/dist/website/main/assets/idl-BEugSyMb.js +0 -1
  86. package/dist/website/main/assets/index-4S2NYemE.js +0 -1
  87. package/dist/website/main/assets/index-6zg8j_nT.js +0 -1
  88. package/dist/website/main/assets/index-72rReQ2I-C_aIAupr.js +0 -6
  89. package/dist/website/main/assets/index-8dCw6Y2Z.css +0 -1
  90. package/dist/website/main/assets/index-B1K6cAvN.js +0 -1
  91. package/dist/website/main/assets/index-B2qulmRp.js +0 -1
  92. package/dist/website/main/assets/index-B5rd6Qgm.js +0 -1
  93. package/dist/website/main/assets/index-B6JeEo9g.js +0 -1
  94. package/dist/website/main/assets/index-B6Oo99Ej.js +0 -1
  95. package/dist/website/main/assets/index-BA02DjBI.js +0 -3
  96. package/dist/website/main/assets/index-BD8DwKlG.js +0 -1
  97. package/dist/website/main/assets/index-BF2ETnQh.js +0 -1
  98. package/dist/website/main/assets/index-BNwWVTCF.js +0 -1
  99. package/dist/website/main/assets/index-BPdEkCOx.js +0 -1
  100. package/dist/website/main/assets/index-BTmh_pkn.js +0 -1
  101. package/dist/website/main/assets/index-BWh3R1jI.js +0 -6
  102. package/dist/website/main/assets/index-BX3Tl9jb.js +0 -1
  103. package/dist/website/main/assets/index-Bn5vi5XZ.css +0 -1
  104. package/dist/website/main/assets/index-BvmEG8Qn.css +0 -1
  105. package/dist/website/main/assets/index-By_sRNiP.js +0 -1
  106. package/dist/website/main/assets/index-C0WquRMM.css +0 -1
  107. package/dist/website/main/assets/index-C1zFaUVE.js +0 -1
  108. package/dist/website/main/assets/index-CCJiyDal.js +0 -1
  109. package/dist/website/main/assets/index-CLT68CCM.css +0 -1
  110. package/dist/website/main/assets/index-CMiBqyhH.js +0 -1
  111. package/dist/website/main/assets/index-CaoAcCMA.js +0 -2
  112. package/dist/website/main/assets/index-CbOKlsZn.js +0 -2
  113. package/dist/website/main/assets/index-CdWXO9ks.css +0 -1
  114. package/dist/website/main/assets/index-CeiBBtdW.js +0 -1
  115. package/dist/website/main/assets/index-ChFpxx4T.css +0 -1
  116. package/dist/website/main/assets/index-CioMG7I6.css +0 -1
  117. package/dist/website/main/assets/index-CtNrOkJr.js +0 -1
  118. package/dist/website/main/assets/index-CuCbuNEj.js +0 -1
  119. package/dist/website/main/assets/index-D-25wqLa.js +0 -1
  120. package/dist/website/main/assets/index-D-HOLV6Z.js +0 -1
  121. package/dist/website/main/assets/index-D-zBzPPy.css +0 -1
  122. package/dist/website/main/assets/index-D6zFRika.js +0 -1
  123. package/dist/website/main/assets/index-D76eWsZ1-a1NwqrGS.js +0 -1
  124. package/dist/website/main/assets/index-DFsl7Pen.css +0 -1
  125. package/dist/website/main/assets/index-DOlF0Z_P.css +0 -1
  126. package/dist/website/main/assets/index-DR4j8Ql1.js +0 -1
  127. package/dist/website/main/assets/index-DRsSRfwD.js +0 -1
  128. package/dist/website/main/assets/index-DS44gjNL.js +0 -2
  129. package/dist/website/main/assets/index-D_NvG8ob.js +0 -1
  130. package/dist/website/main/assets/index-Dblv7zZt.js +0 -1
  131. package/dist/website/main/assets/index-Dcp6qLr1.js +0 -1
  132. package/dist/website/main/assets/index-DdIWt0oE.js +0 -1
  133. package/dist/website/main/assets/index-DdqWCLvd.js +0 -1
  134. package/dist/website/main/assets/index-DgQa2ZqK.js +0 -4
  135. package/dist/website/main/assets/index-DgrizPPB.js +0 -50
  136. package/dist/website/main/assets/index-DlkXaOkE.css +0 -1
  137. package/dist/website/main/assets/index-Dms7ZQ2h-DZe32-4Q.js +0 -1
  138. package/dist/website/main/assets/index-DpUmZw4S.js +0 -1
  139. package/dist/website/main/assets/index-DqiFCfGx-Be_VzFT8.js +0 -1
  140. package/dist/website/main/assets/index-DvFQxOj2.js +0 -1
  141. package/dist/website/main/assets/index-DxypSQ0K-DZ74HfZS.js +0 -1
  142. package/dist/website/main/assets/index-Dy0c-ddP.js +0 -1
  143. package/dist/website/main/assets/index-DyFpWAJM.js +0 -1
  144. package/dist/website/main/assets/index-Ji2WmMDE.css +0 -1
  145. package/dist/website/main/assets/index-KhSB9wFh.js +0 -84
  146. package/dist/website/main/assets/index-Mnu1wKgu.css +0 -1
  147. package/dist/website/main/assets/index-RrkKKQjp.js +0 -1
  148. package/dist/website/main/assets/index-S0EB9acK.js +0 -7
  149. package/dist/website/main/assets/index-T76vWLBU-iHnxnk3E.js +0 -13
  150. package/dist/website/main/assets/index-VpAGAhRh.js +0 -1
  151. package/dist/website/main/assets/index-VyPJ3PyN.js +0 -1
  152. package/dist/website/main/assets/index-Zt46lwNk.js +0 -1
  153. package/dist/website/main/assets/index-ex5YI_gC.js +0 -1
  154. package/dist/website/main/assets/index-fZBcgzqR-CqMOhDrG.js +0 -1
  155. package/dist/website/main/assets/index-mqeGrL6B-C5oP0065.js +0 -1
  156. package/dist/website/main/assets/index-wd7ZswFD.js +0 -1
  157. package/dist/website/main/assets/index-z8BnmFXm.js +0 -1
  158. package/dist/website/main/assets/index.vue_vue_type_script_setup_true_lang-Ap8wTvsB.js +0 -2
  159. package/dist/website/main/assets/index.vue_vue_type_script_setup_true_lang-B05SHLQS.js +0 -1
  160. package/dist/website/main/assets/index.vue_vue_type_script_setup_true_lang-BOkD4Vs3.js +0 -1
  161. package/dist/website/main/assets/index.vue_vue_type_script_setup_true_lang-Bs4fbZK8.js +0 -1
  162. package/dist/website/main/assets/index.vue_vue_type_script_setup_true_lang-ByHasmxS.js +0 -1
  163. package/dist/website/main/assets/index.vue_vue_type_script_setup_true_lang-Dsu1eY0B.js +0 -1
  164. package/dist/website/main/assets/index.vue_vue_type_style_index_0_lang-66fUtqSq.js +0 -6
  165. package/dist/website/main/assets/index.vue_vue_type_style_index_0_lang-CUQ5yd-1.js +0 -1
  166. package/dist/website/main/assets/index3-BiHnTK1Z.js +0 -1
  167. package/dist/website/main/assets/javascript-iXu5QeM3.js +0 -1
  168. package/dist/website/main/assets/julia-DuME0IfC.js +0 -1
  169. package/dist/website/main/assets/kid-star-CiMfD7Sa.js +0 -1
  170. package/dist/website/main/assets/kid-star-D1M-aC1C.css +0 -1
  171. package/dist/website/main/assets/livescript-BwQOo05w.js +0 -1
  172. package/dist/website/main/assets/lua-VAEuO923.js +0 -1
  173. package/dist/website/main/assets/mathematica-DTrFuWx2.js +0 -1
  174. package/dist/website/main/assets/mbox-CNhZ1qSd.js +0 -1
  175. package/dist/website/main/assets/md5-Dkj6ZNQB.js +0 -1
  176. package/dist/website/main/assets/mirc-CjQqDB4T.js +0 -1
  177. package/dist/website/main/assets/mllike-CXdrOF99.js +0 -1
  178. package/dist/website/main/assets/modelica-Dc1JOy9r.js +0 -1
  179. package/dist/website/main/assets/moment-B-YVwB4U.js +0 -4
  180. package/dist/website/main/assets/mscgen-BA5vi2Kp.js +0 -1
  181. package/dist/website/main/assets/mumps-BT43cFF4.js +0 -1
  182. package/dist/website/main/assets/nginx-DdIZxoE0.js +0 -1
  183. package/dist/website/main/assets/nsis-LdVXkNf5.js +0 -1
  184. package/dist/website/main/assets/ntriples-BfvgReVJ.js +0 -1
  185. package/dist/website/main/assets/octave-Ck1zUtKM.js +0 -1
  186. package/dist/website/main/assets/oz-BzwKVEFT.js +0 -1
  187. package/dist/website/main/assets/papaparse.min-Brc8PWCw-BsyFjD51.js +0 -10
  188. package/dist/website/main/assets/pascal--L3eBynH.js +0 -1
  189. package/dist/website/main/assets/perl-CdXCOZ3F.js +0 -1
  190. package/dist/website/main/assets/pig-CevX1Tat.js +0 -1
  191. package/dist/website/main/assets/powershell-CFHJl5sT.js +0 -1
  192. package/dist/website/main/assets/properties-C78fOPTZ.js +0 -1
  193. package/dist/website/main/assets/protobuf-ChK-085T.js +0 -1
  194. package/dist/website/main/assets/pug-DeIclll2.js +0 -1
  195. package/dist/website/main/assets/puppet-DMA9R1ak.js +0 -1
  196. package/dist/website/main/assets/python-BuPzkPfP.js +0 -1
  197. package/dist/website/main/assets/q-pXgVlZs6.js +0 -1
  198. package/dist/website/main/assets/r-B6wPVr8A.js +0 -1
  199. package/dist/website/main/assets/rpm-CTu-6PCP.js +0 -1
  200. package/dist/website/main/assets/ruby-B2Rjki9n.js +0 -1
  201. package/dist/website/main/assets/sas-B4kiWyti.js +0 -1
  202. package/dist/website/main/assets/scheme-C41bIUwD.js +0 -1
  203. package/dist/website/main/assets/settings-BhagQj3w.css +0 -1
  204. package/dist/website/main/assets/settings-CSr4nQM1.js +0 -1
  205. package/dist/website/main/assets/shell-CjFT_Tl9.js +0 -1
  206. package/dist/website/main/assets/sieve-C3Gn_uJK.js +0 -1
  207. package/dist/website/main/assets/simple-mode-GW_nhZxv.js +0 -1
  208. package/dist/website/main/assets/smalltalk-CnHTOXQT.js +0 -1
  209. package/dist/website/main/assets/solr-DehyRSwq.js +0 -1
  210. package/dist/website/main/assets/sparql-DkYu6x3z.js +0 -1
  211. package/dist/website/main/assets/spreadsheet-BCZA_wO0.js +0 -1
  212. package/dist/website/main/assets/sql-D0XecflT.js +0 -1
  213. package/dist/website/main/assets/stex-C3f8Ysf7.js +0 -1
  214. package/dist/website/main/assets/stylus-B533Al4x.js +0 -1
  215. package/dist/website/main/assets/supervised-user-circle-BwUSx6w_.js +0 -1
  216. package/dist/website/main/assets/supervised-user-circle-CZYpyCV4.css +0 -1
  217. package/dist/website/main/assets/swift-BzpIVaGY.js +0 -1
  218. package/dist/website/main/assets/sync-saved-locally-rounded-DyESI323.js +0 -1
  219. package/dist/website/main/assets/sync-saved-locally-rounded-wbwASI26.css +0 -1
  220. package/dist/website/main/assets/tcl-DVfN8rqt.js +0 -1
  221. package/dist/website/main/assets/terminal-DAZ0JqKA.js +0 -1
  222. package/dist/website/main/assets/terminal-DFt3N_TH.css +0 -1
  223. package/dist/website/main/assets/textile-CnDTJFAw.js +0 -1
  224. package/dist/website/main/assets/tiddlywiki-DO-Gjzrf.js +0 -1
  225. package/dist/website/main/assets/tiki-DGYXhP31.js +0 -1
  226. package/dist/website/main/assets/toml-Bm5Em-hy.js +0 -1
  227. package/dist/website/main/assets/troff-wAsdV37c.js +0 -1
  228. package/dist/website/main/assets/ttcn-CfJYG6tj.js +0 -1
  229. package/dist/website/main/assets/ttcn-cfg-B9xdYoR4.js +0 -1
  230. package/dist/website/main/assets/turtle-B1tBg_DP.js +0 -1
  231. package/dist/website/main/assets/useCacheOssStore-C6-kY3lP.js +0 -1
  232. package/dist/website/main/assets/useCompEditStore-B7__tBPJ.js +0 -70
  233. package/dist/website/main/assets/useCompEditStore-C2cDxPfw.css +0 -1
  234. package/dist/website/main/assets/useCompMetaLocalStore-DUMtt_yz.js +0 -1
  235. package/dist/website/main/assets/useKeyword-O-wdQuD_.js +0 -1
  236. package/dist/website/main/assets/useMessage-yR4W8KDP.js +0 -1
  237. package/dist/website/main/assets/useTeamHeaders-BMHQzwDq.css +0 -1
  238. package/dist/website/main/assets/useTeamHeaders-BbJQSrjN.js +0 -380
  239. package/dist/website/main/assets/useUnreadStore-COt1XJEP.js +0 -1
  240. package/dist/website/main/assets/useVscodeOpen-CCvngYEV.js +0 -1
  241. package/dist/website/main/assets/v4-EwEgHOG0.js +0 -1
  242. package/dist/website/main/assets/vb-CmGdzxic.js +0 -1
  243. package/dist/website/main/assets/vbscript-BuJXcnF6.js +0 -1
  244. package/dist/website/main/assets/velocity-D8B20fx6.js +0 -1
  245. package/dist/website/main/assets/vendor-core-CNXB6kVe.js +0 -3
  246. package/dist/website/main/assets/vendor-ui-Cvgmewma.js +0 -50
  247. package/dist/website/main/assets/vendor-xterm-mNFjEaKn.js +0 -9
  248. package/dist/website/main/assets/verilog-C6RDOZhf.js +0 -1
  249. package/dist/website/main/assets/vhdl-lSbBsy5d.js +0 -1
  250. package/dist/website/main/assets/webidl-ZXfAyPTL.js +0 -1
  251. package/dist/website/main/assets/xquery-DzFWVndE.js +0 -1
  252. package/dist/website/main/assets/yacas-BJ4BC0dw.js +0 -1
  253. package/dist/website/main/assets/z80-Hz9HOZM7.js +0 -1
  254. package/dist/website/main/assets/zhCN-VSAW5gZn.js +0 -1
  255. package/dist/website/main/favicon.ico +0 -0
  256. package/dist/website/main/index.html +0 -111
  257. package/dist/website/main/md/COMP_REPEAT.en.md +0 -20
  258. package/dist/website/main/md/COMP_REPEAT.zh.md +0 -20
  259. package/dist/website/main/md/PUT_TREATY.en.md +0 -68
  260. package/dist/website/main/md/PUT_TREATY.zh.md +0 -68
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ <div align="right">
2
+
3
+ **English** · [简体中文](README.zh-CN.md) · [繁體中文](README.zh-Hant.md)
4
+
5
+ </div>
6
+
1
7
  # comp-hub
2
8
 
3
9
  CLI for comp-hub — a component sharing platform supporting Vue and React. Start a local dev server to preview, manage, and share components.
@@ -5,6 +11,8 @@ CLI for comp-hub — a component sharing platform supporting Vue and React. Star
5
11
  [![npm version](https://img.shields.io/npm/v/comp-hub)](https://www.npmjs.com/package/comp-hub)
6
12
  [![Node.js](https://img.shields.io/badge/node-%3E%3D16-brightgreen)](https://nodejs.org)
7
13
 
14
+ **Website:** <https://www.comphub.cn> &nbsp;·&nbsp; **Docs:** <https://docs.comphub.cn>
15
+
8
16
  ## Requirements
9
17
 
10
18
  - Node.js >= 16.0.0
@@ -34,6 +42,8 @@ comphub
34
42
 
35
43
  Once started, open the URL shown in the terminal (default `http://localhost:5478`).
36
44
 
45
+ > `ch` is a shorthand alias for `comphub` — all commands below work interchangeably, e.g. `ch`, `ch status`, `ch -p 8080`.
46
+
37
47
  ### CLI Options
38
48
 
39
49
  ```bash
@@ -124,9 +134,10 @@ module.exports = {
124
134
  - Optional `comp.json` for component metadata (name, version, dependencies, etc.)
125
135
  - Optional `demo/` directory for preview configs
126
136
 
127
- ## Documentation
137
+ ## Links
128
138
 
129
- [comp-hub Docs](https://docs.comphub.cn)
139
+ - Website: <https://www.comphub.cn>
140
+ - Docs: <https://docs.comphub.cn>
130
141
 
131
142
  ## License
132
143
 
@@ -0,0 +1,144 @@
1
+ <div align="right">
2
+
3
+ [English](README.md) · **简体中文** · [繁體中文](README.zh-Hant.md)
4
+
5
+ </div>
6
+
7
+ # comp-hub
8
+
9
+ comp-hub 的 CLI —— 一个同时支持 Vue 与 React 的组件共享平台。在本地启动开发服务器,即可预览、管理和共享组件。
10
+
11
+ [![npm version](https://img.shields.io/npm/v/comp-hub)](https://www.npmjs.com/package/comp-hub)
12
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D16-brightgreen)](https://nodejs.org)
13
+
14
+ **官网:** <https://www.comphub.cn> &nbsp;·&nbsp; **文档站:** <https://docs.comphub.cn>
15
+
16
+ ## 环境要求
17
+
18
+ - Node.js >= 16.0.0
19
+ - npm >= 8.0.0
20
+
21
+ ## 安装
22
+
23
+ **全局安装(推荐)**
24
+
25
+ ```bash
26
+ npm install comp-hub@latest -g
27
+ ```
28
+
29
+ **本地安装**
30
+
31
+ ```bash
32
+ npm install comp-hub@latest -D
33
+ ```
34
+
35
+ ## 快速开始
36
+
37
+ 在项目目录中运行:
38
+
39
+ ```bash
40
+ comphub
41
+ ```
42
+
43
+ 启动后,打开终端里显示的地址(默认 `http://localhost:5478`)。
44
+
45
+ > `ch` 是 `comphub` 的简写别名,以下所有命令均可互换使用,例如 `ch`、`ch status`、`ch -p 8080`。
46
+
47
+ ### CLI 选项
48
+
49
+ ```bash
50
+ comphub [options]
51
+ ```
52
+
53
+ | 选项 | 别名 | 类型 | 默认值 | 说明 |
54
+ |------|------|------|--------|------|
55
+ | `--port` | `-p` | number | 5478 | 服务端口 |
56
+ | `--dir` | `-d` | path | `"./"` | 组件目录 |
57
+ | `--version` | `-v` | — | — | 显示版本 |
58
+ | `--help` | `-h` | — | — | 显示帮助 |
59
+
60
+ 示例:
61
+
62
+ ```bash
63
+ comphub -p 8080 # 自定义端口
64
+ comphub -d ./src # 自定义组件目录
65
+ ```
66
+
67
+ ### 管理命令
68
+
69
+ | 命令 | 说明 |
70
+ |------|------|
71
+ | `comphub` | 启动开发服务器 |
72
+ | `comphub status` | 列出所有正在运行的项目 |
73
+ | `comphub stop <hash>` | 停止指定项目 |
74
+ | `comphub stop --all` | 停止所有项目 |
75
+ | `comphub kill` | 关闭所有服务 |
76
+
77
+ 示例:
78
+
79
+ ```bash
80
+ # 查看正在运行的项目
81
+ comphub status
82
+
83
+ # 停止某个项目
84
+ comphub stop 94525912
85
+
86
+ # 停止所有项目
87
+ comphub stop --all
88
+
89
+ # 关闭全部
90
+ comphub kill
91
+ ```
92
+
93
+ ### 多项目
94
+
95
+ 在不同的端口上同时运行多个项目:
96
+
97
+ ```bash
98
+ cd /path/to/project-a && comphub
99
+ cd /path/to/project-b && comphub
100
+ comphub status # 查看全部
101
+ ```
102
+
103
+ ## 配置
104
+
105
+ 在项目根目录创建 `.comphub.json` 或 `.comphub.js`:
106
+
107
+ ```json
108
+ {
109
+ "dir": "./src",
110
+ "allowDebug": false
111
+ }
112
+ ```
113
+
114
+ ```javascript
115
+ module.exports = {
116
+ dir: './src',
117
+ allowDebug: false
118
+ }
119
+ ```
120
+
121
+ | 选项 | 类型 | 默认值 | 说明 |
122
+ |------|------|--------|------|
123
+ | `dir` | string | `"./"` | 组件根目录 |
124
+ | `allowDebug` | boolean | false | 启用调试模式 |
125
+ | `proxy` | object | — | 自定义代理规则 |
126
+
127
+ **优先级**:命令行参数 > 配置文件 > 默认值
128
+
129
+ ## 组件规范
130
+
131
+ - 组件以**文件夹**形式上传——文件夹名即组件名
132
+ - 入口文件:`index.vue`(Vue)或 `index.jsx` / `index.tsx`(React)
133
+ - 建议包含说明用法的 `README.md`
134
+ - 可选 `comp.json` 用于组件元信息(名称、版本、依赖等)
135
+ - 可选 `demo/` 目录存放预览配置
136
+
137
+ ## 链接
138
+
139
+ - 官网:<https://www.comphub.cn>
140
+ - 文档站:<https://docs.comphub.cn>
141
+
142
+ ## 许可证
143
+
144
+ [MIT](LICENSE)
@@ -0,0 +1,144 @@
1
+ <div align="right">
2
+
3
+ [English](README.md) · [简体中文](README.zh-CN.md) · **繁體中文**
4
+
5
+ </div>
6
+
7
+ # comp-hub
8
+
9
+ comp-hub 的 CLI —— 一個同時支援 Vue 與 React 的元件分享平台。在本地啟動開發伺服器,即可預覽、管理和分享元件。
10
+
11
+ [![npm version](https://img.shields.io/npm/v/comp-hub)](https://www.npmjs.com/package/comp-hub)
12
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D16-brightgreen)](https://nodejs.org)
13
+
14
+ **官網:** <https://www.comphub.cn> &nbsp;·&nbsp; **文件站:** <https://docs.comphub.cn>
15
+
16
+ ## 環境需求
17
+
18
+ - Node.js >= 16.0.0
19
+ - npm >= 8.0.0
20
+
21
+ ## 安裝
22
+
23
+ **全域安裝(建議)**
24
+
25
+ ```bash
26
+ npm install comp-hub@latest -g
27
+ ```
28
+
29
+ **本機安裝**
30
+
31
+ ```bash
32
+ npm install comp-hub@latest -D
33
+ ```
34
+
35
+ ## 快速開始
36
+
37
+ 在專案目錄中執行:
38
+
39
+ ```bash
40
+ comphub
41
+ ```
42
+
43
+ 啟動後,開啟終端機裡顯示的位址(預設 `http://localhost:5478`)。
44
+
45
+ > `ch` 是 `comphub` 的簡寫別名,以下所有指令均可互換使用,例如 `ch`、`ch status`、`ch -p 8080`。
46
+
47
+ ### CLI 選項
48
+
49
+ ```bash
50
+ comphub [options]
51
+ ```
52
+
53
+ | 選項 | 別名 | 型別 | 預設值 | 說明 |
54
+ |------|------|------|--------|------|
55
+ | `--port` | `-p` | number | 5478 | 服務連接埠 |
56
+ | `--dir` | `-d` | path | `"./"` | 元件目錄 |
57
+ | `--version` | `-v` | — | — | 顯示版本 |
58
+ | `--help` | `-h` | — | — | 顯示說明 |
59
+
60
+ 範例:
61
+
62
+ ```bash
63
+ comphub -p 8080 # 自訂連接埠
64
+ comphub -d ./src # 自訂元件目錄
65
+ ```
66
+
67
+ ### 管理指令
68
+
69
+ | 指令 | 說明 |
70
+ |------|------|
71
+ | `comphub` | 啟動開發伺服器 |
72
+ | `comphub status` | 列出所有正在執行的專案 |
73
+ | `comphub stop <hash>` | 停止指定專案 |
74
+ | `comphub stop --all` | 停止所有專案 |
75
+ | `comphub kill` | 關閉所有服務 |
76
+
77
+ 範例:
78
+
79
+ ```bash
80
+ # 查看正在執行的專案
81
+ comphub status
82
+
83
+ # 停止某個專案
84
+ comphub stop 94525912
85
+
86
+ # 停止所有專案
87
+ comphub stop --all
88
+
89
+ # 關閉全部
90
+ comphub kill
91
+ ```
92
+
93
+ ### 多專案
94
+
95
+ 在不同的連接埠上同時執行多個專案:
96
+
97
+ ```bash
98
+ cd /path/to/project-a && comphub
99
+ cd /path/to/project-b && comphub
100
+ comphub status # 查看全部
101
+ ```
102
+
103
+ ## 設定
104
+
105
+ 在專案根目錄建立 `.comphub.json` 或 `.comphub.js`:
106
+
107
+ ```json
108
+ {
109
+ "dir": "./src",
110
+ "allowDebug": false
111
+ }
112
+ ```
113
+
114
+ ```javascript
115
+ module.exports = {
116
+ dir: './src',
117
+ allowDebug: false
118
+ }
119
+ ```
120
+
121
+ | 選項 | 型別 | 預設值 | 說明 |
122
+ |------|------|--------|------|
123
+ | `dir` | string | `"./"` | 元件根目錄 |
124
+ | `allowDebug` | boolean | false | 啟用偵錯模式 |
125
+ | `proxy` | object | — | 自訂代理規則 |
126
+
127
+ **優先順序**:命令列參數 > 設定檔 > 預設值
128
+
129
+ ## 元件規範
130
+
131
+ - 元件以**資料夾**形式上傳——資料夾名稱即元件名稱
132
+ - 進入點:`index.vue`(Vue)或 `index.jsx` / `index.tsx`(React)
133
+ - 建議包含說明用法的 `README.md`
134
+ - 選用的 `comp.json` 可存放元件後設資料(名稱、版本、依賴等)
135
+ - 選用的 `demo/` 目錄可存放預覽設定
136
+
137
+ ## 連結
138
+
139
+ - 官網:<https://www.comphub.cn>
140
+ - 文件站:<https://docs.comphub.cn>
141
+
142
+ ## 授權
143
+
144
+ [MIT](LICENSE)
package/dist/cli.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var ir=Object.create;var Pe=Object.defineProperty;var sr=Object.getOwnPropertyDescriptor;var ar=Object.getOwnPropertyNames;var lr=Object.getPrototypeOf,cr=Object.prototype.hasOwnProperty;var S=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var ur=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ar(e))!cr.call(i,o)&&o!==t&&Pe(i,o,{get:()=>e[o],enumerable:!(r=sr(e,o))||r.enumerable});return i};var d=(i,e,t)=>(t=i!=null?ir(lr(i)):{},ur(e||!i||!i.__esModule?Pe(t,"default",{value:i,enumerable:!0}):t,i));var U=S(ee=>{var Y=class extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Q=class extends Y{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};ee.CommanderError=Y;ee.InvalidArgumentError=Q});var j=S(re=>{var{InvalidArgumentError:ln}=U(),te=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new ln(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function cn(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}re.Argument=te;re.humanReadableArgName=cn});var ne=S(ft=>{var{humanReadableArgName:un}=j(),oe=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(r=>!r._hidden);if(e._hasImplicitHelpCommand()){let[,r,o]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),n=e.createCommand(r).helpOption(!1);n.description(e._helpCommandDescription),o&&n.arguments(o),t.push(n)}return this.sortSubcommands&&t.sort((r,o)=>r.name().localeCompare(o.name())),t}compareOptions(e,t){let r=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(n=>!n.hidden),r=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),o=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(r||o){let n;r?o?n=e.createOption(e._helpFlags,e._helpDescription):n=e.createOption(e._helpShortFlag,e._helpDescription):n=e.createOption(e._helpLongFlag,e._helpDescription),t.push(n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let o=r.options.filter(n=>!n.hidden);t.push(...o)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e._args.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e._args.find(t=>t.description)?e._args:[]}subcommandTerm(e){let t=e._args.map(r=>un(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,o)=>Math.max(r,t.subcommandTerm(o).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,o)=>Math.max(r,t.argumentTerm(o).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let o=e.parent;o;o=o.parent)r=o.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),o=t.helpWidth||80,n=2,s=2;function l(m,x){if(x){let nr=`${m.padEnd(r+s)}${x}`;return t.wrap(nr,o-n,r+s)}return m}function a(m){return m.join(`
3
+ `).replace(/^/gm," ".repeat(n))}let c=[`Usage: ${t.commandUsage(e)}`,""],u=t.commandDescription(e);u.length>0&&(c=c.concat([u,""]));let p=t.visibleArguments(e).map(m=>l(t.argumentTerm(m),t.argumentDescription(m)));p.length>0&&(c=c.concat(["Arguments:",a(p),""]));let _=t.visibleOptions(e).map(m=>l(t.optionTerm(m),t.optionDescription(m)));if(_.length>0&&(c=c.concat(["Options:",a(_),""])),this.showGlobalOptions){let m=t.visibleGlobalOptions(e).map(x=>l(t.optionTerm(x),t.optionDescription(x)));m.length>0&&(c=c.concat(["Global Options:",a(m),""]))}let O=t.visibleCommands(e).map(m=>l(t.subcommandTerm(m),t.subcommandDescription(m)));return O.length>0&&(c=c.concat(["Commands:",a(O),""])),c.join(`
4
+ `)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,r,o=40){if(e.match(/[\n]\s+/))return e;let n=t-r;if(n<o)return e;let s=e.slice(0,r),l=e.slice(r),a=" ".repeat(r),c=new RegExp(".{1,"+(n-1)+"}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)","g"),u=l.match(c)||[];return s+u.map((p,_)=>(p.slice(-1)===`
5
+ `&&(p=p.slice(0,p.length-1)),(_>0?a:"")+p.trimRight())).join(`
6
+ `)}};ft.Help=oe});var ae=S(G=>{var{InvalidArgumentError:pn}=U(),ie=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=Et(e);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){return this.implied=Object.assign(this.implied||{},e),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new pn(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return hn(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},se=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let o=this.negativeOptions.get(r).presetArg,n=o!==void 0?o:!1;return t.negate===(n===e)}};function hn(i){return i.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Et(i){let e,t,r=i.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),t=r.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}G.Option=ie;G.splitOptionFlags=Et;G.DualOptions=se});var Ot=S(gt=>{function mn(i,e){if(Math.abs(i.length-e.length)>3)return Math.max(i.length,e.length);let t=[];for(let r=0;r<=i.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=i.length;o++){let n=1;i[o-1]===e[r-1]?n=0:n=1,t[o][r]=Math.min(t[o-1][r]+1,t[o][r-1]+1,t[o-1][r-1]+n),o>1&&r>1&&i[o-1]===e[r-2]&&i[o-2]===e[r-1]&&(t[o][r]=Math.min(t[o][r],t[o-2][r-2]+1))}return t[i.length][e.length]}function _n(i,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=i.startsWith("--");t&&(i=i.slice(2),e=e.map(s=>s.slice(2)));let r=[],o=3,n=.4;return e.forEach(s=>{if(s.length<=1)return;let l=mn(i,s),a=Math.max(i.length,s.length);(a-l)/a>n&&(l<o?(o=l,r=[s]):l===o&&r.push(s))}),r.sort((s,l)=>s.localeCompare(l)),t&&(r=r.map(s=>`--${s}`)),r.length>1?`
7
+ (Did you mean one of ${r.join(", ")}?)`:r.length===1?`
8
+ (Did you mean ${r[0]}?)`:""}gt.suggestSimilar=_n});var Mt=S(St=>{var dn=require("events").EventEmitter,le=require("child_process"),P=require("path"),ce=require("fs"),h=require("process"),{Argument:fn,humanReadableArgName:En}=j(),{CommanderError:ue}=U(),{Help:gn}=ne(),{Option:Ct,splitOptionFlags:On,DualOptions:Cn}=ae(),{suggestSimilar:At}=Ot(),pe=class i extends dn{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this._args=[],this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>h.stdout.write(t),writeErr:t=>h.stderr.write(t),getOutHelpWidth:()=>h.stdout.isTTY?h.stdout.columns:void 0,getErrHelpWidth:()=>h.stderr.isTTY?h.stderr.columns:void 0,outputError:(t,r)=>r(t)},this._hidden=!1,this._hasHelpOption=!0,this._helpFlags="-h, --help",this._helpDescription="display help for command",this._helpShortFlag="-h",this._helpLongFlag="--help",this._addImplicitHelpCommand=void 0,this._helpCommandName="help",this._helpCommandnameAndArgs="help [command]",this._helpCommandDescription="display help for command",this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._hasHelpOption=e._hasHelpOption,this._helpFlags=e._helpFlags,this._helpDescription=e._helpDescription,this._helpShortFlag=e._helpShortFlag,this._helpLongFlag=e._helpLongFlag,this._helpCommandName=e._helpCommandName,this._helpCommandnameAndArgs=e._helpCommandnameAndArgs,this._helpCommandDescription=e._helpCommandDescription,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}command(e,t,r){let o=t,n=r;typeof o=="object"&&o!==null&&(n=o,o=null),n=n||{};let[,s,l]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return o&&(a.description(o),a._executableHandler=!0),n.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(n.noHelp||n.hidden),a._executableFile=n.executableFile||null,l&&a.arguments(l),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),o?this:a}createCommand(e){return new i(e)}createHelp(){return Object.assign(new gn,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
9
+ - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this.commands.push(e),e.parent=this,this}createArgument(e,t){return new fn(e,t)}argument(e,t,r,o){let n=this.createArgument(e,t);return typeof r=="function"?n.default(o).argParser(r):n.default(r),this.addArgument(n),this}arguments(e){return e.split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this._args.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this._args.push(e),this}addHelpCommand(e,t){return e===!1?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,typeof e=="string"&&(this._helpCommandName=e.split(" ")[0],this._helpCommandnameAndArgs=e),this._helpCommandDescription=t||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return this._addImplicitHelpCommand===void 0?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
10
+ Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,r){this._exitCallback&&this._exitCallback(new ue(e,t,r)),h.exit(e)}action(e){let t=r=>{let o=this._args.length,n=r.slice(0,o);return this._storeOptionsAsProperties?n[o]=this:n[o]=this.opts(),n.push(this),e.apply(this,n)};return this._actionHandler=t,this}createOption(e,t){return new Ct(e,t)}addOption(e){let t=e.name(),r=e.attributeName();if(e.negate){let n=e.long.replace(/^--no-/,"--");this._findOption(n)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");this.options.push(e);let o=(n,s,l)=>{n==null&&e.presetArg!==void 0&&(n=e.presetArg);let a=this.getOptionValue(r);if(n!==null&&e.parseArg)try{n=e.parseArg(n,a)}catch(c){if(c.code==="commander.invalidArgument"){let u=`${s} ${c.message}`;this.error(u,{exitCode:c.exitCode,code:c.code})}throw c}else n!==null&&e.variadic&&(n=e._concatValue(n,a));n==null&&(e.negate?n=!1:e.isBoolean()||e.optional?n=!0:n=""),this.setOptionValueWithSource(r,n,l)};return this.on("option:"+t,n=>{let s=`error: option '${e.flags}' argument '${n}' is invalid.`;o(n,s,"cli")}),e.envVar&&this.on("optionEnv:"+t,n=>{let s=`error: option '${e.flags}' value '${n}' from env '${e.envVar}' is invalid.`;o(n,s,"env")}),this}_optionEx(e,t,r,o,n){if(typeof t=="object"&&t instanceof Ct)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let s=this.createOption(t,r);if(s.makeOptionMandatory(!!e.mandatory),typeof o=="function")s.default(n).argParser(o);else if(o instanceof RegExp){let l=o;o=(a,c)=>{let u=l.exec(a);return u?u[0]:c},s.default(n).argParser(o)}else s.default(o);return this.addOption(s)}option(e,t,r,o){return this._optionEx({},e,t,r,o)}requiredOption(e,t,r,o){return this._optionEx({mandatory:!0},e,t,r,o)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){if(this._passThroughOptions=!!e,this.parent&&e&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(e=!0){if(this._storeOptionsAsProperties=!!e,this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return H(this).forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");t=t||{},e===void 0&&(e=h.argv,h.versions&&h.versions.electron&&(t.from="electron")),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":h.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,t){let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_executeSubCommand(e,t){t=t.slice();let r=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function n(u,p){let _=P.resolve(u,p);if(ce.existsSync(_))return _;if(o.includes(P.extname(p)))return;let O=o.find(m=>ce.existsSync(`${_}${m}`));if(O)return`${_}${O}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=e._executableFile||`${this._name}-${e._name}`,l=this._executableDir||"";if(this._scriptPath){let u;try{u=ce.realpathSync(this._scriptPath)}catch{u=this._scriptPath}l=P.resolve(P.dirname(u),l)}if(l){let u=n(l,s);if(!u&&!e._executableFile&&this._scriptPath){let p=P.basename(this._scriptPath,P.extname(this._scriptPath));p!==this._name&&(u=n(l,`${p}-${e._name}`))}s=u||s}r=o.includes(P.extname(s));let a;h.platform!=="win32"?r?(t.unshift(s),t=Pt(h.execArgv).concat(t),a=le.spawn(h.argv[0],t,{stdio:"inherit"})):a=le.spawn(s,t,{stdio:"inherit"}):(t.unshift(s),t=Pt(h.execArgv).concat(t),a=le.spawn(h.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(p=>{h.on(p,()=>{a.killed===!1&&a.exitCode===null&&a.kill(p)})});let c=this._exitCallback;c?a.on("close",()=>{c(new ue(h.exitCode||0,"commander.executeSubCommandAsync","(close)"))}):a.on("close",h.exit.bind(h)),a.on("error",u=>{if(u.code==="ENOENT"){let p=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",_=`'${s}' does not exist
11
+ - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
12
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
13
+ - ${p}`;throw new Error(_)}else if(u.code==="EACCES")throw new Error(`'${s}' not executable`);if(!c)h.exit(1);else{let p=new ue(1,"commander.executeSubCommandAsync","(error)");p.nestedError=u,c(p)}}),this.runningCommand=a}_dispatchSubcommand(e,t,r){let o=this._findCommand(e);o||this.help({error:!0});let n;return n=this._chainOrCallSubCommandHook(n,o,"preSubcommand"),n=this._chainOrCall(n,()=>{if(o._executableHandler)this._executeSubCommand(o,t.concat(r));else return o._parseCommand(t,r)}),n}_checkNumberOfArguments(){this._args.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this._args.length>0&&this._args[this._args.length-1].variadic)&&this.args.length>this._args.length&&this._excessArguments(this.args)}_processArguments(){let e=(r,o,n)=>{let s=o;if(o!==null&&r.parseArg)try{s=r.parseArg(o,n)}catch(l){if(l.code==="commander.invalidArgument"){let a=`error: command-argument value '${o}' is invalid for argument '${r.name()}'. ${l.message}`;this.error(a,{exitCode:l.exitCode,code:l.code})}throw l}return s};this._checkNumberOfArguments();let t=[];this._args.forEach((r,o)=>{let n=r.defaultValue;r.variadic?o<this.args.length?(n=this.args.slice(o),r.parseArg&&(n=n.reduce((s,l)=>e(r,l,s),r.defaultValue))):n===void 0&&(n=[]):o<this.args.length&&(n=this.args[o],r.parseArg&&(n=e(r,n,r.defaultValue))),t[o]=n}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e,o=[];return H(this).reverse().filter(n=>n._lifeCycleHooks[t]!==void 0).forEach(n=>{n._lifeCycleHooks[t].forEach(s=>{o.push({hookedCommand:n,callback:s})})}),t==="postAction"&&o.reverse(),o.forEach(n=>{r=this._chainOrCall(r,()=>n.callback(n.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let o=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(n=>{o=this._chainOrCall(o,()=>n(this,t))}),o}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._hasImplicitHelpCommand()&&e[0]===this._helpCommandName)return e.length===1&&this.help(),this._dispatchSubcommand(e[1],[],[this._helpLongFlag]);if(this._defaultCommandName)return Tt(this,t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),Tt(this,r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},n=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(n,e,t)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent&&this.parent.listenerCount(n))o(),this._processArguments(),this.parent.emit(n,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){for(let e=this;e;e=e.parent)e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let o=r.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let o=e.find(n=>r.conflictsWith.includes(n.attributeName()));o&&this._conflictingOption(r,o)})}_checkForConflictingOptions(){for(let e=this;e;e=e.parent)e._checkForConflictingLocalOptions()}parseOptions(e){let t=[],r=[],o=t,n=e.slice();function s(a){return a.length>1&&a[0]==="-"}let l=null;for(;n.length;){let a=n.shift();if(a==="--"){o===r&&o.push(a),o.push(...n);break}if(l&&!s(a)){this.emit(`option:${l.name()}`,a);continue}if(l=null,s(a)){let c=this._findOption(a);if(c){if(c.required){let u=n.shift();u===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,u)}else if(c.optional){let u=null;n.length>0&&!s(n[0])&&(u=n.shift()),this.emit(`option:${c.name()}`,u)}else this.emit(`option:${c.name()}`);l=c.variadic?c:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let c=this._findOption(`-${a[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,a.slice(2)):(this.emit(`option:${c.name()}`),n.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let c=a.indexOf("="),u=this._findOption(a.slice(0,c));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,a.slice(c+1));continue}}if(s(a)&&(o=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(a)){t.push(a),n.length>0&&r.push(...n);break}else if(a===this._helpCommandName&&this._hasImplicitHelpCommand()){t.push(a),n.length>0&&t.push(...n);break}else if(this._defaultCommandName){r.push(a),n.length>0&&r.push(...n);break}}if(this._passThroughOptions){o.push(a),n.length>0&&o.push(...n);break}o.push(a)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let o=this.options[r].attributeName();e[o]=o===this._versionOptionName?this._version:this[o]}return e}return this._optionValues}optsWithGlobals(){return H(this).reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
14
+ `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
15
+ `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
16
+ `),this.outputHelp({error:!0}));let r=t||{},o=r.exitCode||1,n=r.code||"commander.error";this._exit(o,n,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in h.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,h.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Cn(this.options),t=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(o=>!t(o)).forEach(o=>{this.setOptionValueWithSource(o,r.implied[o],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let r=s=>{let l=s.attributeName(),a=this.getOptionValue(l),c=this.options.find(p=>p.negate&&l===p.attributeName()),u=this.options.find(p=>!p.negate&&l===p.attributeName());return c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg)?c:u||s},o=s=>{let l=r(s),a=l.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${l.envVar}'`:`option '${l.flags}'`},n=`error: ${o(e)} cannot be used with ${o(t)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],n=this;do{let s=n.createHelp().visibleOptions(n).filter(l=>l.long).map(l=>l.long);o=o.concat(s),n=n.parent}while(n&&!n._enablePositionalOptions);t=At(e,o)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this._args.length,r=t===1?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(n=>{o.push(n.name()),n.alias()&&o.push(n.alias())}),t=At(e,o)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let o=this.createOption(t,r);return this._versionOptionName=o.attributeName(),this.options.push(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${e}
17
+ `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this._args.map(r=>En(r));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=P.basename(e,P.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},r;return t.error?r=o=>this._outputConfiguration.writeErr(o):r=o=>this._outputConfiguration.writeOut(o),t.write=e.write||r,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getHelpContext(e);H(this).reverse().forEach(n=>n.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let o=this.helpInformation(r);if(t&&(o=t(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(o),this.emit(this._helpLongFlag),this.emit("afterHelp",r),H(this).forEach(n=>n.emit("afterAllHelp",r))}helpOption(e,t){if(typeof e=="boolean")return this._hasHelpOption=e,this;this._helpFlags=e||this._helpFlags,this._helpDescription=t||this._helpDescription;let r=On(this._helpFlags);return this._helpShortFlag=r.shortFlag,this._helpLongFlag=r.longFlag,this}help(e){this.outputHelp(e);let t=h.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
18
+ Expecting one of '${r.join("', '")}'`);let o=`${e}Help`;return this.on(o,n=>{let s;typeof t=="function"?s=t({error:n.error,command:n.command}):s=t,s&&n.write(`${s}
19
+ `)}),this}};function Tt(i,e){i._hasHelpOption&&e.find(r=>r===i._helpLongFlag||r===i._helpShortFlag)&&(i.outputHelp(),i._exit(0,"commander.helpDisplayed","(outputHelp)"))}function Pt(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",o="9229",n;return(n=e.match(/^(--inspect(-brk)?)$/))!==null?t=n[1]:(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=n[1],/^\d+$/.test(n[3])?o=n[3]:r=n[3]):(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=n[1],r=n[3],o=n[4]),t&&o!=="0"?`${t}=${r}:${parseInt(o)+1}`:e})}function H(i){let e=[];for(let t=i;t;t=t.parent)e.push(t);return e}St.Command=pe});var Lt=S((C,bt)=>{var{Argument:An}=j(),{Command:Rt}=Mt(),{CommanderError:Tn,InvalidArgumentError:It}=U(),{Help:Pn}=ne(),{Option:Sn}=ae();C=bt.exports=new Rt;C.program=C;C.Argument=An;C.Command=Rt;C.CommanderError=Tn;C.Help=Pn;C.InvalidArgumentError=It;C.InvalidOptionArgumentError=It;C.Option=Sn});var Ht=S((Ai,me)=>{"use strict";var Dn=require("net"),W=class extends Error{constructor(e){super(`${e} is locked`)}},N={old:new Set,young:new Set},wn=1e3*15,B,Ut=i=>new Promise((e,t)=>{let r=Dn.createServer();r.unref(),r.on("error",t),r.listen(i,()=>{let{port:o}=r.address();r.close(()=>{e(o)})})}),yn=function*(i){i&&(yield*i),yield 0};me.exports=async i=>{let e;i&&(e=typeof i.port=="number"?[i.port]:i.port),B===void 0&&(B=setInterval(()=>{N.old=N.young,N.young=new Set},wn),B.unref&&B.unref());for(let t of yn(e))try{let r=await Ut({...i,port:t});for(;N.old.has(r)||N.young.has(r);){if(t!==0)throw new W(t);r=await Ut({...i,port:t})}return N.young.add(r),r}catch(r){if(!["EADDRINUSE","EACCES"].includes(r.code)&&!(r instanceof W))throw r}throw new Error("No available ports found")};me.exports.makeRange=(i,e)=>{if(!Number.isInteger(i)||!Number.isInteger(e))throw new TypeError("`from` and `to` must be integer numbers");if(i<1024||i>65535)throw new RangeError("`from` must be between 1024 and 65535");if(e<1024||e>65536)throw new RangeError("`to` must be between 1024 and 65536");if(e<i)throw new RangeError("`to` must be greater than or equal to `from`");return function*(r,o){for(let n=r;n<=o;n++)yield n}(i,e)}});var w=d(require("fs")),mt=d(require("http")),y=d(require("path"));var nt=d(require("path")),it=d(require("os"));var pr="Comp Hub",hr="main",mr="container",_r="item",dr="/__global_config__",fr="local://",Er="comphubConfig",gr="https://intranet.comphub.cn",Or="https://iframe.comphub.cn",Cr="__remote__",Ar="__local__",Tr="__admin__",Pr="https://api.comphub.cn",Sr="http://localhost:7002",Mr="http://127.0.0.1:5000",Rr="http://localhost:5001",Ir="http://localhost:3580",br="https://apiadmin.comphub.cn",Lr="https://admin.comphub.cn",Dr="/_module_load_prefix_",wr="/_node_modules_load_prefix_",yr="/_comp_preview_prefix_local_",Nr="/__proxy__",xr="/__master__",Ur="authorization",Hr="x-refresh-token",$r="accept-language",vr="X-Token-Refreshed",Fr="team-id",Vr="comp-hub-db",kr="file-compiled",Yr="https://oss.comphub.cn",jr="oss:sts:token",Gr="oss:sts:expire",Br="https://prebuild.comphub.cn",Wr="/dev",Kr="/prod",qr="/node_modules/.prebuild_module",Xr="_metadata.json",Jr="vue/dist/vue.esm-bundler.js",Zr="react-jsx-loader",zr="vue3-sfc-loader",Qr="vue2-sfc-loader",eo="sass-compiler",to="less-compiler",Se="react",ro={COMP_FRAMEWORK_VUE:"vue",COMP_FRAMEWORK_REACT:Se},oo="comp.json",no="README.md",io="main.js",so="index.vue",ao=["index.jsx","index.js","index.tsx"],lo="/.comp_hub_temp",co="screenshot_mini.png",uo=1024*1024*10,po=1024*1024*3,ho=30,Me="list_local",Re="list_remote",mo={COMP_LIST_TYPE_LOCAL:Me,COMP_LIST_TYPE_REMOTE:Re},Ie="config",be="error",Le="dir",De="preview",we="extra",ye="deps",Ne="readme",xe="upgradeLog",_o={TAB_TYPE_CONFIG:Ie,TAB_TYPE_ERROR:be,TAB_TYPE_DIR:Le,TAB_TYPE_PREVIEW:De,TAB_TYPE_EXTRA:we,TAB_TYPE_DEPS:ye,TAB_TYPE_README:Ne,TAB_TYPE_UPGRADE_LOG:xe},Ue="mini",He="full",fo={COMP_EDIT_TAB_TYPE_MINI:Ue,COMP_EDIT_TAB_TYPE_FULL:He},$e="EDIT",ve="ADD",Eo={DIALOG_TYPE_EDIT:$e,DIALOG_TYPE_ADD:ve},Fe="ONLY_INSTALL",Ve="AUTO",ke="MAJOR_VERSION",Ye="MINOR_VERSION",je="EXACT_VERSION",go={COMP_MATCH_TYPE_ONLY_INSTALL:Fe,COMP_MATCH_TYPE_AUTO:Ve,COMP_MATCH_TYPE_MAJOR_VERSION:ke,COMP_MATCH_TYPE_MINOR_VERSION:Ye,COMP_MATCH_TYPE_EXACT_VERSION:je},Ge="online",Be="offline",Oo={COMP_UPDATE_TYPE_ONLINE:Ge,COMP_UPDATE_TYPE_OFFLINE:Be},We="NOT_EXIST",Ke="EXIST",Co={COMP_CHECK_STATUS_NOT_EXIST:We,COMP_CHECK_STATUS_EXIST:Ke},Ao="__id__",To=0,Po=1,So=-1,qe="checkPreviewListForm",Xe="checkExtraInfoForm",Je="checkCompConfig",Ze="checkUpgradeLogForm",ze="getCompError",Qe="afterCompDel",et="afterCompCancelCollect",tt="afterCompRenderRetry",rt="openCompTerminal",Mo={COMP_METHOD_KEY_CHECK_PREVIEW_LIST_FORM:qe,COMP_METHOD_KEY_CHECK_EXTRA_INFO_FORM:Xe,COMP_METHOD_KEY_CHECK_COMP_CONFIG:Je,COMP_METHOD_KEY_CHECK_UPGRADE_LOG_FORM:Ze,COMP_METHOD_KEY_GET_COMP_ERROR:ze,COMP_METHOD_KEY_AFTER_COMP_DEL:Qe,COMP_METHOD_KEY_AFTER_COMP_CANCEL_COLLECT:et,COMP_METHOD_KEY_AFTER_COMP_RENDER_RETRY:tt,COMP_METHOD_KEY_OPEN_COMP_TERMINAL:rt},Ro="compListStore",Io="compEditStore",bo="callbacks",Lo={CONTAINER:{SHARE:"share",COLLECT:"collect",LOCAL:"local",MINE:"mine",SIMILAR:"similar",TEAM_ALL:"teamAll",TEAM_MINE:"teamMine",TEAM_GROUP:"teamGroup",TEAM_ADD:"teamAdd"},ITEM:{PREVIEW_REMOTE:"previewRemote",PREVIEW_LOCAL:"previewLocal",CAROUSEL_REMOTE:"carouselRemote",CAROUSEL_LOCAL:"carouselLocal",EDIT_PANEL:"editPanel",STORAGE_WORKER:"storageWorker"}},Do="http://127.0.0.1",wo="http://localhost:8095",yo="http://localhost:8096",No="http://localhost:5198",xo="http://localhost:3056",Uo="https://www.comphub.cn",Ho="http://localhost:8101",$o="https://render.comphub.cn",vo="/item",Fo="/container",Vo="CREATE",ko="JOIN",Yo="EXIT",jo="teamAddMyComp",Go="teamCompList",Bo="teamCompGroupList",Wo="teamMyCompList",Ko="teamMyCompUpdate",qo="__v__",Xo="local",Jo="prod",Zo="local",zo="prod",Qo="http://localhost:5173",en="https://docs.comphub.cn",tn=20,rn=20,on="SUPER_ADMIN",nn="ADMIN",ot=Object.freeze(Object.defineProperty({__proto__:null,ACCEPT_LANGUAGE_HEADER_NAME:$r,ADMIN_SERVICE_PREFIX:Tr,ADMIN_SERVICE_URL_DEV:Ir,ADMIN_SERVICE_URL_PROD:br,ADMIN_WEB_URL_PROD:Lr,AUTHORIZATION_HEADER_NAME:Ur,CACHE_KEY_STS_EXPIRE_TIME:Gr,CACHE_KEY_STS_TOKEN:jr,COMPHUB_CONFIG_KEY:Er,COMP_ACTION_ICON_HEIGHT:rn,COMP_ACTION_ICON_WIDTH:tn,COMP_CHECK_STATUSES:Co,COMP_CHECK_STATUS_EXIST:Ke,COMP_CHECK_STATUS_NOT_EXIST:We,COMP_CONFIG_FILENAME:oo,COMP_EDIT_TAB_TYPES:fo,COMP_EDIT_TAB_TYPE_FULL:He,COMP_EDIT_TAB_TYPE_MINI:Ue,COMP_ENTRY_FILE:io,COMP_FIELD_COMP_ID:Ao,COMP_FRAMEWORK_REACT:Se,COMP_FRAMEWORK_TYPES:ro,COMP_FRAMEWORK_VUE:"vue",COMP_HUB_DEV_DOCS_URL:Qo,COMP_HUB_PROD_DOCS_URL:en,COMP_LIST_TYPES:mo,COMP_LIST_TYPE_LOCAL:Me,COMP_LIST_TYPE_REMOTE:Re,COMP_MATCH_TYPES:go,COMP_MATCH_TYPE_AUTO:Ve,COMP_MATCH_TYPE_EXACT_VERSION:je,COMP_MATCH_TYPE_MAJOR_VERSION:ke,COMP_MATCH_TYPE_MINOR_VERSION:Ye,COMP_MATCH_TYPE_ONLY_INSTALL:Fe,COMP_METHOD_KEY_AFTER_COMP_CANCEL_COLLECT:et,COMP_METHOD_KEY_AFTER_COMP_DEL:Qe,COMP_METHOD_KEY_AFTER_COMP_RENDER_RETRY:tt,COMP_METHOD_KEY_CHECK_COMP_CONFIG:Je,COMP_METHOD_KEY_CHECK_EXTRA_INFO_FORM:Xe,COMP_METHOD_KEY_CHECK_PREVIEW_LIST_FORM:qe,COMP_METHOD_KEY_CHECK_UPGRADE_LOG_FORM:Ze,COMP_METHOD_KEY_GET_COMP_ERROR:ze,COMP_METHOD_KEY_OPEN_COMP_TERMINAL:rt,COMP_PREVIEW_PREFIX_LOCAL:yr,COMP_README_FILENAME:no,COMP_SCREENSHOT_MINI_FILENAME:co,COMP_SUBMIT_MAX_FILE_COUNT:ho,COMP_SUBMIT_MAX_SINGLE_FILE_SIZE:po,COMP_SUBMIT_MAX_TOTAL_SIZE:uo,COMP_TEMP_DIR:lo,COMP_UPDATE_TYPES:Oo,COMP_UPDATE_TYPE_OFFLINE:Be,COMP_UPDATE_TYPE_ONLINE:Ge,COMP_USE_ENTRY_FILE:so,COMP_USE_ENTRY_FILE_REACT:ao,DIALOG_TYPES:Eo,DIALOG_TYPE_ADD:ve,DIALOG_TYPE_EDIT:$e,FILE_MANAGER_DIRNAME:fr,GLOBAL_CONFIG_PATH:dr,IFRAME_CONTAINER_WEBSITE_PATH:Fo,IFRAME_HOST:Do,IFRAME_ITEM_WEBSITE_PATH:vo,IFRAME_ROUTES:Lo,INDEX_DB_NAME:Vr,INDEX_DB_TABLE_NAME:kr,LESS_COMPILER_KEY:to,LOCAL_CHILD_IFRAME_URL:wo,LOCAL_ITEM_EXTRANET_URL:Ho,LOCAL_LEAF_IFRAME_URL:yo,LOCAL_MAIN_EXTRANET_URL:xo,LOCAL_MIDWAY_ENV_LOCAL:Xo,LOCAL_MIDWAY_ENV_PROD:Jo,LOCAL_SERVICE_PREFIX:Ar,LOCAL_SERVICE_URL_DEV:Mr,LOCAL_SERVICE_URL_DEV_SUB:Rr,LOCAL_TOP_IFRAME_URL:No,MASTER_API_PREFIX:xr,META_FILE_NAME:Xr,MODULE_LOAD_PREFIX:Dr,NODE_MODULES_LOAD_PREFIX:wr,OSS_CUSTOM_DOMAIN:Yr,PREBUILD_HOST:Br,PREBUILD_MAX_SINGLE_FILE_SIZE:52428800,PREBUILD_MODULE_DIR:qr,PREBUILD_MODULE_DIR_DEV:Wr,PREBUILD_MODULE_DIR_PROD:Kr,PROVIDE_KEYS:Mo,PROVIDE_KEY_CALLBACKS:bo,PROVIDE_KEY_COMP_EDIT_STORE:Io,PROVIDE_KEY_COMP_LIST_STORE:Ro,PROXY_PATH_PREFIX:Nr,REACT_JSX_LOADER_KEY:Zr,REFRESH_TOKEN_HEADER_NAME:Hr,REMOTE_ITEM_EXTRANET_URL:$o,REMOTE_MAIN_EXTRANET_URL:Uo,REMOTE_MIDWAY_ENV_LOCAL:Zo,REMOTE_MIDWAY_ENV_PROD:zo,REMOTE_SERVICE_PREFIX:Cr,REMOTE_SERVICE_URL_DEV:Sr,REMOTE_SERVICE_URL_PROD:Pr,ROLE_CODE_ADMIN:nn,ROLE_CODE_SUPER_ADMIN:on,ROUTE_STATE_KEY_VERSION:qo,SASS_COMPILER_KEY:eo,SCOPE_ID_TEAM_ADD_MY_COMP:jo,SCOPE_ID_TEAM_COMP_GROUP_LIST:Bo,SCOPE_ID_TEAM_COMP_LIST:Go,SCOPE_ID_TEAM_MY_COMP_LIST:Wo,SCOPE_ID_TEAM_MY_COMP_UPDATE:Ko,SITE_TITLE:pr,TAB_TYPES:_o,TAB_TYPE_CONFIG:Ie,TAB_TYPE_DEPS:ye,TAB_TYPE_DIR:Le,TAB_TYPE_ERROR:be,TAB_TYPE_EXTRA:we,TAB_TYPE_PREVIEW:De,TAB_TYPE_README:Ne,TAB_TYPE_UPGRADE_LOG:xe,TEAM_ID_HEADER_NAME:Fr,TEAM_OPERATE_TYPE_CREATE:Vo,TEAM_OPERATE_TYPE_EXIT:Yo,TEAM_OPERATE_TYPE_JOIN:ko,VERSION_COMPARE_GREATER:Po,VERSION_COMPARE_LESS:So,VERSION_COMPARE_SAME:To,VUE2_SFC_LOADER_KEY:Qr,VUE3_SFC_LOADER_KEY:zr,VUE_ESM_BUNDLER:Jr,WEBSITE_OSS_URL_IFRAME:Or,WEBSITE_OSS_URL_MAIN:gr,WEBSITE_PATH_CONTAINER:mr,WEBSITE_PATH_ITEM:_r,WEBSITE_PATH_MAIN:hr,X_TOKEN_REFRESHED_HEADER_NAME:vr},Symbol.toStringTag,{value:"Module"}));var v=5478,st=ot.REMOTE_SERVICE_URL_PROD,I=nt.default.join(it.default.tmpdir(),".comphub","master.json"),E={PREFIX:"/__master__",HEALTH:"/__master__/health",REGISTER:"/__master__/register",DEREGISTER:"/__master__/deregister",PROJECTS:"/__master__/projects",SHUTDOWN:"/__master__/shutdown"},at=500,lt=40,ct=2e3,F=5e3;var z=d(require("fs")),Z=d(require("path")),ut=d(require("crypto"));function V(i){return JSON.parse(z.default.readFileSync(i,"utf8"))}function pt(i){let e=i;for(let t=0;t<12;t++){try{let o=Z.default.join(e,"package.json");if(z.default.existsSync(o)){let n=V(o);if(n&&n.name==="comp-hub")return e}}catch{}let r=Z.default.dirname(e);if(r===e)break;e=r}return null}function ht(i){return ut.default.createHash("sha256").update(i).digest("hex").slice(0,8)}function g(i,e){return`http://localhost:${i}${e}`}var f={cyan:i=>`\x1B[36m${i}\x1B[0m`,green:i=>`\x1B[32m${i}\x1B[0m`,white:i=>`\x1B[37m${i}\x1B[0m`,yellow:i=>`\x1B[33m${i}\x1B[0m`,red:i=>`\x1B[31m${i}\x1B[0m`};var k=pt(__dirname)||y.default.resolve(__dirname,"..");function _t(){let i=y.default.join(k,"package.json"),e=V(i),t=y.default.join(k,e.main||"dist/index.js");return{pkg:e,entry:t}}function sn(i){let e=y.default.join(i,".comphub.json"),t=y.default.join(i,".comphub.js");try{if(w.default.existsSync(e))return V(e)}catch{}try{if(w.default.existsSync(t)){let r=require(t);return r.default||r}}catch{}return{}}function dt(i,e){let t=sn(e);return{dir:i.dir||t.dir||"./",api:i.api||t.api,allowDebug:i.allowDebug!=null?i.allowDebug:t.allowDebug!=null?t.allowDebug:!1,proxy:i.proxy||t.proxy,port:i.port,logLevel:i.logLevel||t.logLevel||"info"}}async function T(){try{if(w.default.existsSync(I)){let i=JSON.parse(w.default.readFileSync(I,"utf8"));try{if(process.kill(i.pid,0),await an(i.managementPort))return i}catch{}try{w.default.unlinkSync(I)}catch{}}}catch{}return null}function an(i){return new Promise(e=>{let t=mt.default.get(`http://localhost:${i}${E.HEALTH}`,r=>{let o="";r.on("data",n=>o+=n),r.on("end",()=>{try{let n=JSON.parse(o);e(typeof n.status=="string")}catch{e(!1)}})});t.on("error",()=>e(!1)),t.setTimeout(2e3,()=>{t.destroy(),e(!1)})})}var Dt=d(Lt(),1),{program:si,createCommand:ai,createArgument:li,createOption:ci,CommanderError:ui,InvalidArgumentError:pi,InvalidOptionArgumentError:hi,Command:wt,Argument:mi,Option:b,Help:_i}=Dt.default;function he(i){let e=[{label:"d",divisor:86400},{label:"h",divisor:3600},{label:"m",divisor:60},{label:"s",divisor:1}],t=Math.floor(i),r=[];for(let{label:o,divisor:n}of e)if(t>=n){let s=Math.floor(t/n);t=t%n,r.push(`${s}${o}`)}return r.length>0?r.join(" "):"0s"}async function L(i){if(i.port!=null)return i.port;let e=await T();return e?e.managementPort:v}var Jt=d(require("fs")),Zt=d(require("path"));var yt=d(require("http")),Nt=d(require("https"));var Mn="/api/v2/upgrade/check";function Rn(i){return(i||st).replace(/\/+$/,"")}function In(i,e,t){return new Promise((r,o)=>{let n=i.startsWith("https:")?Nt.default:yt.default,s=JSON.stringify(e),l=new URL(i),a={hostname:l.hostname,port:l.port||(l.protocol==="https:"?443:80),path:l.pathname+l.search,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},c=n.request(a,u=>{let p="";u.setEncoding("utf8"),u.on("data",_=>p+=_),u.on("end",()=>{let _=p;try{_=JSON.parse(p)}catch{}r({status:u.statusCode||0,body:_})})});c.on("error",o),c.setTimeout(t||F,()=>{c.destroy(new Error("Request timeout"))}),c.write(s),c.end()})}function bn(i){if(!i||i.status!==200)throw new Error(i.status?`HTTP ${i.status}`:"No response");let e=i.body?.data;if(!e||typeof e.hasUpgrade!="boolean")throw new Error("Invalid response format");return{hasUpgrade:e.hasUpgrade,isForce:!!e.isForce,latestVersion:typeof e.latestVersion=="string"?e.latestVersion:""}}function Ln(i){return i.hasUpgrade&&i.isForce?"block":i.hasUpgrade?"notice":"none"}async function xt(i){let{base:e,compHubVersion:t,timeout:r,request:o=In}=i,n=`${Rn(e)}${Mn}`;try{let s=await o(n,{compHubVersion:t},r),l=bn(s);return{ok:!0,...l,verdict:Ln(l)}}catch(s){return{ok:!1,error:s?.message||String(s)}}}var Ft=d(require("fs")),Vt=d(require("path")),kt=require("child_process"),_e=d(Ht());var K=d(require("http"));function Nn(i){try{return JSON.parse(i)}catch{return i}}function $(i){return new Promise(e=>{let t=K.default.get(i,r=>{let o="";r.on("data",n=>o+=n),r.on("end",()=>e({ok:!0,status:r.statusCode,body:Nn(o)}))});t.on("error",r=>e({ok:!1,error:r.message})),t.setTimeout(ct,()=>{t.destroy(),e({ok:!1,error:"Request timeout"})})})}function M(i,e){return new Promise(t=>{let r=JSON.stringify(e),o=new URL(i),n={hostname:o.hostname,port:o.port,path:o.pathname,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},s=K.default.request(n,l=>{let a="";l.on("data",c=>a+=c),l.on("end",()=>{try{t({ok:!0,body:JSON.parse(a)})}catch{t({ok:!1,error:"Invalid JSON response"})}})});s.on("error",l=>t({ok:!1,error:l.message})),s.setTimeout(F,()=>{s.destroy(),t({ok:!1,error:"Request timeout"})}),s.write(r),s.end()})}function $t(i,e){return new Promise((t,r)=>{let o=new URL(i),n={hostname:o.hostname,port:o.port,path:o.pathname,method:"GET",headers:{Accept:"text/event-stream"}},s=K.default.request(n,l=>{if(l.statusCode!==200){r(new Error(`SSE connection failed (HTTP ${l.statusCode})`));return}let a="";l.on("data",c=>{a+=c.toString();let u=a.split(`
20
+
21
+ `);a=u.pop()||"";for(let p of u){let _=p.startsWith("data: ")?p.slice(6):p;try{let O=JSON.parse(_);process.stdout.write(O)}catch{}}}),l.on("end",()=>t()),l.on("error",c=>r(c))});s.on("error",l=>r(l)),s.setTimeout(0),s.end()})}function vt(i,e){return M(g(i,"/__master__/deregister"),{hash:e})}var{green:xn}=f;async function Un(){for(let i=0;i<lt;i++){let e=await T();if(e)return e;await new Promise(t=>setTimeout(t,at))}return null}async function Hn(i,e,t){let r=Vt.default.join(k,"dist/master.js");if(!Ft.default.existsSync(r))throw new Error("Master entry file not found, startup failed");let o=["--port",String(i),"--public-port",String(i)],n=(0,kt.spawn)(process.execPath,["--no-deprecation",r,...o],{stdio:["inherit","pipe","pipe"],cwd:t,env:{...process.env,COMP_HUB_VERSION:e.version}}),s="";n.stderr&&n.stderr.on("data",a=>{process.stderr.write(a)}),n.stdout&&n.stdout.on("data",a=>{s+=a.toString();let c=s.split(`
22
+ `);s=c.pop()||"";for(let u of c)/^\[[0-9a-f]{8}\]/.test(u)||process.stdout.write(u+`
23
+ `)}),["SIGINT","SIGTERM"].forEach(a=>{process.on(a,()=>{n.kill(a)})}),n.on("exit",a=>{s&&!/^\[[0-9a-f]{8}\]/.test(s)&&process.stdout.write(s),process.exit(a||0)});let l=await Un();if(!l)throw n.kill(),new Error("Master startup timeout");return{runtime:l}}async function Yt(i,e){let t=!1,r=0,o=await T();if(o){let a=i.port!=null?i.port:o.publicPort;return i.port!=null&&o.publicPort!==a&&(t=!0,r=o.publicPort),{runtime:o,portMismatch:t,runningPublicPort:r}}let n=i.port!=null?i.port:v,s=await(0,_e.default)({port:_e.default.makeRange(n,n+100)}),{runtime:l}=await Hn(s,e,process.cwd());return{runtime:l,portMismatch:t,runningPublicPort:r}}async function jt(i,e,t,r){let o={hash:e,cwd:t,dir:r.dir||"./"};r.api&&(o.api=r.api),r.allowDebug&&(o.allowDebug=!0),r.proxy&&(o.proxy=r.proxy),r.logLevel&&(o.logLevel=r.logLevel);let n=await M(g(i,E.REGISTER),o);if(!n.ok)throw new Error(n.error||"Registration failed");console.log(`${xn("\u2713")} Project registered (hash: ${e})`)}var{cyan:D,green:q,white:Gt,yellow:$n,red:Bt}=f;function Wt(i,e,t,r,o,n){let{portMismatch:s,runningPublicPort:l}=n,a=`http://localhost:${r}/${t}/main/`,c=["",D(" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 "),D(" \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557"),D(" \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D"),D(" \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557"),D(" \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D"),D(" \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D "),"","",` ${q("Version")} ${i.version}`,` ${q("Project")} ${e}`,` ${q("Hash")} ${t}`,` ${q("Port")} ${r}`,"",` ${$n("URL")} ${D(a)}`,"",Gt(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),"",` ${"comphub status".padEnd(30)}View all projects`,` ${`comphub stop ${t}`.padEnd(30)}Stop current project`,` ${"comphub stop --all".padEnd(30)}Stop all projects`,` ${"comphub kill".padEnd(30)}Shutdown master`,""];s&&c.push(Gt(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),"",Bt(` \u26A0 Master is already running on port ${l}, ignoring -p ${o.port}`),Bt(" To change port, please run comphub kill first"),""),console.log(c.join(`
24
+ `))}var{cyan:Kt,green:vn,white:qt,yellow:Xt,red:de}=f;async function fe(i,e){Jt.default.existsSync(Zt.default.join(process.cwd(),"package.json"))||(console.error(`${de("\u2717")} Current directory is not a Node.js project`),process.exit(1));let t=process.cwd(),r=ht(t);e=dt(e,t);let o=await xt({base:e.api,compHubVersion:i.version});if(o.ok&&o.verdict==="block"){let m=o.latestVersion&&o.latestVersion!==i.version?`, latest version v${o.latestVersion}`:"";console.error(""),console.error(`${de("\u2717")} comp-hub must be upgraded before it can start (current v${i.version}${m})`),console.error(` Please run the upgrade command: ${Kt("npm install comp-hub@latest -g")}`),console.error(" Then run comphub again after upgrading"),console.error(""),process.exit(1)}console.log(`${vn("\u2713")} ${i.name} v${i.version}`);let{runtime:n,portMismatch:s,runningPublicPort:l}=await Yt(e,i),a=n.managementPort,c=n.publicPort;if(await jt(a,r,t,e),Wt(i,t,r,c,e,{portMismatch:s,runningPublicPort:l}),o.ok&&o.verdict==="notice"){let m=o.latestVersion&&o.latestVersion!==i.version?` (latest version v${o.latestVersion})`:"";console.log(""),console.log(`${Xt("\u2139")} comp-hub has a new version available${m}; run the upgrade command to update:`),console.log(` ${Kt("npm install comp-hub@latest -g")}`),console.log("")}else o.ok||(console.log(""),console.log(`${Xt("\u26A0")} comp-hub version check failed (${o.error}); skipping the version check for this run`),console.log(""));let u=!1,p=async()=>{if(!u){u=!0;try{await vt(a,r)}catch{}process.exit(0)}};process.on("SIGINT",p),process.on("SIGTERM",p),console.log(`
25
+ ${qt("\u2500")} Streaming logs from MidwayJS (${r}) ${qt("\u2500")}
26
+ `);let _=`http://localhost:${a}/__master__/projects/${r}/logs`;try{await $t(_,r)}catch(O){console.error(`
27
+ ${de("\u2717")} Log stream error: ${O.message}`)}}var{green:R,yellow:zt,cyan:Qt,white:A,red:Fn}=f;async function Ee(i){let e=await L(i),t=await T(),r=t?t.publicPort:e;console.log(`
28
+ ${zt("\u25CF")} Master Status
29
+ `);let o=await $(g(e,E.HEALTH));(!o.ok||!o.body||typeof o.body.status!="string")&&(console.error(`${Fn("\u2717")} Master service is not running`),process.exit(1));let n=o.body,s=n.status==="running"?R("\u25CF"):Qt("\u25CF");console.log(` ${R("Status")} ${s} ${n.status}`),console.log(` ${R("Version")} ${A(n.version||"")}`),console.log(` ${R("Uptime")} ${A(he(n.uptime??0))}`),console.log(` ${R("Projects")} ${A(String(n.projects??0))}`),console.log("");let l=await $(g(e,E.PROJECTS));if(l.ok&&l.body){let a=l.body.projects;if(Array.isArray(a)&&a.length>0){console.log(` ${zt("\u25B8")} Registered Projects (${a.length}):`),console.log(" "+A("\u2500".repeat(56)));for(let c of a)console.log(` ${R("hash")} ${A(c.hash)}`),console.log(` ${R("path")} ${A(c.cwd||"")}`),console.log(` ${R("url")} ${Qt(`http://localhost:${r}/${c.hash}/main/`)}`),console.log(" "+A("\u2500".repeat(56)))}else console.log(` ${A("\u2500".repeat(58))}`),console.log(` ${A("(No registered projects)")}`),console.log(` ${A("\u2500".repeat(58))}`)}console.log(""),process.exit(0)}var{green:er,yellow:ge,red:X}=f;async function Oe(i,e){let t=await L(e);if(e.all){let o=await $(g(t,E.PROJECTS));(!o.ok||!o.body)&&(console.error(`${X("\u2717")} Cannot connect to master service`),process.exit(1));let n=o.body.projects;(!Array.isArray(n)||n.length===0)&&(console.log(`${ge("\u2139")} No running projects`),process.exit(0)),console.log(`
30
+ ${ge("\u25B8")} Stopping all ${n.length} projects...
31
+ `);for(let s of n){let l=await M(g(t,E.DEREGISTER),{hash:s.hash});l.ok?console.log(` ${er("\u2713")} Stopped: ${s.hash} (${s.cwd||""})`):console.error(` ${X("\u2717")} Failed to stop: ${s.hash} - ${l.error}`)}console.log(""),process.exit(0)}i||(console.error(`${X("\u2717")} Please specify project hash or use --all to stop all projects`),console.error(" Usage: comphub stop <hash>"),console.error(" Usage: comphub stop --all"),process.exit(1)),console.log(`
32
+ ${ge("\u25B8")} Stopping project ${i}...`);let r=await M(g(t,E.DEREGISTER),{hash:i});r.ok?console.log(` ${er("\u2713")} Stopped: ${i}
33
+ `):(console.error(` ${X("\u2717")} Failed to stop: ${r.error}
34
+ `),process.exit(1)),process.exit(0)}var{green:Vn,yellow:kn,red:Yn}=f;async function Ce(i){let e=await L(i);console.log(`
35
+ ${kn("\u25B8")} Shutting down master process...
36
+ `);let t=await M(g(e,E.SHUTDOWN),{});t.ok?console.log(`${Vn("\u2713")} Master process has been shut down
37
+ `):(console.error(`${Yn("\u2717")} Shutdown failed: ${t.error}
38
+ `),process.exit(1)),process.exit(0)}var Ae=d(require("fs"));var{green:tr,yellow:rr,red:jn}=f;async function Te(){console.log(`
39
+ ${rr("\u25B8")} Checking master runtime...
40
+ `);let i=await T();if(i&&(console.log(` ${tr("\u2713")} Master is running normally on port ${i.publicPort}
41
+ `),process.exit(0)),Ae.default.existsSync(I))try{Ae.default.unlinkSync(I),console.log(` ${tr("\u2713")} Removed stale runtime file
42
+ `)}catch{console.error(` ${jn("\u2717")} Failed to remove runtime file
43
+ `),process.exit(1)}else console.log(` ${rr("\u2139")} No stale runtime file found
44
+ `);process.exit(0)}function J(i){return parseInt(i,10)}function or(i){let e=new wt;return e.name("comphub").addOption(new b("-p, --port <number>","Startup port").argParser(J)).option("-d, --dir <path>","Resource directory relative path").option("-l, --log-level <level>","Log level: debug, info, warn, error (default: info)","error").version(i.version,"-v, --version","Show version").addOption(new b("--allow-debug","Enable debug mode").hideHelp()).addOption(new b("--api <url>","API URL").hideHelp()).helpOption("-h, --help","Show help"),e.command("status").description("View master service status and all running projects").addOption(new b("-p, --port <number>","Master port").argParser(J).hideHelp()).action(t=>Ee(t)),e.command("stop [hash]").description("Stop a specific project (by hash) or stop all projects (--all)").addOption(new b("-p, --port <number>","Master port").argParser(J).hideHelp()).option("-a, --all","Stop all projects").action((t,r)=>Oe(t,r)),e.command("kill").description("Shutdown master process").addOption(new b("-p, --port <number>","Master port").argParser(J).hideHelp()).action(t=>Ce(t)),e.command("fix").description("Fix common issues (stale runtime file, etc.)").action(()=>Te()),e.action(async()=>{try{await fe(i,e.opts())}catch(t){console.error(`\u2717 Startup failed: ${t.message}`),process.exit(1)}}),e}var{pkg:Gn}=_t(),Bn=or(Gn);Bn.parseAsync(process.argv).catch(i=>{console.error(`\u2717 CLI error: ${i.message}`),process.exit(1)});