@kubb/cli 4.11.3 → 4.12.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/dist/generate-BfIvo80v.js +1249 -0
- package/dist/generate-BfIvo80v.js.map +1 -0
- package/dist/generate-BoZaeXSl.cjs +1256 -0
- package/dist/generate-BoZaeXSl.cjs.map +1 -0
- package/dist/index.cjs +9 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -30
- package/dist/index.js.map +1 -1
- package/dist/{mcp-BIRDY8xn.js → mcp-LLlOFV3c.js} +5 -6
- package/dist/mcp-LLlOFV3c.js.map +1 -0
- package/dist/{mcp-BQjDRDXR.cjs → mcp-N1IVyiXf.cjs} +5 -7
- package/dist/mcp-N1IVyiXf.cjs.map +1 -0
- package/dist/package-B1rQiz1w.js +6 -0
- package/dist/package-B1rQiz1w.js.map +1 -0
- package/dist/package-CngLazMY.cjs +12 -0
- package/dist/package-CngLazMY.cjs.map +1 -0
- package/dist/{validate-0i6Q9eIy.js → validate-BptoQ-63.js} +5 -6
- package/dist/validate-BptoQ-63.js.map +1 -0
- package/dist/{validate-6F-VPZR7.cjs → validate-Dn6hZ7Z4.cjs} +5 -7
- package/dist/validate-Dn6hZ7Z4.cjs.map +1 -0
- package/package.json +7 -7
- package/src/commands/generate.ts +52 -65
- package/src/commands/mcp.ts +4 -5
- package/src/commands/validate.ts +4 -5
- package/src/index.ts +8 -23
- package/src/loggers/clackLogger.ts +433 -0
- package/src/loggers/envDetection.ts +28 -0
- package/src/loggers/fileSystemLogger.ts +79 -0
- package/src/loggers/githubActionsLogger.ts +310 -0
- package/src/loggers/index.ts +5 -0
- package/src/loggers/plainLogger.ts +274 -0
- package/src/loggers/types.ts +1 -0
- package/src/loggers/utils.ts +43 -0
- package/src/runners/generate.ts +196 -208
- package/src/utils/Writables.ts +12 -8
- package/src/utils/executeHooks.ts +11 -18
- package/src/utils/getCosmiConfig.ts +6 -1
- package/src/utils/getSummary.ts +20 -42
- package/src/utils/randomColour.ts +26 -0
- package/src/utils/watcher.ts +2 -4
- package/dist/generate-CYBFB3tU.js +0 -221
- package/dist/generate-CYBFB3tU.js.map +0 -1
- package/dist/generate-CpBJ2Y-n.js +0 -342
- package/dist/generate-CpBJ2Y-n.js.map +0 -1
- package/dist/generate-DpHvARzf.cjs +0 -345
- package/dist/generate-DpHvARzf.cjs.map +0 -1
- package/dist/generate-KUqCSnZp.cjs +0 -225
- package/dist/generate-KUqCSnZp.cjs.map +0 -1
- package/dist/mcp-BIRDY8xn.js.map +0 -1
- package/dist/mcp-BQjDRDXR.cjs.map +0 -1
- package/dist/validate-0i6Q9eIy.js.map +0 -1
- package/dist/validate-6F-VPZR7.cjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.1",
|
|
4
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
6
|
"cli",
|
|
@@ -50,26 +50,26 @@
|
|
|
50
50
|
}
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@clack/prompts": "1.0.0-alpha.8",
|
|
53
54
|
"chokidar": "^4.0.3",
|
|
54
55
|
"citty": "^0.1.6",
|
|
55
|
-
"cli-progress": "^3.12.0",
|
|
56
|
-
"consola": "^3.4.2",
|
|
57
56
|
"cosmiconfig": "^9.0.0",
|
|
58
57
|
"execa": "^9.6.1",
|
|
59
58
|
"gradient-string": "^3.0.0",
|
|
60
59
|
"jiti": "^2.6.1",
|
|
61
60
|
"latest-version": "^9.0.0",
|
|
62
61
|
"picocolors": "^1.1.1",
|
|
62
|
+
"seedrandom": "^3.0.5",
|
|
63
63
|
"semver": "^7.7.3",
|
|
64
64
|
"string-argv": "^0.3.2",
|
|
65
|
-
"@kubb/core": "4.
|
|
65
|
+
"@kubb/core": "4.12.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@types/
|
|
68
|
+
"@types/seedrandom": "^3.0.8",
|
|
69
69
|
"@types/semver": "^7.7.1",
|
|
70
70
|
"source-map-support": "^0.5.21",
|
|
71
|
-
"@kubb/mcp": "4.
|
|
72
|
-
"@kubb/oas": "4.
|
|
71
|
+
"@kubb/mcp": "4.12.1",
|
|
72
|
+
"@kubb/oas": "4.12.1"
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=20"
|
package/src/commands/generate.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import * as process from 'node:process'
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import * as clack from '@clack/prompts'
|
|
4
|
+
import { isInputPath, type KubbEvents, LogLevel, PromiseManager } from '@kubb/core'
|
|
5
|
+
import { AsyncEventEmitter } from '@kubb/core/utils'
|
|
5
6
|
import type { ArgsDef, ParsedArgs } from 'citty'
|
|
6
7
|
import { defineCommand, showUsage } from 'citty'
|
|
7
|
-
import
|
|
8
|
+
import getLatestVersion from 'latest-version'
|
|
8
9
|
import pc from 'picocolors'
|
|
10
|
+
import { lt } from 'semver'
|
|
11
|
+
import { version } from '../../package.json'
|
|
12
|
+
import { setupLogger } from '../loggers/utils.ts'
|
|
13
|
+
import { generate } from '../runners/generate.ts'
|
|
9
14
|
import { getConfig } from '../utils/getConfig.ts'
|
|
10
15
|
import { getCosmiConfig } from '../utils/getCosmiConfig.ts'
|
|
11
16
|
import { startWatcher } from '../utils/watcher.ts'
|
|
12
17
|
|
|
13
|
-
declare global {
|
|
14
|
-
var isDevtoolsEnabled: any
|
|
15
|
-
}
|
|
16
|
-
|
|
17
18
|
const args = {
|
|
18
19
|
config: {
|
|
19
20
|
type: 'string',
|
|
@@ -62,11 +63,10 @@ const command = defineCommand({
|
|
|
62
63
|
},
|
|
63
64
|
args,
|
|
64
65
|
async run(commandContext) {
|
|
65
|
-
const progressCache = new Map<string, SingleBar>()
|
|
66
|
-
|
|
67
66
|
const { args } = commandContext
|
|
68
|
-
|
|
69
67
|
const input = args._[0]
|
|
68
|
+
const events = new AsyncEventEmitter<KubbEvents>()
|
|
69
|
+
const promiseManager = new PromiseManager()
|
|
70
70
|
|
|
71
71
|
if (args.help) {
|
|
72
72
|
return showUsage(command)
|
|
@@ -80,75 +80,62 @@ const command = defineCommand({
|
|
|
80
80
|
args.logLevel = 'verbose'
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
const logLevel =
|
|
84
|
-
const logger = createLogger({
|
|
85
|
-
logLevel,
|
|
86
|
-
})
|
|
87
|
-
const { generate } = await import('../runners/generate.ts')
|
|
83
|
+
const logLevel = LogLevel[args.logLevel as keyof typeof LogLevel] || 3
|
|
88
84
|
|
|
89
|
-
|
|
85
|
+
await setupLogger(events, { logLevel })
|
|
90
86
|
|
|
91
|
-
const
|
|
92
|
-
logger.emit('success', `Config loaded(${pc.dim(path.relative(process.cwd(), result.filepath))})`)
|
|
87
|
+
const latestVersion = await getLatestVersion('@kubb/cli')
|
|
93
88
|
|
|
94
|
-
|
|
89
|
+
if (lt(version, latestVersion)) {
|
|
90
|
+
await events.emit('version:new', version, latestVersion)
|
|
91
|
+
}
|
|
95
92
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const promiseManager = new PromiseManager()
|
|
99
|
-
const promises = config.map((c) => () => {
|
|
100
|
-
progressCache.clear()
|
|
93
|
+
try {
|
|
94
|
+
await events.emit('lifecycle:start', version)
|
|
101
95
|
|
|
102
|
-
|
|
103
|
-
input,
|
|
104
|
-
config: c,
|
|
105
|
-
args,
|
|
106
|
-
progressCache,
|
|
107
|
-
})
|
|
108
|
-
})
|
|
96
|
+
await events.emit('config:start')
|
|
109
97
|
|
|
110
|
-
|
|
111
|
-
return
|
|
112
|
-
}
|
|
98
|
+
const result = await getCosmiConfig('kubb', args.config)
|
|
113
99
|
|
|
114
|
-
|
|
100
|
+
await events.emit('info', 'Config loaded', path.relative(process.cwd(), result.filepath))
|
|
115
101
|
|
|
116
|
-
await
|
|
117
|
-
|
|
118
|
-
config,
|
|
119
|
-
progressCache,
|
|
120
|
-
args,
|
|
121
|
-
})
|
|
102
|
+
const config = await getConfig(result, args)
|
|
103
|
+
const configs = Array.isArray(config) ? config : [config]
|
|
122
104
|
|
|
123
|
-
|
|
124
|
-
|
|
105
|
+
await events.emit('success', 'Config loaded successfully', path.relative(process.cwd(), result.filepath))
|
|
106
|
+
await events.emit('config:end', configs)
|
|
125
107
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
108
|
+
const promises = configs.map((config) => {
|
|
109
|
+
return async () => {
|
|
110
|
+
if (isInputPath(config) && args.watch) {
|
|
111
|
+
await startWatcher([input || config.input.path], async (paths) => {
|
|
112
|
+
await generate({
|
|
113
|
+
input,
|
|
114
|
+
config,
|
|
115
|
+
logLevel,
|
|
116
|
+
events,
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
clack.log.step(pc.yellow(`Watching for changes in ${paths.join(' and ')}`))
|
|
120
|
+
})
|
|
138
121
|
|
|
139
|
-
|
|
122
|
+
return
|
|
123
|
+
}
|
|
140
124
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
125
|
+
await generate({
|
|
126
|
+
input,
|
|
127
|
+
config,
|
|
128
|
+
logLevel,
|
|
129
|
+
events,
|
|
130
|
+
})
|
|
131
|
+
}
|
|
145
132
|
})
|
|
146
133
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
134
|
+
await promiseManager.run('seq', promises)
|
|
135
|
+
|
|
136
|
+
await events.emit('lifecycle:end')
|
|
137
|
+
} catch (e) {
|
|
138
|
+
await events.emit('error', e as Error)
|
|
152
139
|
}
|
|
153
140
|
},
|
|
154
141
|
})
|
package/src/commands/mcp.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ArgsDef, ParsedArgs } from 'citty'
|
|
2
2
|
import { defineCommand, showUsage } from 'citty'
|
|
3
|
-
import consola from 'consola'
|
|
4
3
|
import { createJiti } from 'jiti'
|
|
5
4
|
import pc from 'picocolors'
|
|
6
5
|
|
|
@@ -36,16 +35,16 @@ const command = defineCommand({
|
|
|
36
35
|
try {
|
|
37
36
|
mod = await jiti.import('@kubb/mcp', { default: true })
|
|
38
37
|
} catch (_e) {
|
|
39
|
-
|
|
38
|
+
console.error(`Import of '@kubb/mcp' is required to start the MCP server`)
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
const { startServer } = mod
|
|
43
42
|
try {
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
console.log('⏳ Starting MCP server...')
|
|
44
|
+
console.warn(pc.yellow('This feature is still under development — use with caution'))
|
|
46
45
|
await startServer()
|
|
47
46
|
} catch (e) {
|
|
48
|
-
|
|
47
|
+
console.error((e as Error)?.message)
|
|
49
48
|
}
|
|
50
49
|
},
|
|
51
50
|
})
|
package/src/commands/validate.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
2
|
import type { ArgsDef, ParsedArgs } from 'citty'
|
|
3
3
|
import { defineCommand, showUsage } from 'citty'
|
|
4
|
-
import consola from 'consola'
|
|
5
4
|
import { createJiti } from 'jiti'
|
|
6
5
|
|
|
7
6
|
const jiti = createJiti(import.meta.url, {
|
|
@@ -42,7 +41,7 @@ const command = defineCommand({
|
|
|
42
41
|
try {
|
|
43
42
|
mod = await jiti.import('@kubb/oas', { default: true })
|
|
44
43
|
} catch (_e) {
|
|
45
|
-
|
|
44
|
+
console.error(`Import of '@kubb/oas' is required to do validation`)
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
const { parse } = mod
|
|
@@ -50,10 +49,10 @@ const command = defineCommand({
|
|
|
50
49
|
const oas = await parse(args.input)
|
|
51
50
|
await oas.valdiate()
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
console.log('✅ Validation success')
|
|
54
53
|
} catch (e) {
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
console.error('❌ Validation failed')
|
|
55
|
+
console.log((e as Error)?.message)
|
|
57
56
|
process.exit(1)
|
|
58
57
|
}
|
|
59
58
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { defineCommand, runCommand, runMain } from 'citty'
|
|
2
|
-
import consola from 'consola'
|
|
3
|
-
import { default as gradientString } from 'gradient-string'
|
|
4
|
-
import getLatestVersion from 'latest-version'
|
|
5
|
-
import { lt } from 'semver'
|
|
6
|
-
import { version } from '../package.json'
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
import { version } from '../package.json'
|
|
9
4
|
|
|
10
5
|
const main = defineCommand({
|
|
11
6
|
meta: {
|
|
12
|
-
name,
|
|
7
|
+
name: 'kubb',
|
|
13
8
|
version,
|
|
14
9
|
description: 'Kubb generation',
|
|
15
10
|
},
|
|
@@ -25,24 +20,14 @@ const main = defineCommand({
|
|
|
25
20
|
console.log(version)
|
|
26
21
|
process.exit(0)
|
|
27
22
|
}
|
|
28
|
-
try {
|
|
29
|
-
consola.log(gradientString(['#F58517', '#F5A217', '#F55A17'])('Kubb CLI:'))
|
|
30
23
|
|
|
31
|
-
|
|
24
|
+
if (args.debug) {
|
|
25
|
+
args.logLevel = 'debug'
|
|
26
|
+
}
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
message: `\`v${version}\` → \`v${latestVersion}\`
|
|
37
|
-
Run \`npm install -g @kubb/cli\` to update`,
|
|
38
|
-
style: {
|
|
39
|
-
padding: 2,
|
|
40
|
-
borderColor: 'yellow',
|
|
41
|
-
borderStyle: 'rounded',
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
} catch (_e) {}
|
|
28
|
+
if (args.verbose) {
|
|
29
|
+
args.logLevel = 'verbose'
|
|
30
|
+
}
|
|
46
31
|
|
|
47
32
|
if (!['generate', 'validate', 'mcp'].includes(rawArgs[0] as string)) {
|
|
48
33
|
// generate is not being used
|