@eventcatalog/core 1.2.7 → 2.0.1

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 (622) hide show
  1. package/.changeset/config.json +11 -0
  2. package/.github/CODEOWNERS +3 -0
  3. package/.github/ISSUE_TEMPLATE.md +1 -0
  4. package/.github/PULL_REQUEST_TEMPLATE.md +18 -0
  5. package/.github/funding.yml +1 -0
  6. package/.github/workflows/lint.yml +22 -0
  7. package/.github/workflows/release.yml +34 -0
  8. package/.github/workflows/verify-build.yml +27 -0
  9. package/.prettierignore +7 -0
  10. package/.prettierrc +10 -0
  11. package/CHANGELOG.md +10 -0
  12. package/LICENSE.md +21 -0
  13. package/README.md +206 -5
  14. package/astro.config.mjs +57 -0
  15. package/bin/dist/eventcatalog.cjs +3139 -0
  16. package/bin/dist/eventcatalog.d.cts +1 -0
  17. package/bin/dist/eventcatalog.d.ts +1 -0
  18. package/bin/dist/eventcatalog.js +3141 -0
  19. package/images/example.png +0 -0
  20. package/package.json +59 -52
  21. package/public/icons/github.svg +1 -0
  22. package/public/icons/x-twitter.svg +1 -0
  23. package/public/logo.png +0 -0
  24. package/public/slack-icon.svg +1 -0
  25. package/scripts/build-ci.js +22 -0
  26. package/scripts/catalog-to-astro-content-directory.js +188 -0
  27. package/scripts/default-files-for-collections/commands.md +8 -0
  28. package/scripts/default-files-for-collections/domains.md +8 -0
  29. package/scripts/default-files-for-collections/events.md +8 -0
  30. package/scripts/default-files-for-collections/services.md +8 -0
  31. package/scripts/default-files-for-collections/teams.md +11 -0
  32. package/scripts/default-files-for-collections/users.md +11 -0
  33. package/scripts/start-catalog-locally.js +23 -0
  34. package/scripts/watcher.js +53 -0
  35. package/src/components/DocsNavigation.astro +110 -0
  36. package/src/components/Header.astro +65 -0
  37. package/src/components/Lists/BasicList.tsx +59 -0
  38. package/src/components/Lists/OwnersList.tsx +101 -0
  39. package/src/components/Lists/PillList.tsx +67 -0
  40. package/src/components/Lists/VersionList.astro +29 -0
  41. package/src/components/MDX/Accordion/Accordion.astro +10 -0
  42. package/src/components/MDX/Accordion/Accordion.tsx +29 -0
  43. package/src/components/MDX/Accordion/AccordionGroup.astro +16 -0
  44. package/{components/Mdx → src/components/MDX}/Admonition.tsx +6 -5
  45. package/src/components/MDX/File.tsx +43 -0
  46. package/src/components/MDX/NodeGraph/DownloadButton.tsx +58 -0
  47. package/src/components/MDX/NodeGraph/NodeGraph.astro +82 -0
  48. package/src/components/MDX/NodeGraph/NodeGraph.tsx +135 -0
  49. package/src/components/MDX/NodeGraph/NodeGraphPortal.tsx +15 -0
  50. package/src/components/MDX/NodeGraph/Nodes/Command.tsx +74 -0
  51. package/src/components/MDX/NodeGraph/Nodes/Event.tsx +74 -0
  52. package/src/components/MDX/NodeGraph/Nodes/Service.tsx +83 -0
  53. package/src/components/MDX/OpenAPI/OpenAPI.tsx +35 -0
  54. package/src/components/MDX/Schema.tsx +45 -0
  55. package/src/components/MDX/components.tsx +24 -0
  56. package/src/components/Search.astro +108 -0
  57. package/src/components/Seo.astro +79 -0
  58. package/src/components/SideBars/DomainSideBar.astro +42 -0
  59. package/src/components/SideBars/MessageSideBar.astro +81 -0
  60. package/src/components/SideBars/ServiceSideBar.astro +93 -0
  61. package/src/components/Tables/DebouncedInput.tsx +32 -0
  62. package/src/components/Tables/Table.tsx +228 -0
  63. package/src/components/Tables/columns/DomainTableColumns.tsx +118 -0
  64. package/src/components/Tables/columns/MessageTableColumns.tsx +159 -0
  65. package/src/components/Tables/columns/ServiceTableColumns.tsx +162 -0
  66. package/src/components/Tables/columns/index.tsx +17 -0
  67. package/src/components/Tables/filters/custom-filters.ts +14 -0
  68. package/src/content/config.ts +119 -0
  69. package/src/env.d.ts +2 -0
  70. package/src/layouts/CustomDocsPageLayout.astro +100 -0
  71. package/src/layouts/DiscoverLayout.astro +120 -0
  72. package/src/layouts/DocsLayout.astro +59 -0
  73. package/src/layouts/PlainPage.astro +29 -0
  74. package/src/layouts/VisualiserLayout.astro +73 -0
  75. package/src/pages/discover/[type]/index.astro +36 -0
  76. package/src/pages/docs/[type]/[id]/[version]/index.astro +215 -0
  77. package/src/pages/docs/[type]/[id]/[version]/spec/index.astro +93 -0
  78. package/src/pages/docs/index.md +4 -0
  79. package/src/pages/docs/teams/[id]/index.astro +127 -0
  80. package/src/pages/docs/users/[id]/index.astro +132 -0
  81. package/src/pages/visualiser/[type]/[id]/[version]/index.astro +46 -0
  82. package/src/pages/visualiser/index.astro +25 -0
  83. package/src/remark-plugins/mermaid.ts +27 -0
  84. package/src/remark-plugins/remark-modified-time.mjs +9 -0
  85. package/src/types/index.ts +2 -0
  86. package/src/utils/collections/util.ts +22 -0
  87. package/src/utils/colors.ts +14 -0
  88. package/src/utils/commands/node-graph.ts +107 -0
  89. package/src/utils/commands.ts +60 -0
  90. package/src/utils/config/catalog.ts +2 -0
  91. package/src/utils/domains/domains.ts +50 -0
  92. package/src/utils/domains/node-graph.ts +60 -0
  93. package/src/utils/events/node-graph.ts +108 -0
  94. package/src/utils/events.ts +62 -0
  95. package/src/utils/example-remark-plugin.mjs +6 -0
  96. package/src/utils/messages.ts +7 -0
  97. package/src/utils/node-graph-utils/utils.ts +31 -0
  98. package/src/utils/services/node-graph.ts +133 -0
  99. package/src/utils/services/services.ts +88 -0
  100. package/src/utils/teams.ts +47 -0
  101. package/src/utils/users.ts +59 -0
  102. package/tailwind.config.mjs +24 -0
  103. package/tsconfig.json +11 -26
  104. package/.next/BUILD_ID +0 -1
  105. package/.next/build-manifest.json +0 -246
  106. package/.next/cache/.tsbuildinfo +0 -1
  107. package/.next/cache/config.json +0 -7
  108. package/.next/cache/eslint/.cache_1bay4w0 +0 -1
  109. package/.next/cache/next-server.js.nft.json +0 -1
  110. package/.next/cache/webpack/client-production/0.pack +0 -0
  111. package/.next/cache/webpack/client-production/index.pack +0 -0
  112. package/.next/cache/webpack/server-production/0.pack +0 -0
  113. package/.next/cache/webpack/server-production/index.pack +0 -0
  114. package/.next/export-detail.json +0 -1
  115. package/.next/export-marker.json +0 -1
  116. package/.next/images-manifest.json +0 -1
  117. package/.next/next-server.js.nft.json +0 -1
  118. package/.next/package.json +0 -1
  119. package/.next/prerender-manifest.json +0 -1
  120. package/.next/react-loadable-manifest.json +0 -2112
  121. package/.next/required-server-files.json +0 -1
  122. package/.next/routes-manifest.json +0 -1
  123. package/.next/server/chunks/109.js +0 -608
  124. package/.next/server/chunks/237.js +0 -109
  125. package/.next/server/chunks/267.js +0 -257
  126. package/.next/server/chunks/274.js +0 -32
  127. package/.next/server/chunks/29.js +0 -675
  128. package/.next/server/chunks/331.js +0 -750
  129. package/.next/server/chunks/362.js +0 -570
  130. package/.next/server/chunks/428.js +0 -84
  131. package/.next/server/chunks/50.js +0 -466
  132. package/.next/server/chunks/526.js +0 -159
  133. package/.next/server/chunks/537.js +0 -136
  134. package/.next/server/chunks/788.js +0 -162
  135. package/.next/server/chunks/797.js +0 -92
  136. package/.next/server/chunks/8.js +0 -173
  137. package/.next/server/chunks/854.js +0 -107
  138. package/.next/server/chunks/938.js +0 -140
  139. package/.next/server/chunks/944.js +0 -721
  140. package/.next/server/chunks/962.js +0 -13
  141. package/.next/server/chunks/97.js +0 -2829
  142. package/.next/server/chunks/992.js +0 -50
  143. package/.next/server/chunks/font-manifest.json +0 -1
  144. package/.next/server/font-manifest.json +0 -1
  145. package/.next/server/middleware-manifest.json +0 -6
  146. package/.next/server/pages/404.html +0 -12
  147. package/.next/server/pages/500.html +0 -12
  148. package/.next/server/pages/_app.js +0 -623
  149. package/.next/server/pages/_app.js.nft.json +0 -1
  150. package/.next/server/pages/_document.js +0 -120
  151. package/.next/server/pages/_document.js.nft.json +0 -1
  152. package/.next/server/pages/_error.js +0 -148
  153. package/.next/server/pages/_error.js.nft.json +0 -1
  154. package/.next/server/pages/domains/Orders/events/OrderComplete/logs.html +0 -1
  155. package/.next/server/pages/domains/Orders/events/OrderComplete/logs.json +0 -1
  156. package/.next/server/pages/domains/Orders/events/OrderComplete.html +0 -40
  157. package/.next/server/pages/domains/Orders/events/OrderComplete.json +0 -1
  158. package/.next/server/pages/domains/Orders/events/OrderConfirmed/logs.html +0 -1
  159. package/.next/server/pages/domains/Orders/events/OrderConfirmed/logs.json +0 -1
  160. package/.next/server/pages/domains/Orders/events/OrderConfirmed.html +0 -40
  161. package/.next/server/pages/domains/Orders/events/OrderConfirmed.json +0 -1
  162. package/.next/server/pages/domains/Orders/events/OrderCreated/logs.html +0 -1
  163. package/.next/server/pages/domains/Orders/events/OrderCreated/logs.json +0 -1
  164. package/.next/server/pages/domains/Orders/events/OrderCreated.html +0 -2
  165. package/.next/server/pages/domains/Orders/events/OrderCreated.json +0 -1
  166. package/.next/server/pages/domains/Orders/events/OrderRequested/logs.html +0 -1
  167. package/.next/server/pages/domains/Orders/events/OrderRequested/logs.json +0 -1
  168. package/.next/server/pages/domains/Orders/events/OrderRequested.html +0 -40
  169. package/.next/server/pages/domains/Orders/events/OrderRequested.json +0 -1
  170. package/.next/server/pages/domains/Orders/services/Orders Service.html +0 -2
  171. package/.next/server/pages/domains/Orders/services/Orders Service.json +0 -1
  172. package/.next/server/pages/domains/Orders.html +0 -2
  173. package/.next/server/pages/domains/Orders.json +0 -1
  174. package/.next/server/pages/domains/Shopping/events/AddedItemToCart/logs.html +0 -1
  175. package/.next/server/pages/domains/Shopping/events/AddedItemToCart/logs.json +0 -1
  176. package/.next/server/pages/domains/Shopping/events/AddedItemToCart/v/0.0.1.html +0 -59
  177. package/.next/server/pages/domains/Shopping/events/AddedItemToCart/v/0.0.1.json +0 -1
  178. package/.next/server/pages/domains/Shopping/events/AddedItemToCart/v/0.0.2.html +0 -66
  179. package/.next/server/pages/domains/Shopping/events/AddedItemToCart/v/0.0.2.json +0 -1
  180. package/.next/server/pages/domains/Shopping/events/AddedItemToCart.html +0 -65
  181. package/.next/server/pages/domains/Shopping/events/AddedItemToCart.json +0 -1
  182. package/.next/server/pages/domains/Shopping/events/RemovedItemFromCart/logs.html +0 -1
  183. package/.next/server/pages/domains/Shopping/events/RemovedItemFromCart/logs.json +0 -1
  184. package/.next/server/pages/domains/Shopping/events/RemovedItemFromCart.html +0 -48
  185. package/.next/server/pages/domains/Shopping/events/RemovedItemFromCart.json +0 -1
  186. package/.next/server/pages/domains/Shopping.html +0 -2
  187. package/.next/server/pages/domains/Shopping.json +0 -1
  188. package/.next/server/pages/domains/[domain]/events/[name]/logs.js +0 -345
  189. package/.next/server/pages/domains/[domain]/events/[name]/logs.js.nft.json +0 -1
  190. package/.next/server/pages/domains/[domain]/events/[name]/v/[version].js +0 -435
  191. package/.next/server/pages/domains/[domain]/events/[name]/v/[version].js.nft.json +0 -1
  192. package/.next/server/pages/domains/[domain]/events/[name].js +0 -354
  193. package/.next/server/pages/domains/[domain]/events/[name].js.nft.json +0 -1
  194. package/.next/server/pages/domains/[domain]/services/[name].js +0 -402
  195. package/.next/server/pages/domains/[domain]/services/[name].js.nft.json +0 -1
  196. package/.next/server/pages/domains/[domain].js +0 -549
  197. package/.next/server/pages/domains/[domain].js.nft.json +0 -1
  198. package/.next/server/pages/domains.html +0 -3
  199. package/.next/server/pages/domains.js +0 -576
  200. package/.next/server/pages/domains.js.nft.json +0 -1
  201. package/.next/server/pages/domains.json +0 -1
  202. package/.next/server/pages/events/PaymentProcessed/logs.html +0 -1
  203. package/.next/server/pages/events/PaymentProcessed/logs.json +0 -1
  204. package/.next/server/pages/events/PaymentProcessed.html +0 -44
  205. package/.next/server/pages/events/PaymentProcessed.json +0 -1
  206. package/.next/server/pages/events/ShipmentDelivered/logs.html +0 -1
  207. package/.next/server/pages/events/ShipmentDelivered/logs.json +0 -1
  208. package/.next/server/pages/events/ShipmentDelivered.html +0 -44
  209. package/.next/server/pages/events/ShipmentDelivered.json +0 -1
  210. package/.next/server/pages/events/ShipmentDispatched/logs.html +0 -1
  211. package/.next/server/pages/events/ShipmentDispatched/logs.json +0 -1
  212. package/.next/server/pages/events/ShipmentDispatched.html +0 -44
  213. package/.next/server/pages/events/ShipmentDispatched.json +0 -1
  214. package/.next/server/pages/events/ShipmentPrepared/logs.html +0 -1
  215. package/.next/server/pages/events/ShipmentPrepared/logs.json +0 -1
  216. package/.next/server/pages/events/ShipmentPrepared.html +0 -2
  217. package/.next/server/pages/events/ShipmentPrepared.json +0 -1
  218. package/.next/server/pages/events/[name]/logs.js +0 -263
  219. package/.next/server/pages/events/[name]/logs.js.nft.json +0 -1
  220. package/.next/server/pages/events/[name]/v/[version].js +0 -431
  221. package/.next/server/pages/events/[name]/v/[version].js.nft.json +0 -1
  222. package/.next/server/pages/events/[name].js +0 -354
  223. package/.next/server/pages/events/[name].js.nft.json +0 -1
  224. package/.next/server/pages/events.html +0 -11
  225. package/.next/server/pages/events.js +0 -789
  226. package/.next/server/pages/events.js.nft.json +0 -1
  227. package/.next/server/pages/events.json +0 -1
  228. package/.next/server/pages/index.html +0 -1
  229. package/.next/server/pages/index.js.nft.json +0 -1
  230. package/.next/server/pages/overview.html +0 -1
  231. package/.next/server/pages/overview.js +0 -240
  232. package/.next/server/pages/overview.js.nft.json +0 -1
  233. package/.next/server/pages/overview.json +0 -1
  234. package/.next/server/pages/services/Orders Service.html +0 -1
  235. package/.next/server/pages/services/Orders Service.json +0 -1
  236. package/.next/server/pages/services/Payment Service.html +0 -2
  237. package/.next/server/pages/services/Payment Service.json +0 -1
  238. package/.next/server/pages/services/Shipping Service.html +0 -2
  239. package/.next/server/pages/services/Shipping Service.json +0 -1
  240. package/.next/server/pages/services/[name].js +0 -319
  241. package/.next/server/pages/services/[name].js.nft.json +0 -1
  242. package/.next/server/pages/services.html +0 -4
  243. package/.next/server/pages/services.js +0 -741
  244. package/.next/server/pages/services.js.nft.json +0 -1
  245. package/.next/server/pages/services.json +0 -1
  246. package/.next/server/pages/users/[id].js +0 -475
  247. package/.next/server/pages/users/[id].js.nft.json +0 -1
  248. package/.next/server/pages/users/dboyne.html +0 -16
  249. package/.next/server/pages/users/dboyne.json +0 -1
  250. package/.next/server/pages/users/mSmith.html +0 -13
  251. package/.next/server/pages/users/mSmith.json +0 -1
  252. package/.next/server/pages/users.html +0 -1
  253. package/.next/server/pages/users.js.nft.json +0 -1
  254. package/.next/server/pages/visualiser.html +0 -16
  255. package/.next/server/pages/visualiser.js +0 -739
  256. package/.next/server/pages/visualiser.js.nft.json +0 -1
  257. package/.next/server/pages/visualiser.json +0 -1
  258. package/.next/server/pages-manifest.json +0 -23
  259. package/.next/server/webpack-runtime.js +0 -259
  260. package/.next/static/chunks/020d8314.2bae2f29ef0060e4.js +0 -1
  261. package/.next/static/chunks/1093.67f04e0e6b50c9e5.js +0 -1
  262. package/.next/static/chunks/1178-c3c8c74ac08d7c77.js +0 -1
  263. package/.next/static/chunks/1254.a78e9444e102b061.js +0 -1
  264. package/.next/static/chunks/130.fa515915f80e17f9.js +0 -1
  265. package/.next/static/chunks/1318.a5349c1b3da2b184.js +0 -1
  266. package/.next/static/chunks/1415.55c7c89ef0a8aab1.js +0 -1
  267. package/.next/static/chunks/1455-8df9e334899797b2.js +0 -1
  268. package/.next/static/chunks/172-940ad0353b57ff98.js +0 -1
  269. package/.next/static/chunks/1733.1bead33faaa9eeb0.js +0 -1
  270. package/.next/static/chunks/1806.3ed762ab3ecedc9d.js +0 -1
  271. package/.next/static/chunks/2157.cd3aa9fee64d976e.js +0 -1
  272. package/.next/static/chunks/2566.4084969752c613a9.js +0 -1
  273. package/.next/static/chunks/2620-21775e17d8a6a407.js +0 -1
  274. package/.next/static/chunks/2edb282b-45c56c19221816df.js +0 -1
  275. package/.next/static/chunks/3116-446dd88b93c44018.js +0 -1
  276. package/.next/static/chunks/3193.f69abc67598575a9.js +0 -1
  277. package/.next/static/chunks/3260.00ac1405e82b8dd9.js +0 -1
  278. package/.next/static/chunks/3271.83723868c9b8e7c1.js +0 -1
  279. package/.next/static/chunks/3287.f50c49237cef9ae8.js +0 -1
  280. package/.next/static/chunks/39a9cf3f.8cc8ac3887be2999.js +0 -1
  281. package/.next/static/chunks/3ede58a6.44fda8e0e5284248.js +0 -1
  282. package/.next/static/chunks/40.16abe9d3c57256d6.js +0 -1
  283. package/.next/static/chunks/407.3078ab29e8d18c02.js +0 -1
  284. package/.next/static/chunks/438.dea6dada9bd4b683.js +0 -1
  285. package/.next/static/chunks/4384-8a28a71e7e3b8d8a.js +0 -1
  286. package/.next/static/chunks/4466.dc03dbcd026995cc.js +0 -1
  287. package/.next/static/chunks/4737.ae583b848d202a93.js +0 -1
  288. package/.next/static/chunks/5048.73fa7a6d734ba5ef.js +0 -1
  289. package/.next/static/chunks/5092.8ead508f86f4b11c.js +0 -1
  290. package/.next/static/chunks/5493-b00dc3d50ab46716.js +0 -1
  291. package/.next/static/chunks/5835.a9405ab0913544df.js +0 -1
  292. package/.next/static/chunks/6067.cc75c37618cf0147.js +0 -1
  293. package/.next/static/chunks/6121.758a43c0db92ca23.js +0 -1
  294. package/.next/static/chunks/6229.7a9f0c8b204b76dc.js +0 -1
  295. package/.next/static/chunks/6487.44c6e83c098ed47f.js +0 -1
  296. package/.next/static/chunks/6582.06af6897be0d24b3.js +0 -1
  297. package/.next/static/chunks/6724.ed1280c926906c76.js +0 -1
  298. package/.next/static/chunks/6772-fc6143a6584acf9b.js +0 -1
  299. package/.next/static/chunks/6790-f4527d80153a3e25.js +0 -1
  300. package/.next/static/chunks/7005-09e42f99859b8d03.js +0 -1
  301. package/.next/static/chunks/7109-c8d3fde4c3b6798e.js +0 -1
  302. package/.next/static/chunks/7374.a673e317f007d3b6.js +0 -1
  303. package/.next/static/chunks/74030e57.9636ad3c5c96940b.js +0 -1
  304. package/.next/static/chunks/7458.1de01a44cd67f6f0.js +0 -1
  305. package/.next/static/chunks/7469.d932a6b01168373b.js +0 -1
  306. package/.next/static/chunks/7636.9eaf88a09c2a88ed.js +0 -1
  307. package/.next/static/chunks/7f5d3f51-659399fe6f04b9eb.js +0 -1
  308. package/.next/static/chunks/8264-a1b0376ff4b3d4da.js +0 -1
  309. package/.next/static/chunks/828-1a4a120d2fbea802.js +0 -1
  310. package/.next/static/chunks/8341-b8d844d6f606aed5.js +0 -1
  311. package/.next/static/chunks/8470.c811187bd2982a8a.js +0 -1
  312. package/.next/static/chunks/9076.0a13d7d5aab7bfa1.js +0 -1
  313. package/.next/static/chunks/9097.1efc23284d82765c.js +0 -1
  314. package/.next/static/chunks/9270.a4c64e6be4a278a4.js +0 -1
  315. package/.next/static/chunks/9404.a44dfe8858add605.js +0 -1
  316. package/.next/static/chunks/9497.49670ee9a8bd76f7.js +0 -1
  317. package/.next/static/chunks/9930.28415573db2b7806.js +0 -7
  318. package/.next/static/chunks/b2f22a9c-0216e9400ac0ac1c.js +0 -1
  319. package/.next/static/chunks/b9e0c7b4-52b02c0d4f161186.js +0 -1
  320. package/.next/static/chunks/eb6e03f4.3dd8d555aebe18ff.js +0 -1
  321. package/.next/static/chunks/f4df0e03.56d1c15b5532ab26.js +0 -1
  322. package/.next/static/chunks/framework-6cc1bceeaaf75e91.js +0 -1
  323. package/.next/static/chunks/main-da37322a396d572a.js +0 -1
  324. package/.next/static/chunks/pages/_app-d40841fd52b70886.js +0 -1
  325. package/.next/static/chunks/pages/_error-c36fa6f7fd569cf6.js +0 -1
  326. package/.next/static/chunks/pages/domains/[domain]/events/[name]/logs-350f383eed1cf3f8.js +0 -1
  327. package/.next/static/chunks/pages/domains/[domain]/events/[name]/v/[version]-45b0d7bc42f6f81c.js +0 -1
  328. package/.next/static/chunks/pages/domains/[domain]/events/[name]-15bb0ef487953fa1.js +0 -1
  329. package/.next/static/chunks/pages/domains/[domain]/services/[name]-a4857d4d0aa4d04b.js +0 -1
  330. package/.next/static/chunks/pages/domains/[domain]-ea20e2daae1794fc.js +0 -1
  331. package/.next/static/chunks/pages/domains-71179cbdb719a0f8.js +0 -1
  332. package/.next/static/chunks/pages/events/[name]/logs-695c5b2cfd996539.js +0 -1
  333. package/.next/static/chunks/pages/events/[name]/v/[version]-b718302d7185dcb0.js +0 -1
  334. package/.next/static/chunks/pages/events/[name]-8cb0b3b469bd7845.js +0 -1
  335. package/.next/static/chunks/pages/events-83c9161a6e696533.js +0 -1
  336. package/.next/static/chunks/pages/index-68062a10328e7d10.js +0 -1
  337. package/.next/static/chunks/pages/overview-4251cc856f776fc2.js +0 -1
  338. package/.next/static/chunks/pages/services/[name]-7030da24d73a8ea3.js +0 -1
  339. package/.next/static/chunks/pages/services-7069c0a5295e53ae.js +0 -1
  340. package/.next/static/chunks/pages/users/[id]-00aeace648436383.js +0 -1
  341. package/.next/static/chunks/pages/users-412f257b1de51363.js +0 -1
  342. package/.next/static/chunks/pages/visualiser-8474d03175cf9d12.js +0 -1
  343. package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +0 -1
  344. package/.next/static/chunks/webpack-1ea4cabfc6778694.js +0 -1
  345. package/.next/static/css/7e14b4dede1671ad.css +0 -1
  346. package/.next/static/css/94b9a747218712b2.css +0 -3
  347. package/.next/static/css/ae8abf3666c55019.css +0 -5
  348. package/.next/static/css/cc3c8fcadcf7a58b.css +0 -1
  349. package/.next/static/css/deb57cf90a65a90f.css +0 -1
  350. package/.next/static/css/ed97de5465a152bb.css +0 -1
  351. package/.next/static/wZIh57Hs672ULoPeUaYa1/_buildManifest.js +0 -1
  352. package/.next/static/wZIh57Hs672ULoPeUaYa1/_ssgManifest.js +0 -1
  353. package/.next/trace +0 -141
  354. package/bin/eventcatalog.js +0 -141
  355. package/components/BreadCrumbs.tsx +0 -50
  356. package/components/ContentView.tsx +0 -123
  357. package/components/Footer.tsx +0 -31
  358. package/components/Grids/DomainGrid.tsx +0 -61
  359. package/components/Grids/EventGrid.tsx +0 -102
  360. package/components/Grids/ServiceGrid.tsx +0 -84
  361. package/components/Grids/UserGrid.tsx +0 -55
  362. package/components/Header.tsx +0 -74
  363. package/components/Mdx/AsyncApiSpec.tsx +0 -25
  364. package/components/Mdx/Examples.tsx +0 -70
  365. package/components/Mdx/NodeGraph/GraphElements.tsx +0 -294
  366. package/components/Mdx/NodeGraph/GraphLayout.ts +0 -110
  367. package/components/Mdx/NodeGraph/Node.tsx +0 -15
  368. package/components/Mdx/NodeGraph/NodeGraph.tsx +0 -168
  369. package/components/Mdx/NodeGraph/__tests__/GraphElements.spec.ts +0 -102
  370. package/components/Mdx/NodeGraph/__tests__/GraphLayout.spec.ts +0 -115
  371. package/components/Mdx/NodeGraph/__tests__/__snapshots__/GraphElements.spec.ts.snap +0 -559
  372. package/components/Mdx/NodeGraph/__tests__/__snapshots__/GraphLayout.spec.ts.snap +0 -81
  373. package/components/Mdx/OpenApiSpec.tsx +0 -21
  374. package/components/Mdx/SchemaViewer/SchemaViewer.module.css +0 -5
  375. package/components/Mdx/SchemaViewer/SchemaViewer.tsx +0 -34
  376. package/components/Mermaid/index.tsx +0 -58
  377. package/components/NotFound/index.tsx +0 -40
  378. package/components/Sidebars/DomainSidebar.tsx +0 -55
  379. package/components/Sidebars/EventSidebar.tsx +0 -172
  380. package/components/Sidebars/ServiceSidebar.tsx +0 -128
  381. package/components/Sidebars/components/ExternalLinks.tsx +0 -28
  382. package/components/Sidebars/components/ItemList.tsx +0 -32
  383. package/components/Sidebars/components/Owners.tsx +0 -38
  384. package/components/Sidebars/components/Tags.tsx +0 -45
  385. package/components/SyntaxHighlighter.tsx +0 -42
  386. package/eventcatalog.config.js +0 -58
  387. package/eventcatalog.styles.css +0 -15
  388. package/hooks/EventCatalog.tsx +0 -54
  389. package/lib/__tests__/assets/domains/User/events/UserCreated/index.md +0 -20
  390. package/lib/__tests__/assets/domains/User/events/UserRemoved/examples/Basic.cs +0 -31
  391. package/lib/__tests__/assets/domains/User/events/UserRemoved/examples/Basic.js +0 -1
  392. package/lib/__tests__/assets/domains/User/events/UserRemoved/index.md +0 -16
  393. package/lib/__tests__/assets/domains/User/events/UserRemoved/schema.json +0 -4
  394. package/lib/__tests__/assets/domains/User/index.md +0 -16
  395. package/lib/__tests__/assets/domains/User/services/User Service/index.md +0 -19
  396. package/lib/__tests__/assets/events/AddedItemToCart/index.md +0 -25
  397. package/lib/__tests__/assets/events/EmailSent/index.md +0 -15
  398. package/lib/__tests__/assets/events/EventWithSchemaAndExamples/examples/Basic.cs +0 -31
  399. package/lib/__tests__/assets/events/EventWithSchemaAndExamples/examples/Basic.js +0 -1
  400. package/lib/__tests__/assets/events/EventWithSchemaAndExamples/index.md +0 -8
  401. package/lib/__tests__/assets/events/EventWithSchemaAndExamples/schema.json +0 -4
  402. package/lib/__tests__/assets/events/EventWithVersions/index.md +0 -10
  403. package/lib/__tests__/assets/events/EventWithVersions/versioned/0.0.1/index.md +0 -10
  404. package/lib/__tests__/assets/services/Basket Service/index.md +0 -26
  405. package/lib/__tests__/assets/services/Email Platform/index.md +0 -17
  406. package/lib/__tests__/assets/services/Payment Service/index.md +0 -7
  407. package/lib/__tests__/domains.spec.ts +0 -416
  408. package/lib/__tests__/events.spec.ts +0 -514
  409. package/lib/__tests__/file-reader.spec.ts +0 -69
  410. package/lib/__tests__/graphs.spec.ts +0 -88
  411. package/lib/__tests__/services.spec.ts +0 -268
  412. package/lib/analytics.ts +0 -30
  413. package/lib/domains.ts +0 -160
  414. package/lib/events.ts +0 -313
  415. package/lib/file-reader.ts +0 -76
  416. package/lib/graphs.ts +0 -92
  417. package/lib/services.ts +0 -126
  418. package/next-env.d.ts +0 -5
  419. package/next.config.js +0 -11
  420. package/out/404/index.html +0 -12
  421. package/out/404.html +0 -12
  422. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Orders/events/OrderComplete/logs.json +0 -1
  423. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Orders/events/OrderComplete.json +0 -1
  424. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Orders/events/OrderConfirmed/logs.json +0 -1
  425. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Orders/events/OrderConfirmed.json +0 -1
  426. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Orders/events/OrderCreated/logs.json +0 -1
  427. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Orders/events/OrderCreated.json +0 -1
  428. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Orders/events/OrderRequested/logs.json +0 -1
  429. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Orders/events/OrderRequested.json +0 -1
  430. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Orders/services/Orders Service.json +0 -1
  431. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Orders.json +0 -1
  432. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Shopping/events/AddedItemToCart/logs.json +0 -1
  433. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Shopping/events/AddedItemToCart/v/0.0.1.json +0 -1
  434. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Shopping/events/AddedItemToCart/v/0.0.2.json +0 -1
  435. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Shopping/events/AddedItemToCart.json +0 -1
  436. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Shopping/events/RemovedItemFromCart/logs.json +0 -1
  437. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Shopping/events/RemovedItemFromCart.json +0 -1
  438. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains/Shopping.json +0 -1
  439. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/domains.json +0 -1
  440. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/events/PaymentProcessed/logs.json +0 -1
  441. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/events/PaymentProcessed.json +0 -1
  442. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/events/ShipmentDelivered/logs.json +0 -1
  443. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/events/ShipmentDelivered.json +0 -1
  444. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/events/ShipmentDispatched/logs.json +0 -1
  445. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/events/ShipmentDispatched.json +0 -1
  446. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/events/ShipmentPrepared/logs.json +0 -1
  447. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/events/ShipmentPrepared.json +0 -1
  448. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/events.json +0 -1
  449. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/overview.json +0 -1
  450. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/services/Orders Service.json +0 -1
  451. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/services/Payment Service.json +0 -1
  452. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/services/Shipping Service.json +0 -1
  453. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/services.json +0 -1
  454. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/users/dboyne.json +0 -1
  455. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/users/mSmith.json +0 -1
  456. package/out/_next/data/wZIh57Hs672ULoPeUaYa1/visualiser.json +0 -1
  457. package/out/_next/static/chunks/020d8314.2bae2f29ef0060e4.js +0 -1
  458. package/out/_next/static/chunks/1093.67f04e0e6b50c9e5.js +0 -1
  459. package/out/_next/static/chunks/1178-c3c8c74ac08d7c77.js +0 -1
  460. package/out/_next/static/chunks/1254.a78e9444e102b061.js +0 -1
  461. package/out/_next/static/chunks/130.fa515915f80e17f9.js +0 -1
  462. package/out/_next/static/chunks/1318.a5349c1b3da2b184.js +0 -1
  463. package/out/_next/static/chunks/1415.55c7c89ef0a8aab1.js +0 -1
  464. package/out/_next/static/chunks/1455-8df9e334899797b2.js +0 -1
  465. package/out/_next/static/chunks/172-940ad0353b57ff98.js +0 -1
  466. package/out/_next/static/chunks/1733.1bead33faaa9eeb0.js +0 -1
  467. package/out/_next/static/chunks/1806.3ed762ab3ecedc9d.js +0 -1
  468. package/out/_next/static/chunks/2157.cd3aa9fee64d976e.js +0 -1
  469. package/out/_next/static/chunks/2566.4084969752c613a9.js +0 -1
  470. package/out/_next/static/chunks/2620-21775e17d8a6a407.js +0 -1
  471. package/out/_next/static/chunks/2edb282b-45c56c19221816df.js +0 -1
  472. package/out/_next/static/chunks/3116-446dd88b93c44018.js +0 -1
  473. package/out/_next/static/chunks/3193.f69abc67598575a9.js +0 -1
  474. package/out/_next/static/chunks/3260.00ac1405e82b8dd9.js +0 -1
  475. package/out/_next/static/chunks/3271.83723868c9b8e7c1.js +0 -1
  476. package/out/_next/static/chunks/3287.f50c49237cef9ae8.js +0 -1
  477. package/out/_next/static/chunks/39a9cf3f.8cc8ac3887be2999.js +0 -1
  478. package/out/_next/static/chunks/3ede58a6.44fda8e0e5284248.js +0 -1
  479. package/out/_next/static/chunks/40.16abe9d3c57256d6.js +0 -1
  480. package/out/_next/static/chunks/407.3078ab29e8d18c02.js +0 -1
  481. package/out/_next/static/chunks/438.dea6dada9bd4b683.js +0 -1
  482. package/out/_next/static/chunks/4384-8a28a71e7e3b8d8a.js +0 -1
  483. package/out/_next/static/chunks/4466.dc03dbcd026995cc.js +0 -1
  484. package/out/_next/static/chunks/4737.ae583b848d202a93.js +0 -1
  485. package/out/_next/static/chunks/5048.73fa7a6d734ba5ef.js +0 -1
  486. package/out/_next/static/chunks/5092.8ead508f86f4b11c.js +0 -1
  487. package/out/_next/static/chunks/5493-b00dc3d50ab46716.js +0 -1
  488. package/out/_next/static/chunks/5835.a9405ab0913544df.js +0 -1
  489. package/out/_next/static/chunks/6067.cc75c37618cf0147.js +0 -1
  490. package/out/_next/static/chunks/6121.758a43c0db92ca23.js +0 -1
  491. package/out/_next/static/chunks/6229.7a9f0c8b204b76dc.js +0 -1
  492. package/out/_next/static/chunks/6487.44c6e83c098ed47f.js +0 -1
  493. package/out/_next/static/chunks/6582.06af6897be0d24b3.js +0 -1
  494. package/out/_next/static/chunks/6724.ed1280c926906c76.js +0 -1
  495. package/out/_next/static/chunks/6772-fc6143a6584acf9b.js +0 -1
  496. package/out/_next/static/chunks/6790-f4527d80153a3e25.js +0 -1
  497. package/out/_next/static/chunks/7005-09e42f99859b8d03.js +0 -1
  498. package/out/_next/static/chunks/7109-c8d3fde4c3b6798e.js +0 -1
  499. package/out/_next/static/chunks/7374.a673e317f007d3b6.js +0 -1
  500. package/out/_next/static/chunks/74030e57.9636ad3c5c96940b.js +0 -1
  501. package/out/_next/static/chunks/7458.1de01a44cd67f6f0.js +0 -1
  502. package/out/_next/static/chunks/7469.d932a6b01168373b.js +0 -1
  503. package/out/_next/static/chunks/7636.9eaf88a09c2a88ed.js +0 -1
  504. package/out/_next/static/chunks/7f5d3f51-659399fe6f04b9eb.js +0 -1
  505. package/out/_next/static/chunks/8264-a1b0376ff4b3d4da.js +0 -1
  506. package/out/_next/static/chunks/828-1a4a120d2fbea802.js +0 -1
  507. package/out/_next/static/chunks/8341-b8d844d6f606aed5.js +0 -1
  508. package/out/_next/static/chunks/8470.c811187bd2982a8a.js +0 -1
  509. package/out/_next/static/chunks/9076.0a13d7d5aab7bfa1.js +0 -1
  510. package/out/_next/static/chunks/9097.1efc23284d82765c.js +0 -1
  511. package/out/_next/static/chunks/9270.a4c64e6be4a278a4.js +0 -1
  512. package/out/_next/static/chunks/9404.a44dfe8858add605.js +0 -1
  513. package/out/_next/static/chunks/9497.49670ee9a8bd76f7.js +0 -1
  514. package/out/_next/static/chunks/9930.28415573db2b7806.js +0 -7
  515. package/out/_next/static/chunks/b2f22a9c-0216e9400ac0ac1c.js +0 -1
  516. package/out/_next/static/chunks/b9e0c7b4-52b02c0d4f161186.js +0 -1
  517. package/out/_next/static/chunks/eb6e03f4.3dd8d555aebe18ff.js +0 -1
  518. package/out/_next/static/chunks/f4df0e03.56d1c15b5532ab26.js +0 -1
  519. package/out/_next/static/chunks/framework-6cc1bceeaaf75e91.js +0 -1
  520. package/out/_next/static/chunks/main-da37322a396d572a.js +0 -1
  521. package/out/_next/static/chunks/pages/_app-d40841fd52b70886.js +0 -1
  522. package/out/_next/static/chunks/pages/_error-c36fa6f7fd569cf6.js +0 -1
  523. package/out/_next/static/chunks/pages/domains/[domain]/events/[name]/logs-350f383eed1cf3f8.js +0 -1
  524. package/out/_next/static/chunks/pages/domains/[domain]/events/[name]/v/[version]-45b0d7bc42f6f81c.js +0 -1
  525. package/out/_next/static/chunks/pages/domains/[domain]/events/[name]-15bb0ef487953fa1.js +0 -1
  526. package/out/_next/static/chunks/pages/domains/[domain]/services/[name]-a4857d4d0aa4d04b.js +0 -1
  527. package/out/_next/static/chunks/pages/domains/[domain]-ea20e2daae1794fc.js +0 -1
  528. package/out/_next/static/chunks/pages/domains-71179cbdb719a0f8.js +0 -1
  529. package/out/_next/static/chunks/pages/events/[name]/logs-695c5b2cfd996539.js +0 -1
  530. package/out/_next/static/chunks/pages/events/[name]/v/[version]-b718302d7185dcb0.js +0 -1
  531. package/out/_next/static/chunks/pages/events/[name]-8cb0b3b469bd7845.js +0 -1
  532. package/out/_next/static/chunks/pages/events-83c9161a6e696533.js +0 -1
  533. package/out/_next/static/chunks/pages/index-68062a10328e7d10.js +0 -1
  534. package/out/_next/static/chunks/pages/overview-4251cc856f776fc2.js +0 -1
  535. package/out/_next/static/chunks/pages/services/[name]-7030da24d73a8ea3.js +0 -1
  536. package/out/_next/static/chunks/pages/services-7069c0a5295e53ae.js +0 -1
  537. package/out/_next/static/chunks/pages/users/[id]-00aeace648436383.js +0 -1
  538. package/out/_next/static/chunks/pages/users-412f257b1de51363.js +0 -1
  539. package/out/_next/static/chunks/pages/visualiser-8474d03175cf9d12.js +0 -1
  540. package/out/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js +0 -1
  541. package/out/_next/static/chunks/webpack-1ea4cabfc6778694.js +0 -1
  542. package/out/_next/static/css/7e14b4dede1671ad.css +0 -1
  543. package/out/_next/static/css/94b9a747218712b2.css +0 -3
  544. package/out/_next/static/css/ae8abf3666c55019.css +0 -5
  545. package/out/_next/static/css/cc3c8fcadcf7a58b.css +0 -1
  546. package/out/_next/static/css/deb57cf90a65a90f.css +0 -1
  547. package/out/_next/static/css/ed97de5465a152bb.css +0 -1
  548. package/out/_next/static/wZIh57Hs672ULoPeUaYa1/_buildManifest.js +0 -1
  549. package/out/_next/static/wZIh57Hs672ULoPeUaYa1/_ssgManifest.js +0 -1
  550. package/out/domains/Orders/events/OrderComplete/index.html +0 -40
  551. package/out/domains/Orders/events/OrderComplete/logs/index.html +0 -1
  552. package/out/domains/Orders/events/OrderConfirmed/index.html +0 -40
  553. package/out/domains/Orders/events/OrderConfirmed/logs/index.html +0 -1
  554. package/out/domains/Orders/events/OrderCreated/index.html +0 -2
  555. package/out/domains/Orders/events/OrderCreated/logs/index.html +0 -1
  556. package/out/domains/Orders/events/OrderRequested/index.html +0 -40
  557. package/out/domains/Orders/events/OrderRequested/logs/index.html +0 -1
  558. package/out/domains/Orders/index.html +0 -2
  559. package/out/domains/Orders/services/Orders Service/index.html +0 -2
  560. package/out/domains/Shopping/events/AddedItemToCart/index.html +0 -65
  561. package/out/domains/Shopping/events/AddedItemToCart/logs/index.html +0 -1
  562. package/out/domains/Shopping/events/AddedItemToCart/v/0.0.1/index.html +0 -59
  563. package/out/domains/Shopping/events/AddedItemToCart/v/0.0.2/index.html +0 -66
  564. package/out/domains/Shopping/events/RemovedItemFromCart/index.html +0 -48
  565. package/out/domains/Shopping/events/RemovedItemFromCart/logs/index.html +0 -1
  566. package/out/domains/Shopping/index.html +0 -2
  567. package/out/domains/index.html +0 -3
  568. package/out/events/PaymentProcessed/index.html +0 -44
  569. package/out/events/PaymentProcessed/logs/index.html +0 -1
  570. package/out/events/ShipmentDelivered/index.html +0 -44
  571. package/out/events/ShipmentDelivered/logs/index.html +0 -1
  572. package/out/events/ShipmentDispatched/index.html +0 -44
  573. package/out/events/ShipmentDispatched/logs/index.html +0 -1
  574. package/out/events/ShipmentPrepared/index.html +0 -2
  575. package/out/events/ShipmentPrepared/logs/index.html +0 -1
  576. package/out/events/index.html +0 -11
  577. package/out/favicon.ico +0 -0
  578. package/out/index.html +0 -1
  579. package/out/logo-random.svg +0 -114
  580. package/out/logo.svg +0 -44
  581. package/out/opengraph.png +0 -0
  582. package/out/overview/index.html +0 -1
  583. package/out/services/Orders Service/index.html +0 -1
  584. package/out/services/Payment Service/index.html +0 -2
  585. package/out/services/Shipping Service/index.html +0 -2
  586. package/out/services/index.html +0 -4
  587. package/out/users/dboyne/index.html +0 -16
  588. package/out/users/index.html +0 -1
  589. package/out/users/mSmith/index.html +0 -13
  590. package/out/visualiser/index.html +0 -16
  591. package/pages/_app.tsx +0 -111
  592. package/pages/_document.tsx +0 -18
  593. package/pages/domains/[domain]/events/[name]/logs.tsx +0 -35
  594. package/pages/domains/[domain]/events/[name]/v/[version].tsx +0 -39
  595. package/pages/domains/[domain]/events/[name].tsx +0 -46
  596. package/pages/domains/[domain]/index.tsx +0 -137
  597. package/pages/domains/[domain]/services/[name].tsx +0 -42
  598. package/pages/domains.tsx +0 -210
  599. package/pages/events/[name]/logs.tsx +0 -177
  600. package/pages/events/[name]/v/[version].tsx +0 -38
  601. package/pages/events/[name].tsx +0 -223
  602. package/pages/events.tsx +0 -357
  603. package/pages/index.tsx +0 -56
  604. package/pages/overview.tsx +0 -89
  605. package/pages/services/[name].tsx +0 -164
  606. package/pages/services.tsx +0 -311
  607. package/pages/users/[id].tsx +0 -101
  608. package/pages/users.tsx +0 -43
  609. package/pages/visualiser.tsx +0 -322
  610. package/postcss.config.js +0 -6
  611. package/public/logo-random.svg +0 -114
  612. package/public/logo.svg +0 -44
  613. package/scripts/__tests__/assets/eventcatalog.config.js +0 -32
  614. package/scripts/__tests__/generate.spec.ts +0 -36
  615. package/scripts/generate.js +0 -28
  616. package/scripts/move-schemas-for-download.js +0 -80
  617. package/styles/Home.module.css +0 -116
  618. package/styles/globals.css +0 -85
  619. package/tailwind.config.js +0 -36
  620. package/types/index.ts +0 -7
  621. package/utils/random-bg.ts +0 -13
  622. /package/{lib/__tests__/assets/services/Payment Service/openapi.yaml → public/openapi.yml} +0 -0
@@ -0,0 +1,3141 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __esm = (fn, res) => function __init() {
15
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
+ };
17
+ var __commonJS = (cb, mod) => function __require2() {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+
37
+ // node_modules/tsup/assets/esm_shims.js
38
+ var init_esm_shims = __esm({
39
+ "node_modules/tsup/assets/esm_shims.js"() {
40
+ "use strict";
41
+ }
42
+ });
43
+
44
+ // node_modules/commander/lib/error.js
45
+ var require_error = __commonJS({
46
+ "node_modules/commander/lib/error.js"(exports) {
47
+ "use strict";
48
+ init_esm_shims();
49
+ var CommanderError2 = class extends Error {
50
+ /**
51
+ * Constructs the CommanderError class
52
+ * @param {number} exitCode suggested exit code which could be used with process.exit
53
+ * @param {string} code an id string representing the error
54
+ * @param {string} message human-readable description of the error
55
+ */
56
+ constructor(exitCode, code, message) {
57
+ super(message);
58
+ Error.captureStackTrace(this, this.constructor);
59
+ this.name = this.constructor.name;
60
+ this.code = code;
61
+ this.exitCode = exitCode;
62
+ this.nestedError = void 0;
63
+ }
64
+ };
65
+ var InvalidArgumentError2 = class extends CommanderError2 {
66
+ /**
67
+ * Constructs the InvalidArgumentError class
68
+ * @param {string} [message] explanation of why argument is invalid
69
+ */
70
+ constructor(message) {
71
+ super(1, "commander.invalidArgument", message);
72
+ Error.captureStackTrace(this, this.constructor);
73
+ this.name = this.constructor.name;
74
+ }
75
+ };
76
+ exports.CommanderError = CommanderError2;
77
+ exports.InvalidArgumentError = InvalidArgumentError2;
78
+ }
79
+ });
80
+
81
+ // node_modules/commander/lib/argument.js
82
+ var require_argument = __commonJS({
83
+ "node_modules/commander/lib/argument.js"(exports) {
84
+ "use strict";
85
+ init_esm_shims();
86
+ var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
87
+ var Argument2 = class {
88
+ /**
89
+ * Initialize a new command argument with the given name and description.
90
+ * The default is that the argument is required, and you can explicitly
91
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
92
+ *
93
+ * @param {string} name
94
+ * @param {string} [description]
95
+ */
96
+ constructor(name, description) {
97
+ this.description = description || "";
98
+ this.variadic = false;
99
+ this.parseArg = void 0;
100
+ this.defaultValue = void 0;
101
+ this.defaultValueDescription = void 0;
102
+ this.argChoices = void 0;
103
+ switch (name[0]) {
104
+ case "<":
105
+ this.required = true;
106
+ this._name = name.slice(1, -1);
107
+ break;
108
+ case "[":
109
+ this.required = false;
110
+ this._name = name.slice(1, -1);
111
+ break;
112
+ default:
113
+ this.required = true;
114
+ this._name = name;
115
+ break;
116
+ }
117
+ if (this._name.length > 3 && this._name.slice(-3) === "...") {
118
+ this.variadic = true;
119
+ this._name = this._name.slice(0, -3);
120
+ }
121
+ }
122
+ /**
123
+ * Return argument name.
124
+ *
125
+ * @return {string}
126
+ */
127
+ name() {
128
+ return this._name;
129
+ }
130
+ /**
131
+ * @package
132
+ */
133
+ _concatValue(value, previous) {
134
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
135
+ return [value];
136
+ }
137
+ return previous.concat(value);
138
+ }
139
+ /**
140
+ * Set the default value, and optionally supply the description to be displayed in the help.
141
+ *
142
+ * @param {*} value
143
+ * @param {string} [description]
144
+ * @return {Argument}
145
+ */
146
+ default(value, description) {
147
+ this.defaultValue = value;
148
+ this.defaultValueDescription = description;
149
+ return this;
150
+ }
151
+ /**
152
+ * Set the custom handler for processing CLI command arguments into argument values.
153
+ *
154
+ * @param {Function} [fn]
155
+ * @return {Argument}
156
+ */
157
+ argParser(fn) {
158
+ this.parseArg = fn;
159
+ return this;
160
+ }
161
+ /**
162
+ * Only allow argument value to be one of choices.
163
+ *
164
+ * @param {string[]} values
165
+ * @return {Argument}
166
+ */
167
+ choices(values) {
168
+ this.argChoices = values.slice();
169
+ this.parseArg = (arg, previous) => {
170
+ if (!this.argChoices.includes(arg)) {
171
+ throw new InvalidArgumentError2(
172
+ `Allowed choices are ${this.argChoices.join(", ")}.`
173
+ );
174
+ }
175
+ if (this.variadic) {
176
+ return this._concatValue(arg, previous);
177
+ }
178
+ return arg;
179
+ };
180
+ return this;
181
+ }
182
+ /**
183
+ * Make argument required.
184
+ *
185
+ * @returns {Argument}
186
+ */
187
+ argRequired() {
188
+ this.required = true;
189
+ return this;
190
+ }
191
+ /**
192
+ * Make argument optional.
193
+ *
194
+ * @returns {Argument}
195
+ */
196
+ argOptional() {
197
+ this.required = false;
198
+ return this;
199
+ }
200
+ };
201
+ function humanReadableArgName(arg) {
202
+ const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
203
+ return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
204
+ }
205
+ exports.Argument = Argument2;
206
+ exports.humanReadableArgName = humanReadableArgName;
207
+ }
208
+ });
209
+
210
+ // node_modules/commander/lib/help.js
211
+ var require_help = __commonJS({
212
+ "node_modules/commander/lib/help.js"(exports) {
213
+ "use strict";
214
+ init_esm_shims();
215
+ var { humanReadableArgName } = require_argument();
216
+ var Help2 = class {
217
+ constructor() {
218
+ this.helpWidth = void 0;
219
+ this.sortSubcommands = false;
220
+ this.sortOptions = false;
221
+ this.showGlobalOptions = false;
222
+ }
223
+ /**
224
+ * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
225
+ *
226
+ * @param {Command} cmd
227
+ * @returns {Command[]}
228
+ */
229
+ visibleCommands(cmd) {
230
+ const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
231
+ const helpCommand = cmd._getHelpCommand();
232
+ if (helpCommand && !helpCommand._hidden) {
233
+ visibleCommands.push(helpCommand);
234
+ }
235
+ if (this.sortSubcommands) {
236
+ visibleCommands.sort((a, b) => {
237
+ return a.name().localeCompare(b.name());
238
+ });
239
+ }
240
+ return visibleCommands;
241
+ }
242
+ /**
243
+ * Compare options for sort.
244
+ *
245
+ * @param {Option} a
246
+ * @param {Option} b
247
+ * @returns {number}
248
+ */
249
+ compareOptions(a, b) {
250
+ const getSortKey = (option) => {
251
+ return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
252
+ };
253
+ return getSortKey(a).localeCompare(getSortKey(b));
254
+ }
255
+ /**
256
+ * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
257
+ *
258
+ * @param {Command} cmd
259
+ * @returns {Option[]}
260
+ */
261
+ visibleOptions(cmd) {
262
+ const visibleOptions = cmd.options.filter((option) => !option.hidden);
263
+ const helpOption = cmd._getHelpOption();
264
+ if (helpOption && !helpOption.hidden) {
265
+ const removeShort = helpOption.short && cmd._findOption(helpOption.short);
266
+ const removeLong = helpOption.long && cmd._findOption(helpOption.long);
267
+ if (!removeShort && !removeLong) {
268
+ visibleOptions.push(helpOption);
269
+ } else if (helpOption.long && !removeLong) {
270
+ visibleOptions.push(
271
+ cmd.createOption(helpOption.long, helpOption.description)
272
+ );
273
+ } else if (helpOption.short && !removeShort) {
274
+ visibleOptions.push(
275
+ cmd.createOption(helpOption.short, helpOption.description)
276
+ );
277
+ }
278
+ }
279
+ if (this.sortOptions) {
280
+ visibleOptions.sort(this.compareOptions);
281
+ }
282
+ return visibleOptions;
283
+ }
284
+ /**
285
+ * Get an array of the visible global options. (Not including help.)
286
+ *
287
+ * @param {Command} cmd
288
+ * @returns {Option[]}
289
+ */
290
+ visibleGlobalOptions(cmd) {
291
+ if (!this.showGlobalOptions) return [];
292
+ const globalOptions = [];
293
+ for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
294
+ const visibleOptions = ancestorCmd.options.filter(
295
+ (option) => !option.hidden
296
+ );
297
+ globalOptions.push(...visibleOptions);
298
+ }
299
+ if (this.sortOptions) {
300
+ globalOptions.sort(this.compareOptions);
301
+ }
302
+ return globalOptions;
303
+ }
304
+ /**
305
+ * Get an array of the arguments if any have a description.
306
+ *
307
+ * @param {Command} cmd
308
+ * @returns {Argument[]}
309
+ */
310
+ visibleArguments(cmd) {
311
+ if (cmd._argsDescription) {
312
+ cmd.registeredArguments.forEach((argument) => {
313
+ argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
314
+ });
315
+ }
316
+ if (cmd.registeredArguments.find((argument) => argument.description)) {
317
+ return cmd.registeredArguments;
318
+ }
319
+ return [];
320
+ }
321
+ /**
322
+ * Get the command term to show in the list of subcommands.
323
+ *
324
+ * @param {Command} cmd
325
+ * @returns {string}
326
+ */
327
+ subcommandTerm(cmd) {
328
+ const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
329
+ return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + // simplistic check for non-help option
330
+ (args ? " " + args : "");
331
+ }
332
+ /**
333
+ * Get the option term to show in the list of options.
334
+ *
335
+ * @param {Option} option
336
+ * @returns {string}
337
+ */
338
+ optionTerm(option) {
339
+ return option.flags;
340
+ }
341
+ /**
342
+ * Get the argument term to show in the list of arguments.
343
+ *
344
+ * @param {Argument} argument
345
+ * @returns {string}
346
+ */
347
+ argumentTerm(argument) {
348
+ return argument.name();
349
+ }
350
+ /**
351
+ * Get the longest command term length.
352
+ *
353
+ * @param {Command} cmd
354
+ * @param {Help} helper
355
+ * @returns {number}
356
+ */
357
+ longestSubcommandTermLength(cmd, helper) {
358
+ return helper.visibleCommands(cmd).reduce((max, command) => {
359
+ return Math.max(max, helper.subcommandTerm(command).length);
360
+ }, 0);
361
+ }
362
+ /**
363
+ * Get the longest option term length.
364
+ *
365
+ * @param {Command} cmd
366
+ * @param {Help} helper
367
+ * @returns {number}
368
+ */
369
+ longestOptionTermLength(cmd, helper) {
370
+ return helper.visibleOptions(cmd).reduce((max, option) => {
371
+ return Math.max(max, helper.optionTerm(option).length);
372
+ }, 0);
373
+ }
374
+ /**
375
+ * Get the longest global option term length.
376
+ *
377
+ * @param {Command} cmd
378
+ * @param {Help} helper
379
+ * @returns {number}
380
+ */
381
+ longestGlobalOptionTermLength(cmd, helper) {
382
+ return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
383
+ return Math.max(max, helper.optionTerm(option).length);
384
+ }, 0);
385
+ }
386
+ /**
387
+ * Get the longest argument term length.
388
+ *
389
+ * @param {Command} cmd
390
+ * @param {Help} helper
391
+ * @returns {number}
392
+ */
393
+ longestArgumentTermLength(cmd, helper) {
394
+ return helper.visibleArguments(cmd).reduce((max, argument) => {
395
+ return Math.max(max, helper.argumentTerm(argument).length);
396
+ }, 0);
397
+ }
398
+ /**
399
+ * Get the command usage to be displayed at the top of the built-in help.
400
+ *
401
+ * @param {Command} cmd
402
+ * @returns {string}
403
+ */
404
+ commandUsage(cmd) {
405
+ let cmdName = cmd._name;
406
+ if (cmd._aliases[0]) {
407
+ cmdName = cmdName + "|" + cmd._aliases[0];
408
+ }
409
+ let ancestorCmdNames = "";
410
+ for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
411
+ ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
412
+ }
413
+ return ancestorCmdNames + cmdName + " " + cmd.usage();
414
+ }
415
+ /**
416
+ * Get the description for the command.
417
+ *
418
+ * @param {Command} cmd
419
+ * @returns {string}
420
+ */
421
+ commandDescription(cmd) {
422
+ return cmd.description();
423
+ }
424
+ /**
425
+ * Get the subcommand summary to show in the list of subcommands.
426
+ * (Fallback to description for backwards compatibility.)
427
+ *
428
+ * @param {Command} cmd
429
+ * @returns {string}
430
+ */
431
+ subcommandDescription(cmd) {
432
+ return cmd.summary() || cmd.description();
433
+ }
434
+ /**
435
+ * Get the option description to show in the list of options.
436
+ *
437
+ * @param {Option} option
438
+ * @return {string}
439
+ */
440
+ optionDescription(option) {
441
+ const extraInfo = [];
442
+ if (option.argChoices) {
443
+ extraInfo.push(
444
+ // use stringify to match the display of the default value
445
+ `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
446
+ );
447
+ }
448
+ if (option.defaultValue !== void 0) {
449
+ const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
450
+ if (showDefault) {
451
+ extraInfo.push(
452
+ `default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`
453
+ );
454
+ }
455
+ }
456
+ if (option.presetArg !== void 0 && option.optional) {
457
+ extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
458
+ }
459
+ if (option.envVar !== void 0) {
460
+ extraInfo.push(`env: ${option.envVar}`);
461
+ }
462
+ if (extraInfo.length > 0) {
463
+ return `${option.description} (${extraInfo.join(", ")})`;
464
+ }
465
+ return option.description;
466
+ }
467
+ /**
468
+ * Get the argument description to show in the list of arguments.
469
+ *
470
+ * @param {Argument} argument
471
+ * @return {string}
472
+ */
473
+ argumentDescription(argument) {
474
+ const extraInfo = [];
475
+ if (argument.argChoices) {
476
+ extraInfo.push(
477
+ // use stringify to match the display of the default value
478
+ `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
479
+ );
480
+ }
481
+ if (argument.defaultValue !== void 0) {
482
+ extraInfo.push(
483
+ `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`
484
+ );
485
+ }
486
+ if (extraInfo.length > 0) {
487
+ const extraDescripton = `(${extraInfo.join(", ")})`;
488
+ if (argument.description) {
489
+ return `${argument.description} ${extraDescripton}`;
490
+ }
491
+ return extraDescripton;
492
+ }
493
+ return argument.description;
494
+ }
495
+ /**
496
+ * Generate the built-in help text.
497
+ *
498
+ * @param {Command} cmd
499
+ * @param {Help} helper
500
+ * @returns {string}
501
+ */
502
+ formatHelp(cmd, helper) {
503
+ const termWidth = helper.padWidth(cmd, helper);
504
+ const helpWidth = helper.helpWidth || 80;
505
+ const itemIndentWidth = 2;
506
+ const itemSeparatorWidth = 2;
507
+ function formatItem(term, description) {
508
+ if (description) {
509
+ const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
510
+ return helper.wrap(
511
+ fullText,
512
+ helpWidth - itemIndentWidth,
513
+ termWidth + itemSeparatorWidth
514
+ );
515
+ }
516
+ return term;
517
+ }
518
+ function formatList(textArray) {
519
+ return textArray.join("\n").replace(/^/gm, " ".repeat(itemIndentWidth));
520
+ }
521
+ let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
522
+ const commandDescription = helper.commandDescription(cmd);
523
+ if (commandDescription.length > 0) {
524
+ output = output.concat([
525
+ helper.wrap(commandDescription, helpWidth, 0),
526
+ ""
527
+ ]);
528
+ }
529
+ const argumentList = helper.visibleArguments(cmd).map((argument) => {
530
+ return formatItem(
531
+ helper.argumentTerm(argument),
532
+ helper.argumentDescription(argument)
533
+ );
534
+ });
535
+ if (argumentList.length > 0) {
536
+ output = output.concat(["Arguments:", formatList(argumentList), ""]);
537
+ }
538
+ const optionList = helper.visibleOptions(cmd).map((option) => {
539
+ return formatItem(
540
+ helper.optionTerm(option),
541
+ helper.optionDescription(option)
542
+ );
543
+ });
544
+ if (optionList.length > 0) {
545
+ output = output.concat(["Options:", formatList(optionList), ""]);
546
+ }
547
+ if (this.showGlobalOptions) {
548
+ const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
549
+ return formatItem(
550
+ helper.optionTerm(option),
551
+ helper.optionDescription(option)
552
+ );
553
+ });
554
+ if (globalOptionList.length > 0) {
555
+ output = output.concat([
556
+ "Global Options:",
557
+ formatList(globalOptionList),
558
+ ""
559
+ ]);
560
+ }
561
+ }
562
+ const commandList = helper.visibleCommands(cmd).map((cmd2) => {
563
+ return formatItem(
564
+ helper.subcommandTerm(cmd2),
565
+ helper.subcommandDescription(cmd2)
566
+ );
567
+ });
568
+ if (commandList.length > 0) {
569
+ output = output.concat(["Commands:", formatList(commandList), ""]);
570
+ }
571
+ return output.join("\n");
572
+ }
573
+ /**
574
+ * Calculate the pad width from the maximum term length.
575
+ *
576
+ * @param {Command} cmd
577
+ * @param {Help} helper
578
+ * @returns {number}
579
+ */
580
+ padWidth(cmd, helper) {
581
+ return Math.max(
582
+ helper.longestOptionTermLength(cmd, helper),
583
+ helper.longestGlobalOptionTermLength(cmd, helper),
584
+ helper.longestSubcommandTermLength(cmd, helper),
585
+ helper.longestArgumentTermLength(cmd, helper)
586
+ );
587
+ }
588
+ /**
589
+ * Wrap the given string to width characters per line, with lines after the first indented.
590
+ * Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
591
+ *
592
+ * @param {string} str
593
+ * @param {number} width
594
+ * @param {number} indent
595
+ * @param {number} [minColumnWidth=40]
596
+ * @return {string}
597
+ *
598
+ */
599
+ wrap(str, width, indent, minColumnWidth = 40) {
600
+ const indents = " \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF";
601
+ const manualIndent = new RegExp(`[\\n][${indents}]+`);
602
+ if (str.match(manualIndent)) return str;
603
+ const columnWidth = width - indent;
604
+ if (columnWidth < minColumnWidth) return str;
605
+ const leadingStr = str.slice(0, indent);
606
+ const columnText = str.slice(indent).replace("\r\n", "\n");
607
+ const indentString = " ".repeat(indent);
608
+ const zeroWidthSpace = "\u200B";
609
+ const breaks = `\\s${zeroWidthSpace}`;
610
+ const regex = new RegExp(
611
+ `
612
+ |.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`,
613
+ "g"
614
+ );
615
+ const lines = columnText.match(regex) || [];
616
+ return leadingStr + lines.map((line, i) => {
617
+ if (line === "\n") return "";
618
+ return (i > 0 ? indentString : "") + line.trimEnd();
619
+ }).join("\n");
620
+ }
621
+ };
622
+ exports.Help = Help2;
623
+ }
624
+ });
625
+
626
+ // node_modules/commander/lib/option.js
627
+ var require_option = __commonJS({
628
+ "node_modules/commander/lib/option.js"(exports) {
629
+ "use strict";
630
+ init_esm_shims();
631
+ var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
632
+ var Option2 = class {
633
+ /**
634
+ * Initialize a new `Option` with the given `flags` and `description`.
635
+ *
636
+ * @param {string} flags
637
+ * @param {string} [description]
638
+ */
639
+ constructor(flags, description) {
640
+ this.flags = flags;
641
+ this.description = description || "";
642
+ this.required = flags.includes("<");
643
+ this.optional = flags.includes("[");
644
+ this.variadic = /\w\.\.\.[>\]]$/.test(flags);
645
+ this.mandatory = false;
646
+ const optionFlags = splitOptionFlags(flags);
647
+ this.short = optionFlags.shortFlag;
648
+ this.long = optionFlags.longFlag;
649
+ this.negate = false;
650
+ if (this.long) {
651
+ this.negate = this.long.startsWith("--no-");
652
+ }
653
+ this.defaultValue = void 0;
654
+ this.defaultValueDescription = void 0;
655
+ this.presetArg = void 0;
656
+ this.envVar = void 0;
657
+ this.parseArg = void 0;
658
+ this.hidden = false;
659
+ this.argChoices = void 0;
660
+ this.conflictsWith = [];
661
+ this.implied = void 0;
662
+ }
663
+ /**
664
+ * Set the default value, and optionally supply the description to be displayed in the help.
665
+ *
666
+ * @param {*} value
667
+ * @param {string} [description]
668
+ * @return {Option}
669
+ */
670
+ default(value, description) {
671
+ this.defaultValue = value;
672
+ this.defaultValueDescription = description;
673
+ return this;
674
+ }
675
+ /**
676
+ * Preset to use when option used without option-argument, especially optional but also boolean and negated.
677
+ * The custom processing (parseArg) is called.
678
+ *
679
+ * @example
680
+ * new Option('--color').default('GREYSCALE').preset('RGB');
681
+ * new Option('--donate [amount]').preset('20').argParser(parseFloat);
682
+ *
683
+ * @param {*} arg
684
+ * @return {Option}
685
+ */
686
+ preset(arg) {
687
+ this.presetArg = arg;
688
+ return this;
689
+ }
690
+ /**
691
+ * Add option name(s) that conflict with this option.
692
+ * An error will be displayed if conflicting options are found during parsing.
693
+ *
694
+ * @example
695
+ * new Option('--rgb').conflicts('cmyk');
696
+ * new Option('--js').conflicts(['ts', 'jsx']);
697
+ *
698
+ * @param {(string | string[])} names
699
+ * @return {Option}
700
+ */
701
+ conflicts(names) {
702
+ this.conflictsWith = this.conflictsWith.concat(names);
703
+ return this;
704
+ }
705
+ /**
706
+ * Specify implied option values for when this option is set and the implied options are not.
707
+ *
708
+ * The custom processing (parseArg) is not called on the implied values.
709
+ *
710
+ * @example
711
+ * program
712
+ * .addOption(new Option('--log', 'write logging information to file'))
713
+ * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
714
+ *
715
+ * @param {object} impliedOptionValues
716
+ * @return {Option}
717
+ */
718
+ implies(impliedOptionValues) {
719
+ let newImplied = impliedOptionValues;
720
+ if (typeof impliedOptionValues === "string") {
721
+ newImplied = { [impliedOptionValues]: true };
722
+ }
723
+ this.implied = Object.assign(this.implied || {}, newImplied);
724
+ return this;
725
+ }
726
+ /**
727
+ * Set environment variable to check for option value.
728
+ *
729
+ * An environment variable is only used if when processed the current option value is
730
+ * undefined, or the source of the current value is 'default' or 'config' or 'env'.
731
+ *
732
+ * @param {string} name
733
+ * @return {Option}
734
+ */
735
+ env(name) {
736
+ this.envVar = name;
737
+ return this;
738
+ }
739
+ /**
740
+ * Set the custom handler for processing CLI option arguments into option values.
741
+ *
742
+ * @param {Function} [fn]
743
+ * @return {Option}
744
+ */
745
+ argParser(fn) {
746
+ this.parseArg = fn;
747
+ return this;
748
+ }
749
+ /**
750
+ * Whether the option is mandatory and must have a value after parsing.
751
+ *
752
+ * @param {boolean} [mandatory=true]
753
+ * @return {Option}
754
+ */
755
+ makeOptionMandatory(mandatory = true) {
756
+ this.mandatory = !!mandatory;
757
+ return this;
758
+ }
759
+ /**
760
+ * Hide option in help.
761
+ *
762
+ * @param {boolean} [hide=true]
763
+ * @return {Option}
764
+ */
765
+ hideHelp(hide = true) {
766
+ this.hidden = !!hide;
767
+ return this;
768
+ }
769
+ /**
770
+ * @package
771
+ */
772
+ _concatValue(value, previous) {
773
+ if (previous === this.defaultValue || !Array.isArray(previous)) {
774
+ return [value];
775
+ }
776
+ return previous.concat(value);
777
+ }
778
+ /**
779
+ * Only allow option value to be one of choices.
780
+ *
781
+ * @param {string[]} values
782
+ * @return {Option}
783
+ */
784
+ choices(values) {
785
+ this.argChoices = values.slice();
786
+ this.parseArg = (arg, previous) => {
787
+ if (!this.argChoices.includes(arg)) {
788
+ throw new InvalidArgumentError2(
789
+ `Allowed choices are ${this.argChoices.join(", ")}.`
790
+ );
791
+ }
792
+ if (this.variadic) {
793
+ return this._concatValue(arg, previous);
794
+ }
795
+ return arg;
796
+ };
797
+ return this;
798
+ }
799
+ /**
800
+ * Return option name.
801
+ *
802
+ * @return {string}
803
+ */
804
+ name() {
805
+ if (this.long) {
806
+ return this.long.replace(/^--/, "");
807
+ }
808
+ return this.short.replace(/^-/, "");
809
+ }
810
+ /**
811
+ * Return option name, in a camelcase format that can be used
812
+ * as a object attribute key.
813
+ *
814
+ * @return {string}
815
+ */
816
+ attributeName() {
817
+ return camelcase(this.name().replace(/^no-/, ""));
818
+ }
819
+ /**
820
+ * Check if `arg` matches the short or long flag.
821
+ *
822
+ * @param {string} arg
823
+ * @return {boolean}
824
+ * @package
825
+ */
826
+ is(arg) {
827
+ return this.short === arg || this.long === arg;
828
+ }
829
+ /**
830
+ * Return whether a boolean option.
831
+ *
832
+ * Options are one of boolean, negated, required argument, or optional argument.
833
+ *
834
+ * @return {boolean}
835
+ * @package
836
+ */
837
+ isBoolean() {
838
+ return !this.required && !this.optional && !this.negate;
839
+ }
840
+ };
841
+ var DualOptions = class {
842
+ /**
843
+ * @param {Option[]} options
844
+ */
845
+ constructor(options) {
846
+ this.positiveOptions = /* @__PURE__ */ new Map();
847
+ this.negativeOptions = /* @__PURE__ */ new Map();
848
+ this.dualOptions = /* @__PURE__ */ new Set();
849
+ options.forEach((option) => {
850
+ if (option.negate) {
851
+ this.negativeOptions.set(option.attributeName(), option);
852
+ } else {
853
+ this.positiveOptions.set(option.attributeName(), option);
854
+ }
855
+ });
856
+ this.negativeOptions.forEach((value, key) => {
857
+ if (this.positiveOptions.has(key)) {
858
+ this.dualOptions.add(key);
859
+ }
860
+ });
861
+ }
862
+ /**
863
+ * Did the value come from the option, and not from possible matching dual option?
864
+ *
865
+ * @param {*} value
866
+ * @param {Option} option
867
+ * @returns {boolean}
868
+ */
869
+ valueFromOption(value, option) {
870
+ const optionKey = option.attributeName();
871
+ if (!this.dualOptions.has(optionKey)) return true;
872
+ const preset = this.negativeOptions.get(optionKey).presetArg;
873
+ const negativeValue = preset !== void 0 ? preset : false;
874
+ return option.negate === (negativeValue === value);
875
+ }
876
+ };
877
+ function camelcase(str) {
878
+ return str.split("-").reduce((str2, word) => {
879
+ return str2 + word[0].toUpperCase() + word.slice(1);
880
+ });
881
+ }
882
+ function splitOptionFlags(flags) {
883
+ let shortFlag;
884
+ let longFlag;
885
+ const flagParts = flags.split(/[ |,]+/);
886
+ if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
887
+ shortFlag = flagParts.shift();
888
+ longFlag = flagParts.shift();
889
+ if (!shortFlag && /^-[^-]$/.test(longFlag)) {
890
+ shortFlag = longFlag;
891
+ longFlag = void 0;
892
+ }
893
+ return { shortFlag, longFlag };
894
+ }
895
+ exports.Option = Option2;
896
+ exports.DualOptions = DualOptions;
897
+ }
898
+ });
899
+
900
+ // node_modules/commander/lib/suggestSimilar.js
901
+ var require_suggestSimilar = __commonJS({
902
+ "node_modules/commander/lib/suggestSimilar.js"(exports) {
903
+ "use strict";
904
+ init_esm_shims();
905
+ var maxDistance = 3;
906
+ function editDistance(a, b) {
907
+ if (Math.abs(a.length - b.length) > maxDistance)
908
+ return Math.max(a.length, b.length);
909
+ const d = [];
910
+ for (let i = 0; i <= a.length; i++) {
911
+ d[i] = [i];
912
+ }
913
+ for (let j = 0; j <= b.length; j++) {
914
+ d[0][j] = j;
915
+ }
916
+ for (let j = 1; j <= b.length; j++) {
917
+ for (let i = 1; i <= a.length; i++) {
918
+ let cost = 1;
919
+ if (a[i - 1] === b[j - 1]) {
920
+ cost = 0;
921
+ } else {
922
+ cost = 1;
923
+ }
924
+ d[i][j] = Math.min(
925
+ d[i - 1][j] + 1,
926
+ // deletion
927
+ d[i][j - 1] + 1,
928
+ // insertion
929
+ d[i - 1][j - 1] + cost
930
+ // substitution
931
+ );
932
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
933
+ d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
934
+ }
935
+ }
936
+ }
937
+ return d[a.length][b.length];
938
+ }
939
+ function suggestSimilar(word, candidates) {
940
+ if (!candidates || candidates.length === 0) return "";
941
+ candidates = Array.from(new Set(candidates));
942
+ const searchingOptions = word.startsWith("--");
943
+ if (searchingOptions) {
944
+ word = word.slice(2);
945
+ candidates = candidates.map((candidate) => candidate.slice(2));
946
+ }
947
+ let similar = [];
948
+ let bestDistance = maxDistance;
949
+ const minSimilarity = 0.4;
950
+ candidates.forEach((candidate) => {
951
+ if (candidate.length <= 1) return;
952
+ const distance = editDistance(word, candidate);
953
+ const length = Math.max(word.length, candidate.length);
954
+ const similarity = (length - distance) / length;
955
+ if (similarity > minSimilarity) {
956
+ if (distance < bestDistance) {
957
+ bestDistance = distance;
958
+ similar = [candidate];
959
+ } else if (distance === bestDistance) {
960
+ similar.push(candidate);
961
+ }
962
+ }
963
+ });
964
+ similar.sort((a, b) => a.localeCompare(b));
965
+ if (searchingOptions) {
966
+ similar = similar.map((candidate) => `--${candidate}`);
967
+ }
968
+ if (similar.length > 1) {
969
+ return `
970
+ (Did you mean one of ${similar.join(", ")}?)`;
971
+ }
972
+ if (similar.length === 1) {
973
+ return `
974
+ (Did you mean ${similar[0]}?)`;
975
+ }
976
+ return "";
977
+ }
978
+ exports.suggestSimilar = suggestSimilar;
979
+ }
980
+ });
981
+
982
+ // node_modules/commander/lib/command.js
983
+ var require_command = __commonJS({
984
+ "node_modules/commander/lib/command.js"(exports) {
985
+ "use strict";
986
+ init_esm_shims();
987
+ var EventEmitter = __require("node:events").EventEmitter;
988
+ var childProcess = __require("node:child_process");
989
+ var path2 = __require("node:path");
990
+ var fs2 = __require("node:fs");
991
+ var process2 = __require("node:process");
992
+ var { Argument: Argument2, humanReadableArgName } = require_argument();
993
+ var { CommanderError: CommanderError2 } = require_error();
994
+ var { Help: Help2 } = require_help();
995
+ var { Option: Option2, DualOptions } = require_option();
996
+ var { suggestSimilar } = require_suggestSimilar();
997
+ var Command2 = class _Command extends EventEmitter {
998
+ /**
999
+ * Initialize a new `Command`.
1000
+ *
1001
+ * @param {string} [name]
1002
+ */
1003
+ constructor(name) {
1004
+ super();
1005
+ this.commands = [];
1006
+ this.options = [];
1007
+ this.parent = null;
1008
+ this._allowUnknownOption = false;
1009
+ this._allowExcessArguments = true;
1010
+ this.registeredArguments = [];
1011
+ this._args = this.registeredArguments;
1012
+ this.args = [];
1013
+ this.rawArgs = [];
1014
+ this.processedArgs = [];
1015
+ this._scriptPath = null;
1016
+ this._name = name || "";
1017
+ this._optionValues = {};
1018
+ this._optionValueSources = {};
1019
+ this._storeOptionsAsProperties = false;
1020
+ this._actionHandler = null;
1021
+ this._executableHandler = false;
1022
+ this._executableFile = null;
1023
+ this._executableDir = null;
1024
+ this._defaultCommandName = null;
1025
+ this._exitCallback = null;
1026
+ this._aliases = [];
1027
+ this._combineFlagAndOptionalValue = true;
1028
+ this._description = "";
1029
+ this._summary = "";
1030
+ this._argsDescription = void 0;
1031
+ this._enablePositionalOptions = false;
1032
+ this._passThroughOptions = false;
1033
+ this._lifeCycleHooks = {};
1034
+ this._showHelpAfterError = false;
1035
+ this._showSuggestionAfterError = true;
1036
+ this._outputConfiguration = {
1037
+ writeOut: (str) => process2.stdout.write(str),
1038
+ writeErr: (str) => process2.stderr.write(str),
1039
+ getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : void 0,
1040
+ getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : void 0,
1041
+ outputError: (str, write) => write(str)
1042
+ };
1043
+ this._hidden = false;
1044
+ this._helpOption = void 0;
1045
+ this._addImplicitHelpCommand = void 0;
1046
+ this._helpCommand = void 0;
1047
+ this._helpConfiguration = {};
1048
+ }
1049
+ /**
1050
+ * Copy settings that are useful to have in common across root command and subcommands.
1051
+ *
1052
+ * (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
1053
+ *
1054
+ * @param {Command} sourceCommand
1055
+ * @return {Command} `this` command for chaining
1056
+ */
1057
+ copyInheritedSettings(sourceCommand) {
1058
+ this._outputConfiguration = sourceCommand._outputConfiguration;
1059
+ this._helpOption = sourceCommand._helpOption;
1060
+ this._helpCommand = sourceCommand._helpCommand;
1061
+ this._helpConfiguration = sourceCommand._helpConfiguration;
1062
+ this._exitCallback = sourceCommand._exitCallback;
1063
+ this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
1064
+ this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
1065
+ this._allowExcessArguments = sourceCommand._allowExcessArguments;
1066
+ this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
1067
+ this._showHelpAfterError = sourceCommand._showHelpAfterError;
1068
+ this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
1069
+ return this;
1070
+ }
1071
+ /**
1072
+ * @returns {Command[]}
1073
+ * @private
1074
+ */
1075
+ _getCommandAndAncestors() {
1076
+ const result = [];
1077
+ for (let command = this; command; command = command.parent) {
1078
+ result.push(command);
1079
+ }
1080
+ return result;
1081
+ }
1082
+ /**
1083
+ * Define a command.
1084
+ *
1085
+ * There are two styles of command: pay attention to where to put the description.
1086
+ *
1087
+ * @example
1088
+ * // Command implemented using action handler (description is supplied separately to `.command`)
1089
+ * program
1090
+ * .command('clone <source> [destination]')
1091
+ * .description('clone a repository into a newly created directory')
1092
+ * .action((source, destination) => {
1093
+ * console.log('clone command called');
1094
+ * });
1095
+ *
1096
+ * // Command implemented using separate executable file (description is second parameter to `.command`)
1097
+ * program
1098
+ * .command('start <service>', 'start named service')
1099
+ * .command('stop [service]', 'stop named service, or all if no name supplied');
1100
+ *
1101
+ * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
1102
+ * @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
1103
+ * @param {object} [execOpts] - configuration options (for executable)
1104
+ * @return {Command} returns new command for action handler, or `this` for executable command
1105
+ */
1106
+ command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
1107
+ let desc = actionOptsOrExecDesc;
1108
+ let opts = execOpts;
1109
+ if (typeof desc === "object" && desc !== null) {
1110
+ opts = desc;
1111
+ desc = null;
1112
+ }
1113
+ opts = opts || {};
1114
+ const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
1115
+ const cmd = this.createCommand(name);
1116
+ if (desc) {
1117
+ cmd.description(desc);
1118
+ cmd._executableHandler = true;
1119
+ }
1120
+ if (opts.isDefault) this._defaultCommandName = cmd._name;
1121
+ cmd._hidden = !!(opts.noHelp || opts.hidden);
1122
+ cmd._executableFile = opts.executableFile || null;
1123
+ if (args) cmd.arguments(args);
1124
+ this._registerCommand(cmd);
1125
+ cmd.parent = this;
1126
+ cmd.copyInheritedSettings(this);
1127
+ if (desc) return this;
1128
+ return cmd;
1129
+ }
1130
+ /**
1131
+ * Factory routine to create a new unattached command.
1132
+ *
1133
+ * See .command() for creating an attached subcommand, which uses this routine to
1134
+ * create the command. You can override createCommand to customise subcommands.
1135
+ *
1136
+ * @param {string} [name]
1137
+ * @return {Command} new command
1138
+ */
1139
+ createCommand(name) {
1140
+ return new _Command(name);
1141
+ }
1142
+ /**
1143
+ * You can customise the help with a subclass of Help by overriding createHelp,
1144
+ * or by overriding Help properties using configureHelp().
1145
+ *
1146
+ * @return {Help}
1147
+ */
1148
+ createHelp() {
1149
+ return Object.assign(new Help2(), this.configureHelp());
1150
+ }
1151
+ /**
1152
+ * You can customise the help by overriding Help properties using configureHelp(),
1153
+ * or with a subclass of Help by overriding createHelp().
1154
+ *
1155
+ * @param {object} [configuration] - configuration options
1156
+ * @return {(Command | object)} `this` command for chaining, or stored configuration
1157
+ */
1158
+ configureHelp(configuration) {
1159
+ if (configuration === void 0) return this._helpConfiguration;
1160
+ this._helpConfiguration = configuration;
1161
+ return this;
1162
+ }
1163
+ /**
1164
+ * The default output goes to stdout and stderr. You can customise this for special
1165
+ * applications. You can also customise the display of errors by overriding outputError.
1166
+ *
1167
+ * The configuration properties are all functions:
1168
+ *
1169
+ * // functions to change where being written, stdout and stderr
1170
+ * writeOut(str)
1171
+ * writeErr(str)
1172
+ * // matching functions to specify width for wrapping help
1173
+ * getOutHelpWidth()
1174
+ * getErrHelpWidth()
1175
+ * // functions based on what is being written out
1176
+ * outputError(str, write) // used for displaying errors, and not used for displaying help
1177
+ *
1178
+ * @param {object} [configuration] - configuration options
1179
+ * @return {(Command | object)} `this` command for chaining, or stored configuration
1180
+ */
1181
+ configureOutput(configuration) {
1182
+ if (configuration === void 0) return this._outputConfiguration;
1183
+ Object.assign(this._outputConfiguration, configuration);
1184
+ return this;
1185
+ }
1186
+ /**
1187
+ * Display the help or a custom message after an error occurs.
1188
+ *
1189
+ * @param {(boolean|string)} [displayHelp]
1190
+ * @return {Command} `this` command for chaining
1191
+ */
1192
+ showHelpAfterError(displayHelp = true) {
1193
+ if (typeof displayHelp !== "string") displayHelp = !!displayHelp;
1194
+ this._showHelpAfterError = displayHelp;
1195
+ return this;
1196
+ }
1197
+ /**
1198
+ * Display suggestion of similar commands for unknown commands, or options for unknown options.
1199
+ *
1200
+ * @param {boolean} [displaySuggestion]
1201
+ * @return {Command} `this` command for chaining
1202
+ */
1203
+ showSuggestionAfterError(displaySuggestion = true) {
1204
+ this._showSuggestionAfterError = !!displaySuggestion;
1205
+ return this;
1206
+ }
1207
+ /**
1208
+ * Add a prepared subcommand.
1209
+ *
1210
+ * See .command() for creating an attached subcommand which inherits settings from its parent.
1211
+ *
1212
+ * @param {Command} cmd - new subcommand
1213
+ * @param {object} [opts] - configuration options
1214
+ * @return {Command} `this` command for chaining
1215
+ */
1216
+ addCommand(cmd, opts) {
1217
+ if (!cmd._name) {
1218
+ throw new Error(`Command passed to .addCommand() must have a name
1219
+ - specify the name in Command constructor or using .name()`);
1220
+ }
1221
+ opts = opts || {};
1222
+ if (opts.isDefault) this._defaultCommandName = cmd._name;
1223
+ if (opts.noHelp || opts.hidden) cmd._hidden = true;
1224
+ this._registerCommand(cmd);
1225
+ cmd.parent = this;
1226
+ cmd._checkForBrokenPassThrough();
1227
+ return this;
1228
+ }
1229
+ /**
1230
+ * Factory routine to create a new unattached argument.
1231
+ *
1232
+ * See .argument() for creating an attached argument, which uses this routine to
1233
+ * create the argument. You can override createArgument to return a custom argument.
1234
+ *
1235
+ * @param {string} name
1236
+ * @param {string} [description]
1237
+ * @return {Argument} new argument
1238
+ */
1239
+ createArgument(name, description) {
1240
+ return new Argument2(name, description);
1241
+ }
1242
+ /**
1243
+ * Define argument syntax for command.
1244
+ *
1245
+ * The default is that the argument is required, and you can explicitly
1246
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
1247
+ *
1248
+ * @example
1249
+ * program.argument('<input-file>');
1250
+ * program.argument('[output-file]');
1251
+ *
1252
+ * @param {string} name
1253
+ * @param {string} [description]
1254
+ * @param {(Function|*)} [fn] - custom argument processing function
1255
+ * @param {*} [defaultValue]
1256
+ * @return {Command} `this` command for chaining
1257
+ */
1258
+ argument(name, description, fn, defaultValue) {
1259
+ const argument = this.createArgument(name, description);
1260
+ if (typeof fn === "function") {
1261
+ argument.default(defaultValue).argParser(fn);
1262
+ } else {
1263
+ argument.default(fn);
1264
+ }
1265
+ this.addArgument(argument);
1266
+ return this;
1267
+ }
1268
+ /**
1269
+ * Define argument syntax for command, adding multiple at once (without descriptions).
1270
+ *
1271
+ * See also .argument().
1272
+ *
1273
+ * @example
1274
+ * program.arguments('<cmd> [env]');
1275
+ *
1276
+ * @param {string} names
1277
+ * @return {Command} `this` command for chaining
1278
+ */
1279
+ arguments(names) {
1280
+ names.trim().split(/ +/).forEach((detail) => {
1281
+ this.argument(detail);
1282
+ });
1283
+ return this;
1284
+ }
1285
+ /**
1286
+ * Define argument syntax for command, adding a prepared argument.
1287
+ *
1288
+ * @param {Argument} argument
1289
+ * @return {Command} `this` command for chaining
1290
+ */
1291
+ addArgument(argument) {
1292
+ const previousArgument = this.registeredArguments.slice(-1)[0];
1293
+ if (previousArgument && previousArgument.variadic) {
1294
+ throw new Error(
1295
+ `only the last argument can be variadic '${previousArgument.name()}'`
1296
+ );
1297
+ }
1298
+ if (argument.required && argument.defaultValue !== void 0 && argument.parseArg === void 0) {
1299
+ throw new Error(
1300
+ `a default value for a required argument is never used: '${argument.name()}'`
1301
+ );
1302
+ }
1303
+ this.registeredArguments.push(argument);
1304
+ return this;
1305
+ }
1306
+ /**
1307
+ * Customise or override default help command. By default a help command is automatically added if your command has subcommands.
1308
+ *
1309
+ * @example
1310
+ * program.helpCommand('help [cmd]');
1311
+ * program.helpCommand('help [cmd]', 'show help');
1312
+ * program.helpCommand(false); // suppress default help command
1313
+ * program.helpCommand(true); // add help command even if no subcommands
1314
+ *
1315
+ * @param {string|boolean} enableOrNameAndArgs - enable with custom name and/or arguments, or boolean to override whether added
1316
+ * @param {string} [description] - custom description
1317
+ * @return {Command} `this` command for chaining
1318
+ */
1319
+ helpCommand(enableOrNameAndArgs, description) {
1320
+ if (typeof enableOrNameAndArgs === "boolean") {
1321
+ this._addImplicitHelpCommand = enableOrNameAndArgs;
1322
+ return this;
1323
+ }
1324
+ enableOrNameAndArgs = enableOrNameAndArgs ?? "help [command]";
1325
+ const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/);
1326
+ const helpDescription = description ?? "display help for command";
1327
+ const helpCommand = this.createCommand(helpName);
1328
+ helpCommand.helpOption(false);
1329
+ if (helpArgs) helpCommand.arguments(helpArgs);
1330
+ if (helpDescription) helpCommand.description(helpDescription);
1331
+ this._addImplicitHelpCommand = true;
1332
+ this._helpCommand = helpCommand;
1333
+ return this;
1334
+ }
1335
+ /**
1336
+ * Add prepared custom help command.
1337
+ *
1338
+ * @param {(Command|string|boolean)} helpCommand - custom help command, or deprecated enableOrNameAndArgs as for `.helpCommand()`
1339
+ * @param {string} [deprecatedDescription] - deprecated custom description used with custom name only
1340
+ * @return {Command} `this` command for chaining
1341
+ */
1342
+ addHelpCommand(helpCommand, deprecatedDescription) {
1343
+ if (typeof helpCommand !== "object") {
1344
+ this.helpCommand(helpCommand, deprecatedDescription);
1345
+ return this;
1346
+ }
1347
+ this._addImplicitHelpCommand = true;
1348
+ this._helpCommand = helpCommand;
1349
+ return this;
1350
+ }
1351
+ /**
1352
+ * Lazy create help command.
1353
+ *
1354
+ * @return {(Command|null)}
1355
+ * @package
1356
+ */
1357
+ _getHelpCommand() {
1358
+ const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help"));
1359
+ if (hasImplicitHelpCommand) {
1360
+ if (this._helpCommand === void 0) {
1361
+ this.helpCommand(void 0, void 0);
1362
+ }
1363
+ return this._helpCommand;
1364
+ }
1365
+ return null;
1366
+ }
1367
+ /**
1368
+ * Add hook for life cycle event.
1369
+ *
1370
+ * @param {string} event
1371
+ * @param {Function} listener
1372
+ * @return {Command} `this` command for chaining
1373
+ */
1374
+ hook(event, listener) {
1375
+ const allowedValues = ["preSubcommand", "preAction", "postAction"];
1376
+ if (!allowedValues.includes(event)) {
1377
+ throw new Error(`Unexpected value for event passed to hook : '${event}'.
1378
+ Expecting one of '${allowedValues.join("', '")}'`);
1379
+ }
1380
+ if (this._lifeCycleHooks[event]) {
1381
+ this._lifeCycleHooks[event].push(listener);
1382
+ } else {
1383
+ this._lifeCycleHooks[event] = [listener];
1384
+ }
1385
+ return this;
1386
+ }
1387
+ /**
1388
+ * Register callback to use as replacement for calling process.exit.
1389
+ *
1390
+ * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
1391
+ * @return {Command} `this` command for chaining
1392
+ */
1393
+ exitOverride(fn) {
1394
+ if (fn) {
1395
+ this._exitCallback = fn;
1396
+ } else {
1397
+ this._exitCallback = (err) => {
1398
+ if (err.code !== "commander.executeSubCommandAsync") {
1399
+ throw err;
1400
+ } else {
1401
+ }
1402
+ };
1403
+ }
1404
+ return this;
1405
+ }
1406
+ /**
1407
+ * Call process.exit, and _exitCallback if defined.
1408
+ *
1409
+ * @param {number} exitCode exit code for using with process.exit
1410
+ * @param {string} code an id string representing the error
1411
+ * @param {string} message human-readable description of the error
1412
+ * @return never
1413
+ * @private
1414
+ */
1415
+ _exit(exitCode, code, message) {
1416
+ if (this._exitCallback) {
1417
+ this._exitCallback(new CommanderError2(exitCode, code, message));
1418
+ }
1419
+ process2.exit(exitCode);
1420
+ }
1421
+ /**
1422
+ * Register callback `fn` for the command.
1423
+ *
1424
+ * @example
1425
+ * program
1426
+ * .command('serve')
1427
+ * .description('start service')
1428
+ * .action(function() {
1429
+ * // do work here
1430
+ * });
1431
+ *
1432
+ * @param {Function} fn
1433
+ * @return {Command} `this` command for chaining
1434
+ */
1435
+ action(fn) {
1436
+ const listener = (args) => {
1437
+ const expectedArgsCount = this.registeredArguments.length;
1438
+ const actionArgs = args.slice(0, expectedArgsCount);
1439
+ if (this._storeOptionsAsProperties) {
1440
+ actionArgs[expectedArgsCount] = this;
1441
+ } else {
1442
+ actionArgs[expectedArgsCount] = this.opts();
1443
+ }
1444
+ actionArgs.push(this);
1445
+ return fn.apply(this, actionArgs);
1446
+ };
1447
+ this._actionHandler = listener;
1448
+ return this;
1449
+ }
1450
+ /**
1451
+ * Factory routine to create a new unattached option.
1452
+ *
1453
+ * See .option() for creating an attached option, which uses this routine to
1454
+ * create the option. You can override createOption to return a custom option.
1455
+ *
1456
+ * @param {string} flags
1457
+ * @param {string} [description]
1458
+ * @return {Option} new option
1459
+ */
1460
+ createOption(flags, description) {
1461
+ return new Option2(flags, description);
1462
+ }
1463
+ /**
1464
+ * Wrap parseArgs to catch 'commander.invalidArgument'.
1465
+ *
1466
+ * @param {(Option | Argument)} target
1467
+ * @param {string} value
1468
+ * @param {*} previous
1469
+ * @param {string} invalidArgumentMessage
1470
+ * @private
1471
+ */
1472
+ _callParseArg(target, value, previous, invalidArgumentMessage) {
1473
+ try {
1474
+ return target.parseArg(value, previous);
1475
+ } catch (err) {
1476
+ if (err.code === "commander.invalidArgument") {
1477
+ const message = `${invalidArgumentMessage} ${err.message}`;
1478
+ this.error(message, { exitCode: err.exitCode, code: err.code });
1479
+ }
1480
+ throw err;
1481
+ }
1482
+ }
1483
+ /**
1484
+ * Check for option flag conflicts.
1485
+ * Register option if no conflicts found, or throw on conflict.
1486
+ *
1487
+ * @param {Option} option
1488
+ * @private
1489
+ */
1490
+ _registerOption(option) {
1491
+ const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
1492
+ if (matchingOption) {
1493
+ const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
1494
+ throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
1495
+ - already used by option '${matchingOption.flags}'`);
1496
+ }
1497
+ this.options.push(option);
1498
+ }
1499
+ /**
1500
+ * Check for command name and alias conflicts with existing commands.
1501
+ * Register command if no conflicts found, or throw on conflict.
1502
+ *
1503
+ * @param {Command} command
1504
+ * @private
1505
+ */
1506
+ _registerCommand(command) {
1507
+ const knownBy = (cmd) => {
1508
+ return [cmd.name()].concat(cmd.aliases());
1509
+ };
1510
+ const alreadyUsed = knownBy(command).find(
1511
+ (name) => this._findCommand(name)
1512
+ );
1513
+ if (alreadyUsed) {
1514
+ const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
1515
+ const newCmd = knownBy(command).join("|");
1516
+ throw new Error(
1517
+ `cannot add command '${newCmd}' as already have command '${existingCmd}'`
1518
+ );
1519
+ }
1520
+ this.commands.push(command);
1521
+ }
1522
+ /**
1523
+ * Add an option.
1524
+ *
1525
+ * @param {Option} option
1526
+ * @return {Command} `this` command for chaining
1527
+ */
1528
+ addOption(option) {
1529
+ this._registerOption(option);
1530
+ const oname = option.name();
1531
+ const name = option.attributeName();
1532
+ if (option.negate) {
1533
+ const positiveLongFlag = option.long.replace(/^--no-/, "--");
1534
+ if (!this._findOption(positiveLongFlag)) {
1535
+ this.setOptionValueWithSource(
1536
+ name,
1537
+ option.defaultValue === void 0 ? true : option.defaultValue,
1538
+ "default"
1539
+ );
1540
+ }
1541
+ } else if (option.defaultValue !== void 0) {
1542
+ this.setOptionValueWithSource(name, option.defaultValue, "default");
1543
+ }
1544
+ const handleOptionValue = (val, invalidValueMessage, valueSource) => {
1545
+ if (val == null && option.presetArg !== void 0) {
1546
+ val = option.presetArg;
1547
+ }
1548
+ const oldValue = this.getOptionValue(name);
1549
+ if (val !== null && option.parseArg) {
1550
+ val = this._callParseArg(option, val, oldValue, invalidValueMessage);
1551
+ } else if (val !== null && option.variadic) {
1552
+ val = option._concatValue(val, oldValue);
1553
+ }
1554
+ if (val == null) {
1555
+ if (option.negate) {
1556
+ val = false;
1557
+ } else if (option.isBoolean() || option.optional) {
1558
+ val = true;
1559
+ } else {
1560
+ val = "";
1561
+ }
1562
+ }
1563
+ this.setOptionValueWithSource(name, val, valueSource);
1564
+ };
1565
+ this.on("option:" + oname, (val) => {
1566
+ const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
1567
+ handleOptionValue(val, invalidValueMessage, "cli");
1568
+ });
1569
+ if (option.envVar) {
1570
+ this.on("optionEnv:" + oname, (val) => {
1571
+ const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
1572
+ handleOptionValue(val, invalidValueMessage, "env");
1573
+ });
1574
+ }
1575
+ return this;
1576
+ }
1577
+ /**
1578
+ * Internal implementation shared by .option() and .requiredOption()
1579
+ *
1580
+ * @return {Command} `this` command for chaining
1581
+ * @private
1582
+ */
1583
+ _optionEx(config, flags, description, fn, defaultValue) {
1584
+ if (typeof flags === "object" && flags instanceof Option2) {
1585
+ throw new Error(
1586
+ "To add an Option object use addOption() instead of option() or requiredOption()"
1587
+ );
1588
+ }
1589
+ const option = this.createOption(flags, description);
1590
+ option.makeOptionMandatory(!!config.mandatory);
1591
+ if (typeof fn === "function") {
1592
+ option.default(defaultValue).argParser(fn);
1593
+ } else if (fn instanceof RegExp) {
1594
+ const regex = fn;
1595
+ fn = (val, def) => {
1596
+ const m = regex.exec(val);
1597
+ return m ? m[0] : def;
1598
+ };
1599
+ option.default(defaultValue).argParser(fn);
1600
+ } else {
1601
+ option.default(fn);
1602
+ }
1603
+ return this.addOption(option);
1604
+ }
1605
+ /**
1606
+ * Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.
1607
+ *
1608
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required
1609
+ * option-argument is indicated by `<>` and an optional option-argument by `[]`.
1610
+ *
1611
+ * See the README for more details, and see also addOption() and requiredOption().
1612
+ *
1613
+ * @example
1614
+ * program
1615
+ * .option('-p, --pepper', 'add pepper')
1616
+ * .option('-p, --pizza-type <TYPE>', 'type of pizza') // required option-argument
1617
+ * .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
1618
+ * .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
1619
+ *
1620
+ * @param {string} flags
1621
+ * @param {string} [description]
1622
+ * @param {(Function|*)} [parseArg] - custom option processing function or default value
1623
+ * @param {*} [defaultValue]
1624
+ * @return {Command} `this` command for chaining
1625
+ */
1626
+ option(flags, description, parseArg, defaultValue) {
1627
+ return this._optionEx({}, flags, description, parseArg, defaultValue);
1628
+ }
1629
+ /**
1630
+ * Add a required option which must have a value after parsing. This usually means
1631
+ * the option must be specified on the command line. (Otherwise the same as .option().)
1632
+ *
1633
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
1634
+ *
1635
+ * @param {string} flags
1636
+ * @param {string} [description]
1637
+ * @param {(Function|*)} [parseArg] - custom option processing function or default value
1638
+ * @param {*} [defaultValue]
1639
+ * @return {Command} `this` command for chaining
1640
+ */
1641
+ requiredOption(flags, description, parseArg, defaultValue) {
1642
+ return this._optionEx(
1643
+ { mandatory: true },
1644
+ flags,
1645
+ description,
1646
+ parseArg,
1647
+ defaultValue
1648
+ );
1649
+ }
1650
+ /**
1651
+ * Alter parsing of short flags with optional values.
1652
+ *
1653
+ * @example
1654
+ * // for `.option('-f,--flag [value]'):
1655
+ * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
1656
+ * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
1657
+ *
1658
+ * @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.
1659
+ * @return {Command} `this` command for chaining
1660
+ */
1661
+ combineFlagAndOptionalValue(combine = true) {
1662
+ this._combineFlagAndOptionalValue = !!combine;
1663
+ return this;
1664
+ }
1665
+ /**
1666
+ * Allow unknown options on the command line.
1667
+ *
1668
+ * @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.
1669
+ * @return {Command} `this` command for chaining
1670
+ */
1671
+ allowUnknownOption(allowUnknown = true) {
1672
+ this._allowUnknownOption = !!allowUnknown;
1673
+ return this;
1674
+ }
1675
+ /**
1676
+ * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
1677
+ *
1678
+ * @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.
1679
+ * @return {Command} `this` command for chaining
1680
+ */
1681
+ allowExcessArguments(allowExcess = true) {
1682
+ this._allowExcessArguments = !!allowExcess;
1683
+ return this;
1684
+ }
1685
+ /**
1686
+ * Enable positional options. Positional means global options are specified before subcommands which lets
1687
+ * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
1688
+ * The default behaviour is non-positional and global options may appear anywhere on the command line.
1689
+ *
1690
+ * @param {boolean} [positional]
1691
+ * @return {Command} `this` command for chaining
1692
+ */
1693
+ enablePositionalOptions(positional = true) {
1694
+ this._enablePositionalOptions = !!positional;
1695
+ return this;
1696
+ }
1697
+ /**
1698
+ * Pass through options that come after command-arguments rather than treat them as command-options,
1699
+ * so actual command-options come before command-arguments. Turning this on for a subcommand requires
1700
+ * positional options to have been enabled on the program (parent commands).
1701
+ * The default behaviour is non-positional and options may appear before or after command-arguments.
1702
+ *
1703
+ * @param {boolean} [passThrough] for unknown options.
1704
+ * @return {Command} `this` command for chaining
1705
+ */
1706
+ passThroughOptions(passThrough = true) {
1707
+ this._passThroughOptions = !!passThrough;
1708
+ this._checkForBrokenPassThrough();
1709
+ return this;
1710
+ }
1711
+ /**
1712
+ * @private
1713
+ */
1714
+ _checkForBrokenPassThrough() {
1715
+ if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
1716
+ throw new Error(
1717
+ `passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`
1718
+ );
1719
+ }
1720
+ }
1721
+ /**
1722
+ * Whether to store option values as properties on command object,
1723
+ * or store separately (specify false). In both cases the option values can be accessed using .opts().
1724
+ *
1725
+ * @param {boolean} [storeAsProperties=true]
1726
+ * @return {Command} `this` command for chaining
1727
+ */
1728
+ storeOptionsAsProperties(storeAsProperties = true) {
1729
+ if (this.options.length) {
1730
+ throw new Error("call .storeOptionsAsProperties() before adding options");
1731
+ }
1732
+ if (Object.keys(this._optionValues).length) {
1733
+ throw new Error(
1734
+ "call .storeOptionsAsProperties() before setting option values"
1735
+ );
1736
+ }
1737
+ this._storeOptionsAsProperties = !!storeAsProperties;
1738
+ return this;
1739
+ }
1740
+ /**
1741
+ * Retrieve option value.
1742
+ *
1743
+ * @param {string} key
1744
+ * @return {object} value
1745
+ */
1746
+ getOptionValue(key) {
1747
+ if (this._storeOptionsAsProperties) {
1748
+ return this[key];
1749
+ }
1750
+ return this._optionValues[key];
1751
+ }
1752
+ /**
1753
+ * Store option value.
1754
+ *
1755
+ * @param {string} key
1756
+ * @param {object} value
1757
+ * @return {Command} `this` command for chaining
1758
+ */
1759
+ setOptionValue(key, value) {
1760
+ return this.setOptionValueWithSource(key, value, void 0);
1761
+ }
1762
+ /**
1763
+ * Store option value and where the value came from.
1764
+ *
1765
+ * @param {string} key
1766
+ * @param {object} value
1767
+ * @param {string} source - expected values are default/config/env/cli/implied
1768
+ * @return {Command} `this` command for chaining
1769
+ */
1770
+ setOptionValueWithSource(key, value, source) {
1771
+ if (this._storeOptionsAsProperties) {
1772
+ this[key] = value;
1773
+ } else {
1774
+ this._optionValues[key] = value;
1775
+ }
1776
+ this._optionValueSources[key] = source;
1777
+ return this;
1778
+ }
1779
+ /**
1780
+ * Get source of option value.
1781
+ * Expected values are default | config | env | cli | implied
1782
+ *
1783
+ * @param {string} key
1784
+ * @return {string}
1785
+ */
1786
+ getOptionValueSource(key) {
1787
+ return this._optionValueSources[key];
1788
+ }
1789
+ /**
1790
+ * Get source of option value. See also .optsWithGlobals().
1791
+ * Expected values are default | config | env | cli | implied
1792
+ *
1793
+ * @param {string} key
1794
+ * @return {string}
1795
+ */
1796
+ getOptionValueSourceWithGlobals(key) {
1797
+ let source;
1798
+ this._getCommandAndAncestors().forEach((cmd) => {
1799
+ if (cmd.getOptionValueSource(key) !== void 0) {
1800
+ source = cmd.getOptionValueSource(key);
1801
+ }
1802
+ });
1803
+ return source;
1804
+ }
1805
+ /**
1806
+ * Get user arguments from implied or explicit arguments.
1807
+ * Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches.
1808
+ *
1809
+ * @private
1810
+ */
1811
+ _prepareUserArgs(argv, parseOptions) {
1812
+ if (argv !== void 0 && !Array.isArray(argv)) {
1813
+ throw new Error("first parameter to parse must be array or undefined");
1814
+ }
1815
+ parseOptions = parseOptions || {};
1816
+ if (argv === void 0 && parseOptions.from === void 0) {
1817
+ if (process2.versions?.electron) {
1818
+ parseOptions.from = "electron";
1819
+ }
1820
+ const execArgv = process2.execArgv ?? [];
1821
+ if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
1822
+ parseOptions.from = "eval";
1823
+ }
1824
+ }
1825
+ if (argv === void 0) {
1826
+ argv = process2.argv;
1827
+ }
1828
+ this.rawArgs = argv.slice();
1829
+ let userArgs;
1830
+ switch (parseOptions.from) {
1831
+ case void 0:
1832
+ case "node":
1833
+ this._scriptPath = argv[1];
1834
+ userArgs = argv.slice(2);
1835
+ break;
1836
+ case "electron":
1837
+ if (process2.defaultApp) {
1838
+ this._scriptPath = argv[1];
1839
+ userArgs = argv.slice(2);
1840
+ } else {
1841
+ userArgs = argv.slice(1);
1842
+ }
1843
+ break;
1844
+ case "user":
1845
+ userArgs = argv.slice(0);
1846
+ break;
1847
+ case "eval":
1848
+ userArgs = argv.slice(1);
1849
+ break;
1850
+ default:
1851
+ throw new Error(
1852
+ `unexpected parse option { from: '${parseOptions.from}' }`
1853
+ );
1854
+ }
1855
+ if (!this._name && this._scriptPath)
1856
+ this.nameFromFilename(this._scriptPath);
1857
+ this._name = this._name || "program";
1858
+ return userArgs;
1859
+ }
1860
+ /**
1861
+ * Parse `argv`, setting options and invoking commands when defined.
1862
+ *
1863
+ * Use parseAsync instead of parse if any of your action handlers are async.
1864
+ *
1865
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
1866
+ *
1867
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
1868
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
1869
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
1870
+ * - `'user'`: just user arguments
1871
+ *
1872
+ * @example
1873
+ * program.parse(); // parse process.argv and auto-detect electron and special node flags
1874
+ * program.parse(process.argv); // assume argv[0] is app and argv[1] is script
1875
+ * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1876
+ *
1877
+ * @param {string[]} [argv] - optional, defaults to process.argv
1878
+ * @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron
1879
+ * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
1880
+ * @return {Command} `this` command for chaining
1881
+ */
1882
+ parse(argv, parseOptions) {
1883
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
1884
+ this._parseCommand([], userArgs);
1885
+ return this;
1886
+ }
1887
+ /**
1888
+ * Parse `argv`, setting options and invoking commands when defined.
1889
+ *
1890
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
1891
+ *
1892
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
1893
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
1894
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
1895
+ * - `'user'`: just user arguments
1896
+ *
1897
+ * @example
1898
+ * await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
1899
+ * await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
1900
+ * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1901
+ *
1902
+ * @param {string[]} [argv]
1903
+ * @param {object} [parseOptions]
1904
+ * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
1905
+ * @return {Promise}
1906
+ */
1907
+ async parseAsync(argv, parseOptions) {
1908
+ const userArgs = this._prepareUserArgs(argv, parseOptions);
1909
+ await this._parseCommand([], userArgs);
1910
+ return this;
1911
+ }
1912
+ /**
1913
+ * Execute a sub-command executable.
1914
+ *
1915
+ * @private
1916
+ */
1917
+ _executeSubCommand(subcommand, args) {
1918
+ args = args.slice();
1919
+ let launchWithNode = false;
1920
+ const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1921
+ function findFile(baseDir, baseName) {
1922
+ const localBin = path2.resolve(baseDir, baseName);
1923
+ if (fs2.existsSync(localBin)) return localBin;
1924
+ if (sourceExt.includes(path2.extname(baseName))) return void 0;
1925
+ const foundExt = sourceExt.find(
1926
+ (ext) => fs2.existsSync(`${localBin}${ext}`)
1927
+ );
1928
+ if (foundExt) return `${localBin}${foundExt}`;
1929
+ return void 0;
1930
+ }
1931
+ this._checkForMissingMandatoryOptions();
1932
+ this._checkForConflictingOptions();
1933
+ let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
1934
+ let executableDir = this._executableDir || "";
1935
+ if (this._scriptPath) {
1936
+ let resolvedScriptPath;
1937
+ try {
1938
+ resolvedScriptPath = fs2.realpathSync(this._scriptPath);
1939
+ } catch (err) {
1940
+ resolvedScriptPath = this._scriptPath;
1941
+ }
1942
+ executableDir = path2.resolve(
1943
+ path2.dirname(resolvedScriptPath),
1944
+ executableDir
1945
+ );
1946
+ }
1947
+ if (executableDir) {
1948
+ let localFile = findFile(executableDir, executableFile);
1949
+ if (!localFile && !subcommand._executableFile && this._scriptPath) {
1950
+ const legacyName = path2.basename(
1951
+ this._scriptPath,
1952
+ path2.extname(this._scriptPath)
1953
+ );
1954
+ if (legacyName !== this._name) {
1955
+ localFile = findFile(
1956
+ executableDir,
1957
+ `${legacyName}-${subcommand._name}`
1958
+ );
1959
+ }
1960
+ }
1961
+ executableFile = localFile || executableFile;
1962
+ }
1963
+ launchWithNode = sourceExt.includes(path2.extname(executableFile));
1964
+ let proc;
1965
+ if (process2.platform !== "win32") {
1966
+ if (launchWithNode) {
1967
+ args.unshift(executableFile);
1968
+ args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1969
+ proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
1970
+ } else {
1971
+ proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
1972
+ }
1973
+ } else {
1974
+ args.unshift(executableFile);
1975
+ args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1976
+ proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
1977
+ }
1978
+ if (!proc.killed) {
1979
+ const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
1980
+ signals.forEach((signal) => {
1981
+ process2.on(signal, () => {
1982
+ if (proc.killed === false && proc.exitCode === null) {
1983
+ proc.kill(signal);
1984
+ }
1985
+ });
1986
+ });
1987
+ }
1988
+ const exitCallback = this._exitCallback;
1989
+ proc.on("close", (code) => {
1990
+ code = code ?? 1;
1991
+ if (!exitCallback) {
1992
+ process2.exit(code);
1993
+ } else {
1994
+ exitCallback(
1995
+ new CommanderError2(
1996
+ code,
1997
+ "commander.executeSubCommandAsync",
1998
+ "(close)"
1999
+ )
2000
+ );
2001
+ }
2002
+ });
2003
+ proc.on("error", (err) => {
2004
+ if (err.code === "ENOENT") {
2005
+ const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
2006
+ const executableMissing = `'${executableFile}' does not exist
2007
+ - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
2008
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
2009
+ - ${executableDirMessage}`;
2010
+ throw new Error(executableMissing);
2011
+ } else if (err.code === "EACCES") {
2012
+ throw new Error(`'${executableFile}' not executable`);
2013
+ }
2014
+ if (!exitCallback) {
2015
+ process2.exit(1);
2016
+ } else {
2017
+ const wrappedError = new CommanderError2(
2018
+ 1,
2019
+ "commander.executeSubCommandAsync",
2020
+ "(error)"
2021
+ );
2022
+ wrappedError.nestedError = err;
2023
+ exitCallback(wrappedError);
2024
+ }
2025
+ });
2026
+ this.runningCommand = proc;
2027
+ }
2028
+ /**
2029
+ * @private
2030
+ */
2031
+ _dispatchSubcommand(commandName, operands, unknown) {
2032
+ const subCommand = this._findCommand(commandName);
2033
+ if (!subCommand) this.help({ error: true });
2034
+ let promiseChain;
2035
+ promiseChain = this._chainOrCallSubCommandHook(
2036
+ promiseChain,
2037
+ subCommand,
2038
+ "preSubcommand"
2039
+ );
2040
+ promiseChain = this._chainOrCall(promiseChain, () => {
2041
+ if (subCommand._executableHandler) {
2042
+ this._executeSubCommand(subCommand, operands.concat(unknown));
2043
+ } else {
2044
+ return subCommand._parseCommand(operands, unknown);
2045
+ }
2046
+ });
2047
+ return promiseChain;
2048
+ }
2049
+ /**
2050
+ * Invoke help directly if possible, or dispatch if necessary.
2051
+ * e.g. help foo
2052
+ *
2053
+ * @private
2054
+ */
2055
+ _dispatchHelpCommand(subcommandName) {
2056
+ if (!subcommandName) {
2057
+ this.help();
2058
+ }
2059
+ const subCommand = this._findCommand(subcommandName);
2060
+ if (subCommand && !subCommand._executableHandler) {
2061
+ subCommand.help();
2062
+ }
2063
+ return this._dispatchSubcommand(
2064
+ subcommandName,
2065
+ [],
2066
+ [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]
2067
+ );
2068
+ }
2069
+ /**
2070
+ * Check this.args against expected this.registeredArguments.
2071
+ *
2072
+ * @private
2073
+ */
2074
+ _checkNumberOfArguments() {
2075
+ this.registeredArguments.forEach((arg, i) => {
2076
+ if (arg.required && this.args[i] == null) {
2077
+ this.missingArgument(arg.name());
2078
+ }
2079
+ });
2080
+ if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
2081
+ return;
2082
+ }
2083
+ if (this.args.length > this.registeredArguments.length) {
2084
+ this._excessArguments(this.args);
2085
+ }
2086
+ }
2087
+ /**
2088
+ * Process this.args using this.registeredArguments and save as this.processedArgs!
2089
+ *
2090
+ * @private
2091
+ */
2092
+ _processArguments() {
2093
+ const myParseArg = (argument, value, previous) => {
2094
+ let parsedValue = value;
2095
+ if (value !== null && argument.parseArg) {
2096
+ const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
2097
+ parsedValue = this._callParseArg(
2098
+ argument,
2099
+ value,
2100
+ previous,
2101
+ invalidValueMessage
2102
+ );
2103
+ }
2104
+ return parsedValue;
2105
+ };
2106
+ this._checkNumberOfArguments();
2107
+ const processedArgs = [];
2108
+ this.registeredArguments.forEach((declaredArg, index) => {
2109
+ let value = declaredArg.defaultValue;
2110
+ if (declaredArg.variadic) {
2111
+ if (index < this.args.length) {
2112
+ value = this.args.slice(index);
2113
+ if (declaredArg.parseArg) {
2114
+ value = value.reduce((processed, v) => {
2115
+ return myParseArg(declaredArg, v, processed);
2116
+ }, declaredArg.defaultValue);
2117
+ }
2118
+ } else if (value === void 0) {
2119
+ value = [];
2120
+ }
2121
+ } else if (index < this.args.length) {
2122
+ value = this.args[index];
2123
+ if (declaredArg.parseArg) {
2124
+ value = myParseArg(declaredArg, value, declaredArg.defaultValue);
2125
+ }
2126
+ }
2127
+ processedArgs[index] = value;
2128
+ });
2129
+ this.processedArgs = processedArgs;
2130
+ }
2131
+ /**
2132
+ * Once we have a promise we chain, but call synchronously until then.
2133
+ *
2134
+ * @param {(Promise|undefined)} promise
2135
+ * @param {Function} fn
2136
+ * @return {(Promise|undefined)}
2137
+ * @private
2138
+ */
2139
+ _chainOrCall(promise, fn) {
2140
+ if (promise && promise.then && typeof promise.then === "function") {
2141
+ return promise.then(() => fn());
2142
+ }
2143
+ return fn();
2144
+ }
2145
+ /**
2146
+ *
2147
+ * @param {(Promise|undefined)} promise
2148
+ * @param {string} event
2149
+ * @return {(Promise|undefined)}
2150
+ * @private
2151
+ */
2152
+ _chainOrCallHooks(promise, event) {
2153
+ let result = promise;
2154
+ const hooks = [];
2155
+ this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== void 0).forEach((hookedCommand) => {
2156
+ hookedCommand._lifeCycleHooks[event].forEach((callback) => {
2157
+ hooks.push({ hookedCommand, callback });
2158
+ });
2159
+ });
2160
+ if (event === "postAction") {
2161
+ hooks.reverse();
2162
+ }
2163
+ hooks.forEach((hookDetail) => {
2164
+ result = this._chainOrCall(result, () => {
2165
+ return hookDetail.callback(hookDetail.hookedCommand, this);
2166
+ });
2167
+ });
2168
+ return result;
2169
+ }
2170
+ /**
2171
+ *
2172
+ * @param {(Promise|undefined)} promise
2173
+ * @param {Command} subCommand
2174
+ * @param {string} event
2175
+ * @return {(Promise|undefined)}
2176
+ * @private
2177
+ */
2178
+ _chainOrCallSubCommandHook(promise, subCommand, event) {
2179
+ let result = promise;
2180
+ if (this._lifeCycleHooks[event] !== void 0) {
2181
+ this._lifeCycleHooks[event].forEach((hook) => {
2182
+ result = this._chainOrCall(result, () => {
2183
+ return hook(this, subCommand);
2184
+ });
2185
+ });
2186
+ }
2187
+ return result;
2188
+ }
2189
+ /**
2190
+ * Process arguments in context of this command.
2191
+ * Returns action result, in case it is a promise.
2192
+ *
2193
+ * @private
2194
+ */
2195
+ _parseCommand(operands, unknown) {
2196
+ const parsed = this.parseOptions(unknown);
2197
+ this._parseOptionsEnv();
2198
+ this._parseOptionsImplied();
2199
+ operands = operands.concat(parsed.operands);
2200
+ unknown = parsed.unknown;
2201
+ this.args = operands.concat(unknown);
2202
+ if (operands && this._findCommand(operands[0])) {
2203
+ return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
2204
+ }
2205
+ if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
2206
+ return this._dispatchHelpCommand(operands[1]);
2207
+ }
2208
+ if (this._defaultCommandName) {
2209
+ this._outputHelpIfRequested(unknown);
2210
+ return this._dispatchSubcommand(
2211
+ this._defaultCommandName,
2212
+ operands,
2213
+ unknown
2214
+ );
2215
+ }
2216
+ if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
2217
+ this.help({ error: true });
2218
+ }
2219
+ this._outputHelpIfRequested(parsed.unknown);
2220
+ this._checkForMissingMandatoryOptions();
2221
+ this._checkForConflictingOptions();
2222
+ const checkForUnknownOptions = () => {
2223
+ if (parsed.unknown.length > 0) {
2224
+ this.unknownOption(parsed.unknown[0]);
2225
+ }
2226
+ };
2227
+ const commandEvent = `command:${this.name()}`;
2228
+ if (this._actionHandler) {
2229
+ checkForUnknownOptions();
2230
+ this._processArguments();
2231
+ let promiseChain;
2232
+ promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
2233
+ promiseChain = this._chainOrCall(
2234
+ promiseChain,
2235
+ () => this._actionHandler(this.processedArgs)
2236
+ );
2237
+ if (this.parent) {
2238
+ promiseChain = this._chainOrCall(promiseChain, () => {
2239
+ this.parent.emit(commandEvent, operands, unknown);
2240
+ });
2241
+ }
2242
+ promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
2243
+ return promiseChain;
2244
+ }
2245
+ if (this.parent && this.parent.listenerCount(commandEvent)) {
2246
+ checkForUnknownOptions();
2247
+ this._processArguments();
2248
+ this.parent.emit(commandEvent, operands, unknown);
2249
+ } else if (operands.length) {
2250
+ if (this._findCommand("*")) {
2251
+ return this._dispatchSubcommand("*", operands, unknown);
2252
+ }
2253
+ if (this.listenerCount("command:*")) {
2254
+ this.emit("command:*", operands, unknown);
2255
+ } else if (this.commands.length) {
2256
+ this.unknownCommand();
2257
+ } else {
2258
+ checkForUnknownOptions();
2259
+ this._processArguments();
2260
+ }
2261
+ } else if (this.commands.length) {
2262
+ checkForUnknownOptions();
2263
+ this.help({ error: true });
2264
+ } else {
2265
+ checkForUnknownOptions();
2266
+ this._processArguments();
2267
+ }
2268
+ }
2269
+ /**
2270
+ * Find matching command.
2271
+ *
2272
+ * @private
2273
+ * @return {Command | undefined}
2274
+ */
2275
+ _findCommand(name) {
2276
+ if (!name) return void 0;
2277
+ return this.commands.find(
2278
+ (cmd) => cmd._name === name || cmd._aliases.includes(name)
2279
+ );
2280
+ }
2281
+ /**
2282
+ * Return an option matching `arg` if any.
2283
+ *
2284
+ * @param {string} arg
2285
+ * @return {Option}
2286
+ * @package
2287
+ */
2288
+ _findOption(arg) {
2289
+ return this.options.find((option) => option.is(arg));
2290
+ }
2291
+ /**
2292
+ * Display an error message if a mandatory option does not have a value.
2293
+ * Called after checking for help flags in leaf subcommand.
2294
+ *
2295
+ * @private
2296
+ */
2297
+ _checkForMissingMandatoryOptions() {
2298
+ this._getCommandAndAncestors().forEach((cmd) => {
2299
+ cmd.options.forEach((anOption) => {
2300
+ if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === void 0) {
2301
+ cmd.missingMandatoryOptionValue(anOption);
2302
+ }
2303
+ });
2304
+ });
2305
+ }
2306
+ /**
2307
+ * Display an error message if conflicting options are used together in this.
2308
+ *
2309
+ * @private
2310
+ */
2311
+ _checkForConflictingLocalOptions() {
2312
+ const definedNonDefaultOptions = this.options.filter((option) => {
2313
+ const optionKey = option.attributeName();
2314
+ if (this.getOptionValue(optionKey) === void 0) {
2315
+ return false;
2316
+ }
2317
+ return this.getOptionValueSource(optionKey) !== "default";
2318
+ });
2319
+ const optionsWithConflicting = definedNonDefaultOptions.filter(
2320
+ (option) => option.conflictsWith.length > 0
2321
+ );
2322
+ optionsWithConflicting.forEach((option) => {
2323
+ const conflictingAndDefined = definedNonDefaultOptions.find(
2324
+ (defined) => option.conflictsWith.includes(defined.attributeName())
2325
+ );
2326
+ if (conflictingAndDefined) {
2327
+ this._conflictingOption(option, conflictingAndDefined);
2328
+ }
2329
+ });
2330
+ }
2331
+ /**
2332
+ * Display an error message if conflicting options are used together.
2333
+ * Called after checking for help flags in leaf subcommand.
2334
+ *
2335
+ * @private
2336
+ */
2337
+ _checkForConflictingOptions() {
2338
+ this._getCommandAndAncestors().forEach((cmd) => {
2339
+ cmd._checkForConflictingLocalOptions();
2340
+ });
2341
+ }
2342
+ /**
2343
+ * Parse options from `argv` removing known options,
2344
+ * and return argv split into operands and unknown arguments.
2345
+ *
2346
+ * Examples:
2347
+ *
2348
+ * argv => operands, unknown
2349
+ * --known kkk op => [op], []
2350
+ * op --known kkk => [op], []
2351
+ * sub --unknown uuu op => [sub], [--unknown uuu op]
2352
+ * sub -- --unknown uuu op => [sub --unknown uuu op], []
2353
+ *
2354
+ * @param {string[]} argv
2355
+ * @return {{operands: string[], unknown: string[]}}
2356
+ */
2357
+ parseOptions(argv) {
2358
+ const operands = [];
2359
+ const unknown = [];
2360
+ let dest = operands;
2361
+ const args = argv.slice();
2362
+ function maybeOption(arg) {
2363
+ return arg.length > 1 && arg[0] === "-";
2364
+ }
2365
+ let activeVariadicOption = null;
2366
+ while (args.length) {
2367
+ const arg = args.shift();
2368
+ if (arg === "--") {
2369
+ if (dest === unknown) dest.push(arg);
2370
+ dest.push(...args);
2371
+ break;
2372
+ }
2373
+ if (activeVariadicOption && !maybeOption(arg)) {
2374
+ this.emit(`option:${activeVariadicOption.name()}`, arg);
2375
+ continue;
2376
+ }
2377
+ activeVariadicOption = null;
2378
+ if (maybeOption(arg)) {
2379
+ const option = this._findOption(arg);
2380
+ if (option) {
2381
+ if (option.required) {
2382
+ const value = args.shift();
2383
+ if (value === void 0) this.optionMissingArgument(option);
2384
+ this.emit(`option:${option.name()}`, value);
2385
+ } else if (option.optional) {
2386
+ let value = null;
2387
+ if (args.length > 0 && !maybeOption(args[0])) {
2388
+ value = args.shift();
2389
+ }
2390
+ this.emit(`option:${option.name()}`, value);
2391
+ } else {
2392
+ this.emit(`option:${option.name()}`);
2393
+ }
2394
+ activeVariadicOption = option.variadic ? option : null;
2395
+ continue;
2396
+ }
2397
+ }
2398
+ if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
2399
+ const option = this._findOption(`-${arg[1]}`);
2400
+ if (option) {
2401
+ if (option.required || option.optional && this._combineFlagAndOptionalValue) {
2402
+ this.emit(`option:${option.name()}`, arg.slice(2));
2403
+ } else {
2404
+ this.emit(`option:${option.name()}`);
2405
+ args.unshift(`-${arg.slice(2)}`);
2406
+ }
2407
+ continue;
2408
+ }
2409
+ }
2410
+ if (/^--[^=]+=/.test(arg)) {
2411
+ const index = arg.indexOf("=");
2412
+ const option = this._findOption(arg.slice(0, index));
2413
+ if (option && (option.required || option.optional)) {
2414
+ this.emit(`option:${option.name()}`, arg.slice(index + 1));
2415
+ continue;
2416
+ }
2417
+ }
2418
+ if (maybeOption(arg)) {
2419
+ dest = unknown;
2420
+ }
2421
+ if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
2422
+ if (this._findCommand(arg)) {
2423
+ operands.push(arg);
2424
+ if (args.length > 0) unknown.push(...args);
2425
+ break;
2426
+ } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
2427
+ operands.push(arg);
2428
+ if (args.length > 0) operands.push(...args);
2429
+ break;
2430
+ } else if (this._defaultCommandName) {
2431
+ unknown.push(arg);
2432
+ if (args.length > 0) unknown.push(...args);
2433
+ break;
2434
+ }
2435
+ }
2436
+ if (this._passThroughOptions) {
2437
+ dest.push(arg);
2438
+ if (args.length > 0) dest.push(...args);
2439
+ break;
2440
+ }
2441
+ dest.push(arg);
2442
+ }
2443
+ return { operands, unknown };
2444
+ }
2445
+ /**
2446
+ * Return an object containing local option values as key-value pairs.
2447
+ *
2448
+ * @return {object}
2449
+ */
2450
+ opts() {
2451
+ if (this._storeOptionsAsProperties) {
2452
+ const result = {};
2453
+ const len = this.options.length;
2454
+ for (let i = 0; i < len; i++) {
2455
+ const key = this.options[i].attributeName();
2456
+ result[key] = key === this._versionOptionName ? this._version : this[key];
2457
+ }
2458
+ return result;
2459
+ }
2460
+ return this._optionValues;
2461
+ }
2462
+ /**
2463
+ * Return an object containing merged local and global option values as key-value pairs.
2464
+ *
2465
+ * @return {object}
2466
+ */
2467
+ optsWithGlobals() {
2468
+ return this._getCommandAndAncestors().reduce(
2469
+ (combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()),
2470
+ {}
2471
+ );
2472
+ }
2473
+ /**
2474
+ * Display error message and exit (or call exitOverride).
2475
+ *
2476
+ * @param {string} message
2477
+ * @param {object} [errorOptions]
2478
+ * @param {string} [errorOptions.code] - an id string representing the error
2479
+ * @param {number} [errorOptions.exitCode] - used with process.exit
2480
+ */
2481
+ error(message, errorOptions) {
2482
+ this._outputConfiguration.outputError(
2483
+ `${message}
2484
+ `,
2485
+ this._outputConfiguration.writeErr
2486
+ );
2487
+ if (typeof this._showHelpAfterError === "string") {
2488
+ this._outputConfiguration.writeErr(`${this._showHelpAfterError}
2489
+ `);
2490
+ } else if (this._showHelpAfterError) {
2491
+ this._outputConfiguration.writeErr("\n");
2492
+ this.outputHelp({ error: true });
2493
+ }
2494
+ const config = errorOptions || {};
2495
+ const exitCode = config.exitCode || 1;
2496
+ const code = config.code || "commander.error";
2497
+ this._exit(exitCode, code, message);
2498
+ }
2499
+ /**
2500
+ * Apply any option related environment variables, if option does
2501
+ * not have a value from cli or client code.
2502
+ *
2503
+ * @private
2504
+ */
2505
+ _parseOptionsEnv() {
2506
+ this.options.forEach((option) => {
2507
+ if (option.envVar && option.envVar in process2.env) {
2508
+ const optionKey = option.attributeName();
2509
+ if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(
2510
+ this.getOptionValueSource(optionKey)
2511
+ )) {
2512
+ if (option.required || option.optional) {
2513
+ this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
2514
+ } else {
2515
+ this.emit(`optionEnv:${option.name()}`);
2516
+ }
2517
+ }
2518
+ }
2519
+ });
2520
+ }
2521
+ /**
2522
+ * Apply any implied option values, if option is undefined or default value.
2523
+ *
2524
+ * @private
2525
+ */
2526
+ _parseOptionsImplied() {
2527
+ const dualHelper = new DualOptions(this.options);
2528
+ const hasCustomOptionValue = (optionKey) => {
2529
+ return this.getOptionValue(optionKey) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
2530
+ };
2531
+ this.options.filter(
2532
+ (option) => option.implied !== void 0 && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(
2533
+ this.getOptionValue(option.attributeName()),
2534
+ option
2535
+ )
2536
+ ).forEach((option) => {
2537
+ Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
2538
+ this.setOptionValueWithSource(
2539
+ impliedKey,
2540
+ option.implied[impliedKey],
2541
+ "implied"
2542
+ );
2543
+ });
2544
+ });
2545
+ }
2546
+ /**
2547
+ * Argument `name` is missing.
2548
+ *
2549
+ * @param {string} name
2550
+ * @private
2551
+ */
2552
+ missingArgument(name) {
2553
+ const message = `error: missing required argument '${name}'`;
2554
+ this.error(message, { code: "commander.missingArgument" });
2555
+ }
2556
+ /**
2557
+ * `Option` is missing an argument.
2558
+ *
2559
+ * @param {Option} option
2560
+ * @private
2561
+ */
2562
+ optionMissingArgument(option) {
2563
+ const message = `error: option '${option.flags}' argument missing`;
2564
+ this.error(message, { code: "commander.optionMissingArgument" });
2565
+ }
2566
+ /**
2567
+ * `Option` does not have a value, and is a mandatory option.
2568
+ *
2569
+ * @param {Option} option
2570
+ * @private
2571
+ */
2572
+ missingMandatoryOptionValue(option) {
2573
+ const message = `error: required option '${option.flags}' not specified`;
2574
+ this.error(message, { code: "commander.missingMandatoryOptionValue" });
2575
+ }
2576
+ /**
2577
+ * `Option` conflicts with another option.
2578
+ *
2579
+ * @param {Option} option
2580
+ * @param {Option} conflictingOption
2581
+ * @private
2582
+ */
2583
+ _conflictingOption(option, conflictingOption) {
2584
+ const findBestOptionFromValue = (option2) => {
2585
+ const optionKey = option2.attributeName();
2586
+ const optionValue = this.getOptionValue(optionKey);
2587
+ const negativeOption = this.options.find(
2588
+ (target) => target.negate && optionKey === target.attributeName()
2589
+ );
2590
+ const positiveOption = this.options.find(
2591
+ (target) => !target.negate && optionKey === target.attributeName()
2592
+ );
2593
+ if (negativeOption && (negativeOption.presetArg === void 0 && optionValue === false || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg)) {
2594
+ return negativeOption;
2595
+ }
2596
+ return positiveOption || option2;
2597
+ };
2598
+ const getErrorMessage = (option2) => {
2599
+ const bestOption = findBestOptionFromValue(option2);
2600
+ const optionKey = bestOption.attributeName();
2601
+ const source = this.getOptionValueSource(optionKey);
2602
+ if (source === "env") {
2603
+ return `environment variable '${bestOption.envVar}'`;
2604
+ }
2605
+ return `option '${bestOption.flags}'`;
2606
+ };
2607
+ const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
2608
+ this.error(message, { code: "commander.conflictingOption" });
2609
+ }
2610
+ /**
2611
+ * Unknown option `flag`.
2612
+ *
2613
+ * @param {string} flag
2614
+ * @private
2615
+ */
2616
+ unknownOption(flag) {
2617
+ if (this._allowUnknownOption) return;
2618
+ let suggestion = "";
2619
+ if (flag.startsWith("--") && this._showSuggestionAfterError) {
2620
+ let candidateFlags = [];
2621
+ let command = this;
2622
+ do {
2623
+ const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
2624
+ candidateFlags = candidateFlags.concat(moreFlags);
2625
+ command = command.parent;
2626
+ } while (command && !command._enablePositionalOptions);
2627
+ suggestion = suggestSimilar(flag, candidateFlags);
2628
+ }
2629
+ const message = `error: unknown option '${flag}'${suggestion}`;
2630
+ this.error(message, { code: "commander.unknownOption" });
2631
+ }
2632
+ /**
2633
+ * Excess arguments, more than expected.
2634
+ *
2635
+ * @param {string[]} receivedArgs
2636
+ * @private
2637
+ */
2638
+ _excessArguments(receivedArgs) {
2639
+ if (this._allowExcessArguments) return;
2640
+ const expected = this.registeredArguments.length;
2641
+ const s = expected === 1 ? "" : "s";
2642
+ const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
2643
+ const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
2644
+ this.error(message, { code: "commander.excessArguments" });
2645
+ }
2646
+ /**
2647
+ * Unknown command.
2648
+ *
2649
+ * @private
2650
+ */
2651
+ unknownCommand() {
2652
+ const unknownName = this.args[0];
2653
+ let suggestion = "";
2654
+ if (this._showSuggestionAfterError) {
2655
+ const candidateNames = [];
2656
+ this.createHelp().visibleCommands(this).forEach((command) => {
2657
+ candidateNames.push(command.name());
2658
+ if (command.alias()) candidateNames.push(command.alias());
2659
+ });
2660
+ suggestion = suggestSimilar(unknownName, candidateNames);
2661
+ }
2662
+ const message = `error: unknown command '${unknownName}'${suggestion}`;
2663
+ this.error(message, { code: "commander.unknownCommand" });
2664
+ }
2665
+ /**
2666
+ * Get or set the program version.
2667
+ *
2668
+ * This method auto-registers the "-V, --version" option which will print the version number.
2669
+ *
2670
+ * You can optionally supply the flags and description to override the defaults.
2671
+ *
2672
+ * @param {string} [str]
2673
+ * @param {string} [flags]
2674
+ * @param {string} [description]
2675
+ * @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments
2676
+ */
2677
+ version(str, flags, description) {
2678
+ if (str === void 0) return this._version;
2679
+ this._version = str;
2680
+ flags = flags || "-V, --version";
2681
+ description = description || "output the version number";
2682
+ const versionOption = this.createOption(flags, description);
2683
+ this._versionOptionName = versionOption.attributeName();
2684
+ this._registerOption(versionOption);
2685
+ this.on("option:" + versionOption.name(), () => {
2686
+ this._outputConfiguration.writeOut(`${str}
2687
+ `);
2688
+ this._exit(0, "commander.version", str);
2689
+ });
2690
+ return this;
2691
+ }
2692
+ /**
2693
+ * Set the description.
2694
+ *
2695
+ * @param {string} [str]
2696
+ * @param {object} [argsDescription]
2697
+ * @return {(string|Command)}
2698
+ */
2699
+ description(str, argsDescription) {
2700
+ if (str === void 0 && argsDescription === void 0)
2701
+ return this._description;
2702
+ this._description = str;
2703
+ if (argsDescription) {
2704
+ this._argsDescription = argsDescription;
2705
+ }
2706
+ return this;
2707
+ }
2708
+ /**
2709
+ * Set the summary. Used when listed as subcommand of parent.
2710
+ *
2711
+ * @param {string} [str]
2712
+ * @return {(string|Command)}
2713
+ */
2714
+ summary(str) {
2715
+ if (str === void 0) return this._summary;
2716
+ this._summary = str;
2717
+ return this;
2718
+ }
2719
+ /**
2720
+ * Set an alias for the command.
2721
+ *
2722
+ * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
2723
+ *
2724
+ * @param {string} [alias]
2725
+ * @return {(string|Command)}
2726
+ */
2727
+ alias(alias) {
2728
+ if (alias === void 0) return this._aliases[0];
2729
+ let command = this;
2730
+ if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
2731
+ command = this.commands[this.commands.length - 1];
2732
+ }
2733
+ if (alias === command._name)
2734
+ throw new Error("Command alias can't be the same as its name");
2735
+ const matchingCommand = this.parent?._findCommand(alias);
2736
+ if (matchingCommand) {
2737
+ const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
2738
+ throw new Error(
2739
+ `cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`
2740
+ );
2741
+ }
2742
+ command._aliases.push(alias);
2743
+ return this;
2744
+ }
2745
+ /**
2746
+ * Set aliases for the command.
2747
+ *
2748
+ * Only the first alias is shown in the auto-generated help.
2749
+ *
2750
+ * @param {string[]} [aliases]
2751
+ * @return {(string[]|Command)}
2752
+ */
2753
+ aliases(aliases) {
2754
+ if (aliases === void 0) return this._aliases;
2755
+ aliases.forEach((alias) => this.alias(alias));
2756
+ return this;
2757
+ }
2758
+ /**
2759
+ * Set / get the command usage `str`.
2760
+ *
2761
+ * @param {string} [str]
2762
+ * @return {(string|Command)}
2763
+ */
2764
+ usage(str) {
2765
+ if (str === void 0) {
2766
+ if (this._usage) return this._usage;
2767
+ const args = this.registeredArguments.map((arg) => {
2768
+ return humanReadableArgName(arg);
2769
+ });
2770
+ return [].concat(
2771
+ this.options.length || this._helpOption !== null ? "[options]" : [],
2772
+ this.commands.length ? "[command]" : [],
2773
+ this.registeredArguments.length ? args : []
2774
+ ).join(" ");
2775
+ }
2776
+ this._usage = str;
2777
+ return this;
2778
+ }
2779
+ /**
2780
+ * Get or set the name of the command.
2781
+ *
2782
+ * @param {string} [str]
2783
+ * @return {(string|Command)}
2784
+ */
2785
+ name(str) {
2786
+ if (str === void 0) return this._name;
2787
+ this._name = str;
2788
+ return this;
2789
+ }
2790
+ /**
2791
+ * Set the name of the command from script filename, such as process.argv[1],
2792
+ * or require.main.filename, or __filename.
2793
+ *
2794
+ * (Used internally and public although not documented in README.)
2795
+ *
2796
+ * @example
2797
+ * program.nameFromFilename(require.main.filename);
2798
+ *
2799
+ * @param {string} filename
2800
+ * @return {Command}
2801
+ */
2802
+ nameFromFilename(filename) {
2803
+ this._name = path2.basename(filename, path2.extname(filename));
2804
+ return this;
2805
+ }
2806
+ /**
2807
+ * Get or set the directory for searching for executable subcommands of this command.
2808
+ *
2809
+ * @example
2810
+ * program.executableDir(__dirname);
2811
+ * // or
2812
+ * program.executableDir('subcommands');
2813
+ *
2814
+ * @param {string} [path]
2815
+ * @return {(string|null|Command)}
2816
+ */
2817
+ executableDir(path3) {
2818
+ if (path3 === void 0) return this._executableDir;
2819
+ this._executableDir = path3;
2820
+ return this;
2821
+ }
2822
+ /**
2823
+ * Return program help documentation.
2824
+ *
2825
+ * @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout
2826
+ * @return {string}
2827
+ */
2828
+ helpInformation(contextOptions) {
2829
+ const helper = this.createHelp();
2830
+ if (helper.helpWidth === void 0) {
2831
+ helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
2832
+ }
2833
+ return helper.formatHelp(this, helper);
2834
+ }
2835
+ /**
2836
+ * @private
2837
+ */
2838
+ _getHelpContext(contextOptions) {
2839
+ contextOptions = contextOptions || {};
2840
+ const context = { error: !!contextOptions.error };
2841
+ let write;
2842
+ if (context.error) {
2843
+ write = (arg) => this._outputConfiguration.writeErr(arg);
2844
+ } else {
2845
+ write = (arg) => this._outputConfiguration.writeOut(arg);
2846
+ }
2847
+ context.write = contextOptions.write || write;
2848
+ context.command = this;
2849
+ return context;
2850
+ }
2851
+ /**
2852
+ * Output help information for this command.
2853
+ *
2854
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
2855
+ *
2856
+ * @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout
2857
+ */
2858
+ outputHelp(contextOptions) {
2859
+ let deprecatedCallback;
2860
+ if (typeof contextOptions === "function") {
2861
+ deprecatedCallback = contextOptions;
2862
+ contextOptions = void 0;
2863
+ }
2864
+ const context = this._getHelpContext(contextOptions);
2865
+ this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", context));
2866
+ this.emit("beforeHelp", context);
2867
+ let helpInformation = this.helpInformation(context);
2868
+ if (deprecatedCallback) {
2869
+ helpInformation = deprecatedCallback(helpInformation);
2870
+ if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
2871
+ throw new Error("outputHelp callback must return a string or a Buffer");
2872
+ }
2873
+ }
2874
+ context.write(helpInformation);
2875
+ if (this._getHelpOption()?.long) {
2876
+ this.emit(this._getHelpOption().long);
2877
+ }
2878
+ this.emit("afterHelp", context);
2879
+ this._getCommandAndAncestors().forEach(
2880
+ (command) => command.emit("afterAllHelp", context)
2881
+ );
2882
+ }
2883
+ /**
2884
+ * You can pass in flags and a description to customise the built-in help option.
2885
+ * Pass in false to disable the built-in help option.
2886
+ *
2887
+ * @example
2888
+ * program.helpOption('-?, --help' 'show help'); // customise
2889
+ * program.helpOption(false); // disable
2890
+ *
2891
+ * @param {(string | boolean)} flags
2892
+ * @param {string} [description]
2893
+ * @return {Command} `this` command for chaining
2894
+ */
2895
+ helpOption(flags, description) {
2896
+ if (typeof flags === "boolean") {
2897
+ if (flags) {
2898
+ this._helpOption = this._helpOption ?? void 0;
2899
+ } else {
2900
+ this._helpOption = null;
2901
+ }
2902
+ return this;
2903
+ }
2904
+ flags = flags ?? "-h, --help";
2905
+ description = description ?? "display help for command";
2906
+ this._helpOption = this.createOption(flags, description);
2907
+ return this;
2908
+ }
2909
+ /**
2910
+ * Lazy create help option.
2911
+ * Returns null if has been disabled with .helpOption(false).
2912
+ *
2913
+ * @returns {(Option | null)} the help option
2914
+ * @package
2915
+ */
2916
+ _getHelpOption() {
2917
+ if (this._helpOption === void 0) {
2918
+ this.helpOption(void 0, void 0);
2919
+ }
2920
+ return this._helpOption;
2921
+ }
2922
+ /**
2923
+ * Supply your own option to use for the built-in help option.
2924
+ * This is an alternative to using helpOption() to customise the flags and description etc.
2925
+ *
2926
+ * @param {Option} option
2927
+ * @return {Command} `this` command for chaining
2928
+ */
2929
+ addHelpOption(option) {
2930
+ this._helpOption = option;
2931
+ return this;
2932
+ }
2933
+ /**
2934
+ * Output help information and exit.
2935
+ *
2936
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
2937
+ *
2938
+ * @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout
2939
+ */
2940
+ help(contextOptions) {
2941
+ this.outputHelp(contextOptions);
2942
+ let exitCode = process2.exitCode || 0;
2943
+ if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2944
+ exitCode = 1;
2945
+ }
2946
+ this._exit(exitCode, "commander.help", "(outputHelp)");
2947
+ }
2948
+ /**
2949
+ * Add additional text to be displayed with the built-in help.
2950
+ *
2951
+ * Position is 'before' or 'after' to affect just this command,
2952
+ * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
2953
+ *
2954
+ * @param {string} position - before or after built-in help
2955
+ * @param {(string | Function)} text - string to add, or a function returning a string
2956
+ * @return {Command} `this` command for chaining
2957
+ */
2958
+ addHelpText(position, text) {
2959
+ const allowedValues = ["beforeAll", "before", "after", "afterAll"];
2960
+ if (!allowedValues.includes(position)) {
2961
+ throw new Error(`Unexpected value for position to addHelpText.
2962
+ Expecting one of '${allowedValues.join("', '")}'`);
2963
+ }
2964
+ const helpEvent = `${position}Help`;
2965
+ this.on(helpEvent, (context) => {
2966
+ let helpStr;
2967
+ if (typeof text === "function") {
2968
+ helpStr = text({ error: context.error, command: context.command });
2969
+ } else {
2970
+ helpStr = text;
2971
+ }
2972
+ if (helpStr) {
2973
+ context.write(`${helpStr}
2974
+ `);
2975
+ }
2976
+ });
2977
+ return this;
2978
+ }
2979
+ /**
2980
+ * Output help information if help flags specified
2981
+ *
2982
+ * @param {Array} args - array of options to search for help flags
2983
+ * @private
2984
+ */
2985
+ _outputHelpIfRequested(args) {
2986
+ const helpOption = this._getHelpOption();
2987
+ const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
2988
+ if (helpRequested) {
2989
+ this.outputHelp();
2990
+ this._exit(0, "commander.helpDisplayed", "(outputHelp)");
2991
+ }
2992
+ }
2993
+ };
2994
+ function incrementNodeInspectorPort(args) {
2995
+ return args.map((arg) => {
2996
+ if (!arg.startsWith("--inspect")) {
2997
+ return arg;
2998
+ }
2999
+ let debugOption;
3000
+ let debugHost = "127.0.0.1";
3001
+ let debugPort = "9229";
3002
+ let match;
3003
+ if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
3004
+ debugOption = match[1];
3005
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
3006
+ debugOption = match[1];
3007
+ if (/^\d+$/.test(match[3])) {
3008
+ debugPort = match[3];
3009
+ } else {
3010
+ debugHost = match[3];
3011
+ }
3012
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
3013
+ debugOption = match[1];
3014
+ debugHost = match[3];
3015
+ debugPort = match[4];
3016
+ }
3017
+ if (debugOption && debugPort !== "0") {
3018
+ return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
3019
+ }
3020
+ return arg;
3021
+ });
3022
+ }
3023
+ exports.Command = Command2;
3024
+ }
3025
+ });
3026
+
3027
+ // node_modules/commander/index.js
3028
+ var require_commander = __commonJS({
3029
+ "node_modules/commander/index.js"(exports) {
3030
+ "use strict";
3031
+ init_esm_shims();
3032
+ var { Argument: Argument2 } = require_argument();
3033
+ var { Command: Command2 } = require_command();
3034
+ var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
3035
+ var { Help: Help2 } = require_help();
3036
+ var { Option: Option2 } = require_option();
3037
+ exports.program = new Command2();
3038
+ exports.createCommand = (name) => new Command2(name);
3039
+ exports.createOption = (flags, description) => new Option2(flags, description);
3040
+ exports.createArgument = (name, description) => new Argument2(name, description);
3041
+ exports.Command = Command2;
3042
+ exports.Option = Option2;
3043
+ exports.Argument = Argument2;
3044
+ exports.Help = Help2;
3045
+ exports.CommanderError = CommanderError2;
3046
+ exports.InvalidArgumentError = InvalidArgumentError2;
3047
+ exports.InvalidOptionArgumentError = InvalidArgumentError2;
3048
+ }
3049
+ });
3050
+
3051
+ // bin/eventcatalog.ts
3052
+ init_esm_shims();
3053
+
3054
+ // node_modules/commander/esm.mjs
3055
+ init_esm_shims();
3056
+ var import_index = __toESM(require_commander(), 1);
3057
+ var {
3058
+ program,
3059
+ createCommand,
3060
+ createArgument,
3061
+ createOption,
3062
+ CommanderError,
3063
+ InvalidArgumentError,
3064
+ InvalidOptionArgumentError,
3065
+ // deprecated old name
3066
+ Command,
3067
+ Argument,
3068
+ Option,
3069
+ Help
3070
+ } = import_index.default;
3071
+
3072
+ // bin/eventcatalog.ts
3073
+ import { exec, execSync } from "node:child_process";
3074
+ import { join } from "node:path";
3075
+ import fs from "fs";
3076
+ import path from "node:path";
3077
+ import { fileURLToPath } from "node:url";
3078
+ var currentDir = path.dirname(fileURLToPath(import.meta.url));
3079
+ var program2 = new Command();
3080
+ var dir = process.cwd();
3081
+ var core = join(dir, ".eventcatalog-core");
3082
+ var eventCatalogDir = join(currentDir, "../../");
3083
+ program2.name("eventcatalog").description("Documentation tool for event-driven architectures");
3084
+ var copyFile = (from, to) => {
3085
+ if (fs.existsSync(from)) {
3086
+ fs.cpSync(from, to);
3087
+ }
3088
+ };
3089
+ var copyFolder = (from, to) => {
3090
+ if (fs.existsSync(from)) {
3091
+ fs.cpSync(from, to, { recursive: true });
3092
+ }
3093
+ };
3094
+ var ensureDir = (dir2) => {
3095
+ if (!fs.existsSync(dir2)) {
3096
+ fs.mkdirSync(dir2);
3097
+ }
3098
+ };
3099
+ var copyCore = () => {
3100
+ if (fs.existsSync(core)) {
3101
+ fs.rmSync(core, { recursive: true });
3102
+ }
3103
+ ensureDir(core);
3104
+ fs.cpSync(eventCatalogDir, core, {
3105
+ recursive: true,
3106
+ filter: (src) => {
3107
+ return true;
3108
+ }
3109
+ });
3110
+ };
3111
+ program2.command("dev").description("Run development server of EventCatalog").option("-d, --debug", "Output EventCatalog application information into your terminal").action((options) => {
3112
+ console.log("Setting up EventCatalog...");
3113
+ if (options.debug) {
3114
+ console.log("Debug mode enabled");
3115
+ console.log("PROJECT_DIR", dir);
3116
+ console.log("CATALOG_DIR", core);
3117
+ }
3118
+ copyCore();
3119
+ copyFolder(join(dir, "public"), join(core, "public"));
3120
+ copyFile(join(dir, "eventcatalog.config.js"), join(core, "eventcatalog.config.js"));
3121
+ copyFile(join(dir, "eventcatalog.styles.css"), join(core, "eventcatalog.styles.css"));
3122
+ const command = options.debug ? "execSync" : "exec";
3123
+ const execOptions = { exec, execSync };
3124
+ execOptions[command](`PROJECT_DIR='${dir}' CATALOG_DIR='${core}' npm run dev`, {
3125
+ cwd: core,
3126
+ // @ts-ignore
3127
+ stdio: "inherit"
3128
+ });
3129
+ console.log("EventCatalog has started on port 3000: http://localhost:3000/docs");
3130
+ });
3131
+ program2.command("build").description("Run build of EventCatalog").action((options) => {
3132
+ copyFolder(join(dir, "public"), join(core, "public"));
3133
+ copyFile(join(dir, "eventcatalog.config.js"), join(core, "eventcatalog.config.js"));
3134
+ copyFile(join(dir, "eventcatalog.styles.css"), join(core, "eventcatalog.styles.css"));
3135
+ execSync(`PROJECT_DIR='${dir}' CATALOG_DIR='${core}' npm run build`, {
3136
+ cwd: core,
3137
+ stdio: "inherit"
3138
+ });
3139
+ copyFolder(join(core, "dist"), join(dir, "dist"));
3140
+ });
3141
+ program2.parse();