@kubb/cli 5.0.0-beta.37 → 5.0.0-beta.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/{agent-B8oJFhcN.js → agent-CLspGfSn.js} +4 -4
  2. package/dist/{agent-B8oJFhcN.js.map → agent-CLspGfSn.js.map} +1 -1
  3. package/dist/{agent-DtuTV_Qk.cjs → agent-RdNQgRXD.cjs} +4 -4
  4. package/dist/{agent-DtuTV_Qk.cjs.map → agent-RdNQgRXD.cjs.map} +1 -1
  5. package/dist/{constants-CYxk4aNm.js → constants-84a47qA-.js} +2 -6
  6. package/dist/constants-84a47qA-.js.map +1 -0
  7. package/dist/{constants-CAKUpLcQ.cjs → constants-BtmponZ3.cjs} +1 -11
  8. package/dist/constants-BtmponZ3.cjs.map +1 -0
  9. package/dist/{generate-BvaMqrBk.cjs → generate-DK1pLJMi.cjs} +3 -4
  10. package/dist/generate-DK1pLJMi.cjs.map +1 -0
  11. package/dist/{generate-CzTjeiji.js → generate-Db0pJmbG.js} +3 -4
  12. package/dist/{generate-CzTjeiji.js.map → generate-Db0pJmbG.js.map} +1 -1
  13. package/dist/index.cjs +9 -9
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.js +9 -9
  16. package/dist/index.js.map +1 -1
  17. package/dist/{init-CaMeuE1-.js → init-DKMwmbmx.js} +2 -2
  18. package/dist/{init-CaMeuE1-.js.map → init-DKMwmbmx.js.map} +1 -1
  19. package/dist/{init-C59u3T68.cjs → init-D_MQBDVz.cjs} +2 -2
  20. package/dist/{init-C59u3T68.cjs.map → init-D_MQBDVz.cjs.map} +1 -1
  21. package/dist/{mcp-Ca3ZcpKB.js → mcp-DqNyN0cN.js} +3 -3
  22. package/dist/{mcp-Ca3ZcpKB.js.map → mcp-DqNyN0cN.js.map} +1 -1
  23. package/dist/{mcp-D4NMV9lk.cjs → mcp-DvEeDWlW.cjs} +3 -3
  24. package/dist/{mcp-D4NMV9lk.cjs.map → mcp-DvEeDWlW.cjs.map} +1 -1
  25. package/dist/package-C8u_WvqI.js +6 -0
  26. package/dist/package-C8u_WvqI.js.map +1 -0
  27. package/dist/{package-DQFf9DB2.cjs → package-CusjBrSS.cjs} +2 -2
  28. package/dist/package-CusjBrSS.cjs.map +1 -0
  29. package/dist/{run-DJxYClJV.js → run-BQ3Qj0xB.js} +4 -4
  30. package/dist/run-BQ3Qj0xB.js.map +1 -0
  31. package/dist/{run-BvXxelGR.js → run-BQzoaxjR.js} +3 -3
  32. package/dist/run-BQzoaxjR.js.map +1 -0
  33. package/dist/{run-Ca2h07rN.js → run-BabEDDqN.js} +130 -369
  34. package/dist/run-BabEDDqN.js.map +1 -0
  35. package/dist/{run-BFEK9md9.js → run-CGf0KEts.js} +3 -3
  36. package/dist/run-CGf0KEts.js.map +1 -0
  37. package/dist/{run-CK8Cvq6n.cjs → run-CJUmJcbC.cjs} +130 -369
  38. package/dist/run-CJUmJcbC.cjs.map +1 -0
  39. package/dist/{run-Bz9IFMWg.cjs → run-CkTpemme.cjs} +3 -3
  40. package/dist/run-CkTpemme.cjs.map +1 -0
  41. package/dist/{run-BQZyg7If.cjs → run-Cl4SrSob.cjs} +3 -3
  42. package/dist/run-Cl4SrSob.cjs.map +1 -0
  43. package/dist/{run-BFv6avA_.cjs → run-D-s2LdlW.cjs} +5 -5
  44. package/dist/run-D-s2LdlW.cjs.map +1 -0
  45. package/dist/{validate-B_wfDSHQ.cjs → validate-CkW_AKZp.cjs} +3 -3
  46. package/dist/{validate-B_wfDSHQ.cjs.map → validate-CkW_AKZp.cjs.map} +1 -1
  47. package/dist/{validate-BEEerg2-.js → validate-jRewvR0c.js} +3 -3
  48. package/dist/{validate-BEEerg2-.js.map → validate-jRewvR0c.js.map} +1 -1
  49. package/package.json +7 -7
  50. package/src/commands/generate.ts +2 -3
  51. package/src/constants.ts +0 -15
  52. package/src/index.ts +2 -2
  53. package/src/loggers/clackLogger.ts +4 -6
  54. package/src/loggers/githubActionsLogger.ts +3 -3
  55. package/src/loggers/plainLogger.ts +2 -3
  56. package/src/loggers/utils.ts +29 -28
  57. package/src/runners/agent/run.ts +2 -2
  58. package/src/runners/generate/run.ts +21 -17
  59. package/src/runners/generate/utils.ts +2 -2
  60. package/src/runners/mcp/run.ts +2 -2
  61. package/src/runners/validate/run.ts +2 -2
  62. package/dist/constants-CAKUpLcQ.cjs.map +0 -1
  63. package/dist/constants-CYxk4aNm.js.map +0 -1
  64. package/dist/generate-BvaMqrBk.cjs.map +0 -1
  65. package/dist/package-DQFf9DB2.cjs.map +0 -1
  66. package/dist/package-DUwUSFeL.js +0 -6
  67. package/dist/package-DUwUSFeL.js.map +0 -1
  68. package/dist/run-BFEK9md9.js.map +0 -1
  69. package/dist/run-BFv6avA_.cjs.map +0 -1
  70. package/dist/run-BQZyg7If.cjs.map +0 -1
  71. package/dist/run-BvXxelGR.js.map +0 -1
  72. package/dist/run-Bz9IFMWg.cjs.map +0 -1
  73. package/dist/run-CK8Cvq6n.cjs.map +0 -1
  74. package/dist/run-Ca2h07rN.js.map +0 -1
  75. package/dist/run-DJxYClJV.js.map +0 -1
  76. package/dist/telemetry-B80oJfxR.cjs +0 -280
  77. package/dist/telemetry-B80oJfxR.cjs.map +0 -1
  78. package/dist/telemetry-ueaMzs_c.js +0 -243
  79. package/dist/telemetry-ueaMzs_c.js.map +0 -1
  80. package/src/loggers/diagnostics.ts +0 -77
  81. package/src/reporters/cliReporter.ts +0 -89
  82. package/src/reporters/fileReporter.ts +0 -103
  83. package/src/reporters/jsonReporter.ts +0 -15
  84. package/src/reporters/report.ts +0 -84
  85. package/src/telemetry.ts +0 -280
@@ -1,6 +1,6 @@
1
1
  import { styleText } from 'node:util'
2
2
  import { formatMs, formatMsWithColor, toCause } from '@internals/utils'
3
- import { type Config, defineLogger, diagnosticCode, Diagnostics, isProblemDiagnostic, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'
3
+ import { type Config, defineLogger, Diagnostics, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'
4
4
  import {
5
5
  buildProgressLine,
6
6
  createHookTimer,
@@ -157,7 +157,7 @@ export const githubActionsLogger = defineLogger({
157
157
  return
158
158
  }
159
159
 
160
- if (!isProblemDiagnostic(diagnostic)) {
160
+ if (!Diagnostics.isProblem(diagnostic)) {
161
161
  console.log(`::notice::${diagnostic.message}`)
162
162
  return
163
163
  }
@@ -172,7 +172,7 @@ export const githubActionsLogger = defineLogger({
172
172
  if (diagnostic.help) {
173
173
  parts.push(`help: ${diagnostic.help}`)
174
174
  }
175
- if (diagnostic.code !== diagnosticCode.unknown) {
175
+ if (diagnostic.code !== Diagnostics.code.unknown) {
176
176
  parts.push(`docs: ${Diagnostics.docsUrl(diagnostic.code)}`)
177
177
  }
178
178
  console.error(`::error::${parts.join(' ')}`)
@@ -1,7 +1,6 @@
1
1
  import { relative } from 'node:path'
2
2
  import { formatMs, toCause } from '@internals/utils'
3
- import { defineLogger, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'
4
- import { formatDiagnostic } from './diagnostics.ts'
3
+ import { defineLogger, Diagnostics, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'
5
4
  import { createHookTimer, formatCommandWithArgs, formatMessage } from './utils.ts'
6
5
 
7
6
  /**
@@ -87,7 +86,7 @@ export const plainLogger = defineLogger({
87
86
  if (logLevel <= logLevelMap.silent && diagnostic.severity !== 'error') {
88
87
  return
89
88
  }
90
- console.log(getMessage(formatDiagnostic(diagnostic).join('\n')))
89
+ console.log(getMessage(Diagnostics.formatLines(diagnostic).join('\n')))
91
90
  })
92
91
 
93
92
  context.on('kubb:lifecycle:start', ({ version }) => {
@@ -1,11 +1,8 @@
1
1
  import process from 'node:process'
2
2
  import { styleText } from 'node:util'
3
3
  import { canUseTTY, formatHrtime, getElapsedMs, isGitHubActions } from '@internals/utils'
4
- import type { Logger, LoggerContext, LoggerOptions, Reporter, ReporterContext, ReporterName } from '@kubb/core'
4
+ import type { Logger, LoggerContext, LoggerOptions, Reporter, ReporterContext } from '@kubb/core'
5
5
  import { logLevel as logLevelMap } from '@kubb/core'
6
- import { cliReporter } from '../reporters/cliReporter.ts'
7
- import { fileReporter } from '../reporters/fileReporter.ts'
8
- import { jsonReporter } from '../reporters/jsonReporter.ts'
9
6
  import { clackLogger } from './clackLogger.ts'
10
7
  import { githubActionsLogger } from './githubActionsLogger.ts'
11
8
  import { plainLogger } from './plainLogger.ts'
@@ -234,44 +231,48 @@ export function installReporter(context: LoggerContext, reporter: Reporter, ctx:
234
231
  context.on('kubb:generation:end', async ({ config, diagnostics = [], filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {
235
232
  await reporter.report({ config, diagnostics, filesCreated, status, hrStart }, ctx)
236
233
  })
234
+
235
+ if (reporter.drain) {
236
+ context.on('kubb:lifecycle:end', () => reporter.drain?.(ctx))
237
+ }
237
238
  }
238
239
 
239
240
  /**
240
- * Installs the live logger (the TUI view) and the selected reporters (the output), returning the
241
- * terminal logger's hook sink when one was installed. Loggers and reporters are independent: the
242
- * `cli` selection activates the env logger plus the {@link cliReporter} summary.
241
+ * Installs the live logger (the TUI view) and the given reporters (the output), returning the
242
+ * terminal logger's hook sink when one was installed. The reporters are already selected by the
243
+ * caller (the CLI maps `--reporter` to names via `selectReporters`); this only wires them.
243
244
  *
244
- * The `json` reporter owns stdout, so the terminal logger and `cli` summary are suppressed whenever
245
- * `json` is selected, even if `cli` is also listed.
245
+ * Loggers and reporters are independent: the `cli` reporter also activates the env logger summary.
246
+ * The `json` reporter owns stdout, so the live logger and the `cli` summary are suppressed whenever
247
+ * `json` is among the reporters, even if `cli` is also listed.
246
248
  */
247
- export async function setupReporters(
249
+ async function setupReporters(
248
250
  context: LoggerContext,
249
- { logLevel, reporters }: LoggerOptions & { reporters: ReadonlyArray<ReporterName> },
251
+ { logLevel, reporters }: LoggerOptions & { reporters: ReadonlyArray<Reporter> },
250
252
  ): Promise<HookSinkFactory | null> {
251
- const unique = new Set<ReporterName>(reporters.length ? reporters : ['cli'])
252
- const hasJson = unique.has('json')
253
+ const hasJson = reporters.some((reporter) => reporter.name === 'json')
253
254
  const ctx: ReporterContext = { logLevel }
254
255
 
255
256
  let makeSink: HookSinkFactory | null = null
256
257
 
257
- if (unique.has('cli') && !hasJson) {
258
- const type = detectLogger()
259
- const logger = logMapper[type]
260
- if (!logger) {
261
- throw new Error(`Unknown adapter type: ${type}`)
258
+ for (const reporter of reporters) {
259
+ if (reporter.name === 'cli') {
260
+ if (hasJson) {
261
+ continue
262
+ }
263
+ const type = detectLogger()
264
+ const logger = logMapper[type]
265
+ if (!logger) {
266
+ throw new Error(`Unknown adapter type: ${type}`)
267
+ }
268
+ const sink = await logger.install(context, { logLevel })
269
+ makeSink = typeof sink === 'function' ? sink : null
262
270
  }
263
- const sink = await logger.install(context, { logLevel })
264
- makeSink = typeof sink === 'function' ? sink : null
265
- installReporter(context, cliReporter, ctx)
266
- }
267
-
268
- if (hasJson) {
269
- installReporter(context, jsonReporter, ctx)
270
- }
271
271
 
272
- if (unique.has('file')) {
273
- installReporter(context, fileReporter, ctx)
272
+ installReporter(context, reporter, ctx)
274
273
  }
275
274
 
276
275
  return makeSink
277
276
  }
277
+
278
+ export default setupReporters
@@ -4,8 +4,8 @@ import process from 'node:process'
4
4
  import { styleText } from 'node:util'
5
5
  import * as clack from '@clack/prompts'
6
6
  import { spawnAsync, getErrorMessage } from '@internals/utils'
7
+ import { Telemetry } from '@kubb/core'
7
8
  import { agentDefaults } from '../../constants.ts'
8
- import { buildTelemetryEvent, sendTelemetry } from '../../telemetry.ts'
9
9
  import { isPortAvailable, resolveAgentStartEnvironment } from './utils.ts'
10
10
 
11
11
  type AgentStartOptions = {
@@ -43,7 +43,7 @@ type AgentStartOptions = {
43
43
  */
44
44
  export async function run({ port, host, configPath, allowWrite, allowAll, version }: AgentStartOptions): Promise<void> {
45
45
  const hrStart = process.hrtime()
46
- const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status }))
46
+ const report = (status: 'success' | 'failed') => Telemetry.send(Telemetry.build({ command: 'agent', kubbVersion: version, hrStart, status }))
47
47
 
48
48
  try {
49
49
  // Load .env file into process.env using Node.js built-in (v20.12.0+)
@@ -1,4 +1,5 @@
1
1
  import { createHash } from 'node:crypto'
2
+ import { existsSync } from 'node:fs'
2
3
  import path from 'node:path'
3
4
  import process from 'node:process'
4
5
  import { styleText } from 'node:util'
@@ -7,23 +8,21 @@ import type { AsyncEventEmitter } from '@internals/utils'
7
8
  import { AsyncEventEmitter as AsyncEventEmitterClass, detectFormatter, detectLinter, executeIfOnline, formatters, linters, toError } from '@internals/utils'
8
9
  import {
9
10
  type CLIOptions,
11
+ cliReporter,
10
12
  type Config,
11
13
  createKubb,
12
14
  type Diagnostic,
13
- diagnosticCode,
14
15
  Diagnostics,
15
- isInputPath,
16
- isProblemDiagnostic,
17
16
  type KubbHooks,
18
17
  logLevel as logLevelMap,
19
- narrowDiagnostic,
20
18
  type ProblemDiagnostic,
21
19
  type ReporterName,
20
+ selectReporters,
21
+ Telemetry,
22
22
  } from '@kubb/core'
23
23
  import { version } from '../../../package.json'
24
24
  import { KUBB_NPM_PACKAGE_URL } from '../../constants.ts'
25
- import { setupReporters, type HookSinkFactory } from '../../loggers/utils.ts'
26
- import { buildTelemetryEvent, sendTelemetry } from '../../telemetry.ts'
25
+ import setupReporters, { type HookSinkFactory } from '../../loggers/utils.ts'
27
26
  import { executeHooks, getConfigs, runHook, startWatcher } from './utils.ts'
28
27
 
29
28
  type GenerateProps = {
@@ -106,7 +105,9 @@ async function runToolPass({
106
105
 
107
106
  let toolError: Error | undefined
108
107
 
109
- if (resolvedTool && resolvedTool !== 'auto' && resolvedTool in toolMap) {
108
+ // Nothing to lint or format when the output dir was never written. Skip so the tool
109
+ // (e.g. oxlint with --no-ignore) doesn't fail with "No files found to lint".
110
+ if (resolvedTool && resolvedTool !== 'auto' && resolvedTool in toolMap && existsSync(outputPath)) {
110
111
  const toolConfig = toolMap[resolvedTool as keyof ToolMap]
111
112
  const hookId = createHash('sha256').update([configName, resolvedTool].filter(Boolean).join('-')).digest('hex')
112
113
 
@@ -180,15 +181,15 @@ async function generate(options: GenerateProps): Promise<boolean> {
180
181
  const telemetryPlugins = Array.from(driver.plugins.values(), (p) => ({ name: p.name, options: p.options as Record<string, unknown> }))
181
182
 
182
183
  const reportTelemetry = (status: 'success' | 'failed') =>
183
- sendTelemetry(buildTelemetryEvent({ command: 'generate', kubbVersion: version, plugins: telemetryPlugins, hrStart, filesCreated: files.length, status }))
184
+ Telemetry.send(Telemetry.build({ command: 'generate', kubbVersion: version, plugins: telemetryPlugins, hrStart, filesCreated: files.length, status }))
184
185
 
185
186
  // Render every problem, not just on failure, so warnings and info surface too.
186
187
  // `performance` diagnostics feed the summary, not the log.
187
188
  for (const diagnostic of diagnostics) {
188
- if (!isProblemDiagnostic(diagnostic)) {
189
+ if (!Diagnostics.isProblem(diagnostic)) {
189
190
  continue
190
191
  }
191
- const unknown = narrowDiagnostic(diagnostic, diagnosticCode.unknown)
192
+ const unknown = Diagnostics.narrow(diagnostic, Diagnostics.code.unknown)
192
193
  if (unknown) {
193
194
  await hooks.emit('kubb:error', { error: unknown.cause ?? new Error(unknown.message) })
194
195
  } else {
@@ -213,7 +214,7 @@ async function generate(options: GenerateProps): Promise<boolean> {
213
214
 
214
215
  const toolPasses = [
215
216
  config.output.format && {
216
- code: diagnosticCode.formatFailed,
217
+ code: Diagnostics.code.formatFailed,
217
218
  toolValue: config.output.format,
218
219
  detect: detectFormatter,
219
220
  toolMap: formatters,
@@ -224,7 +225,7 @@ async function generate(options: GenerateProps): Promise<boolean> {
224
225
  onEnd: () => hooks.emit('kubb:format:end'),
225
226
  },
226
227
  config.output.lint && {
227
- code: diagnosticCode.lintFailed,
228
+ code: Diagnostics.code.lintFailed,
228
229
  toolValue: config.output.lint,
229
230
  detect: detectLinter,
230
231
  toolMap: linters,
@@ -261,7 +262,7 @@ async function generate(options: GenerateProps): Promise<boolean> {
261
262
  hooks.off('kubb:hook:end', onHookEnd)
262
263
  }
263
264
  for (const error of hookFailures) {
264
- const diagnostic = outputDiagnostic(diagnosticCode.hookFailed, 'Post-generate hook', error)
265
+ const diagnostic = outputDiagnostic(Diagnostics.code.hookFailed, 'Post-generate hook', error)
265
266
  outputDiagnostics.push(diagnostic)
266
267
  await Diagnostics.emit(hooks, diagnostic)
267
268
  }
@@ -348,13 +349,16 @@ export async function run({ input, configPath, logLevel: logLevelKey, watch, rep
348
349
  configs = loaded.configs
349
350
  resolvedConfigPath = loaded.configPath
350
351
  } catch (error) {
351
- await setupReporters(hooks, { logLevel, reporters: ['cli'] })
352
+ await setupReporters(hooks, { logLevel, reporters: [cliReporter] })
352
353
  await hooks.emit('kubb:error', { error: toError(error) })
353
354
  process.exit(1)
354
355
  }
355
356
 
356
- // CLI `--reporter` wins. Otherwise the first config's `reporters`. Otherwise the default.
357
- const reporters: Array<ReporterName> = cliReporters?.length ? cliReporters : (configs[0]?.reporters ?? ['cli'])
357
+ // CLI `--reporter` selects which reporters to trigger by name, defaulting to `cli`. The config
358
+ // always carries the available reporters (defineConfig registers the built-ins).
359
+ const requestedNames: Array<ReporterName> = cliReporters?.length ? cliReporters : ['cli']
360
+ const available = configs[0]?.reporters ?? []
361
+ const reporters = selectReporters(available, requestedNames)
358
362
  const makeSink = await setupReporters(hooks, { logLevel, reporters })
359
363
 
360
364
  await hooks.emit('kubb:lifecycle:start', { version })
@@ -371,7 +375,7 @@ export async function run({ input, configPath, logLevel: logLevelKey, watch, rep
371
375
 
372
376
  let anyFailed = false
373
377
  for (const config of configs) {
374
- if (isInputPath(config) && watch) {
378
+ if (config.input && 'path' in config.input && watch) {
375
379
  await startWatcher(
376
380
  [input || config.input.path],
377
381
  async (paths) => {
@@ -171,7 +171,6 @@ export async function runHook({ id, command, args, commandWithArgs, hooks, strea
171
171
  if (!(err instanceof NonZeroExitError)) {
172
172
  const error = toError(err)
173
173
  await emitEnd(false, error)
174
- await hooks.emit('kubb:error', { error })
175
174
  return
176
175
  }
177
176
 
@@ -182,8 +181,9 @@ export async function runHook({ id, command, args, commandWithArgs, hooks, strea
182
181
  if (stdout) sink?.onStdout?.(stdout)
183
182
 
184
183
  const error = new Error(`Hook execute failed: ${commandWithArgs}`)
184
+ // Signal the failure via `kubb:hook:end` only. The caller turns it into a coded diagnostic and
185
+ // emits that through `Diagnostics.emit`, so emitting `kubb:error` here would render it twice.
185
186
  await emitEnd(false, error)
186
- await hooks.emit('kubb:error', { error })
187
187
  }
188
188
  }
189
189
 
@@ -1,8 +1,8 @@
1
1
  import process from 'node:process'
2
2
  import { styleText } from 'node:util'
3
3
  import { getErrorMessage } from '@internals/utils'
4
+ import { Telemetry } from '@kubb/core'
4
5
  import type * as McpModule from '@kubb/mcp'
5
- import { buildTelemetryEvent, sendTelemetry } from '../../telemetry.ts'
6
6
 
7
7
  type McpOptions = {
8
8
  /**
@@ -24,7 +24,7 @@ type McpOptions = {
24
24
  export async function run({ version, port, host }: McpOptions): Promise<void> {
25
25
  const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule
26
26
  const hrStart = process.hrtime()
27
- const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'mcp', kubbVersion: version, hrStart, status }))
27
+ const report = (status: 'success' | 'failed') => Telemetry.send(Telemetry.build({ command: 'mcp', kubbVersion: version, hrStart, status }))
28
28
  try {
29
29
  console.log(styleText('cyan', '⏳ Starting MCP server...'))
30
30
  console.warn(styleText('yellow', 'This feature is still under development, use with caution'))
@@ -1,7 +1,7 @@
1
1
  import process from 'node:process'
2
2
  import { styleText } from 'node:util'
3
3
  import { getErrorMessage } from '@internals/utils'
4
- import { buildTelemetryEvent, sendTelemetry } from '../../telemetry.ts'
4
+ import { Telemetry } from '@kubb/core'
5
5
 
6
6
  type ValidateOptions = {
7
7
  /**
@@ -35,7 +35,7 @@ export function loadValidateModule(): Promise<ValidateModule> {
35
35
  */
36
36
  export async function run({ input, version }: ValidateOptions, dependencies: ValidateDependencies = { loadValidateModule }): Promise<void> {
37
37
  const hrStart = process.hrtime()
38
- const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status }))
38
+ const report = (status: 'success' | 'failed') => Telemetry.send(Telemetry.build({ command: 'validate', kubbVersion: version, hrStart, status }))
39
39
  try {
40
40
  const { adapterOas } = await dependencies.loadValidateModule()
41
41
  const adapter = adapterOas()
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants-CAKUpLcQ.cjs","names":["KUBB_CONFIG_FILENAME"],"sources":["../src/constants.ts"],"sourcesContent":["import { KUBB_CONFIG_FILENAME } from '@internals/shared'\n\n/**\n * NPM registry endpoint used to check for @kubb/cli updates.\n */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/**\n * OpenTelemetry ingestion endpoint for anonymous usage telemetry.\n */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\n/**\n * Horizontal rule rendered above/below the plain-logger generation summary.\n */\nexport const SUMMARY_SEPARATOR = '─'.repeat(27)\n\n/**\n * Maximum number of █ characters in a plugin timing bar.\n */\nexport const SUMMARY_MAX_BAR_LENGTH = 10 as const\n\n/**\n * Divides elapsed milliseconds into bar-length units (1 block per 100 ms).\n */\nexport const SUMMARY_TIME_SCALE_DIVISOR = 100 as const\n\n/**\n * Glob pattern for paths the file watcher ignores.\n */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Flags that short-circuit execution (help/version), no telemetry notice is shown.\n */\nexport const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)\n\nexport const agentDefaults = {\n port: '3000',\n host: 'localhost',\n configFile: KUBB_CONFIG_FILENAME,\n retryTimeout: '30000',\n studioUrl: 'https://kubb.studio',\n /**\n * Relative path from the @kubb/agent package root to the server entry.\n */\n serverEntryPath: '.output/server/index.mjs',\n} as const\n"],"mappings":";;;;;AAKA,MAAa,uBAAuB;;;;AAKpC,MAAa,gBAAgB;AAKI,IAAI,OAAO,EAAE;;;;AAe9C,MAAa,wBAAwB;;;;AAKrC,MAAa,cAAc,IAAI,IAAI;CAAC;CAAU;CAAM;CAAa;AAAI,CAAU;AAE/E,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,YAAYA,kBAAAA;CACZ,cAAc;CACd,WAAW;;;;CAIX,iBAAiB;AACnB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants-CYxk4aNm.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { KUBB_CONFIG_FILENAME } from '@internals/shared'\n\n/**\n * NPM registry endpoint used to check for @kubb/cli updates.\n */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/**\n * OpenTelemetry ingestion endpoint for anonymous usage telemetry.\n */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\n/**\n * Horizontal rule rendered above/below the plain-logger generation summary.\n */\nexport const SUMMARY_SEPARATOR = '─'.repeat(27)\n\n/**\n * Maximum number of █ characters in a plugin timing bar.\n */\nexport const SUMMARY_MAX_BAR_LENGTH = 10 as const\n\n/**\n * Divides elapsed milliseconds into bar-length units (1 block per 100 ms).\n */\nexport const SUMMARY_TIME_SCALE_DIVISOR = 100 as const\n\n/**\n * Glob pattern for paths the file watcher ignores.\n */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Flags that short-circuit execution (help/version), no telemetry notice is shown.\n */\nexport const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)\n\nexport const agentDefaults = {\n port: '3000',\n host: 'localhost',\n configFile: KUBB_CONFIG_FILENAME,\n retryTimeout: '30000',\n studioUrl: 'https://kubb.studio',\n /**\n * Relative path from the @kubb/agent package root to the server entry.\n */\n serverEntryPath: '.output/server/index.mjs',\n} as const\n"],"mappings":";;;;;AAKA,MAAa,uBAAuB;;;;AAKpC,MAAa,gBAAgB;AAKI,IAAI,OAAO,EAAE;;;;AAe9C,MAAa,wBAAwB;;;;AAKrC,MAAa,cAAc,IAAI,IAAI;CAAC;CAAU;CAAM;CAAa;AAAI,CAAU;AAE/E,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,YAAY;CACZ,cAAc;CACd,WAAW;;;;CAIX,iBAAiB;AACnB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-BvaMqrBk.cjs","names":["defineCommand"],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport type { ReporterName } from '@kubb/core'\n\nexport const command = defineCommand({\n name: 'generate',\n description:\n 'Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.',\n arguments: ['[input]'],\n examples: ['kubb generate', 'kubb generate ./openapi.yaml', 'kubb generate --config kubb.config.ts', 'kubb generate --watch'],\n options: {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n logLevel: {\n type: 'string',\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n hint: 'silent|info|verbose',\n enum: ['silent', 'info', 'verbose'],\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n short: 'v',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'string',\n description: 'Reporters that render the run, comma-separated. Overrides config.reporters',\n default: 'cli',\n hint: 'cli|json|file',\n enum: ['cli', 'json', 'file'],\n },\n },\n async run({ values, positionals }) {\n const logLevel = values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel\n const reporters = values.reporter\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean) as Array<ReporterName>\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: positionals[0],\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters,\n })\n },\n})\n"],"mappings":";;AAGA,MAAa,yCAAUA,EAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,WAAW,CAAC,SAAS;CACrB,UAAU;EAAC;EAAiB;EAAgC;EAAyC;CAAuB;CAC5H,SAAS;EACP,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;EACT;EACA,UAAU;GACR,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACT,MAAM;GACN,MAAM;IAAC;IAAU;IAAQ;GAAS;EACpC;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,UAAU;GACR,MAAM;GACN,aAAa;GACb,SAAS;GACT,MAAM;GACN,MAAM;IAAC;IAAO;IAAQ;GAAM;EAC9B;CACF;CACA,MAAM,IAAI,EAAE,QAAQ,eAAe;EACjC,MAAM,WAAW,OAAO,UAAU,YAAY,OAAO,SAAS,WAAW,OAAO;EAChF,MAAM,YAAY,OAAO,SACtB,MAAM,GAAG,EACT,KAAK,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,OAAO;EACjB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,OAAO,YAAY;GACnB,YAAY,OAAO;GACnB;GACA,OAAO,OAAO;GACd;EACF,CAAC;CACH;AACF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-DQFf9DB2.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,6 +0,0 @@
1
- //#region package.json
2
- var version = "5.0.0-beta.37";
3
- //#endregion
4
- export { version as t };
5
-
6
- //# sourceMappingURL=package-DUwUSFeL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-DUwUSFeL.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-BFEK9md9.js","names":[],"sources":["../src/runners/validate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { buildTelemetryEvent, sendTelemetry } from '../../telemetry.ts'\n\ntype ValidateOptions = {\n /**\n * Path or URL to the OpenAPI/Swagger file to validate.\n */\n input: string\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n}\n\ntype ValidateModule = typeof import('@kubb/adapter-oas')\ntype ValidateDependencies = {\n /**\n * Loads `@kubb/adapter-oas`. Injected so tests can substitute a mock.\n */\n loadValidateModule: () => Promise<ValidateModule>\n}\n\n/**\n * Dynamically loads `@kubb/adapter-oas` for OpenAPI validation.\n */\nexport function loadValidateModule(): Promise<ValidateModule> {\n return import('@kubb/adapter-oas') as Promise<ValidateModule>\n}\n\n/**\n * Validates an OpenAPI/Swagger file at `input` using `@kubb/adapter-oas`.\n * Exits the process with code 1 on validation failure or missing dependency.\n */\nexport async function run({ input, version }: ValidateOptions, dependencies: ValidateDependencies = { loadValidateModule }): Promise<void> {\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status }))\n try {\n const { adapterOas } = await dependencies.loadValidateModule()\n const adapter = adapterOas()\n if (!adapter.validate) {\n throw new Error('The loaded adapter does not support validation.')\n }\n await adapter.validate(input, { throwOnError: true })\n await report('success')\n console.log('✅ Validation success')\n } catch (error) {\n await report('failed')\n if (error instanceof Error && /@kubb\\/adapter-oas/.test(error.message)) {\n console.error(styleText('red', 'The @kubb/adapter-oas package is not installed.'))\n console.error('')\n console.error('Install it with:')\n console.error(styleText('cyan', ' npm install @kubb/adapter-oas'))\n console.error(styleText('cyan', ' # or'))\n console.error(styleText('cyan', ' pnpm install @kubb/adapter-oas'))\n console.error('')\n }\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,qBAA8C;CAC5D,OAAO,OAAO;AAChB;;;;;AAMA,eAAsB,IAAI,EAAE,OAAO,WAA4B,eAAqC,EAAE,mBAAmB,GAAkB;CACzI,MAAM,UAAU,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiC,cAAc,oBAAoB;EAAE,SAAS;EAAY,aAAa;EAAS;EAAS;CAAO,CAAC,CAAC;CAClJ,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,aAAa,mBAAmB;EAC7D,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,QAAQ,UACX,MAAM,IAAI,MAAM,iDAAiD;EAEnE,MAAM,QAAQ,SAAS,OAAO,EAAE,cAAc,KAAK,CAAC;EACpD,MAAM,OAAO,SAAS;EACtB,QAAQ,IAAI,sBAAsB;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,IAAI,iBAAiB,SAAS,qBAAqB,KAAK,MAAM,OAAO,GAAG;GACtE,QAAQ,MAAM,UAAU,OAAO,iDAAiD,CAAC;GACjF,QAAQ,MAAM,EAAE;GAChB,QAAQ,MAAM,kBAAkB;GAChC,QAAQ,MAAM,UAAU,QAAQ,iCAAiC,CAAC;GAClE,QAAQ,MAAM,UAAU,QAAQ,QAAQ,CAAC;GACzC,QAAQ,MAAM,UAAU,QAAQ,kCAAkC,CAAC;GACnE,QAAQ,MAAM,EAAE;EAClB;EACA,QAAQ,MAAM,qBAAqB;EACnC,QAAQ,MAAM,gBAAgB,KAAK,CAAC;EACpC,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-BFv6avA_.cjs","names":["process","agentDefaults","path","net","process","sendTelemetry","buildTelemetryEvent","path","agentDefaults","spawnAsync","getErrorMessage"],"sources":["../src/runners/agent/utils.ts","../src/runners/agent/run.ts"],"sourcesContent":["import net from 'node:net'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { agentDefaults } from '../../constants.ts'\n\ntype AgentStartEnvironmentInput = {\n /**\n * TCP port for the HTTP server. When `undefined`, falls back to `PORT` env var or the default (`3000`).\n */\n port: string | undefined\n /**\n * Hostname the HTTP server binds to.\n */\n host: string\n /**\n * Explicit path to the Kubb config file. When `undefined`, falls back to `KUBB_AGENT_CONFIG` or the default filename.\n */\n configPath: string | undefined\n /**\n * Grants the agent permission to write generated files to the filesystem.\n */\n allowWrite: boolean\n /**\n * Grants all agent permissions, including filesystem writes. Implies `allowWrite`.\n */\n allowAll: boolean\n}\n\ntype ResolvedAgentStartEnvironment = {\n /**\n * Final port string after merging CLI flag, `PORT` env var, and the default.\n */\n port: string\n /**\n * Final hostname after merging CLI flag, `HOST` env var, and the default.\n */\n host: string\n /**\n * Effective write-permission flag, accounting for `allowAll` and `KUBB_AGENT_ALLOW_WRITE`.\n */\n allowWrite: boolean\n /**\n * Effective all-permissions flag, accounting for `KUBB_AGENT_ALLOW_ALL`.\n */\n allowAll: boolean\n /**\n * Absolute path to the Kubb config file passed to the agent subprocess.\n */\n agentConfigPath: string\n /**\n * Merged `process.env` object with all resolved agent environment variables applied.\n */\n env: NodeJS.ProcessEnv\n}\n\n/**\n * Resolves the environment passed to the detached agent process using CLI values first, then environment values, then CLI defaults.\n */\nexport function resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll }: AgentStartEnvironmentInput): ResolvedAgentStartEnvironment {\n const resolvedPort = port ?? process.env.PORT ?? agentDefaults.port\n const resolvedHost = host !== agentDefaults.host ? host : (process.env.HOST ?? agentDefaults.host)\n const resolvedAllowAll = allowAll || process.env.KUBB_AGENT_ALLOW_ALL === 'true'\n const resolvedAllowWrite = resolvedAllowAll || allowWrite || process.env.KUBB_AGENT_ALLOW_WRITE === 'true'\n const agentRoot = process.env.KUBB_AGENT_ROOT ?? process.cwd()\n const agentConfigPath = path.resolve(process.cwd(), configPath || process.env.KUBB_AGENT_CONFIG || agentDefaults.configFile)\n\n return {\n port: resolvedPort,\n host: resolvedHost,\n allowWrite: resolvedAllowWrite,\n allowAll: resolvedAllowAll,\n agentConfigPath,\n env: {\n ...process.env,\n PORT: resolvedPort,\n HOST: resolvedHost,\n KUBB_AGENT_ROOT: agentRoot,\n KUBB_AGENT_CONFIG: agentConfigPath,\n KUBB_AGENT_ALLOW_WRITE: String(resolvedAllowWrite),\n KUBB_AGENT_ALLOW_ALL: String(resolvedAllowAll),\n KUBB_AGENT_TOKEN: process.env.KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT: process.env.KUBB_AGENT_RETRY_TIMEOUT ?? agentDefaults.retryTimeout,\n KUBB_STUDIO_URL: process.env.KUBB_STUDIO_URL ?? agentDefaults.studioUrl,\n },\n }\n}\n\nexport function isPortAvailable(port: number, host: string): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer()\n server.once('error', () => resolve(false))\n server.once('listening', () => {\n server.close()\n resolve(true)\n })\n server.listen(port, host)\n })\n}\n","import { createRequire } from 'node:module'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { spawnAsync, getErrorMessage } from '@internals/utils'\nimport { agentDefaults } from '../../constants.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../../telemetry.ts'\nimport { isPortAvailable, resolveAgentStartEnvironment } from './utils.ts'\n\ntype AgentStartOptions = {\n /**\n * TCP port for the HTTP server. When `undefined`, falls back to `PORT` env var or the default (`3000`).\n */\n port: string | undefined\n /**\n * Hostname the HTTP server binds to.\n *\n * @default 'localhost'\n */\n host: string\n /**\n * Explicit path to the Kubb config file. When `undefined`, falls back to `KUBB_AGENT_CONFIG` or the default filename.\n */\n configPath: string | undefined\n /**\n * Grants the agent permission to write generated files to the filesystem.\n */\n allowWrite: boolean\n /**\n * Grants all agent permissions, including filesystem writes. Implies `allowWrite`.\n */\n allowAll: boolean\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n}\n\n/**\n * Spawns the Kubb Agent HTTP server as a Node.js subprocess.\n * Resolves config from CLI flags and environment variables, validates the port, and exits with code 1 on failure.\n */\nexport async function run({ port, host, configPath, allowWrite, allowAll, version }: AgentStartOptions): Promise<void> {\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status }))\n\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist. Ignore\n }\n\n // Resolve the @kubb/agent package path, createRequire is CJS/ESM compatible (import.meta.resolve is ESM-only)\n const require = createRequire(import.meta.url)\n let agentPkgPath: string\n try {\n agentPkgPath = require.resolve('@kubb/agent/package.json')\n } catch (_e) {\n console.error(styleText('red', 'The @kubb/agent package is not installed.'))\n console.error('')\n console.error('Install it with:')\n console.error(styleText('cyan', ' npm install @kubb/agent'))\n console.error(styleText('cyan', ' # or'))\n console.error(styleText('cyan', ' pnpm install @kubb/agent'))\n console.error('')\n process.exit(1)\n }\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, agentDefaults.serverEntryPath)\n\n const resolvedEnv = resolveAgentStartEnvironment({\n port,\n host,\n configPath,\n allowWrite,\n allowAll,\n })\n const numericPort = Number(resolvedEnv.port)\n\n if (!Number.isInteger(numericPort) || numericPort <= 0) {\n throw new Error(`Invalid port \"${resolvedEnv.port}\". Provide a positive integer with --port or PORT.`)\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${resolvedEnv.agentConfigPath}`))\n clack.log.info(styleText('dim', `Host: ${resolvedEnv.host}`))\n clack.log.info(styleText('dim', `Port: ${resolvedEnv.port}`))\n if (!resolvedEnv.allowWrite && !resolvedEnv.allowAll) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n if (!(await isPortAvailable(numericPort, resolvedEnv.host))) {\n clack.log.error(styleText('red', `Port ${resolvedEnv.port} is already in use. Stop the existing process or choose a different port with --port.`))\n process.exit(1)\n }\n\n // Spawns the server as a detached background process so the CLI can exit independently.\n await spawnAsync('node', [serverPath], {\n env: resolvedEnv.env,\n cwd: process.cwd(),\n })\n\n await report('success')\n } catch (error) {\n await report('failed')\n clack.log.error(styleText('red', 'Failed to start agent server'))\n clack.log.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":"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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-BQZyg7If.cjs","names":["process","sendTelemetry","buildTelemetryEvent","getErrorMessage"],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport type * as McpModule from '@kubb/mcp'\nimport { buildTelemetryEvent, sendTelemetry } from '../../telemetry.ts'\n\ntype McpOptions = {\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n /**\n * TCP port for the HTTP MCP server. When `undefined`, the server uses stdio transport.\n */\n port?: string\n /**\n * Hostname to bind to when running in HTTP mode.\n *\n * @default 'localhost'\n */\n host?: string\n}\n\nexport async function run({ version, port, host }: McpOptions): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'mcp', kubbVersion: version, hrStart, status }))\n try {\n console.log(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n await startMcpServer(undefined, { port: port !== undefined ? Number(port) : undefined, host })\n await report('success')\n } catch (error) {\n await report('failed')\n console.error(getErrorMessage(error))\n }\n}\n"],"mappings":";;;;;;;AAuBA,eAAsB,IAAI,EAAE,SAAS,MAAM,QAAmC;CAC5E,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAC9C,MAAM,UAAUA,aAAAA,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiCC,kBAAAA,cAAcC,kBAAAA,oBAAoB;EAAE,SAAS;EAAO,aAAa;EAAS;EAAS;CAAO,CAAC,CAAC;CAC7I,IAAI;EACF,QAAQ,KAAA,GAAA,UAAA,WAAc,QAAQ,0BAA0B,CAAC;EACzD,QAAQ,MAAA,GAAA,UAAA,WAAe,UAAU,2DAA2D,CAAC;EAC7F,MAAM,eAAe,KAAA,GAAW;GAAE,MAAM,SAAS,KAAA,IAAY,OAAO,IAAI,IAAI,KAAA;GAAW;EAAK,CAAC;EAC7F,MAAM,OAAO,SAAS;CACxB,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,QAAQ,MAAMC,eAAAA,gBAAgB,KAAK,CAAC;CACtC;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-BvXxelGR.js","names":[],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport type * as McpModule from '@kubb/mcp'\nimport { buildTelemetryEvent, sendTelemetry } from '../../telemetry.ts'\n\ntype McpOptions = {\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n /**\n * TCP port for the HTTP MCP server. When `undefined`, the server uses stdio transport.\n */\n port?: string\n /**\n * Hostname to bind to when running in HTTP mode.\n *\n * @default 'localhost'\n */\n host?: string\n}\n\nexport async function run({ version, port, host }: McpOptions): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'mcp', kubbVersion: version, hrStart, status }))\n try {\n console.log(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n await startMcpServer(undefined, { port: port !== undefined ? Number(port) : undefined, host })\n await report('success')\n } catch (error) {\n await report('failed')\n console.error(getErrorMessage(error))\n }\n}\n"],"mappings":";;;;;;AAuBA,eAAsB,IAAI,EAAE,SAAS,MAAM,QAAmC;CAC5E,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAC9C,MAAM,UAAU,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiC,cAAc,oBAAoB;EAAE,SAAS;EAAO,aAAa;EAAS;EAAS;CAAO,CAAC,CAAC;CAC7I,IAAI;EACF,QAAQ,IAAI,UAAU,QAAQ,0BAA0B,CAAC;EACzD,QAAQ,KAAK,UAAU,UAAU,2DAA2D,CAAC;EAC7F,MAAM,eAAe,KAAA,GAAW;GAAE,MAAM,SAAS,KAAA,IAAY,OAAO,IAAI,IAAI,KAAA;GAAW;EAAK,CAAC;EAC7F,MAAM,OAAO,SAAS;CACxB,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,QAAQ,MAAM,gBAAgB,KAAK,CAAC;CACtC;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-Bz9IFMWg.cjs","names":["process","sendTelemetry","buildTelemetryEvent","getErrorMessage"],"sources":["../src/runners/validate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { buildTelemetryEvent, sendTelemetry } from '../../telemetry.ts'\n\ntype ValidateOptions = {\n /**\n * Path or URL to the OpenAPI/Swagger file to validate.\n */\n input: string\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n}\n\ntype ValidateModule = typeof import('@kubb/adapter-oas')\ntype ValidateDependencies = {\n /**\n * Loads `@kubb/adapter-oas`. Injected so tests can substitute a mock.\n */\n loadValidateModule: () => Promise<ValidateModule>\n}\n\n/**\n * Dynamically loads `@kubb/adapter-oas` for OpenAPI validation.\n */\nexport function loadValidateModule(): Promise<ValidateModule> {\n return import('@kubb/adapter-oas') as Promise<ValidateModule>\n}\n\n/**\n * Validates an OpenAPI/Swagger file at `input` using `@kubb/adapter-oas`.\n * Exits the process with code 1 on validation failure or missing dependency.\n */\nexport async function run({ input, version }: ValidateOptions, dependencies: ValidateDependencies = { loadValidateModule }): Promise<void> {\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status }))\n try {\n const { adapterOas } = await dependencies.loadValidateModule()\n const adapter = adapterOas()\n if (!adapter.validate) {\n throw new Error('The loaded adapter does not support validation.')\n }\n await adapter.validate(input, { throwOnError: true })\n await report('success')\n console.log('✅ Validation success')\n } catch (error) {\n await report('failed')\n if (error instanceof Error && /@kubb\\/adapter-oas/.test(error.message)) {\n console.error(styleText('red', 'The @kubb/adapter-oas package is not installed.'))\n console.error('')\n console.error('Install it with:')\n console.error(styleText('cyan', ' npm install @kubb/adapter-oas'))\n console.error(styleText('cyan', ' # or'))\n console.error(styleText('cyan', ' pnpm install @kubb/adapter-oas'))\n console.error('')\n }\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,qBAA8C;CAC5D,OAAO,OAAO;AAChB;;;;;AAMA,eAAsB,IAAI,EAAE,OAAO,WAA4B,eAAqC,EAAE,mBAAmB,GAAkB;CACzI,MAAM,UAAUA,aAAAA,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiCC,kBAAAA,cAAcC,kBAAAA,oBAAoB;EAAE,SAAS;EAAY,aAAa;EAAS;EAAS;CAAO,CAAC,CAAC;CAClJ,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,aAAa,mBAAmB;EAC7D,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,QAAQ,UACX,MAAM,IAAI,MAAM,iDAAiD;EAEnE,MAAM,QAAQ,SAAS,OAAO,EAAE,cAAc,KAAK,CAAC;EACpD,MAAM,OAAO,SAAS;EACtB,QAAQ,IAAI,sBAAsB;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,IAAI,iBAAiB,SAAS,qBAAqB,KAAK,MAAM,OAAO,GAAG;GACtE,QAAQ,OAAA,GAAA,UAAA,WAAgB,OAAO,iDAAiD,CAAC;GACjF,QAAQ,MAAM,EAAE;GAChB,QAAQ,MAAM,kBAAkB;GAChC,QAAQ,OAAA,GAAA,UAAA,WAAgB,QAAQ,iCAAiC,CAAC;GAClE,QAAQ,OAAA,GAAA,UAAA,WAAgB,QAAQ,QAAQ,CAAC;GACzC,QAAQ,OAAA,GAAA,UAAA,WAAgB,QAAQ,kCAAkC,CAAC;GACnE,QAAQ,MAAM,EAAE;EAClB;EACA,QAAQ,MAAM,qBAAqB;EACnC,QAAQ,MAAMC,eAAAA,gBAAgB,KAAK,CAAC;EACpC,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}