@kubb/cli 5.2.7 → 5.3.0
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-DIDDCARm.js → Telemetry-CJcQkQOT.js} +2 -2
- package/dist/Telemetry-CJcQkQOT.js.map +1 -0
- package/dist/{Telemetry-C-y1OMHs.cjs → Telemetry-CvHQevSK.cjs} +4 -4
- package/dist/Telemetry-CvHQevSK.cjs.map +1 -0
- package/dist/agent-3JmkMghp.js +24 -0
- package/dist/agent-3JmkMghp.js.map +1 -0
- package/dist/agent-BPqs9VRj.cjs +36 -0
- package/dist/agent-BPqs9VRj.cjs.map +1 -0
- package/dist/{generate-Rb7ZSrZM.cjs → generate-CCjNi8-B.cjs} +6 -5
- package/dist/generate-CCjNi8-B.cjs.map +1 -0
- package/dist/{generate-DAszcRsb.js → generate-DnOsvKdA.js} +6 -5
- package/dist/generate-DnOsvKdA.js.map +1 -0
- package/dist/index.cjs +20 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -10
- package/dist/index.js.map +1 -1
- package/dist/{init-B2x0IqYy.cjs → init-BEZE-TU-.cjs} +3 -3
- package/dist/{init-B2x0IqYy.cjs.map → init-BEZE-TU-.cjs.map} +1 -1
- package/dist/{init-D4ZkBmLw.js → init-DFBbp97w.js} +3 -3
- package/dist/{init-D4ZkBmLw.js.map → init-DFBbp97w.js.map} +1 -1
- package/dist/{output-LZvrgF3z.js → output-DH2Uoy4x.js} +32 -3
- package/dist/output-DH2Uoy4x.js.map +1 -0
- package/dist/{output-B2V2MN_C.cjs → output-kmklyYIv.cjs} +42 -7
- package/dist/output-kmklyYIv.cjs.map +1 -0
- package/dist/package-DYdGw7-C.js +6 -0
- package/dist/package-DYdGw7-C.js.map +1 -0
- package/dist/{package-ALlJ_R7l.cjs → package-DgNWnCoo.cjs} +2 -2
- package/dist/package-DgNWnCoo.cjs.map +1 -0
- package/dist/{run-BWdOuixw.js → run-B1-xSKKe.js} +3 -3
- package/dist/{run-BWdOuixw.js.map → run-B1-xSKKe.js.map} +1 -1
- package/dist/{run-Dp_cu_Sq.cjs → run-BWahaRPU.cjs} +3 -3
- package/dist/{run-Dp_cu_Sq.cjs.map → run-BWahaRPU.cjs.map} +1 -1
- package/dist/{run-DH7L-NJ7.cjs → run-Bh9GxeT8.cjs} +6 -7
- package/dist/{run-DH7L-NJ7.cjs.map → run-Bh9GxeT8.cjs.map} +1 -1
- package/dist/{run-BCsAD0fU.cjs → run-BwMRCeWt.cjs} +3 -3
- package/dist/{run-BCsAD0fU.cjs.map → run-BwMRCeWt.cjs.map} +1 -1
- package/dist/{run-BxTAsxxj.cjs → run-CDLUop5s.cjs} +290 -32
- package/dist/run-CDLUop5s.cjs.map +1 -0
- package/dist/{run-oAiRfQ1w.js → run-CIkCVMy_.js} +3 -3
- package/dist/{run-oAiRfQ1w.js.map → run-CIkCVMy_.js.map} +1 -1
- package/dist/{run-DiZjX981.js → run-CZaUf7i2.js} +290 -32
- package/dist/run-CZaUf7i2.js.map +1 -0
- package/dist/{run-YTMp0zre.js → run-DiL672xB.js} +6 -7
- package/dist/{run-YTMp0zre.js.map → run-DiL672xB.js.map} +1 -1
- package/dist/{run-DRBqVXX0.cjs → run-VK50TiB7.cjs} +2 -2
- package/dist/{run-DRBqVXX0.cjs.map → run-VK50TiB7.cjs.map} +1 -1
- package/dist/{run-BzvsJ0Ek.js → run-kdxqOL8u.js} +2 -2
- package/dist/{run-BzvsJ0Ek.js.map → run-kdxqOL8u.js.map} +1 -1
- package/dist/{studio-PDMxqFN0.cjs → studio-BQV9CeZK.cjs} +32 -4
- package/dist/studio-BQV9CeZK.cjs.map +1 -0
- package/dist/{studio-DKv2YLJZ.js → studio-DUNPmQ5V.js} +32 -4
- package/dist/studio-DUNPmQ5V.js.map +1 -0
- package/dist/{utils-BgEQilnN.cjs → utils-CMU1rLfY.cjs} +22 -6
- package/dist/utils-CMU1rLfY.cjs.map +1 -0
- package/dist/{utils-VadUNZOm.js → utils-s6yetN6W.js} +21 -5
- package/dist/utils-s6yetN6W.js.map +1 -0
- package/package.json +7 -7
- package/dist/Telemetry-C-y1OMHs.cjs.map +0 -1
- package/dist/Telemetry-DIDDCARm.js.map +0 -1
- package/dist/env-DHaFBZTX.cjs +0 -82
- package/dist/env-DHaFBZTX.cjs.map +0 -1
- package/dist/env-DqPKEL59.js +0 -59
- package/dist/env-DqPKEL59.js.map +0 -1
- package/dist/generate-DAszcRsb.js.map +0 -1
- package/dist/generate-Rb7ZSrZM.cjs.map +0 -1
- package/dist/output-B2V2MN_C.cjs.map +0 -1
- package/dist/output-LZvrgF3z.js.map +0 -1
- package/dist/package-ALlJ_R7l.cjs.map +0 -1
- package/dist/package-CqrP-sja.js +0 -6
- package/dist/package-CqrP-sja.js.map +0 -1
- package/dist/run-BxTAsxxj.cjs.map +0 -1
- package/dist/run-DiZjX981.js.map +0 -1
- package/dist/studio-DKv2YLJZ.js.map +0 -1
- package/dist/studio-PDMxqFN0.cjs.map +0 -1
- package/dist/utils-BgEQilnN.cjs.map +0 -1
- package/dist/utils-VadUNZOm.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import {
|
|
2
|
+
import { n as isCIEnvironment, t as getAgentName } from "./agent-3JmkMghp.js";
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import process$1 from "node:process";
|
|
@@ -259,4 +259,4 @@ async function sendTelemetry(event) {
|
|
|
259
259
|
//#endregion
|
|
260
260
|
export { QUIET_FLAGS as a, URL_WATCHER_TIMEOUT_MS as c, KUBB_NPM_PACKAGE_URL as i, WATCHER_IGNORED_PATHS as l, isDisabled as n, UPDATE_CHECK_TIMEOUT_MS as o, sendTelemetry as r, URL_WATCHER_INTERVAL_MS as s, buildTelemetryEvent as t, runtime as u };
|
|
261
261
|
|
|
262
|
-
//# sourceMappingURL=Telemetry-
|
|
262
|
+
//# sourceMappingURL=Telemetry-CJcQkQOT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Telemetry-CJcQkQOT.js","names":["process"],"sources":["../../../internals/utils/src/runtime.ts","../src/constants.ts","../src/Telemetry.ts"],"sourcesContent":["/**\n * Name of the JavaScript runtime executing the current process.\n */\ntype RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Detects the JavaScript runtime executing the current process and exposes its name and version.\n *\n * Prefer the shared {@link runtime} instance over constructing your own.\n */\nclass Runtime {\n /**\n * `true` when the current process is running under Bun.\n *\n * Detection keys off the global `Bun` object rather than `process.versions`,\n * because Bun polyfills `process.versions.node` for Node compatibility and would\n * otherwise look like Node.\n *\n * @example\n * ```ts\n * if (runtime.isBun) {\n * await Bun.write(path, data)\n * }\n * ```\n */\n get isBun(): boolean {\n return typeof Bun !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Deno.\n */\n get isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Node.\n *\n * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.\n */\n get isNode(): boolean {\n return !this.isBun && !this.isDeno && typeof process !== 'undefined' && process.versions?.node != null\n }\n\n /**\n * Name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\n get name(): RuntimeName {\n if (this.isBun) return 'bun'\n if (this.isDeno) return 'deno'\n\n return 'node'\n }\n\n /**\n * Version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * runtime.version // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\n get version(): string {\n if (this.isBun) return process.versions.bun ?? ''\n if (this.isDeno) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n\n return process.versions?.node ?? ''\n }\n}\n\n/**\n * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.\n */\nexport const runtime = new Runtime()\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 * Glob pattern for paths the file watcher ignores.\n */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Quiet window in milliseconds that collapses a burst of watcher events (an editor save emits\n * several) into a single rebuild.\n */\nexport const WATCHER_DEBOUNCE_MS = 100\n\n/**\n * Interval in milliseconds between polls of a remote `input` URL in watch mode. A remote document\n * emits no filesystem events, so watch mode falls back to fetching it and comparing bodies.\n */\nexport const URL_WATCHER_INTERVAL_MS = 2_000\n\n/**\n * Upper bound in milliseconds for a single URL watcher request, covering both the response headers\n * and the body read. A server that hangs mid-response would otherwise stall polling forever.\n */\nexport const URL_WATCHER_TIMEOUT_MS = 10_000\n\n/**\n * Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run.\n */\nexport const UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/**\n * Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.\n */\nexport const QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v'])\n","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { isCIEnvironment, runtime } from '@internals/utils'\nimport { getAgentName } from './agent.ts'\nimport { OTLP_ENDPOINT } from './constants.ts'\n\ntype OtlpKeyValue = {\n key: string\n value:\n | { stringValue: string }\n | { boolValue: boolean }\n | { intValue: number }\n | { arrayValue: { values: Array<{ kvlistValue: { values: Array<OtlpKeyValue> } }> } }\n | { kvlistValue: { values: Array<OtlpKeyValue> } }\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n name: string\n kind: 1\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes: Array<OtlpKeyValue>\n status: { code: 1 | 2 }\n}\n\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: Array<{\n resource: { attributes: Array<OtlpKeyValue> }\n scopeSpans: Array<{\n scope: { name: string; version: string }\n spans: Array<OtlpSpan>\n }>\n }>\n}\n\n/**\n * Anonymous plugin name and options snapshot sent with each telemetry event.\n */\nexport type TelemetryPlugin = {\n /**\n * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.\n */\n name: string\n /**\n * Anonymized snapshot of the plugin options. Values are included but cannot be traced back to a user.\n */\n options: Record<string, unknown>\n}\n\n/**\n * Anonymous snapshot of a single Kubb run, built by {@link buildTelemetryEvent} and sent by {@link sendTelemetry}.\n */\ntype TelemetryEvent = {\n command: string\n kubbVersion: string\n /**\n * Major version of Node that executed the run, e.g. `'22'`.\n */\n nodeVersion: string\n /**\n * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.\n */\n runtime: string\n /**\n * Major version of the active runtime, e.g. `'1'` under Bun or `'22'` under Node.\n */\n runtimeVersion: string\n platform: string\n ci: boolean\n /**\n * Name of the detected AI coding agent (e.g. `'claude'`, `'cursor'`), when the CLI is invoked\n * by one. `undefined` when run by a human or an unrecognized caller.\n */\n agent?: string\n plugins: Array<TelemetryPlugin>\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\nexport function isDisabled(): boolean {\n return (\n process.env['DO_NOT_TRACK'] === '1' ||\n process.env['DO_NOT_TRACK'] === 'true' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === '1' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === 'true'\n )\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n */\nexport function buildTelemetryEvent(options: {\n command: 'generate' | 'mcp' | 'studio' | 'validate'\n kubbVersion: string\n plugins?: Array<TelemetryPlugin>\n hrStart: [number, number]\n filesCreated?: number\n status: 'success' | 'failed'\n}): TelemetryEvent {\n const [seconds, nanoseconds] = process.hrtime(options.hrStart)\n const duration = Math.round(seconds * 1000 + nanoseconds / 1e6)\n\n return {\n command: options.command,\n kubbVersion: options.kubbVersion,\n nodeVersion: process.versions.node.split('.')[0] as string,\n runtime: runtime.name,\n runtimeVersion: runtime.version.split('.')[0] as string,\n platform: os.platform(),\n ci: isCIEnvironment(),\n agent: getAgentName(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n\n/**\n * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.\n *\n * @see https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/\n */\nexport function buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest {\n const traceId = randomBytes(16).toString('hex')\n const spanId = randomBytes(8).toString('hex')\n const endTimeNs = BigInt(Date.now()) * 1_000_000n\n const startTimeNs = endTimeNs - BigInt(event.duration) * 1_000_000n\n\n const attributes: Array<OtlpKeyValue> = [\n { key: 'kubb.command', value: { stringValue: event.command } },\n { key: 'kubb.version', value: { stringValue: event.kubbVersion } },\n { key: 'kubb.node_version', value: { stringValue: event.nodeVersion } },\n { key: 'kubb.runtime', value: { stringValue: event.runtime } },\n { key: 'kubb.runtime_version', value: { stringValue: event.runtimeVersion } },\n { key: 'kubb.platform', value: { stringValue: event.platform } },\n { key: 'kubb.ci', value: { boolValue: event.ci } },\n ...(event.agent ? [{ key: 'kubb.agent', value: { stringValue: event.agent } }] : []),\n { key: 'kubb.files_created', value: { intValue: event.filesCreated } },\n { key: 'kubb.status', value: { stringValue: event.status } },\n {\n key: 'kubb.plugins',\n value: {\n arrayValue: {\n values: event.plugins.map((p) => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n {\n key: 'options',\n value: {\n stringValue: JSON.stringify({\n ...p.options,\n usedEnumNames: undefined,\n }),\n },\n },\n ],\n },\n })),\n },\n },\n },\n ]\n\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: 'kubb-core' } },\n {\n key: 'service.version',\n value: { stringValue: event.kubbVersion },\n },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-core', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: event.status === 'success' ? 1 : 2,\n },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and\n * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run. No file\n * paths, OpenAPI specs, or secrets are sent.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isDisabled()) {\n return\n }\n\n try {\n await fetch(`${OTLP_ENDPOINT}/v1/traces`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Kubb-Telemetry-Version': '1',\n 'Kubb-Telemetry-Source': 'kubb-core',\n },\n body: JSON.stringify(buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently, telemetry must never break the run\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA,IAAM,UAAN,MAAc;;;;;;;;;;;;;;;CAeZ,IAAI,QAAiB;EACnB,OAAO,OAAO,QAAQ;CACxB;;;;CAKA,IAAI,SAAkB;EACpB,OAAO,OAAQ,WAAkC,SAAS;CAC5D;;;;;;CAOA,IAAI,SAAkB;EACpB,OAAO,CAAC,KAAK,SAAS,CAAC,KAAK,UAAU,OAAO,YAAY,eAAe,QAAQ,UAAU,QAAQ;CACpG;;;;;;;;;CAUA,IAAI,OAAoB;EACtB,IAAI,KAAK,OAAO,OAAO;EACvB,IAAI,KAAK,QAAQ,OAAO;EAExB,OAAO;CACT;;;;;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a,MAAM,YAAY;GAC1C;GACA;IAAE,KAAK;IAA0B,OAAO,EAAE,aAAa,SAAS;GAAE;EACpE,EACF;EACA,YAAY,CACV;GACE,OAAO;IAAE,MAAM;IAAa,SAAS,MAAM;GAAY;GACvD,OAAO,CACL;IACE;IACA;IACA,MAAM,MAAM;IACZ,MAAM;IACN,mBAAmB,OAAO,WAAW;IACrC,iBAAiB,OAAO,SAAS;IACjC;IACA,QAAQ,EACN,MAAM,MAAM,WAAW,YAAY,IAAI,EACzC;GACF,CACF;EACF,CACF;CACF,CACF,EACF;AACF;;;;;;AAOA,eAAsB,cAAc,OAAsC;CACxE,IAAI,WAAW,GACb;CAGF,IAAI;EACF,MAAM,MAAM,GAAG,cAAc,aAAa;GACxC,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,0BAA0B;IAC1B,yBAAyB;GAC3B;GACA,MAAM,KAAK,UAAU,iBAAiB,KAAK,CAAC;GAC5C,QAAQ,YAAY,QAAQ,GAAK;EACnC,CAAC;CACH,SAAS,IAAI,CAEb;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-qbf5tadS.cjs");
|
|
2
|
-
const
|
|
2
|
+
const require_agent = require("./agent-BPqs9VRj.cjs");
|
|
3
3
|
let node_crypto = require("node:crypto");
|
|
4
4
|
let node_os = require("node:os");
|
|
5
5
|
node_os = require_rolldown_runtime.__toESM(node_os, 1);
|
|
@@ -132,8 +132,8 @@ function buildTelemetryEvent(options) {
|
|
|
132
132
|
runtime: runtime.name,
|
|
133
133
|
runtimeVersion: runtime.version.split(".")[0],
|
|
134
134
|
platform: node_os.default.platform(),
|
|
135
|
-
ci:
|
|
136
|
-
agent:
|
|
135
|
+
ci: require_agent.isCIEnvironment(),
|
|
136
|
+
agent: require_agent.getAgentName(),
|
|
137
137
|
plugins: options.plugins ?? [],
|
|
138
138
|
duration,
|
|
139
139
|
filesCreated: options.filesCreated ?? 0,
|
|
@@ -320,4 +320,4 @@ Object.defineProperty(exports, "sendTelemetry", {
|
|
|
320
320
|
}
|
|
321
321
|
});
|
|
322
322
|
|
|
323
|
-
//# sourceMappingURL=Telemetry-
|
|
323
|
+
//# sourceMappingURL=Telemetry-CvHQevSK.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Telemetry-CvHQevSK.cjs","names":["process","os","isCIEnvironment","getAgentName","randomBytes"],"sources":["../../../internals/utils/src/runtime.ts","../src/constants.ts","../src/Telemetry.ts"],"sourcesContent":["/**\n * Name of the JavaScript runtime executing the current process.\n */\ntype RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Detects the JavaScript runtime executing the current process and exposes its name and version.\n *\n * Prefer the shared {@link runtime} instance over constructing your own.\n */\nclass Runtime {\n /**\n * `true` when the current process is running under Bun.\n *\n * Detection keys off the global `Bun` object rather than `process.versions`,\n * because Bun polyfills `process.versions.node` for Node compatibility and would\n * otherwise look like Node.\n *\n * @example\n * ```ts\n * if (runtime.isBun) {\n * await Bun.write(path, data)\n * }\n * ```\n */\n get isBun(): boolean {\n return typeof Bun !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Deno.\n */\n get isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Node.\n *\n * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.\n */\n get isNode(): boolean {\n return !this.isBun && !this.isDeno && typeof process !== 'undefined' && process.versions?.node != null\n }\n\n /**\n * Name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\n get name(): RuntimeName {\n if (this.isBun) return 'bun'\n if (this.isDeno) return 'deno'\n\n return 'node'\n }\n\n /**\n * Version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * runtime.version // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\n get version(): string {\n if (this.isBun) return process.versions.bun ?? ''\n if (this.isDeno) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n\n return process.versions?.node ?? ''\n }\n}\n\n/**\n * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.\n */\nexport const runtime = new Runtime()\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 * Glob pattern for paths the file watcher ignores.\n */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Quiet window in milliseconds that collapses a burst of watcher events (an editor save emits\n * several) into a single rebuild.\n */\nexport const WATCHER_DEBOUNCE_MS = 100\n\n/**\n * Interval in milliseconds between polls of a remote `input` URL in watch mode. A remote document\n * emits no filesystem events, so watch mode falls back to fetching it and comparing bodies.\n */\nexport const URL_WATCHER_INTERVAL_MS = 2_000\n\n/**\n * Upper bound in milliseconds for a single URL watcher request, covering both the response headers\n * and the body read. A server that hangs mid-response would otherwise stall polling forever.\n */\nexport const URL_WATCHER_TIMEOUT_MS = 10_000\n\n/**\n * Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run.\n */\nexport const UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/**\n * Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.\n */\nexport const QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v'])\n","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { isCIEnvironment, runtime } from '@internals/utils'\nimport { getAgentName } from './agent.ts'\nimport { OTLP_ENDPOINT } from './constants.ts'\n\ntype OtlpKeyValue = {\n key: string\n value:\n | { stringValue: string }\n | { boolValue: boolean }\n | { intValue: number }\n | { arrayValue: { values: Array<{ kvlistValue: { values: Array<OtlpKeyValue> } }> } }\n | { kvlistValue: { values: Array<OtlpKeyValue> } }\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n name: string\n kind: 1\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes: Array<OtlpKeyValue>\n status: { code: 1 | 2 }\n}\n\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: Array<{\n resource: { attributes: Array<OtlpKeyValue> }\n scopeSpans: Array<{\n scope: { name: string; version: string }\n spans: Array<OtlpSpan>\n }>\n }>\n}\n\n/**\n * Anonymous plugin name and options snapshot sent with each telemetry event.\n */\nexport type TelemetryPlugin = {\n /**\n * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.\n */\n name: string\n /**\n * Anonymized snapshot of the plugin options. Values are included but cannot be traced back to a user.\n */\n options: Record<string, unknown>\n}\n\n/**\n * Anonymous snapshot of a single Kubb run, built by {@link buildTelemetryEvent} and sent by {@link sendTelemetry}.\n */\ntype TelemetryEvent = {\n command: string\n kubbVersion: string\n /**\n * Major version of Node that executed the run, e.g. `'22'`.\n */\n nodeVersion: string\n /**\n * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.\n */\n runtime: string\n /**\n * Major version of the active runtime, e.g. `'1'` under Bun or `'22'` under Node.\n */\n runtimeVersion: string\n platform: string\n ci: boolean\n /**\n * Name of the detected AI coding agent (e.g. `'claude'`, `'cursor'`), when the CLI is invoked\n * by one. `undefined` when run by a human or an unrecognized caller.\n */\n agent?: string\n plugins: Array<TelemetryPlugin>\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\nexport function isDisabled(): boolean {\n return (\n process.env['DO_NOT_TRACK'] === '1' ||\n process.env['DO_NOT_TRACK'] === 'true' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === '1' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === 'true'\n )\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n */\nexport function buildTelemetryEvent(options: {\n command: 'generate' | 'mcp' | 'studio' | 'validate'\n kubbVersion: string\n plugins?: Array<TelemetryPlugin>\n hrStart: [number, number]\n filesCreated?: number\n status: 'success' | 'failed'\n}): TelemetryEvent {\n const [seconds, nanoseconds] = process.hrtime(options.hrStart)\n const duration = Math.round(seconds * 1000 + nanoseconds / 1e6)\n\n return {\n command: options.command,\n kubbVersion: options.kubbVersion,\n nodeVersion: process.versions.node.split('.')[0] as string,\n runtime: runtime.name,\n runtimeVersion: runtime.version.split('.')[0] as string,\n platform: os.platform(),\n ci: isCIEnvironment(),\n agent: getAgentName(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n\n/**\n * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.\n *\n * @see https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/\n */\nexport function buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest {\n const traceId = randomBytes(16).toString('hex')\n const spanId = randomBytes(8).toString('hex')\n const endTimeNs = BigInt(Date.now()) * 1_000_000n\n const startTimeNs = endTimeNs - BigInt(event.duration) * 1_000_000n\n\n const attributes: Array<OtlpKeyValue> = [\n { key: 'kubb.command', value: { stringValue: event.command } },\n { key: 'kubb.version', value: { stringValue: event.kubbVersion } },\n { key: 'kubb.node_version', value: { stringValue: event.nodeVersion } },\n { key: 'kubb.runtime', value: { stringValue: event.runtime } },\n { key: 'kubb.runtime_version', value: { stringValue: event.runtimeVersion } },\n { key: 'kubb.platform', value: { stringValue: event.platform } },\n { key: 'kubb.ci', value: { boolValue: event.ci } },\n ...(event.agent ? [{ key: 'kubb.agent', value: { stringValue: event.agent } }] : []),\n { key: 'kubb.files_created', value: { intValue: event.filesCreated } },\n { key: 'kubb.status', value: { stringValue: event.status } },\n {\n key: 'kubb.plugins',\n value: {\n arrayValue: {\n values: event.plugins.map((p) => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n {\n key: 'options',\n value: {\n stringValue: JSON.stringify({\n ...p.options,\n usedEnumNames: undefined,\n }),\n },\n },\n ],\n },\n })),\n },\n },\n },\n ]\n\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: 'kubb-core' } },\n {\n key: 'service.version',\n value: { stringValue: event.kubbVersion },\n },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-core', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: event.status === 'success' ? 1 : 2,\n },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and\n * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run. No file\n * paths, OpenAPI specs, or secrets are sent.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isDisabled()) {\n return\n }\n\n try {\n await fetch(`${OTLP_ENDPOINT}/v1/traces`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Kubb-Telemetry-Version': '1',\n 'Kubb-Telemetry-Source': 'kubb-core',\n },\n body: JSON.stringify(buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently, telemetry must never break the run\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,IAAM,UAAN,MAAc;;;;;;;;;;;;;;;CAeZ,IAAI,QAAiB;EACnB,OAAO,OAAO,QAAQ;CACxB;;;;CAKA,IAAI,SAAkB;EACpB,OAAO,OAAQ,WAAkC,SAAS;CAC5D;;;;;;CAOA,IAAI,SAAkB;EACpB,OAAO,CAAC,KAAK,SAAS,CAAC,KAAK,UAAU,OAAO,Y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,aAAa,KAAK,UAAU;KAC1B,GAAG,EAAE;KACL,eAAe,KAAA;IACjB,CAAC,EACH;GACF,CACF,EACF,EACF,EAAE,EACJ,EACF;EACF;CACF;CAEA,OAAO,EACL,eAAe,CACb;EACE,UAAU,EACR,YAAY;GACV;IAAE,KAAK;IAAgB,OAAO,EAAE,aAAa,YAAY;GAAE;GAC3D;IACE,KAAK;IACL,OAAO,EAAE,aAAa,MAAM,YAAY;GAC1C;GACA;IAAE,KAAK;IAA0B,OAAO,EAAE,aAAa,SAAS;GAAE;EACpE,EACF;EACA,YAAY,CACV;GACE,OAAO;IAAE,MAAM;IAAa,SAAS,MAAM;GAAY;GACvD,OAAO,CACL;IACE;IACA;IACA,MAAM,MAAM;IACZ,MAAM;IACN,mBAAmB,OAAO,WAAW;IACrC,iBAAiB,OAAO,SAAS;IACjC;IACA,QAAQ,EACN,MAAM,MAAM,WAAW,YAAY,IAAI,EACzC;GACF,CACF;EACF,CACF;CACF,CACF,EACF;AACF;;;;;;AAOA,eAAsB,cAAc,OAAsC;CACxE,IAAI,WAAW,GACb;CAGF,IAAI;EACF,MAAM,MAAM,GAAG,cAAc,aAAa;GACxC,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,0BAA0B;IAC1B,yBAAyB;GAC3B;GACA,MAAM,KAAK,UAAU,iBAAiB,KAAK,CAAC;GAC5C,QAAQ,YAAY,QAAQ,GAAK;EACnC,CAAC;CACH,SAAS,IAAI,CAEb;AACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { getAgentProfile } from "gunshi/agent";
|
|
4
|
+
//#region ../../internals/utils/src/isCIEnvironment.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns `true` when a known CI provider has set its environment variable.
|
|
7
|
+
*/
|
|
8
|
+
function isCIEnvironment() {
|
|
9
|
+
return !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.BITBUCKET_BUILD_NUMBER || process.env.JENKINS_URL || process.env.CIRCLECI || process.env.TRAVIS || process.env.TEAMCITY_VERSION || process.env.BUILDKITE || process.env.TF_BUILD);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/agent.ts
|
|
13
|
+
/**
|
|
14
|
+
* Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,
|
|
15
|
+
* `'cursor'`). `undefined` when run by a human or an unrecognized caller.
|
|
16
|
+
*/
|
|
17
|
+
function getAgentName() {
|
|
18
|
+
const profile = getAgentProfile();
|
|
19
|
+
return profile.isAgent ? profile.name : void 0;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { isCIEnvironment as n, getAgentName as t };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=agent-3JmkMghp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-3JmkMghp.js","names":[],"sources":["../../../internals/utils/src/isCIEnvironment.ts","../src/agent.ts"],"sourcesContent":["import process from 'node:process'\n\n/**\n * Returns `true` when a known CI provider has set its environment variable.\n */\nexport function isCIEnvironment(): boolean {\n return !!(\n process.env.CI ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n","import { getAgentProfile } from 'gunshi/agent'\n\n/**\n * Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,\n * `'cursor'`). `undefined` when run by a human or an unrecognized caller.\n */\nexport function getAgentName(): string | undefined {\n const profile = getAgentProfile()\n return profile.isAgent ? profile.name : undefined\n}\n"],"mappings":";;;;;;;AAKA,SAAgB,kBAA2B;CACzC,OAAO,CAAC,EACN,QAAQ,IAAI,MACZ,QAAQ,IAAI,kBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI,0BACZ,QAAQ,IAAI,eACZ,QAAQ,IAAI,YACZ,QAAQ,IAAI,UACZ,QAAQ,IAAI,oBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI;AAEhB;;;;;;;ACZA,SAAgB,eAAmC;CACjD,MAAM,UAAU,gBAAgB;CAChC,OAAO,QAAQ,UAAU,QAAQ,OAAO,KAAA;AAC1C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-qbf5tadS.cjs");
|
|
2
|
+
let node_process = require("node:process");
|
|
3
|
+
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
4
|
+
let gunshi_agent = require("gunshi/agent");
|
|
5
|
+
//#region ../../internals/utils/src/isCIEnvironment.ts
|
|
6
|
+
/**
|
|
7
|
+
* Returns `true` when a known CI provider has set its environment variable.
|
|
8
|
+
*/
|
|
9
|
+
function isCIEnvironment() {
|
|
10
|
+
return !!(node_process.default.env.CI || node_process.default.env.GITHUB_ACTIONS || node_process.default.env.GITLAB_CI || node_process.default.env.BITBUCKET_BUILD_NUMBER || node_process.default.env.JENKINS_URL || node_process.default.env.CIRCLECI || node_process.default.env.TRAVIS || node_process.default.env.TEAMCITY_VERSION || node_process.default.env.BUILDKITE || node_process.default.env.TF_BUILD);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/agent.ts
|
|
14
|
+
/**
|
|
15
|
+
* Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,
|
|
16
|
+
* `'cursor'`). `undefined` when run by a human or an unrecognized caller.
|
|
17
|
+
*/
|
|
18
|
+
function getAgentName() {
|
|
19
|
+
const profile = (0, gunshi_agent.getAgentProfile)();
|
|
20
|
+
return profile.isAgent ? profile.name : void 0;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
Object.defineProperty(exports, "getAgentName", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return getAgentName;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "isCIEnvironment", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function() {
|
|
32
|
+
return isCIEnvironment;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=agent-BPqs9VRj.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-BPqs9VRj.cjs","names":["process","getAgentProfile"],"sources":["../../../internals/utils/src/isCIEnvironment.ts","../src/agent.ts"],"sourcesContent":["import process from 'node:process'\n\n/**\n * Returns `true` when a known CI provider has set its environment variable.\n */\nexport function isCIEnvironment(): boolean {\n return !!(\n process.env.CI ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n","import { getAgentProfile } from 'gunshi/agent'\n\n/**\n * Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,\n * `'cursor'`). `undefined` when run by a human or an unrecognized caller.\n */\nexport function getAgentName(): string | undefined {\n const profile = getAgentProfile()\n return profile.isAgent ? profile.name : undefined\n}\n"],"mappings":";;;;;;;;AAKA,SAAgB,kBAA2B;CACzC,OAAO,CAAC,EACNA,aAAAA,QAAQ,IAAI,MACZA,aAAAA,QAAQ,IAAI,kBACZA,aAAAA,QAAQ,IAAI,aACZA,aAAAA,QAAQ,IAAI,0BACZA,aAAAA,QAAQ,IAAI,eACZA,aAAAA,QAAQ,IAAI,YACZA,aAAAA,QAAQ,IAAI,UACZA,aAAAA,QAAQ,IAAI,oBACZA,aAAAA,QAAQ,IAAI,aACZA,aAAAA,QAAQ,IAAI;AAEhB;;;;;;;ACZA,SAAgB,eAAmC;CACjD,MAAM,WAAA,GAAUC,aAAAA,gBAAAA,CAAgB;CAChC,OAAO,QAAQ,UAAU,QAAQ,OAAO,KAAA;AAC1C"}
|
|
@@ -5,14 +5,15 @@ let _gunshi_plugin_dryrun = require("@gunshi/plugin-dryrun");
|
|
|
5
5
|
const REPORTER_NAMES = [
|
|
6
6
|
"cli",
|
|
7
7
|
"json",
|
|
8
|
-
"file"
|
|
8
|
+
"file",
|
|
9
|
+
"html"
|
|
9
10
|
];
|
|
10
11
|
/**
|
|
11
12
|
* Splits and validates the comma-separated `--reporter` value against the known reporter names.
|
|
12
13
|
*/
|
|
13
14
|
function parseReporters(value) {
|
|
14
15
|
const names = value.split(",").map((name) => name.trim()).filter(Boolean);
|
|
15
|
-
for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file (got "${name}")`);
|
|
16
|
+
for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file, html (got "${name}")`);
|
|
16
17
|
return names;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
@@ -78,14 +79,14 @@ const command = (0, gunshi.defineWithTypes)()({
|
|
|
78
79
|
reporter: {
|
|
79
80
|
type: "custom",
|
|
80
81
|
description: "Reporters that render the run, comma-separated. Overrides config.reporters",
|
|
81
|
-
metavar: "cli|json|file",
|
|
82
|
+
metavar: "cli|json|file|html",
|
|
82
83
|
parse: parseReporters
|
|
83
84
|
}
|
|
84
85
|
},
|
|
85
86
|
async run(ctx) {
|
|
86
87
|
const { values } = ctx;
|
|
87
88
|
const logLevel = resolveLogLevel(values);
|
|
88
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
89
|
+
const { run } = await Promise.resolve().then(() => require("./run-Bh9GxeT8.cjs"));
|
|
89
90
|
await run({
|
|
90
91
|
input: values.input,
|
|
91
92
|
configPath: values.config,
|
|
@@ -99,4 +100,4 @@ const command = (0, gunshi.defineWithTypes)()({
|
|
|
99
100
|
//#endregion
|
|
100
101
|
exports.command = command;
|
|
101
102
|
|
|
102
|
-
//# sourceMappingURL=generate-
|
|
103
|
+
//# sourceMappingURL=generate-CCjNi8-B.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-CCjNi8-B.cjs","names":["defineWithTypes","dryRunId"],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { defineWithTypes } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\nimport { dryRunId } from '../gunshiDryRun.ts'\nimport type { DryRunExtensions } from '../gunshiDryRun.ts'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file', 'html']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Error(`must be one of cli, json, file, html (got \"${name}\")`)\n }\n }\n\n return names as Array<ReporterName>\n}\n\n/**\n * Resolves the effective log level, letting the `--verbose` and `--silent` flags win over `--logLevel`.\n */\nfunction resolveLogLevel({ verbose, silent, logLevel }: { verbose: boolean; silent: boolean; logLevel: string }): string {\n if (verbose) return 'verbose'\n if (silent) return 'silent'\n return logLevel\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\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 examples: [\n 'kubb generate # generate from kubb.config.ts',\n 'kubb generate ./openapi.yaml # generate from this spec instead of the config input',\n 'kubb generate --config kubb.config.ts',\n 'kubb generate --watch # regenerate whenever the spec changes',\n 'kubb generate --dryRun # preview the run without writing files',\n 'kubb studio # connect this project to Kubb Studio and generate from the browser',\n 'kubb studio --allowWrite # let Studio write the generated files to disk',\n 'kubb studio login # pair this machine with Studio without connecting',\n ].join('\\n'),\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode: watches an input file for changes, or polls an input URL',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\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: 'custom',\n description: 'Reporters that render the run, comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file|html',\n parse: parseReporters,\n },\n },\n async run(ctx) {\n const { values } = ctx\n const logLevel = resolveLogLevel(values)\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: values.input,\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n dryRun: ctx.extensions[dryRunId].enabled,\n })\n },\n})\n"],"mappings":";;;;AAKA,MAAM,iBAAsC;CAAC;CAAO;CAAQ;CAAQ;AAAM;;;;AAK1E,SAAS,eAAe,OAAoC;CAC1D,MAAM,QAAQ,MACX,MAAM,GAAG,CAAC,CACV,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,OAAO,OAAO;CAEjB,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,eAAe,SAAS,IAAoB,GAC/C,MAAM,IAAI,MAAM,8CAA8C,KAAK,GAAG;CAI1E,OAAO;AACT;;;;AAKA,SAAS,gBAAgB,EAAE,SAAS,QAAQ,YAA6E;CACvH,IAAI,SAAS,OAAO;CACpB,IAAI,QAAQ,OAAO;CACnB,OAAO;AACT;AAEA,MAAa,WAAA,GAAUA,OAAAA,gBAAAA,CAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,OAAO;GACL,MAAM;GACN,UAAU;GACV,aAAa;EACf;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;EACT;EACA,UAAU;GACR,MAAM;GACN,SAAS;IAAC;IAAU;IAAQ;GAAS;GACrC,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aAAa;GACb,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,UAAU;GACR,MAAM;GACN,aAAa;GACb,SAAS;GACT,OAAO;EACT;CACF;CACA,MAAM,IAAI,KAAK;EACb,MAAM,EAAE,WAAW;EACnB,MAAM,WAAW,gBAAgB,MAAM;EACvC,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,OAAO,OAAO;GACd,YAAY,OAAO;GACnB;GACA,OAAO,OAAO;GACd,WAAW,OAAO;GAClB,QAAQ,IAAI,WAAWC,sBAAAA,SAAS,CAAC;EACnC,CAAC;CACH;AACF,CAAC"}
|
|
@@ -5,14 +5,15 @@ import { defineWithTypes } from "gunshi";
|
|
|
5
5
|
const REPORTER_NAMES = [
|
|
6
6
|
"cli",
|
|
7
7
|
"json",
|
|
8
|
-
"file"
|
|
8
|
+
"file",
|
|
9
|
+
"html"
|
|
9
10
|
];
|
|
10
11
|
/**
|
|
11
12
|
* Splits and validates the comma-separated `--reporter` value against the known reporter names.
|
|
12
13
|
*/
|
|
13
14
|
function parseReporters(value) {
|
|
14
15
|
const names = value.split(",").map((name) => name.trim()).filter(Boolean);
|
|
15
|
-
for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file (got "${name}")`);
|
|
16
|
+
for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file, html (got "${name}")`);
|
|
16
17
|
return names;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
@@ -78,14 +79,14 @@ const command = defineWithTypes()({
|
|
|
78
79
|
reporter: {
|
|
79
80
|
type: "custom",
|
|
80
81
|
description: "Reporters that render the run, comma-separated. Overrides config.reporters",
|
|
81
|
-
metavar: "cli|json|file",
|
|
82
|
+
metavar: "cli|json|file|html",
|
|
82
83
|
parse: parseReporters
|
|
83
84
|
}
|
|
84
85
|
},
|
|
85
86
|
async run(ctx) {
|
|
86
87
|
const { values } = ctx;
|
|
87
88
|
const logLevel = resolveLogLevel(values);
|
|
88
|
-
const { run } = await import("./run-
|
|
89
|
+
const { run } = await import("./run-DiL672xB.js");
|
|
89
90
|
await run({
|
|
90
91
|
input: values.input,
|
|
91
92
|
configPath: values.config,
|
|
@@ -99,4 +100,4 @@ const command = defineWithTypes()({
|
|
|
99
100
|
//#endregion
|
|
100
101
|
export { command };
|
|
101
102
|
|
|
102
|
-
//# sourceMappingURL=generate-
|
|
103
|
+
//# sourceMappingURL=generate-DnOsvKdA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-DnOsvKdA.js","names":[],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { defineWithTypes } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\nimport { dryRunId } from '../gunshiDryRun.ts'\nimport type { DryRunExtensions } from '../gunshiDryRun.ts'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file', 'html']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Error(`must be one of cli, json, file, html (got \"${name}\")`)\n }\n }\n\n return names as Array<ReporterName>\n}\n\n/**\n * Resolves the effective log level, letting the `--verbose` and `--silent` flags win over `--logLevel`.\n */\nfunction resolveLogLevel({ verbose, silent, logLevel }: { verbose: boolean; silent: boolean; logLevel: string }): string {\n if (verbose) return 'verbose'\n if (silent) return 'silent'\n return logLevel\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\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 examples: [\n 'kubb generate # generate from kubb.config.ts',\n 'kubb generate ./openapi.yaml # generate from this spec instead of the config input',\n 'kubb generate --config kubb.config.ts',\n 'kubb generate --watch # regenerate whenever the spec changes',\n 'kubb generate --dryRun # preview the run without writing files',\n 'kubb studio # connect this project to Kubb Studio and generate from the browser',\n 'kubb studio --allowWrite # let Studio write the generated files to disk',\n 'kubb studio login # pair this machine with Studio without connecting',\n ].join('\\n'),\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode: watches an input file for changes, or polls an input URL',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\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: 'custom',\n description: 'Reporters that render the run, comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file|html',\n parse: parseReporters,\n },\n },\n async run(ctx) {\n const { values } = ctx\n const logLevel = resolveLogLevel(values)\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: values.input,\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n dryRun: ctx.extensions[dryRunId].enabled,\n })\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AO;GAClB,QAAQ,IAAI,WAAW,SAAS,CAAC;EACnC,CAAC;CACH;AACF,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rolldown_runtime = require("./rolldown-runtime-qbf5tadS.cjs");
|
|
3
|
-
const require_Telemetry = require("./Telemetry-
|
|
4
|
-
const require_package = require("./package-
|
|
3
|
+
const require_Telemetry = require("./Telemetry-CvHQevSK.cjs");
|
|
4
|
+
const require_package = require("./package-DgNWnCoo.cjs");
|
|
5
5
|
let node_util = require("node:util");
|
|
6
6
|
let _gunshi_plugin_dryrun = require("@gunshi/plugin-dryrun");
|
|
7
7
|
_gunshi_plugin_dryrun = require_rolldown_runtime.__toESM(_gunshi_plugin_dryrun, 1);
|
|
@@ -17,22 +17,31 @@ function stripExecArgs(argv) {
|
|
|
17
17
|
return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
+
* Whether this run is `kubb studio snapshot --json`, which must print exactly one JSON object on
|
|
21
|
+
* stdout so a script can parse it. The telemetry notice and gunshi's own header both write to
|
|
22
|
+
* stdout by default, so both are suppressed for this one invocation shape.
|
|
23
|
+
*/
|
|
24
|
+
function isSnapshotJson(args) {
|
|
25
|
+
return args[0] === "studio" && args[1] === "snapshot" && args.includes("--json");
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
20
28
|
* Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a
|
|
21
29
|
* quiet flag is passed, then runs the generate, validate, mcp, studio, and init commands. Defaults to
|
|
22
30
|
* `generate` when no command is given.
|
|
23
31
|
*/
|
|
24
32
|
async function run(argv = process.argv) {
|
|
25
|
-
const
|
|
33
|
+
const args = stripExecArgs(argv);
|
|
34
|
+
const isQuietFlag = args.some((arg) => require_Telemetry.QUIET_FLAGS.has(arg)) || isSnapshotJson(args);
|
|
26
35
|
if (!require_Telemetry.isDisabled() && !isQuietFlag) console.log(`${(0, node_util.styleText)("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${(0, node_util.styleText)("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
|
|
27
|
-
const { command: generateCommand } = await Promise.resolve().then(() => require("./generate-
|
|
28
|
-
const { command: initCommand } = await Promise.resolve().then(() => require("./init-
|
|
36
|
+
const { command: generateCommand } = await Promise.resolve().then(() => require("./generate-CCjNi8-B.cjs"));
|
|
37
|
+
const { command: initCommand } = await Promise.resolve().then(() => require("./init-BEZE-TU-.cjs"));
|
|
29
38
|
const { definition: validateDefinition } = await Promise.resolve().then(() => require("./validate-BcB0tFQ6.cjs"));
|
|
30
|
-
const validateCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-
|
|
39
|
+
const validateCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-BwMRCeWt.cjs"))).runner, validateDefinition);
|
|
31
40
|
const { definition: mcpDefinition } = await Promise.resolve().then(() => require("./mcp-B3B-rE7W.cjs"));
|
|
32
|
-
const mcpCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-
|
|
33
|
-
const { definition: studioDefinition } = await Promise.resolve().then(() => require("./studio-
|
|
34
|
-
const studioCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-
|
|
35
|
-
await (0, gunshi.cli)(
|
|
41
|
+
const mcpCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-BWahaRPU.cjs"))).runner, mcpDefinition);
|
|
42
|
+
const { definition: studioDefinition } = await Promise.resolve().then(() => require("./studio-BQV9CeZK.cjs"));
|
|
43
|
+
const studioCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-CDLUop5s.cjs"))).runner, studioDefinition);
|
|
44
|
+
await (0, gunshi.cli)(args, generateCommand, {
|
|
36
45
|
name: "kubb",
|
|
37
46
|
version: require_package.version,
|
|
38
47
|
description: "Generate code from an OpenAPI specification, or connect the project to Kubb Studio.",
|
|
@@ -46,6 +55,7 @@ async function run(argv = process.argv) {
|
|
|
46
55
|
fallbackToEntry: true,
|
|
47
56
|
strict: true,
|
|
48
57
|
plugins: [(0, _gunshi_plugin_dryrun.default)()],
|
|
58
|
+
...isSnapshotJson(args) ? { renderHeader: null } : {},
|
|
49
59
|
onErrorCommand: async (_ctx, error) => {
|
|
50
60
|
process.exitCode = 1;
|
|
51
61
|
console.error(error);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["QUIET_FLAGS","isTelemetryDisabled","styleText","lazy","cli","dryrun"],"sources":["../src/index.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport dryrun from '@gunshi/plugin-dryrun'\nimport { cli, lazy } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\n\n/**\n * Strips the leading executable + script entries when `process.argv` is passed directly.\n * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime\n * executable paths contain a path separator; bare command names do not.\n */\nfunction stripExecArgs(argv: Array<string>): Array<string> {\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n}\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the generate, validate, mcp, studio, and init commands. Defaults to\n * `generate` when no command is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const isQuietFlag =
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["QUIET_FLAGS","isTelemetryDisabled","styleText","lazy","cli","dryrun"],"sources":["../src/index.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport dryrun from '@gunshi/plugin-dryrun'\nimport { cli, lazy } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\n\n/**\n * Strips the leading executable + script entries when `process.argv` is passed directly.\n * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime\n * executable paths contain a path separator; bare command names do not.\n */\nfunction stripExecArgs(argv: Array<string>): Array<string> {\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n}\n\n/**\n * Whether this run is `kubb studio snapshot --json`, which must print exactly one JSON object on\n * stdout so a script can parse it. The telemetry notice and gunshi's own header both write to\n * stdout by default, so both are suppressed for this one invocation shape.\n */\nfunction isSnapshotJson(args: Array<string>): boolean {\n return args[0] === 'studio' && args[1] === 'snapshot' && args.includes('--json')\n}\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the generate, validate, mcp, studio, and init commands. Defaults to\n * `generate` when no command is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const args = stripExecArgs(argv)\n const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg)) || isSnapshotJson(args)\n\n if (!isTelemetryDisabled() && !isQuietFlag) {\n console.log(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n const { command: generateCommand } = await import('./commands/generate.ts')\n const { command: initCommand } = await import('./commands/init.ts')\n // Each runner pulls in an optional peer (@kubb/adapter-oas, @kubb/mcp, @kubb/studio), so it\n // loads only when its command runs.\n const { definition: validateDefinition } = await import('./commands/validate.ts')\n const validateCommand = lazy(async () => (await import('./runners/validate/run.ts')).runner, validateDefinition)\n const { definition: mcpDefinition } = await import('./commands/mcp.ts')\n const mcpCommand = lazy(async () => (await import('./runners/mcp/run.ts')).runner, mcpDefinition)\n const { definition: studioDefinition } = await import('./commands/studio.ts')\n const studioCommand = lazy(async () => (await import('./runners/studio/run.ts')).runner, studioDefinition)\n\n await cli(args, generateCommand, {\n name: 'kubb',\n version,\n // Not `generateCommand.description`: gunshi prints this on every subcommand's help too, so\n // `kubb studio --help` would open with a paragraph about generating types.\n description: 'Generate code from an OpenAPI specification, or connect the project to Kubb Studio.',\n subCommands: {\n generate: generateCommand,\n init: initCommand,\n validate: validateCommand,\n mcp: mcpCommand,\n studio: studioCommand,\n },\n fallbackToEntry: true,\n strict: true,\n plugins: [dryrun()],\n // `snapshot --json` owns stdout: gunshi's default header would otherwise print ahead of it.\n ...(isSnapshotJson(args) ? { renderHeader: null } : {}),\n onErrorCommand: async (_ctx, error) => {\n process.exitCode = 1\n console.error(error)\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAS,cAAc,MAAoC;CACzD,MAAM,4BAA4B,KAAK,EAAE,EAAE,SAAS,GAAG,KAAK,KAAK,EAAE,EAAE,SAAS,IAAI,MAAM;CACxF,OAAO,KAAK,UAAU,KAAK,2BAA2B,KAAK,MAAM,CAAC,IAAI;AACxE;;;;;;AAOA,SAAS,eAAe,MAA8B;CACpD,OAAO,KAAK,OAAO,YAAY,KAAK,OAAO,cAAc,KAAK,SAAS,QAAQ;AACjF;;;;;;AAOA,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;CAC3E,MAAM,OAAO,cAAc,IAAI;CAC/B,MAAM,cAAc,KAAK,MAAM,QAAQA,kBAAAA,YAAY,IAAI,GAAG,CAAC,KAAK,eAAe,IAAI;CAEnF,IAAI,CAACC,kBAAAA,WAAoB,KAAK,CAAC,aAC7B,QAAQ,IACN,IAAA,GAAGC,UAAAA,UAAAA,CAAU,UAAU,SAAS,EAAE,wIAAA,GAAuIA,UAAAA,UAAA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ACrC,QAAQ,WAAW;GACnB,QAAQ,MAAM,KAAK;EACrB;CACF,CAAC;AACH"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { a as QUIET_FLAGS, n as isDisabled } from "./Telemetry-
|
|
3
|
-
import { t as version } from "./package-
|
|
2
|
+
import { a as QUIET_FLAGS, n as isDisabled } from "./Telemetry-CJcQkQOT.js";
|
|
3
|
+
import { t as version } from "./package-DYdGw7-C.js";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import dryrun from "@gunshi/plugin-dryrun";
|
|
6
6
|
import { cli, lazy } from "gunshi";
|
|
@@ -15,22 +15,31 @@ function stripExecArgs(argv) {
|
|
|
15
15
|
return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
+
* Whether this run is `kubb studio snapshot --json`, which must print exactly one JSON object on
|
|
19
|
+
* stdout so a script can parse it. The telemetry notice and gunshi's own header both write to
|
|
20
|
+
* stdout by default, so both are suppressed for this one invocation shape.
|
|
21
|
+
*/
|
|
22
|
+
function isSnapshotJson(args) {
|
|
23
|
+
return args[0] === "studio" && args[1] === "snapshot" && args.includes("--json");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
18
26
|
* Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a
|
|
19
27
|
* quiet flag is passed, then runs the generate, validate, mcp, studio, and init commands. Defaults to
|
|
20
28
|
* `generate` when no command is given.
|
|
21
29
|
*/
|
|
22
30
|
async function run(argv = process.argv) {
|
|
23
|
-
const
|
|
31
|
+
const args = stripExecArgs(argv);
|
|
32
|
+
const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg)) || isSnapshotJson(args);
|
|
24
33
|
if (!isDisabled() && !isQuietFlag) console.log(`${styleText("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${styleText("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
|
|
25
|
-
const { command: generateCommand } = await import("./generate-
|
|
26
|
-
const { command: initCommand } = await import("./init-
|
|
34
|
+
const { command: generateCommand } = await import("./generate-DnOsvKdA.js");
|
|
35
|
+
const { command: initCommand } = await import("./init-DFBbp97w.js");
|
|
27
36
|
const { definition: validateDefinition } = await import("./validate-QpkCbIFJ.js");
|
|
28
|
-
const validateCommand = lazy(async () => (await import("./run-
|
|
37
|
+
const validateCommand = lazy(async () => (await import("./run-B1-xSKKe.js")).runner, validateDefinition);
|
|
29
38
|
const { definition: mcpDefinition } = await import("./mcp-B-GxGgVr.js");
|
|
30
|
-
const mcpCommand = lazy(async () => (await import("./run-
|
|
31
|
-
const { definition: studioDefinition } = await import("./studio-
|
|
32
|
-
const studioCommand = lazy(async () => (await import("./run-
|
|
33
|
-
await cli(
|
|
39
|
+
const mcpCommand = lazy(async () => (await import("./run-CIkCVMy_.js")).runner, mcpDefinition);
|
|
40
|
+
const { definition: studioDefinition } = await import("./studio-DUNPmQ5V.js");
|
|
41
|
+
const studioCommand = lazy(async () => (await import("./run-CZaUf7i2.js")).runner, studioDefinition);
|
|
42
|
+
await cli(args, generateCommand, {
|
|
34
43
|
name: "kubb",
|
|
35
44
|
version,
|
|
36
45
|
description: "Generate code from an OpenAPI specification, or connect the project to Kubb Studio.",
|
|
@@ -44,6 +53,7 @@ async function run(argv = process.argv) {
|
|
|
44
53
|
fallbackToEntry: true,
|
|
45
54
|
strict: true,
|
|
46
55
|
plugins: [dryrun()],
|
|
56
|
+
...isSnapshotJson(args) ? { renderHeader: null } : {},
|
|
47
57
|
onErrorCommand: async (_ctx, error) => {
|
|
48
58
|
process.exitCode = 1;
|
|
49
59
|
console.error(error);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isTelemetryDisabled"],"sources":["../src/index.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport dryrun from '@gunshi/plugin-dryrun'\nimport { cli, lazy } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\n\n/**\n * Strips the leading executable + script entries when `process.argv` is passed directly.\n * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime\n * executable paths contain a path separator; bare command names do not.\n */\nfunction stripExecArgs(argv: Array<string>): Array<string> {\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n}\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the generate, validate, mcp, studio, and init commands. Defaults to\n * `generate` when no command is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const isQuietFlag =
|
|
1
|
+
{"version":3,"file":"index.js","names":["isTelemetryDisabled"],"sources":["../src/index.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport dryrun from '@gunshi/plugin-dryrun'\nimport { cli, lazy } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\n\n/**\n * Strips the leading executable + script entries when `process.argv` is passed directly.\n * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime\n * executable paths contain a path separator; bare command names do not.\n */\nfunction stripExecArgs(argv: Array<string>): Array<string> {\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n}\n\n/**\n * Whether this run is `kubb studio snapshot --json`, which must print exactly one JSON object on\n * stdout so a script can parse it. The telemetry notice and gunshi's own header both write to\n * stdout by default, so both are suppressed for this one invocation shape.\n */\nfunction isSnapshotJson(args: Array<string>): boolean {\n return args[0] === 'studio' && args[1] === 'snapshot' && args.includes('--json')\n}\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the generate, validate, mcp, studio, and init commands. Defaults to\n * `generate` when no command is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const args = stripExecArgs(argv)\n const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg)) || isSnapshotJson(args)\n\n if (!isTelemetryDisabled() && !isQuietFlag) {\n console.log(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n const { command: generateCommand } = await import('./commands/generate.ts')\n const { command: initCommand } = await import('./commands/init.ts')\n // Each runner pulls in an optional peer (@kubb/adapter-oas, @kubb/mcp, @kubb/studio), so it\n // loads only when its command runs.\n const { definition: validateDefinition } = await import('./commands/validate.ts')\n const validateCommand = lazy(async () => (await import('./runners/validate/run.ts')).runner, validateDefinition)\n const { definition: mcpDefinition } = await import('./commands/mcp.ts')\n const mcpCommand = lazy(async () => (await import('./runners/mcp/run.ts')).runner, mcpDefinition)\n const { definition: studioDefinition } = await import('./commands/studio.ts')\n const studioCommand = lazy(async () => (await import('./runners/studio/run.ts')).runner, studioDefinition)\n\n await cli(args, generateCommand, {\n name: 'kubb',\n version,\n // Not `generateCommand.description`: gunshi prints this on every subcommand's help too, so\n // `kubb studio --help` would open with a paragraph about generating types.\n description: 'Generate code from an OpenAPI specification, or connect the project to Kubb Studio.',\n subCommands: {\n generate: generateCommand,\n init: initCommand,\n validate: validateCommand,\n mcp: mcpCommand,\n studio: studioCommand,\n },\n fallbackToEntry: true,\n strict: true,\n plugins: [dryrun()],\n // `snapshot --json` owns stdout: gunshi's default header would otherwise print ahead of it.\n ...(isSnapshotJson(args) ? { renderHeader: null } : {}),\n on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;EACV;EACA,iBAAiB;EACjB,QAAQ;EACR,SAAS,CAAC,OAAO,CAAC;EAElB,GAAI,eAAe,IAAI,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;EACrD,gBAAgB,OAAO,MAAM,UAAU;GACrC,QAAQ,WAAW;GACnB,QAAQ,MAAM,KAAK;EACrB;CACF,CAAC;AACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./rolldown-runtime-qbf5tadS.cjs");
|
|
2
|
-
const require_package = require("./package-
|
|
2
|
+
const require_package = require("./package-DgNWnCoo.cjs");
|
|
3
3
|
let gunshi = require("gunshi");
|
|
4
4
|
let _gunshi_plugin_dryrun = require("@gunshi/plugin-dryrun");
|
|
5
5
|
//#region src/commands/init.ts
|
|
@@ -40,7 +40,7 @@ const command = (0, gunshi.defineWithTypes)()({
|
|
|
40
40
|
},
|
|
41
41
|
async run(ctx) {
|
|
42
42
|
const { values } = ctx;
|
|
43
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
43
|
+
const { run } = await Promise.resolve().then(() => require("./run-VK50TiB7.cjs"));
|
|
44
44
|
await run({
|
|
45
45
|
yes: values.yes,
|
|
46
46
|
version: require_package.version,
|
|
@@ -54,4 +54,4 @@ const command = (0, gunshi.defineWithTypes)()({
|
|
|
54
54
|
//#endregion
|
|
55
55
|
exports.command = command;
|
|
56
56
|
|
|
57
|
-
//# sourceMappingURL=init-
|
|
57
|
+
//# sourceMappingURL=init-BEZE-TU-.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-
|
|
1
|
+
{"version":3,"file":"init-BEZE-TU-.cjs","names":["defineWithTypes","dryRunId"],"sources":["../src/commands/init.ts"],"sourcesContent":["import { defineWithTypes } from 'gunshi'\nimport { dryRunId } from '../gunshiDryRun.ts'\nimport type { DryRunExtensions } from '../gunshiDryRun.ts'\nimport { version } from '../../package.json'\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dryRun',\n ].join('\\n'),\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run(ctx) {\n const { values } = ctx\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n dryRun: ctx.extensions[dryRunId],\n })\n },\n})\n"],"mappings":";;;;;AAKA,MAAa,WAAA,GAAUA,OAAAA,gBAAAA,CAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,IAAI,KAAK;EACb,MAAM,EAAE,WAAW;EACnB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,KAAK,OAAO;GACZ,SAAA,gBAAA;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;GAChB,QAAQ,IAAI,WAAWC,sBAAAA;EACzB,CAAC;CACH;AACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { t as version } from "./package-
|
|
2
|
+
import { t as version } from "./package-DYdGw7-C.js";
|
|
3
3
|
import { t as dryRunId } from "./gunshiDryRun-DdKJuVn1.js";
|
|
4
4
|
import { defineWithTypes } from "gunshi";
|
|
5
5
|
//#region src/commands/init.ts
|
|
@@ -40,7 +40,7 @@ const command = defineWithTypes()({
|
|
|
40
40
|
},
|
|
41
41
|
async run(ctx) {
|
|
42
42
|
const { values } = ctx;
|
|
43
|
-
const { run } = await import("./run-
|
|
43
|
+
const { run } = await import("./run-kdxqOL8u.js");
|
|
44
44
|
await run({
|
|
45
45
|
yes: values.yes,
|
|
46
46
|
version,
|
|
@@ -54,4 +54,4 @@ const command = defineWithTypes()({
|
|
|
54
54
|
//#endregion
|
|
55
55
|
export { command };
|
|
56
56
|
|
|
57
|
-
//# sourceMappingURL=init-
|
|
57
|
+
//# sourceMappingURL=init-DFBbp97w.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-
|
|
1
|
+
{"version":3,"file":"init-DFBbp97w.js","names":[],"sources":["../src/commands/init.ts"],"sourcesContent":["import { defineWithTypes } from 'gunshi'\nimport { dryRunId } from '../gunshiDryRun.ts'\nimport type { DryRunExtensions } from '../gunshiDryRun.ts'\nimport { version } from '../../package.json'\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dryRun',\n ].join('\\n'),\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run(ctx) {\n const { values } = ctx\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n dryRun: ctx.extensions[dryRunId],\n })\n },\n})\n"],"mappings":";;;;;AAKA,MAAa,UAAU,gBAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,IAAI,KAAK;EACb,MAAM,EAAE,WAAW;EACnB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GACR,KAAK,OAAO;GACZ;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;GAChB,QAAQ,IAAI,WAAW;EACzB,CAAC;CACH;AACF,CAAC"}
|
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import {
|
|
2
|
+
import { n as isCIEnvironment, t as getAgentName } from "./agent-3JmkMghp.js";
|
|
3
3
|
import * as prompts from "@clack/prompts";
|
|
4
|
+
//#region src/utils/env.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns `true` when the process has an interactive TTY with a valid terminal
|
|
7
|
+
* width and is not running in CI.
|
|
8
|
+
*
|
|
9
|
+
* Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
|
|
10
|
+
* which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
|
|
11
|
+
* with a negative count and throw a `RangeError`). A positive column count is
|
|
12
|
+
* required before the TTY counts as usable.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* if (canUseTTY()) {
|
|
17
|
+
* renderProgressBar()
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function canUseTTY() {
|
|
22
|
+
return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns `true` when output can carry spinners and clack's gutter: an interactive TTY that no AI
|
|
26
|
+
* coding agent is reading. Cursor-movement escapes are hard for an agent to parse even over a
|
|
27
|
+
* pseudo-TTY, so it gets the plain writer.
|
|
28
|
+
*/
|
|
29
|
+
function isRichOutput() {
|
|
30
|
+
return canUseTTY() && !getAgentName();
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
4
33
|
//#region src/loggers/output.ts
|
|
5
34
|
/**
|
|
6
35
|
* Prefixes the plain writers use, the same ones `plainLogger` prints, so a command's own output
|
|
@@ -84,6 +113,6 @@ function createSpinner() {
|
|
|
84
113
|
};
|
|
85
114
|
}
|
|
86
115
|
//#endregion
|
|
87
|
-
export { logIntro as a, logWarn as c, logInfo as i, logBlock as n, logOutro as o, logError as r, logStep as s, createSpinner as t };
|
|
116
|
+
export { logIntro as a, logWarn as c, logInfo as i, canUseTTY as l, logBlock as n, logOutro as o, logError as r, logStep as s, createSpinner as t };
|
|
88
117
|
|
|
89
|
-
//# sourceMappingURL=output-
|
|
118
|
+
//# sourceMappingURL=output-DH2Uoy4x.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-DH2Uoy4x.js","names":[],"sources":["../src/utils/env.ts","../src/loggers/output.ts"],"sourcesContent":["import { getAgentName } from '../agent.ts'\nimport { isCIEnvironment } from '@internals/utils'\n\n/**\n * Returns `true` when the process has an interactive TTY with a valid terminal\n * width and is not running in CI.\n *\n * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,\n * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`\n * with a negative count and throw a `RangeError`). A positive column count is\n * required before the TTY counts as usable.\n *\n * @example\n * ```ts\n * if (canUseTTY()) {\n * renderProgressBar()\n * }\n * ```\n */\nexport function canUseTTY(): boolean {\n return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment()\n}\n\n/**\n * Returns `true` when output can carry spinners and clack's gutter: an interactive TTY that no AI\n * coding agent is reading. Cursor-movement escapes are hard for an agent to parse even over a\n * pseudo-TTY, so it gets the plain writer.\n */\nexport function isRichOutput(): boolean {\n return canUseTTY() && !getAgentName()\n}\n","import * as prompts from '@clack/prompts'\nimport { isRichOutput } from '../utils/env.ts'\n\n/**\n * Prefixes the plain writers use, the same ones `plainLogger` prints, so a command's own output\n * and the hook output around it read as one stream.\n */\nconst SYMBOLS = { info: 'ℹ', warn: '⚠', error: '✗', step: '◇' } as const\n\ntype Level = keyof typeof SYMBOLS\n\nfunction write(level: Level, message: string): void {\n if (isRichOutput()) {\n prompts.log[level](message)\n\n return\n }\n\n console.log(`${SYMBOLS[level]} ${message}`)\n}\n\ntype IntroOptions = {\n title: string\n /**\n * Printed under the title, for a command that has a caveat to lead with.\n */\n warning?: string\n /**\n * Whether to open a block a later {@link logOutro} closes. Pass `false` for a command that\n * prints and exits, since nothing would ever close the block.\n *\n * @default true\n */\n block?: boolean\n}\n\n/**\n * Opens a command's output with its title.\n */\nexport function logIntro({ title, warning, block = true }: IntroOptions): void {\n if (block && isRichOutput()) {\n prompts.intro(title)\n\n if (warning) {\n prompts.log.warn(warning)\n }\n\n return\n }\n\n console.log(title)\n\n if (warning) {\n console.warn(warning)\n }\n\n console.log()\n}\n\n/**\n * Closes the block {@link logIntro} opened. The closing gutter is not a written line, so plain\n * output prints the text on its own.\n */\nexport function logOutro(text: string): void {\n if (isRichOutput()) {\n prompts.outro(text)\n\n return\n }\n\n console.log(text)\n}\n\n/**\n * Prints lines as one block, without a symbol in front of them.\n */\nexport function logBlock(lines: string | Array<string>): void {\n if (isRichOutput()) {\n prompts.log.message(lines)\n\n return\n }\n\n console.log([lines].flat().join('\\n'))\n}\n\nexport function logInfo(message: string): void {\n write('info', message)\n}\n\nexport function logWarn(message: string): void {\n write('warn', message)\n}\n\nexport function logError(message: string): void {\n write('error', message)\n}\n\n/**\n * Reports a step the command is taking, rather than something it found.\n */\nexport function logStep(message: string): void {\n write('step', message)\n}\n\ntype Spinner = {\n start: (message?: string) => void\n stop: (message?: string, code?: number) => void\n message: (message?: string) => void\n}\n\n/**\n * A progress spinner, or a writer that prints each message it is given when the terminal cannot\n * animate one. Callers drive both the same way.\n */\nexport function createSpinner(): Spinner {\n if (isRichOutput()) {\n return prompts.spinner()\n }\n\n const print = (message?: string) => {\n if (message) {\n console.log(message)\n }\n }\n\n return { start: print, stop: print, message: print }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,YAAqB;CACnC,OAAO,QAAQ,OAAO,UAAU,QAAQ,OAAO,WAAW,KAAK,KAAK,CAAC,gBAAgB;AACvF;;;;;;AAOA,SAAgB,eAAwB;CACtC,OAAO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