@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.
- package/dist/{Telemetry-CZJ2Noi6.cjs → Telemetry-CBzCK4kO.cjs} +5 -5
- package/dist/{Telemetry-CZJ2Noi6.cjs.map → Telemetry-CBzCK4kO.cjs.map} +1 -1
- package/dist/{Telemetry-DQG_EpcV.js → Telemetry-DUl_hxVn.js} +5 -5
- package/dist/{Telemetry-DQG_EpcV.js.map → Telemetry-DUl_hxVn.js.map} +1 -1
- package/dist/{background-Z23KW1yA.js → background-CA9lRKAK.js} +4 -4
- package/dist/{background-Z23KW1yA.js.map → background-CA9lRKAK.js.map} +1 -1
- package/dist/{background-Dsy12RvL.js → background-DK3HLyNk.js} +1 -1
- package/dist/{background-DIVc60mm.cjs → background-fhpYDuSs.cjs} +4 -4
- package/dist/{background-DIVc60mm.cjs.map → background-fhpYDuSs.cjs.map} +1 -1
- package/dist/{banner-BdTTDFkG.js → banner-BMIxunVW.js} +3 -3
- package/dist/{banner-BdTTDFkG.js.map → banner-BMIxunVW.js.map} +1 -1
- package/dist/{banner-wJFk-L-c.cjs → banner-GwQ2NFNI.cjs} +3 -3
- package/dist/{banner-wJFk-L-c.cjs.map → banner-GwQ2NFNI.cjs.map} +1 -1
- package/dist/config-BKi_vTvh.js +1 -0
- package/dist/{config-CRrmj88c.cjs → config-BU9xeaGq.cjs} +3 -3
- package/dist/{config-CRrmj88c.cjs.map → config-BU9xeaGq.cjs.map} +1 -1
- package/dist/{config-Uk3rbZfb.js → config-CGcQTdZV.js} +7 -6
- package/dist/config-CGcQTdZV.js.map +1 -0
- package/dist/{config-BWj9jBVj.cjs → config-CkTrJD0E.cjs} +7 -6
- package/dist/config-CkTrJD0E.cjs.map +1 -0
- package/dist/{config-CQTxXvIG.js → config-re864UnO.js} +5 -5
- package/dist/config-re864UnO.js.map +1 -0
- package/dist/{configFile-BPHxtrEM.cjs → configFile-BQ-Pp7i_.cjs} +5 -5
- package/dist/{configFile-BPHxtrEM.cjs.map → configFile-BQ-Pp7i_.cjs.map} +1 -1
- package/dist/{configFile-L5i7gGUc.js → configFile-CPXDgTC2.js} +5 -5
- package/dist/{configFile-L5i7gGUc.js.map → configFile-CPXDgTC2.js.map} +1 -1
- package/dist/{credentials-DEsGwcGD.cjs → credentials-Cl3eOa8G.cjs} +3 -7
- package/dist/{credentials-DEsGwcGD.cjs.map → credentials-Cl3eOa8G.cjs.map} +1 -1
- package/dist/{credentials-B77iJx9H.js → credentials-DznluKkp.js} +1 -1
- package/dist/{credentials-osgjujE_.js → credentials-LPHovWZe.js} +2 -2
- package/dist/{credentials-osgjujE_.js.map → credentials-LPHovWZe.js.map} +1 -1
- package/dist/{env-rv-VgSGN.js → env-BYZIPHqz.js} +3 -3
- package/dist/{env-rv-VgSGN.js.map → env-BYZIPHqz.js.map} +1 -1
- package/dist/env-BgVegN_u.js +1 -0
- package/dist/{env-eu3XyKqJ.cjs → env-Bi4GXVdd.cjs} +4 -7
- package/dist/{env-eu3XyKqJ.cjs.map → env-Bi4GXVdd.cjs.map} +1 -1
- package/dist/{errors-BponpdjN.cjs → errors-Bewwe8mY.cjs} +2 -2
- package/dist/{errors-BponpdjN.cjs.map → errors-Bewwe8mY.cjs.map} +1 -1
- package/dist/{errors-wzqmMpMo.js → errors-CEzFbRvL.js} +2 -2
- package/dist/{errors-wzqmMpMo.js.map → errors-CEzFbRvL.js.map} +1 -1
- package/dist/{fs-Cf1FSRh9.js → fs-CmODfKN-.js} +27 -8
- package/dist/fs-CmODfKN-.js.map +1 -0
- package/dist/index.cjs +15 -15
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +15 -15
- package/dist/{installWithSpinner-CnE4dIza.cjs → installWithSpinner-DZDlVp1J.cjs} +6 -6
- package/dist/{installWithSpinner-CnE4dIza.cjs.map → installWithSpinner-DZDlVp1J.cjs.map} +1 -1
- package/dist/{installWithSpinner-CNDzLZw-.js → installWithSpinner-gv_OWgww.js} +6 -6
- package/dist/{installWithSpinner-CNDzLZw-.js.map → installWithSpinner-gv_OWgww.js.map} +1 -1
- package/dist/{intro-DRl-pwVs.js → intro-Dun8Eqod.js} +4 -4
- package/dist/{intro-DRl-pwVs.js.map → intro-Dun8Eqod.js.map} +1 -1
- package/dist/{intro-DuyzJ3Rb.cjs → intro-PFXmY9bD.cjs} +4 -4
- package/dist/{intro-DuyzJ3Rb.cjs.map → intro-PFXmY9bD.cjs.map} +1 -1
- package/dist/{isCIEnvironment-D6xtAAZ2.js → isCIEnvironment-DAMZSlP2.js} +2 -2
- package/dist/{isCIEnvironment-D6xtAAZ2.js.map → isCIEnvironment-DAMZSlP2.js.map} +1 -1
- package/dist/{isCIEnvironment-DiVOMI5Q.cjs → isCIEnvironment-jzKqdVwJ.cjs} +2 -2
- package/dist/{isCIEnvironment-DiVOMI5Q.cjs.map → isCIEnvironment-jzKqdVwJ.cjs.map} +1 -1
- package/dist/{log-B-1vLxF1.js → log-B_uVM704.js} +3 -3
- package/dist/{log-B-1vLxF1.js.map → log-B_uVM704.js.map} +1 -1
- package/dist/{log-wv1OxLiq.cjs → log-BzmBldY6.cjs} +3 -3
- package/dist/{log-wv1OxLiq.cjs.map → log-BzmBldY6.cjs.map} +1 -1
- package/dist/{mascot-CC-D4ON2.cjs → mascot-CLw0Qmln.cjs} +14 -10
- package/dist/{mascot-CC-D4ON2.cjs.map → mascot-CLw0Qmln.cjs.map} +1 -1
- package/dist/{mascot-CmUUHLlx.js → mascot-b4yXsKwl.js} +14 -10
- package/dist/mascot-b4yXsKwl.js.map +1 -0
- package/dist/{mcp-D60W6v_6.cjs → mcp-BBD4kdKF.cjs} +3 -3
- package/dist/{mcp-D60W6v_6.cjs.map → mcp-BBD4kdKF.cjs.map} +1 -1
- package/dist/{mcp-D63ugfbT.js → mcp-CQXp9pcW.js} +3 -3
- package/dist/{mcp-D63ugfbT.js.map → mcp-CQXp9pcW.js.map} +1 -1
- package/dist/package-CdMFA8OG.js +5 -0
- package/dist/package-CdMFA8OG.js.map +1 -0
- package/dist/{package-B8KmMINL.cjs → package-DXNoJQYa.cjs} +2 -2
- package/dist/package-DXNoJQYa.cjs.map +1 -0
- package/dist/{registry-Cy48PGdh.js → registry-BBJpMlM9.js} +4 -4
- package/dist/{registry-Cy48PGdh.js.map → registry-BBJpMlM9.js.map} +1 -1
- package/dist/{registry-Q77p5TZp.cjs → registry-CTVAqQFn.cjs} +4 -4
- package/dist/{registry-Q77p5TZp.cjs.map → registry-CTVAqQFn.cjs.map} +1 -1
- package/dist/{reporters-DyjE3BzZ.cjs → reporters-CaJ8brYA.cjs} +258 -106
- package/dist/reporters-CaJ8brYA.cjs.map +1 -0
- package/dist/{reporters-9MqdcKPp.js → reporters-CzxaQ_bD.js} +1 -1
- package/dist/{reporters-B_USHwD6.js → reporters-DeruUk9K.js} +260 -108
- package/dist/reporters-DeruUk9K.js.map +1 -0
- package/dist/{rolldown-runtime-C3-Zg-KD.cjs → rolldown-runtime-BV8xUvPy.cjs} +4 -4
- package/dist/{rolldown-runtime-xo6NMXYd.js → rolldown-runtime-BowF1xt-.js} +0 -1
- package/dist/{run-Dx8QpT_k.js → run-96_svbr3.js} +31 -21
- package/dist/run-96_svbr3.js.map +1 -0
- package/dist/{run-DMvX80Mi.cjs → run-BIgV2zvB.cjs} +4 -4
- package/dist/{run-DMvX80Mi.cjs.map → run-BIgV2zvB.cjs.map} +1 -1
- package/dist/{run-BA5vGtx3.cjs → run-BSA2x4iE.cjs} +14 -14
- package/dist/{run-BA5vGtx3.cjs.map → run-BSA2x4iE.cjs.map} +1 -1
- package/dist/{run-D_tbKvAc.js → run-Bi8hhAzv.js} +1 -1
- package/dist/{run-83Aaa6qM.cjs → run-Bxqg0GuI.cjs} +8 -8
- package/dist/{run-83Aaa6qM.cjs.map → run-Bxqg0GuI.cjs.map} +1 -1
- package/dist/{run-Ch7Uuu-u.js → run-C4fd98gp.js} +7 -7
- package/dist/{run-Ch7Uuu-u.js.map → run-C4fd98gp.js.map} +1 -1
- package/dist/{run-9mcw0FWy.cjs → run-CIEKCdM-.cjs} +19 -19
- package/dist/run-CIEKCdM-.cjs.map +1 -0
- package/dist/{run-5u7cHD85.js → run-CYdKWpyH.js} +43 -23
- package/dist/run-CYdKWpyH.js.map +1 -0
- package/dist/{run-DHdlUkYt.js → run-CmHjIMpd.js} +19 -19
- package/dist/run-CmHjIMpd.js.map +1 -0
- package/dist/{run-CgXrvsL9.js → run-CpyFU0RM.js} +16 -16
- package/dist/{run-CgXrvsL9.js.map → run-CpyFU0RM.js.map} +1 -1
- package/dist/{run-CfumUZCl.cjs → run-D15oxCOd.cjs} +7 -7
- package/dist/{run-CfumUZCl.cjs.map → run-D15oxCOd.cjs.map} +1 -1
- package/dist/{run-BxNbFsmc.cjs → run-DLRu4z5Z.cjs} +30 -19
- package/dist/run-DLRu4z5Z.cjs.map +1 -0
- package/dist/run-Df4PGOFX.js +291 -0
- package/dist/run-Df4PGOFX.js.map +1 -0
- package/dist/{run-D-FHx4uQ.cjs → run-GdctJlXN.cjs} +42 -21
- package/dist/run-GdctJlXN.cjs.map +1 -0
- package/dist/{run-Do24e475.js → run-ORjkOWFp.js} +4 -4
- package/dist/{run-Do24e475.js.map → run-ORjkOWFp.js.map} +1 -1
- package/dist/{run-DhlC3it5.cjs → run-OqiJknWr.cjs} +17 -17
- package/dist/{run-DhlC3it5.cjs.map → run-OqiJknWr.cjs.map} +1 -1
- package/dist/{run-BD6A0HGa.js → run-U2Ze_QP4.js} +17 -17
- package/dist/{run-BD6A0HGa.js.map → run-U2Ze_QP4.js.map} +1 -1
- package/dist/{run-DKqUfsTv.js → run-ixh050Ip.js} +8 -8
- package/dist/{run-DKqUfsTv.js.map → run-ixh050Ip.js.map} +1 -1
- package/dist/run-k-LqKkgU.cjs +294 -0
- package/dist/run-k-LqKkgU.cjs.map +1 -0
- package/dist/{shared-KKRMm1xX.cjs → shared-DoD3p_X8.cjs} +2 -2
- package/dist/{shared-KKRMm1xX.cjs.map → shared-DoD3p_X8.cjs.map} +1 -1
- package/dist/{shared-DcDHRtZx.js → shared-SrKde4x4.js} +2 -2
- package/dist/{shared-DcDHRtZx.js.map → shared-SrKde4x4.js.map} +1 -1
- package/dist/{snapshot-C_11eUdT.cjs → snapshot-C-ge8g3_.cjs} +12 -12
- package/dist/snapshot-C-ge8g3_.cjs.map +1 -0
- package/dist/{snapshot-CbajkXfi.js → snapshot-CSacL1qI.js} +12 -12
- package/dist/snapshot-CSacL1qI.js.map +1 -0
- package/dist/{spinner-RfMb7fd6.cjs → spinner-D584jFAz.cjs} +27 -9
- package/dist/spinner-D584jFAz.cjs.map +1 -0
- package/dist/{spinner-DxsAllRI.js → spinner-D5DgYSS5.js} +3 -3
- package/dist/{spinner-DxsAllRI.js.map → spinner-D5DgYSS5.js.map} +1 -1
- package/dist/{status-CaEQY12V.js → status-Bq-Bjo2n.js} +4 -4
- package/dist/{status-CaEQY12V.js.map → status-Bq-Bjo2n.js.map} +1 -1
- package/dist/{status-CgVRLP9A.cjs → status-D-Osmkhr.cjs} +4 -4
- package/dist/{status-CgVRLP9A.cjs.map → status-D-Osmkhr.cjs.map} +1 -1
- package/dist/{studio-1Otb3b_g.js → studio-BBXKjMN-.js} +18 -18
- package/dist/{studio-1Otb3b_g.js.map → studio-BBXKjMN-.js.map} +1 -1
- package/dist/{studio-CENejJka.cjs → studio-BZ53idqa.cjs} +18 -18
- package/dist/{studio-CENejJka.cjs.map → studio-BZ53idqa.cjs.map} +1 -1
- package/dist/studioWorker.js +3 -3
- package/dist/{summary-BQWHL_Ca.js → summary-BS-iWuye.js} +4 -4
- package/dist/{summary-BQWHL_Ca.js.map → summary-BS-iWuye.js.map} +1 -1
- package/dist/{summary-B2Apv5KO.cjs → summary-n4osDoch.cjs} +4 -4
- package/dist/{summary-B2Apv5KO.cjs.map → summary-n4osDoch.cjs.map} +1 -1
- package/dist/{table-CR7iZJGo.js → table-BKkctGHD.js} +2 -2
- package/dist/{table-CR7iZJGo.js.map → table-BKkctGHD.js.map} +1 -1
- package/dist/{table-BlRe9YTZ.cjs → table-_fOF5WNI.cjs} +2 -2
- package/dist/{table-BlRe9YTZ.cjs.map → table-_fOF5WNI.cjs.map} +1 -1
- package/dist/{text-DMiX2dcG.cjs → text-CkCtm5VP.cjs} +2 -2
- package/dist/{text-DMiX2dcG.cjs.map → text-CkCtm5VP.cjs.map} +1 -1
- package/dist/{text-EoYn04SX.js → text-HYWAcipy.js} +2 -2
- package/dist/{text-EoYn04SX.js.map → text-HYWAcipy.js.map} +1 -1
- package/dist/{time-3BKoci3G.cjs → time-D4xUq6tx.cjs} +2 -2
- package/dist/{time-3BKoci3G.cjs.map → time-D4xUq6tx.cjs.map} +1 -1
- package/dist/{time-C-wU7VhC.js → time-D7ONPPZf.js} +2 -2
- package/dist/{time-C-wU7VhC.js.map → time-D7ONPPZf.js.map} +1 -1
- package/dist/{utils-f1C7RiEI.js → utils-BVccq6W0.js} +4 -4
- package/dist/{utils-f1C7RiEI.js.map → utils-BVccq6W0.js.map} +1 -1
- package/dist/{utils-DeXBGzGJ.cjs → utils-C9fYoqP2.cjs} +5 -5
- package/dist/{utils-DeXBGzGJ.cjs.map → utils-C9fYoqP2.cjs.map} +1 -1
- package/dist/{validate-cBMe2ndk.js → validate-BuStuH_z.js} +4 -4
- package/dist/{validate-cBMe2ndk.js.map → validate-BuStuH_z.js.map} +1 -1
- package/dist/{validate-BPYNc8h8.cjs → validate-rr0LpFhN.cjs} +4 -4
- package/dist/{validate-BPYNc8h8.cjs.map → validate-rr0LpFhN.cjs.map} +1 -1
- package/package.json +8 -8
- package/dist/config-BL3HnFhb.js +0 -1
- package/dist/config-BWj9jBVj.cjs.map +0 -1
- package/dist/config-CQTxXvIG.js.map +0 -1
- package/dist/config-Uk3rbZfb.js.map +0 -1
- package/dist/env-C3xHRMez.js +0 -1
- package/dist/fs-Cf1FSRh9.js.map +0 -1
- package/dist/mascot-CmUUHLlx.js.map +0 -1
- package/dist/package-B8KmMINL.cjs.map +0 -1
- package/dist/package-Cjh6pjp9.js +0 -5
- package/dist/package-Cjh6pjp9.js.map +0 -1
- package/dist/reporters-B_USHwD6.js.map +0 -1
- package/dist/reporters-DyjE3BzZ.cjs.map +0 -1
- package/dist/run-5u7cHD85.js.map +0 -1
- package/dist/run-9mcw0FWy.cjs.map +0 -1
- package/dist/run-BxNbFsmc.cjs.map +0 -1
- package/dist/run-CXYwjh9u.cjs +0 -229
- package/dist/run-CXYwjh9u.cjs.map +0 -1
- package/dist/run-D-FHx4uQ.cjs.map +0 -1
- package/dist/run-DHdlUkYt.js.map +0 -1
- package/dist/run-Dx8QpT_k.js.map +0 -1
- package/dist/run-m5ZAeYLj.js +0 -226
- package/dist/run-m5ZAeYLj.js.map +0 -1
- package/dist/snapshot-C_11eUdT.cjs.map +0 -1
- package/dist/snapshot-CbajkXfi.js.map +0 -1
- package/dist/spinner-RfMb7fd6.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-Df4PGOFX.js","names":["delay","logLevel","logLevelMap"],"sources":["../src/utils/updateCheck.ts","../src/runners/generate/run.ts"],"sourcesContent":["import { isCIEnvironment } from '@internals/utils'\nimport { kubbStorage } from '@kubb/core'\nimport { isValid } from 'verkit'\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/** How long a stored registry answer stays fresh. */\nexport const UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1_000\n\nconst STORE_KEY = 'update-check.json'\n\ntype StoredCheck = {\n version: string\n checkedAt: number\n}\n\nfunction isStoredCheck(value: unknown): value is StoredCheck {\n const check = value as Partial<StoredCheck> | null\n return typeof check?.version === 'string' && isValid(check.version) && typeof check.checkedAt === 'number'\n}\n\n// A timestamp in the future, from a clock set back, counts as stale so it cannot hide updates.\nfunction isFresh(checkedAt: number): boolean {\n const age = Date.now() - checkedAt\n return age >= 0 && age < UPDATE_CHECK_INTERVAL_MS\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 if (!res.ok) return undefined\n const data = (await res.json()) as { version?: unknown }\n return typeof data.version === 'string' && isValid(data.version) ? data.version : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * The latest published `@kubb/cli` version for the update notice. Skipped in CI. Asks npm at most once per\n * {@link UPDATE_CHECK_INTERVAL_MS} and keeps the answer in `~/.kubb/cache` (or `KUBB_HOME`).\n * Resolves `undefined` when there is nothing to show. Never rejects.\n */\nexport async function getLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n if (isCIEnvironment()) return undefined\n\n const storage = (() => {\n try {\n return kubbStorage({ base: 'cache' })\n } catch {\n return undefined\n }\n })()\n const stored = await storage?.getItem(STORE_KEY).catch(() => null)\n if (isStoredCheck(stored) && isFresh(stored.checkedAt)) return stored.version\n\n const latest = await fetchLatestVersion(signal)\n if (latest) await storage?.setItem(STORE_KEY, { version: latest, checkedAt: Date.now() }).catch(() => undefined)\n return latest\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { setTimeout as delay } from 'node:timers/promises'\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 Diagnostics,\n fileReporter,\n getInputKind,\n htmlReporter,\n jsonReporter,\n Kubb,\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 { getLatestVersion } from '../../utils/updateCheck.ts'\nimport { type BuildDiff, type BuildSnapshot, diffBuilds, listenForKeys, startWatcher, trackBuild } from './utils.ts'\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\nfunction toRunConfig({ config, input, dryRun }: { config: Config; input?: string; dryRun: boolean }): Config {\n return {\n ...config,\n input: input ?? config.input,\n // Dry-run never touches disk, regardless of the config's own storage driver.\n storage: dryRun ? memoryStorage() : config.storage,\n // Also keeps core's `hasOutputPasses` false, so dry-run skips the output manifest write too.\n output: dryRun ? { ...config.output, format: false, lint: false, postGenerate: [] } : config.output,\n }\n}\n\ntype GenerateProps = {\n configs: Array<Config>\n hooks: Hookable<KubbHooks>\n}\n\n/**\n * Generates the configs and returns whether every build succeeded.\n */\nexport async function generate({ configs, hooks }: GenerateProps): Promise<boolean> {\n // Not awaited: each request finishes in the background, capped by its timeout, so it never delays the summary.\n const untrack = hooks.hook('kubb:generation:end', ({ config, filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {\n void trackRun({ command: 'generate', hrStart })({\n plugins: 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,\n status,\n })\n })\n let succeeded = true\n try {\n for await (const { success, error } of Kubb.generate(configs, { hooks })) {\n if (error) await Diagnostics.emit(hooks, error)\n succeeded &&= success\n }\n } finally {\n untrack()\n }\n return succeeded\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/** Upper bound in milliseconds for the update check's cache read or write once generation is done. */\nconst UPDATE_WAIT_MS = 1_000\n\n/** `promise`'s value, or `undefined` when it takes longer than `ms`. */\nasync function withTimeout<T>({ promise, ms }: { promise: Promise<T>; ms: number }): Promise<T | undefined> {\n const timer = new AbortController()\n const timeout = delay(ms, undefined, { signal: timer.signal }).catch(() => undefined)\n return Promise.race([promise, timeout]).finally(() => timer.abort())\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 * Generates the configs, then again whenever a local `input` file changes. Returns whether the build succeeded when there is no file to watch.\n */\nasync function watch({ configs, hooks, quiet }: GenerateProps & { quiet: boolean }): Promise<boolean> {\n const watchPaths = [...new Set(configs.flatMap(({ input }) => (typeof input === 'string' && getInputKind(input) === 'file' ? [input] : [])))]\n if (!watchPaths.length) {\n if (!quiet) logWarn('Watch mode only follows a local `input` file, so the configs are generated once.')\n return generate({ configs, hooks })\n }\n\n const label = styleText('yellow', `Watching ${watchPaths.map((watchPath) => path.relative(process.cwd(), watchPath)).join(', ')}`)\n const tracker = trackBuild(hooks)\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 // Every config builds again, since an edited spec can change what the configs share.\n const succeeded = await generate({ configs, hooks })\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 a build is queued joins it. One that lands during the build queues one more. Never rejects.\n let queue = Promise.resolve()\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(hooks, error))\n return queue\n }\n const armKeys = quiet\n ? undefined\n : listenForKeys({\n rebuild: () => void rebuild(),\n quit: (code) => void Promise.resolve(hooks.callHook('kubb:lifecycle:end')).finally(() => process.exit(code)),\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 await startWatcher(watchPaths, rebuild, { info: logInfo, error: logError })\n return true\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 a newer version is known.\n */\nexport async function run({\n input,\n configPath,\n logLevel: logLevelKey,\n watch: watchMode,\n reporters: cliReporters,\n dryRun,\n}: GenerateCommandOptions): Promise<void> {\n // Started first: the notice prints at the end only when the stored answer or the registry is there by then.\n const updateCheck = new AbortController()\n const latestVersion = getLatestVersion(updateCheck.signal)\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 // The run log goes to stderr in `json` mode, so an error with no report entry is never silent and stdout stays one JSON document.\n if (json) setupReporters(hooks, { logLevel, reporters: [cliReporter], writer: createPlainWriter(console.error) })\n\n // The config loads while the banner plays. Once it settles the banner jumps to its last frame, so\n // the build starts right away and no frame lands between log lines.\n const bannerCut = new AbortController()\n const banner = quiet ? undefined : logBanner({ version, signal: bannerCut.signal })\n const loading = getConfigs({\n configPath,\n input,\n watch: watchMode,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n reporters: cliReporters,\n })\n // A rejection is handled below; this also keeps it from counting as unhandled during the banner.\n void loading.then(\n () => bannerCut.abort(),\n () => bannerCut.abort(),\n )\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(hooks, 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 const runConfigs = configs.map((config) => toRunConfig({ config, input, dryRun: dryRun ?? false }))\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n // One config that fails does not stop the others.\n const succeeded = await (watchMode ? watch({ configs: runConfigs, hooks, quiet }) : generate({ configs: runConfigs, hooks }))\n\n // Aborting settles a request in flight at once; the timeout covers a cache read or write on a stalled disk.\n updateCheck.abort()\n await checkForUpdate({ hooks, latestVersion: await withTimeout({ promise: latestVersion, ms: UPDATE_WAIT_MS }) })\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 && !watchMode && succeeded) {\n logTip()\n }\n\n // `exitCode`, not `exit()`, so a telemetry request still in flight can finish within its timeout.\n if (!succeeded) {\n process.exitCode = 1\n }\n } catch (error) {\n await Diagnostics.emit(hooks, error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,uBAAuB;;AAG7B,MAAM,0BAA0B;AAKhC,MAAM,YAAY;AAOlB,SAAS,cAAc,OAAsC;CAC3D,MAAM,QAAQ;CACd,OAAO,OAAO,OAAO,YAAY,YAAY,QAAQ,MAAM,OAAO,KAAK,OAAO,MAAM,cAAc;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AAe;GAAE;GAAO,eAAe,MAAM,YAAY;IAAE,SAAS;IAAe,IAAI;GAAe,CAAC;EAAE,CAAC;EAEhH,MAAM,MAAM,SAAS,oBAAoB;EAIzC,IAAI,CAAC,SAAS,CAAC,aAAa,WAC1B,OAAO;EAIT,IAAI,CAAC,WACH,QAAQ,WAAW;CAEvB,SAAS,OAAO;EACd,MAAM,YAAY,KAAK,OAAO,KAAK;EACnC,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const require_shared = require("./shared-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const require_summary = require("./summary-
|
|
11
|
-
const require_registry = require("./registry-
|
|
12
|
-
const require_installWithSpinner = require("./installWithSpinner-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
|
|
2
|
+
const require_config = require("./config-BU9xeaGq.cjs");
|
|
3
|
+
const require_configFile = require("./configFile-BQ-Pp7i_.cjs");
|
|
4
|
+
const require_errors = require("./errors-Bewwe8mY.cjs");
|
|
5
|
+
const require_utils = require("./utils-C9fYoqP2.cjs");
|
|
6
|
+
const require_spinner = require("./spinner-D584jFAz.cjs");
|
|
7
|
+
const require_shared = require("./shared-DoD3p_X8.cjs");
|
|
8
|
+
const require_intro = require("./intro-PFXmY9bD.cjs");
|
|
9
|
+
const require_log = require("./log-BzmBldY6.cjs");
|
|
10
|
+
const require_summary = require("./summary-n4osDoch.cjs");
|
|
11
|
+
const require_registry = require("./registry-CTVAqQFn.cjs");
|
|
12
|
+
const require_installWithSpinner = require("./installWithSpinner-DZDlVp1J.cjs");
|
|
13
13
|
let node_util = require("node:util");
|
|
14
14
|
let gunshi = require("gunshi");
|
|
15
15
|
let node_process = require("node:process");
|
|
@@ -19,6 +19,7 @@ node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
|
19
19
|
let _clack_prompts = require("@clack/prompts");
|
|
20
20
|
_clack_prompts = require_rolldown_runtime.__toESM(_clack_prompts, 1);
|
|
21
21
|
let _kubb_core = require("@kubb/core");
|
|
22
|
+
let _gunshi_plugin_dryrun = require("@gunshi/plugin-dryrun");
|
|
22
23
|
// src/runners/add/run.ts
|
|
23
24
|
/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */
|
|
24
25
|
function toSnippet({ artifact, manifest }) {
|
|
@@ -121,15 +122,19 @@ function summarize(description, max = 64) {
|
|
|
121
122
|
* adds it to `kubb.config.ts`, offering to add the plugins it needs as well. An adapter is never
|
|
122
123
|
* written: the command prints the snippet to swap it in by hand. Without an id, asks which one.
|
|
123
124
|
* Previews the packages and config lines before asking. Refuses when the running Kubb or Node.js
|
|
124
|
-
* version is outside its compatibility.
|
|
125
|
+
* version is outside its compatibility. With `dryRun`, stops after the preview: installs nothing and
|
|
126
|
+
* leaves the config as it is.
|
|
125
127
|
*/
|
|
126
|
-
async function run({ id: input, configPath, yes, install }) {
|
|
128
|
+
async function run({ id: input, configPath, yes, install, dryRun = false }) {
|
|
127
129
|
const cwd = node_process.default.cwd();
|
|
128
130
|
const hrStart = node_process.default.hrtime();
|
|
129
131
|
const summary = require_summary.createSummary(hrStart);
|
|
130
132
|
const installedPackages = [];
|
|
131
133
|
const configured = [];
|
|
132
|
-
require_intro.logIntro({ title: require_intro.isInteractiveRun({
|
|
134
|
+
require_intro.logIntro({ title: require_intro.isInteractiveRun({
|
|
135
|
+
yes,
|
|
136
|
+
dryRun
|
|
137
|
+
}) ? void 0 : (0, node_util.styleText)("bgCyan", (0, node_util.styleText)("black", " Kubb Add ")) });
|
|
133
138
|
try {
|
|
134
139
|
const registry = require_registry.registryUrl();
|
|
135
140
|
if (!input && yes) throw new _kubb_core.Diagnostics.Error({
|
|
@@ -195,7 +200,7 @@ async function run({ id: input, configPath, yes, install }) {
|
|
|
195
200
|
const withDependencies = await confirmDependencies({
|
|
196
201
|
entry,
|
|
197
202
|
missing,
|
|
198
|
-
yes
|
|
203
|
+
yes: yes || dryRun
|
|
199
204
|
});
|
|
200
205
|
if (withDependencies === void 0) {
|
|
201
206
|
summary("Add canceled", "canceled", [` ${kind} ${manifest.name}`, " No changes made"]);
|
|
@@ -223,6 +228,20 @@ async function run({ id: input, configPath, yes, install }) {
|
|
|
223
228
|
...preview && "lines" in preview ? preview.lines.map((line) => (0, node_util.styleText)("green", ` + ${line}`)) : [],
|
|
224
229
|
...preview && "reason" in preview ? [(0, node_util.styleText)("yellow", ` cannot edit it: ${preview.reason}`)] : []
|
|
225
230
|
]);
|
|
231
|
+
if (dryRun) {
|
|
232
|
+
if (configFile && configSource === void 0) {
|
|
233
|
+
node_process.default.exitCode = 1;
|
|
234
|
+
summary(`${kind} not added`, "failed", [`Could not read ${configName}. Check the path passed with --config.`]);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (!configName) require_log.logBlock([
|
|
238
|
+
"Add the import to your Kubb config and merge the property into its defineConfig call:",
|
|
239
|
+
"",
|
|
240
|
+
...targets.map(toSnippet)
|
|
241
|
+
]);
|
|
242
|
+
summary(`${kind} not added`, "planned", ["Dry run: nothing was installed or written. Run the same command without --dry-run to add it."]);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
226
245
|
const confirmed = yes || await _clack_prompts.confirm({
|
|
227
246
|
message: "Add it?",
|
|
228
247
|
initialValue: true
|
|
@@ -279,7 +298,7 @@ async function run({ id: input, configPath, yes, install }) {
|
|
|
279
298
|
node_process.default.exitCode = 1;
|
|
280
299
|
}
|
|
281
300
|
}
|
|
282
|
-
const command = (0, gunshi.
|
|
301
|
+
const command = (0, gunshi.defineWithTypes)()({
|
|
283
302
|
name: "add",
|
|
284
303
|
description: "Find and install plugins, adapters, and parsers from the Kubb registry.",
|
|
285
304
|
examples: [
|
|
@@ -287,7 +306,8 @@ const command = (0, gunshi.define)({
|
|
|
287
306
|
"kubb add plugin-zod",
|
|
288
307
|
"kubb add kubb-labs/plugin-react-query",
|
|
289
308
|
"kubb add acme/plugin-x --yes",
|
|
290
|
-
"kubb add plugin-zod --no-install"
|
|
309
|
+
"kubb add plugin-zod --no-install",
|
|
310
|
+
"kubb add plugin-zod --dry-run"
|
|
291
311
|
].join("\n"),
|
|
292
312
|
toKebab: true,
|
|
293
313
|
args: {
|
|
@@ -305,15 +325,16 @@ const command = (0, gunshi.define)({
|
|
|
305
325
|
default: true
|
|
306
326
|
}
|
|
307
327
|
},
|
|
308
|
-
run: ({ values }) => run({
|
|
328
|
+
run: ({ values, extensions }) => run({
|
|
309
329
|
id: values.id,
|
|
310
330
|
configPath: values.config,
|
|
311
331
|
yes: values.yes,
|
|
312
|
-
install: values.install
|
|
332
|
+
install: values.install,
|
|
333
|
+
dryRun: extensions[_gunshi_plugin_dryrun.pluginId].enabled
|
|
313
334
|
})
|
|
314
335
|
});
|
|
315
336
|
exports.command = command;
|
|
316
337
|
exports.run = run;
|
|
317
338
|
exports.summarize = summarize;
|
|
318
339
|
|
|
319
|
-
//# sourceMappingURL=run-
|
|
340
|
+
//# sourceMappingURL=run-GdctJlXN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-GdctJlXN.cjs","names":["ConfigEditOperation","extensionKinds","editConfig","Diagnostics","toShortId","clack","process","createSummary","isInteractiveRun","styleText","registryUrl","toRegistryId","path","findConfigFile","withSpinner","fetchRegistryIndex","readInstalledPackages","read","closestIds","pascalCase","incompatibility","readImports","BUNDLED_PACKAGES","installSpec","detectPackageManager","installWithSpinner","editConfigFile","getErrorMessage","defineWithTypes","configArg","yesArg","dryRunId"],"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 { defineWithTypes } 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, 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 { 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 dryRun?: 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. With `dryRun`, stops after the preview: installs nothing and\n * leaves the config as it is.\n */\nexport async function run({ id: input, configPath, yes, install, dryRun = false }: 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, dryRun }) ? 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 // A dry run asks nothing and previews the recommended answer.\n const withDependencies = await confirmDependencies({ entry, missing, yes: yes || dryRun })\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 if (dryRun) {\n // The real run installs first and only then fails on the edit, so the dry run has to say it.\n if (configFile && configSource === undefined) {\n process.exitCode = 1\n summary(`${kind} not added`, 'failed', [`Could not read ${configName}. Check the path passed with --config.`])\n return\n }\n if (!configName) logBlock(['Add the import to your Kubb config and merge the property into its defineConfig call:', '', ...targets.map(toSnippet)])\n summary(`${kind} not added`, 'planned', ['Dry run: nothing was installed or written. Run the same command without --dry-run to add it.'])\n return\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 = defineWithTypes<{ extensions: DryRunExtensions }>()({\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 'kubb add plugin-zod --dry-run',\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, extensions }) =>\n run({ id: values.id, configPath: values.config, yes: values.yes, install: values.install, dryRun: extensions[dryRunId].enabled }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+BA,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,WAAWA,mBAAAA,oBAAoB;GAC/B,GAAI,SAAS,SAASC,mBAAAA,eAAe,SAAS,EAAE,MAAMA,mBAAAA,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;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|
1
|
+
import "./rolldown-runtime-BowF1xt-.js";
|
|
2
|
+
import { n as toError } from "./errors-CEzFbRvL.js";
|
|
3
|
+
import { n as trackRun } from "./Telemetry-DUl_hxVn.js";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
// src/runners/mcp/run.ts
|
|
@@ -28,4 +28,4 @@ async function run() {
|
|
|
28
28
|
}
|
|
29
29
|
export { run };
|
|
30
30
|
|
|
31
|
-
//# sourceMappingURL=run-
|
|
31
|
+
//# sourceMappingURL=run-ORjkOWFp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-ORjkOWFp.js","names":[],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport type * as McpModule from '@kubb/mcp'\nimport { trackRun } from '../../Telemetry.ts'\n\n/**\n * Starts the `@kubb/mcp` server over stdio and reports the outcome to telemetry.\n */\nexport async function run(): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n\n const report = trackRun({ command: 'mcp', hrStart: process.hrtime() })\n\n try {\n // The MCP stdio transport owns stdout: anything else written there corrupts the JSON-RPC stream.\n console.error(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n const server = startMcpServer()\n // Report once the client introduces itself, so the event names the client (e.g. `claude-code`, `cursor-vscode`).\n server.on('initialize', ({ clientInfo }) => void report({ status: 'success', mcpClient: clientInfo.name }), { once: true })\n } catch (error) {\n await report({ status: 'failed' })\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;AASA,eAAsB,MAAqB;CACzC,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAE9C,MAAM,SAAS,SAAS;EAAE,SAAS;EAAO,SAAS,QAAQ,OAAO;CAAE,CAAC;CAErE,IAAI;EAEF,QAAQ,MAAM,UAAU,QAAQ,0BAA0B,CAAC;EAC3D,QAAQ,KAAK,UAAU,UAAU,2DAA2D,CAAC;EAG7F,eAAK,CAAC,CAAC,GAAG,eAAe,EAAE,iBAAiB,KAAK,OAAO;GAAE,QAAQ;GAAW,WAAW,WAAW;EAAK,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC;CAC5H,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,QAAQ,WAAW;CACrB;AACF"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const require_config$1 = require("./config-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
|
|
2
|
+
const require_text = require("./text-CkCtm5VP.cjs");
|
|
3
|
+
const require_config = require("./config-BU9xeaGq.cjs");
|
|
4
|
+
const require_isCIEnvironment = require("./isCIEnvironment-jzKqdVwJ.cjs");
|
|
5
|
+
const require_errors = require("./errors-Bewwe8mY.cjs");
|
|
6
|
+
const require_Telemetry = require("./Telemetry-CBzCK4kO.cjs");
|
|
7
|
+
const require_log = require("./log-BzmBldY6.cjs");
|
|
8
|
+
const require_reporters = require("./reporters-CaJ8brYA.cjs");
|
|
9
|
+
const require_intro = require("./intro-PFXmY9bD.cjs");
|
|
10
|
+
const require_spinner = require("./spinner-D584jFAz.cjs");
|
|
11
|
+
const require_env = require("./env-Bi4GXVdd.cjs");
|
|
12
|
+
const require_config$1 = require("./config-CkTrJD0E.cjs");
|
|
13
|
+
const require_credentials = require("./credentials-Cl3eOa8G.cjs");
|
|
14
|
+
const require_package = require("./package-DXNoJQYa.cjs");
|
|
15
15
|
let node_util = require("node:util");
|
|
16
16
|
let node_os = require("node:os");
|
|
17
17
|
let node_process = require("node:process");
|
|
@@ -303,7 +303,7 @@ async function connect(options, context = {}) {
|
|
|
303
303
|
let unwatch;
|
|
304
304
|
try {
|
|
305
305
|
if (!context.prepared) {
|
|
306
|
-
const { getWorkerStatus } = await Promise.resolve().then(() => require("./background-
|
|
306
|
+
const { getWorkerStatus } = await Promise.resolve().then(() => require("./background-fhpYDuSs.cjs"));
|
|
307
307
|
if ((await getWorkerStatus()).running) throw new _kubb_core.Diagnostics.Error({
|
|
308
308
|
code: _kubb_core.Diagnostics.code.unknown,
|
|
309
309
|
severity: "error",
|
|
@@ -371,7 +371,7 @@ async function connect(options, context = {}) {
|
|
|
371
371
|
await hooks.callHook("kubb:lifecycle:end");
|
|
372
372
|
unwatch?.();
|
|
373
373
|
if (background) {
|
|
374
|
-
const { startWorker } = await Promise.resolve().then(() => require("./background-
|
|
374
|
+
const { startWorker } = await Promise.resolve().then(() => require("./background-fhpYDuSs.cjs"));
|
|
375
375
|
await startWorker(options);
|
|
376
376
|
if (options.logLevel !== "silent") require_intro.logOutro("Running in the background · kubb studio stop");
|
|
377
377
|
return;
|
|
@@ -449,4 +449,4 @@ exports.prepareConnection = prepareConnection;
|
|
|
449
449
|
exports.resolvePermissions = resolvePermissions;
|
|
450
450
|
exports.runStudio = runStudio;
|
|
451
451
|
|
|
452
|
-
//# sourceMappingURL=run-
|
|
452
|
+
//# sourceMappingURL=run-OqiJknWr.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-DhlC3it5.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,eAAe,CAAC,CAAC;CAC1C,IAAI,SAAS,OAAO,IAAI,IAAI;CAE5B,OAAO,IAAI,MACR,EAAE,eAAe,aAAa,SACzB,KACR;AACF;;AC1BA,MAAM,eAAe,CAAC;;;;AAKtB,SAAgB,cAAc,QAAsB;CAClD,IAAIC,wBAAAA,gBAAgB,GAAG;CAEvB,IAAIC,aAAAA,QAAQ,aAAa,SAAS;EAChC,CAAA,GAAA,SAAA,EAAA,CAAE,OAAO;GAAC;GAAM;GAAS;GAAI;EAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,MAAM;EACzD;CACF;CACA,CAAA,GAAA,SAAA,EAAA,CAAEA,aAAAA,QA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AY,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
|
+
{"version":3,"file":"run-OqiJknWr.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,M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AAI,QAAQ,MAAM;EACxB,MAAM,WAAW,KAAK;EACtB,MAAM,MAAM;CACd;AACF;;;;;AAMA,eAAsB,UACpB,QACA,QACA,EAAE,QAAQ,OAAO,OAAO,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,17 +1,17 @@
|
|
|
1
|
-
import "./rolldown-runtime-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { n as trackRun } from "./Telemetry-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { a as logTip, n as logIntro, r as logOutro } from "./intro-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { t as
|
|
14
|
-
import { t as
|
|
1
|
+
import "./rolldown-runtime-BowF1xt-.js";
|
|
2
|
+
import { r as toPermissionFlag } from "./text-HYWAcipy.js";
|
|
3
|
+
import { a as KUBB_CONFIG_FILENAME } from "./config-re864UnO.js";
|
|
4
|
+
import { t as isCIEnvironment } from "./isCIEnvironment-DAMZSlP2.js";
|
|
5
|
+
import { n as toError } from "./errors-CEzFbRvL.js";
|
|
6
|
+
import { n as trackRun } from "./Telemetry-DUl_hxVn.js";
|
|
7
|
+
import { c as plainWriter, i as logStep, t as logBlock } from "./log-B_uVM704.js";
|
|
8
|
+
import { n as setupReporters } from "./reporters-DeruUk9K.js";
|
|
9
|
+
import { a as logTip, n as logIntro, r as logOutro } from "./intro-Dun8Eqod.js";
|
|
10
|
+
import { t as createSpinner } from "./spinner-D5DgYSS5.js";
|
|
11
|
+
import { n as isRichOutput, t as canUseTTY } from "./env-BYZIPHqz.js";
|
|
12
|
+
import { t as getConfigs } from "./config-CGcQTdZV.js";
|
|
13
|
+
import { a as readCredentials, n as getCredentialsPath, o as writeCredentials, r as getMachineId, t as clearCredentials } from "./credentials-LPHovWZe.js";
|
|
14
|
+
import { t as version } from "./package-CdMFA8OG.js";
|
|
15
15
|
import { styleText } from "node:util";
|
|
16
16
|
import { hostname } from "node:os";
|
|
17
17
|
import process from "node:process";
|
|
@@ -300,7 +300,7 @@ async function connect(options, context = {}) {
|
|
|
300
300
|
let unwatch;
|
|
301
301
|
try {
|
|
302
302
|
if (!context.prepared) {
|
|
303
|
-
const { getWorkerStatus } = await import("./background-
|
|
303
|
+
const { getWorkerStatus } = await import("./background-DK3HLyNk.js");
|
|
304
304
|
if ((await getWorkerStatus()).running) throw new Diagnostics.Error({
|
|
305
305
|
code: Diagnostics.code.unknown,
|
|
306
306
|
severity: "error",
|
|
@@ -368,7 +368,7 @@ async function connect(options, context = {}) {
|
|
|
368
368
|
await hooks.callHook("kubb:lifecycle:end");
|
|
369
369
|
unwatch?.();
|
|
370
370
|
if (background) {
|
|
371
|
-
const { startWorker } = await import("./background-
|
|
371
|
+
const { startWorker } = await import("./background-DK3HLyNk.js");
|
|
372
372
|
await startWorker(options);
|
|
373
373
|
if (options.logLevel !== "silent") logOutro("Running in the background · kubb studio stop");
|
|
374
374
|
return;
|
|
@@ -440,4 +440,4 @@ async function runStudio(values, action, { block = false, json = false } = {}) {
|
|
|
440
440
|
}
|
|
441
441
|
export { login as a, runStudio as c, loadConfigs as i, watchKeys as l, formatCountdown as n, prepareConnection as o, formatPermissionRows as r, resolvePermissions as s, connect as t };
|
|
442
442
|
|
|
443
|
-
//# sourceMappingURL=run-
|
|
443
|
+
//# sourceMappingURL=run-U2Ze_QP4.js.map
|