@kubb/cli 5.14.6 → 5.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/bin/kubb.js +2 -1
  2. package/dist/{Telemetry-B5V_ufmv.cjs → Telemetry-B52pKz9i.cjs} +14 -118
  3. package/dist/Telemetry-B52pKz9i.cjs.map +1 -0
  4. package/dist/{Telemetry-DrnGartf.js → Telemetry-C7Qwy2s7.js} +12 -86
  5. package/dist/Telemetry-C7Qwy2s7.js.map +1 -0
  6. package/dist/{background-DlK0by5c.js → background-BJCuXYuB.js} +5 -6
  7. package/dist/{background-DlK0by5c.js.map → background-BJCuXYuB.js.map} +1 -1
  8. package/dist/{background-CdPT1eaq.cjs → background-CK2gQtTU.cjs} +5 -6
  9. package/dist/{background-CdPT1eaq.cjs.map → background-CK2gQtTU.cjs.map} +1 -1
  10. package/dist/{background-C6XHpEo7.js → background-D4mZCg-4.js} +1 -1
  11. package/dist/banner-BdTTDFkG.js +140 -0
  12. package/dist/banner-BdTTDFkG.js.map +1 -0
  13. package/dist/banner-wJFk-L-c.cjs +163 -0
  14. package/dist/banner-wJFk-L-c.cjs.map +1 -0
  15. package/dist/config-BL3HnFhb.js +1 -0
  16. package/dist/config-BWj9jBVj.cjs +62 -0
  17. package/dist/config-BWj9jBVj.cjs.map +1 -0
  18. package/dist/{config-CNqgDSu3.js → config-CQTxXvIG.js} +6 -52
  19. package/dist/config-CQTxXvIG.js.map +1 -0
  20. package/dist/{config-BG_Nr2CZ.cjs → config-CRrmj88c.cjs} +15 -62
  21. package/dist/config-CRrmj88c.cjs.map +1 -0
  22. package/dist/config-Uk3rbZfb.js +49 -0
  23. package/dist/config-Uk3rbZfb.js.map +1 -0
  24. package/dist/configFile-C0DIXNMD.js +993 -0
  25. package/dist/configFile-C0DIXNMD.js.map +1 -0
  26. package/dist/configFile-CoEpHdXG.cjs +1028 -0
  27. package/dist/configFile-CoEpHdXG.cjs.map +1 -0
  28. package/dist/{credentials-C8tjAhTo.js → credentials-B77iJx9H.js} +1 -1
  29. package/dist/{credentials-DDaKqtJn.cjs → credentials-DEsGwcGD.cjs} +3 -4
  30. package/dist/{credentials-DDaKqtJn.cjs.map → credentials-DEsGwcGD.cjs.map} +1 -1
  31. package/dist/{credentials-CZK6zPLv.js → credentials-osgjujE_.js} +3 -4
  32. package/dist/{credentials-CZK6zPLv.js.map → credentials-osgjujE_.js.map} +1 -1
  33. package/dist/env-C3xHRMez.js +1 -0
  34. package/dist/env-eu3XyKqJ.cjs +55 -0
  35. package/dist/env-eu3XyKqJ.cjs.map +1 -0
  36. package/dist/env-rv-VgSGN.js +34 -0
  37. package/dist/env-rv-VgSGN.js.map +1 -0
  38. package/dist/{errors-Cl69p_vI.cjs → errors-BponpdjN.cjs} +3 -4
  39. package/dist/{errors-Cl69p_vI.cjs.map → errors-BponpdjN.cjs.map} +1 -1
  40. package/dist/{errors-DmC83ALX.js → errors-wzqmMpMo.js} +3 -4
  41. package/dist/{errors-DmC83ALX.js.map → errors-wzqmMpMo.js.map} +1 -1
  42. package/dist/index.cjs +37 -2719
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.cts +0 -2
  45. package/dist/index.d.ts +0 -2
  46. package/dist/index.js +35 -2713
  47. package/dist/index.js.map +1 -1
  48. package/dist/installWithSpinner-DpnpxHq5.js +49 -0
  49. package/dist/installWithSpinner-DpnpxHq5.js.map +1 -0
  50. package/dist/installWithSpinner-ONGfIVUJ.cjs +56 -0
  51. package/dist/installWithSpinner-ONGfIVUJ.cjs.map +1 -0
  52. package/dist/{text-CL6N6yPS.js → intro-9PB8sE8z.js} +8 -52
  53. package/dist/intro-9PB8sE8z.js.map +1 -0
  54. package/dist/{text-DrsG1EDN.cjs → intro-YPaf1Imr.cjs} +12 -80
  55. package/dist/intro-YPaf1Imr.cjs.map +1 -0
  56. package/dist/isCIEnvironment-D6xtAAZ2.js +14 -0
  57. package/dist/isCIEnvironment-D6xtAAZ2.js.map +1 -0
  58. package/dist/isCIEnvironment-DiVOMI5Q.cjs +20 -0
  59. package/dist/isCIEnvironment-DiVOMI5Q.cjs.map +1 -0
  60. package/dist/mascot--q1xjKw1.js +63 -0
  61. package/dist/mascot--q1xjKw1.js.map +1 -0
  62. package/dist/mascot-JSA0j3Q_.cjs +80 -0
  63. package/dist/mascot-JSA0j3Q_.cjs.map +1 -0
  64. package/dist/mcp-CcseJJwh.cjs +20 -0
  65. package/dist/mcp-CcseJJwh.cjs.map +1 -0
  66. package/dist/mcp-DUTsS8tR.js +21 -0
  67. package/dist/mcp-DUTsS8tR.js.map +1 -0
  68. package/dist/package-B1hUUjio.cjs +10 -0
  69. package/dist/package-B1hUUjio.cjs.map +1 -0
  70. package/dist/package-MYPMnnTX.js +5 -0
  71. package/dist/package-MYPMnnTX.js.map +1 -0
  72. package/dist/{registry-DOGpflct.js → registry-B3eYk4LN.js} +7 -67
  73. package/dist/registry-B3eYk4LN.js.map +1 -0
  74. package/dist/{registry-BzBp6aZI.cjs → registry-YE1pFWL-.cjs} +4 -82
  75. package/dist/registry-YE1pFWL-.cjs.map +1 -0
  76. package/dist/{reporters-GzXlc4CK.cjs → reporters-2cgjvXwR.cjs} +32 -40
  77. package/dist/{reporters-GzXlc4CK.cjs.map → reporters-2cgjvXwR.cjs.map} +1 -1
  78. package/dist/{reporters-mYHIUZSx.js → reporters-BM430HdQ.js} +19 -27
  79. package/dist/{reporters-mYHIUZSx.js.map → reporters-BM430HdQ.js.map} +1 -1
  80. package/dist/{rolldown-runtime-CPE0t6oh.cjs → rolldown-runtime-C3-Zg-KD.cjs} +1 -2
  81. package/dist/{rolldown-runtime-CRm0XQPb.js → rolldown-runtime-xo6NMXYd.js} +1 -2
  82. package/dist/run-1H9TGT8v.js +77 -0
  83. package/dist/run-1H9TGT8v.js.map +1 -0
  84. package/dist/run-BYP_t9dR.cjs +324 -0
  85. package/dist/run-BYP_t9dR.cjs.map +1 -0
  86. package/dist/run-Bq6gcfkS.js +1 -0
  87. package/dist/run-BrM7-NSV.js +181 -0
  88. package/dist/run-BrM7-NSV.js.map +1 -0
  89. package/dist/run-BsrNfFIl.js +228 -0
  90. package/dist/run-BsrNfFIl.js.map +1 -0
  91. package/dist/{run-l8IiOR_c.js → run-CLiHI99L.js} +9 -9
  92. package/dist/{run-l8IiOR_c.js.map → run-CLiHI99L.js.map} +1 -1
  93. package/dist/{run-C8Prej7s.cjs → run-CQORv7Gq.cjs} +44 -37
  94. package/dist/run-CQORv7Gq.cjs.map +1 -0
  95. package/dist/{run-EJtgdIin.js → run-CXVhxFfC.js} +31 -23
  96. package/dist/run-CXVhxFfC.js.map +1 -0
  97. package/dist/run-CrM4jsix.cjs +80 -0
  98. package/dist/run-CrM4jsix.cjs.map +1 -0
  99. package/dist/run-CvFakE3B.cjs +185 -0
  100. package/dist/run-CvFakE3B.cjs.map +1 -0
  101. package/dist/{run-DC_xH5H3.cjs → run-CyzKy-0p.cjs} +49 -41
  102. package/dist/run-CyzKy-0p.cjs.map +1 -0
  103. package/dist/run-D-nn9-Wq.js +319 -0
  104. package/dist/run-D-nn9-Wq.js.map +1 -0
  105. package/dist/run-DBnSbwtU.cjs +389 -0
  106. package/dist/run-DBnSbwtU.cjs.map +1 -0
  107. package/dist/{run-j1g5si5R.js → run-DTqMrPS9.js} +5 -6
  108. package/dist/{run-j1g5si5R.js.map → run-DTqMrPS9.js.map} +1 -1
  109. package/dist/{run-9fs2T2Je.js → run-DUwX6Icx.js} +26 -20
  110. package/dist/run-DUwX6Icx.js.map +1 -0
  111. package/dist/run-FEiyv6_U.js +385 -0
  112. package/dist/run-FEiyv6_U.js.map +1 -0
  113. package/dist/run-LY_UAYyM.cjs +233 -0
  114. package/dist/run-LY_UAYyM.cjs.map +1 -0
  115. package/dist/{run-sjzj0ir-.cjs → run-dMTJfs4_.cjs} +10 -10
  116. package/dist/{run-sjzj0ir-.cjs.map → run-dMTJfs4_.cjs.map} +1 -1
  117. package/dist/{run-CypFtkVE.cjs → run-uPA5s3rI.cjs} +5 -6
  118. package/dist/{run-CypFtkVE.cjs.map → run-uPA5s3rI.cjs.map} +1 -1
  119. package/dist/shared-C0EtrdUm.cjs +123 -0
  120. package/dist/shared-C0EtrdUm.cjs.map +1 -0
  121. package/dist/shared-Ct9stKpp.js +94 -0
  122. package/dist/shared-Ct9stKpp.js.map +1 -0
  123. package/dist/{snapshot-laSRD0z1.cjs → snapshot-CPF9zyZj.cjs} +13 -14
  124. package/dist/{snapshot-laSRD0z1.cjs.map → snapshot-CPF9zyZj.cjs.map} +1 -1
  125. package/dist/{snapshot-BJWnL6hE.js → snapshot-CiV08NJr.js} +10 -11
  126. package/dist/{snapshot-BJWnL6hE.js.map → snapshot-CiV08NJr.js.map} +1 -1
  127. package/dist/spinner-BZaln7O8.js +160 -0
  128. package/dist/spinner-BZaln7O8.js.map +1 -0
  129. package/dist/spinner-CfB0sIPy.cjs +208 -0
  130. package/dist/spinner-CfB0sIPy.cjs.map +1 -0
  131. package/dist/{status-DFEdbBPu.cjs → status-C066YA-4.cjs} +7 -8
  132. package/dist/{status-DFEdbBPu.cjs.map → status-C066YA-4.cjs.map} +1 -1
  133. package/dist/{status-BjmXLRm2.js → status-Dj8tivag.js} +6 -7
  134. package/dist/{status-BjmXLRm2.js.map → status-Dj8tivag.js.map} +1 -1
  135. package/dist/studio-B4XsXgKj.js +215 -0
  136. package/dist/studio-B4XsXgKj.js.map +1 -0
  137. package/dist/studio-D9_-mKee.cjs +218 -0
  138. package/dist/studio-D9_-mKee.cjs.map +1 -0
  139. package/dist/studioWorker.js +4 -5
  140. package/dist/{summary-DDnI70tn.js → summary-CbmQKA8l.js} +5 -6
  141. package/dist/{summary-DDnI70tn.js.map → summary-CbmQKA8l.js.map} +1 -1
  142. package/dist/{summary-1DCwzWEU.cjs → summary-Clvl5Hxs.cjs} +7 -8
  143. package/dist/{summary-1DCwzWEU.cjs.map → summary-Clvl5Hxs.cjs.map} +1 -1
  144. package/dist/table-BlRe9YTZ.cjs +15 -0
  145. package/dist/table-BlRe9YTZ.cjs.map +1 -0
  146. package/dist/table-CR7iZJGo.js +10 -0
  147. package/dist/table-CR7iZJGo.js.map +1 -0
  148. package/dist/text-BmiI4s6N.js +13 -0
  149. package/dist/text-BmiI4s6N.js.map +1 -0
  150. package/dist/text-Ep3AulAS.cjs +24 -0
  151. package/dist/text-Ep3AulAS.cjs.map +1 -0
  152. package/dist/time-3BKoci3G.cjs +82 -0
  153. package/dist/time-3BKoci3G.cjs.map +1 -0
  154. package/dist/time-C-wU7VhC.js +65 -0
  155. package/dist/time-C-wU7VhC.js.map +1 -0
  156. package/dist/utils-BdibacYq.js +244 -0
  157. package/dist/utils-BdibacYq.js.map +1 -0
  158. package/dist/utils-CO89mxRU.cjs +290 -0
  159. package/dist/utils-CO89mxRU.cjs.map +1 -0
  160. package/dist/utils-CbJ6hS_t.js +222 -0
  161. package/dist/utils-CbJ6hS_t.js.map +1 -0
  162. package/dist/utils-CcARPB45.cjs +286 -0
  163. package/dist/utils-CcARPB45.cjs.map +1 -0
  164. package/dist/validate-B3tLWYJU.cjs +27 -0
  165. package/dist/validate-B3tLWYJU.cjs.map +1 -0
  166. package/dist/validate-C5fyNF4v.js +28 -0
  167. package/dist/validate-C5fyNF4v.js.map +1 -0
  168. package/package.json +7 -7
  169. package/dist/Telemetry-B5V_ufmv.cjs.map +0 -1
  170. package/dist/Telemetry-DrnGartf.js.map +0 -1
  171. package/dist/config-BG_Nr2CZ.cjs.map +0 -1
  172. package/dist/config-CNqgDSu3.js.map +0 -1
  173. package/dist/config-DWDpFSn1.js +0 -1
  174. package/dist/registry-BzBp6aZI.cjs.map +0 -1
  175. package/dist/registry-DOGpflct.js.map +0 -1
  176. package/dist/run-9fs2T2Je.js.map +0 -1
  177. package/dist/run-C8Prej7s.cjs.map +0 -1
  178. package/dist/run-CXVme-aS.js +0 -1
  179. package/dist/run-DC_xH5H3.cjs.map +0 -1
  180. package/dist/run-EJtgdIin.js.map +0 -1
  181. package/dist/text-CL6N6yPS.js.map +0 -1
  182. package/dist/text-DrsG1EDN.cjs.map +0 -1
  183. package/dist/utils-C3vTpUje.cjs +0 -645
  184. package/dist/utils-C3vTpUje.cjs.map +0 -1
  185. package/dist/utils-CIc8YFtr.js +0 -536
  186. package/dist/utils-CIc8YFtr.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-CQORv7Gq.cjs","names":["process","isCIEnvironment","x","isCIEnvironment","process","createSpinner","pairAgent","path","process","hostname","getMachineId","styleText","isRichOutput","writeCredentials","getCredentialsPath","PairingCanceledError","AgentPermission","toPermissionFlag","KUBB_CONFIG_FILENAME","isCIEnvironment","canUseTTY","prompts","getConfigs","Diagnostics","readCredentials","Hookable","logLevelMap","cliReporter","plainWriter","connectAgent","InvalidAgentTokenError","clearCredentials","defaultStudioUrl","trackRun","toError"],"sources":["../../../internals/utils/src/copyToClipboard.ts","../../../internals/utils/src/openInBrowser.ts","../src/runners/studio/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { x } from 'tinyexec'\nimport { isCIEnvironment } from './isCIEnvironment.ts'\n\nconst COMMANDS: Partial<Record<NodeJS.Platform, [string, ...Array<string>]>> = {\n darwin: ['pbcopy'],\n win32: ['clip.exe'],\n linux: ['xclip', '-selection', 'clipboard'],\n}\n\n/**\n * Copies text to the system clipboard with the platform's own tool. Resolves `false` in CI, on a\n * platform without a known tool, or when the tool is missing or fails.\n */\nexport async function copyToClipboard(text: string): Promise<boolean> {\n // Wayland sessions have no X selection for xclip to serve, so they use `wl-copy`.\n const command = process.platform === 'linux' && process.env.WAYLAND_DISPLAY ? (['wl-copy'] as const) : COMMANDS[process.platform]\n if (!command || isCIEnvironment()) return false\n\n const [name, ...args] = command\n // stdout and stderr are ignored: xclip and wl-copy stay alive to serve the selection and would hold open pipes until the timeout.\n const run = x(name, args, { timeout: 2_000, nodeOptions: { stdio: ['pipe', 'ignore', 'ignore'] } })\n // A missing tool closes stdin before the write lands; the rejection below reports it.\n run.process?.stdin?.once('error', () => {})\n run.process?.stdin?.end(text)\n\n return run.then(\n ({ exitCode }) => exitCode === 0,\n () => false,\n )\n}\n","import process from 'node:process'\nimport { x } from 'tinyexec'\nimport { isCIEnvironment } from './isCIEnvironment.ts'\n\nconst ignore = () => {}\n\n/**\n * Opens a URL or local file in the default browser, unless running in CI.\n */\nexport function openInBrowser(target: string): void {\n if (isCIEnvironment()) return\n\n if (process.platform === 'win32') {\n x('cmd', ['/c', 'start', '', target]).then(ignore, ignore)\n return\n }\n x(process.platform === 'darwin' ? 'open' : 'xdg-open', [target]).then(ignore, ignore)\n}\n","import { hostname } from 'node:os'\nimport { toPermissionFlag } from '../../ui/text.ts'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as prompts from '@clack/prompts'\nimport { KUBB_CONFIG_FILENAME } from '@internals/shared'\nimport { copyToClipboard, isCIEnvironment, openInBrowser, toError } from '@internals/utils'\nimport type { CLIOptions, Config } from '@kubb/core'\nimport { cliReporter, Diagnostics, Hookable, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'\nimport { connectAgent, defaultStudioUrl, InvalidAgentTokenError, pairAgent, PairingCanceledError } from '@kubb/studio'\nimport { AgentPermission } from '@kubb/studio/protocol'\nimport { trackRun } from '../../Telemetry.ts'\nimport { plainWriter } from '../../loggers/plainWriter.ts'\nimport setupReporters from '../../loggers/reporters.ts'\nimport { logIntro, logOutro, logTip } from '../../ui/intro.ts'\nimport { logBlock, logStep } from '../../ui/log.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { canUseTTY, isRichOutput } from '../../utils/env.ts'\nimport { getConfigs } from '../../config.ts'\nimport { clearCredentials, type Credentials, getCredentialsPath, getMachineId, readCredentials, writeCredentials } from './credentials.ts'\nimport { version } from '../../../package.json'\n\nexport type StudioOptions = {\n /**\n * Current `@kubb/cli` version, reported to Studio and used for the telemetry payload.\n */\n version: string\n configPath?: string\n /**\n * Base URL of the Studio instance, for a self-hosted deployment. Resolved before it reaches here,\n * since stored credentials are bound to it.\n */\n studioUrl: string\n /**\n * What Studio may do in this project. Each flag grants outright; the rest are asked once per\n * project through {@link resolvePermissions}.\n */\n permission: Record<AgentPermission, boolean>\n /**\n * Whether to open the approval page in a browser during pairing.\n */\n autoOpen: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\nexport type SnapshotOptions = Pick<StudioOptions, 'configPath' | 'studioUrl' | 'logLevel'> & {\n /**\n * Organization CI API key. Falls back to `KUBB_TOKEN`.\n */\n token?: string\n /**\n * Stable identity for the CI agent. Falls back to CI auto-detection.\n */\n id?: string\n /** Identity of another CI agent to also compare with. Falls back to CI auto-detection. */\n baseId?: string\n /**\n * Package name for the generated tarball. Falls back to the nearest package.json.\n */\n name?: string\n /**\n * Package version for the generated tarball. Falls back to the nearest package.json.\n */\n packageVersion?: string\n /**\n * Print the result as one JSON object instead of a summary.\n */\n json?: boolean\n}\n\n/** The flags a `kubb studio` subcommand parsed; each one is optional since a subcommand declares only the flags it uses. */\nexport type StudioValues = {\n config?: string\n url?: string\n allowRead?: boolean\n allowReadAst?: boolean\n allowWrite?: boolean\n allowConfigEdit?: boolean\n allowInstall?: boolean\n allowUpdate?: boolean\n allowRemove?: boolean\n allowSaveInput?: boolean\n allowExec?: boolean\n open?: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\ntype LoginOptions = {\n /**\n * Aborting this cancels an in-flight pairing request or poll and rejects with\n * {@link PairingCanceledError}. Wired to `kubb studio`'s shutdown signal, so Ctrl+C during\n * pairing cancels it instead of leaving the poll running.\n */\n signal?: AbortSignal\n /**\n * Credentials from before this login. When the fresh pairing resolves to the same agent on the\n * same Studio, its saved project permissions carry forward instead of being asked again.\n * Left out for an explicitly requested `kubb studio login`, which always starts clean.\n */\n previousCredentials?: Credentials | null\n}\n\n/**\n * Pairs this machine with Studio and stores the resulting token.\n *\n * The CLI holds a code and the browser approves it, rather than the user copying a token out of\n * the UI. The token comes back over the CLI's own HTTPS POST, so it never lands in a URL, a\n * server log, or a `Referer` header.\n */\nexport async function login({ studioUrl, autoOpen }: StudioOptions, { signal, previousCredentials }: LoginOptions = {}): Promise<Credentials> {\n const spinner = createSpinner()\n // A retry notice stays on screen a while before the countdown takes the line back.\n let retryUntil = 0\n // The spinner only starts once a code is shown.\n let waiting = false\n let countdown: NodeJS.Timeout | undefined\n\n try {\n const { token, agent } = await pairAgent({\n studioUrl,\n type: 'cli',\n name: path.basename(process.cwd()),\n hostname: hostname(),\n machineId: await getMachineId(),\n signal,\n onCode: (session) => {\n logStep(\n [\n 'Pair this machine',\n `${styleText('dim', 'Open')} ${styleText('cyan', session.verification_uri)}`,\n `${styleText('dim', 'Code')} ${styleText('bold', session.user_code)}`,\n ].join('\\n'),\n )\n\n if (autoOpen) {\n openInBrowser(session.verification_uri_complete)\n }\n\n // Same fallback as the poll in `@kubb/studio`, so the countdown ends when polling does.\n const deadline = Date.now() + (session.expires_in > 0 ? session.expires_in : 600) * 1000\n let copied = false\n const waitingText = () =>\n `Waiting for approval ${styleText('dim', `expires in ${formatCountdown(deadline - Date.now())}${copied ? ' · code copied' : ''} · ctrl+c to cancel`)}`\n clearInterval(countdown)\n spinner.start(waitingText())\n waiting = true\n // Plain output prints every message, so only an animated spinner ticks.\n if (isRichOutput()) countdown = setInterval(() => Date.now() > retryUntil && spinner.message(waitingText()), 1000)\n // Not awaited: the code shows at once, and the spinner picks up the copy when it lands.\n void copyToClipboard(session.user_code).then((done) => {\n copied = done\n })\n },\n onRetry: (error) => {\n retryUntil = Date.now() + 5000\n spinner.message(`Could not reach Kubb Studio, retrying: ${error.message}`)\n },\n })\n clearInterval(countdown)\n spinner.stop(`Paired as ${agent.name}${agent.organizationSlug ? ` · org ${agent.organizationSlug}` : ''}`)\n\n const keepsIdentity = previousCredentials?.studioUrl === studioUrl && previousCredentials.agentId === agent.id\n const credentials: Credentials = {\n studioUrl,\n token,\n agentId: agent.id,\n agentSlug: agent.slug,\n ...(agent.organizationSlug ? { organizationSlug: agent.organizationSlug } : {}),\n ...(keepsIdentity && previousCredentials?.projects ? { projects: previousCredentials.projects } : {}),\n }\n await writeCredentials(credentials)\n\n console.log(`Credentials stored in ${getCredentialsPath()}`)\n\n return credentials\n } catch (error) {\n clearInterval(countdown)\n if (waiting) {\n spinner.stop(error instanceof PairingCanceledError ? 'Pairing canceled' : 'Pairing failed')\n }\n throw error\n }\n}\n\n/** Time left on a pairing code as `m:ss`, never below `0:00`. */\nexport function formatCountdown(ms: number): string {\n const seconds = Math.max(0, Math.ceil(ms / 1000))\n\n return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`\n}\n\n/**\n * What each permission is asked as, in the order the list shows them.\n */\nconst PERMISSIONS: ReadonlyArray<{\n key: AgentPermission\n /**\n * Short label for status output and the connect summary.\n */\n label: string\n title: (configPath: string) => string\n hint: string\n}> = [\n { key: AgentPermission.READ, label: 'read source', title: () => 'Read generated files', hint: 'show code in the browser' },\n { key: AgentPermission.READ_AST, label: 'read spec', title: () => 'Read the parsed spec', hint: 'browse schemas and operations' },\n { key: AgentPermission.WRITE, label: 'write files', title: () => 'Write files to disk', hint: 'generate from the browser' },\n { key: AgentPermission.CONFIG_EDIT, label: 'edit config', title: (configPath) => `Change ${configPath}`, hint: 'edit plugin options' },\n { key: AgentPermission.INSTALL, label: 'add plugins', title: () => 'Install extensions from the registry', hint: 'kubb add from the browser' },\n { key: AgentPermission.UPDATE, label: 'update plugins', title: () => 'Update installed extensions', hint: 'kubb update from the browser' },\n { key: AgentPermission.REMOVE, label: 'remove plugins', title: () => 'Remove extensions', hint: 'kubb remove from the browser' },\n {\n key: AgentPermission.SAVE_INPUT,\n label: 'save input',\n title: (configPath) => `Save the spec from Studio as the input in ${configPath}`,\n hint: 'keep a pasted spec, URL, or git file',\n },\n { key: AgentPermission.EXEC, label: 'run tools', title: () => 'Run the formatter, linter, and postGenerate', hint: 'after each generation' },\n]\n\n/**\n * Two permissions per row, each marked granted or not, with the flags that grant the missing ones\n * after the last row. For `kubb studio status`.\n */\nexport function formatPermissionRows(granted: Partial<Record<AgentPermission, boolean>>): Array<string> {\n const width = Math.max(...PERMISSIONS.map(({ label }) => label.length))\n const cells = PERMISSIONS.map(({ key, label }) => `${granted[key] ? styleText('green', '✓') : styleText('red', '✖')} ${label.padEnd(width)}`)\n const rows = Array.from({ length: Math.ceil(cells.length / 2) }, (_, index) => cells.slice(index * 2, index * 2 + 2).join(' '))\n const flags = PERMISSIONS.filter(({ key }) => !granted[key])\n .map(({ key }) => toPermissionFlag(key))\n .join(' ')\n\n return flags ? [...rows.slice(0, -1), `${rows.at(-1)} ${styleText('dim', flags)}`] : rows\n}\n\n/**\n * Resolves Studio permissions for the current project.\n * Flags win, saved answers are reused, and the rest are asked in one list whose answers are stored\n * in `~/.kubb/credentials.json`.\n */\nexport async function resolvePermissions(\n options: StudioOptions,\n credentials: Credentials,\n configPath: string = KUBB_CONFIG_FILENAME,\n { edit = false }: { edit?: boolean } = {},\n): Promise<Record<AgentPermission, boolean>> {\n const project = process.cwd()\n const remembered = credentials.projects?.[project]\n const granted = Object.fromEntries(PERMISSIONS.map(({ key }) => [key, options.permission[key] || remembered?.[key] === true])) as Record<\n AgentPermission,\n boolean\n >\n // `edit` asks again for every permission no flag grants, with the saved ones checked.\n const pending = PERMISSIONS.filter(({ key }) => !options.permission[key] && (edit || typeof remembered?.[key] !== 'boolean'))\n\n if (!pending.length || isCIEnvironment() || !canUseTTY()) return granted\n\n prompts.updateSettings({ withGuide: true })\n const selected = await prompts.multiselect({\n message: 'What may Kubb Studio do in this project?',\n options: pending.map(({ key, title, hint }) => ({ value: key, label: title(configPath), hint })),\n ...(edit ? { initialValues: pending.filter(({ key }) => remembered?.[key] === true).map(({ key }) => key) } : {}),\n required: false,\n })\n // A canceled list grants nothing and saves nothing, so the next run asks again.\n if (prompts.isCancel(selected)) {\n if (edit) throw new Error('Canceled. Permissions are unchanged.')\n return granted\n }\n\n const answers = Object.fromEntries(pending.map(({ key }) => [key, selected.includes(key)]))\n await writeCredentials({\n ...credentials,\n projects: { ...credentials.projects, [project]: { ...remembered, ...answers } },\n })\n\n return { ...granted, ...answers }\n}\n\n/**\n * Loads the project's Kubb config the same way `kubb generate` does, one entry per `defineConfig(...)` entry.\n */\nexport async function loadConfigs(options: Pick<StudioOptions, 'configPath' | 'logLevel'>): Promise<{ configPath: string; configs: Array<Config> }> {\n const { configPath, configs } = await getConfigs({ configPath: options.configPath, logLevel: options.logLevel })\n\n if (!configs.length) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'Config not defined, create a kubb.config.ts or pass it with --config',\n })\n }\n\n // `getConfigs` resolves this to an absolute path. Relativized here, once, so the permission\n // prompt and the path Studio receives over the wire both show the project-relative form instead\n // of leaking the local filesystem layout.\n return { configPath: path.relative(process.cwd(), configPath) || configPath, configs }\n}\n\nexport type PreparedConnection = {\n configPath: string\n credentials: Credentials\n permissions: StudioOptions['permission']\n}\n\n/** Validates the project and resolves pairing and permissions before starting its worker. */\nexport async function prepareConnection(options: StudioOptions, signal?: AbortSignal): Promise<PreparedConnection> {\n const { configPath } = await loadConfigs(options)\n const stored = await readCredentials()\n const credentials = await (async () => {\n if (stored?.studioUrl === options.studioUrl) return stored\n if (isCIEnvironment()) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `Not paired with ${options.studioUrl}. In CI, run \\`kubb studio snapshot\\` instead, or run \\`kubb studio login\\` on a machine with a browser.`,\n })\n }\n return login(options, { signal })\n })()\n const permissions = await resolvePermissions(options, credentials, configPath)\n return { configPath, credentials, permissions }\n}\n\nexport type WorkerState = 'starting' | 'connected' | 'reconnecting' | 'authentication required' | 'stopped'\n\n/** Runs the same project connection in the foreground or in a background worker. */\nexport async function connect(\n options: StudioOptions,\n context: {\n prepared?: PreparedConnection\n signal?: AbortSignal\n onState?: (state: WorkerState) => void | Promise<void>\n } = {},\n): Promise<void> {\n const shutdown = new AbortController()\n const signal = context.signal ?? shutdown.signal\n const stop = () => shutdown.abort()\n const events = process as unknown as NodeJS.EventEmitter\n if (!context.signal) {\n events.once('SIGINT', stop)\n events.once('SIGTERM', stop)\n }\n let unwatch: (() => void) | undefined\n try {\n if (!context.prepared) {\n const { getWorkerStatus } = await import('./background.ts')\n const worker = await getWorkerStatus()\n if (worker.running)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'This project is running in the background. Run `kubb studio stop` first.',\n })\n }\n const prepared = context.prepared ?? (await prepareConnection(options, signal))\n let { credentials, permissions } = prepared\n const { configPath } = prepared\n let hinted = false\n // Set by a fresh pairing until it connects, so a token rejected right after approval fails the run instead of looping.\n let pairedAgain = false\n\n // The background worker writes to a log file, so it gets the plain logger rather than the\n // animated one. The logger also covers the `studio:*` events and each generation run.\n const hooks = new Hookable<KubbHooks>()\n setupReporters(hooks, {\n logLevel: logLevelMap[options.logLevel ?? 'info'],\n reporters: [cliReporter],\n ...(context.onState ? { writer: plainWriter } : {}),\n })\n // `b` hands the session to the background worker; only a foreground run in a terminal listens.\n const listens = !context.onState && process.stdin.isTTY === true && canUseTTY()\n let background = false\n hooks.hook('studio:connected', async () => {\n pairedAgain = false\n await context.onState?.('connected')\n if (listens && !unwatch) {\n unwatch = watchKeys({\n onBackground: () => {\n background = true\n stop()\n },\n onStop: stop,\n })\n }\n if (hinted || context.onState || options.logLevel === 'silent') return\n hinted = true\n logBlock([\n `${styleText('dim', 'Project')} ${path.basename(process.cwd())} ${styleText(\n 'dim',\n PERMISSIONS.filter(({ key }) => permissions[key])\n .map(({ label }) => label)\n .join(' · ') || 'no permissions',\n )}`,\n styleText('dim', listens ? 'Press b to keep running in the background, Ctrl+C to disconnect' : 'Press Ctrl+C to disconnect'),\n ])\n logTip()\n })\n hooks.hook('studio:reconnecting', () => context.onState?.('reconnecting'))\n\n for (;;) {\n try {\n await connectAgent({\n token: credentials.token,\n studioUrl: options.studioUrl,\n configPath,\n version: options.version,\n root: process.cwd(),\n permissions,\n loadConfigs: async () => (await loadConfigs(options)).configs,\n hooks,\n signal,\n })\n break\n } catch (error) {\n if (!(error instanceof InvalidAgentTokenError)) throw error\n await context.onState?.('authentication required')\n await clearCredentials()\n if (pairedAgain) throw new Error(`${error.message} Studio rejected the newly approved token too. Run \\`kubb studio login\\` and try again.`)\n if (context.onState || isCIEnvironment() || !canUseTTY()) throw new Error(`${error.message} Run \\`kubb studio login\\` to pair again.`)\n\n // The pairing prompts need stdin back.\n unwatch?.()\n unwatch = undefined\n console.log(styleText('yellow', `${error.message} Pairing again...`))\n credentials = await login(options, { signal, previousCredentials: credentials })\n pairedAgain = true\n permissions = await resolvePermissions(options, credentials, configPath)\n }\n }\n // Stops the \"Ready for jobs\" spinner, which would otherwise keep drawing under the closing line.\n await hooks.callHook('kubb:lifecycle:end')\n unwatch?.()\n if (background) {\n const { startWorker } = await import('./background.ts')\n await startWorker(options)\n if (options.logLevel !== 'silent') logOutro('Running in the background · kubb studio stop')\n return\n }\n if (!context.onState && signal.aborted && options.logLevel !== 'silent') logOutro('Disconnected')\n } catch (error) {\n if (!(error instanceof PairingCanceledError)) throw error\n } finally {\n unwatch?.()\n events.off('SIGINT', stop)\n events.off('SIGTERM', stop)\n }\n}\n\n/**\n * Listens for single keys on a TTY stdin. Raw mode turns Ctrl+C into a key instead of SIGINT, so it\n * is handled here too. Returns the function that restores the terminal, safe to call twice.\n */\nexport function watchKeys({ onBackground, onStop }: { onBackground: () => void; onStop: () => void }): () => void {\n const stdin = process.stdin\n const onData = (data: Buffer) => {\n const key = data.toString()\n if (key === 'b' || key === 'B') onBackground()\n if (key === '\\u0003') onStop()\n }\n // A clack spinner reads stdin too and exits the process on Ctrl+C, before the session can close\n // its socket, so its Ctrl+C alias is lifted while these keys are read.\n const cancelAlias = prompts.settings.aliases.get('\\u0003')\n prompts.settings.aliases.delete('\\u0003')\n stdin.setRawMode(true)\n stdin.on('data', onData)\n stdin.resume()\n let restored = false\n\n return () => {\n if (restored) return\n restored = true\n if (cancelAlias) prompts.settings.aliases.set('\\u0003', cancelAlias)\n stdin.off('data', onData)\n stdin.setRawMode(false)\n stdin.pause()\n }\n}\n\n/**\n * Runs a Studio command from its parsed flags: builds the {@link StudioOptions}, prints the intro,\n * and reports the run to telemetry. A failure is printed and sets the exit code instead of throwing.\n */\nexport async function runStudio(\n values: StudioValues,\n action: (options: StudioOptions) => Promise<unknown>,\n { block = false, json = false }: { block?: boolean; json?: boolean } = {},\n): Promise<void> {\n const options: StudioOptions = {\n version,\n configPath: values.config,\n studioUrl: values.url ?? defaultStudioUrl,\n permission: Object.fromEntries(Object.values(AgentPermission).map((key) => [key, values[key] ?? false])) as Record<AgentPermission, boolean>,\n autoOpen: values.open ?? true,\n logLevel: values.logLevel,\n }\n const report = trackRun({ command: 'studio', hrStart: process.hrtime() })\n\n try {\n if (options.logLevel !== 'silent' && !json) {\n logIntro({\n warning: styleText('yellow', 'This feature is still under development, use with caution'),\n block,\n })\n }\n\n await action(options)\n\n await report({ status: 'success' })\n } catch (error) {\n await report({ status: 'failed' })\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,WAAyE;CAC7E,QAAQ,CAAC,QAAQ;CACjB,OAAO,CAAC,UAAU;CAClB,OAAO;EAAC;EAAS;EAAc;CAAW;AAC5C;;;;;AAMA,eAAsB,gBAAgB,MAAgC;CAEpE,MAAM,UAAUA,aAAAA,QAAQ,aAAa,WAAWA,aAAAA,QAAQ,IAAI,kBAAmB,CAAC,SAAS,IAAc,SAASA,aAAAA,QAAQ;CACxH,IAAI,CAAC,WAAWC,wBAAAA,gBAAgB,GAAG,OAAO;CAE1C,MAAM,CAAC,MAAM,GAAG,QAAQ;CAExB,MAAM,OAAA,GAAMC,SAAAA,EAAAA,CAAE,MAAM,MAAM;EAAE,SAAS;EAAO,aAAa,EAAE,OAAO;GAAC;GAAQ;GAAU;EAAQ,EAAE;CAAE,CAAC;CAElG,IAAI,SAAS,OAAO,KAAK,eA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AAO,UAA+C,CAAC,GACzD;CACf,MAAM,UAAyB;EAC7B,SAAA,gBAAA;EACA,YAAY,OAAO;EACnB,WAAW,OAAO,OAAOW,aAAAA;EACzB,YAAY,OAAO,YAAY,OAAO,OAAOhB,sBAAAA,eAAe,CAAC,CAAC,KAAK,QAAQ,CAAC,KAAK,OAAO,QAAQ,KAAK,CAAC,CAAC;EACvG,UAAU,OAAO,QAAQ;EACzB,UAAU,OAAO;CACnB;CACA,MAAM,SAASiB,kBAAAA,SAAS;EAAE,SAAS;EAAU,SAASzB,aAAAA,QAAQ,OAAO;CAAE,CAAC;CAExE,IAAI;EACF,IAAI,QAAQ,aAAa,YAAY,CAAC,MACpC,cAAA,SAAS;GACP,UAAA,GAASG,UAAAA,UAAAA,CAAU,UAAU,2DAA2D;GACxF;EACF,CAAC;EAGH,MAAM,OAAO,OAAO;EAEpB,MAAM,OAAO,EAAE,QAAQ,UAAU,CAAC;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,QAAQ,MAAMuB,eAAAA,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,aAAA,QAAA,WAAmB;CACrB;AACF"}
@@ -1,15 +1,20 @@
1
- import "./rolldown-runtime-CRm0XQPb.js";
2
- import { a as getElapsedMs, i as formatMs, n as trackRun, r as version } from "./Telemetry-DrnGartf.js";
3
- import { c as createSpinner, i as listenForKeys, o as startWatcher, s as trackBuild, t as diffBuilds } from "./utils-CIc8YFtr.js";
4
- import { a as logOutro, d as logStep, f as logWarn, i as logIntro, l as logError, m as createPlainWriter, o as logSpacer, s as logTip, t as pluralize, u as logInfo } from "./text-CL6N6yPS.js";
5
- import { d as logBanner, o as isOutdated } from "./registry-DOGpflct.js";
6
- import { t as getConfigs } from "./config-CNqgDSu3.js";
7
- import { n as setupReporters, t as selectReporters } from "./reporters-mYHIUZSx.js";
1
+ import "./rolldown-runtime-xo6NMXYd.js";
2
+ import { n as getElapsedMs, t as formatMs } from "./time-C-wU7VhC.js";
3
+ import { t as createSpinner } from "./spinner-BZaln7O8.js";
4
+ import { i as listenForKeys, o as startWatcher, s as trackBuild, t as diffBuilds } from "./utils-BdibacYq.js";
5
+ import { t as version } from "./package-MYPMnnTX.js";
6
+ import { n as trackRun } from "./Telemetry-C7Qwy2s7.js";
7
+ import { a as logTip, c as logInfo, f as createPlainWriter, i as logSpacer, l as logStep, n as logIntro, r as logOutro, s as logError, u as logWarn } from "./intro-9PB8sE8z.js";
8
+ import { n as logBanner } from "./mascot--q1xjKw1.js";
9
+ import { t as pluralize } from "./text-BmiI4s6N.js";
10
+ import { n as setupReporters, t as selectReporters } from "./reporters-BM430HdQ.js";
11
+ import { t as getConfigs } from "./config-Uk3rbZfb.js";
12
+ import { o as isOutdated } from "./registry-B3eYk4LN.js";
8
13
  import { styleText } from "node:util";
9
14
  import process from "node:process";
10
15
  import path from "node:path";
11
16
  import { Diagnostics, Hookable, cliReporter, createKubb, fileReporter, getInputKind, htmlReporter, jsonReporter, logLevel, memoryStorage } from "@kubb/core";
12
- //#region src/runners/generate/run.ts
17
+ // src/runners/generate/run.ts
13
18
  /** NPM registry endpoint used to check for @kubb/cli updates. */
14
19
  const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
15
20
  /** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */
@@ -33,7 +38,7 @@ async function generate(options) {
33
38
  };
34
39
  const kubb = createKubb(config, { hooks });
35
40
  const result = await kubb.generate();
36
- await report({
41
+ report({
37
42
  plugins: kubb.config.plugins.flatMap((p) => p && typeof p === "object" ? [{
38
43
  name: p.meta?.name ?? p.name ?? "",
39
44
  options: p.options ?? {}
@@ -43,16 +48,15 @@ async function generate(options) {
43
48
  });
44
49
  return result.success;
45
50
  }
46
- /** The latest published version, `undefined` when the registry does not answer in time. Never rejects. */
47
- async function fetchLatestVersion() {
51
+ /** The latest published version, `undefined` when the registry does not answer in time or `signal` aborts. Never rejects. */
52
+ async function fetchLatestVersion(signal) {
48
53
  try {
49
- return (await (await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS) })).json()).version;
54
+ return (await (await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.any([signal, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)]) })).json()).version;
50
55
  } catch {
51
56
  return;
52
57
  }
53
58
  }
54
- async function checkForUpdate({ hooks, latest }) {
55
- const latestVersion = await latest;
59
+ async function checkForUpdate({ hooks, latestVersion }) {
56
60
  if (latestVersion && isOutdated({
57
61
  installed: version,
58
62
  latest: latestVersion
@@ -74,10 +78,14 @@ function logRebuild({ diff: { schemas, operations }, durationMs }) {
74
78
  /**
75
79
  * Runs the full Kubb generation lifecycle for the given CLI options.
76
80
  * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),
77
- * checks for a newer version, and calls `generate` for each config entry.
81
+ * calls `generate` for each config entry, and prints an update notice when the registry answered in time.
78
82
  */
79
83
  async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, dryRun }) {
80
- const latest = fetchLatestVersion();
84
+ const updateCheck = new AbortController();
85
+ let latestVersion;
86
+ fetchLatestVersion(updateCheck.signal).then((value) => {
87
+ latestVersion = value;
88
+ });
81
89
  const logLevel$1 = logLevel[logLevelKey] ?? logLevel.info;
82
90
  const hooks = new Hookable();
83
91
  const requestedNames = cliReporters?.length ? cliReporters : ["cli"];
@@ -131,10 +139,6 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
131
139
  dryRun
132
140
  });
133
141
  await hooks.callHook("kubb:lifecycle:start", { version });
134
- await checkForUpdate({
135
- hooks,
136
- latest
137
- });
138
142
  if (!quiet) logOutro(`${pluralize(configs.length, "config")} ready`);
139
143
  try {
140
144
  let anyFailed = false;
@@ -204,15 +208,19 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
204
208
  }
205
209
  }
206
210
  }
211
+ updateCheck.abort();
212
+ await checkForUpdate({
213
+ hooks,
214
+ latestVersion
215
+ });
207
216
  await hooks.callHook("kubb:lifecycle:end");
208
217
  if (!quiet && !watch && !anyFailed) logTip();
209
- if (anyFailed) process.exit(1);
218
+ if (anyFailed) process.exitCode = 1;
210
219
  } catch (error) {
211
220
  await Diagnostics.emit(errorHooks, error);
212
221
  process.exit(1);
213
222
  }
214
223
  }
215
- //#endregion
216
224
  export { generate, run };
217
225
 
218
- //# sourceMappingURL=run-EJtgdIin.js.map
226
+ //# sourceMappingURL=run-CXVhxFfC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-CXVhxFfC.js","names":["logLevel","logLevelMap"],"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,SAAS,SAAS;EAAE,SAAS;EAAY,SAAS,QAAQ,OAAO;CAAE,CAAC;CAE1E,MAAM,SAAiB;EACrB,GAAG,QAAQ;EACX,OAAO,SAAS,QAAQ,OAAO;EAE/B,SAAS,SAAS,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,OAAO,WAAW,QAAQ,EAAE,MAAM,CAAC;CACzC,MAAM,SAAS,MAAM,KAAK,SAAS;CAGnC,OAAY;EAEV,SAAS,KAAK,OAAO,Q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nC,IAAI,SAAS,OAAO;KACpB,UAAU;KACV,QAAQ,MACL,WAAW;MACV,UAAU;MACV,OAAO,MAAM;KACf,CAAC,CAAC,CACD,OAAO,UAAU,KAAK,YAAY,KAAK,YAAY,KAAK,CAAC;KAC5D,OAAO;IACT;IACA,SAAS,KAAK,OAAO;IACrB,IAAI,CAAC,OACH,YAAY,cAAc;KACxB,eAAe,SAAS,SAAS,YAAY,KAAK,QAAQ,CAAC;KAC3D,OAAO,SAAS,KAAK,QAAQ,QAAQ,MAAM,SAAS,oBAAoB,CAAC,CAAC,CAAC,cAAc,QAAQ,KAAK,IAAI,CAAC;IAC7G,CAAC;IAIH,MAAM,QAAQ;IAEd,MAAM,aAAa,CAAC,SAAS,GAAG,SAAS;KAAE,MAAM;KAAS,OAAO;IAAS,CAAC;GAC7E,OAAO;IACL,IAAI,WAAW,CAAC,OAAO,QAAQ,iFAAiF;IAChH,IAAI;KAEF,IAAI,CAAC,MADmB,SAAS;MAAE;MAAO;MAAQ;MAAO;KAAO,CAAC,GACjD,YAAY;IAC9B,SAAS,aAAa;KACpB,MAAM,YAAY,KAAK,YAAY,WAAW;KAC9C,YAAY;IACd;GACF;EACF;EAGA,YAAY,MAAM;EAClB,MAAM,eAAe;GAAE;GAAO;EAAc,CAAC;EAE7C,MAAM,MAAM,SAAS,oBAAoB;EAIzC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,WACvB,OAAO;EAIT,IAAI,WACF,QAAQ,WAAW;CAEvB,SAAS,OAAO;EACd,MAAM,YAAY,KAAK,YAAY,KAAK;EACxC,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -0,0 +1,80 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
2
+ const require_errors = require("./errors-BponpdjN.cjs");
3
+ const require_intro = require("./intro-YPaf1Imr.cjs");
4
+ const require_registry = require("./registry-YE1pFWL-.cjs");
5
+ const require_table = require("./table-BlRe9YTZ.cjs");
6
+ let node_util = require("node:util");
7
+ let gunshi = require("gunshi");
8
+ let node_process = require("node:process");
9
+ node_process = require_rolldown_runtime.__toESM(node_process, 1);
10
+ let _kubb_core = require("@kubb/core");
11
+ // src/runners/list/run.ts
12
+ /**
13
+ * The installed packages that ship a `kubb-extension.json` or have a registry entry, with the
14
+ * version the registry pins.
15
+ */
16
+ async function listExtensions({ cwd, registry }) {
17
+ const [installed, entries] = await Promise.all([(0, _kubb_core.readInstalledPackages)({ root: cwd }), require_registry.fetchRegistryIndex({ registry }).catch((error) => {
18
+ require_intro.logWarn(`Showing installed extensions only: ${require_errors.getErrorMessage(error)}`);
19
+ return [];
20
+ })]);
21
+ const byPackage = new Map(entries.map((entry) => [entry.artifact.package, entry]));
22
+ return installed.flatMap(({ package: name, version, manifest }) => {
23
+ const entry = byPackage.get(name);
24
+ if (!entry && !manifest) return [];
25
+ const latest = entry?.artifact.version;
26
+ return [{
27
+ id: entry?.id,
28
+ package: name,
29
+ installed: version,
30
+ registry: latest,
31
+ update: !!latest && require_registry.isOutdated({
32
+ installed: version,
33
+ latest
34
+ })
35
+ }];
36
+ });
37
+ }
38
+ /** Prints the installed extensions as a table. */
39
+ async function run() {
40
+ try {
41
+ const rows = await listExtensions({
42
+ cwd: node_process.default.cwd(),
43
+ registry: require_registry.registryUrl()
44
+ });
45
+ if (!rows.length) {
46
+ require_intro.logOutro("No installed extensions found.");
47
+ return;
48
+ }
49
+ const header = [
50
+ "ID",
51
+ "PACKAGE",
52
+ "INSTALLED",
53
+ "REGISTRY",
54
+ "UPDATE"
55
+ ];
56
+ const cells = rows.map((row) => [
57
+ row.id ?? "-",
58
+ row.package,
59
+ row.installed ?? "-",
60
+ row.registry ?? "-",
61
+ row.update ? "yes" : "no"
62
+ ]);
63
+ const [head, ...body] = require_table.formatTable([header, ...cells]);
64
+ require_intro.logBlock([(0, node_util.styleText)("dim", head), ...body]);
65
+ } catch (error) {
66
+ require_intro.logError(require_errors.getErrorMessage(error));
67
+ node_process.default.exitCode = 1;
68
+ }
69
+ }
70
+ const command = (0, gunshi.define)({
71
+ name: "list",
72
+ description: "List installed extensions, their versions, and available updates.",
73
+ examples: "kubb list",
74
+ run: () => run()
75
+ });
76
+ exports.command = command;
77
+ exports.listExtensions = listExtensions;
78
+ exports.run = run;
79
+
80
+ //# sourceMappingURL=run-CrM4jsix.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-CrM4jsix.cjs","names":["readInstalledPackages","fetchRegistryIndex","getErrorMessage","isOutdated","process","registryUrl","formatTable","styleText","define"],"sources":["../src/runners/list/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { define } from 'gunshi'\nimport { readInstalledPackages, type RegistryEntry } from '@kubb/core'\nimport { logOutro } from '../../ui/intro.ts'\nimport { logBlock, logError, logWarn } from '../../ui/log.ts'\nimport { formatTable } from '../../ui/table.ts'\nimport { fetchRegistryIndex, isOutdated, registryUrl } from '../../utils/registry.ts'\n\nexport type ListRow = {\n id?: string\n package: string\n installed?: string\n registry?: string\n update: boolean\n}\n\n/**\n * The installed packages that ship a `kubb-extension.json` or have a registry entry, with the\n * version the registry pins.\n */\nexport async function listExtensions({ cwd, registry }: { cwd: string; registry: string }): Promise<Array<ListRow>> {\n const [installed, entries] = await Promise.all([\n readInstalledPackages({ root: cwd }),\n fetchRegistryIndex({ registry }).catch((error: unknown): Array<RegistryEntry> => {\n logWarn(`Showing installed extensions only: ${getErrorMessage(error)}`)\n return []\n }),\n ])\n const byPackage = new Map(entries.map((entry) => [entry.artifact.package, entry]))\n\n return installed.flatMap(({ package: name, version, manifest }): Array<ListRow> => {\n const entry = byPackage.get(name)\n if (!entry && !manifest) return []\n const latest = entry?.artifact.version\n return [{ id: entry?.id, package: name, installed: version, registry: latest, update: !!latest && isOutdated({ installed: version, latest }) }]\n })\n}\n\n/** Prints the installed extensions as a table. */\nexport async function run(): Promise<void> {\n try {\n const rows = await listExtensions({ cwd: process.cwd(), registry: registryUrl() })\n if (!rows.length) {\n logOutro('No installed extensions found.')\n return\n }\n\n const header = ['ID', 'PACKAGE', 'INSTALLED', 'REGISTRY', 'UPDATE']\n const cells = rows.map((row) => [row.id ?? '-', row.package, row.installed ?? '-', row.registry ?? '-', row.update ? 'yes' : 'no'])\n const [head, ...body] = formatTable([header, ...cells])\n logBlock([styleText('dim', head!), ...body])\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n\nexport const command = define({\n name: 'list',\n description: 'List installed extensions, their versions, and available updates.',\n examples: 'kubb list',\n run: () => run(),\n})\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,eAAsB,eAAe,EAAE,KAAK,YAAwE;CAClH,MAAM,CAAC,WAAW,WAAW,MAAM,QAAQ,IAAI,EAAA,GAC7CA,WAAAA,sBAAAA,CAAsB,EAAE,MAAM,IAAI,CAAC,GACnCC,iBAAAA,mBAAmB,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,UAAyC;EAC/E,cAAA,QAAQ,sCAAsCC,eAAAA,gBAAgB,KAAK,GAAG;EACtE,OAAO,CAAC;CACV,CAAC,CACH,CAAC;CACD,MAAM,YAAY,IAAI,IAAI,QAAQ,KAAK,UAAU,CAAC,MAAM,SAAS,SAAS,KAAK,CAAC,CAAC;CAEjF,OAAO,UAAU,SAAS,EAAE,SAAS,MAAM,SAAS,eAA+B;EACjF,MAAM,QAAQ,UAAU,IAAI,IAAI;EAChC,IAAI,CAAC,SAAS,CAAC,UAAU,OAAO,CAAC;EACjC,MAAM,SAAS,OAAO,SAAS;EAC/B,OAAO,CAAC;GAAE,IAAI,OAAO;GAAI,SAAS;GAAM,WAAW;GAAS,UAAU;GAAQ,QAAQ,CAAC,CAAC,UAAUC,iBAAAA,WAAW;IAAE,WAAW;IAAS;GAAO,CAAC;EAAE,CAAC;CAChJ,CAAC;AACH;;AAGA,eAAsB,MAAqB;CACzC,IAAI;EACF,MAAM,OAAO,MAAM,eAAe;GAAE,KAAKC,aAAAA,QAAQ,IAAI;GAAG,UAAUC,iBAAAA,YAAY;EAAE,CAAC;EACjF,IAAI,CAAC,KAAK,QAAQ;GAChB,cAAA,SAAS,gCAAgC;GACzC;EACF;EAEA,MAAM,SAAS;GAAC;GAAM;GAAW;GAAa;GAAY;EAAQ;EAClE,MAAM,QAAQ,KAAK,KAAK,QAAQ;GAAC,IAAI,MAAM;GAAK,IAAI;GAAS,IAAI,aAAa;GAAK,IAAI,YAAY;GAAK,IAAI,SAAS,QAAQ;EAAI,CAAC;EAClI,MAAM,CAAC,MAAM,GAAG,QAAQC,cAAAA,YAAY,CAAC,QAAQ,GAAG,KAAK,CAAC;EACtD,cAAA,SAAS,EAAA,GAACC,UAAAA,UAAAA,CAAU,OAAO,IAAK,GAAG,GAAG,IAAI,CAAC;CAC7C,SAAS,OAAO;EACd,cAAA,SAASL,eAAAA,gBAAgB,KAAK,CAAC;EAC/B,aAAA,QAAA,WAAmB;CACrB;AACF;AAEA,MAAa,WAAA,GAAUM,OAAAA,OAAAA,CAAO;CAC5B,MAAM;CACN,aAAa;CACb,UAAU;CACV,WAAW,IAAI;AACjB,CAAC"}
@@ -0,0 +1,185 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
2
+ const require_configFile = require("./configFile-CoEpHdXG.cjs");
3
+ const require_errors = require("./errors-BponpdjN.cjs");
4
+ const require_spinner = require("./spinner-CfB0sIPy.cjs");
5
+ const require_intro = require("./intro-YPaf1Imr.cjs");
6
+ const require_shared = require("./shared-C0EtrdUm.cjs");
7
+ const require_config = require("./config-CRrmj88c.cjs");
8
+ const require_summary = require("./summary-Clvl5Hxs.cjs");
9
+ const require_registry = require("./registry-YE1pFWL-.cjs");
10
+ const require_utils = require("./utils-CO89mxRU.cjs");
11
+ let node_util = require("node:util");
12
+ let gunshi = require("gunshi");
13
+ let node_process = require("node:process");
14
+ node_process = require_rolldown_runtime.__toESM(node_process, 1);
15
+ let node_path = require("node:path");
16
+ node_path = require_rolldown_runtime.__toESM(node_path, 1);
17
+ let _clack_prompts = require("@clack/prompts");
18
+ _clack_prompts = require_rolldown_runtime.__toESM(_clack_prompts, 1);
19
+ let _kubb_core = require("@kubb/core");
20
+ // src/runners/remove/run.ts
21
+ /** The lines of `before` that `after` no longer has, trimmed. */
22
+ function removedLines({ before, after }) {
23
+ const remaining = after.split("\n");
24
+ return before.split("\n").filter((line) => {
25
+ const index = remaining.indexOf(line);
26
+ if (index !== -1) remaining.splice(index, 1);
27
+ return index === -1 && line.trim() !== "";
28
+ }).map((line) => line.trim());
29
+ }
30
+ /**
31
+ * Removes a plugin or parser from `kubb.config.ts` and uninstalls its package. Refuses the adapter,
32
+ * which the config needs, and an extension another one in the config depends on. Previews the
33
+ * change before asking.
34
+ */
35
+ async function run({ id: input, configPath, yes, uninstall }) {
36
+ const cwd = node_process.default.cwd();
37
+ const hrStart = node_process.default.hrtime();
38
+ const summary = (title, status, lines) => require_summary.logCommandSummary({
39
+ title,
40
+ status,
41
+ hrStart,
42
+ block: true,
43
+ lines
44
+ });
45
+ const fail = (title, lines) => {
46
+ summary(title, "failed", lines);
47
+ node_process.default.exitCode = 1;
48
+ };
49
+ require_intro.logIntro({ title: require_intro.isInteractiveRun({ yes }) ? void 0 : (0, node_util.styleText)("bgCyan", (0, node_util.styleText)("black", " Kubb Remove ")) });
50
+ try {
51
+ const id = require_registry.toRegistryId(input);
52
+ const configFile = configPath ? node_path.default.resolve(configPath) : require_config.findConfigFile(cwd);
53
+ if (!configFile) throw new _kubb_core.Diagnostics.Error({
54
+ code: _kubb_core.Diagnostics.code.unknown,
55
+ severity: "error",
56
+ message: "No kubb.config.ts found. Pass its path with --config.",
57
+ help: "Run `kubb remove <id> --config <path>`."
58
+ });
59
+ const configName = node_path.default.relative(cwd, configFile) || configFile;
60
+ const [entries, installed, source] = await require_spinner.withSpinner({
61
+ message: "Reading the registry",
62
+ promise: Promise.all([
63
+ require_registry.fetchRegistryIndex({ registry: require_registry.registryUrl() }),
64
+ (0, _kubb_core.readInstalledPackages)({ root: cwd }),
65
+ require_spinner.read(configFile)
66
+ ])
67
+ });
68
+ const versions = new Map(installed.map((item) => [item.package, item.version]));
69
+ const entry = entries.find((candidate) => candidate.id === id);
70
+ if (!entry) {
71
+ const suggestions = require_registry.closestIds({
72
+ input: id,
73
+ ids: entries.map((candidate) => candidate.id)
74
+ }).map(require_registry.toShortId);
75
+ return fail(`No extension named ${input}`, suggestions.map((suggestion) => ` kubb remove ${suggestion}`));
76
+ }
77
+ const { artifact, manifest } = entry;
78
+ const kind = manifest.kind.charAt(0).toUpperCase() + manifest.kind.slice(1);
79
+ if (manifest.kind === require_configFile.extensionKinds.adapter) return fail("The adapter cannot be removed", [` A config needs one adapter. Change it in ${configName} by hand.`]);
80
+ const view = require_configFile.readConfig(source);
81
+ const running = new Set(view.managed ? view.configs.flatMap((config) => [...config.plugins, ...config.parsers ?? []].filter((call) => !call.disabled).map((call) => call.packageName)) : []);
82
+ const dependents = entries.filter((other) => other.id !== entry.id && other.manifest.dependencies?.includes(manifest.name) && running.has(other.artifact.package));
83
+ if (dependents.length) {
84
+ const names = dependents.map((other) => other.manifest.name).join(", ");
85
+ return fail(`${names} ${dependents.length === 1 ? "needs" : "need"} ${manifest.name}`, [` Remove ${names} first.`]);
86
+ }
87
+ const edits = [{
88
+ operation: require_configFile.ConfigEditOperation.REMOVE_EXTENSION,
89
+ ...manifest.kind === require_configFile.extensionKinds.parser ? { kind: require_configFile.extensionKinds.parser } : {},
90
+ plugin: artifact.package
91
+ }];
92
+ const preview = require_configFile.editConfig({
93
+ source,
94
+ edits
95
+ });
96
+ const outcome = preview.outcomes[0];
97
+ if (!outcome?.applied) return fail(`Could not edit ${configName}`, [` ${outcome?.reason ?? "the config file was not changed"}`]);
98
+ const bundled = require_config.BUNDLED_PACKAGES.includes(artifact.package);
99
+ const stillImported = require_configFile.readImports(preview.source).includes(artifact.package);
100
+ const uninstalls = uninstall && !bundled && !stillImported && versions.has(artifact.package);
101
+ if (!preview.changed && !uninstalls) {
102
+ summary(`${manifest.name} is not in the project`, "success", [" No changes made"]);
103
+ return;
104
+ }
105
+ const packageLine = (() => {
106
+ if (uninstalls) return `Uninstalls ${artifact.package}`;
107
+ if (bundled) return `Keeps ${artifact.package}, which ships with kubb`;
108
+ if (stillImported) return `Keeps ${artifact.package}, which another config entry still imports`;
109
+ return "Uninstalls nothing";
110
+ })();
111
+ require_intro.logStep(`${kind} ${(0, node_util.styleText)("cyan", manifest.name)} v${versions.get(artifact.package) ?? artifact.version}`);
112
+ require_intro.logBlock([
113
+ `Config ${configName}`,
114
+ ...removedLines({
115
+ before: source,
116
+ after: preview.source
117
+ }).map((line) => (0, node_util.styleText)("red", ` - ${line}`)),
118
+ packageLine
119
+ ]);
120
+ const confirmed = yes || await _clack_prompts.confirm({
121
+ message: "Remove it?",
122
+ initialValue: true
123
+ });
124
+ if (_clack_prompts.isCancel(confirmed) || !confirmed) {
125
+ summary("Remove canceled", "canceled", [` ${kind} ${manifest.name}`, " No changes made"]);
126
+ return;
127
+ }
128
+ if (preview.changed) {
129
+ const written = await require_configFile.editConfigFile({
130
+ filePath: configFile,
131
+ edits
132
+ });
133
+ if (!written.outcomes[0]?.applied) return fail(`Could not edit ${configName}`, [` ${written.outcomes[0]?.reason ?? "the config file was not changed"}`]);
134
+ require_intro.logStep(`${manifest.export}() removed from ${configName}`);
135
+ }
136
+ const packageManager = require_utils.detectPackageManager(cwd);
137
+ if (uninstalls) await require_spinner.withSpinner({
138
+ message: `Uninstalling ${artifact.package} with ${packageManager.name}`,
139
+ promise: require_utils.uninstallPackages([artifact.package], packageManager, cwd)
140
+ });
141
+ summary(`${kind} removed`, "success", [
142
+ ` Packages ${uninstalls ? `${artifact.package} uninstalled with ${packageManager.name}` : "none uninstalled"}`,
143
+ "",
144
+ "Next kubb generate"
145
+ ]);
146
+ } catch (error) {
147
+ require_intro.logError(require_errors.getErrorMessage(error));
148
+ fail("Remove failed", [" See the error above"]);
149
+ }
150
+ }
151
+ const command = (0, gunshi.define)({
152
+ name: "remove",
153
+ description: "Remove a plugin or parser from kubb.config.ts and uninstall its package.",
154
+ examples: [
155
+ "kubb remove plugin-zod",
156
+ "kubb remove acme/plugin-x --yes",
157
+ "kubb remove plugin-zod --no-uninstall"
158
+ ].join("\n"),
159
+ toKebab: true,
160
+ args: {
161
+ id: {
162
+ type: "positional",
163
+ description: "Registry id: owner/slug, or a slug for an official extension",
164
+ required: true
165
+ },
166
+ ...require_shared.configArg,
167
+ ...require_shared.yesArg,
168
+ uninstall: {
169
+ type: "boolean",
170
+ description: "Uninstall the package. Pass --no-uninstall to only edit the config",
171
+ negatable: true,
172
+ default: true
173
+ }
174
+ },
175
+ run: ({ values }) => run({
176
+ id: values.id,
177
+ configPath: values.config,
178
+ yes: values.yes,
179
+ uninstall: values.uninstall
180
+ })
181
+ });
182
+ exports.command = command;
183
+ exports.run = run;
184
+
185
+ //# sourceMappingURL=run-CvFakE3B.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-CvFakE3B.cjs","names":["process","logCommandSummary","isInteractiveRun","styleText","toRegistryId","path","findConfigFile","Diagnostics","withSpinner","fetchRegistryIndex","registryUrl","readInstalledPackages","read","closestIds","toShortId","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, 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 { logCommandSummary } 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 = (title: string, status: Parameters<typeof logCommandSummary>[0]['status'], lines: ReadonlyArray<string>) =>\n logCommandSummary({ title, status, hrStart, block: true, lines })\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 = manifest.kind.charAt(0).toUpperCase() + manifest.kind.slice(1)\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 = 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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