@kubb/cli 3.13.1 → 3.14.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/LICENSE +1 -1
- package/dist/{generate-APFHZUB2.js → generate-BQMCI2PI.js} +3 -3
- package/dist/{generate-APFHZUB2.js.map → generate-BQMCI2PI.js.map} +1 -1
- package/dist/{generate-NXWDSHAC.cjs → generate-KWI4M7ZL.cjs} +8 -6
- package/dist/generate-KWI4M7ZL.cjs.map +1 -0
- package/dist/{generate-R2AKCBCX.js → generate-O3UFDY6P.js} +9 -7
- package/dist/generate-O3UFDY6P.js.map +1 -0
- package/dist/{generate-4F5PQZNA.cjs → generate-UCQVYQWW.cjs} +3 -3
- package/dist/{generate-4F5PQZNA.cjs.map → generate-UCQVYQWW.cjs.map} +1 -1
- package/dist/index.cjs +12 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/mcp-4JT7CWBR.cjs +56 -0
- package/dist/mcp-4JT7CWBR.cjs.map +1 -0
- package/dist/mcp-PKBP525K.js +48 -0
- package/dist/mcp-PKBP525K.js.map +1 -0
- package/dist/validate-ONIM7M3A.cjs +67 -0
- package/dist/validate-ONIM7M3A.cjs.map +1 -0
- package/dist/validate-ONN45RYY.js +58 -0
- package/dist/validate-ONN45RYY.js.map +1 -0
- package/package.json +16 -11
- package/src/commands/mcp.ts +52 -0
- package/src/commands/validate.ts +63 -0
- package/src/index.ts +5 -4
- package/src/runners/generate.ts +6 -10
- package/dist/generate-NXWDSHAC.cjs.map +0 -1
- package/dist/generate-R2AKCBCX.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.14.0",
|
|
4
|
+
"description": "Command-line interface for Kubb, enabling easy generation of TypeScript, React-Query, Zod, and other code from OpenAPI specifications.",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"command-line",
|
|
6
8
|
"typescript",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
+
"openapi",
|
|
10
|
+
"swagger",
|
|
11
|
+
"code-generator",
|
|
9
12
|
"codegen",
|
|
10
|
-
"
|
|
13
|
+
"plugins",
|
|
14
|
+
"kubb"
|
|
11
15
|
],
|
|
12
16
|
"repository": {
|
|
13
17
|
"type": "git",
|
|
@@ -52,8 +56,8 @@
|
|
|
52
56
|
"p-queue": "^8.1.0",
|
|
53
57
|
"semver": "^7.7.2",
|
|
54
58
|
"string-argv": "^0.3.2",
|
|
55
|
-
"@kubb/core": "3.
|
|
56
|
-
"@kubb/ui": "3.
|
|
59
|
+
"@kubb/core": "3.14.0",
|
|
60
|
+
"@kubb/ui": "3.14.0"
|
|
57
61
|
},
|
|
58
62
|
"devDependencies": {
|
|
59
63
|
"@types/cli-progress": "^3.11.6",
|
|
@@ -62,10 +66,11 @@
|
|
|
62
66
|
"source-map-support": "^0.5.21",
|
|
63
67
|
"tsup": "^8.5.0",
|
|
64
68
|
"typescript": "^5.8.3",
|
|
65
|
-
"@kubb/config-ts": "3.
|
|
66
|
-
"@kubb/config-tsup": "3.
|
|
67
|
-
"@kubb/mcp": "3.
|
|
68
|
-
"@kubb/
|
|
69
|
+
"@kubb/config-ts": "3.14.0",
|
|
70
|
+
"@kubb/config-tsup": "3.14.0",
|
|
71
|
+
"@kubb/mcp": "3.14.0",
|
|
72
|
+
"@kubb/oas": "3.14.0",
|
|
73
|
+
"@kubb/plugin-oas": "3.14.0"
|
|
69
74
|
},
|
|
70
75
|
"engines": {
|
|
71
76
|
"node": ">=20"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ArgsDef, ParsedArgs } from 'citty'
|
|
2
|
+
import { defineCommand, showUsage } from 'citty'
|
|
3
|
+
import consola from 'consola'
|
|
4
|
+
import { createJiti } from 'jiti'
|
|
5
|
+
|
|
6
|
+
const jiti = createJiti(import.meta.url, {
|
|
7
|
+
sourceMaps: true,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const args = {
|
|
11
|
+
help: {
|
|
12
|
+
type: 'boolean',
|
|
13
|
+
description: 'Show help',
|
|
14
|
+
alias: 'h',
|
|
15
|
+
default: false,
|
|
16
|
+
},
|
|
17
|
+
} as const satisfies ArgsDef
|
|
18
|
+
|
|
19
|
+
export type Args = ParsedArgs<typeof args>
|
|
20
|
+
|
|
21
|
+
const command = defineCommand({
|
|
22
|
+
meta: {
|
|
23
|
+
name: 'mcp',
|
|
24
|
+
description: 'Start the server to enable the MCP client to interact with the LLM.',
|
|
25
|
+
},
|
|
26
|
+
args,
|
|
27
|
+
async run(commandContext) {
|
|
28
|
+
const { args } = commandContext
|
|
29
|
+
|
|
30
|
+
if (args.help) {
|
|
31
|
+
return showUsage(command)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let mod: any
|
|
35
|
+
try {
|
|
36
|
+
mod = await jiti.import('@kubb/mcp', { default: true })
|
|
37
|
+
} catch (_e) {
|
|
38
|
+
consola.error(`Import of '@kubb/mcp' is required to start the MCP server`)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { startServer } = mod
|
|
42
|
+
try {
|
|
43
|
+
consola.start('Starting MCP server...')
|
|
44
|
+
consola.warn('This feature is still under development — use with caution')
|
|
45
|
+
await startServer()
|
|
46
|
+
} catch (e) {
|
|
47
|
+
consola.error((e as Error)?.message)
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
export default command
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import type { ArgsDef, ParsedArgs } from 'citty'
|
|
3
|
+
import { defineCommand, showUsage } from 'citty'
|
|
4
|
+
import consola from 'consola'
|
|
5
|
+
import { createJiti } from 'jiti'
|
|
6
|
+
|
|
7
|
+
const jiti = createJiti(import.meta.url, {
|
|
8
|
+
sourceMaps: true,
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
const args = {
|
|
12
|
+
input: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'Path to Swagger/OpenAPI file',
|
|
15
|
+
alias: 'i',
|
|
16
|
+
},
|
|
17
|
+
help: {
|
|
18
|
+
type: 'boolean',
|
|
19
|
+
description: 'Show help',
|
|
20
|
+
alias: 'h',
|
|
21
|
+
default: false,
|
|
22
|
+
},
|
|
23
|
+
} as const satisfies ArgsDef
|
|
24
|
+
|
|
25
|
+
export type Args = ParsedArgs<typeof args>
|
|
26
|
+
|
|
27
|
+
const command = defineCommand({
|
|
28
|
+
meta: {
|
|
29
|
+
name: 'validate',
|
|
30
|
+
description: 'Validate a Swagger/OpenAPI file',
|
|
31
|
+
},
|
|
32
|
+
args,
|
|
33
|
+
async run(commandContext) {
|
|
34
|
+
const { args } = commandContext
|
|
35
|
+
|
|
36
|
+
if (args.help) {
|
|
37
|
+
return showUsage(command)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (args.input) {
|
|
41
|
+
let mod: any
|
|
42
|
+
try {
|
|
43
|
+
mod = await jiti.import('@kubb/oas', { default: true })
|
|
44
|
+
} catch (_e) {
|
|
45
|
+
consola.error(`Import of '@kubb/oas' is required to do validation`)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { parse } = mod
|
|
49
|
+
try {
|
|
50
|
+
const oas = await parse(args.input)
|
|
51
|
+
await oas.valdiate()
|
|
52
|
+
|
|
53
|
+
consola.success('Validation success')
|
|
54
|
+
} catch (e) {
|
|
55
|
+
consola.fail('Validation failed')
|
|
56
|
+
consola.log((e as Error)?.message)
|
|
57
|
+
process.exit(1)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
export default command
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { defineCommand, runCommand, runMain } from 'citty'
|
|
2
|
+
import consola from 'consola'
|
|
3
|
+
import { default as gradientString } from 'gradient-string'
|
|
2
4
|
import getLatestVersion from 'latest-version'
|
|
3
5
|
import { lt } from 'semver'
|
|
4
|
-
import { default as gradientString } from 'gradient-string'
|
|
5
|
-
|
|
6
6
|
import { version } from '../package.json'
|
|
7
|
-
import consola from 'consola'
|
|
8
7
|
|
|
9
8
|
const name = 'kubb'
|
|
10
9
|
|
|
@@ -34,7 +33,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
34
33
|
}
|
|
35
34
|
} catch (_e) {}
|
|
36
35
|
|
|
37
|
-
if (!['generate'].includes(rawArgs[0] as string)) {
|
|
36
|
+
if (!['generate', 'validate', 'mcp'].includes(rawArgs[0] as string)) {
|
|
38
37
|
console.log(rawArgs[0])
|
|
39
38
|
// generate is not being used
|
|
40
39
|
const generateCommand = await import('./commands/generate.ts').then((r) => r.default)
|
|
@@ -46,6 +45,8 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
46
45
|
},
|
|
47
46
|
subCommands: {
|
|
48
47
|
generate: () => import('./commands/generate.ts').then((r) => r.default),
|
|
48
|
+
validate: () => import('./commands/validate.ts').then((r) => r.default),
|
|
49
|
+
mcp: () => import('./commands/mcp.ts').then((r) => r.default),
|
|
49
50
|
},
|
|
50
51
|
})
|
|
51
52
|
|
package/src/runners/generate.ts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { colors } from 'consola/utils'
|
|
4
|
-
|
|
1
|
+
import process from 'node:process'
|
|
5
2
|
import { type Config, safeBuild, setup } from '@kubb/core'
|
|
3
|
+
import { createLogger, LogMapper } from '@kubb/core/logger'
|
|
4
|
+
import { Presets, SingleBar } from 'cli-progress'
|
|
5
|
+
import { colors } from 'consola/utils'
|
|
6
|
+
import type { Args } from '../commands/generate.ts'
|
|
6
7
|
import { executeHooks } from '../utils/executeHooks.ts'
|
|
7
8
|
import { getErrorCauses } from '../utils/getErrorCauses.ts'
|
|
8
9
|
import { getSummary } from '../utils/getSummary.ts'
|
|
9
10
|
|
|
10
|
-
import { createLogger } from '@kubb/core/logger'
|
|
11
|
-
import { Presets, SingleBar } from 'cli-progress'
|
|
12
|
-
import type { Args } from '../commands/generate.ts'
|
|
13
|
-
import process from 'node:process'
|
|
14
|
-
|
|
15
11
|
type GenerateProps = {
|
|
16
12
|
input?: string
|
|
17
13
|
config: Config
|
|
@@ -134,7 +130,7 @@ export async function generate({ input, config, progressCache, args }: GenerateP
|
|
|
134
130
|
|
|
135
131
|
logger.consola?.error(error)
|
|
136
132
|
|
|
137
|
-
process.exit(
|
|
133
|
+
process.exit(1)
|
|
138
134
|
}
|
|
139
135
|
|
|
140
136
|
if (config.hooks) {
|