@kubb/cli 5.0.0-alpha.9 → 5.0.0-beta.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/README.md +4 -2
- package/bin/kubb.js +6 -0
- package/dist/agent-B_pirbeB.cjs +116 -0
- package/dist/agent-B_pirbeB.cjs.map +1 -0
- package/dist/{agent-BKphjOIF.cjs → agent-CUmEyiqY.cjs} +5 -5
- package/dist/agent-CUmEyiqY.cjs.map +1 -0
- package/dist/agent-Ev5hU5hH.js +112 -0
- package/dist/agent-Ev5hU5hH.js.map +1 -0
- package/dist/{agent-5mmp7QzF.js → agent-v_2S-bnN.js} +5 -5
- package/dist/agent-v_2S-bnN.js.map +1 -0
- package/dist/{constants-D0XHAHeZ.cjs → constants-CnDXa1R6.cjs} +30 -60
- package/dist/constants-CnDXa1R6.cjs.map +1 -0
- package/dist/{constants-DJM9zCXm.js → constants-aL3CP_Wq.js} +23 -59
- package/dist/constants-aL3CP_Wq.js.map +1 -0
- package/dist/define-Bdn8j5VM.cjs +54 -0
- package/dist/define-Bdn8j5VM.cjs.map +1 -0
- package/dist/define-Ctii4bel.js +43 -0
- package/dist/define-Ctii4bel.js.map +1 -0
- package/dist/{errors-DBW0N9w4.cjs → errors-CLCjoSg0.cjs} +22 -6
- package/dist/errors-CLCjoSg0.cjs.map +1 -0
- package/dist/errors-CjPmyZHy.js +43 -0
- package/dist/errors-CjPmyZHy.js.map +1 -0
- package/dist/{generate-Rly1EXBN.js → generate-BaJRhbCS.js} +3 -3
- package/dist/generate-BaJRhbCS.js.map +1 -0
- package/dist/{generate-BHNyeQXl.js → generate-CuxArvEk.js} +552 -258
- package/dist/generate-CuxArvEk.js.map +1 -0
- package/dist/{generate-DU5zzc54.cjs → generate-TL8zY_IT.cjs} +3 -3
- package/dist/generate-TL8zY_IT.cjs.map +1 -0
- package/dist/{generate-Cq5RDTBL.cjs → generate-UCP0qpDp.cjs} +559 -265
- package/dist/generate-UCP0qpDp.cjs.map +1 -0
- package/dist/index.cjs +40 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +40 -18
- package/dist/index.js.map +1 -1
- package/dist/{init-BK6inBTR.cjs → init-CZ5Xq2Hd.cjs} +45 -58
- package/dist/init-CZ5Xq2Hd.cjs.map +1 -0
- package/dist/{init-CN1JFyGX.cjs → init-DRR_YWIq.cjs} +4 -4
- package/dist/init-DRR_YWIq.cjs.map +1 -0
- package/dist/{init-iN7e1XwI.js → init-DSnRd1RJ.js} +4 -4
- package/dist/init-DSnRd1RJ.js.map +1 -0
- package/dist/{init-BQ6zfsnw.js → init-eNRlotJK.js} +41 -54
- package/dist/init-eNRlotJK.js.map +1 -0
- package/dist/{mcp-CONmm_xT.cjs → mcp-CLcDV4Jm.cjs} +5 -6
- package/dist/mcp-CLcDV4Jm.cjs.map +1 -0
- package/dist/{mcp-BiGUvbWP.js → mcp-D7EIR9fR.js} +4 -5
- package/dist/mcp-D7EIR9fR.js.map +1 -0
- package/dist/{mcp-eP1S40LZ.js → mcp-Dakxi9CL.js} +4 -4
- package/dist/{mcp-eP1S40LZ.js.map → mcp-Dakxi9CL.js.map} +1 -1
- package/dist/{mcp-T7Q4nWbT.cjs → mcp-Dr_RY-hd.cjs} +4 -4
- package/dist/{mcp-T7Q4nWbT.cjs.map → mcp-Dr_RY-hd.cjs.map} +1 -1
- package/dist/{package-BJ6ionm6.cjs → package-Cdo6lNjF.cjs} +2 -2
- package/dist/package-Cdo6lNjF.cjs.map +1 -0
- package/dist/package-DPooAj2l.js +6 -0
- package/dist/package-DPooAj2l.js.map +1 -0
- package/dist/{shell-7HPrTCJ5.cjs → shell-475fQKaX.cjs} +8 -3
- package/dist/shell-475fQKaX.cjs.map +1 -0
- package/dist/{shell-DqqWsHCD.js → shell-DLzN4fRo.js} +8 -3
- package/dist/shell-DLzN4fRo.js.map +1 -0
- package/dist/{telemetry-DZ7IrLAU.cjs → telemetry-DN95_2pF.cjs} +50 -8
- package/dist/telemetry-DN95_2pF.cjs.map +1 -0
- package/dist/{telemetry-BF3SMlH6.js → telemetry-LgT_sdPe.js} +48 -6
- package/dist/telemetry-LgT_sdPe.js.map +1 -0
- package/dist/{validate-DAZdX_0i.js → validate-B1o-rY9o.js} +4 -4
- package/dist/validate-B1o-rY9o.js.map +1 -0
- package/dist/{validate-DucFMytl.cjs → validate-CXFY-mHL.cjs} +4 -4
- package/dist/validate-CXFY-mHL.cjs.map +1 -0
- package/dist/{validate-BImbbx1t.js → validate-kLJoT_hi.js} +5 -13
- package/dist/validate-kLJoT_hi.js.map +1 -0
- package/dist/{validate-ujLCYSWU.cjs → validate-yKKzqEZ5.cjs} +6 -14
- package/dist/validate-yKKzqEZ5.cjs.map +1 -0
- package/package.json +47 -46
- package/src/commands/agent/start.ts +20 -4
- package/src/commands/generate.ts +35 -6
- package/src/commands/init.ts +6 -1
- package/src/commands/validate.ts +6 -1
- package/src/constants.ts +19 -38
- package/src/index.ts +7 -10
- package/src/loggers/clackLogger.ts +54 -46
- package/src/loggers/fileSystemLogger.ts +15 -16
- package/src/loggers/githubActionsLogger.ts +23 -24
- package/src/loggers/plainLogger.ts +22 -23
- package/src/runners/agent.ts +81 -34
- package/src/runners/generate.ts +90 -100
- package/src/runners/init.ts +24 -51
- package/src/runners/mcp.ts +17 -4
- package/src/runners/validate.ts +19 -15
- package/src/utils/executeHooks.ts +15 -15
- package/src/utils/flags.ts +1 -2
- package/src/utils/getConfig.ts +10 -0
- package/src/utils/getCosmiConfig.ts +21 -12
- package/src/utils/getSummary.ts +1 -1
- package/src/utils/runHook.ts +29 -13
- package/src/utils/telemetry.ts +16 -3
- package/bin/kubb.cjs +0 -18
- package/dist/agent-5mmp7QzF.js.map +0 -1
- package/dist/agent-BKphjOIF.cjs.map +0 -1
- package/dist/agent-BapvKB4r.cjs +0 -92
- package/dist/agent-BapvKB4r.cjs.map +0 -1
- package/dist/agent-CBrpIMMU.js +0 -88
- package/dist/agent-CBrpIMMU.js.map +0 -1
- package/dist/constants-D0XHAHeZ.cjs.map +0 -1
- package/dist/constants-DJM9zCXm.js.map +0 -1
- package/dist/define--M_JMcDC.js +0 -25
- package/dist/define--M_JMcDC.js.map +0 -1
- package/dist/define-D6Kfm7-Z.cjs +0 -36
- package/dist/define-D6Kfm7-Z.cjs.map +0 -1
- package/dist/errors-6mF_WKxg.js +0 -27
- package/dist/errors-6mF_WKxg.js.map +0 -1
- package/dist/errors-DBW0N9w4.cjs.map +0 -1
- package/dist/generate-BHNyeQXl.js.map +0 -1
- package/dist/generate-Cq5RDTBL.cjs.map +0 -1
- package/dist/generate-DU5zzc54.cjs.map +0 -1
- package/dist/generate-Rly1EXBN.js.map +0 -1
- package/dist/init-BK6inBTR.cjs.map +0 -1
- package/dist/init-BQ6zfsnw.js.map +0 -1
- package/dist/init-CN1JFyGX.cjs.map +0 -1
- package/dist/init-iN7e1XwI.js.map +0 -1
- package/dist/jiti-Cd3S0xwr.cjs +0 -16
- package/dist/jiti-Cd3S0xwr.cjs.map +0 -1
- package/dist/jiti-e08mD2Ph.js +0 -11
- package/dist/jiti-e08mD2Ph.js.map +0 -1
- package/dist/mcp-BiGUvbWP.js.map +0 -1
- package/dist/mcp-CONmm_xT.cjs.map +0 -1
- package/dist/package-BJ6ionm6.cjs.map +0 -1
- package/dist/package-BKZ0H3Zf.js +0 -6
- package/dist/package-BKZ0H3Zf.js.map +0 -1
- package/dist/shell-7HPrTCJ5.cjs.map +0 -1
- package/dist/shell-DqqWsHCD.js.map +0 -1
- package/dist/telemetry-BF3SMlH6.js.map +0 -1
- package/dist/telemetry-DZ7IrLAU.cjs.map +0 -1
- package/dist/validate-BImbbx1t.js.map +0 -1
- package/dist/validate-DAZdX_0i.js.map +0 -1
- package/dist/validate-DucFMytl.cjs.map +0 -1
- package/dist/validate-ujLCYSWU.cjs.map +0 -1
- package/src/utils/jiti.ts +0 -9
package/package.json
CHANGED
|
@@ -1,41 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-beta.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",
|
|
7
|
+
"code-generator",
|
|
8
|
+
"codegen",
|
|
7
9
|
"command-line",
|
|
8
10
|
"command-line-tool",
|
|
9
|
-
"
|
|
10
|
-
"typescript",
|
|
11
|
-
"openapi",
|
|
12
|
-
"swagger",
|
|
11
|
+
"kubb",
|
|
13
12
|
"oas",
|
|
14
|
-
"
|
|
15
|
-
"codegen",
|
|
16
|
-
"sdk-generator",
|
|
13
|
+
"openapi",
|
|
17
14
|
"plugins",
|
|
18
|
-
"
|
|
15
|
+
"sdk-generator",
|
|
16
|
+
"swagger",
|
|
17
|
+
"terminal",
|
|
18
|
+
"typescript"
|
|
19
19
|
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "stijnvanhulle",
|
|
20
22
|
"repository": {
|
|
21
23
|
"type": "git",
|
|
22
24
|
"url": "git+https://github.com/kubb-labs/kubb.git",
|
|
23
25
|
"directory": "packages/cli"
|
|
24
26
|
},
|
|
25
|
-
"license": "MIT",
|
|
26
|
-
"author": "stijnvanhulle",
|
|
27
|
-
"sideEffects": false,
|
|
28
|
-
"type": "module",
|
|
29
|
-
"exports": {
|
|
30
|
-
".": {
|
|
31
|
-
"import": "./dist/index.js",
|
|
32
|
-
"require": "./dist/index.cjs"
|
|
33
|
-
},
|
|
34
|
-
"./package.json": "./package.json"
|
|
35
|
-
},
|
|
36
|
-
"types": "./dist/index.d.ts",
|
|
37
27
|
"bin": {
|
|
38
|
-
"kubb": "bin/kubb.
|
|
28
|
+
"kubb": "bin/kubb.js"
|
|
39
29
|
},
|
|
40
30
|
"files": [
|
|
41
31
|
"src",
|
|
@@ -45,6 +35,38 @@
|
|
|
45
35
|
"!/**/__tests__/**",
|
|
46
36
|
"!/**/__snapshots__/**"
|
|
47
37
|
],
|
|
38
|
+
"type": "module",
|
|
39
|
+
"sideEffects": false,
|
|
40
|
+
"main": "./dist/index.cjs",
|
|
41
|
+
"module": "./dist/index.js",
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"import": "./dist/index.js",
|
|
46
|
+
"require": "./dist/index.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./package.json": "./package.json"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"registry": "https://registry.npmjs.org/"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@clack/prompts": "^1.3.0",
|
|
56
|
+
"chokidar": "^5.0.0",
|
|
57
|
+
"cosmiconfig": "^9.0.1",
|
|
58
|
+
"tinyexec": "^1.1.2",
|
|
59
|
+
"unrun": "^0.2.37",
|
|
60
|
+
"@kubb/adapter-oas": "5.0.0-beta.1",
|
|
61
|
+
"@kubb/core": "5.0.0-beta.1"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@internals/utils": "0.0.0"
|
|
65
|
+
},
|
|
66
|
+
"optionalDependencies": {
|
|
67
|
+
"@kubb/agent": "5.0.0-beta.1",
|
|
68
|
+
"@kubb/mcp": "5.0.0-beta.1"
|
|
69
|
+
},
|
|
48
70
|
"size-limit": [
|
|
49
71
|
{
|
|
50
72
|
"path": "./dist/*.js",
|
|
@@ -52,36 +74,15 @@
|
|
|
52
74
|
"gzip": true
|
|
53
75
|
}
|
|
54
76
|
],
|
|
55
|
-
"
|
|
56
|
-
"@clack/prompts": "^1.1.0",
|
|
57
|
-
"chokidar": "^5.0.0",
|
|
58
|
-
"cosmiconfig": "^9.0.1",
|
|
59
|
-
"jiti": "2.5.1",
|
|
60
|
-
"tinyexec": "^1.0.4",
|
|
61
|
-
"@kubb/core": "5.0.0-alpha.9"
|
|
62
|
-
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"source-map-support": "^0.5.21",
|
|
65
|
-
"@internals/utils": "0.0.0",
|
|
66
|
-
"@kubb/agent": "5.0.0-alpha.9",
|
|
67
|
-
"@kubb/mcp": "5.0.0-alpha.9",
|
|
68
|
-
"@kubb/oas": "5.0.0-alpha.9"
|
|
69
|
-
},
|
|
77
|
+
"preferGlobal": true,
|
|
70
78
|
"engines": {
|
|
71
79
|
"node": ">=22"
|
|
72
80
|
},
|
|
73
|
-
"preferGlobal": true,
|
|
74
|
-
"publishConfig": {
|
|
75
|
-
"access": "public",
|
|
76
|
-
"registry": "https://registry.npmjs.org/"
|
|
77
|
-
},
|
|
78
|
-
"main": "./dist/index.cjs",
|
|
79
|
-
"module": "./dist/index.js",
|
|
80
81
|
"scripts": {
|
|
81
82
|
"build": "tsdown && size-limit",
|
|
82
83
|
"clean": "npx rimraf ./dist",
|
|
83
|
-
"lint": "
|
|
84
|
-
"lint:fix": "
|
|
84
|
+
"lint": "oxlint .",
|
|
85
|
+
"lint:fix": "oxlint --fix .",
|
|
85
86
|
"release": "pnpm publish --no-git-check",
|
|
86
87
|
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
87
88
|
"start": "tsdown --watch",
|
|
@@ -6,15 +6,31 @@ export const command = defineCommand({
|
|
|
6
6
|
name: 'start',
|
|
7
7
|
description: 'Start the Agent server',
|
|
8
8
|
options: {
|
|
9
|
-
config: {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
config: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
description: 'Path to the Kubb config',
|
|
12
|
+
short: 'c',
|
|
13
|
+
},
|
|
14
|
+
port: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: `Port for the server (default: ${agentDefaults.port})`,
|
|
17
|
+
short: 'p',
|
|
18
|
+
},
|
|
19
|
+
host: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'Host for the server',
|
|
22
|
+
default: agentDefaults.host,
|
|
23
|
+
},
|
|
12
24
|
'allow-write': {
|
|
13
25
|
type: 'boolean',
|
|
14
26
|
description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',
|
|
15
27
|
default: false,
|
|
16
28
|
},
|
|
17
|
-
'allow-all': {
|
|
29
|
+
'allow-all': {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
description: 'Grant all permissions (implies --allow-write).',
|
|
32
|
+
default: false,
|
|
33
|
+
},
|
|
18
34
|
},
|
|
19
35
|
async run({ values }) {
|
|
20
36
|
const { runAgentStart } = await import('../../runners/agent.ts')
|
package/src/commands/generate.ts
CHANGED
|
@@ -5,7 +5,11 @@ export const command = defineCommand({
|
|
|
5
5
|
description: "[input] Generate files based on a 'kubb.config.ts' file",
|
|
6
6
|
arguments: ['[input]'],
|
|
7
7
|
options: {
|
|
8
|
-
config: {
|
|
8
|
+
config: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'Path to the Kubb config',
|
|
11
|
+
short: 'c',
|
|
12
|
+
},
|
|
9
13
|
logLevel: {
|
|
10
14
|
type: 'string',
|
|
11
15
|
description: 'Info, silent, verbose or debug',
|
|
@@ -14,15 +18,40 @@ export const command = defineCommand({
|
|
|
14
18
|
hint: 'silent|info|verbose|debug',
|
|
15
19
|
enum: ['silent', 'info', 'verbose', 'debug'],
|
|
16
20
|
},
|
|
17
|
-
watch: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
watch: {
|
|
22
|
+
type: 'boolean',
|
|
23
|
+
description: 'Watch mode based on the input file',
|
|
24
|
+
short: 'w',
|
|
25
|
+
default: false,
|
|
26
|
+
},
|
|
27
|
+
debug: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
description: 'Override logLevel to debug',
|
|
30
|
+
short: 'd',
|
|
31
|
+
default: false,
|
|
32
|
+
},
|
|
33
|
+
verbose: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
description: 'Override logLevel to verbose',
|
|
36
|
+
short: 'v',
|
|
37
|
+
default: false,
|
|
38
|
+
},
|
|
39
|
+
silent: {
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
description: 'Override logLevel to silent',
|
|
42
|
+
short: 's',
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
21
45
|
},
|
|
22
46
|
async run({ values, positionals }) {
|
|
23
47
|
const logLevel = values.debug ? 'debug' : values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel
|
|
24
48
|
const { runGenerateCommand } = await import('../runners/generate.ts')
|
|
25
49
|
|
|
26
|
-
await runGenerateCommand({
|
|
50
|
+
await runGenerateCommand({
|
|
51
|
+
input: positionals[0],
|
|
52
|
+
configPath: values.config,
|
|
53
|
+
logLevel,
|
|
54
|
+
watch: values.watch,
|
|
55
|
+
})
|
|
27
56
|
},
|
|
28
57
|
})
|
package/src/commands/init.ts
CHANGED
|
@@ -5,7 +5,12 @@ export const command = defineCommand({
|
|
|
5
5
|
name: 'init',
|
|
6
6
|
description: 'Initialize a new Kubb project with interactive setup',
|
|
7
7
|
options: {
|
|
8
|
-
yes: {
|
|
8
|
+
yes: {
|
|
9
|
+
type: 'boolean',
|
|
10
|
+
description: 'Skip prompts and use default options',
|
|
11
|
+
short: 'y',
|
|
12
|
+
default: false,
|
|
13
|
+
},
|
|
9
14
|
},
|
|
10
15
|
async run({ values }) {
|
|
11
16
|
const { runInit } = await import('../runners/init.ts')
|
package/src/commands/validate.ts
CHANGED
|
@@ -5,7 +5,12 @@ export const command = defineCommand({
|
|
|
5
5
|
name: 'validate',
|
|
6
6
|
description: 'Validate a Swagger/OpenAPI file',
|
|
7
7
|
options: {
|
|
8
|
-
input: {
|
|
8
|
+
input: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'Path to Swagger/OpenAPI file',
|
|
11
|
+
short: 'i',
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
9
14
|
},
|
|
10
15
|
async run({ values }) {
|
|
11
16
|
const { runValidate } = await import('../runners/validate.ts')
|
package/src/constants.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default filename for the Kubb configuration file.
|
|
3
|
+
*
|
|
4
|
+
* Used by the `init` command when scaffolding new projects and by the `agent` default config.
|
|
5
|
+
*/
|
|
6
|
+
export const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* NPM registry endpoint used to check for @kubb/cli updates.
|
|
3
10
|
*/
|
|
@@ -31,37 +38,12 @@ export const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const
|
|
|
31
38
|
/**
|
|
32
39
|
* Flags that short-circuit execution (help/version) — no telemetry notice is shown.
|
|
33
40
|
*/
|
|
34
|
-
export const
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Flags accepted by the `generate` command.
|
|
38
|
-
*/
|
|
39
|
-
export const GENERATE_FLAGS = new Set(['--config', '-c', '--log-level', '-l', '--watch', '-w', '--debug', '-d', '--verbose', '-v', '--silent', '-s'] as const)
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Flags accepted by the `validate` command.
|
|
43
|
-
*/
|
|
44
|
-
export const VALIDATE_FLAGS = new Set(['--input', '-i'] as const)
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Flags accepted by the `init` command.
|
|
48
|
-
*/
|
|
49
|
-
export const INIT_FLAGS = new Set(['--yes', '-y'] as const)
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Flags accepted by the `agent start` command.
|
|
53
|
-
*/
|
|
54
|
-
export const AGENT_START_FLAGS = new Set(['--config', '-c', '--port', '-p', '--host', '--allow-write', '--allow-all'] as const)
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* All known CLI flags across every command.
|
|
58
|
-
*/
|
|
59
|
-
export const ARGS = new Set([...QUITE_FLAGS, ...GENERATE_FLAGS, ...VALIDATE_FLAGS, ...INIT_FLAGS, ...AGENT_START_FLAGS] as const)
|
|
41
|
+
export const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)
|
|
60
42
|
|
|
61
43
|
export const agentDefaults = {
|
|
62
44
|
port: '3000',
|
|
63
45
|
host: 'localhost',
|
|
64
|
-
configFile:
|
|
46
|
+
configFile: KUBB_CONFIG_FILENAME,
|
|
65
47
|
retryTimeout: '30000',
|
|
66
48
|
studioUrl: 'https://studio.kubb.dev',
|
|
67
49
|
/**
|
|
@@ -76,7 +58,7 @@ export const agentDefaults = {
|
|
|
76
58
|
export const initDefaults = {
|
|
77
59
|
inputPath: './openapi.yaml',
|
|
78
60
|
outputPath: './src/gen',
|
|
79
|
-
plugins: ['plugin-
|
|
61
|
+
plugins: ['plugin-ts'],
|
|
80
62
|
} as const
|
|
81
63
|
|
|
82
64
|
/**
|
|
@@ -85,7 +67,6 @@ export const initDefaults = {
|
|
|
85
67
|
* `as const` keeps the object deeply immutable.
|
|
86
68
|
*/
|
|
87
69
|
export const pluginDefaultConfigs = {
|
|
88
|
-
'plugin-oas': 'pluginOas()',
|
|
89
70
|
'plugin-ts': `pluginTs({
|
|
90
71
|
output: { path: 'models' },
|
|
91
72
|
})`,
|
|
@@ -95,18 +76,9 @@ export const pluginDefaultConfigs = {
|
|
|
95
76
|
'plugin-react-query': `pluginReactQuery({
|
|
96
77
|
output: { path: 'hooks' },
|
|
97
78
|
})`,
|
|
98
|
-
'plugin-solid-query': `pluginSolidQuery({
|
|
99
|
-
output: { path: 'hooks' },
|
|
100
|
-
})`,
|
|
101
|
-
'plugin-svelte-query': `pluginSvelteQuery({
|
|
102
|
-
output: { path: 'hooks' },
|
|
103
|
-
})`,
|
|
104
79
|
'plugin-vue-query': `pluginVueQuery({
|
|
105
80
|
output: { path: 'hooks' },
|
|
106
81
|
})`,
|
|
107
|
-
'plugin-swr': `pluginSwr({
|
|
108
|
-
output: { path: 'hooks' },
|
|
109
|
-
})`,
|
|
110
82
|
'plugin-zod': `pluginZod({
|
|
111
83
|
output: { path: 'zod' },
|
|
112
84
|
})`,
|
|
@@ -116,6 +88,15 @@ export const pluginDefaultConfigs = {
|
|
|
116
88
|
'plugin-msw': `pluginMsw({
|
|
117
89
|
output: { path: 'msw' },
|
|
118
90
|
})`,
|
|
91
|
+
'plugin-cypress': `pluginCypress({
|
|
92
|
+
output: { path: 'cypress' },
|
|
93
|
+
})`,
|
|
94
|
+
'plugin-mcp': `pluginMcp({
|
|
95
|
+
output: { path: 'mcp' },
|
|
96
|
+
})`,
|
|
97
|
+
'plugin-redoc': `pluginRedoc({
|
|
98
|
+
output: { path: 'redoc' },
|
|
99
|
+
})`,
|
|
119
100
|
} as const satisfies Record<string, string>
|
|
120
101
|
|
|
121
102
|
/**
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { styleText } from 'node:util'
|
|
2
2
|
import { createCLI } from '@internals/utils'
|
|
3
3
|
import { version } from '../package.json'
|
|
4
|
-
import {
|
|
4
|
+
import { QUIET_FLAGS } from './constants.ts'
|
|
5
5
|
import { isFlag } from './utils/flags.ts'
|
|
6
6
|
import { isTelemetryDisabled } from './utils/telemetry.ts'
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ function shouldShowTelemetryNotice(argv: Array<string>): boolean {
|
|
|
12
12
|
return false
|
|
13
13
|
}
|
|
14
14
|
// Skip when the user is just asking for help or version info
|
|
15
|
-
if (argv.some((arg) => isFlag(
|
|
15
|
+
if (argv.some((arg) => isFlag(QUIET_FLAGS, arg))) {
|
|
16
16
|
return false
|
|
17
17
|
}
|
|
18
18
|
// Skip in non-interactive / scripting contexts
|
|
@@ -29,14 +29,11 @@ export async function run(argv: Array<string> = process.argv): Promise<void> {
|
|
|
29
29
|
)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
import('./commands/agent.ts'),
|
|
38
|
-
import('./commands/init.ts'),
|
|
39
|
-
])
|
|
32
|
+
const { command: generateCommand } = await import('./commands/generate.ts')
|
|
33
|
+
const { command: validateCommand } = await import('./commands/validate.ts')
|
|
34
|
+
const { command: mcpCommand } = await import('./commands/mcp.ts')
|
|
35
|
+
const { command: agentCommand } = await import('./commands/agent.ts')
|
|
36
|
+
const { command: initCommand } = await import('./commands/init.ts')
|
|
40
37
|
|
|
41
38
|
await cli.run([generateCommand, validateCommand, mcpCommand, agentCommand, initCommand], argv, {
|
|
42
39
|
programName: 'kubb',
|
|
@@ -10,8 +10,7 @@ import { ClackWritable } from '../utils/Writables.ts'
|
|
|
10
10
|
import { buildProgressLine, formatCommandWithArgs, formatMessage } from './utils.ts'
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* Provides a beautiful CLI UI with flat structure inspired by Claude's CLI patterns
|
|
13
|
+
* TTY logger with beautiful UI and progress indicators for local development.
|
|
15
14
|
*/
|
|
16
15
|
export const clackLogger = defineLogger({
|
|
17
16
|
name: 'clack',
|
|
@@ -73,7 +72,7 @@ export const clackLogger = defineLogger({
|
|
|
73
72
|
state.isSpinning = false
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
context.on('info', (message, info = '') => {
|
|
75
|
+
context.on('kubb:info', ({ message, info = '' }) => {
|
|
77
76
|
if (logLevel <= logLevelMap.silent) {
|
|
78
77
|
return
|
|
79
78
|
}
|
|
@@ -87,7 +86,7 @@ export const clackLogger = defineLogger({
|
|
|
87
86
|
}
|
|
88
87
|
})
|
|
89
88
|
|
|
90
|
-
context.on('success', (message, info = '') => {
|
|
89
|
+
context.on('kubb:success', ({ message, info = '' }) => {
|
|
91
90
|
if (logLevel <= logLevelMap.silent) {
|
|
92
91
|
return
|
|
93
92
|
}
|
|
@@ -101,7 +100,7 @@ export const clackLogger = defineLogger({
|
|
|
101
100
|
}
|
|
102
101
|
})
|
|
103
102
|
|
|
104
|
-
context.on('warn', (message, info) => {
|
|
103
|
+
context.on('kubb:warn', ({ message, info }) => {
|
|
105
104
|
if (logLevel < logLevelMap.warn) {
|
|
106
105
|
return
|
|
107
106
|
}
|
|
@@ -113,7 +112,7 @@ export const clackLogger = defineLogger({
|
|
|
113
112
|
clack.log.warn(text)
|
|
114
113
|
})
|
|
115
114
|
|
|
116
|
-
context.on('error', (error) => {
|
|
115
|
+
context.on('kubb:error', ({ error }) => {
|
|
117
116
|
const caused = toCause(error)
|
|
118
117
|
|
|
119
118
|
const text = [styleText('red', '✗'), error.message].join(' ')
|
|
@@ -142,33 +141,38 @@ export const clackLogger = defineLogger({
|
|
|
142
141
|
}
|
|
143
142
|
})
|
|
144
143
|
|
|
145
|
-
context.on('version:new', (
|
|
144
|
+
context.on('kubb:version:new', ({ currentVersion, latestVersion }) => {
|
|
146
145
|
if (logLevel <= logLevelMap.silent) {
|
|
147
146
|
return
|
|
148
147
|
}
|
|
149
148
|
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
try {
|
|
150
|
+
clack.box(
|
|
151
|
+
`\`v${currentVersion}\` → \`v${latestVersion}\`
|
|
152
152
|
Run \`npm install -g @kubb/cli\` to update`,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
153
|
+
'Update available for `Kubb`',
|
|
154
|
+
{
|
|
155
|
+
width: 'auto',
|
|
156
|
+
formatBorder: (s: string) => styleText('yellow', s),
|
|
157
|
+
rounded: true,
|
|
158
|
+
withGuide: false,
|
|
159
|
+
contentAlign: 'center',
|
|
160
|
+
titleAlign: 'center',
|
|
161
|
+
},
|
|
162
|
+
)
|
|
163
|
+
} catch {
|
|
164
|
+
console.log(`Update available for Kubb: v${currentVersion} → v${latestVersion}`)
|
|
165
|
+
console.log('Run `npm install -g @kubb/cli` to update')
|
|
166
|
+
}
|
|
163
167
|
})
|
|
164
168
|
|
|
165
|
-
context.on('lifecycle:start', async (version) => {
|
|
169
|
+
context.on('kubb:lifecycle:start', async ({ version }) => {
|
|
166
170
|
console.log(`\n${getIntro({ title: 'The ultimate toolkit for working with APIs', description: 'Ready to start', version, areEyesOpen: true })}\n`)
|
|
167
171
|
|
|
168
172
|
reset()
|
|
169
173
|
})
|
|
170
174
|
|
|
171
|
-
context.on('config:start', () => {
|
|
175
|
+
context.on('kubb:config:start', () => {
|
|
172
176
|
if (logLevel <= logLevelMap.silent) {
|
|
173
177
|
return
|
|
174
178
|
}
|
|
@@ -179,7 +183,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
179
183
|
startSpinner(getMessage('Configuration loading'))
|
|
180
184
|
})
|
|
181
185
|
|
|
182
|
-
context.on('config:end', (
|
|
186
|
+
context.on('kubb:config:end', () => {
|
|
183
187
|
if (logLevel <= logLevelMap.silent) {
|
|
184
188
|
return
|
|
185
189
|
}
|
|
@@ -189,7 +193,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
189
193
|
clack.outro(text)
|
|
190
194
|
})
|
|
191
195
|
|
|
192
|
-
context.on('generation:start', (config) => {
|
|
196
|
+
context.on('kubb:generation:start', ({ config }) => {
|
|
193
197
|
reset()
|
|
194
198
|
|
|
195
199
|
// Initialize progress tracking for this generation
|
|
@@ -200,7 +204,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
200
204
|
clack.intro(text)
|
|
201
205
|
})
|
|
202
206
|
|
|
203
|
-
context.on('plugin:start', (plugin) => {
|
|
207
|
+
context.on('kubb:plugin:start', ({ plugin }) => {
|
|
204
208
|
if (logLevel <= logLevelMap.silent) {
|
|
205
209
|
return
|
|
206
210
|
}
|
|
@@ -222,7 +226,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
222
226
|
state.activeProgress.set(plugin.name, { progressBar, interval })
|
|
223
227
|
})
|
|
224
228
|
|
|
225
|
-
context.on('plugin:end', (plugin,
|
|
229
|
+
context.on('kubb:plugin:end', ({ plugin, duration, success }) => {
|
|
226
230
|
stopSpinner()
|
|
227
231
|
|
|
228
232
|
const active = state.activeProgress.get(plugin.name)
|
|
@@ -253,7 +257,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
253
257
|
showProgressStep()
|
|
254
258
|
})
|
|
255
259
|
|
|
256
|
-
context.on('files:processing:start', (files) => {
|
|
260
|
+
context.on('kubb:files:processing:start', ({ files }) => {
|
|
257
261
|
if (logLevel <= logLevelMap.silent) {
|
|
258
262
|
return
|
|
259
263
|
}
|
|
@@ -270,12 +274,12 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
270
274
|
size: 30,
|
|
271
275
|
})
|
|
272
276
|
|
|
273
|
-
context.emit('info', text)
|
|
277
|
+
context.emit('kubb:info', { message: text })
|
|
274
278
|
progressBar.start(getMessage(text))
|
|
275
279
|
state.activeProgress.set('files', { progressBar })
|
|
276
280
|
})
|
|
277
281
|
|
|
278
|
-
context.on('file:processing:update', ({ file, config }) => {
|
|
282
|
+
context.on('kubb:file:processing:update', ({ file, config }) => {
|
|
279
283
|
if (logLevel <= logLevelMap.silent) {
|
|
280
284
|
return
|
|
281
285
|
}
|
|
@@ -293,7 +297,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
293
297
|
|
|
294
298
|
active.progressBar.advance(undefined, text)
|
|
295
299
|
})
|
|
296
|
-
context.on('files:processing:end', () => {
|
|
300
|
+
context.on('kubb:files:processing:end', () => {
|
|
297
301
|
if (logLevel <= logLevelMap.silent) {
|
|
298
302
|
return
|
|
299
303
|
}
|
|
@@ -314,13 +318,13 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
314
318
|
showProgressStep()
|
|
315
319
|
})
|
|
316
320
|
|
|
317
|
-
context.on('generation:end', (config) => {
|
|
321
|
+
context.on('kubb:generation:end', ({ config }) => {
|
|
318
322
|
const text = getMessage(config.name ? `Generation completed for ${styleText('dim', config.name)}` : 'Generation completed')
|
|
319
323
|
|
|
320
324
|
clack.outro(text)
|
|
321
325
|
})
|
|
322
326
|
|
|
323
|
-
context.on('format:start', () => {
|
|
327
|
+
context.on('kubb:format:start', () => {
|
|
324
328
|
if (logLevel <= logLevelMap.silent) {
|
|
325
329
|
return
|
|
326
330
|
}
|
|
@@ -330,7 +334,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
330
334
|
clack.intro(text)
|
|
331
335
|
})
|
|
332
336
|
|
|
333
|
-
context.on('format:end', () => {
|
|
337
|
+
context.on('kubb:format:end', () => {
|
|
334
338
|
if (logLevel <= logLevelMap.silent) {
|
|
335
339
|
return
|
|
336
340
|
}
|
|
@@ -340,7 +344,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
340
344
|
clack.outro(text)
|
|
341
345
|
})
|
|
342
346
|
|
|
343
|
-
context.on('lint:start', () => {
|
|
347
|
+
context.on('kubb:lint:start', () => {
|
|
344
348
|
if (logLevel <= logLevelMap.silent) {
|
|
345
349
|
return
|
|
346
350
|
}
|
|
@@ -350,7 +354,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
350
354
|
clack.intro(text)
|
|
351
355
|
})
|
|
352
356
|
|
|
353
|
-
context.on('lint:end', () => {
|
|
357
|
+
context.on('kubb:lint:end', () => {
|
|
354
358
|
if (logLevel <= logLevelMap.silent) {
|
|
355
359
|
return
|
|
356
360
|
}
|
|
@@ -360,7 +364,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
360
364
|
clack.outro(text)
|
|
361
365
|
})
|
|
362
366
|
|
|
363
|
-
context.on('hook:start', async ({ id, command, args }) => {
|
|
367
|
+
context.on('kubb:hook:start', async ({ id, command, args }) => {
|
|
364
368
|
const commandWithArgs = formatCommandWithArgs(command, args)
|
|
365
369
|
const text = getMessage(`Hook ${styleText('dim', commandWithArgs)} started`)
|
|
366
370
|
|
|
@@ -407,7 +411,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
407
411
|
})
|
|
408
412
|
})
|
|
409
413
|
|
|
410
|
-
context.on('hook:end', ({ command, args }) => {
|
|
414
|
+
context.on('kubb:hook:end', ({ command, args }) => {
|
|
411
415
|
if (logLevel <= logLevelMap.silent) {
|
|
412
416
|
return
|
|
413
417
|
}
|
|
@@ -418,7 +422,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
418
422
|
clack.outro(text)
|
|
419
423
|
})
|
|
420
424
|
|
|
421
|
-
context.on('generation:summary', (config,
|
|
425
|
+
context.on('kubb:generation:summary', ({ config, pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
|
|
422
426
|
const summary = getSummary({
|
|
423
427
|
failedPlugins,
|
|
424
428
|
filesCreated,
|
|
@@ -433,17 +437,21 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
433
437
|
summary.push('\n')
|
|
434
438
|
|
|
435
439
|
const borderColor = status === 'success' ? 'green' : 'red'
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
440
|
+
try {
|
|
441
|
+
clack.box(summary.join('\n'), getMessage(title), {
|
|
442
|
+
width: 'auto',
|
|
443
|
+
formatBorder: (s: string) => styleText(borderColor, s),
|
|
444
|
+
rounded: true,
|
|
445
|
+
withGuide: false,
|
|
446
|
+
contentAlign: 'left',
|
|
447
|
+
titleAlign: 'center',
|
|
448
|
+
})
|
|
449
|
+
} catch {
|
|
450
|
+
console.log(summary.join('\n'))
|
|
451
|
+
}
|
|
444
452
|
})
|
|
445
453
|
|
|
446
|
-
context.on('lifecycle:end', () => {
|
|
454
|
+
context.on('kubb:lifecycle:end', () => {
|
|
447
455
|
reset()
|
|
448
456
|
})
|
|
449
457
|
},
|