@kubb/cli 3.13.2 → 3.14.1
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/{chunk-EGPY7KZT.cjs → chunk-VVNXHIJS.cjs} +4 -4
- package/dist/{chunk-EGPY7KZT.cjs.map → chunk-VVNXHIJS.cjs.map} +1 -1
- package/dist/{generate-4F5PQZNA.cjs → generate-7JAJY63M.cjs} +10 -10
- package/dist/{generate-4F5PQZNA.cjs.map → generate-7JAJY63M.cjs.map} +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-MXYNXCQF.cjs} +193 -191
- package/dist/generate-MXYNXCQF.cjs.map +1 -0
- package/dist/{generate-R2AKCBCX.js → generate-O3UFDY6P.js} +9 -7
- package/dist/generate-O3UFDY6P.js.map +1 -0
- package/dist/index.cjs +14 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/mcp-PKBP525K.js +48 -0
- package/dist/mcp-PKBP525K.js.map +1 -0
- package/dist/mcp-WWVA2S6S.cjs +56 -0
- package/dist/mcp-WWVA2S6S.cjs.map +1 -0
- package/dist/validate-ONN45RYY.js +58 -0
- package/dist/validate-ONN45RYY.js.map +1 -0
- package/dist/validate-TEQYQFI4.cjs +67 -0
- package/dist/validate-TEQYQFI4.cjs.map +1 -0
- package/package.json +17 -12
- 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
|
@@ -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) {
|