@kubb/cli 5.0.0-beta.38 → 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.
- package/dist/{agent-CfZ_Uqde.js → agent-CLspGfSn.js} +4 -4
- package/dist/{agent-CfZ_Uqde.js.map → agent-CLspGfSn.js.map} +1 -1
- package/dist/{agent-Bl8JwjMa.cjs → agent-RdNQgRXD.cjs} +4 -4
- package/dist/{agent-Bl8JwjMa.cjs.map → agent-RdNQgRXD.cjs.map} +1 -1
- package/dist/{constants-CYxk4aNm.js → constants-84a47qA-.js} +2 -6
- package/dist/constants-84a47qA-.js.map +1 -0
- package/dist/{constants-CAKUpLcQ.cjs → constants-BtmponZ3.cjs} +1 -11
- package/dist/constants-BtmponZ3.cjs.map +1 -0
- package/dist/{generate-Bgds6Zx3.cjs → generate-DK1pLJMi.cjs} +2 -2
- package/dist/{generate-Bgds6Zx3.cjs.map → generate-DK1pLJMi.cjs.map} +1 -1
- package/dist/{generate-CfxFqNeb.js → generate-Db0pJmbG.js} +2 -2
- package/dist/{generate-CfxFqNeb.js.map → generate-Db0pJmbG.js.map} +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/{init-TIec3Dym.js → init-DKMwmbmx.js} +2 -2
- package/dist/{init-TIec3Dym.js.map → init-DKMwmbmx.js.map} +1 -1
- package/dist/{init-C5wnuzeK.cjs → init-D_MQBDVz.cjs} +2 -2
- package/dist/{init-C5wnuzeK.cjs.map → init-D_MQBDVz.cjs.map} +1 -1
- package/dist/{mcp-Damue5Mq.js → mcp-DqNyN0cN.js} +3 -3
- package/dist/{mcp-Damue5Mq.js.map → mcp-DqNyN0cN.js.map} +1 -1
- package/dist/{mcp-Cr753GW1.cjs → mcp-DvEeDWlW.cjs} +3 -3
- package/dist/{mcp-Cr753GW1.cjs.map → mcp-DvEeDWlW.cjs.map} +1 -1
- package/dist/package-C8u_WvqI.js +6 -0
- package/dist/package-C8u_WvqI.js.map +1 -0
- package/dist/{package-guApEHiW.cjs → package-CusjBrSS.cjs} +2 -2
- package/dist/package-CusjBrSS.cjs.map +1 -0
- package/dist/{run-DJxYClJV.js → run-BQ3Qj0xB.js} +4 -4
- package/dist/run-BQ3Qj0xB.js.map +1 -0
- package/dist/{run-BvXxelGR.js → run-BQzoaxjR.js} +3 -3
- package/dist/run-BQzoaxjR.js.map +1 -0
- package/dist/{run-C752fag9.js → run-BabEDDqN.js} +128 -369
- package/dist/run-BabEDDqN.js.map +1 -0
- package/dist/{run-BFEK9md9.js → run-CGf0KEts.js} +3 -3
- package/dist/run-CGf0KEts.js.map +1 -0
- package/dist/{run-BFZtWpcW.cjs → run-CJUmJcbC.cjs} +128 -369
- package/dist/run-CJUmJcbC.cjs.map +1 -0
- package/dist/{run-Bz9IFMWg.cjs → run-CkTpemme.cjs} +3 -3
- package/dist/run-CkTpemme.cjs.map +1 -0
- package/dist/{run-BQZyg7If.cjs → run-Cl4SrSob.cjs} +3 -3
- package/dist/run-Cl4SrSob.cjs.map +1 -0
- package/dist/{run-BFv6avA_.cjs → run-D-s2LdlW.cjs} +5 -5
- package/dist/run-D-s2LdlW.cjs.map +1 -0
- package/dist/{validate-DMzjP-hd.cjs → validate-CkW_AKZp.cjs} +3 -3
- package/dist/{validate-DMzjP-hd.cjs.map → validate-CkW_AKZp.cjs.map} +1 -1
- package/dist/{validate-CYTKdezO.js → validate-jRewvR0c.js} +3 -3
- package/dist/{validate-CYTKdezO.js.map → validate-jRewvR0c.js.map} +1 -1
- package/package.json +7 -7
- package/src/constants.ts +0 -15
- package/src/index.ts +2 -2
- package/src/loggers/clackLogger.ts +4 -6
- package/src/loggers/githubActionsLogger.ts +3 -3
- package/src/loggers/plainLogger.ts +2 -3
- package/src/loggers/utils.ts +27 -32
- package/src/runners/agent/run.ts +2 -2
- package/src/runners/generate/run.ts +21 -17
- package/src/runners/mcp/run.ts +2 -2
- package/src/runners/validate/run.ts +2 -2
- package/dist/constants-CAKUpLcQ.cjs.map +0 -1
- package/dist/constants-CYxk4aNm.js.map +0 -1
- package/dist/package-Cnt1K03J.js +0 -6
- package/dist/package-Cnt1K03J.js.map +0 -1
- package/dist/package-guApEHiW.cjs.map +0 -1
- package/dist/run-BFEK9md9.js.map +0 -1
- package/dist/run-BFZtWpcW.cjs.map +0 -1
- package/dist/run-BFv6avA_.cjs.map +0 -1
- package/dist/run-BQZyg7If.cjs.map +0 -1
- package/dist/run-BvXxelGR.js.map +0 -1
- package/dist/run-Bz9IFMWg.cjs.map +0 -1
- package/dist/run-C752fag9.js.map +0 -1
- package/dist/run-DJxYClJV.js.map +0 -1
- package/dist/telemetry-B80oJfxR.cjs +0 -280
- package/dist/telemetry-B80oJfxR.cjs.map +0 -1
- package/dist/telemetry-ueaMzs_c.js +0 -243
- package/dist/telemetry-ueaMzs_c.js.map +0 -1
- package/src/loggers/diagnostics.ts +0 -77
- package/src/reporters/cliReporter.ts +0 -89
- package/src/reporters/fileReporter.ts +0 -103
- package/src/reporters/jsonReporter.ts +0 -20
- package/src/reporters/report.ts +0 -84
- 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,
|
|
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 (!
|
|
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 !==
|
|
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(
|
|
89
|
+
console.log(getMessage(Diagnostics.formatLines(diagnostic).join('\n')))
|
|
91
90
|
})
|
|
92
91
|
|
|
93
92
|
context.on('kubb:lifecycle:start', ({ version }) => {
|
package/src/loggers/utils.ts
CHANGED
|
@@ -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
|
|
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'
|
|
@@ -235,49 +232,47 @@ export function installReporter(context: LoggerContext, reporter: Reporter, ctx:
|
|
|
235
232
|
await reporter.report({ config, diagnostics, filesCreated, status, hrStart }, ctx)
|
|
236
233
|
})
|
|
237
234
|
|
|
238
|
-
if (reporter.
|
|
239
|
-
context.on('kubb:lifecycle:end', () => reporter.
|
|
235
|
+
if (reporter.drain) {
|
|
236
|
+
context.on('kubb:lifecycle:end', () => reporter.drain?.(ctx))
|
|
240
237
|
}
|
|
241
238
|
}
|
|
242
239
|
|
|
243
240
|
/**
|
|
244
|
-
* Installs the live logger (the TUI view) and the
|
|
245
|
-
* terminal logger's hook sink when one was installed.
|
|
246
|
-
*
|
|
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.
|
|
247
244
|
*
|
|
248
|
-
*
|
|
249
|
-
* `json`
|
|
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.
|
|
250
248
|
*/
|
|
251
|
-
|
|
249
|
+
async function setupReporters(
|
|
252
250
|
context: LoggerContext,
|
|
253
|
-
{ logLevel, reporters }: LoggerOptions & { reporters: ReadonlyArray<
|
|
251
|
+
{ logLevel, reporters }: LoggerOptions & { reporters: ReadonlyArray<Reporter> },
|
|
254
252
|
): Promise<HookSinkFactory | null> {
|
|
255
|
-
const
|
|
256
|
-
const hasJson = unique.has('json')
|
|
253
|
+
const hasJson = reporters.some((reporter) => reporter.name === 'json')
|
|
257
254
|
const ctx: ReporterContext = { logLevel }
|
|
258
255
|
|
|
259
256
|
let makeSink: HookSinkFactory | null = null
|
|
260
257
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
|
266
270
|
}
|
|
267
|
-
const sink = await logger.install(context, { logLevel })
|
|
268
|
-
makeSink = typeof sink === 'function' ? sink : null
|
|
269
|
-
installReporter(context, cliReporter, ctx)
|
|
270
|
-
}
|
|
271
271
|
|
|
272
|
-
|
|
273
|
-
// json aggregates across configs: report buffers each result and flush writes one array on
|
|
274
|
-
// lifecycle end, rather than printing per config (which would concatenate documents and break `jq .`).
|
|
275
|
-
installReporter(context, jsonReporter, ctx)
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if (unique.has('file')) {
|
|
279
|
-
installReporter(context, fileReporter, ctx)
|
|
272
|
+
installReporter(context, reporter, ctx)
|
|
280
273
|
}
|
|
281
274
|
|
|
282
275
|
return makeSink
|
|
283
276
|
}
|
|
277
|
+
|
|
278
|
+
export default setupReporters
|
package/src/runners/agent/run.ts
CHANGED
|
@@ -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') =>
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 (!
|
|
189
|
+
if (!Diagnostics.isProblem(diagnostic)) {
|
|
189
190
|
continue
|
|
190
191
|
}
|
|
191
|
-
const 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:
|
|
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:
|
|
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(
|
|
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: [
|
|
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`
|
|
357
|
-
|
|
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 (
|
|
378
|
+
if (config.input && 'path' in config.input && watch) {
|
|
375
379
|
await startWatcher(
|
|
376
380
|
[input || config.input.path],
|
|
377
381
|
async (paths) => {
|
package/src/runners/mcp/run.ts
CHANGED
|
@@ -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') =>
|
|
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 {
|
|
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') =>
|
|
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"}
|
package/dist/package-Cnt1K03J.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-Cnt1K03J.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-guApEHiW.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
package/dist/run-BFEK9md9.js.map
DELETED
|
@@ -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"}
|