@kubb/cli 5.0.0-beta.1 → 5.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +177 -26
  2. package/dist/agent-Bx2yllmS.js +68 -0
  3. package/dist/agent-Bx2yllmS.js.map +1 -0
  4. package/dist/agent-CeLwj5im.cjs +70 -0
  5. package/dist/agent-CeLwj5im.cjs.map +1 -0
  6. package/dist/{chunk--u3MIqq1.js → chunk-BvFE5Tac.js} +1 -0
  7. package/dist/constants-B2JTeRBb.js +42 -0
  8. package/dist/constants-B2JTeRBb.js.map +1 -0
  9. package/dist/constants-BINTA5VZ.cjs +77 -0
  10. package/dist/constants-BINTA5VZ.cjs.map +1 -0
  11. package/dist/constants-BYGmiFs0.cjs +139 -0
  12. package/dist/constants-BYGmiFs0.cjs.map +1 -0
  13. package/dist/constants-DSJ-Xrbv.js +116 -0
  14. package/dist/constants-DSJ-Xrbv.js.map +1 -0
  15. package/dist/define-Bdn8j5VM.cjs.map +1 -1
  16. package/dist/{define-Ctii4bel.js → define-m_fp-Aqm.js} +2 -2
  17. package/dist/{define-Ctii4bel.js.map → define-m_fp-Aqm.js.map} +1 -1
  18. package/dist/{errors-CjPmyZHy.js → errors-CINO1EIv.js} +2 -2
  19. package/dist/{errors-CjPmyZHy.js.map → errors-CINO1EIv.js.map} +1 -1
  20. package/dist/errors-CLCjoSg0.cjs.map +1 -1
  21. package/dist/{generate-BaJRhbCS.js → generate-BLvcvoIj.js} +12 -6
  22. package/dist/generate-BLvcvoIj.js.map +1 -0
  23. package/dist/{generate-TL8zY_IT.cjs → generate-drLxTAnz.cjs} +10 -4
  24. package/dist/generate-drLxTAnz.cjs.map +1 -0
  25. package/dist/index.cjs +20 -11
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +22 -13
  29. package/dist/index.js.map +1 -1
  30. package/dist/init-CGu7JZEF.js +53 -0
  31. package/dist/init-CGu7JZEF.js.map +1 -0
  32. package/dist/init-CyCjvIEF.cjs +53 -0
  33. package/dist/init-CyCjvIEF.cjs.map +1 -0
  34. package/dist/mcp-Cq2sylQC.js +39 -0
  35. package/dist/mcp-Cq2sylQC.js.map +1 -0
  36. package/dist/mcp-DSF5gpI-.cjs +39 -0
  37. package/dist/mcp-DSF5gpI-.cjs.map +1 -0
  38. package/dist/{package-Cdo6lNjF.cjs → package-DZ-6zAIO.cjs} +2 -2
  39. package/dist/package-DZ-6zAIO.cjs.map +1 -0
  40. package/dist/package-OLYIpjqw.js +6 -0
  41. package/dist/package-OLYIpjqw.js.map +1 -0
  42. package/dist/{generate-CuxArvEk.js → run-Bfbr3RaM.js} +322 -337
  43. package/dist/run-Bfbr3RaM.js.map +1 -0
  44. package/dist/{agent-Ev5hU5hH.js → run-BzpYYOQs.js} +53 -44
  45. package/dist/run-BzpYYOQs.js.map +1 -0
  46. package/dist/run-CCZ24VKk.js +51 -0
  47. package/dist/run-CCZ24VKk.js.map +1 -0
  48. package/dist/{init-eNRlotJK.js → run-CF97BWVa.js} +102 -147
  49. package/dist/run-CF97BWVa.js.map +1 -0
  50. package/dist/run-CQbj3ley.cjs +52 -0
  51. package/dist/run-CQbj3ley.cjs.map +1 -0
  52. package/dist/{generate-UCP0qpDp.cjs → run-CVlrIZoW.cjs} +319 -334
  53. package/dist/run-CVlrIZoW.cjs.map +1 -0
  54. package/dist/run-D0hmRpHy.js +49 -0
  55. package/dist/run-D0hmRpHy.js.map +1 -0
  56. package/dist/{agent-B_pirbeB.cjs → run-DwdAwnLG.cjs} +51 -42
  57. package/dist/run-DwdAwnLG.cjs.map +1 -0
  58. package/dist/run-Lr0Ctnu0.cjs +50 -0
  59. package/dist/run-Lr0Ctnu0.cjs.map +1 -0
  60. package/dist/{init-CZ5Xq2Hd.cjs → run-YsoCk5we.cjs} +100 -145
  61. package/dist/run-YsoCk5we.cjs.map +1 -0
  62. package/dist/shell-475fQKaX.cjs.map +1 -1
  63. package/dist/{shell-DLzN4fRo.js → shell-CN6DNqeC.js} +2 -2
  64. package/dist/{shell-DLzN4fRo.js.map → shell-CN6DNqeC.js.map} +1 -1
  65. package/dist/{telemetry-DN95_2pF.cjs → telemetry-B2iWkY5e.cjs} +5 -7
  66. package/dist/telemetry-B2iWkY5e.cjs.map +1 -0
  67. package/dist/{telemetry-LgT_sdPe.js → telemetry-BkektVz6.js} +6 -8
  68. package/dist/telemetry-BkektVz6.js.map +1 -0
  69. package/dist/validate-CAUqLaGt.js +26 -0
  70. package/dist/validate-CAUqLaGt.js.map +1 -0
  71. package/dist/validate-J6AEd5zK.cjs +26 -0
  72. package/dist/validate-J6AEd5zK.cjs.map +1 -0
  73. package/package.json +22 -14
  74. package/src/commands/agent/start.ts +10 -7
  75. package/src/commands/agent.ts +3 -1
  76. package/src/commands/generate.ts +5 -3
  77. package/src/commands/init.ts +34 -3
  78. package/src/commands/mcp.ts +28 -4
  79. package/src/commands/validate.ts +6 -4
  80. package/src/constants.ts +2 -58
  81. package/src/index.ts +5 -3
  82. package/src/loggers/clackLogger.ts +45 -43
  83. package/src/loggers/fileSystemLogger.ts +26 -13
  84. package/src/loggers/githubActionsLogger.ts +13 -25
  85. package/src/loggers/plainLogger.ts +12 -23
  86. package/src/loggers/types.ts +6 -0
  87. package/src/loggers/utils.ts +155 -9
  88. package/src/runners/agent/run.ts +113 -0
  89. package/src/runners/agent/utils.ts +98 -0
  90. package/src/runners/generate/run.ts +276 -0
  91. package/src/runners/generate/utils.ts +209 -0
  92. package/src/runners/init/run.ts +211 -0
  93. package/src/{utils/packageManager.ts → runners/init/utils.ts} +10 -0
  94. package/src/runners/mcp/run.ts +55 -0
  95. package/src/runners/validate/run.ts +63 -0
  96. package/src/{utils/telemetry.ts → telemetry.ts} +12 -5
  97. package/dist/agent-B_pirbeB.cjs.map +0 -1
  98. package/dist/agent-CUmEyiqY.cjs +0 -58
  99. package/dist/agent-CUmEyiqY.cjs.map +0 -1
  100. package/dist/agent-Ev5hU5hH.js.map +0 -1
  101. package/dist/agent-v_2S-bnN.js +0 -56
  102. package/dist/agent-v_2S-bnN.js.map +0 -1
  103. package/dist/constants-CnDXa1R6.cjs +0 -148
  104. package/dist/constants-CnDXa1R6.cjs.map +0 -1
  105. package/dist/constants-aL3CP_Wq.js +0 -95
  106. package/dist/constants-aL3CP_Wq.js.map +0 -1
  107. package/dist/generate-BaJRhbCS.js.map +0 -1
  108. package/dist/generate-CuxArvEk.js.map +0 -1
  109. package/dist/generate-TL8zY_IT.cjs.map +0 -1
  110. package/dist/generate-UCP0qpDp.cjs.map +0 -1
  111. package/dist/init-CZ5Xq2Hd.cjs.map +0 -1
  112. package/dist/init-DRR_YWIq.cjs +0 -25
  113. package/dist/init-DRR_YWIq.cjs.map +0 -1
  114. package/dist/init-DSnRd1RJ.js +0 -25
  115. package/dist/init-DSnRd1RJ.js.map +0 -1
  116. package/dist/init-eNRlotJK.js.map +0 -1
  117. package/dist/mcp-CLcDV4Jm.cjs +0 -41
  118. package/dist/mcp-CLcDV4Jm.cjs.map +0 -1
  119. package/dist/mcp-D7EIR9fR.js +0 -40
  120. package/dist/mcp-D7EIR9fR.js.map +0 -1
  121. package/dist/mcp-Dakxi9CL.js +0 -16
  122. package/dist/mcp-Dakxi9CL.js.map +0 -1
  123. package/dist/mcp-Dr_RY-hd.cjs +0 -16
  124. package/dist/mcp-Dr_RY-hd.cjs.map +0 -1
  125. package/dist/package-Cdo6lNjF.cjs.map +0 -1
  126. package/dist/package-DPooAj2l.js +0 -6
  127. package/dist/package-DPooAj2l.js.map +0 -1
  128. package/dist/telemetry-DN95_2pF.cjs.map +0 -1
  129. package/dist/telemetry-LgT_sdPe.js.map +0 -1
  130. package/dist/validate-B1o-rY9o.js +0 -25
  131. package/dist/validate-B1o-rY9o.js.map +0 -1
  132. package/dist/validate-CXFY-mHL.cjs +0 -25
  133. package/dist/validate-CXFY-mHL.cjs.map +0 -1
  134. package/dist/validate-kLJoT_hi.js +0 -33
  135. package/dist/validate-kLJoT_hi.js.map +0 -1
  136. package/dist/validate-yKKzqEZ5.cjs +0 -34
  137. package/dist/validate-yKKzqEZ5.cjs.map +0 -1
  138. package/src/runners/agent.ts +0 -149
  139. package/src/runners/generate.ts +0 -333
  140. package/src/runners/init.ts +0 -296
  141. package/src/runners/mcp.ts +0 -45
  142. package/src/runners/validate.ts +0 -39
  143. package/src/types.ts +0 -11
  144. package/src/utils/Writables.ts +0 -17
  145. package/src/utils/executeHooks.ts +0 -45
  146. package/src/utils/flags.ts +0 -9
  147. package/src/utils/getConfig.ts +0 -10
  148. package/src/utils/getCosmiConfig.ts +0 -80
  149. package/src/utils/getSummary.ts +0 -68
  150. package/src/utils/runHook.ts +0 -91
  151. package/src/utils/watcher.ts +0 -19
@@ -1,12 +1,19 @@
1
1
  import fs from 'node:fs'
2
2
  import path from 'node:path'
3
+ import process from 'node:process'
3
4
  import type { PackageManagerInfo, PackageManagerName } from '@internals/utils'
4
5
  import { spawnAsync } from '@internals/utils'
5
6
 
7
+ /**
8
+ * Returns `true` when a `package.json` exists at `cwd`.
9
+ */
6
10
  export function hasPackageJson(cwd: string = process.cwd()): boolean {
7
11
  return fs.existsSync(path.join(cwd, 'package.json'))
8
12
  }
9
13
 
14
+ /**
15
+ * Initializes a new `package.json` at `cwd` using the detected package manager.
16
+ */
10
17
  export async function initPackageJson(cwd: string, packageManager: PackageManagerInfo): Promise<void> {
11
18
  const commands: Record<PackageManagerName, string[]> = {
12
19
  npm: ['init', '-y'],
@@ -18,6 +25,9 @@ export async function initPackageJson(cwd: string, packageManager: PackageManage
18
25
  await spawnAsync(packageManager.name, commands[packageManager.name], { cwd })
19
26
  }
20
27
 
28
+ /**
29
+ * Installs the given packages at `cwd` using the detected package manager.
30
+ */
21
31
  export async function installPackages(packages: string[], packageManager: PackageManagerInfo, cwd: string = process.cwd()): Promise<void> {
22
32
  await spawnAsync(packageManager.name, [...packageManager.installCommand, ...packages], { cwd })
23
33
  }
@@ -0,0 +1,55 @@
1
+ import process from 'node:process'
2
+ import { styleText } from 'node:util'
3
+ import { getErrorMessage } from '@internals/utils'
4
+ import type * as McpModule from '@kubb/mcp'
5
+ import { buildTelemetryEvent, sendTelemetry } from '../../telemetry.ts'
6
+
7
+ type McpOptions = {
8
+ /**
9
+ * Current `@kubb/cli` version string, used for the telemetry payload.
10
+ */
11
+ version: string
12
+ /**
13
+ * TCP port for the HTTP MCP server. When `undefined`, the server uses stdio transport.
14
+ */
15
+ port?: string
16
+ /**
17
+ * Hostname to bind to when running in HTTP mode.
18
+ *
19
+ * @default 'localhost'
20
+ */
21
+ host?: string
22
+ }
23
+
24
+ /**
25
+ * Starts the Kubb MCP server using `@kubb/mcp`.
26
+ * Exits the process with code 1 if `@kubb/mcp` is not installed.
27
+ */
28
+ export async function run({ version, port, host }: McpOptions): Promise<void> {
29
+ let mod: typeof McpModule
30
+ try {
31
+ mod = (await import('@kubb/mcp')) as typeof McpModule
32
+ } catch (_e) {
33
+ console.error(styleText('red', 'The @kubb/mcp package is not installed.'))
34
+ console.error('')
35
+ console.error('Install it with:')
36
+ console.error(styleText('cyan', ' npm install @kubb/mcp'))
37
+ console.error(styleText('cyan', ' # or'))
38
+ console.error(styleText('cyan', ' pnpm install @kubb/mcp'))
39
+ console.error('')
40
+ process.exit(1)
41
+ }
42
+
43
+ const { run: startMcpServer } = mod
44
+ const hrStart = process.hrtime()
45
+ const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'mcp', kubbVersion: version, hrStart, status }))
46
+ try {
47
+ console.log(styleText('cyan', '⏳ Starting MCP server...'))
48
+ console.warn(styleText('yellow', 'This feature is still under development, use with caution'))
49
+ await startMcpServer(undefined, { port: port !== undefined ? Number(port) : undefined, host })
50
+ await report('success')
51
+ } catch (error) {
52
+ await report('failed')
53
+ console.error(getErrorMessage(error))
54
+ }
55
+ }
@@ -0,0 +1,63 @@
1
+ import process from 'node:process'
2
+ import { styleText } from 'node:util'
3
+ import { getErrorMessage } from '@internals/utils'
4
+ import { buildTelemetryEvent, sendTelemetry } from '../../telemetry.ts'
5
+
6
+ type ValidateOptions = {
7
+ /**
8
+ * Path or URL to the OpenAPI/Swagger file to validate.
9
+ */
10
+ input: string
11
+ /**
12
+ * Current `@kubb/cli` version string, used for the telemetry payload.
13
+ */
14
+ version: string
15
+ }
16
+
17
+ type ValidateModule = typeof import('@kubb/adapter-oas')
18
+ type ValidateDependencies = {
19
+ /**
20
+ * Loads `@kubb/adapter-oas`. Injected so tests can substitute a mock.
21
+ */
22
+ loadValidateModule: () => Promise<ValidateModule>
23
+ }
24
+
25
+ /**
26
+ * Dynamically loads `@kubb/adapter-oas` for OpenAPI validation.
27
+ */
28
+ export function loadValidateModule(): Promise<ValidateModule> {
29
+ return import('@kubb/adapter-oas') as Promise<ValidateModule>
30
+ }
31
+
32
+ /**
33
+ * Validates an OpenAPI/Swagger file at `input` using `@kubb/adapter-oas`.
34
+ * Exits the process with code 1 on validation failure or missing dependency.
35
+ */
36
+ export async function run({ input, version }: ValidateOptions, dependencies: ValidateDependencies = { loadValidateModule }): Promise<void> {
37
+ const hrStart = process.hrtime()
38
+ const report = (status: 'success' | 'failed') => sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status }))
39
+ try {
40
+ const { adapterOas } = await dependencies.loadValidateModule()
41
+ const adapter = adapterOas()
42
+ if (!adapter.validate) {
43
+ throw new Error('The loaded adapter does not support validation.')
44
+ }
45
+ await adapter.validate(input, { throwOnError: true })
46
+ await report('success')
47
+ console.log('✅ Validation success')
48
+ } catch (error) {
49
+ await report('failed')
50
+ if (error instanceof Error && /@kubb\/adapter-oas/.test(error.message)) {
51
+ console.error(styleText('red', 'The @kubb/adapter-oas package is not installed.'))
52
+ console.error('')
53
+ console.error('Install it with:')
54
+ console.error(styleText('cyan', ' npm install @kubb/adapter-oas'))
55
+ console.error(styleText('cyan', ' # or'))
56
+ console.error(styleText('cyan', ' pnpm install @kubb/adapter-oas'))
57
+ console.error('')
58
+ }
59
+ console.error('❌ Validation failed')
60
+ console.error(getErrorMessage(error))
61
+ process.exit(1)
62
+ }
63
+ }
@@ -2,7 +2,7 @@ import { randomBytes } from 'node:crypto'
2
2
  import os from 'node:os'
3
3
  import process from 'node:process'
4
4
  import { executeIfOnline, isCIEnvironment } from '@internals/utils'
5
- import { OTLP_ENDPOINT } from '../constants.ts'
5
+ import { OTLP_ENDPOINT } from './constants.ts'
6
6
 
7
7
  // OpenTelemetry OTLP JSON types
8
8
  // https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto
@@ -96,8 +96,17 @@ type OtlpExportTraceServiceRequest = {
96
96
  resourceSpans: OtlpResourceSpans[]
97
97
  }
98
98
 
99
+ /**
100
+ * Anonymous plugin name and options snapshot sent with each telemetry event.
101
+ */
99
102
  export type TelemetryPlugin = {
103
+ /**
104
+ * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.
105
+ */
100
106
  name: string
107
+ /**
108
+ * anonymized plugin options snapshot — values are included but cannot be traced back to the user.
109
+ */
101
110
  options: Record<string, unknown>
102
111
  }
103
112
 
@@ -114,16 +123,14 @@ type TelemetryEvent = {
114
123
  }
115
124
 
116
125
  /**
117
- * Detect whether the current process is running inside a CI environment.
118
- * Delegates to the canonical isCIEnvironment() from envDetection.
126
+ * Returns `true` when the current process runs inside a CI environment.
119
127
  */
120
128
  export function isCi(): boolean {
121
129
  return isCIEnvironment()
122
130
  }
123
131
 
124
132
  /**
125
- * Check if telemetry is disabled via DO_NOT_TRACK or KUBB_DISABLE_TELEMETRY.
126
- * Respects the standard DO_NOT_TRACK convention used across development tools.
133
+ * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
127
134
  */
128
135
  export function isTelemetryDisabled(): boolean {
129
136
  return (
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-B_pirbeB.cjs","names":["process","agentDefaults","path","net","spawnAsync","sendTelemetry","buildTelemetryEvent"],"sources":["../src/runners/agent.ts"],"sourcesContent":["import net from 'node:net'\nimport path from 'node:path'\nimport * as process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { spawnAsync } from '@internals/utils'\nimport { agentDefaults } from '../constants.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype AgentStartOptions = {\n port: string | undefined\n host: string\n configPath: string | undefined\n allowWrite: boolean\n allowAll: boolean\n version: string\n}\n\ntype ResolvedAgentStartEnvironment = {\n port: string\n host: string\n allowWrite: boolean\n allowAll: boolean\n agentConfigPath: string\n env: NodeJS.ProcessEnv\n}\n\n/**\n * Resolves the environment passed to the detached agent process using CLI values first, then environment values, then CLI defaults.\n */\nfunction resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll }: Omit<AgentStartOptions, 'version'>): ResolvedAgentStartEnvironment {\n const resolvedPort = port ?? process.env.PORT ?? agentDefaults.port\n const resolvedHost = host !== agentDefaults.host ? host : (process.env.HOST ?? agentDefaults.host)\n const resolvedAllowAll = allowAll || process.env.KUBB_AGENT_ALLOW_ALL === 'true'\n const resolvedAllowWrite = resolvedAllowAll || allowWrite || process.env.KUBB_AGENT_ALLOW_WRITE === 'true'\n const agentRoot = process.env.KUBB_AGENT_ROOT ?? process.cwd()\n const agentConfigPath = path.resolve(process.cwd(), configPath || process.env.KUBB_AGENT_CONFIG || agentDefaults.configFile)\n\n return {\n port: resolvedPort,\n host: resolvedHost,\n allowWrite: resolvedAllowWrite,\n allowAll: resolvedAllowAll,\n agentConfigPath,\n env: {\n ...process.env,\n PORT: resolvedPort,\n HOST: resolvedHost,\n KUBB_AGENT_ROOT: agentRoot,\n KUBB_AGENT_CONFIG: agentConfigPath,\n KUBB_AGENT_ALLOW_WRITE: String(resolvedAllowWrite),\n KUBB_AGENT_ALLOW_ALL: String(resolvedAllowAll),\n KUBB_AGENT_TOKEN: process.env.KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT: process.env.KUBB_AGENT_RETRY_TIMEOUT ?? agentDefaults.retryTimeout,\n KUBB_STUDIO_URL: process.env.KUBB_STUDIO_URL ?? agentDefaults.studioUrl,\n },\n }\n}\n\nfunction isPortAvailable(port: number, host: string): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer()\n server.once('error', () => resolve(false))\n server.once('listening', () => {\n server.close()\n resolve(true)\n })\n server.listen(port, host)\n })\n}\n\nexport async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }: AgentStartOptions): Promise<void> {\n const hrStart = process.hrtime()\n\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist; ignore\n }\n\n // Resolve the @kubb/agent package path\n let agentPkgUrl: string\n try {\n agentPkgUrl = import.meta.resolve('@kubb/agent/package.json')\n } catch (_e) {\n console.error(`Import of '@kubb/agent' is required to start the Agent server`)\n process.exit(1)\n }\n const agentPkgPath = fileURLToPath(agentPkgUrl)\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, agentDefaults.serverEntryPath)\n\n const resolvedEnv = resolveAgentStartEnvironment({\n port,\n host,\n configPath,\n allowWrite,\n allowAll,\n })\n const numericPort = Number(resolvedEnv.port)\n\n if (!Number.isInteger(numericPort) || numericPort <= 0) {\n throw new Error(`Invalid port \"${resolvedEnv.port}\". Provide a positive integer with --port or PORT.`)\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${resolvedEnv.agentConfigPath}`))\n clack.log.info(styleText('dim', `Host: ${resolvedEnv.host}`))\n clack.log.info(styleText('dim', `Port: ${resolvedEnv.port}`))\n if (!resolvedEnv.allowWrite && !resolvedEnv.allowAll) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n if (!(await isPortAvailable(numericPort, resolvedEnv.host))) {\n clack.log.error(styleText('red', `Port ${resolvedEnv.port} is already in use. Stop the existing process or choose a different port with --port.`))\n process.exit(1)\n }\n\n // Spawns the server as a detached background process so the CLI can exit independently.\n await spawnAsync('node', [serverPath], {\n env: resolvedEnv.env,\n cwd: process.cwd(),\n })\n\n await sendTelemetry(\n buildTelemetryEvent({\n command: 'agent',\n kubbVersion: version,\n hrStart,\n status: 'success',\n }),\n )\n } catch (error) {\n await sendTelemetry(\n buildTelemetryEvent({\n command: 'agent',\n kubbVersion: version,\n hrStart,\n status: 'failed',\n }),\n )\n clack.log.error(styleText('red', 'Failed to start agent server'))\n console.error(error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,SAAS,6BAA6B,EAAE,MAAM,MAAM,YAAY,YAAY,YAA+E;CACzJ,MAAM,eAAe,QAAQA,aAAQ,IAAI,QAAQC,kBAAAA,cAAc;CAC/D,MAAM,eAAe,SAASA,kBAAAA,cAAc,OAAO,OAAQD,aAAQ,IAAI,QAAQC,kBAAAA,cAAc;CAC7F,MAAM,mBAAmB,YAAYD,aAAQ,IAAI,yBAAyB;CAC1E,MAAM,qBAAqB,oBAAoB,cAAcA,aAAQ,IAAI,2BAA2B;CACpG,MAAM,YAAYA,aAAQ,IAAI,mBAAmBA,aAAQ,KAAK;CAC9D,MAAM,kBAAkBE,UAAAA,QAAK,QAAQF,aAAQ,KAAK,EAAE,cAAcA,aAAQ,IAAI,qBAAqBC,kBAAAA,cAAc,WAAW;AAE5H,QAAO;EACL,MAAM;EACN,MAAM;EACN,YAAY;EACZ,UAAU;EACV;EACA,KAAK;GACH,GAAGD,aAAQ;GACX,MAAM;GACN,MAAM;GACN,iBAAiB;GACjB,mBAAmB;GACnB,wBAAwB,OAAO,mBAAmB;GAClD,sBAAsB,OAAO,iBAAiB;GAC9C,kBAAkBA,aAAQ,IAAI;GAC9B,0BAA0BA,aAAQ,IAAI,4BAA4BC,kBAAAA,cAAc;GAChF,iBAAiBD,aAAQ,IAAI,mBAAmBC,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C,YAAY,cAAc,CAAC,YAAY,SAC1C,gBAAM,IAAI,MAAA,GAAA,UAAA,WAAe,UAAU,0EAA0E,CAAC;AAGhH,MAAI,CAAE,MAAM,gBAAgB,aAAa,YAAY,KAAK,EAAG;AAC3D,kBAAM,IAAI,OAAA,GAAA,UAAA,WAAgB,OAAO,QAAQ,YAAY,KAAK,uFAAuF,CAAC;AAClJ,gBAAQ,KAAK,EAAE;;AAIjB,QAAMG,cAAAA,WAAW,QAAQ,CAAC,WAAW,EAAE;GACrC,KAAK,YAAY;GACjB,KAAKJ,aAAQ,KAAK;GACnB,CAAC;AAEF,QAAMK,kBAAAA,cACJC,kBAAAA,oBAAoB;GAClB,SAAS;GACT,aAAa;GACb;GACA,QAAQ;GACT,CAAC,CACH;UACM,OAAO;AACd,QAAMD,kBAAAA,cACJC,kBAAAA,oBAAoB;GAClB,SAAS;GACT,aAAa;GACb;GACA,QAAQ;GACT,CAAC,CACH;AACD,iBAAM,IAAI,OAAA,GAAA,UAAA,WAAgB,OAAO,+BAA+B,CAAC;AACjE,UAAQ,MAAM,MAAM;AACpB,eAAQ,KAAK,EAAE"}
@@ -1,58 +0,0 @@
1
- require("./chunk-ByKO4r7w.cjs");
2
- const require_define = require("./define-Bdn8j5VM.cjs");
3
- const require_package = require("./package-Cdo6lNjF.cjs");
4
- const require_constants = require("./constants-CnDXa1R6.cjs");
5
- //#region src/commands/agent/start.ts
6
- const command$1 = require_define.defineCommand({
7
- name: "start",
8
- description: "Start the Agent server",
9
- options: {
10
- config: {
11
- type: "string",
12
- description: "Path to the Kubb config",
13
- short: "c"
14
- },
15
- port: {
16
- type: "string",
17
- description: `Port for the server (default: ${require_constants.agentDefaults.port})`,
18
- short: "p"
19
- },
20
- host: {
21
- type: "string",
22
- description: "Host for the server",
23
- default: require_constants.agentDefaults.host
24
- },
25
- "allow-write": {
26
- type: "boolean",
27
- description: "Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.",
28
- default: false
29
- },
30
- "allow-all": {
31
- type: "boolean",
32
- description: "Grant all permissions (implies --allow-write).",
33
- default: false
34
- }
35
- },
36
- async run({ values }) {
37
- const { runAgentStart } = await Promise.resolve().then(() => require("./agent-B_pirbeB.cjs"));
38
- await runAgentStart({
39
- port: values.port !== void 0 ? values.port : void 0,
40
- host: values.host,
41
- configPath: values.config,
42
- allowWrite: values["allow-write"],
43
- allowAll: values["allow-all"],
44
- version: require_package.version
45
- });
46
- }
47
- });
48
- //#endregion
49
- //#region src/commands/agent.ts
50
- const command = require_define.defineCommand({
51
- name: "agent",
52
- description: "Manage the Kubb Agent server",
53
- subCommands: [command$1]
54
- });
55
- //#endregion
56
- exports.command = command;
57
-
58
- //# sourceMappingURL=agent-CUmEyiqY.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-CUmEyiqY.cjs","names":["command","defineCommand","agentDefaults","defineCommand","startCommand"],"sources":["../src/commands/agent/start.ts","../src/commands/agent.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../../package.json'\nimport { agentDefaults } from '../../constants.ts'\n\nexport const command = defineCommand({\n name: 'start',\n description: 'Start the Agent server',\n options: {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n port: {\n type: 'string',\n description: `Port for the server (default: ${agentDefaults.port})`,\n short: 'p',\n },\n host: {\n type: 'string',\n description: 'Host for the server',\n default: agentDefaults.host,\n },\n 'allow-write': {\n type: 'boolean',\n description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',\n default: false,\n },\n 'allow-all': {\n type: 'boolean',\n description: 'Grant all permissions (implies --allow-write).',\n default: false,\n },\n },\n async run({ values }) {\n const { runAgentStart } = await import('../../runners/agent.ts')\n\n await runAgentStart({\n port: values.port !== undefined ? values.port : undefined,\n host: values.host,\n configPath: values.config,\n allowWrite: values['allow-write'],\n allowAll: values['allow-all'],\n version,\n })\n },\n})\n","import { defineCommand } from '@internals/utils'\nimport { command as startCommand } from './agent/start.ts'\n\nexport const command = defineCommand({\n name: 'agent',\n description: 'Manage the Kubb Agent server',\n subCommands: [startCommand],\n})\n"],"mappings":";;;;;AAIA,MAAaA,YAAUC,eAAAA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACR;EACD,MAAM;GACJ,MAAM;GACN,aAAa,iCAAiCC,kBAAAA,cAAc,KAAK;GACjE,OAAO;GACR;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,SAASA,kBAAAA,cAAc;GACxB;EACD,eAAe;GACb,MAAM;GACN,aAAa;GACb,SAAS;GACV;EACD,aAAa;GACX,MAAM;GACN,aAAa;GACb,SAAS;GACV;EACF;CACD,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,kBAAkB,MAAA,QAAA,SAAA,CAAA,WAAA,QAAM,uBAAA,CAAA;AAEhC,QAAM,cAAc;GAClB,MAAM,OAAO,SAAS,KAAA,IAAY,OAAO,OAAO,KAAA;GAChD,MAAM,OAAO;GACb,YAAY,OAAO;GACnB,YAAY,OAAO;GACnB,UAAU,OAAO;GACjB,SAAA,gBAAA;GACD,CAAC;;CAEL,CAAC;;;AC3CF,MAAa,UAAUC,eAAAA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,aAAa,CAACC,UAAa;CAC5B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-Ev5hU5hH.js","names":["process"],"sources":["../src/runners/agent.ts"],"sourcesContent":["import net from 'node:net'\nimport path from 'node:path'\nimport * as process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { spawnAsync } from '@internals/utils'\nimport { agentDefaults } from '../constants.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype AgentStartOptions = {\n port: string | undefined\n host: string\n configPath: string | undefined\n allowWrite: boolean\n allowAll: boolean\n version: string\n}\n\ntype ResolvedAgentStartEnvironment = {\n port: string\n host: string\n allowWrite: boolean\n allowAll: boolean\n agentConfigPath: string\n env: NodeJS.ProcessEnv\n}\n\n/**\n * Resolves the environment passed to the detached agent process using CLI values first, then environment values, then CLI defaults.\n */\nfunction resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll }: Omit<AgentStartOptions, 'version'>): ResolvedAgentStartEnvironment {\n const resolvedPort = port ?? process.env.PORT ?? agentDefaults.port\n const resolvedHost = host !== agentDefaults.host ? host : (process.env.HOST ?? agentDefaults.host)\n const resolvedAllowAll = allowAll || process.env.KUBB_AGENT_ALLOW_ALL === 'true'\n const resolvedAllowWrite = resolvedAllowAll || allowWrite || process.env.KUBB_AGENT_ALLOW_WRITE === 'true'\n const agentRoot = process.env.KUBB_AGENT_ROOT ?? process.cwd()\n const agentConfigPath = path.resolve(process.cwd(), configPath || process.env.KUBB_AGENT_CONFIG || agentDefaults.configFile)\n\n return {\n port: resolvedPort,\n host: resolvedHost,\n allowWrite: resolvedAllowWrite,\n allowAll: resolvedAllowAll,\n agentConfigPath,\n env: {\n ...process.env,\n PORT: resolvedPort,\n HOST: resolvedHost,\n KUBB_AGENT_ROOT: agentRoot,\n KUBB_AGENT_CONFIG: agentConfigPath,\n KUBB_AGENT_ALLOW_WRITE: String(resolvedAllowWrite),\n KUBB_AGENT_ALLOW_ALL: String(resolvedAllowAll),\n KUBB_AGENT_TOKEN: process.env.KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT: process.env.KUBB_AGENT_RETRY_TIMEOUT ?? agentDefaults.retryTimeout,\n KUBB_STUDIO_URL: process.env.KUBB_STUDIO_URL ?? agentDefaults.studioUrl,\n },\n }\n}\n\nfunction isPortAvailable(port: number, host: string): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer()\n server.once('error', () => resolve(false))\n server.once('listening', () => {\n server.close()\n resolve(true)\n })\n server.listen(port, host)\n })\n}\n\nexport async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }: AgentStartOptions): Promise<void> {\n const hrStart = process.hrtime()\n\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist; ignore\n }\n\n // Resolve the @kubb/agent package path\n let agentPkgUrl: string\n try {\n agentPkgUrl = import.meta.resolve('@kubb/agent/package.json')\n } catch (_e) {\n console.error(`Import of '@kubb/agent' is required to start the Agent server`)\n process.exit(1)\n }\n const agentPkgPath = fileURLToPath(agentPkgUrl)\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, agentDefaults.serverEntryPath)\n\n const resolvedEnv = resolveAgentStartEnvironment({\n port,\n host,\n configPath,\n allowWrite,\n allowAll,\n })\n const numericPort = Number(resolvedEnv.port)\n\n if (!Number.isInteger(numericPort) || numericPort <= 0) {\n throw new Error(`Invalid port \"${resolvedEnv.port}\". Provide a positive integer with --port or PORT.`)\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${resolvedEnv.agentConfigPath}`))\n clack.log.info(styleText('dim', `Host: ${resolvedEnv.host}`))\n clack.log.info(styleText('dim', `Port: ${resolvedEnv.port}`))\n if (!resolvedEnv.allowWrite && !resolvedEnv.allowAll) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n if (!(await isPortAvailable(numericPort, resolvedEnv.host))) {\n clack.log.error(styleText('red', `Port ${resolvedEnv.port} is already in use. Stop the existing process or choose a different port with --port.`))\n process.exit(1)\n }\n\n // Spawns the server as a detached background process so the CLI can exit independently.\n await spawnAsync('node', [serverPath], {\n env: resolvedEnv.env,\n cwd: process.cwd(),\n })\n\n await sendTelemetry(\n buildTelemetryEvent({\n command: 'agent',\n kubbVersion: version,\n hrStart,\n status: 'success',\n }),\n )\n } catch (error) {\n await sendTelemetry(\n buildTelemetryEvent({\n command: 'agent',\n kubbVersion: version,\n hrStart,\n status: 'failed',\n }),\n )\n clack.log.error(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QAAM,IAAI,MAAM,UAAU,OAAO,+BAA+B,CAAC;AACjE,UAAQ,MAAM,MAAM;AACpB,YAAQ,KAAK,EAAE"}
@@ -1,56 +0,0 @@
1
- import "./chunk--u3MIqq1.js";
2
- import { n as defineCommand } from "./define-Ctii4bel.js";
3
- import { t as version } from "./package-DPooAj2l.js";
4
- import { s as agentDefaults } from "./constants-aL3CP_Wq.js";
5
- //#endregion
6
- //#region src/commands/agent.ts
7
- const command = defineCommand({
8
- name: "agent",
9
- description: "Manage the Kubb Agent server",
10
- subCommands: [defineCommand({
11
- name: "start",
12
- description: "Start the Agent server",
13
- options: {
14
- config: {
15
- type: "string",
16
- description: "Path to the Kubb config",
17
- short: "c"
18
- },
19
- port: {
20
- type: "string",
21
- description: `Port for the server (default: ${agentDefaults.port})`,
22
- short: "p"
23
- },
24
- host: {
25
- type: "string",
26
- description: "Host for the server",
27
- default: agentDefaults.host
28
- },
29
- "allow-write": {
30
- type: "boolean",
31
- description: "Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.",
32
- default: false
33
- },
34
- "allow-all": {
35
- type: "boolean",
36
- description: "Grant all permissions (implies --allow-write).",
37
- default: false
38
- }
39
- },
40
- async run({ values }) {
41
- const { runAgentStart } = await import("./agent-Ev5hU5hH.js");
42
- await runAgentStart({
43
- port: values.port !== void 0 ? values.port : void 0,
44
- host: values.host,
45
- configPath: values.config,
46
- allowWrite: values["allow-write"],
47
- allowAll: values["allow-all"],
48
- version
49
- });
50
- }
51
- })]
52
- });
53
- //#endregion
54
- export { command };
55
-
56
- //# sourceMappingURL=agent-v_2S-bnN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-v_2S-bnN.js","names":["command","startCommand"],"sources":["../src/commands/agent/start.ts","../src/commands/agent.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../../package.json'\nimport { agentDefaults } from '../../constants.ts'\n\nexport const command = defineCommand({\n name: 'start',\n description: 'Start the Agent server',\n options: {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n port: {\n type: 'string',\n description: `Port for the server (default: ${agentDefaults.port})`,\n short: 'p',\n },\n host: {\n type: 'string',\n description: 'Host for the server',\n default: agentDefaults.host,\n },\n 'allow-write': {\n type: 'boolean',\n description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',\n default: false,\n },\n 'allow-all': {\n type: 'boolean',\n description: 'Grant all permissions (implies --allow-write).',\n default: false,\n },\n },\n async run({ values }) {\n const { runAgentStart } = await import('../../runners/agent.ts')\n\n await runAgentStart({\n port: values.port !== undefined ? values.port : undefined,\n host: values.host,\n configPath: values.config,\n allowWrite: values['allow-write'],\n allowAll: values['allow-all'],\n version,\n })\n },\n})\n","import { defineCommand } from '@internals/utils'\nimport { command as startCommand } from './agent/start.ts'\n\nexport const command = defineCommand({\n name: 'agent',\n description: 'Manage the Kubb Agent server',\n subCommands: [startCommand],\n})\n"],"mappings":";;;;;;ACGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,aAAa,CDFQ,cAAc;EACnC,MAAM;EACN,aAAa;EACb,SAAS;GACP,QAAQ;IACN,MAAM;IACN,aAAa;IACb,OAAO;IACR;GACD,MAAM;IACJ,MAAM;IACN,aAAa,iCAAiC,cAAc,KAAK;IACjE,OAAO;IACR;GACD,MAAM;IACJ,MAAM;IACN,aAAa;IACb,SAAS,cAAc;IACxB;GACD,eAAe;IACb,MAAM;IACN,aAAa;IACb,SAAS;IACV;GACD,aAAa;IACX,MAAM;IACN,aAAa;IACb,SAAS;IACV;GACF;EACD,MAAM,IAAI,EAAE,UAAU;GACpB,MAAM,EAAE,kBAAkB,MAAM,OAAO;AAEvC,SAAM,cAAc;IAClB,MAAM,OAAO,SAAS,KAAA,IAAY,OAAO,OAAO,KAAA;IAChD,MAAM,OAAO;IACb,YAAY,OAAO;IACnB,YAAY,OAAO;IACnB,UAAU,OAAO;IACjB;IACD,CAAC;;EAEL,CCxCeC,CAAa;CAC5B,CAAC"}
@@ -1,148 +0,0 @@
1
- //#region src/constants.ts
2
- /**
3
- * Default filename for the Kubb configuration file.
4
- *
5
- * Used by the `init` command when scaffolding new projects and by the `agent` default config.
6
- */
7
- const KUBB_CONFIG_FILENAME = "kubb.config.ts";
8
- /**
9
- * NPM registry endpoint used to check for @kubb/cli updates.
10
- */
11
- const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
12
- /**
13
- * OpenTelemetry ingestion endpoint for anonymous usage telemetry.
14
- */
15
- const OTLP_ENDPOINT = "https://otlp.kubb.dev";
16
- /**
17
- * Horizontal rule rendered above/below the plain-logger generation summary.
18
- */
19
- const SUMMARY_SEPARATOR = "─".repeat(27);
20
- /**
21
- * Glob pattern for paths the file watcher ignores.
22
- */
23
- const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
24
- /**
25
- * Flags that short-circuit execution (help/version) — no telemetry notice is shown.
26
- */
27
- const QUIET_FLAGS = new Set([
28
- "--help",
29
- "-h",
30
- "--version",
31
- "-v"
32
- ]);
33
- const agentDefaults = {
34
- port: "3000",
35
- host: "localhost",
36
- configFile: KUBB_CONFIG_FILENAME,
37
- retryTimeout: "30000",
38
- studioUrl: "https://studio.kubb.dev",
39
- /**
40
- * Relative path from the @kubb/agent package root to the server entry.
41
- */
42
- serverEntryPath: ".output/server/index.mjs"
43
- };
44
- /**
45
- * Default values used during interactive `init` scaffolding.
46
- */
47
- const initDefaults = {
48
- inputPath: "./openapi.yaml",
49
- outputPath: "./src/gen",
50
- plugins: ["plugin-ts"]
51
- };
52
- /**
53
- * Maps each plugin value to the default config snippet inserted by `init`.
54
- * The `satisfies` constraint ensures all values remain plain strings while
55
- * `as const` keeps the object deeply immutable.
56
- */
57
- const pluginDefaultConfigs = {
58
- "plugin-ts": `pluginTs({
59
- output: { path: 'models' },
60
- })`,
61
- "plugin-client": `pluginClient({
62
- output: { path: 'clients' },
63
- })`,
64
- "plugin-react-query": `pluginReactQuery({
65
- output: { path: 'hooks' },
66
- })`,
67
- "plugin-vue-query": `pluginVueQuery({
68
- output: { path: 'hooks' },
69
- })`,
70
- "plugin-zod": `pluginZod({
71
- output: { path: 'zod' },
72
- })`,
73
- "plugin-faker": `pluginFaker({
74
- output: { path: 'mocks' },
75
- })`,
76
- "plugin-msw": `pluginMsw({
77
- output: { path: 'msw' },
78
- })`,
79
- "plugin-cypress": `pluginCypress({
80
- output: { path: 'cypress' },
81
- })`,
82
- "plugin-mcp": `pluginMcp({
83
- output: { path: 'mcp' },
84
- })`,
85
- "plugin-redoc": `pluginRedoc({
86
- output: { path: 'redoc' },
87
- })`
88
- };
89
- /**
90
- * Color palette used by randomCliColor() for deterministic plugin name coloring.
91
- */
92
- //#endregion
93
- Object.defineProperty(exports, "KUBB_CONFIG_FILENAME", {
94
- enumerable: true,
95
- get: function() {
96
- return KUBB_CONFIG_FILENAME;
97
- }
98
- });
99
- Object.defineProperty(exports, "KUBB_NPM_PACKAGE_URL", {
100
- enumerable: true,
101
- get: function() {
102
- return KUBB_NPM_PACKAGE_URL;
103
- }
104
- });
105
- Object.defineProperty(exports, "OTLP_ENDPOINT", {
106
- enumerable: true,
107
- get: function() {
108
- return OTLP_ENDPOINT;
109
- }
110
- });
111
- Object.defineProperty(exports, "QUIET_FLAGS", {
112
- enumerable: true,
113
- get: function() {
114
- return QUIET_FLAGS;
115
- }
116
- });
117
- Object.defineProperty(exports, "SUMMARY_SEPARATOR", {
118
- enumerable: true,
119
- get: function() {
120
- return SUMMARY_SEPARATOR;
121
- }
122
- });
123
- Object.defineProperty(exports, "WATCHER_IGNORED_PATHS", {
124
- enumerable: true,
125
- get: function() {
126
- return WATCHER_IGNORED_PATHS;
127
- }
128
- });
129
- Object.defineProperty(exports, "agentDefaults", {
130
- enumerable: true,
131
- get: function() {
132
- return agentDefaults;
133
- }
134
- });
135
- Object.defineProperty(exports, "initDefaults", {
136
- enumerable: true,
137
- get: function() {
138
- return initDefaults;
139
- }
140
- });
141
- Object.defineProperty(exports, "pluginDefaultConfigs", {
142
- enumerable: true,
143
- get: function() {
144
- return pluginDefaultConfigs;
145
- }
146
- });
147
-
148
- //# sourceMappingURL=constants-CnDXa1R6.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants-CnDXa1R6.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Default filename for the Kubb configuration file.\n *\n * Used by the `init` command when scaffolding new projects and by the `agent` default config.\n */\nexport const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const\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://studio.kubb.dev',\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\n/**\n * Default values used during interactive `init` scaffolding.\n */\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-ts'],\n} as const\n\n/**\n * Maps each plugin value to the default config snippet inserted by `init`.\n * The `satisfies` constraint ensures all values remain plain strings while\n * `as const` keeps the object deeply immutable.\n */\nexport const pluginDefaultConfigs = {\n 'plugin-ts': `pluginTs({\n output: { path: 'models' },\n })`,\n 'plugin-client': `pluginClient({\n output: { path: 'clients' },\n })`,\n 'plugin-react-query': `pluginReactQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-vue-query': `pluginVueQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-zod': `pluginZod({\n output: { path: 'zod' },\n })`,\n 'plugin-faker': `pluginFaker({\n output: { path: 'mocks' },\n })`,\n 'plugin-msw': `pluginMsw({\n output: { path: 'msw' },\n })`,\n 'plugin-cypress': `pluginCypress({\n output: { path: 'cypress' },\n })`,\n 'plugin-mcp': `pluginMcp({\n output: { path: 'mcp' },\n })`,\n 'plugin-redoc': `pluginRedoc({\n output: { path: 'redoc' },\n })`,\n} as const satisfies Record<string, string>\n\n/**\n * Color palette used by randomCliColor() for deterministic plugin name coloring.\n */\n"],"mappings":";;;;;;AAKA,MAAa,uBAAuB;;;;AAKpC,MAAa,uBAAuB;;;;AAKpC,MAAa,gBAAgB;;;;AAK7B,MAAa,oBAAoB,IAAI,OAAO,GAAG;;;;AAe/C,MAAa,wBAAwB;;;;AAKrC,MAAa,cAAc,IAAI,IAAI;CAAC;CAAU;CAAM;CAAa;CAAK,CAAU;AAEhF,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,YAAY;CACZ,cAAc;CACd,WAAW;;;;CAIX,iBAAiB;CAClB;;;;AAKD,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,YAAY;CACvB;;;;;;AAOD,MAAa,uBAAuB;CAClC,aAAa;;;CAGb,iBAAiB;;;CAGjB,sBAAsB;;;CAGtB,oBAAoB;;;CAGpB,cAAc;;;CAGd,gBAAgB;;;CAGhB,cAAc;;;CAGd,kBAAkB;;;CAGlB,cAAc;;;CAGd,gBAAgB;;;CAGjB"}
@@ -1,95 +0,0 @@
1
- //#region src/constants.ts
2
- /**
3
- * Default filename for the Kubb configuration file.
4
- *
5
- * Used by the `init` command when scaffolding new projects and by the `agent` default config.
6
- */
7
- const KUBB_CONFIG_FILENAME = "kubb.config.ts";
8
- /**
9
- * NPM registry endpoint used to check for @kubb/cli updates.
10
- */
11
- const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
12
- /**
13
- * OpenTelemetry ingestion endpoint for anonymous usage telemetry.
14
- */
15
- const OTLP_ENDPOINT = "https://otlp.kubb.dev";
16
- /**
17
- * Horizontal rule rendered above/below the plain-logger generation summary.
18
- */
19
- const SUMMARY_SEPARATOR = "─".repeat(27);
20
- /**
21
- * Glob pattern for paths the file watcher ignores.
22
- */
23
- const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
24
- /**
25
- * Flags that short-circuit execution (help/version) — no telemetry notice is shown.
26
- */
27
- const QUIET_FLAGS = new Set([
28
- "--help",
29
- "-h",
30
- "--version",
31
- "-v"
32
- ]);
33
- const agentDefaults = {
34
- port: "3000",
35
- host: "localhost",
36
- configFile: KUBB_CONFIG_FILENAME,
37
- retryTimeout: "30000",
38
- studioUrl: "https://studio.kubb.dev",
39
- /**
40
- * Relative path from the @kubb/agent package root to the server entry.
41
- */
42
- serverEntryPath: ".output/server/index.mjs"
43
- };
44
- /**
45
- * Default values used during interactive `init` scaffolding.
46
- */
47
- const initDefaults = {
48
- inputPath: "./openapi.yaml",
49
- outputPath: "./src/gen",
50
- plugins: ["plugin-ts"]
51
- };
52
- /**
53
- * Maps each plugin value to the default config snippet inserted by `init`.
54
- * The `satisfies` constraint ensures all values remain plain strings while
55
- * `as const` keeps the object deeply immutable.
56
- */
57
- const pluginDefaultConfigs = {
58
- "plugin-ts": `pluginTs({
59
- output: { path: 'models' },
60
- })`,
61
- "plugin-client": `pluginClient({
62
- output: { path: 'clients' },
63
- })`,
64
- "plugin-react-query": `pluginReactQuery({
65
- output: { path: 'hooks' },
66
- })`,
67
- "plugin-vue-query": `pluginVueQuery({
68
- output: { path: 'hooks' },
69
- })`,
70
- "plugin-zod": `pluginZod({
71
- output: { path: 'zod' },
72
- })`,
73
- "plugin-faker": `pluginFaker({
74
- output: { path: 'mocks' },
75
- })`,
76
- "plugin-msw": `pluginMsw({
77
- output: { path: 'msw' },
78
- })`,
79
- "plugin-cypress": `pluginCypress({
80
- output: { path: 'cypress' },
81
- })`,
82
- "plugin-mcp": `pluginMcp({
83
- output: { path: 'mcp' },
84
- })`,
85
- "plugin-redoc": `pluginRedoc({
86
- output: { path: 'redoc' },
87
- })`
88
- };
89
- /**
90
- * Color palette used by randomCliColor() for deterministic plugin name coloring.
91
- */
92
- //#endregion
93
- export { SUMMARY_SEPARATOR as a, initDefaults as c, QUIET_FLAGS as i, pluginDefaultConfigs as l, KUBB_NPM_PACKAGE_URL as n, WATCHER_IGNORED_PATHS as o, OTLP_ENDPOINT as r, agentDefaults as s, KUBB_CONFIG_FILENAME as t };
94
-
95
- //# sourceMappingURL=constants-aL3CP_Wq.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants-aL3CP_Wq.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Default filename for the Kubb configuration file.\n *\n * Used by the `init` command when scaffolding new projects and by the `agent` default config.\n */\nexport const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const\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://studio.kubb.dev',\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\n/**\n * Default values used during interactive `init` scaffolding.\n */\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-ts'],\n} as const\n\n/**\n * Maps each plugin value to the default config snippet inserted by `init`.\n * The `satisfies` constraint ensures all values remain plain strings while\n * `as const` keeps the object deeply immutable.\n */\nexport const pluginDefaultConfigs = {\n 'plugin-ts': `pluginTs({\n output: { path: 'models' },\n })`,\n 'plugin-client': `pluginClient({\n output: { path: 'clients' },\n })`,\n 'plugin-react-query': `pluginReactQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-vue-query': `pluginVueQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-zod': `pluginZod({\n output: { path: 'zod' },\n })`,\n 'plugin-faker': `pluginFaker({\n output: { path: 'mocks' },\n })`,\n 'plugin-msw': `pluginMsw({\n output: { path: 'msw' },\n })`,\n 'plugin-cypress': `pluginCypress({\n output: { path: 'cypress' },\n })`,\n 'plugin-mcp': `pluginMcp({\n output: { path: 'mcp' },\n })`,\n 'plugin-redoc': `pluginRedoc({\n output: { path: 'redoc' },\n })`,\n} as const satisfies Record<string, string>\n\n/**\n * Color palette used by randomCliColor() for deterministic plugin name coloring.\n */\n"],"mappings":";;;;;;AAKA,MAAa,uBAAuB;;;;AAKpC,MAAa,uBAAuB;;;;AAKpC,MAAa,gBAAgB;;;;AAK7B,MAAa,oBAAoB,IAAI,OAAO,GAAG;;;;AAe/C,MAAa,wBAAwB;;;;AAKrC,MAAa,cAAc,IAAI,IAAI;CAAC;CAAU;CAAM;CAAa;CAAK,CAAU;AAEhF,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,YAAY;CACZ,cAAc;CACd,WAAW;;;;CAIX,iBAAiB;CAClB;;;;AAKD,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,YAAY;CACvB;;;;;;AAOD,MAAa,uBAAuB;CAClC,aAAa;;;CAGb,iBAAiB;;;CAGjB,sBAAsB;;;CAGtB,oBAAoB;;;CAGpB,cAAc;;;CAGd,gBAAgB;;;CAGhB,cAAc;;;CAGd,kBAAkB;;;CAGlB,cAAc;;;CAGd,gBAAgB;;;CAGjB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-BaJRhbCS.js","names":[],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\n\nexport const command = defineCommand({\n name: 'generate',\n description: \"[input] Generate files based on a 'kubb.config.ts' file\",\n arguments: ['[input]'],\n options: {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n logLevel: {\n type: 'string',\n description: 'Info, silent, verbose or debug',\n short: 'l',\n default: 'info',\n hint: 'silent|info|verbose|debug',\n enum: ['silent', 'info', 'verbose', 'debug'],\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n short: 'w',\n default: false,\n },\n debug: {\n type: 'boolean',\n description: 'Override logLevel to debug',\n short: 'd',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n short: 'v',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n },\n async run({ values, positionals }) {\n const logLevel = values.debug ? 'debug' : values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel\n const { runGenerateCommand } = await import('../runners/generate.ts')\n\n await runGenerateCommand({\n input: positionals[0],\n configPath: values.config,\n logLevel,\n watch: values.watch,\n })\n },\n})\n"],"mappings":";;;AAEA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,WAAW,CAAC,UAAU;CACtB,SAAS;EACP,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACR;EACD,UAAU;GACR,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACT,MAAM;GACN,MAAM;IAAC;IAAU;IAAQ;IAAW;IAAQ;GAC7C;EACD,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACD,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACD,SAAS;GACP,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACD,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACF;CACD,MAAM,IAAI,EAAE,QAAQ,eAAe;EACjC,MAAM,WAAW,OAAO,QAAQ,UAAU,OAAO,UAAU,YAAY,OAAO,SAAS,WAAW,OAAO;EACzG,MAAM,EAAE,uBAAuB,MAAM,OAAO;AAE5C,QAAM,mBAAmB;GACvB,OAAO,YAAY;GACnB,YAAY,OAAO;GACnB;GACA,OAAO,OAAO;GACf,CAAC;;CAEL,CAAC"}