@kubb/cli 5.0.0-alpha.5 → 5.0.0-alpha.50
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-Bt-Z24BD.cjs +116 -0
- package/dist/agent-Bt-Z24BD.cjs.map +1 -0
- package/dist/{agent-SWUT_sgq.js → agent-CHqQt6-j.js} +5 -5
- package/dist/agent-CHqQt6-j.js.map +1 -0
- package/dist/agent-LgBdb1gx.js +112 -0
- package/dist/agent-LgBdb1gx.js.map +1 -0
- package/dist/{agent-CEHZSBVT.cjs → agent-l26FqXrz.cjs} +5 -5
- package/dist/agent-l26FqXrz.cjs.map +1 -0
- package/dist/{constants-BTUap0zs.cjs → constants-B2q7VPbi.cjs} +91 -9
- package/dist/constants-B2q7VPbi.cjs.map +1 -0
- package/dist/constants-T_2rsi7T.js +137 -0
- package/dist/constants-T_2rsi7T.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-CNkdrX6u.cjs → generate-BSqljMWH.cjs} +3 -3
- package/dist/generate-BSqljMWH.cjs.map +1 -0
- package/dist/{generate-CtFkZeTU.js → generate-CQPHU8Xt.js} +493 -248
- package/dist/generate-CQPHU8Xt.js.map +1 -0
- package/dist/{generate-nJaqPdGL.cjs → generate-I-SQLa8R.cjs} +500 -255
- package/dist/generate-I-SQLa8R.cjs.map +1 -0
- package/dist/{generate-CfoLoEd0.js → generate-TP0il_KX.js} +3 -3
- package/dist/generate-TP0il_KX.js.map +1 -0
- package/dist/index.cjs +49 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +49 -21
- package/dist/index.js.map +1 -1
- package/dist/{init-D_oERuMn.js → init-13Vizgki.js} +4 -4
- package/dist/init-13Vizgki.js.map +1 -0
- package/dist/{init-hmolV6B4.cjs → init-AVT-2Uxi.cjs} +31 -21
- package/dist/init-AVT-2Uxi.cjs.map +1 -0
- package/dist/{init-C-InrmSY.js → init-BecEYFRb.js} +27 -17
- package/dist/init-BecEYFRb.js.map +1 -0
- package/dist/{init-BAs1d5rK.cjs → init-POdCjZS0.cjs} +4 -4
- package/dist/init-POdCjZS0.cjs.map +1 -0
- package/dist/{mcp-D2SHEg_d.js → mcp-BDHEbuy3.js} +11 -4
- package/dist/mcp-BDHEbuy3.js.map +1 -0
- package/dist/{mcp-DEvDB6FY.cjs → mcp-BotRrBI-.cjs} +4 -4
- package/dist/{mcp-DEvDB6FY.cjs.map → mcp-BotRrBI-.cjs.map} +1 -1
- package/dist/{mcp-ChHFPRzD.cjs → mcp-CqpVw3PO.cjs} +12 -6
- package/dist/mcp-CqpVw3PO.cjs.map +1 -0
- package/dist/{mcp-jKYiomZT.js → mcp-q4XumdSd.js} +4 -4
- package/dist/{mcp-jKYiomZT.js.map → mcp-q4XumdSd.js.map} +1 -1
- package/dist/package-BRmZkKt7.js +6 -0
- package/dist/package-BRmZkKt7.js.map +1 -0
- package/dist/{package-C-fC2Eoy.cjs → package-D86Y6wqb.cjs} +2 -2
- package/dist/package-D86Y6wqb.cjs.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-Cn9X1I5B.cjs → telemetry-B6ZbZOrb.cjs} +50 -8
- package/dist/telemetry-B6ZbZOrb.cjs.map +1 -0
- package/dist/{telemetry-DxiR7clS.js → telemetry-Dis5nWR_.js} +48 -6
- package/dist/telemetry-Dis5nWR_.js.map +1 -0
- package/dist/{validate--IXRJEhp.js → validate-AV-0RFuL.js} +4 -4
- package/dist/validate-AV-0RFuL.js.map +1 -0
- package/dist/{validate-BK3pc8zv.cjs → validate-Cu8Sfj-n.cjs} +4 -4
- package/dist/validate-Cu8Sfj-n.cjs.map +1 -0
- package/dist/{validate-Bbrn3Q-A.cjs → validate-D-8_wAFV.cjs} +6 -14
- package/dist/validate-D-8_wAFV.cjs.map +1 -0
- package/dist/{validate-l8vLmwKA.js → validate-GfErHsnI.js} +5 -13
- package/dist/validate-GfErHsnI.js.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 +65 -11
- package/src/index.ts +10 -12
- package/src/loggers/clackLogger.ts +54 -46
- package/src/loggers/fileSystemLogger.ts +13 -11
- package/src/loggers/githubActionsLogger.ts +22 -22
- package/src/loggers/plainLogger.ts +21 -21
- package/src/runners/agent.ts +81 -34
- package/src/runners/generate.ts +90 -109
- package/src/runners/init.ts +9 -9
- package/src/runners/mcp.ts +19 -3
- package/src/runners/validate.ts +19 -15
- package/src/types.ts +11 -0
- package/src/utils/executeHooks.ts +11 -11
- package/src/utils/flags.ts +10 -0
- package/src/utils/getConfig.ts +10 -0
- package/src/utils/getCosmiConfig.ts +9 -3
- package/src/utils/getSummary.ts +1 -1
- package/src/utils/runHook.ts +27 -9
- package/src/utils/telemetry.ts +16 -3
- package/bin/kubb.cjs +0 -18
- package/dist/agent-C6o_6GSJ.cjs +0 -92
- package/dist/agent-C6o_6GSJ.cjs.map +0 -1
- package/dist/agent-CEHZSBVT.cjs.map +0 -1
- package/dist/agent-L50VNhXv.js +0 -88
- package/dist/agent-L50VNhXv.js.map +0 -1
- package/dist/agent-SWUT_sgq.js.map +0 -1
- package/dist/constants-BTUap0zs.cjs.map +0 -1
- package/dist/constants-CM3dJzjK.js +0 -67
- package/dist/constants-CM3dJzjK.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-CNkdrX6u.cjs.map +0 -1
- package/dist/generate-CfoLoEd0.js.map +0 -1
- package/dist/generate-CtFkZeTU.js.map +0 -1
- package/dist/generate-nJaqPdGL.cjs.map +0 -1
- package/dist/init-BAs1d5rK.cjs.map +0 -1
- package/dist/init-C-InrmSY.js.map +0 -1
- package/dist/init-D_oERuMn.js.map +0 -1
- package/dist/init-hmolV6B4.cjs.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-ChHFPRzD.cjs.map +0 -1
- package/dist/mcp-D2SHEg_d.js.map +0 -1
- package/dist/package-C-fC2Eoy.cjs.map +0 -1
- package/dist/package-DxH_MEG4.js +0 -6
- package/dist/package-DxH_MEG4.js.map +0 -1
- package/dist/shell-7HPrTCJ5.cjs.map +0 -1
- package/dist/shell-DqqWsHCD.js.map +0 -1
- package/dist/telemetry-Cn9X1I5B.cjs.map +0 -1
- package/dist/telemetry-DxiR7clS.js.map +0 -1
- package/dist/validate--IXRJEhp.js.map +0 -1
- package/dist/validate-BK3pc8zv.cjs.map +0 -1
- package/dist/validate-Bbrn3Q-A.cjs.map +0 -1
- package/dist/validate-l8vLmwKA.js.map +0 -1
- package/src/utils/getIntro.ts +0 -1
package/package.json
CHANGED
|
@@ -1,41 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.50",
|
|
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.2.0",
|
|
56
|
+
"chokidar": "^5.0.0",
|
|
57
|
+
"cosmiconfig": "^9.0.1",
|
|
58
|
+
"jiti": "^2.6.1",
|
|
59
|
+
"tinyexec": "^1.1.1",
|
|
60
|
+
"@kubb/adapter-oas": "5.0.0-alpha.50",
|
|
61
|
+
"@kubb/core": "5.0.0-alpha.50"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@internals/utils": "0.0.0"
|
|
65
|
+
},
|
|
66
|
+
"optionalDependencies": {
|
|
67
|
+
"@kubb/agent": "5.0.0-alpha.50",
|
|
68
|
+
"@kubb/mcp": "5.0.0-alpha.50"
|
|
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.5"
|
|
62
|
-
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"source-map-support": "^0.5.21",
|
|
65
|
-
"@internals/utils": "0.0.0",
|
|
66
|
-
"@kubb/agent": "5.0.0-alpha.5",
|
|
67
|
-
"@kubb/mcp": "5.0.0-alpha.5",
|
|
68
|
-
"@kubb/oas": "5.0.0-alpha.5"
|
|
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,33 +1,85 @@
|
|
|
1
|
-
/**
|
|
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
|
+
|
|
8
|
+
/**
|
|
9
|
+
* NPM registry endpoint used to check for @kubb/cli updates.
|
|
10
|
+
*/
|
|
2
11
|
export const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const
|
|
3
12
|
|
|
4
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* OpenTelemetry ingestion endpoint for anonymous usage telemetry.
|
|
15
|
+
*/
|
|
5
16
|
export const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const
|
|
6
17
|
|
|
7
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Horizontal rule rendered above/below the plain-logger generation summary.
|
|
20
|
+
*/
|
|
8
21
|
export const SUMMARY_SEPARATOR = '─'.repeat(27)
|
|
9
22
|
|
|
10
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Maximum number of █ characters in a plugin timing bar.
|
|
25
|
+
*/
|
|
11
26
|
export const SUMMARY_MAX_BAR_LENGTH = 10 as const
|
|
12
27
|
|
|
13
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Divides elapsed milliseconds into bar-length units (1 block per 100 ms).
|
|
30
|
+
*/
|
|
14
31
|
export const SUMMARY_TIME_SCALE_DIVISOR = 100 as const
|
|
15
32
|
|
|
16
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Glob pattern for paths the file watcher ignores.
|
|
35
|
+
*/
|
|
17
36
|
export const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const
|
|
18
37
|
|
|
19
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Flags that short-circuit execution (help/version) — no telemetry notice is shown.
|
|
40
|
+
*/
|
|
41
|
+
export const QUITE_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Flags accepted by the `generate` command.
|
|
45
|
+
*/
|
|
46
|
+
export const GENERATE_FLAGS = new Set(['--config', '-c', '--log-level', '-l', '--watch', '-w', '--debug', '-d', '--verbose', '-v', '--silent', '-s'] as const)
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Flags accepted by the `validate` command.
|
|
50
|
+
*/
|
|
51
|
+
export const VALIDATE_FLAGS = new Set(['--input', '-i'] as const)
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Flags accepted by the `init` command.
|
|
55
|
+
*/
|
|
56
|
+
export const INIT_FLAGS = new Set(['--yes', '-y'] as const)
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Flags accepted by the `agent start` command.
|
|
60
|
+
*/
|
|
61
|
+
export const AGENT_START_FLAGS = new Set(['--config', '-c', '--port', '-p', '--host', '--allow-write', '--allow-all'] as const)
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* All known CLI flags across every command.
|
|
65
|
+
*/
|
|
66
|
+
export const ARGS = new Set([...QUITE_FLAGS, ...GENERATE_FLAGS, ...VALIDATE_FLAGS, ...INIT_FLAGS, ...AGENT_START_FLAGS] as const)
|
|
67
|
+
|
|
20
68
|
export const agentDefaults = {
|
|
21
69
|
port: '3000',
|
|
22
70
|
host: 'localhost',
|
|
23
|
-
configFile:
|
|
71
|
+
configFile: KUBB_CONFIG_FILENAME,
|
|
24
72
|
retryTimeout: '30000',
|
|
25
73
|
studioUrl: 'https://studio.kubb.dev',
|
|
26
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Relative path from the @kubb/agent package root to the server entry.
|
|
76
|
+
*/
|
|
27
77
|
serverEntryPath: '.output/server/index.mjs',
|
|
28
78
|
} as const
|
|
29
79
|
|
|
30
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Default values used during interactive `init` scaffolding.
|
|
82
|
+
*/
|
|
31
83
|
export const initDefaults = {
|
|
32
84
|
inputPath: './openapi.yaml',
|
|
33
85
|
outputPath: './src/gen',
|
|
@@ -73,4 +125,6 @@ export const pluginDefaultConfigs = {
|
|
|
73
125
|
})`,
|
|
74
126
|
} as const satisfies Record<string, string>
|
|
75
127
|
|
|
76
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* Color palette used by randomCliColor() for deterministic plugin name coloring.
|
|
130
|
+
*/
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { styleText } from 'node:util'
|
|
2
2
|
import { createCLI } from '@internals/utils'
|
|
3
3
|
import { version } from '../package.json'
|
|
4
|
+
import { QUITE_FLAGS } from './constants.ts'
|
|
5
|
+
import { isFlag } from './utils/flags.ts'
|
|
4
6
|
import { isTelemetryDisabled } from './utils/telemetry.ts'
|
|
5
7
|
|
|
6
8
|
const cli = createCLI()
|
|
7
9
|
|
|
8
|
-
function shouldShowTelemetryNotice(argv: string
|
|
10
|
+
function shouldShowTelemetryNotice(argv: Array<string>): boolean {
|
|
9
11
|
if (isTelemetryDisabled()) {
|
|
10
12
|
return false
|
|
11
13
|
}
|
|
12
14
|
// Skip when the user is just asking for help or version info
|
|
13
|
-
|
|
14
|
-
if (argv.some((arg) => quietFlags.has(arg))) {
|
|
15
|
+
if (argv.some((arg) => isFlag(QUITE_FLAGS, arg))) {
|
|
15
16
|
return false
|
|
16
17
|
}
|
|
17
18
|
// Skip in non-interactive / scripting contexts
|
|
@@ -21,21 +22,18 @@ function shouldShowTelemetryNotice(argv: string[]): boolean {
|
|
|
21
22
|
return true
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export async function run(argv: string
|
|
25
|
+
export async function run(argv: Array<string> = process.argv): Promise<void> {
|
|
25
26
|
if (shouldShowTelemetryNotice(argv)) {
|
|
26
27
|
console.log(
|
|
27
28
|
`${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\n`,
|
|
28
29
|
)
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
import('./commands/agent.ts'),
|
|
37
|
-
import('./commands/init.ts'),
|
|
38
|
-
])
|
|
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')
|
|
39
37
|
|
|
40
38
|
await cli.run([generateCommand, validateCommand, mcpCommand, agentCommand, initCommand], argv, {
|
|
41
39
|
programName: 'kubb',
|
|
@@ -2,9 +2,8 @@ import { relative } from 'node:path'
|
|
|
2
2
|
import process from 'node:process'
|
|
3
3
|
import { styleText } from 'node:util'
|
|
4
4
|
import * as clack from '@clack/prompts'
|
|
5
|
-
import { formatMs, formatMsWithColor, toCause } from '@internals/utils'
|
|
5
|
+
import { formatMs, formatMsWithColor, getIntro, toCause } from '@internals/utils'
|
|
6
6
|
import { defineLogger, logLevel as logLevelMap } from '@kubb/core'
|
|
7
|
-
import { getIntro } from '../utils/getIntro.ts'
|
|
8
7
|
import { getSummary } from '../utils/getSummary.ts'
|
|
9
8
|
import { runHook } from '../utils/runHook.ts'
|
|
10
9
|
import { ClackWritable } from '../utils/Writables.ts'
|
|
@@ -74,7 +73,7 @@ export const clackLogger = defineLogger({
|
|
|
74
73
|
state.isSpinning = false
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
context.on('info', (message, info = '') => {
|
|
76
|
+
context.on('kubb:info', (message, info = '') => {
|
|
78
77
|
if (logLevel <= logLevelMap.silent) {
|
|
79
78
|
return
|
|
80
79
|
}
|
|
@@ -88,7 +87,7 @@ export const clackLogger = defineLogger({
|
|
|
88
87
|
}
|
|
89
88
|
})
|
|
90
89
|
|
|
91
|
-
context.on('success', (message, info = '') => {
|
|
90
|
+
context.on('kubb:success', (message, info = '') => {
|
|
92
91
|
if (logLevel <= logLevelMap.silent) {
|
|
93
92
|
return
|
|
94
93
|
}
|
|
@@ -102,7 +101,7 @@ export const clackLogger = defineLogger({
|
|
|
102
101
|
}
|
|
103
102
|
})
|
|
104
103
|
|
|
105
|
-
context.on('warn', (message, info) => {
|
|
104
|
+
context.on('kubb:warn', (message, info) => {
|
|
106
105
|
if (logLevel < logLevelMap.warn) {
|
|
107
106
|
return
|
|
108
107
|
}
|
|
@@ -114,7 +113,7 @@ export const clackLogger = defineLogger({
|
|
|
114
113
|
clack.log.warn(text)
|
|
115
114
|
})
|
|
116
115
|
|
|
117
|
-
context.on('error', (error) => {
|
|
116
|
+
context.on('kubb:error', (error) => {
|
|
118
117
|
const caused = toCause(error)
|
|
119
118
|
|
|
120
119
|
const text = [styleText('red', '✗'), error.message].join(' ')
|
|
@@ -143,33 +142,38 @@ export const clackLogger = defineLogger({
|
|
|
143
142
|
}
|
|
144
143
|
})
|
|
145
144
|
|
|
146
|
-
context.on('version:new', (version, latestVersion) => {
|
|
145
|
+
context.on('kubb:version:new', (version, latestVersion) => {
|
|
147
146
|
if (logLevel <= logLevelMap.silent) {
|
|
148
147
|
return
|
|
149
148
|
}
|
|
150
149
|
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
try {
|
|
151
|
+
clack.box(
|
|
152
|
+
`\`v${version}\` → \`v${latestVersion}\`
|
|
153
153
|
Run \`npm install -g @kubb/cli\` to update`,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
154
|
+
'Update available for `Kubb`',
|
|
155
|
+
{
|
|
156
|
+
width: 'auto',
|
|
157
|
+
formatBorder: (s: string) => styleText('yellow', s),
|
|
158
|
+
rounded: true,
|
|
159
|
+
withGuide: false,
|
|
160
|
+
contentAlign: 'center',
|
|
161
|
+
titleAlign: 'center',
|
|
162
|
+
},
|
|
163
|
+
)
|
|
164
|
+
} catch {
|
|
165
|
+
console.log(`Update available for Kubb: v${version} → v${latestVersion}`)
|
|
166
|
+
console.log('Run `npm install -g @kubb/cli` to update')
|
|
167
|
+
}
|
|
164
168
|
})
|
|
165
169
|
|
|
166
|
-
context.on('lifecycle:start', async (version) => {
|
|
170
|
+
context.on('kubb:lifecycle:start', async (version) => {
|
|
167
171
|
console.log(`\n${getIntro({ title: 'The ultimate toolkit for working with APIs', description: 'Ready to start', version, areEyesOpen: true })}\n`)
|
|
168
172
|
|
|
169
173
|
reset()
|
|
170
174
|
})
|
|
171
175
|
|
|
172
|
-
context.on('config:start', () => {
|
|
176
|
+
context.on('kubb:config:start', () => {
|
|
173
177
|
if (logLevel <= logLevelMap.silent) {
|
|
174
178
|
return
|
|
175
179
|
}
|
|
@@ -180,7 +184,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
180
184
|
startSpinner(getMessage('Configuration loading'))
|
|
181
185
|
})
|
|
182
186
|
|
|
183
|
-
context.on('config:end', (_configs) => {
|
|
187
|
+
context.on('kubb:config:end', (_configs) => {
|
|
184
188
|
if (logLevel <= logLevelMap.silent) {
|
|
185
189
|
return
|
|
186
190
|
}
|
|
@@ -190,7 +194,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
190
194
|
clack.outro(text)
|
|
191
195
|
})
|
|
192
196
|
|
|
193
|
-
context.on('generation:start', (config) => {
|
|
197
|
+
context.on('kubb:generation:start', (config) => {
|
|
194
198
|
reset()
|
|
195
199
|
|
|
196
200
|
// Initialize progress tracking for this generation
|
|
@@ -201,7 +205,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
201
205
|
clack.intro(text)
|
|
202
206
|
})
|
|
203
207
|
|
|
204
|
-
context.on('plugin:start', (plugin) => {
|
|
208
|
+
context.on('kubb:plugin:start', (plugin) => {
|
|
205
209
|
if (logLevel <= logLevelMap.silent) {
|
|
206
210
|
return
|
|
207
211
|
}
|
|
@@ -223,7 +227,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
223
227
|
state.activeProgress.set(plugin.name, { progressBar, interval })
|
|
224
228
|
})
|
|
225
229
|
|
|
226
|
-
context.on('plugin:end', (plugin, { duration, success }) => {
|
|
230
|
+
context.on('kubb:plugin:end', (plugin, { duration, success }) => {
|
|
227
231
|
stopSpinner()
|
|
228
232
|
|
|
229
233
|
const active = state.activeProgress.get(plugin.name)
|
|
@@ -254,7 +258,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
254
258
|
showProgressStep()
|
|
255
259
|
})
|
|
256
260
|
|
|
257
|
-
context.on('files:processing:start', (files) => {
|
|
261
|
+
context.on('kubb:files:processing:start', (files) => {
|
|
258
262
|
if (logLevel <= logLevelMap.silent) {
|
|
259
263
|
return
|
|
260
264
|
}
|
|
@@ -271,12 +275,12 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
271
275
|
size: 30,
|
|
272
276
|
})
|
|
273
277
|
|
|
274
|
-
context.emit('info', text)
|
|
278
|
+
context.emit('kubb:info', text)
|
|
275
279
|
progressBar.start(getMessage(text))
|
|
276
280
|
state.activeProgress.set('files', { progressBar })
|
|
277
281
|
})
|
|
278
282
|
|
|
279
|
-
context.on('file:processing:update', ({ file, config }) => {
|
|
283
|
+
context.on('kubb:file:processing:update', ({ file, config }) => {
|
|
280
284
|
if (logLevel <= logLevelMap.silent) {
|
|
281
285
|
return
|
|
282
286
|
}
|
|
@@ -294,7 +298,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
294
298
|
|
|
295
299
|
active.progressBar.advance(undefined, text)
|
|
296
300
|
})
|
|
297
|
-
context.on('files:processing:end', () => {
|
|
301
|
+
context.on('kubb:files:processing:end', () => {
|
|
298
302
|
if (logLevel <= logLevelMap.silent) {
|
|
299
303
|
return
|
|
300
304
|
}
|
|
@@ -315,13 +319,13 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
315
319
|
showProgressStep()
|
|
316
320
|
})
|
|
317
321
|
|
|
318
|
-
context.on('generation:end', (config) => {
|
|
322
|
+
context.on('kubb:generation:end', (config) => {
|
|
319
323
|
const text = getMessage(config.name ? `Generation completed for ${styleText('dim', config.name)}` : 'Generation completed')
|
|
320
324
|
|
|
321
325
|
clack.outro(text)
|
|
322
326
|
})
|
|
323
327
|
|
|
324
|
-
context.on('format:start', () => {
|
|
328
|
+
context.on('kubb:format:start', () => {
|
|
325
329
|
if (logLevel <= logLevelMap.silent) {
|
|
326
330
|
return
|
|
327
331
|
}
|
|
@@ -331,7 +335,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
331
335
|
clack.intro(text)
|
|
332
336
|
})
|
|
333
337
|
|
|
334
|
-
context.on('format:end', () => {
|
|
338
|
+
context.on('kubb:format:end', () => {
|
|
335
339
|
if (logLevel <= logLevelMap.silent) {
|
|
336
340
|
return
|
|
337
341
|
}
|
|
@@ -341,7 +345,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
341
345
|
clack.outro(text)
|
|
342
346
|
})
|
|
343
347
|
|
|
344
|
-
context.on('lint:start', () => {
|
|
348
|
+
context.on('kubb:lint:start', () => {
|
|
345
349
|
if (logLevel <= logLevelMap.silent) {
|
|
346
350
|
return
|
|
347
351
|
}
|
|
@@ -351,7 +355,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
351
355
|
clack.intro(text)
|
|
352
356
|
})
|
|
353
357
|
|
|
354
|
-
context.on('lint:end', () => {
|
|
358
|
+
context.on('kubb:lint:end', () => {
|
|
355
359
|
if (logLevel <= logLevelMap.silent) {
|
|
356
360
|
return
|
|
357
361
|
}
|
|
@@ -361,7 +365,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
361
365
|
clack.outro(text)
|
|
362
366
|
})
|
|
363
367
|
|
|
364
|
-
context.on('hook:start', async ({ id, command, args }) => {
|
|
368
|
+
context.on('kubb:hook:start', async ({ id, command, args }) => {
|
|
365
369
|
const commandWithArgs = formatCommandWithArgs(command, args)
|
|
366
370
|
const text = getMessage(`Hook ${styleText('dim', commandWithArgs)} started`)
|
|
367
371
|
|
|
@@ -408,7 +412,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
408
412
|
})
|
|
409
413
|
})
|
|
410
414
|
|
|
411
|
-
context.on('hook:end', ({ command, args }) => {
|
|
415
|
+
context.on('kubb:hook:end', ({ command, args }) => {
|
|
412
416
|
if (logLevel <= logLevelMap.silent) {
|
|
413
417
|
return
|
|
414
418
|
}
|
|
@@ -419,7 +423,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
419
423
|
clack.outro(text)
|
|
420
424
|
})
|
|
421
425
|
|
|
422
|
-
context.on('generation:summary', (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
|
|
426
|
+
context.on('kubb:generation:summary', (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
|
|
423
427
|
const summary = getSummary({
|
|
424
428
|
failedPlugins,
|
|
425
429
|
filesCreated,
|
|
@@ -434,17 +438,21 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
434
438
|
summary.push('\n')
|
|
435
439
|
|
|
436
440
|
const borderColor = status === 'success' ? 'green' : 'red'
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
441
|
+
try {
|
|
442
|
+
clack.box(summary.join('\n'), getMessage(title), {
|
|
443
|
+
width: 'auto',
|
|
444
|
+
formatBorder: (s: string) => styleText(borderColor, s),
|
|
445
|
+
rounded: true,
|
|
446
|
+
withGuide: false,
|
|
447
|
+
contentAlign: 'left',
|
|
448
|
+
titleAlign: 'center',
|
|
449
|
+
})
|
|
450
|
+
} catch {
|
|
451
|
+
console.log(summary.join('\n'))
|
|
452
|
+
}
|
|
445
453
|
})
|
|
446
454
|
|
|
447
|
-
context.on('lifecycle:end', () => {
|
|
455
|
+
context.on('kubb:lifecycle:end', () => {
|
|
448
456
|
reset()
|
|
449
457
|
})
|
|
450
458
|
},
|