@kubb/cli 5.18.6 → 5.18.8

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 (193) hide show
  1. package/dist/{Telemetry-CZJ2Noi6.cjs → Telemetry-CBzCK4kO.cjs} +5 -5
  2. package/dist/{Telemetry-CZJ2Noi6.cjs.map → Telemetry-CBzCK4kO.cjs.map} +1 -1
  3. package/dist/{Telemetry-DQG_EpcV.js → Telemetry-DUl_hxVn.js} +5 -5
  4. package/dist/{Telemetry-DQG_EpcV.js.map → Telemetry-DUl_hxVn.js.map} +1 -1
  5. package/dist/{background-Z23KW1yA.js → background-CA9lRKAK.js} +4 -4
  6. package/dist/{background-Z23KW1yA.js.map → background-CA9lRKAK.js.map} +1 -1
  7. package/dist/{background-Dsy12RvL.js → background-DK3HLyNk.js} +1 -1
  8. package/dist/{background-DIVc60mm.cjs → background-fhpYDuSs.cjs} +4 -4
  9. package/dist/{background-DIVc60mm.cjs.map → background-fhpYDuSs.cjs.map} +1 -1
  10. package/dist/{banner-BdTTDFkG.js → banner-BMIxunVW.js} +3 -3
  11. package/dist/{banner-BdTTDFkG.js.map → banner-BMIxunVW.js.map} +1 -1
  12. package/dist/{banner-wJFk-L-c.cjs → banner-GwQ2NFNI.cjs} +3 -3
  13. package/dist/{banner-wJFk-L-c.cjs.map → banner-GwQ2NFNI.cjs.map} +1 -1
  14. package/dist/config-BKi_vTvh.js +1 -0
  15. package/dist/{config-CRrmj88c.cjs → config-BU9xeaGq.cjs} +3 -3
  16. package/dist/{config-CRrmj88c.cjs.map → config-BU9xeaGq.cjs.map} +1 -1
  17. package/dist/{config-Uk3rbZfb.js → config-CGcQTdZV.js} +7 -6
  18. package/dist/config-CGcQTdZV.js.map +1 -0
  19. package/dist/{config-BWj9jBVj.cjs → config-CkTrJD0E.cjs} +7 -6
  20. package/dist/config-CkTrJD0E.cjs.map +1 -0
  21. package/dist/{config-CQTxXvIG.js → config-re864UnO.js} +5 -5
  22. package/dist/config-re864UnO.js.map +1 -0
  23. package/dist/{configFile-BPHxtrEM.cjs → configFile-BQ-Pp7i_.cjs} +5 -5
  24. package/dist/{configFile-BPHxtrEM.cjs.map → configFile-BQ-Pp7i_.cjs.map} +1 -1
  25. package/dist/{configFile-L5i7gGUc.js → configFile-CPXDgTC2.js} +5 -5
  26. package/dist/{configFile-L5i7gGUc.js.map → configFile-CPXDgTC2.js.map} +1 -1
  27. package/dist/{credentials-DEsGwcGD.cjs → credentials-Cl3eOa8G.cjs} +3 -7
  28. package/dist/{credentials-DEsGwcGD.cjs.map → credentials-Cl3eOa8G.cjs.map} +1 -1
  29. package/dist/{credentials-B77iJx9H.js → credentials-DznluKkp.js} +1 -1
  30. package/dist/{credentials-osgjujE_.js → credentials-LPHovWZe.js} +2 -2
  31. package/dist/{credentials-osgjujE_.js.map → credentials-LPHovWZe.js.map} +1 -1
  32. package/dist/{env-rv-VgSGN.js → env-BYZIPHqz.js} +3 -3
  33. package/dist/{env-rv-VgSGN.js.map → env-BYZIPHqz.js.map} +1 -1
  34. package/dist/env-BgVegN_u.js +1 -0
  35. package/dist/{env-eu3XyKqJ.cjs → env-Bi4GXVdd.cjs} +4 -7
  36. package/dist/{env-eu3XyKqJ.cjs.map → env-Bi4GXVdd.cjs.map} +1 -1
  37. package/dist/{errors-BponpdjN.cjs → errors-Bewwe8mY.cjs} +2 -2
  38. package/dist/{errors-BponpdjN.cjs.map → errors-Bewwe8mY.cjs.map} +1 -1
  39. package/dist/{errors-wzqmMpMo.js → errors-CEzFbRvL.js} +2 -2
  40. package/dist/{errors-wzqmMpMo.js.map → errors-CEzFbRvL.js.map} +1 -1
  41. package/dist/{fs-Cf1FSRh9.js → fs-CmODfKN-.js} +27 -8
  42. package/dist/fs-CmODfKN-.js.map +1 -0
  43. package/dist/index.cjs +15 -15
  44. package/dist/index.d.cts +1 -2
  45. package/dist/index.d.ts +1 -2
  46. package/dist/index.js +15 -15
  47. package/dist/{installWithSpinner-CnE4dIza.cjs → installWithSpinner-DZDlVp1J.cjs} +6 -6
  48. package/dist/{installWithSpinner-CnE4dIza.cjs.map → installWithSpinner-DZDlVp1J.cjs.map} +1 -1
  49. package/dist/{installWithSpinner-CNDzLZw-.js → installWithSpinner-gv_OWgww.js} +6 -6
  50. package/dist/{installWithSpinner-CNDzLZw-.js.map → installWithSpinner-gv_OWgww.js.map} +1 -1
  51. package/dist/{intro-DRl-pwVs.js → intro-Dun8Eqod.js} +4 -4
  52. package/dist/{intro-DRl-pwVs.js.map → intro-Dun8Eqod.js.map} +1 -1
  53. package/dist/{intro-DuyzJ3Rb.cjs → intro-PFXmY9bD.cjs} +4 -4
  54. package/dist/{intro-DuyzJ3Rb.cjs.map → intro-PFXmY9bD.cjs.map} +1 -1
  55. package/dist/{isCIEnvironment-D6xtAAZ2.js → isCIEnvironment-DAMZSlP2.js} +2 -2
  56. package/dist/{isCIEnvironment-D6xtAAZ2.js.map → isCIEnvironment-DAMZSlP2.js.map} +1 -1
  57. package/dist/{isCIEnvironment-DiVOMI5Q.cjs → isCIEnvironment-jzKqdVwJ.cjs} +2 -2
  58. package/dist/{isCIEnvironment-DiVOMI5Q.cjs.map → isCIEnvironment-jzKqdVwJ.cjs.map} +1 -1
  59. package/dist/{log-B-1vLxF1.js → log-B_uVM704.js} +3 -3
  60. package/dist/{log-B-1vLxF1.js.map → log-B_uVM704.js.map} +1 -1
  61. package/dist/{log-wv1OxLiq.cjs → log-BzmBldY6.cjs} +3 -3
  62. package/dist/{log-wv1OxLiq.cjs.map → log-BzmBldY6.cjs.map} +1 -1
  63. package/dist/{mascot-CC-D4ON2.cjs → mascot-CLw0Qmln.cjs} +14 -10
  64. package/dist/{mascot-CC-D4ON2.cjs.map → mascot-CLw0Qmln.cjs.map} +1 -1
  65. package/dist/{mascot-CmUUHLlx.js → mascot-b4yXsKwl.js} +14 -10
  66. package/dist/mascot-b4yXsKwl.js.map +1 -0
  67. package/dist/{mcp-D60W6v_6.cjs → mcp-BBD4kdKF.cjs} +3 -3
  68. package/dist/{mcp-D60W6v_6.cjs.map → mcp-BBD4kdKF.cjs.map} +1 -1
  69. package/dist/{mcp-D63ugfbT.js → mcp-CQXp9pcW.js} +3 -3
  70. package/dist/{mcp-D63ugfbT.js.map → mcp-CQXp9pcW.js.map} +1 -1
  71. package/dist/package-CdMFA8OG.js +5 -0
  72. package/dist/package-CdMFA8OG.js.map +1 -0
  73. package/dist/{package-B8KmMINL.cjs → package-DXNoJQYa.cjs} +2 -2
  74. package/dist/package-DXNoJQYa.cjs.map +1 -0
  75. package/dist/{registry-Cy48PGdh.js → registry-BBJpMlM9.js} +4 -4
  76. package/dist/{registry-Cy48PGdh.js.map → registry-BBJpMlM9.js.map} +1 -1
  77. package/dist/{registry-Q77p5TZp.cjs → registry-CTVAqQFn.cjs} +4 -4
  78. package/dist/{registry-Q77p5TZp.cjs.map → registry-CTVAqQFn.cjs.map} +1 -1
  79. package/dist/{reporters-DyjE3BzZ.cjs → reporters-CaJ8brYA.cjs} +258 -106
  80. package/dist/reporters-CaJ8brYA.cjs.map +1 -0
  81. package/dist/{reporters-9MqdcKPp.js → reporters-CzxaQ_bD.js} +1 -1
  82. package/dist/{reporters-B_USHwD6.js → reporters-DeruUk9K.js} +260 -108
  83. package/dist/reporters-DeruUk9K.js.map +1 -0
  84. package/dist/{rolldown-runtime-C3-Zg-KD.cjs → rolldown-runtime-BV8xUvPy.cjs} +4 -4
  85. package/dist/{rolldown-runtime-xo6NMXYd.js → rolldown-runtime-BowF1xt-.js} +0 -1
  86. package/dist/{run-Dx8QpT_k.js → run-96_svbr3.js} +31 -21
  87. package/dist/run-96_svbr3.js.map +1 -0
  88. package/dist/{run-DMvX80Mi.cjs → run-BIgV2zvB.cjs} +4 -4
  89. package/dist/{run-DMvX80Mi.cjs.map → run-BIgV2zvB.cjs.map} +1 -1
  90. package/dist/{run-BA5vGtx3.cjs → run-BSA2x4iE.cjs} +14 -14
  91. package/dist/{run-BA5vGtx3.cjs.map → run-BSA2x4iE.cjs.map} +1 -1
  92. package/dist/{run-D_tbKvAc.js → run-Bi8hhAzv.js} +1 -1
  93. package/dist/{run-83Aaa6qM.cjs → run-Bxqg0GuI.cjs} +8 -8
  94. package/dist/{run-83Aaa6qM.cjs.map → run-Bxqg0GuI.cjs.map} +1 -1
  95. package/dist/{run-Ch7Uuu-u.js → run-C4fd98gp.js} +7 -7
  96. package/dist/{run-Ch7Uuu-u.js.map → run-C4fd98gp.js.map} +1 -1
  97. package/dist/{run-9mcw0FWy.cjs → run-CIEKCdM-.cjs} +19 -19
  98. package/dist/run-CIEKCdM-.cjs.map +1 -0
  99. package/dist/{run-5u7cHD85.js → run-CYdKWpyH.js} +43 -23
  100. package/dist/run-CYdKWpyH.js.map +1 -0
  101. package/dist/{run-DHdlUkYt.js → run-CmHjIMpd.js} +19 -19
  102. package/dist/run-CmHjIMpd.js.map +1 -0
  103. package/dist/{run-CgXrvsL9.js → run-CpyFU0RM.js} +16 -16
  104. package/dist/{run-CgXrvsL9.js.map → run-CpyFU0RM.js.map} +1 -1
  105. package/dist/{run-CfumUZCl.cjs → run-D15oxCOd.cjs} +7 -7
  106. package/dist/{run-CfumUZCl.cjs.map → run-D15oxCOd.cjs.map} +1 -1
  107. package/dist/{run-BxNbFsmc.cjs → run-DLRu4z5Z.cjs} +30 -19
  108. package/dist/run-DLRu4z5Z.cjs.map +1 -0
  109. package/dist/run-Df4PGOFX.js +291 -0
  110. package/dist/run-Df4PGOFX.js.map +1 -0
  111. package/dist/{run-D-FHx4uQ.cjs → run-GdctJlXN.cjs} +42 -21
  112. package/dist/run-GdctJlXN.cjs.map +1 -0
  113. package/dist/{run-Do24e475.js → run-ORjkOWFp.js} +4 -4
  114. package/dist/{run-Do24e475.js.map → run-ORjkOWFp.js.map} +1 -1
  115. package/dist/{run-DhlC3it5.cjs → run-OqiJknWr.cjs} +17 -17
  116. package/dist/{run-DhlC3it5.cjs.map → run-OqiJknWr.cjs.map} +1 -1
  117. package/dist/{run-BD6A0HGa.js → run-U2Ze_QP4.js} +17 -17
  118. package/dist/{run-BD6A0HGa.js.map → run-U2Ze_QP4.js.map} +1 -1
  119. package/dist/{run-DKqUfsTv.js → run-ixh050Ip.js} +8 -8
  120. package/dist/{run-DKqUfsTv.js.map → run-ixh050Ip.js.map} +1 -1
  121. package/dist/run-k-LqKkgU.cjs +294 -0
  122. package/dist/run-k-LqKkgU.cjs.map +1 -0
  123. package/dist/{shared-KKRMm1xX.cjs → shared-DoD3p_X8.cjs} +2 -2
  124. package/dist/{shared-KKRMm1xX.cjs.map → shared-DoD3p_X8.cjs.map} +1 -1
  125. package/dist/{shared-DcDHRtZx.js → shared-SrKde4x4.js} +2 -2
  126. package/dist/{shared-DcDHRtZx.js.map → shared-SrKde4x4.js.map} +1 -1
  127. package/dist/{snapshot-C_11eUdT.cjs → snapshot-C-ge8g3_.cjs} +12 -12
  128. package/dist/snapshot-C-ge8g3_.cjs.map +1 -0
  129. package/dist/{snapshot-CbajkXfi.js → snapshot-CSacL1qI.js} +12 -12
  130. package/dist/snapshot-CSacL1qI.js.map +1 -0
  131. package/dist/{spinner-RfMb7fd6.cjs → spinner-D584jFAz.cjs} +27 -9
  132. package/dist/spinner-D584jFAz.cjs.map +1 -0
  133. package/dist/{spinner-DxsAllRI.js → spinner-D5DgYSS5.js} +3 -3
  134. package/dist/{spinner-DxsAllRI.js.map → spinner-D5DgYSS5.js.map} +1 -1
  135. package/dist/{status-CaEQY12V.js → status-Bq-Bjo2n.js} +4 -4
  136. package/dist/{status-CaEQY12V.js.map → status-Bq-Bjo2n.js.map} +1 -1
  137. package/dist/{status-CgVRLP9A.cjs → status-D-Osmkhr.cjs} +4 -4
  138. package/dist/{status-CgVRLP9A.cjs.map → status-D-Osmkhr.cjs.map} +1 -1
  139. package/dist/{studio-1Otb3b_g.js → studio-BBXKjMN-.js} +18 -18
  140. package/dist/{studio-1Otb3b_g.js.map → studio-BBXKjMN-.js.map} +1 -1
  141. package/dist/{studio-CENejJka.cjs → studio-BZ53idqa.cjs} +18 -18
  142. package/dist/{studio-CENejJka.cjs.map → studio-BZ53idqa.cjs.map} +1 -1
  143. package/dist/studioWorker.js +3 -3
  144. package/dist/{summary-BQWHL_Ca.js → summary-BS-iWuye.js} +4 -4
  145. package/dist/{summary-BQWHL_Ca.js.map → summary-BS-iWuye.js.map} +1 -1
  146. package/dist/{summary-B2Apv5KO.cjs → summary-n4osDoch.cjs} +4 -4
  147. package/dist/{summary-B2Apv5KO.cjs.map → summary-n4osDoch.cjs.map} +1 -1
  148. package/dist/{table-CR7iZJGo.js → table-BKkctGHD.js} +2 -2
  149. package/dist/{table-CR7iZJGo.js.map → table-BKkctGHD.js.map} +1 -1
  150. package/dist/{table-BlRe9YTZ.cjs → table-_fOF5WNI.cjs} +2 -2
  151. package/dist/{table-BlRe9YTZ.cjs.map → table-_fOF5WNI.cjs.map} +1 -1
  152. package/dist/{text-DMiX2dcG.cjs → text-CkCtm5VP.cjs} +2 -2
  153. package/dist/{text-DMiX2dcG.cjs.map → text-CkCtm5VP.cjs.map} +1 -1
  154. package/dist/{text-EoYn04SX.js → text-HYWAcipy.js} +2 -2
  155. package/dist/{text-EoYn04SX.js.map → text-HYWAcipy.js.map} +1 -1
  156. package/dist/{time-3BKoci3G.cjs → time-D4xUq6tx.cjs} +2 -2
  157. package/dist/{time-3BKoci3G.cjs.map → time-D4xUq6tx.cjs.map} +1 -1
  158. package/dist/{time-C-wU7VhC.js → time-D7ONPPZf.js} +2 -2
  159. package/dist/{time-C-wU7VhC.js.map → time-D7ONPPZf.js.map} +1 -1
  160. package/dist/{utils-f1C7RiEI.js → utils-BVccq6W0.js} +4 -4
  161. package/dist/{utils-f1C7RiEI.js.map → utils-BVccq6W0.js.map} +1 -1
  162. package/dist/{utils-DeXBGzGJ.cjs → utils-C9fYoqP2.cjs} +5 -5
  163. package/dist/{utils-DeXBGzGJ.cjs.map → utils-C9fYoqP2.cjs.map} +1 -1
  164. package/dist/{validate-cBMe2ndk.js → validate-BuStuH_z.js} +4 -4
  165. package/dist/{validate-cBMe2ndk.js.map → validate-BuStuH_z.js.map} +1 -1
  166. package/dist/{validate-BPYNc8h8.cjs → validate-rr0LpFhN.cjs} +4 -4
  167. package/dist/{validate-BPYNc8h8.cjs.map → validate-rr0LpFhN.cjs.map} +1 -1
  168. package/package.json +8 -8
  169. package/dist/config-BL3HnFhb.js +0 -1
  170. package/dist/config-BWj9jBVj.cjs.map +0 -1
  171. package/dist/config-CQTxXvIG.js.map +0 -1
  172. package/dist/config-Uk3rbZfb.js.map +0 -1
  173. package/dist/env-C3xHRMez.js +0 -1
  174. package/dist/fs-Cf1FSRh9.js.map +0 -1
  175. package/dist/mascot-CmUUHLlx.js.map +0 -1
  176. package/dist/package-B8KmMINL.cjs.map +0 -1
  177. package/dist/package-Cjh6pjp9.js +0 -5
  178. package/dist/package-Cjh6pjp9.js.map +0 -1
  179. package/dist/reporters-B_USHwD6.js.map +0 -1
  180. package/dist/reporters-DyjE3BzZ.cjs.map +0 -1
  181. package/dist/run-5u7cHD85.js.map +0 -1
  182. package/dist/run-9mcw0FWy.cjs.map +0 -1
  183. package/dist/run-BxNbFsmc.cjs.map +0 -1
  184. package/dist/run-CXYwjh9u.cjs +0 -229
  185. package/dist/run-CXYwjh9u.cjs.map +0 -1
  186. package/dist/run-D-FHx4uQ.cjs.map +0 -1
  187. package/dist/run-DHdlUkYt.js.map +0 -1
  188. package/dist/run-Dx8QpT_k.js.map +0 -1
  189. package/dist/run-m5ZAeYLj.js +0 -226
  190. package/dist/run-m5ZAeYLj.js.map +0 -1
  191. package/dist/snapshot-C_11eUdT.cjs.map +0 -1
  192. package/dist/snapshot-CbajkXfi.js.map +0 -1
  193. package/dist/spinner-RfMb7fd6.cjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"reporters-DyjE3BzZ.cjs","names":["logLevelMap","styleText","styleText","process","formatMsWithColor","getElapsedMs","styleText","logLevelMap","styleText","logLevelMap","process","relative","Diagnostics","styleText","getInputKind","resolve","read","pluralize","logLevelMap","pluralize","relative","styleText","styleText","logLevelMap","toPermissionFlag","process","getElapsedMs","Diagnostics","pluralize","formatMs","process","formatMs","getElapsedMs","styleText","pluralize","formatBar","formatMsWithColor","styleText","relative","process","readdir","join","read","matchesStored","defaultWriter","createCliReporter","logLevelMap","resolve","hasOutputPasses","isPathInside","readFile","process","createOutputManifest","cacheStorage"],"sources":["../../../internals/utils/src/promise.ts","../src/loggers/features/context.ts","../src/loggers/features/generation.ts","../src/loggers/features/phases.ts","../src/loggers/specFrame.ts","../src/loggers/features/problems.ts","../src/loggers/features/progress.ts","../src/loggers/features/session.ts","../src/loggers/features/spinner.ts","../src/loggers/features/walk.ts","../src/loggers/features/index.ts","../src/runners/generate/utils.ts","../src/loggers/reporters.ts"],"sourcesContent":["/** A value that may already be resolved or still pending.\n *\n * @example\n * ```ts\n * function load(id: string): PossiblePromise<string> {\n * return cache.get(id) ?? fetchRemote(id)\n * }\n * ```\n */\nexport type PossiblePromise<T> = Promise<T> | T\n\ntype Store<TKey, TValue> = {\n has(key: TKey): boolean\n get(key: TKey): TValue | undefined\n set(key: TKey, value: TValue): unknown\n}\n\n/**\n * Returns the value cached under `key` in `store`, computing and storing it on the first call.\n * Pass a `WeakMap` for object keys, so an entry goes away with its key, or a `Map` for primitive\n * keys. A cached `null` or `undefined` counts as a hit, so `compute` runs once per key.\n *\n * @example\n * `const refs = memo(refCache, node, () => collectRefs(node))`\n */\nexport function memo<TKey, TValue>(store: Store<TKey, TValue>, key: TKey, compute: () => TValue): TValue {\n if (store.has(key)) return store.get(key) as TValue\n const value = compute()\n store.set(key, value)\n return value\n}\n\ntype ParallelOptions<TItem> = {\n /**\n * Items to work through, handed out in order.\n */\n items: ReadonlyArray<TItem>\n /**\n * How many items may be in flight at once.\n */\n limit: number\n /**\n * Runs once per item, with the item's position so a caller can report progress.\n */\n run(item: TItem, index: number): Promise<void>\n}\n\n/**\n * Runs `run` over every item with at most `limit` in flight. Workers share one iterator, so each\n * takes the next item the moment it frees up instead of waiting for a batch to drain.\n *\n * @example\n * ```ts\n * await inParallel({ items: files, limit: 50, run: (file) => storage.writeItem(file.path, file.source) })\n * ```\n */\nexport async function inParallel<TItem>({ items, limit, run }: ParallelOptions<TItem>): Promise<void> {\n const queue = items.entries()\n\n const worker = async (): Promise<void> => {\n for (const [index, item] of queue) await run(item, index)\n }\n\n await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()))\n}\n","import { styleText } from 'node:util'\nimport { type Config, type Hookable, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'\nimport type { LoggerWriter } from '../types.ts'\n\n/**\n * What `installLogger` shares with its features: the writer, the verbosity flags, and the two\n * run-wide flags a feature flips for the others to read.\n */\nexport type LoggerContext = {\n hooks: Hookable<KubbHooks>\n writer: LoggerWriter\n logLevel: number\n silent: boolean\n human: boolean\n /** Set once a rich `kubb studio` session connects: each run then shows as one job line. */\n session: boolean\n /** Whether a config's group is open, so a problem can wait for its end. */\n groupOpen: boolean\n /** Prefixes a `[HH:MM:SS]` timestamp at verbose and above. */\n text: (message: string) => string\n /** `✓ message info`, with the info dimmed. */\n line: (symbol: string, message: string, info?: string) => string\n /** Registers a per-run hook. In a Studio session the job line stands for the whole run, so these stay quiet. */\n onRun: <Name extends keyof KubbHooks & string>(name: Name, fn: (...args: KubbHooks[Name]) => unknown) => () => void\n}\n\nexport function createLoggerContext({ hooks, writer, logLevel }: { hooks: Hookable<KubbHooks>; writer: LoggerWriter; logLevel: number }): LoggerContext {\n const text = (message: string) => (logLevel >= logLevelMap.verbose ? `${styleText('dim', `[${clock()}]`)} ${message}` : message)\n const ctx: LoggerContext = {\n hooks,\n writer,\n logLevel,\n silent: logLevel <= logLevelMap.silent,\n human: writer.audience === 'human',\n session: false,\n groupOpen: false,\n text,\n line: (symbol, message, info) => text([symbol, message, info && styleText('dim', info)].filter(Boolean).join(' ')),\n onRun(name, fn) {\n return hooks.hook(name, (...args) => (ctx.session ? undefined : fn(...args)))\n },\n }\n return ctx\n}\n\n/** `HH:MM:SS` in 24-hour time. */\nexport function clock(date = new Date()): string {\n return date.toLocaleTimeString('en-US', { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' })\n}\n\n/** Display path for a config's input: the string form, or its `path` field when the input is an object. */\nexport function getInputPath(config: Config): string | undefined {\n const { input } = config\n if (typeof input === 'string') return input\n return typeof input?.path === 'string' ? input.path : undefined\n}\n","import { styleText } from 'node:util'\nimport type { SummaryRenderer } from '@kubb/core'\nimport type { LogStatus } from '../types.ts'\nimport { getInputPath, type LoggerContext } from './context.ts'\nimport type { Phases } from './phases.ts'\nimport type { Problems } from './problems.ts'\nimport type { Progress } from './progress.ts'\nimport type { Spinner } from './spinner.ts'\nimport type { Walk } from './walk.ts'\n\n/**\n * One config's run: the group it opens, the state every feature resets at its start, and the\n * closing line, which the lifecycle end draws too for a run that threw before its summary.\n */\nexport function createGeneration(\n ctx: LoggerContext,\n { spinner, progress, walk, phases, problems }: { spinner: Spinner; progress: Progress; walk: Walk; phases: Phases; problems: Problems },\n): { renderSummary: SummaryRenderer } {\n const { writer, silent, human, text, hooks, onRun } = ctx\n\n function reset() {\n spinner.reset()\n progress.reset()\n walk.reset()\n phases.reset()\n problems.reset()\n }\n\n // A run that throws before `kubb:generation:end` never reaches the summary, so the lifecycle\n // end calls this too rather than leave a group without its closing line.\n function closeGroup(status: LogStatus) {\n if (!ctx.groupOpen) {\n return\n }\n ctx.groupOpen = false\n\n spinner.stop()\n progress.stop()\n writer.groupEnd(status === 'failed' ? styleText('red', problems.failedTitle()) : styleText('green', '✓ Generation succeeded'))\n }\n\n hooks.hook('kubb:lifecycle:start', () => {\n reset()\n })\n\n onRun('kubb:generation:start', ({ config }) => {\n closeGroup('failed')\n reset()\n\n walk.state.totalPlugins = config.plugins?.length ?? 0\n progress.state.inMemory = config.storage?.name === 'memory'\n problems.setSpec(config)\n\n if (silent) {\n return\n }\n\n const input = getInputPath(config)\n writer.group(text([styleText('bold', config.name ?? 'kubb'), input ? styleText('dim', input) : undefined].filter(Boolean).join(' ')))\n ctx.groupOpen = true\n\n spinner.start('Parsing spec')\n })\n\n onRun('kubb:generation:end', async ({ diagnostics = [] }) => {\n spinner.stop()\n progress.stop()\n problems.state.diagnostics = diagnostics\n await problems.flush()\n })\n\n hooks.hook('kubb:lifecycle:end', async () => {\n await problems.flush()\n closeGroup('failed')\n reset()\n })\n\n const renderSummary: SummaryRenderer = (lines, { status }) => {\n if (silent || !ctx.groupOpen) {\n return\n }\n\n spinner.stop()\n progress.stop()\n if (human) closeGroup(status)\n ctx.groupOpen = false\n writer.diagnostic([...lines])\n }\n\n return { renderSummary }\n}\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getElapsedMs } from '@internals/utils'\nimport { logLevel as logLevelMap } from '@kubb/core'\nimport { formatMsWithColor } from '../banner.ts'\nimport type { LoggerContext } from './context.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Phases = ReturnType<typeof createPhases>\n\n/**\n * One output phase while its step owns the line. A phase buffers what it is told, because a spinner\n * redraws over anything written under it, and prints the lot once it knows its own result.\n */\ntype Phase = StartPhaseOptions & {\n failed: boolean\n hrStart: [number, number]\n lines: Array<string>\n /**\n * Raw lines a hook printed, drawn outside the group.\n */\n output: Array<string>\n}\n\ntype StartPhaseOptions = {\n /**\n * Shown while the phase runs.\n */\n running: string\n success: string\n failure: string\n /**\n * Whether each hook's own result is worth a line. Format and lint run one command, so the phase\n * result already says everything; the post-generate phase runs several.\n */\n showHookResults?: boolean\n}\n\n/**\n * The three output phases, in the order the generate runner runs them.\n */\nconst PHASES = {\n format: { running: 'Formatting', success: 'Formatted', failure: 'Formatting failed' },\n lint: { running: 'Linting', success: 'Linted', failure: 'Linting failed' },\n hooks: {\n running: 'Running post-generate hooks',\n success: 'Post-generate hooks completed',\n failure: 'Post-generate hooks failed',\n showHookResults: true,\n },\n} as const satisfies Record<string, StartPhaseOptions>\n\n/** A hook's display name: its `name`, or the command line it runs. */\nfunction formatHookLabel({ command, name, args }: { command: string; name?: string; args?: ReadonlyArray<string> }): string {\n return name ?? (args?.length ? `${command} ${args.join(' ')}` : command)\n}\n\n/**\n * Drops the blank lines a subprocess leaves at either end of its output, so its block does not open\n * or close on an empty row.\n */\nfunction trimBlankEdges(lines: ReadonlyArray<string>): Array<string> {\n const start = lines.findIndex((line) => line.trim())\n if (start === -1) {\n return []\n }\n\n return lines.slice(start, lines.findLastIndex((line) => line.trim()) + 1)\n}\n\n/** The format, lint and post-generate phases, and the hooks and messages they buffer while their step owns the line. */\nexport function createPhases({ writer, silent, logLevel, text, line, onRun }: LoggerContext, spinner: Spinner) {\n const state = {\n phase: null as Phase | null,\n hooks: new Map<string, { hrStart: [number, number]; lines: Array<string> }>(),\n }\n\n function startPhase(options: StartPhaseOptions) {\n state.phase = { ...options, failed: false, hrStart: process.hrtime(), lines: [], output: [] }\n spinner.start(options.running)\n }\n\n function endPhase() {\n const phase = state.phase\n state.phase = null\n\n if (!phase || silent) {\n return\n }\n\n const duration = formatMsWithColor(getElapsedMs(phase.hrStart))\n\n spinner.stop(phase.failed ? `${phase.failure} after ${duration}` : `${phase.success} in ${duration}`, phase.failed ? 'failed' : 'success')\n\n if (phase.lines.length) {\n writer.block(phase.lines)\n }\n writeOutput(phase.output)\n }\n\n function writeOutput(lines: ReadonlyArray<string>) {\n const output = trimBlankEdges(lines)\n if (output.length) {\n writer.raw(output)\n }\n }\n\n onRun('kubb:format:start', () => startPhase(PHASES.format))\n onRun('kubb:format:end', endPhase)\n onRun('kubb:lint:start', () => startPhase(PHASES.lint))\n onRun('kubb:lint:end', endPhase)\n onRun('kubb:hooks:start', () => startPhase(PHASES.hooks))\n onRun('kubb:hooks:end', endPhase)\n\n onRun('kubb:hook:end', (ctx) => {\n const { id, command, name, args, success, error } = ctx\n if (!id) {\n return\n }\n\n if (!success && state.phase) {\n state.phase.failed = true\n }\n\n if (silent) {\n // Even when silent, surface a failed hook's captured output. `stdout` and `stderr` only exist on a failed result.\n if (!ctx.success) {\n if (ctx.stdout) console.log(ctx.stdout)\n if (ctx.stderr) console.error(ctx.stderr)\n }\n return\n }\n\n const active = state.hooks.get(id)\n if (!active) {\n return\n }\n state.hooks.delete(id)\n\n const label = styleText('dim', formatHookLabel({ command, name, args }))\n const reason = error?.message ? ` (${error.message})` : ''\n const result = success\n ? `${styleText('green', '✓')} ${label} in ${formatMsWithColor(getElapsedMs(active.hrStart))}`\n : `${styleText('red', '✗')} ${label} failed${reason}`\n\n const phase = state.phase\n if (phase) {\n if (phase.showHookResults || !success) {\n phase.lines.push(result)\n }\n phase.output.push(...active.lines)\n return\n }\n\n spinner.stop()\n writer.step(text(result))\n writeOutput(active.lines)\n })\n\n // Not registered at silent: the missing `kubb:hook:line` listener is also what tells the runner not to stream.\n if (!silent) {\n onRun('kubb:info', ({ message, info }) => {\n const formatted = line(styleText('blue', 'ℹ'), message, info)\n\n // Info carries something new (the auto-detected tool), so inside a phase it waits for the phase to print.\n if (state.phase) {\n state.phase.lines.push(formatted)\n return\n }\n if (spinner.message(formatted)) {\n return\n }\n writer.info(formatted)\n })\n\n onRun('kubb:success', ({ message, info }) => {\n const formatted = line(styleText('green', '✓'), message, logLevel >= logLevelMap.info ? info : undefined)\n\n // The phase step's own result already reports these successes, so let the step carry them.\n if (spinner.message(formatted)) {\n return\n }\n writer.success(formatted)\n })\n\n onRun('kubb:hook:start', ({ id, command, name, args }) => {\n if (!id) {\n return\n }\n state.hooks.set(id, { hrStart: process.hrtime(), lines: [] })\n spinner.message(text(`Running ${styleText('dim', formatHookLabel({ command, name, args }))}`))\n })\n\n onRun('kubb:hook:line', ({ id, line }) => {\n const active = state.hooks.get(id)\n if (!active) {\n return\n }\n\n // A phase step redraws its own line, so its output waits until the phase ends.\n if (state.phase) {\n active.lines.push(line)\n return\n }\n writer.raw([line])\n })\n }\n\n return {\n /** The phase whose step owns the line, so a failure or an info line can wait for it. */\n get phase(): Phase | null {\n return state.phase\n },\n reset() {\n state.phase = null\n state.hooks = new Map()\n },\n }\n}\n","import { styleText } from 'node:util'\nimport type { Adapter, DiagnosticLocation } from '@kubb/core'\n\n/**\n * A location in source text, with a terminal code frame that underlines it.\n */\nexport type SpecPosition = {\n line: number\n column: number\n frame: Array<string>\n}\n\n// Diagnostics of one run share a source, so its line starts are indexed once. Splitting a large\n// spec per diagnostic made code frames the slowest part of a run.\nlet cached: { source: string; starts: Array<number> } | undefined\n\nfunction lineStarts(source: string): Array<number> {\n if (cached?.source !== source) {\n const starts = [0]\n for (const match of source.matchAll(/\\n/g)) starts.push(match.index + 1)\n cached = { source, starts }\n }\n return cached.starts\n}\n\n/** The index of the last line start at or before `offset`, found by binary search. */\nfunction lineIndex(starts: Array<number>, offset: number, low = 0, high = starts.length - 1): number {\n if (low >= high) return low\n const mid = (low + high + 1) >> 1\n return starts[mid]! <= offset ? lineIndex(starts, offset, mid, high) : lineIndex(starts, offset, low, mid - 1)\n}\n\n/**\n * Where `location` sits in `source` according to its adapter, with a code frame. `undefined` when the adapter cannot place it.\n */\nexport function locateInSpec({ adapter, source, location }: { adapter: Adapter; source: string; location: DiagnosticLocation }): SpecPosition | undefined {\n try {\n const range = adapter.locate?.(source, location)\n if (!range) return undefined\n const starts = lineStarts(source)\n const index = lineIndex(starts, range.start)\n const lineText = (number: number) => source.slice(starts[number - 1], number < starts.length ? starts[number]! - 1 : source.length).replace(/\\r$/, '')\n const line = index + 1\n const column = range.start - starts[index]! + 1\n const text = lineText(line)\n const width = String(line).length\n const gutter = (number?: number) => styleText('dim', `${number === undefined ? ''.padStart(width) : String(number).padStart(width)} │`)\n const carets = '^'.repeat(Math.max(1, Math.min(range.end - range.start, text.length - column + 1)))\n return {\n line,\n column,\n frame: [\n ...(line > 1 ? [`${gutter(line - 1)} ${lineText(line - 1)}`] : []),\n `${gutter(line)} ${text}`,\n `${gutter()} ${' '.repeat(column - 1)}${styleText('red', carets)}`,\n ],\n }\n } catch {\n return undefined\n }\n}\n","import { relative, resolve } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { read } from '@internals/utils'\nimport type { Adapter, Config, Diagnostic, DiagnosticFormatOptions, ProblemDiagnostic } from '@kubb/core'\nimport { Diagnostics, getInputKind, logLevel as logLevelMap } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport { locateInSpec } from '../specFrame.ts'\nimport { getInputPath, type LoggerContext } from './context.ts'\nimport type { Phases } from './phases.ts'\nimport type { Progress } from './progress.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Problems = ReturnType<typeof createProblems>\n\n/** Warnings, errors and diagnostics: printed as they come, or held back and grouped by plugin once a human's build ends. */\nexport function createProblems(ctx: LoggerContext, spinner: Spinner, progress: Progress, phases: Phases) {\n const { writer, silent, human, logLevel, text, line, hooks } = ctx\n const { audience } = writer\n const formatOptions: DiagnosticFormatOptions = {\n audience,\n verbose: logLevel >= logLevelMap.verbose,\n // The code lines up at the right edge, inside the group indent and the human view's per-problem indent.\n width: Math.min(process.stdout.columns || 80, 100) - (audience === 'human' ? 4 : 2),\n }\n const state = {\n /** Problems held back so the human view can print them grouped by plugin once the build ends. */\n problems: [] as Array<ProblemDiagnostic>,\n /** The finished config's diagnostics, for the closing verdict. */\n diagnostics: [] as Array<Diagnostic>,\n /** A local-file input, which a located diagnostic points into; `load` parses it once, on the first such diagnostic. */\n spec: undefined as { path: string; adapter: Adapter; source: Promise<string | undefined> } | undefined,\n }\n\n /** Format options for one problem, with its line and column in a local spec when its pointer resolves there. */\n async function optionsFor(problem: ProblemDiagnostic): Promise<DiagnosticFormatOptions> {\n const { location } = problem\n const { spec } = state\n if (!location || !spec) {\n return formatOptions\n }\n\n const source = await spec.source\n const position = source && locateInSpec({ adapter: spec.adapter, source, location })\n if (!position) {\n return formatOptions\n }\n return { ...formatOptions, position: { file: relative(process.cwd(), spec.path), ...position } }\n }\n\n /**\n * Prints problems grouped under their plugin's name, each with the code aligned at the right.\n */\n async function writeProblems(problems: ReadonlyArray<ProblemDiagnostic>) {\n if (!problems.length) {\n return\n }\n const formatted = await Promise.all(problems.map(async (problem) => Diagnostics.format(problem, await optionsFor(problem))))\n if (!human) {\n for (const lines of formatted) writer.diagnostic(lines)\n return\n }\n\n const byPlugin = Map.groupBy(\n problems.map((problem, index) => ({ plugin: problem.plugin ?? '', lines: formatted[index]! })),\n ({ plugin }) => plugin,\n )\n const lines = [...byPlugin].flatMap(([plugin, group]) => [\n ...(plugin ? [` ${styleText('bold', plugin)}`, ''] : []),\n ...group.flatMap((entry) => [...entry.lines.map((entryLine) => ` ${entryLine}`), '']),\n ])\n writer.diagnostic(lines.slice(0, -1))\n }\n\n hooks.hook('kubb:warn', ({ message, info }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n\n writer.warn(line(styleText('yellow', '⚠'), message, logLevel >= logLevelMap.info ? info : undefined))\n })\n\n // Unguarded: a failure stays visible even at silent.\n hooks.hook('kubb:error', ({ error }) => {\n const phase = phases.phase\n if (phase) {\n phase.failed = true\n }\n\n // Rendered as a `KUBB_UNKNOWN` diagnostic, so the output alone says what broke and where. The\n // name tells a `TypeError` from a plain `Error`.\n const message = error.name === 'Error' || Diagnostics.isError(error) ? error.message : `${error.name}: ${error.message}`\n const help = Diagnostics.isError(error) ? error.diagnostic.help : undefined\n const [headline = '', ...details] = Diagnostics.format({ code: Diagnostics.code.unknown, severity: 'error', message, help, cause: error }, formatOptions)\n\n if (!human) {\n spinner.stop()\n progress.stop()\n writer.diagnostic([headline, ...details])\n return\n }\n\n // The writer draws the error symbol, so the message goes in bare.\n if (spinner.active) {\n spinner.stop(message, 'failed')\n } else {\n writer.error(text(message))\n }\n if (details.length) {\n writer.block(details.map(text))\n }\n })\n\n hooks.hook('kubb:diagnostic', async ({ diagnostic }) => {\n // Silent still surfaces errors so failures stay visible. It drops warnings and info.\n if (silent && diagnostic.severity !== 'error') {\n return\n }\n // A Studio job's problems show in Studio; its job line counts the errors.\n if (ctx.session && !Diagnostics.isUpdate(diagnostic)) {\n return\n }\n\n spinner.stop()\n progress.stop()\n\n if (Diagnostics.isUpdate(diagnostic)) {\n writer.update(\n [`\\`v${diagnostic.currentVersion}\\` → \\`v${diagnostic.latestVersion}\\``, 'Run `npm install -g @kubb/cli` to update'],\n 'Update available for `Kubb`',\n )\n return\n }\n\n // Inside a build, the human view waits for the end to group by plugin.\n if (human && ctx.groupOpen) {\n state.problems.push(diagnostic)\n return\n }\n await writeProblems([diagnostic])\n })\n\n return {\n state,\n /** Points located diagnostics into the config's input when it is a local file. */\n setSpec(config: Config) {\n const input = getInputPath(config)\n if (input && config.adapter?.locate && getInputKind(input) === 'file') {\n const path = resolve(config.root, input)\n // Read lazily, once, and only when a diagnostic needs a frame.\n let source: Promise<string | undefined> | undefined\n state.spec = {\n path,\n adapter: config.adapter,\n get source() {\n return (source ??= read(path).catch(() => undefined))\n },\n }\n }\n },\n /** Prints the problems held back so far. */\n flush() {\n return writeProblems(state.problems.splice(0))\n },\n /** `✖ Failed 1 error · 1 warning in plugin-ts` once the build ended, or `✗ Generation failed` for a run that stopped early. */\n failedTitle(): string {\n const { errors, warnings } = Diagnostics.count(state.diagnostics)\n const counts = [errors && pluralize(errors, 'error'), warnings && pluralize(warnings, 'warning')].filter(Boolean).join(' · ')\n if (!human || !counts) {\n return '✗ Generation failed'\n }\n const plugins = Diagnostics.failedPlugins(state.diagnostics)\n return `✖ Failed ${counts}${plugins.length ? ` in ${plugins.join(', ')}` : ''}`\n },\n reset() {\n Object.assign(state, { problems: [], diagnostics: [], spec: undefined })\n },\n }\n}\n","import { relative } from 'node:path'\nimport { styleText } from 'node:util'\nimport { logLevel as logLevelMap } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport type { WriterProgress } from '../types.ts'\nimport type { LoggerContext } from './context.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Progress = ReturnType<typeof createProgress>\n\n/** The progress bar over the file writes, and the counts the summary line shows. */\nexport function createProgress({ writer, silent, human, logLevel, text, onRun }: LoggerContext, spinner: Spinner) {\n // Plain output prints every advance as its own line, so it names each file only at the verbose level.\n const nameFiles = human || logLevel >= logLevelMap.verbose\n const state = {\n progress: null as WriterProgress | null,\n totalFiles: 0,\n processedFiles: 0,\n /** Whether this run keeps its files in memory, as a `kubb studio` run without `--allow-write` does. */\n inMemory: false,\n }\n\n function stop(message?: string) {\n const progress = state.progress\n if (!progress) {\n return\n }\n state.progress = null\n progress.stop(message === undefined ? '' : text(message))\n }\n\n if (!silent) {\n onRun('kubb:files:processing:start', ({ files }) => {\n spinner.stop()\n state.totalFiles = files.length\n state.processedFiles = 0\n\n state.progress = writer.progress(files.length)\n state.progress.start(text(`${state.inMemory ? 'Generating' : 'Writing'} ${pluralize(files.length, 'file')}`))\n })\n\n onRun('kubb:files:processing:update', ({ files }) => {\n for (const { file, config } of files) {\n state.processedFiles++\n if (nameFiles) state.progress?.advance(`${state.inMemory ? 'Generating' : 'Writing'} ${relative(config.root, file.path)}`)\n }\n })\n\n onRun('kubb:files:processing:end', ({ files, unchanged }) => {\n const skipped = unchanged.length ? styleText('dim', ` · ${unchanged.length} unchanged`) : ''\n stop(\n state.inMemory\n ? `Generated ${pluralize(state.processedFiles, 'file')} in memory`\n : `Wrote ${pluralize(files.length - unchanged.length, 'file')}${skipped}`,\n )\n })\n }\n\n return {\n state,\n stop,\n reset() {\n stop()\n Object.assign(state, { totalFiles: 0, processedFiles: 0, inMemory: false })\n },\n }\n}\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { Diagnostics, logLevel as logLevelMap } from '@kubb/core'\nimport { pluralize, toPermissionFlag } from '../../ui/text.ts'\nimport { clock, type LoggerContext } from './context.ts'\nimport type { Spinner } from './spinner.ts'\n\n/** One line of a Studio session's job log: the time, the command, who asked for it, and how it ended. */\nfunction formatJobLine({ command, result, requestedBy }: { command: string; result: string; requestedBy?: string }): string {\n const by = requestedBy ? `${styleText('dim', `by ${requestedBy}`.padEnd(16))} ` : ''\n return `${styleText('dim', clock())} ${command.padEnd(10)} ${by}${result}`\n}\n\n/**\n * A `kubb studio` session. It emits these on the same emitter as its generations, so one logger\n * renders the whole command: the connection, then one job line per command.\n */\nexport function createSession(ctx: LoggerContext, spinner: Spinner) {\n const { writer, silent, human, logLevel, text, hooks } = ctx\n\n hooks.hook('studio:disconnected', ({ code, reason }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n\n spinner.stop()\n // 4002 is `AgentCloseCode.SUPERSEDED`, spelled out because `@kubb/studio` is an optional peer.\n if (code === 4002) {\n writer.warn(text('⚠ Another process connected to Kubb Studio as this agent, so this one stopped'))\n return\n }\n writer.warn(text(`⚠ Kubb Studio ended the session (${reason || `code ${code}`})`))\n })\n\n hooks.hook('studio:warn', ({ message, permission }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n const remedy = permission ? `; pass ${toPermissionFlag(permission)} to allow it` : ''\n // A warning drawn under a running spinner leaves a stale spinner frame above it, so it pauses the spinner like a job line does.\n const paused = spinner.active\n spinner.stop()\n writer.warn(text(`⚠ ${message}${remedy}`))\n if (paused) spinner.start('Ready for jobs')\n })\n\n // Unguarded, like `kubb:error`: a failure stays visible even at silent.\n hooks.hook('studio:error', ({ error }) => {\n if (spinner.active) {\n spinner.stop(error.message, 'failed')\n return\n }\n writer.error(text(error.message))\n })\n\n if (silent) {\n return\n }\n\n // The last generation's outcome, for the job line `studio:command` prints after it.\n let job: { fileCount: number; ms: number; errors: number } | null = null\n\n hooks.hook('studio:connected', ({ url, versions: { studio, kubb, agent } }) => {\n ctx.session = human\n spinner.stop()\n // The runtime version shows only when it differs from the host's.\n const versions = [`v${agent}`, kubb !== agent ? `runtime v${kubb}` : undefined, `Studio v${studio}`].filter(Boolean).join(' · ')\n writer.success(text(`✓ Connected to ${styleText('cyan', url)} ${styleText('dim', `· ${versions}`)}`))\n spinner.start('Ready for jobs')\n })\n\n hooks.hook('kubb:generation:start', () => {\n if (ctx.session) spinner.message(text('Generating'))\n })\n\n hooks.hook('kubb:generation:end', ({ diagnostics = [], filesCreated = 0, status, hrStart = process.hrtime() }) => {\n job = { fileCount: filesCreated, ms: getElapsedMs(hrStart), errors: status === 'failed' ? Diagnostics.count(diagnostics).errors : 0 }\n })\n\n hooks.hook('studio:command', ({ command, info, requestedBy, failed }) => {\n spinner.stop()\n const took = command === 'generate' && job ? `${pluralize(job.fileCount, 'file')} in ${formatMs(job.ms)} ` : ''\n const result = failed\n ? `${styleText('red', '✖')} ${job?.errors ? pluralize(job.errors, 'error') : 'failed'}, see Studio`\n : `${styleText('green', '✓')} ${took}${styleText('dim', `(${info})`)}`\n writer.info(formatJobLine({ command, requestedBy, result }))\n job = null\n spinner.start('Ready for jobs')\n })\n\n hooks.hook('studio:reconnecting', ({ delayMs }) => {\n spinner.stop()\n writer.info(text(styleText('dim', `Retrying connection to Kubb Studio in ${formatMs(delayMs)}`)))\n })\n}\n","import type { LogStatus, WriterSpinner } from '../types.ts'\nimport type { LoggerContext } from './context.ts'\n\nexport type Spinner = ReturnType<typeof createSpinner>\n\n/** The step whose end is not known when it starts: the spec parse, the node walk, a phase, or a Studio session waiting for jobs. */\nexport function createSpinner({ writer, silent, text }: LoggerContext) {\n let spinner: WriterSpinner | null = null\n\n function stop(message?: string, status: LogStatus = 'success') {\n const active = spinner\n if (!active) {\n return\n }\n spinner = null\n\n if (message === undefined) {\n active.clear()\n return\n }\n if (status === 'failed') {\n active.error(text(message))\n return\n }\n active.stop(text(message))\n }\n\n return {\n /** Whether a spinner is drawing right now. */\n get active(): boolean {\n return spinner !== null\n },\n start(message: string) {\n if (silent) {\n return\n }\n\n spinner = writer.spinner()\n spinner.start(text(message))\n },\n stop,\n /** Redraws the spinner's line. `false` when no spinner is running, so the caller prints the line itself. */\n message(line: string): boolean {\n if (!spinner) {\n return false\n }\n spinner.message(line)\n return true\n },\n reset: () => stop(),\n }\n}\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { formatBar, formatMsWithColor } from '../banner.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport type { LoggerContext } from './context.ts'\nimport type { Progress } from './progress.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Walk = ReturnType<typeof createWalk>\n\n/** Milliseconds between redraws of the live generation block, about clack's spinner frame rate. */\nconst WALK_REDRAW_MS = 80\n\nfunction createState() {\n return {\n totalPlugins: 0,\n completedPlugins: 0,\n failedPlugins: 0,\n /** `process.hrtime()` snapshot taken at the start of generation, for the elapsed time. */\n hrStart: process.hrtime(),\n /** Plugin results held back while the generation step owns the line. */\n pluginLines: [] as Array<string>,\n /** The node walk's live state: the spec's node total, the distinct nodes generated, and each plugin's count and current node. */\n walk: { total: 0, visited: new Set<string>(), plugins: new Map<string, { count: number; current: string }>() },\n lastWalkDraw: 0,\n }\n}\n\n/** The node walk the plugins share: the live generation block, and the plugin results printed once the walk ends. */\nexport function createWalk({ writer, silent, human, text, onRun }: LoggerContext, spinner: Spinner, progress: Progress) {\n const state = createState()\n\n /** The progress summary line the clack logger shows, `null` when there is nothing to display. */\n function buildProgressLine(): string | null {\n const parts: Array<string> = []\n const duration = formatMs(getElapsedMs(state.hrStart))\n const { totalFiles, processedFiles } = progress.state\n\n if (state.totalPlugins > 0) {\n const failed = state.failedPlugins > 0 ? ` ${styleText('red', `(${state.failedPlugins} failed)`)}` : ''\n parts.push(`Plugins ${styleText('green', state.completedPlugins.toString())}/${state.totalPlugins}${failed}`)\n }\n\n if (totalFiles > 0) {\n parts.push(`Files ${styleText('green', processedFiles.toString())}/${totalFiles}`)\n }\n\n if (parts.length === 0) {\n return null\n }\n\n parts.push(`${styleText('green', duration)} elapsed`)\n return parts.join(styleText('dim', ' | '))\n }\n\n if (!silent) {\n onRun('kubb:build:start', ({ nodeCounts: { schemas, operations } }) => {\n state.walk.total = schemas + operations\n const details = `${pluralize(schemas, 'schema')} · ${pluralize(operations, 'operation')} · ${formatMs(getElapsedMs(state.hrStart))}`\n spinner.stop(`Parsed spec ${styleText('dim', details)}`)\n spinner.start('Generating')\n })\n\n // Plugins all end after one shared node walk, so per-node hooks keep the step live; plain output would get a line per node.\n if (human) {\n const onNode = (key: string, name: string, plugin: string) => {\n const { total, visited, plugins } = state.walk\n visited.add(key)\n plugins.set(plugin, { count: (plugins.get(plugin)?.count ?? 0) + 1, current: name })\n\n // Counting stays per node; the redraw waits for the spinner's next frame.\n const now = Date.now()\n if (now - state.lastWalkDraw < WALK_REDRAW_MS) return\n state.lastWalkDraw = now\n\n const elapsed = styleText('dim', formatMs(getElapsedMs(state.hrStart)))\n const head = total\n ? `Generating ${formatBar(visited.size, total)} ${visited.size}/${total} nodes ${elapsed}`\n : `Generating ${pluralize(visited.size, 'node')} ${elapsed}`\n const width = Math.max(...[...plugins.keys()].map((pluginName) => pluginName.length))\n const rows = [...plugins].map(\n ([pluginName, row]) =>\n `${styleText('dim', '│')} ${pluginName.padEnd(width)} ${styleText('dim', String(row.count).padStart(4))} ${styleText('cyan', row.current)}`,\n )\n spinner.message(text([head, ...rows].join('\\n')))\n }\n\n onRun('kubb:generate:schema', (node, { plugin }) => onNode(`schema:${node.name}`, node.name ?? 'schema', plugin.name))\n onRun('kubb:generate:operation', (node, { plugin }) => onNode(`operation:${node.operationId}`, node.operationId, plugin.name))\n }\n\n // Buffered, not printed: a step redraws over anything written while it runs.\n onRun('kubb:plugin:end', ({ plugin, duration, success }) => {\n state[success ? 'completedPlugins' : 'failedPlugins']++\n state.pluginLines.push(text(`${plugin.name} ${success ? 'completed' : 'failed'} in ${formatMsWithColor(duration)}`))\n })\n\n onRun('kubb:plugins:end', () => {\n const failed = state.failedPlugins > 0\n spinner.stop(buildProgressLine() ?? undefined, failed ? 'failed' : 'success')\n\n if (state.pluginLines.length) {\n writer.block(state.pluginLines)\n state.pluginLines = []\n }\n })\n }\n\n return {\n state,\n reset() {\n Object.assign(state, createState())\n },\n }\n}\n","import type { Hookable, KubbHooks, SummaryRenderer } from '@kubb/core'\nimport type { LoggerWriter } from '../types.ts'\nimport { createLoggerContext } from './context.ts'\nimport { createGeneration } from './generation.ts'\nimport { createPhases } from './phases.ts'\nimport { createProblems } from './problems.ts'\nimport { createProgress } from './progress.ts'\nimport { createSession } from './session.ts'\nimport { createSpinner } from './spinner.ts'\nimport { createWalk } from './walk.ts'\n\n/**\n * Wires a {@link LoggerWriter} onto the run's hooks. Each feature registers the hooks for one\n * concern, so every writer reports the same run in the same order: one group per config, a step\n * over the plugin work, a progress bar for the writes, one step per output phase, then the summary.\n * It hands back `renderSummary`, which writes the `cli` reporter's summary inside the group opened\n * for that config and closes the group.\n */\nexport function installLogger({ hooks, writer, logLevel }: { hooks: Hookable<KubbHooks>; writer: LoggerWriter; logLevel: number }): {\n renderSummary: SummaryRenderer\n} {\n const ctx = createLoggerContext({ hooks, writer, logLevel })\n const spinner = createSpinner(ctx)\n const progress = createProgress(ctx, spinner)\n const walk = createWalk(ctx, spinner, progress)\n const phases = createPhases(ctx, spinner)\n const problems = createProblems(ctx, spinner, progress, phases)\n createSession(ctx, spinner)\n return createGeneration(ctx, { spinner, progress, walk, phases, problems })\n}\n","import { readdir } from 'node:fs/promises'\nimport { join, relative } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { inParallel, matchesStored, read } from '@internals/utils'\nimport type { Hookable, KubbHooks, OutputManifest, Storage } from '@kubb/core'\n\n/** Glob pattern for paths the file watcher ignores. */\nconst WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Quiet window in milliseconds that collapses a burst of watcher events (an editor save emits several) into one rebuild.\n * It outlasts chokidar's 100 ms atomic-save window, which holds back the event of a write-then-rename save.\n */\nconst WATCHER_DEBOUNCE_MS = 250\n\n/** `14:02:11 petStore.yaml changed`, the line a watcher prints when its input changes. */\nexport function formatChange({ target, removed = false, now = new Date() }: { target: string; removed?: boolean; now?: Date }): string {\n return `${styleText('dim', now.toTimeString().slice(0, 8))} ${styleText('bold', target)} ${removed ? 'removed' : 'changed'}`\n}\n\ntype WatcherLog = {\n info: (message: string) => void\n error: (message: string) => void\n}\n\n/**\n * Starts a file watcher on the given paths and calls `cb` on any change.\n * Ignores `.git` and `node_modules` directories. Event bursts (an editor save emits several)\n * are debounced into one call. `cb` must never reject: its result is not awaited, so the caller\n * serializes and reports its own builds. Resolves to a function that stops watching.\n */\nexport async function startWatcher(\n path: Array<string>,\n cb: (path: Array<string>) => Promise<void>,\n log: WatcherLog = { info: console.log, error: console.log },\n): Promise<() => Promise<void>> {\n const { watch } = await import('chokidar')\n // `ignoreInitial` skips the `add` events chokidar fires for existing files at startup, which\n // would otherwise rebuild right after the initial run.\n const watcher = watch(path, { ignorePermissionErrors: true, ignored: WATCHER_IGNORED_PATHS, ignoreInitial: true })\n\n for (const signal of ['SIGINT', 'SIGTERM'] as const) {\n process.once(signal, () => void watcher.close())\n }\n\n let debounceTimer: ReturnType<typeof setTimeout> | null = null\n\n watcher.on('all', (type, file) => {\n log.info(formatChange({ target: relative(process.cwd(), file), removed: type === 'unlink' }))\n if (debounceTimer) clearTimeout(debounceTimer)\n debounceTimer = setTimeout(() => {\n debounceTimer = null\n void cb(path)\n }, WATCHER_DEBOUNCE_MS)\n })\n\n return async () => {\n if (debounceTimer) clearTimeout(debounceTimer)\n await watcher.close()\n }\n}\n\n/**\n * What one build produced: the schema and operation names the plugins generated.\n */\nexport type BuildSnapshot = {\n schemas: Set<string>\n operations: Set<string>\n}\n\nfunction createSnapshot(): BuildSnapshot {\n return { schemas: new Set(), operations: new Set() }\n}\n\n/**\n * Collects a {@link BuildSnapshot} from the hooks while a build runs. `take` hands back the finished\n * build's snapshot and starts the next one.\n */\nexport function trackBuild(hooks: Hookable<KubbHooks>): { take(): BuildSnapshot } {\n let current = createSnapshot()\n\n hooks.hook('kubb:generate:schema', (node) => {\n if (node.name) current.schemas.add(node.name)\n })\n hooks.hook('kubb:generate:operation', (node) => {\n current.operations.add(node.operationId)\n })\n\n return {\n take() {\n const snapshot = current\n current = createSnapshot()\n return snapshot\n },\n }\n}\n\ntype NameChange = { added: number; removed: number }\n\n/**\n * How a rebuild differs from the build before it: the spec's added and removed schemas and operations.\n */\nexport type BuildDiff = {\n schemas: NameChange\n operations: NameChange\n}\n\nfunction diffNames(previous: Set<string>, next: Set<string>): NameChange {\n return { added: [...next].filter((name) => !previous.has(name)).length, removed: [...previous].filter((name) => !next.has(name)).length }\n}\n\n/**\n * Compares two {@link BuildSnapshot}s by name.\n */\nexport function diffBuilds(previous: BuildSnapshot, next: BuildSnapshot): BuildDiff {\n return {\n schemas: diffNames(previous.schemas, next.schemas),\n operations: diffNames(previous.operations, next.operations),\n }\n}\n\n/** A changed file with how many lines it gains and loses, counted as a multiset, which is cheap and close enough for a plan. */\nexport type FileChange = { status: 'A' | 'M' | 'D'; path: string; added?: number; removed?: number }\n\nfunction countLineChanges(before: string, after: string): { added: number; removed: number } {\n const remaining = new Map<string, number>()\n for (const line of before ? before.split('\\n') : []) remaining.set(line, (remaining.get(line) ?? 0) + 1)\n let added = 0\n for (const line of after ? after.split('\\n') : []) {\n const count = remaining.get(line) ?? 0\n if (count > 0) remaining.set(line, count - 1)\n else added++\n }\n const removed = [...remaining.values()].reduce((sum, count) => sum + count, 0)\n return { added, removed }\n}\n\n/**\n * Reads the output before generation, so cleaning the directory cannot erase the diff baseline.\n * A missing directory or an unreadable file is skipped.\n */\nexport async function readOutputFiles(outputPath: string): Promise<Map<string, string>> {\n const entries = await readdir(outputPath, { recursive: true, withFileTypes: true }).catch(() => [])\n const files = new Map<string, string>()\n await inParallel({\n items: entries.filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name)),\n limit: 50,\n run: async (filePath) => {\n const source = await read(filePath).catch(() => null)\n if (source !== null) files.set(filePath, source)\n },\n })\n return files\n}\n\n/**\n * How one generated file differs from its copy before generation: `undefined` when both hold the\n * same output, otherwise the change with its line counts. The manifest recognizes output a\n * formatter rewrote.\n */\nexport function diffFile({\n path,\n next,\n previous,\n manifest,\n}: {\n path: string\n next: string\n previous: string | null\n manifest?: Pick<OutputManifest, 'isUpToDate'>\n}): FileChange | undefined {\n if (previous !== null && (matchesStored({ stored: previous, source: next }) || manifest?.isUpToDate({ key: path, source: next, disk: previous }))) {\n return undefined\n }\n return {\n status: previous === null ? 'A' : 'M',\n path,\n ...countLineChanges(previous?.trim() ?? '', previous === null ? next.trimEnd() : next.trim()),\n }\n}\n\n/**\n * Compares generated output with the files captured before generation. The manifest recognizes\n * output rewritten by a formatter, and `clean` includes files the run would delete. `counted` holds\n * changes already worked out while the files were written; any other path is read back.\n */\nexport async function diffOutput({\n storage,\n paths,\n clean,\n manifest,\n previousFiles,\n counted,\n}: {\n storage: Storage\n paths: ReadonlyArray<string>\n clean: boolean\n manifest?: Pick<OutputManifest, 'isUpToDate'>\n /**\n * The output captured before a real run, including files removed by cleaning.\n */\n previousFiles: ReadonlyMap<string, string>\n /**\n * Each written file's change from {@link diffFile}, `undefined` when unchanged. A path missing here, such as a blank file the storage skipped, is read back.\n */\n counted?: ReadonlyMap<string, FileChange | undefined>\n}): Promise<{ files: Array<FileChange>; unchanged: number }> {\n const generated = new Set(paths)\n const changes: Array<FileChange | undefined> = []\n let unchanged = 0\n await inParallel({\n items: paths,\n limit: 50,\n run: async (filePath, index) => {\n let change: FileChange | undefined\n if (counted?.has(filePath)) {\n change = counted.get(filePath)\n } else {\n const next = await storage.readItem(filePath)\n if (next === null) return\n change = diffFile({ path: filePath, next, previous: previousFiles.get(filePath) ?? null, manifest })\n }\n if (change) changes[index] = change\n else unchanged++\n },\n })\n const files = changes.filter((file) => file !== undefined)\n if (clean) {\n for (const [filePath, source] of previousFiles) {\n if (!generated.has(filePath)) files.push({ status: 'D', path: filePath, ...countLineChanges(source.trimEnd(), '') })\n }\n }\n\n return { files, unchanged }\n}\n\ntype KeyInput = Pick<NodeJS.ReadStream, 'isTTY' | 'setRawMode' | 'resume' | 'pause' | 'setEncoding' | 'on'>\n\ntype KeyOptions = {\n rebuild: () => void\n /**\n * Ends the process with this exit code: `0` for `q`, `130` for ctrl+c, which raw mode turns into a key.\n */\n quit: (code: number) => void\n input?: KeyInput\n}\n\n/**\n * Reads `r` (rebuild) and `q` (quit) from an interactive stdin in raw mode, and keeps ctrl+c\n * working. Returns `undefined` when stdin is not a TTY. Otherwise returns `arm`, which turns raw\n * mode back on: a spinner restores the terminal when it stops, so call it after each build. Raw mode\n * is restored on exit.\n */\nexport function listenForKeys({ rebuild, quit, input = process.stdin }: KeyOptions): (() => void) | undefined {\n if (!input.isTTY) return undefined\n\n const arm = () => {\n input.setRawMode(true)\n input.resume()\n }\n input.setEncoding('utf8')\n input.on('data', (data: string) => {\n const key = data.trim()\n if (key === 'r') {\n rebuild()\n return\n }\n if (key === 'q' || data === '\\u0003') {\n input.setRawMode(false)\n input.pause()\n quit(key === 'q' ? 0 : 130)\n }\n })\n process.once('exit', () => input.setRawMode(false))\n arm()\n\n return arm\n}\n","import process from 'node:process'\nimport { resolve } from 'node:path'\nimport { readFile } from 'node:fs/promises'\nimport { isPathInside } from '@internals/utils'\nimport type { GenerationResult, Hookable, KubbHooks, Reporter, ReporterContext } from '@kubb/core'\nimport { cacheStorage, createCliReporter, createOutputManifest, hasOutputPasses, logLevel as logLevelMap } from '@kubb/core'\nimport { writer as defaultWriter } from '../ui/log.ts'\nimport { installLogger } from './features/index.ts'\nimport type { LoggerWriter } from './types.ts'\nimport { diffFile, diffOutput, type FileChange, readOutputFiles } from '../runners/generate/utils.ts'\n\n/** Installs the live logger and wires the selected reporters. `cli` renders its summary through the logger, and is skipped when `json` owns stdout. */\nfunction setupReporters(\n context: Hookable<KubbHooks>,\n {\n logLevel,\n reporters,\n writer = defaultWriter(),\n dryRun = false,\n fileChanges = false,\n }: {\n /** Output verbosity. Use the `logLevel` constants exported from `@kubb/core`. */\n logLevel: number\n reporters: ReadonlyArray<Reporter>\n /** Overrides the terminal-based pick, e.g. the plain writer for `kubb studio snapshot`. */\n writer?: LoggerWriter\n /**\n * Labels the memory-backed generation as a preview rather than a completed write.\n */\n dryRun?: boolean\n /**\n * Hands `fileChanges` to every reporter, not only `cli`.\n */\n fileChanges?: boolean\n },\n): void {\n const hasJson = reporters.some((reporter) => reporter.name === 'json')\n const selected = reporters.flatMap((reporter) => {\n if (reporter.name !== 'cli') return [reporter]\n if (hasJson) return []\n return [createCliReporter({ render: installLogger({ hooks: context, writer, logLevel }).renderSummary })]\n })\n const ctx: ReporterContext = { logLevel }\n const pluginFiles = selected.some((reporter) => reporter.needsPluginFiles) ? new Map<string, Array<string>>() : undefined\n const seen = new Set<string>()\n if (pluginFiles) {\n context.hook('kubb:plugin:end', ({ plugin, files }) => {\n for (const file of files) {\n if (seen.has(file.path)) continue\n seen.add(file.path)\n const paths = pluginFiles.get(plugin.name) ?? []\n paths.push(file.path)\n pluginFiles.set(plugin.name, paths)\n }\n })\n }\n\n // Configs generate one at a time, so the last write before `kubb:generation:end` is this config's.\n let filesUnchanged = 0\n let previous: Map<string, string> | undefined\n let reading: Promise<Map<string, string>> | undefined\n // Changes worked out from each source as it is written, so the summary does not read the output back.\n let counted: Map<string, FileChange | undefined> | undefined\n let paths: Array<string> = []\n let outputPath = ''\n const trackChanges = (fileChanges || selected.some((reporter) => reporter.name === 'cli')) && logLevel > logLevelMap.silent\n context.hook('kubb:generation:start', ({ config }) => {\n pluginFiles?.clear()\n seen.clear()\n filesUnchanged = 0\n paths = []\n outputPath = resolve(config.root, config.output.path)\n previous = undefined\n // Read while the plugins generate; `kubb:plugins:end` waits for it, before cleaning can erase the baseline.\n reading = trackChanges && (dryRun || config.storage?.name === 'fs') ? readOutputFiles(outputPath) : undefined\n // Output passes rewrite stored files and a dry run compares through the manifest, so both read the output back.\n counted = reading && !dryRun && !hasOutputPasses(config) ? new Map() : undefined\n })\n context.hook('kubb:plugins:end', async () => {\n if (reading) previous = await reading\n })\n context.hook('kubb:files:processing:start', async ({ files }) => {\n if (!previous) return\n // Plugin output can live outside the main output folder; capture it before writes start.\n for (const file of files) {\n if (previous.has(file.path) || isPathInside(outputPath, file.path)) continue\n const source = await readFile(file.path, 'utf8').catch(() => null)\n if (source !== null) previous.set(file.path, source)\n }\n })\n context.hook('kubb:file:processed', ({ file, source }) => {\n if (!counted || !previous) return\n // The storage writes the trimmed source and skips a blank one.\n const next = source.trim()\n if (next) counted.set(file.path, diffFile({ path: file.path, next, previous: previous.get(file.path) ?? null }))\n })\n context.hook('kubb:files:processing:end', ({ files, unchanged }) => {\n filesUnchanged = unchanged.length\n paths = files.map((file) => file.path)\n })\n\n context.hook('kubb:generation:end', async ({ config, storage, diagnostics = [], filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {\n const result: GenerationResult = { config, diagnostics, filesCreated, filesUnchanged, dryRun, status, hrStart }\n const cliResult = { ...result }\n if (previous && status !== 'failed') {\n const manifest = dryRun ? await createOutputManifest({ storage, cache: cacheStorage({ root: config.root }) }) : undefined\n const diff = await diffOutput({\n storage,\n paths,\n clean: Boolean(config.output.clean),\n manifest,\n previousFiles: previous,\n counted,\n })\n const changes = { added: 0, modified: 0, deleted: 0, linesAdded: 0, linesRemoved: 0 }\n const counts = { A: 'added', M: 'modified', D: 'deleted' } as const\n for (const file of diff.files) {\n changes[counts[file.status]]++\n changes.linesAdded += file.added ?? 0\n changes.linesRemoved += file.removed ?? 0\n }\n cliResult.filesCreated = changes.added + changes.modified + diff.unchanged\n cliResult.filesUnchanged = diff.unchanged\n cliResult.fileChanges = changes\n }\n for (const reporter of selected) {\n const grouped = reporter.needsPluginFiles && pluginFiles?.size ? [...pluginFiles].map(([plugin, files]) => ({ plugin, files: [...files] })) : undefined\n await reporter.report({ ...(reporter.name === 'cli' || fileChanges ? cliResult : result), pluginFiles: grouped }, ctx)\n }\n })\n\n context.hook('kubb:lifecycle:end', async () => {\n for (const reporter of selected) await reporter.drain?.(ctx)\n })\n}\n\nexport default setupReporters\n\n/** Picks the reporters whose `name` is in `names`, in the given order (the CLI maps `--reporter` to this); duplicates and unknown names are skipped. */\nexport function selectReporters(reporters: ReadonlyArray<Reporter>, names: ReadonlyArray<string>): Array<Reporter> {\n return [...new Set(names)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,MAAM,YAAY,UAAU,MAAM,SAAS,QAAQ,GAAG;CAC7D,CAAC;AACH;;AAKA,SAAgB,gBAAgB,WAAoC,OAA+C;CACjH,OAAO,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,SAAS,SAAS,UAAU,MAAM,aAAa,SAAS,SAAS,IAAI,KAAK,CAAC,CAAC;AACzG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-5u7cHD85.js","names":[],"sources":["../src/runners/add/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { define } from 'gunshi'\nimport { BUNDLED_PACKAGES, ConfigEditOperation, extensionKinds, editConfig, editConfigFile, findConfigFile, readImports } from '@internals/shared'\nimport { getErrorMessage, pascalCase, read } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, readInstalledPackages, type RegistryDetail, type RegistryEntry } from '@kubb/core'\nimport { configArg, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { withSpinner } from '../../ui/spinner.ts'\nimport { createSummary } from '../../ui/summary.ts'\nimport { closestIds, fetchRegistryIndex, incompatibility, installSpec, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\n\nexport type AddOptions = {\n /**\n * `owner/slug`, or a bare `slug` for an official extension. Asked for when omitted.\n */\n id?: string\n configPath?: string\n yes: boolean\n install: boolean\n}\n\ntype ConfigTarget = Pick<RegistryDetail, 'artifact' | 'manifest'>\n\n/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */\nfunction toSnippet({ artifact, manifest }: ConfigTarget): string {\n const call = `${manifest.export}()`\n const property: Record<ExtensionManifest['kind'], string> = {\n plugin: `plugins: [..., ${call}],`,\n adapter: `adapter: ${call},`,\n parser: `parsers: [..., ${call}],`,\n }\n return [`import { ${manifest.export} } from '${artifact.package}'`, '', property[manifest.kind]].join('\\n')\n}\n\n/** The `add-plugin` edits for `details`, and the manifests the edits read their export names from. */\nfunction toConfigEdits(details: Array<ConfigTarget>) {\n return {\n edits: details.map(({ artifact, manifest }) => ({\n operation: ConfigEditOperation.ADD_PLUGIN,\n ...(manifest.kind === extensionKinds.parser ? { kind: extensionKinds.parser } : {}),\n plugin: artifact.package,\n })),\n extensions: new Map(details.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n }\n}\n\n/** The lines adding `details` would put in the config `source`, trimmed, or why it could not add them. */\nfunction previewConfig({ details, source }: { details: Array<ConfigTarget>; source: string }): { lines: Array<string>; source: string } | { reason: string } {\n const result = editConfig({ source, ...toConfigEdits(details) })\n const failed = result.outcomes.find((outcome) => !outcome.applied)\n if (failed) return { reason: failed.reason ?? 'the config file was not changed' }\n const remaining = source.split('\\n')\n const lines = result.source.split('\\n').filter((line) => {\n const index = remaining.indexOf(line)\n if (index !== -1) remaining.splice(index, 1)\n return index === -1\n })\n return { lines: lines.map((line) => line.trim()), source: result.source }\n}\n\nasync function selectExtension({\n entries,\n versions,\n registry,\n}: {\n entries: Array<RegistryEntry>\n versions: Map<string, unknown>\n registry: string\n}): Promise<string | undefined> {\n if (!entries.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `The registry at ${registry} lists no extensions.`,\n help: 'Check that `KUBB_REGISTRY` points at a Kubb registry, or unset it to use https://kubb.dev/registry.',\n })\n\n // Filters in memory, so typing never waits on the network.\n const searchText = new Map(entries.map((entry) => [entry.id, `${entry.id} ${entry.manifest.displayName} ${entry.manifest.description}`.toLowerCase()]))\n const options = entries\n .toSorted((a, b) => a.id.localeCompare(b.id))\n .map((entry) => {\n const installed = versions.has(entry.artifact.package)\n return { value: entry.id, label: toShortId(entry.id), hint: installed ? 'installed' : summarize(entry.manifest.description), disabled: installed }\n })\n\n const id = await clack.autocomplete({\n message: `Add an extension · ${entries.length} in the registry`,\n placeholder: 'Search',\n options,\n filter: (search, option) => searchText.get(option.value)?.includes(search.toLowerCase()) ?? false,\n })\n return clack.isCancel(id) ? undefined : id\n}\n\n/** Asks whether to also add the required plugins the config lacks. `--yes` adds them. */\nasync function confirmDependencies({\n entry,\n missing,\n yes,\n}: {\n entry: RegistryEntry\n missing: Array<RegistryEntry>\n yes: boolean\n}): Promise<boolean | undefined> {\n if (!missing.length || yes) return true\n const names = missing.map((dependency) => dependency.manifest.name).join(', ')\n const answer = await clack.select({\n message: `${entry.manifest.name} needs ${names}. Add ${names} as well?`,\n options: [\n { value: true, label: `Yes, add ${missing.length === 1 ? 'both' : 'all'}`, hint: 'recommended' },\n { value: false, label: `Only ${entry.manifest.name}`, hint: 'generate fails until you add it' },\n ],\n initialValue: true,\n })\n return clack.isCancel(answer) ? undefined : answer\n}\n\n/** The first sentence of a registry description, cut to one terminal line. */\nexport function summarize(description: string, max = 64): string {\n const sentence = description.split(/\\.\\s/)[0]!.replace(/\\.$/, '')\n return sentence.length > max ? `${sentence.slice(0, max - 1).trimEnd()}…` : sentence\n}\n\n/**\n * Installs an extension from the Kubb registry at its reviewed version and, for a plugin or a parser,\n * adds it to `kubb.config.ts`, offering to add the plugins it needs as well. An adapter is never\n * written: the command prints the snippet to swap it in by hand. Without an id, asks which one.\n * Previews the packages and config lines before asking. Refuses when the running Kubb or Node.js\n * version is outside its compatibility.\n */\nexport async function run({ id: input, configPath, yes, install }: AddOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const summary = createSummary(hrStart)\n const installedPackages: Array<string> = []\n const configured: Array<RegistryEntry> = []\n logIntro({ title: isInteractiveRun({ yes }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Add ')) })\n\n try {\n const registry = registryUrl()\n if (!input && yes)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'Pass a registry id, such as plugin-zod, when using --yes.',\n help: 'Run `kubb add plugin-zod --yes`, or drop `--yes` to pick from a list.',\n })\n const inputId = input ? toRegistryId(input) : undefined\n const foundConfig = configPath ? path.resolve(configPath) : findConfigFile(cwd)\n const [entries, installed, configSource] = await withSpinner({\n message: 'Reading the registry',\n promise: Promise.all([\n fetchRegistryIndex({ registry }),\n readInstalledPackages({ root: cwd }),\n foundConfig ? read(foundConfig).catch(() => undefined) : undefined,\n ]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const id = inputId ?? (await selectExtension({ entries, versions, registry }))\n if (!id) {\n summary('Add canceled', 'canceled', [' No changes made'])\n return\n }\n const entry = entries.find((candidate) => candidate.id === id)\n if (!entry) {\n const suggestions = closestIds({ input: id, ids: entries.map((entry) => entry.id) }).map(toShortId)\n summary(`No extension named ${input ?? id}`, 'failed', [\n ...suggestions.map((suggestion) => ` kubb add ${suggestion}`),\n ' Browse all kubb.dev/extensions',\n ])\n process.exitCode = 1\n return\n }\n const { artifact, manifest } = entry\n const kind = pascalCase(manifest.kind)\n\n const problem = incompatibility(manifest)\n if (problem)\n throw new Diagnostics.Error({\n code: Diagnostics.code.incompatibleExtension,\n severity: 'error',\n message: problem,\n help: 'Upgrade Kubb or Node.js to a version the extension supports.',\n })\n\n const configFile = manifest.kind === extensionKinds.adapter ? undefined : foundConfig\n if (manifest.kind !== extensionKinds.adapter && !configFile)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'No kubb.config.ts found. Run `kubb init` first, or pass --config.',\n help: 'Run `kubb init` to create a config, or pass its path with `--config`.',\n })\n const configName = configFile ? path.relative(cwd, configFile) || configFile : undefined\n\n const byName = new Map(entries.map((candidate) => [candidate.manifest.name, candidate]))\n const inConfig = (name: string) => {\n const dependency = byName.get(name)\n return dependency ? !!configSource?.includes(`${dependency.manifest.export}(`) : installed.some((item) => item.manifest?.name === name)\n }\n const dependencies = manifest.dependencies ?? []\n const missing = configFile ? dependencies.filter((name) => !inConfig(name)).flatMap((name) => byName.get(name) ?? []) : []\n const withDependencies = await confirmDependencies({ entry, missing, yes })\n if (withDependencies === undefined) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n const targets = [...(withDependencies ? missing : []), entry]\n\n const dependencyStatus = (name: string) => {\n if (inConfig(name)) return `${name} ${styleText('green', '✓ installed')}`\n return targets.some((target) => target.manifest.name === name) ? `${name} ${styleText('cyan', '+ adding')}` : `${name} ${styleText('yellow', 'missing')}`\n }\n const preview = configFile && configSource !== undefined ? previewConfig({ details: targets, source: configSource }) : undefined\n // The default parsers written next to a new parser come with `kubb`. A strict node_modules layout\n // only lets the config import direct dependencies, so they are installed at the project's `kubb` version.\n const before = readImports(configSource ?? '')\n const added = preview && 'lines' in preview ? readImports(preview.source).filter((name) => !before.includes(name)) : []\n const bundled = BUNDLED_PACKAGES.filter(\n (name) => added.includes(name) && !versions.has(name) && !targets.some((target) => target.artifact.package === name),\n )\n const kubbVersion = versions.get('kubb')\n const specs = [\n ...targets.filter((target) => target === entry || !versions.has(target.artifact.package)).map((target) => installSpec(target.artifact)),\n ...bundled.map((name) => (kubbVersion ? `${name}@${kubbVersion}` : name)),\n ]\n logStep(`${kind} ${styleText('cyan', manifest.name)} v${artifact.version} · ${summarize(manifest.description)}`)\n logBlock([\n ...(dependencies.length ? [`Needs ${dependencies.map(dependencyStatus).join(' ')}`] : []),\n install ? `Installs ${specs.join(' ')}` : 'Installs nothing (--no-install)',\n ...(configName ? [`Config ${configName}`] : [`Config prints the ${manifest.kind} snippet to add`]),\n ...(preview && 'lines' in preview ? preview.lines.map((line) => styleText('green', ` + ${line}`)) : []),\n ...(preview && 'reason' in preview ? [styleText('yellow', ` cannot edit it: ${preview.reason}`)] : []),\n ])\n\n const confirmed = yes || (await clack.confirm({ message: 'Add it?', initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n\n const packageManager = await detectPackageManager(cwd)\n const packages = () => (install ? `${installedPackages.length} installed with ${packageManager.name}` : 'installation skipped (--no-install)')\n if (install) {\n const names = [...targets.filter((target) => specs.includes(installSpec(target.artifact))).map((target) => target.artifact.package), ...bundled]\n await installWithSpinner({ packages: specs, names: names.join(', '), packageManager, cwd })\n installedPackages.push(...names)\n }\n\n const unconfigured: Array<RegistryEntry> = configFile ? [] : [entry]\n if (configFile) {\n for (const target of targets) {\n try {\n const { outcomes, changed } = await editConfigFile({ filePath: configFile, ...toConfigEdits([target]) })\n if (!outcomes[0]?.applied) throw new Error(outcomes[0]?.reason ?? 'the config file was not changed')\n if (changed) configured.push(target)\n logStep(`${target.manifest.export}() configured in ${configName}`)\n } catch (error) {\n logWarn(`Could not edit ${configName}: ${getErrorMessage(error)}`)\n unconfigured.push(target)\n }\n }\n }\n\n const manual = unconfigured.length > 0\n // A plugin or parser the command could not write into the config is a failure a caller can act on; an adapter never gets written.\n if (manual && manifest.kind !== extensionKinds.adapter) process.exitCode = 1\n if (manual)\n logBlock([\n 'Add the import to your Kubb config and merge the property into its defineConfig call:',\n '',\n ...unconfigured.map((target) => toSnippet(target)),\n ])\n const dependenciesMissing = !withDependencies && missing.length > 0\n const title = manual\n ? `${kind} needs configuration`\n : dependenciesMissing\n ? 'Plugin configured; dependencies missing'\n : configured.length\n ? install\n ? `${kind} ready`\n : `${kind} configured`\n : `${kind} already configured`\n summary(title, manual || dependenciesMissing ? 'warning' : 'success', [\n ` Packages ${packages()}`,\n ...configured.map((target) => styleText('green', ` + ${target.manifest.export}()`)),\n '',\n ...(!install ? [`Install ${specs.join(' ')} to use it.`] : []),\n ...(dependenciesMissing ? [`Missing plugins ${missing.map((target) => target.manifest.name).join(', ')}`] : []),\n manual ? 'Add the snippet above, then run kubb generate.' : 'Next kubb generate',\n `Options kubb.dev/extensions/${entry.id}`,\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Add failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = define({\n name: 'add',\n description: 'Find and install plugins, adapters, and parsers from the Kubb registry.',\n examples: [\n 'kubb add',\n 'kubb add plugin-zod',\n 'kubb add kubb-labs/plugin-react-query',\n 'kubb add acme/plugin-x --yes',\n 'kubb add plugin-zod --no-install',\n ].join('\\n'),\n toKebab: true,\n args: {\n id: {\n type: 'positional',\n description: 'Registry id: owner/slug, or a slug for an official extension. Asked for when omitted',\n required: false,\n },\n ...configArg,\n ...yesArg,\n install: {\n type: 'boolean',\n description: 'Install the package. Pass --no-install to only edit the config',\n negatable: true,\n default: true,\n },\n },\n run: ({ values }) => run({ id: values.id, configPath: values.config, yes: values.yes, install: values.install }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,UAAU,EAAE,UAAU,YAAkC;CAC/D,MAAM,OAAO,GAAG,SAAS,OAAO;CAChC,MAAM,WAAsD;EAC1D,QAAQ,kBAAkB,KAAK;EAC/B,SAAS,YAAY,KAAK;EAC1B,QAAQ,kBAAkB,KAAK;CACjC;CACA,OAAO;EAAC,YAAY,SAAS,OAAO,WAAW,SAAS,QAAQ;EAAI;EAAI,SAAS,SAAS;CAAK,CAAC,CAAC,KAAK,IAAI;AAC5G;;AAGA,SAAS,cAAc,SAA8B;CACnD,OAAO;EACL,OAAO,QAAQ,KAAK,EAAE,UAAU,gBAAgB;GAC9C,WAAW,oBAAoB;GAC/B,GAAI,SAAS,SAAS,eAAe,SAAS,EAAE,MAAM,eAAe,OAAO,IAAI,CAAC;GACjF,QAAQ,SAAS;EACnB,EAAE;EACF,YAAY,IAAI,IAAI,QAAQ,KAAK,EAAE,UAAU,eAAe,CAAC,SAAS,SAAS;GAAE,SAAS,SAAS;GAAS,SAAS,SAAS;GAAS;EAAS,CAAC,CAAC,CAAC;CACrJ;AACF;;AAGA,SAAS,cAAc,EAAE,SAAS,UAA2H;CAC3J,MAAM,SAAS,WAAW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names":["createSpinner","Hookable","logLevelMap","pluralize","path","getErrorMessage","process","createSummary","isInteractiveRun","styleText","toRegistryId","withSpinner","fetchRegistryIndex","registryUrl","readInstalledPackages","bumpOf","isOutdated","incompatibility","formatTable","clack","pascalCase","toShortId","detectPackageManager","installWithSpinner","installSpec","findConfigFile","defineWithTypes","yesArg","dryRunId"],"sources":["../src/runners/update/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { defineWithTypes } from 'gunshi'\nimport { findConfigFile } from '@internals/shared'\nimport { getErrorMessage, pascalCase } from '@internals/utils'\nimport { type GenerationResult, Hookable, type KubbHooks, logLevel as logLevelMap, readInstalledPackages, type RegistryEntry, type Reporter } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport { dryRunId, type DryRunExtensions, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { createSpinner, withSpinner } from '../../ui/spinner.ts'\nimport { createSummary } from '../../ui/summary.ts'\nimport { formatTable } from '../../ui/table.ts'\nimport { bumpOf, fetchRegistryIndex, incompatibility, installSpec, isOutdated, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\n\nexport type UpdateOptions = {\n /**\n * Registry ids to update. Empty updates every installed extension the registry lists.\n */\n ids: Array<string>\n /**\n * List the updates without installing anything.\n */\n dryRun: boolean\n yes: boolean\n}\n\ntype FileChanges = NonNullable<GenerationResult['fileChanges']>\n\n/**\n * Generates every config in this process, the way `kubb generate` does, and returns the counts of\n * output files it changed. Runs after the install, so the config loads the new versions.\n * `undefined` when the config fails to load or a build fails.\n */\nasync function regenerate({ cwd, configPath }: { cwd: string; configPath: string }): Promise<{ changes: FileChanges; output: string } | undefined> {\n const spinner = createSpinner()\n spinner.start('Generating with the new versions')\n try {\n // Imported here, so the config loader and the generate path never slow down `kubb --help`.\n const [{ getConfigs }, { generate }, { default: setupReporters }] = await Promise.all([\n import('../../config.ts'),\n import('../generate/run.ts'),\n import('../../loggers/reporters.ts'),\n ])\n const { configs } = await getConfigs({ configPath })\n const hooks = new Hookable<KubbHooks>()\n const changes: FileChanges = { added: 0, modified: 0, deleted: 0, linesAdded: 0, linesRemoved: 0 }\n const collect: Reporter = {\n name: 'update',\n report: ({ fileChanges }) => {\n for (const key of Object.keys(changes) as Array<keyof FileChanges>) changes[key] += fileChanges?.[key] ?? 0\n },\n }\n setupReporters(hooks, { logLevel: logLevelMap.info, reporters: [collect], fileChanges: true })\n for (const config of configs) {\n if (!(await generate({ config, hooks }))) throw new Error('Generation failed')\n }\n const changed = changes.added + changes.modified + changes.deleted\n spinner.stop(changed ? `Generated: ${pluralize(changed, 'file')} changed` : 'Generated: no files changed')\n return { changes, output: configs.map((config) => path.relative(cwd, path.resolve(config.root ?? cwd, config.output.path)) || '.').join(', ') }\n } catch (error) {\n spinner.error(`Generation failed: ${getErrorMessage(error)}`)\n return undefined\n }\n}\n\n/**\n * Moves installed extensions to the version the registry pins. Shows each version change with its\n * bump, asks which to install with majors left out, installs them, and regenerates to show which\n * files changed. With `dryRun`, only lists the updates and installs nothing.\n */\nexport async function run({ ids, dryRun, yes }: UpdateOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const installedPackages: Array<string> = []\n const summary = createSummary(hrStart)\n logIntro({ title: isInteractiveRun({ yes, dryRun }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Update ')) })\n\n try {\n const wanted = new Set(ids.map(toRegistryId))\n const [entries, installed] = await withSpinner({\n message: 'Checking the registry',\n promise: Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd })]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const tracked = entries.filter((entry) => versions.has(entry.artifact.package) && (!wanted.size || wanted.has(entry.id)))\n for (const id of wanted) {\n if (tracked.some((entry) => entry.id === id)) continue\n logWarn(`${id} is not installed, or not in the registry.`)\n // A caller that named it, such as Studio, must not read the run as a successful update.\n process.exitCode = 1\n }\n\n const current = ({ artifact }: RegistryEntry) => versions.get(artifact.package)\n const isMajor = (entry: RegistryEntry) => bumpOf({ installed: current(entry), latest: entry.artifact.version }) === 'major'\n const outdated = tracked.filter((entry) => isOutdated({ installed: current(entry), latest: entry.artifact.version }))\n const proposals = outdated.filter((entry) => {\n const problem = incompatibility(entry.manifest)\n if (problem) {\n logWarn(`Skipped ${entry.id}: ${problem}`)\n // Same as a missing id: Studio would report an update that installed nothing.\n if (wanted.has(entry.id)) process.exitCode = 1\n }\n return !problem\n })\n\n if (!proposals.length) {\n const title = outdated.length ? 'No compatible updates available' : 'Already up to date'\n summary(tracked.length ? title : 'No installed extensions to update', outdated.length ? 'warning' : 'success', [\n ` ${tracked.length - outdated.length} of ${tracked.length} up to date`,\n ...(ids.length ? ['', `No updates for ${ids.join(', ')}.`] : []),\n ])\n return\n }\n\n if (tracked.length) {\n const header = ['Extension', 'Current', 'Latest', '']\n const rows = tracked.map((entry) => {\n if (!outdated.includes(entry)) return [entry.artifact.package, current(entry) ?? '-', 'up to date', '']\n const bump = bumpOf({ installed: current(entry), latest: entry.artifact.version }) ?? ''\n return [entry.artifact.package, current(entry) ?? 'not installed', entry.artifact.version, bump === 'major' ? 'major · breaking' : bump]\n })\n const lines = formatTable([header, ...rows])\n logStep(`Checked ${pluralize(tracked.length, 'extension')} against the registry`)\n logBlock([\n styleText('dim', lines[0]!),\n ...lines.slice(1).map((line, index) => {\n if (!outdated.includes(tracked[index]!)) return styleText('dim', line)\n return line.endsWith('major · breaking') ? styleText('yellow', line) : line\n }),\n ])\n }\n\n if (dryRun) {\n summary('Updates available', 'planned', [`Dry run: nothing was installed. Run kubb update to install ${proposals.length === 1 ? 'it' : 'them'}.`])\n return\n }\n\n // A major can break the generated code, so it is only picked for you when you named it.\n const defaults = proposals.filter((entry) => wanted.has(entry.id) || !isMajor(entry))\n const chosen = yes\n ? defaults.map((entry) => entry.id)\n : await clack.multiselect({\n message: 'Select the updates to install',\n options: proposals.map((entry) => ({\n value: entry.id,\n label: entry.artifact.package,\n hint: `${current(entry) ?? 'not installed'} → ${entry.artifact.version}`,\n })),\n initialValues: defaults.map((entry) => entry.id),\n required: false,\n })\n if (clack.isCancel(chosen)) {\n summary('Update canceled', 'canceled', [' No changes made'])\n return\n }\n const selected = proposals.filter((entry) => chosen.includes(entry.id))\n\n const skipped = proposals\n .filter((entry) => !selected.includes(entry))\n .map((entry) => {\n const kind = pascalCase(entry.manifest.kind)\n return ` ${styleText('dim', 'Skipped')} ${kind} ${entry.artifact.package} ${entry.artifact.version} ${styleText('dim', `run kubb update ${toShortId(entry.id)} later`)}`\n })\n if (!selected.length) {\n summary('No updates installed', 'canceled', [' No updates selected.', ...skipped])\n return\n }\n\n const packageManager = await detectPackageManager(cwd)\n const names = selected.map(({ artifact }) => artifact.package).join(', ')\n await installWithSpinner({\n packages: selected.map(({ artifact }) => installSpec(artifact)),\n names,\n packageManager,\n cwd,\n })\n installedPackages.push(...selected.map((entry) => entry.artifact.package))\n\n // Regenerating rewrites output files, so it is asked for. `--yes` only accepts the install.\n const foundConfig = findConfigFile(cwd)\n const regenerateNow =\n foundConfig && !yes && (await clack.confirm({ message: 'Regenerate now? This rewrites the generated files.', initialValue: true })) === true\n const configPath = regenerateNow ? foundConfig : undefined\n const changed = configPath ? await regenerate({ cwd, configPath }) : undefined\n\n const generationFailed = Boolean(configPath && !changed)\n summary(generationFailed ? 'Extensions updated; generation failed' : 'Update complete', generationFailed ? 'warning' : 'success', [\n ` Packages ${selected.length} installed with ${packageManager.name}${skipped.length ? ` · ${skipped.length} skipped` : ''}`,\n ...skipped,\n ...(changed ? [` Files ${changed.changes.added} added · ${changed.changes.modified} modified · ${changed.changes.deleted} deleted`] : []),\n ...(!configPath ? [' Regeneration not run'] : []),\n ...(generationFailed ? ['', 'Fix the generation error, then run kubb generate.'] : []),\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Update failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'update',\n description: 'Update installed extensions, regenerate, and summarize file changes.',\n examples: ['kubb update', 'kubb update --dry-run', 'kubb update plugin-zod plugin-ts --yes'].join('\\n'),\n args: {\n ids: {\n type: 'positional',\n description: 'Registry ids to update, all installed extensions when omitted',\n multiple: true,\n },\n ...yesArg,\n },\n run: ({ values, extensions }) => run({ ids: values.ids ?? [], dryRun: extensions[dryRunId].enabled, yes: values.yes }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,eAAe,WAAW,EAAE,KAAK,cAAkH;CACjJ,MAAM,UAAUA,gBAAAA,cAAc;CAC9B,QAAQ,MAAM,kCAAkC;CAChD,IAAI;EAEF,MAAM,CAAC,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,oBAAoB,MAAM,QAAQ,IAAI;GACpF,QAAA,QAAA,CAAA,CAAA,WAAA,QAAA,uBAAA,CAAA,CAAA,CAAA,MAAA,MAAA,EAAA,cAAA;GACA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAA,oBAAA,CAAA;GACA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAA,0BAAA,CAAA,CAAA,CAAA,MAAA,MAAA,EAAA,iBAAA;EACF,CAAC;EACD,MAAM,EAAE,YAAY,MAAM,WAAW,EAAE,WAAW,CAAC;EACnD,MAAM,QAAQ,IAAIC,WAAAA,SAAoB;EACtC,MAAM,UAAuB;GAAE,OAAO;GAAG,UAAU;GAAG,SAAS;GAAG,YAAY;GAAG,cAAc;EAAE;EAOjG,eAAe,OAAO;GAAE,UAAUC,WAAAA,SAAY;GAAM,WAAW,CAAC;IAL9D,MAAM;IACN,SAAS,EAAE,kBAAkB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AS,CAAC;EAAS,KAAK,OAAO;CAAI,CAAC;AACvH,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-BxNbFsmc.cjs","names":["process","createSummary","isInteractiveRun","styleText","toRegistryId","path","findConfigFile","Diagnostics","withSpinner","fetchRegistryIndex","registryUrl","readInstalledPackages","read","closestIds","toShortId","pascalCase","extensionKinds","readConfig","ConfigEditOperation","editConfig","BUNDLED_PACKAGES","readImports","clack","editConfigFile","detectPackageManager","uninstallPackages","getErrorMessage","define","configArg","yesArg"],"sources":["../src/runners/remove/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { define } from 'gunshi'\nimport { BUNDLED_PACKAGES, ConfigEditOperation, extensionKinds, editConfig, editConfigFile, findConfigFile, readConfig, readImports } from '@internals/shared'\nimport { getErrorMessage, pascalCase, read } from '@internals/utils'\nimport { Diagnostics, readInstalledPackages } from '@kubb/core'\nimport { configArg, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep } from '../../ui/log.ts'\nimport { withSpinner } from '../../ui/spinner.ts'\nimport { createSummary } from '../../ui/summary.ts'\nimport { closestIds, fetchRegistryIndex, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager, uninstallPackages } from '../init/utils.ts'\n\nexport type RemoveOptions = {\n /**\n * `owner/slug`, or a bare `slug` for an official extension.\n */\n id: string\n configPath?: string\n yes: boolean\n uninstall: boolean\n}\n\n/** The lines of `before` that `after` no longer has, trimmed. */\nfunction removedLines({ before, after }: { before: string; after: string }): Array<string> {\n const remaining = after.split('\\n')\n return before\n .split('\\n')\n .filter((line) => {\n const index = remaining.indexOf(line)\n if (index !== -1) remaining.splice(index, 1)\n return index === -1 && line.trim() !== ''\n })\n .map((line) => line.trim())\n}\n\n/**\n * Removes a plugin or parser from `kubb.config.ts` and uninstalls its package. Refuses the adapter,\n * which the config needs, and an extension another one in the config depends on. Previews the\n * change before asking.\n */\nexport async function run({ id: input, configPath, yes, uninstall }: RemoveOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const summary = createSummary(hrStart)\n const fail = (title: string, lines: ReadonlyArray<string>) => {\n summary(title, 'failed', lines)\n process.exitCode = 1\n }\n logIntro({ title: isInteractiveRun({ yes }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Remove ')) })\n\n try {\n const id = toRegistryId(input)\n const configFile = configPath ? path.resolve(configPath) : findConfigFile(cwd)\n if (!configFile)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'No kubb.config.ts found. Pass its path with --config.',\n help: 'Run `kubb remove <id> --config <path>`.',\n })\n const configName = path.relative(cwd, configFile) || configFile\n const [entries, installed, source] = await withSpinner({\n message: 'Reading the registry',\n promise: Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd }), read(configFile)]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const entry = entries.find((candidate) => candidate.id === id)\n if (!entry) {\n const suggestions = closestIds({ input: id, ids: entries.map((candidate) => candidate.id) }).map(toShortId)\n return fail(\n `No extension named ${input}`,\n suggestions.map((suggestion) => ` kubb remove ${suggestion}`),\n )\n }\n const { artifact, manifest } = entry\n const kind = pascalCase(manifest.kind)\n if (manifest.kind === extensionKinds.adapter)\n return fail('The adapter cannot be removed', [` A config needs one adapter. Change it in ${configName} by hand.`])\n\n // Only calls that run count: a plugin Studio switched off is a comment, as in Studio's own check.\n const view = readConfig(source)\n const running = new Set(\n view.managed\n ? view.configs.flatMap((config) => [...config.plugins, ...(config.parsers ?? [])].filter((call) => !call.disabled).map((call) => call.packageName))\n : [],\n )\n const dependents = entries.filter(\n (other) => other.id !== entry.id && other.manifest.dependencies?.includes(manifest.name) && running.has(other.artifact.package),\n )\n if (dependents.length) {\n const names = dependents.map((other) => other.manifest.name).join(', ')\n return fail(`${names} ${dependents.length === 1 ? 'needs' : 'need'} ${manifest.name}`, [` Remove ${names} first.`])\n }\n\n const edits = [\n {\n operation: ConfigEditOperation.REMOVE_EXTENSION,\n ...(manifest.kind === extensionKinds.parser ? { kind: extensionKinds.parser } : {}),\n plugin: artifact.package,\n },\n ]\n const preview = editConfig({ source, edits })\n const outcome = preview.outcomes[0]\n if (!outcome?.applied) return fail(`Could not edit ${configName}`, [` ${outcome?.reason ?? 'the config file was not changed'}`])\n\n // Bundled extensions leave the config but stay installed.\n const bundled = BUNDLED_PACKAGES.includes(artifact.package)\n // Another `defineConfig` entry can still import it, and uninstalling it then breaks the config.\n const stillImported = readImports(preview.source).includes(artifact.package)\n const uninstalls = uninstall && !bundled && !stillImported && versions.has(artifact.package)\n if (!preview.changed && !uninstalls) {\n summary(`${manifest.name} is not in the project`, 'success', [' No changes made'])\n return\n }\n\n const packageLine = (() => {\n if (uninstalls) return `Uninstalls ${artifact.package}`\n if (bundled) return `Keeps ${artifact.package}, which ships with kubb`\n if (stillImported) return `Keeps ${artifact.package}, which another config entry still imports`\n return 'Uninstalls nothing'\n })()\n logStep(`${kind} ${styleText('cyan', manifest.name)} v${versions.get(artifact.package) ?? artifact.version}`)\n logBlock([\n `Config ${configName}`,\n ...removedLines({ before: source, after: preview.source }).map((line) => styleText('red', ` - ${line}`)),\n packageLine,\n ])\n\n const confirmed = yes || (await clack.confirm({ message: 'Remove it?', initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n summary('Remove canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n\n if (preview.changed) {\n const written = await editConfigFile({ filePath: configFile, edits })\n if (!written.outcomes[0]?.applied) return fail(`Could not edit ${configName}`, [` ${written.outcomes[0]?.reason ?? 'the config file was not changed'}`])\n logStep(`${manifest.export}() removed from ${configName}`)\n }\n const packageManager = await detectPackageManager(cwd)\n if (uninstalls)\n await withSpinner({\n message: `Uninstalling ${artifact.package} with ${packageManager.name}`,\n promise: uninstallPackages([artifact.package], packageManager, cwd),\n })\n\n summary(`${kind} removed`, 'success', [\n ` Packages ${uninstalls ? `${artifact.package} uninstalled with ${packageManager.name}` : 'none uninstalled'}`,\n '',\n 'Next kubb generate',\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n fail('Remove failed', [' See the error above'])\n }\n}\n\nexport const command = define({\n name: 'remove',\n description: 'Remove a plugin or parser from kubb.config.ts and uninstall its package.',\n examples: ['kubb remove plugin-zod', 'kubb remove acme/plugin-x --yes', 'kubb remove plugin-zod --no-uninstall'].join('\\n'),\n toKebab: true,\n args: {\n id: {\n type: 'positional',\n description: 'Registry id: owner/slug, or a slug for an official extension',\n required: true,\n },\n ...configArg,\n ...yesArg,\n uninstall: {\n type: 'boolean',\n description: 'Uninstall the package. Pass --no-uninstall to only edit the config',\n negatable: true,\n default: true,\n },\n },\n run: ({ values }) => run({ id: values.id, configPath: values.config, yes: values.yes, uninstall: values.uninstall }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,aAAa,EAAE,QAAQ,SAA2D;CACzF,MAAM,YAAY,MAAM,MAAM,IAAI;CAClC,OAAO,OACJ,MAAM,IAAI,CAAC,CACX,QAAQ,SAAS;EAChB,MAAM,QAAQ,UAAU,QAAQ,IAAI;EACpC,IAAI,UAAU,IAAI,UAAU,OAAO,OAAO,CAAC;EAC3C,OAAO,UAAU,MAAM,KAAK,KAAK,MAAM;CACzC,CAAC,CAAC,CACD,KAAK,SAAS,KAAK,KAAK,CAAC;AAC9B;;;;;;AAOA,eAAsB,IAAI,EAAE,IAAI,OAAO,YAAY,KAAK,aAA2C;CACjG,MAAM,MAAMA,aAAAA,QAAQ,IAAI;CACxB,MAAM,UAAUA,aAAAA,QAAQ,OAAO;CAC/B,MAAM,UAAUC,gBAAAA,cAAc,OAAO;CACrC,MAAM,QAAQ,OAAe,UAAiC;EAC5D,QAAQ,OAAO,UAAU,KAAK;EAC9B,aAAA,QAAA,WAAmB;CAC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qB,GAAG;EACrD,IAAI,YACF,MAAMhB,gBAAAA,YAAY;GAChB,SAAS,gBAAgB,SAAS,QAAQ,QAAQ,eAAe;GACjE,SAASiB,cAAAA,kBAAkB,CAAC,SAAS,OAAO,GAAG,gBAAgB,GAAG;EACpE,CAAC;EAEH,QAAQ,GAAG,KAAK,WAAW,WAAW;GACpC,eAAe,aAAa,GAAG,SAAS,QAAQ,oBAAoB,eAAe,SAAS;GAC5F;GACA;EACF,CAAC;CACH,SAAS,OAAO;EACd,YAAA,SAASC,eAAAA,gBAAgB,KAAK,CAAC;EAC/B,KAAK,iBAAiB,CAAC,uBAAuB,CAAC;CACjD;AACF;AAEA,MAAa,WAAA,GAAUC,OAAAA,OAAAA,CAAO;CAC5B,MAAM;CACN,aAAa;CACb,UAAU;EAAC;EAA0B;EAAmC;CAAuC,CAAC,CAAC,KAAK,IAAI;CAC1H,SAAS;CACT,MAAM;EACJ,IAAI;GACF,MAAM;GACN,aAAa;GACb,UAAU;EACZ;EACA,GAAGC,eAAAA;EACH,GAAGC,eAAAA;EACH,WAAW;GACT,MAAM;GACN,aAAa;GACb,WAAW;GACX,SAAS;EACX;CACF;CACA,MAAM,EAAE,aAAa,IAAI;EAAE,IAAI,OAAO;EAAI,YAAY,OAAO;EAAQ,KAAK,OAAO;EAAK,WAAW,OAAO;CAAU,CAAC;AACrH,CAAC"}
@@ -1,229 +0,0 @@
1
- const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
2
- const require_time = require("./time-3BKoci3G.cjs");
3
- const require_spinner = require("./spinner-RfMb7fd6.cjs");
4
- const require_reporters = require("./reporters-DyjE3BzZ.cjs");
5
- const require_package = require("./package-B8KmMINL.cjs");
6
- const require_Telemetry = require("./Telemetry-CZJ2Noi6.cjs");
7
- const require_log = require("./log-wv1OxLiq.cjs");
8
- const require_intro = require("./intro-DuyzJ3Rb.cjs");
9
- const require_mascot = require("./mascot-CC-D4ON2.cjs");
10
- const require_config = require("./config-BWj9jBVj.cjs");
11
- const require_text = require("./text-DMiX2dcG.cjs");
12
- const require_registry = require("./registry-Q77p5TZp.cjs");
13
- let node_util = require("node:util");
14
- let node_process = require("node:process");
15
- node_process = require_rolldown_runtime.__toESM(node_process, 1);
16
- let node_path = require("node:path");
17
- node_path = require_rolldown_runtime.__toESM(node_path, 1);
18
- let _kubb_core = require("@kubb/core");
19
- // src/runners/generate/run.ts
20
- /** NPM registry endpoint used to check for @kubb/cli updates. */
21
- const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
22
- /** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */
23
- const UPDATE_CHECK_TIMEOUT_MS = 3e3;
24
- async function generate(options) {
25
- const { input, hooks, dryRun = false } = options;
26
- const report = require_Telemetry.trackRun({
27
- command: "generate",
28
- hrStart: node_process.default.hrtime()
29
- });
30
- const config = {
31
- ...options.config,
32
- input: input ?? options.config.input,
33
- storage: dryRun ? (0, _kubb_core.memoryStorage)() : options.config.storage,
34
- output: dryRun ? {
35
- ...options.config.output,
36
- format: false,
37
- lint: false,
38
- postGenerate: []
39
- } : options.config.output
40
- };
41
- const kubb = (0, _kubb_core.createKubb)(config, { hooks });
42
- const result = await kubb.generate();
43
- report({
44
- plugins: kubb.config.plugins.flatMap((p) => p && typeof p === "object" ? [{
45
- name: p.meta?.name ?? p.name ?? "",
46
- options: p.options ?? {}
47
- }] : []),
48
- filesCreated: result.files.length,
49
- status: result.success ? "success" : "failed"
50
- });
51
- return result.success;
52
- }
53
- /** The latest published version, `undefined` when the registry does not answer in time or `signal` aborts. Never rejects. */
54
- async function fetchLatestVersion(signal) {
55
- try {
56
- return (await (await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.any([signal, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)]) })).json()).version;
57
- } catch {
58
- return;
59
- }
60
- }
61
- async function checkForUpdate({ hooks, latestVersion }) {
62
- if (latestVersion && require_registry.isOutdated({
63
- installed: require_package.version,
64
- latest: latestVersion
65
- })) await _kubb_core.Diagnostics.emit(hooks, _kubb_core.Diagnostics.update({
66
- currentVersion: require_package.version,
67
- latestVersion
68
- }));
69
- }
70
- /** Prints `Rebuilt in 1.2s · +1 schema -2 operations`, without the names part when the spec kept the same names. */
71
- function logRebuild({ diff: { schemas, operations }, durationMs }) {
72
- const specChange = [
73
- schemas.added && (0, node_util.styleText)("green", `+${require_text.pluralize(schemas.added, "schema")}`),
74
- schemas.removed && (0, node_util.styleText)("red", `-${require_text.pluralize(schemas.removed, "schema")}`),
75
- operations.added && (0, node_util.styleText)("green", `+${require_text.pluralize(operations.added, "operation")}`),
76
- operations.removed && (0, node_util.styleText)("red", `-${require_text.pluralize(operations.removed, "operation")}`)
77
- ].filter(Boolean).join(" ");
78
- require_log.logStep([`Rebuilt in ${require_time.formatMs(durationMs)}`, specChange].filter(Boolean).join((0, node_util.styleText)("dim", " · ")));
79
- }
80
- /**
81
- * Runs the full Kubb generation lifecycle for the given CLI options.
82
- * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),
83
- * calls `generate` for each config entry, and prints an update notice when the registry answered in time.
84
- */
85
- async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, dryRun }) {
86
- const updateCheck = new AbortController();
87
- let latestVersion;
88
- fetchLatestVersion(updateCheck.signal).then((value) => {
89
- latestVersion = value;
90
- });
91
- const logLevel = _kubb_core.logLevel[logLevelKey] ?? _kubb_core.logLevel.info;
92
- const hooks = new _kubb_core.Hookable();
93
- const requestedNames = cliReporters?.length ? cliReporters : ["cli"];
94
- const json = requestedNames.includes("json");
95
- const quiet = logLevel <= _kubb_core.logLevel.silent || json;
96
- const errorHooks = json ? new _kubb_core.Hookable() : hooks;
97
- if (json) require_reporters.setupReporters(errorHooks, {
98
- logLevel,
99
- reporters: [_kubb_core.cliReporter],
100
- writer: require_log.createPlainWriter(console.error)
101
- });
102
- const banner = quiet ? void 0 : require_mascot.logBanner(require_package.version);
103
- const loading = require_config.getConfigs({
104
- configPath,
105
- input,
106
- watch,
107
- logLevel: logLevelKey
108
- });
109
- loading.catch(() => void 0);
110
- await banner;
111
- if (!quiet) require_intro.logIntro({ title: "Configuration" });
112
- const configSpinner = require_spinner.createSpinner();
113
- let configs;
114
- let resolvedConfigPath;
115
- try {
116
- if (!quiet) configSpinner.start("Loading config");
117
- const loaded = await loading;
118
- configs = loaded.configs;
119
- resolvedConfigPath = loaded.configPath;
120
- if (!quiet) configSpinner.stop(`Loaded ${(0, node_util.styleText)("dim", node_path.default.relative(node_process.default.cwd(), resolvedConfigPath))}`);
121
- } catch (error) {
122
- if (!quiet) configSpinner.error("Config failed loading");
123
- if (!json) require_reporters.setupReporters(hooks, {
124
- logLevel,
125
- reporters: [_kubb_core.cliReporter]
126
- });
127
- await _kubb_core.Diagnostics.emit(errorHooks, error);
128
- if (!quiet) require_intro.logOutro((0, node_util.styleText)("red", "✗ Configuration failed"));
129
- node_process.default.exit(1);
130
- }
131
- const available = configs[0]?.reporters?.length ? configs[0].reporters : [
132
- _kubb_core.cliReporter,
133
- _kubb_core.jsonReporter,
134
- _kubb_core.fileReporter,
135
- _kubb_core.htmlReporter
136
- ];
137
- const reporters = require_reporters.selectReporters(available, requestedNames);
138
- require_reporters.setupReporters(hooks, {
139
- logLevel,
140
- reporters,
141
- dryRun
142
- });
143
- await hooks.callHook("kubb:lifecycle:start", { version: require_package.version });
144
- if (!quiet) require_intro.logOutro(`${require_text.pluralize(configs.length, "config")} ready`);
145
- try {
146
- let anyFailed = false;
147
- const tracker = watch ? require_reporters.trackBuild(hooks) : void 0;
148
- const rebuilds = [];
149
- let armKeys;
150
- let queue = Promise.resolve();
151
- for (const config of configs) {
152
- const effectiveInput = input ?? config.input;
153
- const watchPath = (typeof effectiveInput === "string" ? (0, _kubb_core.getInputKind)(effectiveInput) : void 0) === "file" ? effectiveInput : void 0;
154
- if (watchPath && tracker) {
155
- const label = (0, node_util.styleText)("yellow", `Watching ${node_path.default.relative(node_process.default.cwd(), watchPath)}`);
156
- let previous;
157
- const build = async () => {
158
- const hrStart = node_process.default.hrtime();
159
- const succeeded = await generate({
160
- input,
161
- config,
162
- hooks,
163
- dryRun
164
- });
165
- const snapshot = tracker.take();
166
- if (previous) logRebuild({
167
- diff: require_reporters.diffBuilds(previous, snapshot),
168
- durationMs: require_time.getElapsedMs(hrStart)
169
- });
170
- previous = snapshot;
171
- require_log.logStep(armKeys ? `${label} ${(0, node_util.styleText)("dim", "r rebuild · q quit")}` : label);
172
- armKeys?.();
173
- if (succeeded) {
174
- require_intro.logSpacer();
175
- require_intro.logTip();
176
- }
177
- };
178
- let pending = false;
179
- const rebuild = () => {
180
- if (pending) return queue;
181
- pending = true;
182
- queue = queue.then(() => {
183
- pending = false;
184
- return build();
185
- }).catch((error) => void _kubb_core.Diagnostics.emit(errorHooks, error));
186
- return queue;
187
- };
188
- rebuilds.push(rebuild);
189
- if (!quiet) armKeys ??= require_reporters.listenForKeys({
190
- rebuild: () => rebuilds.forEach((trigger) => void trigger()),
191
- quit: (code) => void Promise.resolve(hooks.callHook("kubb:lifecycle:end")).finally(() => node_process.default.exit(code))
192
- });
193
- await rebuild();
194
- await require_reporters.startWatcher([watchPath], rebuild, {
195
- info: require_log.logInfo,
196
- error: require_log.logError
197
- });
198
- } else {
199
- if (tracker && !quiet) require_log.logWarn("Watch mode only follows a local `input` file, so this config is generated once.");
200
- try {
201
- if (!await generate({
202
- input,
203
- config,
204
- hooks,
205
- dryRun
206
- })) anyFailed = true;
207
- } catch (configError) {
208
- await _kubb_core.Diagnostics.emit(errorHooks, configError);
209
- anyFailed = true;
210
- }
211
- }
212
- }
213
- updateCheck.abort();
214
- await checkForUpdate({
215
- hooks,
216
- latestVersion
217
- });
218
- await hooks.callHook("kubb:lifecycle:end");
219
- if (!quiet && !watch && !anyFailed) require_intro.logTip();
220
- if (anyFailed) node_process.default.exitCode = 1;
221
- } catch (error) {
222
- await _kubb_core.Diagnostics.emit(errorHooks, error);
223
- node_process.default.exit(1);
224
- }
225
- }
226
- exports.generate = generate;
227
- exports.run = run;
228
-
229
- //# sourceMappingURL=run-CXYwjh9u.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-CXYwjh9u.cjs","names":["trackRun","process","memoryStorage","createKubb","isOutdated","version","Diagnostics","styleText","pluralize","formatMs","logLevelMap","Hookable","cliReporter","createPlainWriter","logBanner","getConfigs","createSpinner","path","jsonReporter","fileReporter","htmlReporter","selectReporters","trackBuild","getInputKind","diffBuilds","getElapsedMs","listenForKeys","startWatcher","logInfo","logError"],"sources":["../src/runners/generate/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, formatters, getElapsedMs, linters } from '@internals/utils'\nimport {\n Hookable,\n type CLIOptions,\n cliReporter,\n type Config,\n createKubb,\n Diagnostics,\n fileReporter,\n getInputKind,\n htmlReporter,\n jsonReporter,\n type KubbHooks,\n logLevel as logLevelMap,\n memoryStorage,\n type ReporterName,\n} from '@kubb/core'\nimport { version } from '../../../package.json'\nimport { trackRun } from '../../Telemetry.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport setupReporters, { selectReporters } from '../../loggers/reporters.ts'\nimport { createPlainWriter } from '../../loggers/plainWriter.ts'\nimport { logIntro, logOutro, logSpacer, logTip } from '../../ui/intro.ts'\nimport { logError, logInfo, logStep, logWarn } from '../../ui/log.ts'\nimport { logBanner } from '../../ui/mascot.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isOutdated } from '../../utils/registry.ts'\nimport { type BuildDiff, type BuildSnapshot, diffBuilds, listenForKeys, startWatcher, trackBuild } from './utils.ts'\n\n/** NPM registry endpoint used to check for @kubb/cli updates. */\nconst KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */\nconst UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/** The formatter names from `Config['output'].format`, without `'auto'` (detection, not a tool) and `false` (skip). */\ntype FormatterName = Exclude<NonNullable<Config['output']['format']>, 'auto' | false>\ntype LinterName = Exclude<NonNullable<Config['output']['lint']>, 'auto' | false>\n\n// Pinned here, not in `@internals/utils` (which must not import `@kubb/core`): a tool added to the union without a descriptor fails to compile.\nformatters satisfies Record<FormatterName, unknown>\nlinters satisfies Record<LinterName, unknown>\n\ntype GenerateProps = {\n input?: string\n config: Config\n hooks: Hookable<KubbHooks>\n /**\n * When `true`, generates in memory instead of writing to disk, skips formatting, linting, and\n * post-generate commands, and prints what would change on disk.\n */\n dryRun?: boolean\n}\n\nexport async function generate(options: GenerateProps): Promise<boolean> {\n const { input, hooks, dryRun = false } = options\n\n const report = trackRun({ command: 'generate', hrStart: process.hrtime() })\n\n const config: Config = {\n ...options.config,\n input: input ?? options.config.input,\n // Dry-run never touches disk, regardless of the config's own storage driver.\n storage: dryRun ? memoryStorage() : options.config.storage,\n // Also keeps core's `hasOutputPasses` false, so dry-run skips the output manifest write too.\n output: dryRun ? { ...options.config.output, format: false, lint: false, postGenerate: [] } : options.config.output,\n }\n\n // Core formats, lints and runs `output.postGenerate` after an error-free build, and reports\n // their failures as coded diagnostics that reach the summary, the json report and the exit code.\n const kubb = createKubb(config, { hooks })\n const result = await kubb.generate()\n\n // Not awaited: the request finishes in the background, capped by its timeout, so it never delays the summary.\n void report({\n // A setup that threw leaves no driver, so read the configured plugins instead.\n plugins: kubb.config.plugins.flatMap((p) =>\n p && typeof p === 'object' ? [{ name: p.meta?.name ?? p.name ?? '', options: (p.options ?? {}) as Record<string, unknown> }] : [],\n ),\n filesCreated: result.files.length,\n status: result.success ? 'success' : 'failed',\n })\n\n return result.success\n}\n\ntype GenerateCommandOptions = {\n input?: string\n configPath?: string\n logLevel: string\n watch: boolean\n reporters?: Array<ReporterName>\n dryRun?: boolean\n}\n\n/** The latest published version, `undefined` when the registry does not answer in time or `signal` aborts. Never rejects. */\nasync function fetchLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n try {\n const res = await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.any([signal, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)]) })\n const data = (await res.json()) as { version: string }\n return data.version\n } catch {\n // Ignore network errors\n return undefined\n }\n}\n\nasync function checkForUpdate({ hooks, latestVersion }: { hooks: Hookable<KubbHooks>; latestVersion: string | undefined }): Promise<void> {\n if (latestVersion && isOutdated({ installed: version, latest: latestVersion })) {\n await Diagnostics.emit(hooks, Diagnostics.update({ currentVersion: version, latestVersion }))\n }\n}\n\n/** Prints `Rebuilt in 1.2s · +1 schema -2 operations`, without the names part when the spec kept the same names. */\nfunction logRebuild({ diff: { schemas, operations }, durationMs }: { diff: BuildDiff; durationMs: number }): void {\n const specChange = [\n schemas.added && styleText('green', `+${pluralize(schemas.added, 'schema')}`),\n schemas.removed && styleText('red', `-${pluralize(schemas.removed, 'schema')}`),\n operations.added && styleText('green', `+${pluralize(operations.added, 'operation')}`),\n operations.removed && styleText('red', `-${pluralize(operations.removed, 'operation')}`),\n ]\n .filter(Boolean)\n .join(' ')\n logStep([`Rebuilt in ${formatMs(durationMs)}`, specChange].filter(Boolean).join(styleText('dim', ' · ')))\n}\n\n/**\n * Runs the full Kubb generation lifecycle for the given CLI options.\n * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),\n * calls `generate` for each config entry, and prints an update notice when the registry answered in time.\n */\nexport async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, dryRun }: GenerateCommandOptions): Promise<void> {\n // Started first and never awaited: the notice prints at the end only when the registry has answered by then.\n const updateCheck = new AbortController()\n let latestVersion: string | undefined\n void fetchLatestVersion(updateCheck.signal).then((value) => {\n latestVersion = value\n })\n const logLevel = logLevelMap[logLevelKey as keyof typeof logLevelMap] ?? logLevelMap.info\n const hooks = new Hookable<KubbHooks>()\n\n // CLI `--reporter` selects which reporters to trigger by name, defaulting to `cli`. `defineConfig`\n // registers the built-in reporters on the config; a config exported without it falls back to them below.\n const requestedNames: Array<ReporterName> = cliReporters?.length ? cliReporters : ['cli']\n\n // The `json` reporter owns stdout, so the command writes nothing of its own around it.\n const json = requestedNames.includes('json')\n const quiet = logLevel <= logLevelMap.silent || json\n\n // Errors raised outside a build have no report entry. In `json` mode they go to a stderr logger,\n // so they are never silent and stdout stays one JSON document.\n const errorHooks = json ? new Hookable<KubbHooks>() : hooks\n if (json) setupReporters(errorHooks, { logLevel, reporters: [cliReporter], writer: createPlainWriter(console.error) })\n\n // The config loads while the banner plays; the output still prints in order once the banner is done.\n const banner = quiet ? undefined : logBanner(version)\n const loading = getConfigs({\n configPath,\n input,\n watch,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n })\n // Handled below; this keeps a rejection during the banner from counting as unhandled.\n loading.catch(() => undefined)\n await banner\n\n if (!quiet) {\n logIntro({ title: 'Configuration' })\n }\n\n // Load the config first so `config.reporters` can pick the reporters. A failure here has no\n // reporter installed yet, so fall back to the default `cli` reporter to surface it.\n const configSpinner = createSpinner()\n let configs: Array<Config>\n let resolvedConfigPath: string\n try {\n if (!quiet) configSpinner.start('Loading config')\n\n const loaded = await loading\n configs = loaded.configs\n resolvedConfigPath = loaded.configPath\n\n if (!quiet) configSpinner.stop(`Loaded ${styleText('dim', path.relative(process.cwd(), resolvedConfigPath))}`)\n } catch (error) {\n if (!quiet) configSpinner.error('Config failed loading')\n\n if (!json) setupReporters(hooks, { logLevel, reporters: [cliReporter] })\n // A diagnostic thrown while the config file runs, such as invalid extension options, sits in the cause chain.\n await Diagnostics.emit(errorHooks, error)\n\n if (!quiet) logOutro(styleText('red', '✗ Configuration failed'))\n process.exit(1)\n }\n\n // Without a reporter nothing is printed, not even an error, so a config written without\n // `defineConfig` gets the same built-ins it would have registered.\n const available = configs[0]?.reporters?.length ? configs[0].reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter]\n const reporters = selectReporters(available, requestedNames)\n setupReporters(hooks, { logLevel, reporters, dryRun })\n\n await hooks.callHook('kubb:lifecycle:start', { version })\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n let anyFailed = false\n // One tracker, one key listener and one build queue serve every watched config, so several configs never mix diffs or answer `r` twice.\n const tracker = watch ? trackBuild(hooks) : undefined\n const rebuilds: Array<() => Promise<void>> = []\n let armKeys: (() => void) | undefined\n // Configs share the hooks emitter, so every build, from any watcher or the `r` key, waits for the one before it.\n let queue = Promise.resolve()\n for (const config of configs) {\n const effectiveInput = input ?? config.input\n const inputKind = typeof effectiveInput === 'string' ? getInputKind(effectiveInput) : undefined\n const watchPath = inputKind === 'file' ? (effectiveInput as string) : undefined\n if (watchPath && tracker) {\n const label = styleText('yellow', `Watching ${path.relative(process.cwd(), watchPath)}`)\n let previous: BuildSnapshot | undefined\n // Don't removeAll() between builds, that would also drop logger and lifecycle\n // listeners. Plugin listeners are already disposed by safeBuild's dispose()\n // in its finally block, so re-running generate() on the same hooks emitter is safe.\n const build = async () => {\n const hrStart = process.hrtime()\n const succeeded = await generate({ input, config, hooks, dryRun })\n const snapshot = tracker.take()\n if (previous) logRebuild({ diff: diffBuilds(previous, snapshot), durationMs: getElapsedMs(hrStart) })\n previous = snapshot\n\n logStep(armKeys ? `${label} ${styleText('dim', 'r rebuild · q quit')}` : label)\n armKeys?.()\n if (succeeded) {\n logSpacer()\n logTip()\n }\n }\n // A trigger that lands while this config's build is queued joins it; one that lands during the build queues one more. Never rejects.\n let pending = false\n const rebuild = (): Promise<void> => {\n if (pending) return queue\n pending = true\n queue = queue\n .then(() => {\n pending = false\n return build()\n })\n .catch((error) => void Diagnostics.emit(errorHooks, error))\n return queue\n }\n rebuilds.push(rebuild)\n if (!quiet) {\n armKeys ??= listenForKeys({\n rebuild: () => rebuilds.forEach((trigger) => void trigger()),\n quit: (code) => void Promise.resolve(hooks.callHook('kubb:lifecycle:end')).finally(() => process.exit(code)),\n })\n }\n\n // The watcher ignores its startup state, so run the first build here; a failing one keeps watching so the user can fix the input.\n await rebuild()\n\n await startWatcher([watchPath], rebuild, { info: logInfo, error: logError })\n } else {\n if (tracker && !quiet) logWarn('Watch mode only follows a local `input` file, so this config is generated once.')\n try {\n const succeeded = await generate({ input, config, hooks, dryRun })\n if (!succeeded) anyFailed = true\n } catch (configError) {\n await Diagnostics.emit(errorHooks, configError)\n anyFailed = true\n }\n }\n }\n\n // A request still in flight would keep the process alive until its timeout.\n updateCheck.abort()\n await checkForUpdate({ hooks, latestVersion })\n\n await hooks.callHook('kubb:lifecycle:end')\n\n // Watch mode prints a tip after each successful build. Regular generate commands need to\n // print one explicitly after the lifecycle group has closed so it stays outside the group.\n if (!quiet && !watch && !anyFailed) {\n logTip()\n }\n\n // `exitCode`, not `exit()`, so a telemetry request still in flight can finish within its timeout.\n if (anyFailed) {\n process.exitCode = 1\n }\n } catch (error) {\n await Diagnostics.emit(errorHooks, error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,uBAAuB;;AAG7B,MAAM,0BAA0B;AAqBhC,eAAsB,SAAS,SAA0C;CACvE,MAAM,EAAE,OAAO,OAAO,SAAS,UAAU;CAEzC,MAAM,SAASA,kBAAAA,SAAS;EAAE,SAAS;EAAY,SAASC,aAAAA,QAAQ,OAAO;CAAE,CAAC;CAE1E,MAAM,SAAiB;EACrB,GAAG,QAAQ;EACX,OAAO,SAAS,QAAQ,OAAO;EAE/B,SAAS,UAAA,GAASC,WAAAA,cAAAA,CAAc,IAAI,QAAQ,OAAO;EAEnD,QAAQ,SAAS;GAAE,GAAG,QAAQ,OAAO;GAAQ,QAAQ;GAAO,MAAM;GAAO,cAAc,CAAC;EAAE,IAAI,QAAQ,OAAO;CAC/G;CAIA,MAAM,QAAA,GAAOC,WAAAA,WAAAA,CAAW,QAAQ,EAAE,MAAM,CAAC;CACzC,MAAM,SAAS,MAAM,KAAK,SAAS;CAGnC,OAAY;EAEV,SAAS,KAAK,OAAO,QAAQ,SAAS,MACpC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