@kubb/cli 5.0.0-beta.75 → 5.0.0-beta.76
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 +17 -10
- package/README.md +171 -51
- package/bin/kubb.js +9 -3
- package/dist/Telemetry-CxzkLSdD.js +284 -0
- package/dist/Telemetry-CxzkLSdD.js.map +1 -0
- package/dist/Telemetry-D8jhC5Bc.cjs +315 -0
- package/dist/Telemetry-D8jhC5Bc.cjs.map +1 -0
- package/dist/{define-Bdn8j5VM.cjs → defineCommand-Bo3yZTWI.cjs} +3 -21
- package/dist/defineCommand-Bo3yZTWI.cjs.map +1 -0
- package/dist/{define-Ctii4bel.js → defineCommand-DMEeqliP.js} +4 -16
- package/dist/defineCommand-DMEeqliP.js.map +1 -0
- package/dist/{errors-CjPmyZHy.js → errors-Dc_d7BfX.js} +2 -2
- package/dist/{errors-CjPmyZHy.js.map → errors-Dc_d7BfX.js.map} +1 -1
- package/dist/{errors-CLCjoSg0.cjs → errors-gxFK0vrp.cjs} +2 -2
- package/dist/{errors-CLCjoSg0.cjs.map → errors-gxFK0vrp.cjs.map} +1 -1
- package/dist/generate-DD2TMRmo.js +77 -0
- package/dist/generate-DD2TMRmo.js.map +1 -0
- package/dist/generate-DJUcRnD9.cjs +76 -0
- package/dist/generate-DJUcRnD9.cjs.map +1 -0
- package/dist/index.cjs +93 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +93 -149
- package/dist/index.js.map +1 -1
- package/dist/init-BYgTbDpy.cjs +53 -0
- package/dist/init-BYgTbDpy.cjs.map +1 -0
- package/dist/init-CONuOE9n.js +53 -0
- package/dist/init-CONuOE9n.js.map +1 -0
- package/dist/mcp---VI5xTX.js +21 -0
- package/dist/mcp---VI5xTX.js.map +1 -0
- package/dist/mcp-CbM2iAFq.cjs +21 -0
- package/dist/mcp-CbM2iAFq.cjs.map +1 -0
- package/dist/package-6guIlMlB.js +6 -0
- package/dist/package-6guIlMlB.js.map +1 -0
- package/dist/{package-D5arPDnh.cjs → package-DnvclOkv.cjs} +2 -2
- package/dist/package-DnvclOkv.cjs.map +1 -0
- package/dist/run-44Zxh8Ec.js +289 -0
- package/dist/run-44Zxh8Ec.js.map +1 -0
- package/dist/run-BPLW8mrc.cjs +52 -0
- package/dist/run-BPLW8mrc.cjs.map +1 -0
- package/dist/run-D1rr0epF.js +1327 -0
- package/dist/run-D1rr0epF.js.map +1 -0
- package/dist/run-DXEMoDFa.cjs +293 -0
- package/dist/run-DXEMoDFa.cjs.map +1 -0
- package/dist/run-Dq0CXCqU.cjs +1330 -0
- package/dist/run-Dq0CXCqU.cjs.map +1 -0
- package/dist/run-Dv-1NGl-.js +32 -0
- package/dist/run-Dv-1NGl-.js.map +1 -0
- package/dist/run-GFI-E4ua.cjs +33 -0
- package/dist/run-GFI-E4ua.cjs.map +1 -0
- package/dist/run-WfvBLKQY.js +51 -0
- package/dist/run-WfvBLKQY.js.map +1 -0
- package/dist/tools-CZT9wSA6.cjs +175 -0
- package/dist/tools-CZT9wSA6.cjs.map +1 -0
- package/dist/tools-D0UogMU3.js +152 -0
- package/dist/tools-D0UogMU3.js.map +1 -0
- package/dist/validate-CNvR28KI.cjs +26 -0
- package/dist/validate-CNvR28KI.cjs.map +1 -0
- package/dist/validate-ClAyEQgx.js +26 -0
- package/dist/validate-ClAyEQgx.js.map +1 -0
- package/package.json +24 -28
- package/dist/agent-BEgI2HXH.cjs +0 -58
- package/dist/agent-BEgI2HXH.cjs.map +0 -1
- package/dist/agent-B_pirbeB.cjs +0 -116
- package/dist/agent-B_pirbeB.cjs.map +0 -1
- package/dist/agent-CTdJEHEs.js +0 -56
- package/dist/agent-CTdJEHEs.js.map +0 -1
- package/dist/agent-Ev5hU5hH.js +0 -112
- package/dist/agent-Ev5hU5hH.js.map +0 -1
- package/dist/constants-CnDXa1R6.cjs +0 -148
- package/dist/constants-CnDXa1R6.cjs.map +0 -1
- package/dist/constants-aL3CP_Wq.js +0 -95
- package/dist/constants-aL3CP_Wq.js.map +0 -1
- package/dist/define-Bdn8j5VM.cjs.map +0 -1
- package/dist/define-Ctii4bel.js.map +0 -1
- package/dist/generate-Cg8yufrw.js +0 -1753
- package/dist/generate-Cg8yufrw.js.map +0 -1
- package/dist/generate-DDCwNQNo.cjs +0 -65
- package/dist/generate-DDCwNQNo.cjs.map +0 -1
- package/dist/generate-K8MJ9aQF.cjs +0 -1756
- package/dist/generate-K8MJ9aQF.cjs.map +0 -1
- package/dist/generate-YPtfjsg4.js +0 -66
- package/dist/generate-YPtfjsg4.js.map +0 -1
- package/dist/init-Bu95ML_u.cjs +0 -25
- package/dist/init-Bu95ML_u.cjs.map +0 -1
- package/dist/init-CZ5Xq2Hd.cjs +0 -293
- package/dist/init-CZ5Xq2Hd.cjs.map +0 -1
- package/dist/init-eNRlotJK.js +0 -289
- package/dist/init-eNRlotJK.js.map +0 -1
- package/dist/init-ooJeOBGt.js +0 -25
- package/dist/init-ooJeOBGt.js.map +0 -1
- package/dist/mcp-C-d5N1wZ.js +0 -16
- package/dist/mcp-C-d5N1wZ.js.map +0 -1
- package/dist/mcp-CLcDV4Jm.cjs +0 -41
- package/dist/mcp-CLcDV4Jm.cjs.map +0 -1
- package/dist/mcp-D7EIR9fR.js +0 -40
- package/dist/mcp-D7EIR9fR.js.map +0 -1
- package/dist/mcp-Dpu8vzzj.cjs +0 -16
- package/dist/mcp-Dpu8vzzj.cjs.map +0 -1
- package/dist/package-D5arPDnh.cjs.map +0 -1
- package/dist/package-DqZsMLZ9.js +0 -6
- package/dist/package-DqZsMLZ9.js.map +0 -1
- package/dist/shell-475fQKaX.cjs +0 -62
- package/dist/shell-475fQKaX.cjs.map +0 -1
- package/dist/shell-DLzN4fRo.js +0 -51
- package/dist/shell-DLzN4fRo.js.map +0 -1
- package/dist/telemetry-DN95_2pF.cjs +0 -282
- package/dist/telemetry-DN95_2pF.cjs.map +0 -1
- package/dist/telemetry-LgT_sdPe.js +0 -245
- package/dist/telemetry-LgT_sdPe.js.map +0 -1
- package/dist/validate-CIR3_lZI.js +0 -25
- package/dist/validate-CIR3_lZI.js.map +0 -1
- package/dist/validate-DcqUb4DM.cjs +0 -25
- package/dist/validate-DcqUb4DM.cjs.map +0 -1
- package/dist/validate-kLJoT_hi.js +0 -33
- package/dist/validate-kLJoT_hi.js.map +0 -1
- package/dist/validate-yKKzqEZ5.cjs +0 -34
- package/dist/validate-yKKzqEZ5.cjs.map +0 -1
- package/src/commands/agent/start.ts +0 -47
- package/src/commands/agent.ts +0 -8
- package/src/commands/generate.ts +0 -57
- package/src/commands/init.ts +0 -20
- package/src/commands/mcp.ts +0 -12
- package/src/commands/validate.ts +0 -20
- package/src/constants.ts +0 -104
- package/src/index.ts +0 -43
- package/src/loggers/clackLogger.ts +0 -458
- package/src/loggers/fileSystemLogger.ts +0 -138
- package/src/loggers/githubActionsLogger.ts +0 -379
- package/src/loggers/plainLogger.ts +0 -254
- package/src/loggers/types.ts +0 -1
- package/src/loggers/utils.ts +0 -106
- package/src/runners/agent.ts +0 -149
- package/src/runners/generate.ts +0 -333
- package/src/runners/init.ts +0 -296
- package/src/runners/mcp.ts +0 -45
- package/src/runners/validate.ts +0 -39
- package/src/types.ts +0 -11
- package/src/utils/Writables.ts +0 -17
- package/src/utils/executeHooks.ts +0 -45
- package/src/utils/flags.ts +0 -9
- package/src/utils/getConfig.ts +0 -10
- package/src/utils/getCosmiConfig.ts +0 -80
- package/src/utils/getSummary.ts +0 -68
- package/src/utils/packageManager.ts +0 -23
- package/src/utils/runHook.ts +0 -91
- package/src/utils/telemetry.ts +0 -273
- package/src/utils/watcher.ts +0 -19
- /package/dist/{chunk-ByKO4r7w.cjs → rolldown-runtime-Bx3C2hgW.cjs} +0 -0
- /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
//#region ../../internals/utils/src/tools.ts
|
|
6
|
+
/**
|
|
7
|
+
* CLI command descriptors for each supported code formatter.
|
|
8
|
+
*
|
|
9
|
+
* Each entry contains the executable `command`, an `args` factory that maps an
|
|
10
|
+
* output path to the correct argument list, and an `errorMessage` shown when
|
|
11
|
+
* the formatter is not found.
|
|
12
|
+
*/
|
|
13
|
+
const formatters = {
|
|
14
|
+
prettier: {
|
|
15
|
+
command: "prettier",
|
|
16
|
+
args: (outputPath) => [
|
|
17
|
+
"--ignore-unknown",
|
|
18
|
+
"--write",
|
|
19
|
+
outputPath
|
|
20
|
+
],
|
|
21
|
+
errorMessage: "Prettier not found"
|
|
22
|
+
},
|
|
23
|
+
biome: {
|
|
24
|
+
command: "biome",
|
|
25
|
+
args: (outputPath) => [
|
|
26
|
+
"format",
|
|
27
|
+
"--write",
|
|
28
|
+
outputPath
|
|
29
|
+
],
|
|
30
|
+
errorMessage: "Biome not found"
|
|
31
|
+
},
|
|
32
|
+
oxfmt: {
|
|
33
|
+
command: "oxfmt",
|
|
34
|
+
args: (outputPath) => [outputPath],
|
|
35
|
+
errorMessage: "Oxfmt not found"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* CLI command descriptors for each supported linter.
|
|
40
|
+
*
|
|
41
|
+
* Each entry contains the executable `command`, an `args` factory that maps an
|
|
42
|
+
* output path to the correct argument list, and an `errorMessage` shown when
|
|
43
|
+
* the linter is not found.
|
|
44
|
+
*/
|
|
45
|
+
const linters = {
|
|
46
|
+
eslint: {
|
|
47
|
+
command: "eslint",
|
|
48
|
+
args: (outputPath) => [outputPath, "--fix"],
|
|
49
|
+
errorMessage: "Eslint not found"
|
|
50
|
+
},
|
|
51
|
+
biome: {
|
|
52
|
+
command: "biome",
|
|
53
|
+
args: (outputPath) => [
|
|
54
|
+
"lint",
|
|
55
|
+
"--fix",
|
|
56
|
+
outputPath
|
|
57
|
+
],
|
|
58
|
+
errorMessage: "Biome not found"
|
|
59
|
+
},
|
|
60
|
+
oxlint: {
|
|
61
|
+
command: "oxlint",
|
|
62
|
+
args: (outputPath) => [
|
|
63
|
+
"--fix",
|
|
64
|
+
"--no-ignore",
|
|
65
|
+
outputPath
|
|
66
|
+
],
|
|
67
|
+
errorMessage: "Oxlint not found"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Resolves to `true` when running `tool --version` exits with code 0.
|
|
72
|
+
*/
|
|
73
|
+
async function isToolAvailable(tool) {
|
|
74
|
+
return new Promise((resolve) => {
|
|
75
|
+
const child = spawn(tool, ["--version"], { stdio: "ignore" });
|
|
76
|
+
child.on("close", (code) => resolve(code === 0));
|
|
77
|
+
child.on("error", () => resolve(false));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the first installed tool from `candidates`, checked in order, or `null` when none are found.
|
|
82
|
+
*
|
|
83
|
+
* Availability is probed by running `<tool> --version` and checking for a zero exit code.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const formatter = await detectTool(['oxfmt', 'biome', 'prettier'] as const)
|
|
88
|
+
* const linter = await detectTool(['oxlint', 'biome', 'eslint'] as const)
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
async function detectTool(candidates) {
|
|
92
|
+
for (const tool of candidates) if (await isToolAvailable(tool)) return tool;
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Metadata for each supported package manager, keyed by its short name.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* packageManagers.pnpm.installCommand // ['add', '-D']
|
|
101
|
+
* packageManagers.npm.lockFile // 'package-lock.json'
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
const packageManagers = {
|
|
105
|
+
pnpm: {
|
|
106
|
+
name: "pnpm",
|
|
107
|
+
lockFile: "pnpm-lock.yaml",
|
|
108
|
+
installCommand: ["add", "-D"]
|
|
109
|
+
},
|
|
110
|
+
yarn: {
|
|
111
|
+
name: "yarn",
|
|
112
|
+
lockFile: "yarn.lock",
|
|
113
|
+
installCommand: ["add", "-D"]
|
|
114
|
+
},
|
|
115
|
+
bun: {
|
|
116
|
+
name: "bun",
|
|
117
|
+
lockFile: "bun.lockb",
|
|
118
|
+
installCommand: ["add", "-d"]
|
|
119
|
+
},
|
|
120
|
+
npm: {
|
|
121
|
+
name: "npm",
|
|
122
|
+
lockFile: "package-lock.json",
|
|
123
|
+
installCommand: ["install", "--save-dev"]
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Detects the active package manager for the given directory.
|
|
128
|
+
* Resolution order: `packageManager` field in `package.json`, then presence of a lock file.
|
|
129
|
+
* Falls back to `npm` when no signal is found.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }
|
|
134
|
+
* detectPackageManager() // falls back to npm when no lock file is found
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
function detectPackageManager(cwd = process.cwd()) {
|
|
138
|
+
const packageJsonPath = join(cwd, "package.json");
|
|
139
|
+
if (existsSync(packageJsonPath)) try {
|
|
140
|
+
const pmField = JSON.parse(readFileSync(packageJsonPath, "utf-8")).packageManager;
|
|
141
|
+
if (typeof pmField === "string") {
|
|
142
|
+
const name = pmField.split("@")[0];
|
|
143
|
+
if (name && name in packageManagers) return packageManagers[name];
|
|
144
|
+
}
|
|
145
|
+
} catch {}
|
|
146
|
+
for (const pm of Object.values(packageManagers)) if (existsSync(join(cwd, pm.lockFile))) return pm;
|
|
147
|
+
return packageManagers.npm;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
export { linters as i, detectTool as n, formatters as r, detectPackageManager as t };
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=tools-D0UogMU3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools-D0UogMU3.js","names":[],"sources":["../../../internals/utils/src/tools.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\n/**\n * CLI command descriptors for each supported code formatter.\n *\n * Each entry contains the executable `command`, an `args` factory that maps an\n * output path to the correct argument list, and an `errorMessage` shown when\n * the formatter is not found.\n */\nexport const formatters = {\n prettier: {\n command: 'prettier',\n args: (outputPath: string) => ['--ignore-unknown', '--write', outputPath],\n errorMessage: 'Prettier not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['format', '--write', outputPath],\n errorMessage: 'Biome not found',\n },\n oxfmt: {\n command: 'oxfmt',\n args: (outputPath: string) => [outputPath],\n errorMessage: 'Oxfmt not found',\n },\n} as const\n\n/**\n * CLI command descriptors for each supported linter.\n *\n * Each entry contains the executable `command`, an `args` factory that maps an\n * output path to the correct argument list, and an `errorMessage` shown when\n * the linter is not found.\n */\nexport const linters = {\n eslint: {\n command: 'eslint',\n args: (outputPath: string) => [outputPath, '--fix'],\n errorMessage: 'Eslint not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['lint', '--fix', outputPath],\n errorMessage: 'Biome not found',\n },\n oxlint: {\n command: 'oxlint',\n // --no-ignore so oxlint lints the folder even when it's gitignored (generated output dirs usually are).\n args: (outputPath: string) => ['--fix', '--no-ignore', outputPath],\n errorMessage: 'Oxlint not found',\n },\n} as const\n\n/**\n * Resolves to `true` when running `tool --version` exits with code 0.\n */\nasync function isToolAvailable(tool: string): Promise<boolean> {\n return new Promise((resolve) => {\n const child = spawn(tool, ['--version'], { stdio: 'ignore' })\n\n child.on('close', (code) => resolve(code === 0))\n child.on('error', () => resolve(false))\n })\n}\n\n/**\n * Returns the first installed tool from `candidates`, checked in order, or `null` when none are found.\n *\n * Availability is probed by running `<tool> --version` and checking for a zero exit code.\n *\n * @example\n * ```ts\n * const formatter = await detectTool(['oxfmt', 'biome', 'prettier'] as const)\n * const linter = await detectTool(['oxlint', 'biome', 'eslint'] as const)\n * ```\n */\nexport async function detectTool<TName extends string>(candidates: ReadonlyArray<TName>): Promise<TName | null> {\n for (const tool of candidates) {\n if (await isToolAvailable(tool)) {\n return tool\n }\n }\n\n return null\n}\n\n/**\n * Supported package manager identifiers.\n *\n * @example\n * ```ts\n * const pm: PackageManagerName = 'pnpm'\n * ```\n */\nexport type PackageManagerName = 'npm' | 'pnpm' | 'yarn' | 'bun'\n\n/**\n * Metadata describing a package manager's lock file and install command.\n */\nexport interface PackageManagerInfo {\n /**\n * Identifier used in CLI commands, e.g. `pnpm`, `yarn`.\n */\n name: PackageManagerName\n /**\n * Lock file name that uniquely identifies this package manager in a project root.\n */\n lockFile: string\n /**\n * Subcommands passed to the package manager binary to install a dev dependency.\n */\n installCommand: ReadonlyArray<string>\n}\n\n/**\n * Metadata for each supported package manager, keyed by its short name.\n *\n * @example\n * ```ts\n * packageManagers.pnpm.installCommand // ['add', '-D']\n * packageManagers.npm.lockFile // 'package-lock.json'\n * ```\n */\nconst packageManagers: Record<PackageManagerName, PackageManagerInfo> = {\n pnpm: {\n name: 'pnpm',\n lockFile: 'pnpm-lock.yaml',\n installCommand: ['add', '-D'],\n },\n yarn: {\n name: 'yarn',\n lockFile: 'yarn.lock',\n installCommand: ['add', '-D'],\n },\n bun: {\n name: 'bun',\n lockFile: 'bun.lockb',\n installCommand: ['add', '-d'],\n },\n npm: {\n name: 'npm',\n lockFile: 'package-lock.json',\n installCommand: ['install', '--save-dev'],\n },\n}\n\n/**\n * Minimal shape of `package.json` fields read during detection.\n */\ntype PackageJson = {\n /**\n * The `packageManager` field from `package.json` (e.g. `\"pnpm@9.0.0\"`).\n */\n packageManager?: string\n}\n\n/**\n * Detects the active package manager for the given directory.\n * Resolution order: `packageManager` field in `package.json`, then presence of a lock file.\n * Falls back to `npm` when no signal is found.\n *\n * @example\n * ```ts\n * detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }\n * detectPackageManager() // falls back to npm when no lock file is found\n * ```\n */\nexport function detectPackageManager(cwd: string = process.cwd()): PackageManagerInfo {\n const packageJsonPath = join(cwd, 'package.json')\n if (existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as PackageJson\n const pmField = packageJson.packageManager\n if (typeof pmField === 'string') {\n const name = pmField.split('@')[0]\n if (name && name in packageManagers) {\n return packageManagers[name as PackageManagerName]\n }\n }\n } catch {\n // Continue to lock file detection\n }\n }\n\n for (const pm of Object.values(packageManagers)) {\n if (existsSync(join(cwd, pm.lockFile))) {\n return pm\n }\n }\n\n return packageManagers.npm\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,aAAa;CACxB,UAAU;EACR,SAAS;EACT,OAAO,eAAuB;GAAC;GAAoB;GAAW;EAAU;EACxE,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAU;GAAW;EAAU;EAC9D,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB,CAAC,UAAU;EACzC,cAAc;CAChB;AACF;;;;;;;;AASA,MAAa,UAAU;CACrB,QAAQ;EACN,SAAS;EACT,OAAO,eAAuB,CAAC,YAAY,OAAO;EAClD,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAQ;GAAS;EAAU;EAC1D,cAAc;CAChB;CACA,QAAQ;EACN,SAAS;EAET,OAAO,eAAuB;GAAC;GAAS;GAAe;EAAU;EACjE,cAAc;CAChB;AACF;;;;AAKA,eAAe,gBAAgB,MAAgC;CAC7D,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,QAAQ,MAAM,MAAM,CAAC,WAAW,GAAG,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require("./package-DnvclOkv.cjs");
|
|
4
|
+
//#region src/commands/validate.ts
|
|
5
|
+
const command = require_defineCommand.defineCommand({
|
|
6
|
+
name: "validate",
|
|
7
|
+
description: "Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.",
|
|
8
|
+
examples: ["kubb validate --input ./openapi.yaml", "kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json"],
|
|
9
|
+
options: { input: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "Path or URL to the OpenAPI/Swagger file to validate",
|
|
12
|
+
short: "i",
|
|
13
|
+
required: true
|
|
14
|
+
} },
|
|
15
|
+
async run({ values }) {
|
|
16
|
+
const { run } = await Promise.resolve().then(() => require("./run-BPLW8mrc.cjs"));
|
|
17
|
+
await run({
|
|
18
|
+
input: values.input,
|
|
19
|
+
version: require_package.version
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.command = command;
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=validate-CNvR28KI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-CNvR28KI.cjs","names":["defineCommand"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description:\n 'Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAUA,sBAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,wEAAwE;CAC3H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO,SAAA,gBAAA;EAAQ,CAAC;CAC5C;AACF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { t as defineCommand } from "./defineCommand-DMEeqliP.js";
|
|
3
|
+
import { t as version } from "./package-6guIlMlB.js";
|
|
4
|
+
//#region src/commands/validate.ts
|
|
5
|
+
const command = defineCommand({
|
|
6
|
+
name: "validate",
|
|
7
|
+
description: "Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.",
|
|
8
|
+
examples: ["kubb validate --input ./openapi.yaml", "kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json"],
|
|
9
|
+
options: { input: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "Path or URL to the OpenAPI/Swagger file to validate",
|
|
12
|
+
short: "i",
|
|
13
|
+
required: true
|
|
14
|
+
} },
|
|
15
|
+
async run({ values }) {
|
|
16
|
+
const { run } = await import("./run-WfvBLKQY.js");
|
|
17
|
+
await run({
|
|
18
|
+
input: values.input,
|
|
19
|
+
version
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
//#endregion
|
|
24
|
+
export { command };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=validate-ClAyEQgx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-ClAyEQgx.js","names":[],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description:\n 'Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,wEAAwE;CAC3H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO;EAAQ,CAAC;CAC5C;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "5.0.0-beta.76",
|
|
4
|
+
"description": "Official CLI for Kubb. Run kubb generate, kubb init, kubb validate, and kubb mcp to manage the full code generation lifecycle.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
7
7
|
"code-generator",
|
|
8
8
|
"codegen",
|
|
9
|
-
"command-line",
|
|
10
|
-
"command-line-tool",
|
|
11
9
|
"kubb",
|
|
12
|
-
"
|
|
13
|
-
"openapi",
|
|
14
|
-
"plugins",
|
|
10
|
+
"meta-framework",
|
|
15
11
|
"sdk-generator",
|
|
16
|
-
"swagger",
|
|
17
|
-
"terminal",
|
|
18
12
|
"typescript"
|
|
19
13
|
],
|
|
20
14
|
"license": "MIT",
|
|
@@ -28,7 +22,6 @@
|
|
|
28
22
|
"kubb": "bin/kubb.js"
|
|
29
23
|
},
|
|
30
24
|
"files": [
|
|
31
|
-
"src",
|
|
32
25
|
"dist",
|
|
33
26
|
"bin",
|
|
34
27
|
"!/**/**.test.**",
|
|
@@ -52,39 +45,42 @@
|
|
|
52
45
|
"registry": "https://registry.npmjs.org/"
|
|
53
46
|
},
|
|
54
47
|
"dependencies": {
|
|
55
|
-
"@clack/prompts": "^1.
|
|
48
|
+
"@clack/prompts": "^1.6.0",
|
|
56
49
|
"chokidar": "^5.0.0",
|
|
57
|
-
"
|
|
58
|
-
"tinyexec": "^1.
|
|
59
|
-
"
|
|
60
|
-
"@kubb/core": "5.0.0-beta.
|
|
61
|
-
"@kubb/adapter-oas": "5.0.0-beta.75"
|
|
50
|
+
"jiti": "^2.7.0",
|
|
51
|
+
"tinyexec": "^1.2.4",
|
|
52
|
+
"unconfig": "^7.5.0",
|
|
53
|
+
"@kubb/core": "5.0.0-beta.76"
|
|
62
54
|
},
|
|
63
55
|
"devDependencies": {
|
|
64
|
-
"@internals/
|
|
56
|
+
"@internals/shared": "0.0.0",
|
|
57
|
+
"@internals/utils": "0.0.0",
|
|
58
|
+
"@kubb/adapter-oas": "5.0.0-beta.76"
|
|
65
59
|
},
|
|
66
|
-
"
|
|
67
|
-
"@kubb/
|
|
68
|
-
"@kubb/mcp": "5.0.0-beta.
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@kubb/adapter-oas": "5.0.0-beta.76",
|
|
62
|
+
"@kubb/mcp": "5.0.0-beta.76"
|
|
69
63
|
},
|
|
70
|
-
"
|
|
71
|
-
{
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
"peerDependenciesMeta": {
|
|
65
|
+
"@kubb/adapter-oas": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"@kubb/mcp": {
|
|
69
|
+
"optional": true
|
|
75
70
|
}
|
|
76
|
-
|
|
71
|
+
},
|
|
77
72
|
"preferGlobal": true,
|
|
78
73
|
"engines": {
|
|
79
74
|
"node": ">=22"
|
|
80
75
|
},
|
|
81
76
|
"scripts": {
|
|
82
|
-
"build": "tsdown
|
|
83
|
-
"clean": "
|
|
77
|
+
"build": "tsdown",
|
|
78
|
+
"clean": "node -e \"require('node:fs').rmSync('./dist', {recursive:true,force:true})\"",
|
|
84
79
|
"lint": "oxlint .",
|
|
85
80
|
"lint:fix": "oxlint --fix .",
|
|
86
81
|
"release": "pnpm publish --no-git-check",
|
|
87
82
|
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
83
|
+
"release:stage": "pnpm stage publish --no-git-check",
|
|
88
84
|
"start": "tsdown --watch",
|
|
89
85
|
"test": "vitest --passWithNoTests",
|
|
90
86
|
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
package/dist/agent-BEgI2HXH.cjs
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
require("./chunk-ByKO4r7w.cjs");
|
|
2
|
-
const require_define = require("./define-Bdn8j5VM.cjs");
|
|
3
|
-
const require_package = require("./package-D5arPDnh.cjs");
|
|
4
|
-
const require_constants = require("./constants-CnDXa1R6.cjs");
|
|
5
|
-
//#region src/commands/agent/start.ts
|
|
6
|
-
const command$1 = require_define.defineCommand({
|
|
7
|
-
name: "start",
|
|
8
|
-
description: "Start the Agent server",
|
|
9
|
-
options: {
|
|
10
|
-
config: {
|
|
11
|
-
type: "string",
|
|
12
|
-
description: "Path to the Kubb config",
|
|
13
|
-
short: "c"
|
|
14
|
-
},
|
|
15
|
-
port: {
|
|
16
|
-
type: "string",
|
|
17
|
-
description: `Port for the server (default: ${require_constants.agentDefaults.port})`,
|
|
18
|
-
short: "p"
|
|
19
|
-
},
|
|
20
|
-
host: {
|
|
21
|
-
type: "string",
|
|
22
|
-
description: "Host for the server",
|
|
23
|
-
default: require_constants.agentDefaults.host
|
|
24
|
-
},
|
|
25
|
-
"allow-write": {
|
|
26
|
-
type: "boolean",
|
|
27
|
-
description: "Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.",
|
|
28
|
-
default: false
|
|
29
|
-
},
|
|
30
|
-
"allow-all": {
|
|
31
|
-
type: "boolean",
|
|
32
|
-
description: "Grant all permissions (implies --allow-write).",
|
|
33
|
-
default: false
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
async run({ values }) {
|
|
37
|
-
const { runAgentStart } = await Promise.resolve().then(() => require("./agent-B_pirbeB.cjs"));
|
|
38
|
-
await runAgentStart({
|
|
39
|
-
port: values.port !== void 0 ? values.port : void 0,
|
|
40
|
-
host: values.host,
|
|
41
|
-
configPath: values.config,
|
|
42
|
-
allowWrite: values["allow-write"],
|
|
43
|
-
allowAll: values["allow-all"],
|
|
44
|
-
version: require_package.version
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/commands/agent.ts
|
|
50
|
-
const command = require_define.defineCommand({
|
|
51
|
-
name: "agent",
|
|
52
|
-
description: "Manage the Kubb Agent server",
|
|
53
|
-
subCommands: [command$1]
|
|
54
|
-
});
|
|
55
|
-
//#endregion
|
|
56
|
-
exports.command = command;
|
|
57
|
-
|
|
58
|
-
//# sourceMappingURL=agent-BEgI2HXH.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-BEgI2HXH.cjs","names":["command","defineCommand","agentDefaults","defineCommand","startCommand"],"sources":["../src/commands/agent/start.ts","../src/commands/agent.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../../package.json'\nimport { agentDefaults } from '../../constants.ts'\n\nexport const command = defineCommand({\n name: 'start',\n description: 'Start the Agent server',\n options: {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n port: {\n type: 'string',\n description: `Port for the server (default: ${agentDefaults.port})`,\n short: 'p',\n },\n host: {\n type: 'string',\n description: 'Host for the server',\n default: agentDefaults.host,\n },\n 'allow-write': {\n type: 'boolean',\n description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',\n default: false,\n },\n 'allow-all': {\n type: 'boolean',\n description: 'Grant all permissions (implies --allow-write).',\n default: false,\n },\n },\n async run({ values }) {\n const { runAgentStart } = await import('../../runners/agent.ts')\n\n await runAgentStart({\n port: values.port !== undefined ? values.port : undefined,\n host: values.host,\n configPath: values.config,\n allowWrite: values['allow-write'],\n allowAll: values['allow-all'],\n version,\n })\n },\n})\n","import { defineCommand } from '@internals/utils'\nimport { command as startCommand } from './agent/start.ts'\n\nexport const command = defineCommand({\n name: 'agent',\n description: 'Manage the Kubb Agent server',\n subCommands: [startCommand],\n})\n"],"mappings":";;;;;AAIA,MAAaA,YAAUC,eAAAA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACR;EACD,MAAM;GACJ,MAAM;GACN,aAAa,iCAAiCC,kBAAAA,cAAc,KAAK;GACjE,OAAO;GACR;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,SAASA,kBAAAA,cAAc;GACxB;EACD,eAAe;GACb,MAAM;GACN,aAAa;GACb,SAAS;GACV;EACD,aAAa;GACX,MAAM;GACN,aAAa;GACb,SAAS;GACV;EACF;CACD,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,kBAAkB,MAAA,QAAA,SAAA,CAAA,WAAA,QAAM,uBAAA,CAAA;AAEhC,QAAM,cAAc;GAClB,MAAM,OAAO,SAAS,KAAA,IAAY,OAAO,OAAO,KAAA;GAChD,MAAM,OAAO;GACb,YAAY,OAAO;GACnB,YAAY,OAAO;GACnB,UAAU,OAAO;GACjB,SAAA,gBAAA;GACD,CAAC;;CAEL,CAAC;;;AC3CF,MAAa,UAAUC,eAAAA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,aAAa,CAACC,UAAa;CAC5B,CAAC"}
|
package/dist/agent-B_pirbeB.cjs
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
2
|
-
const require_telemetry = require("./telemetry-DN95_2pF.cjs");
|
|
3
|
-
const require_shell = require("./shell-475fQKaX.cjs");
|
|
4
|
-
const require_constants = require("./constants-CnDXa1R6.cjs");
|
|
5
|
-
let node_util = require("node:util");
|
|
6
|
-
let node_path = require("node:path");
|
|
7
|
-
node_path = require_chunk.__toESM(node_path, 1);
|
|
8
|
-
let node_process = require("node:process");
|
|
9
|
-
node_process = require_chunk.__toESM(node_process, 1);
|
|
10
|
-
let node_net = require("node:net");
|
|
11
|
-
node_net = require_chunk.__toESM(node_net, 1);
|
|
12
|
-
let node_url = require("node:url");
|
|
13
|
-
let _clack_prompts = require("@clack/prompts");
|
|
14
|
-
_clack_prompts = require_chunk.__toESM(_clack_prompts, 1);
|
|
15
|
-
//#region src/runners/agent.ts
|
|
16
|
-
/**
|
|
17
|
-
* Resolves the environment passed to the detached agent process using CLI values first, then environment values, then CLI defaults.
|
|
18
|
-
*/
|
|
19
|
-
function resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll }) {
|
|
20
|
-
const resolvedPort = port ?? node_process.env.PORT ?? require_constants.agentDefaults.port;
|
|
21
|
-
const resolvedHost = host !== require_constants.agentDefaults.host ? host : node_process.env.HOST ?? require_constants.agentDefaults.host;
|
|
22
|
-
const resolvedAllowAll = allowAll || node_process.env.KUBB_AGENT_ALLOW_ALL === "true";
|
|
23
|
-
const resolvedAllowWrite = resolvedAllowAll || allowWrite || node_process.env.KUBB_AGENT_ALLOW_WRITE === "true";
|
|
24
|
-
const agentRoot = node_process.env.KUBB_AGENT_ROOT ?? node_process.cwd();
|
|
25
|
-
const agentConfigPath = node_path.default.resolve(node_process.cwd(), configPath || node_process.env.KUBB_AGENT_CONFIG || require_constants.agentDefaults.configFile);
|
|
26
|
-
return {
|
|
27
|
-
port: resolvedPort,
|
|
28
|
-
host: resolvedHost,
|
|
29
|
-
allowWrite: resolvedAllowWrite,
|
|
30
|
-
allowAll: resolvedAllowAll,
|
|
31
|
-
agentConfigPath,
|
|
32
|
-
env: {
|
|
33
|
-
...node_process.env,
|
|
34
|
-
PORT: resolvedPort,
|
|
35
|
-
HOST: resolvedHost,
|
|
36
|
-
KUBB_AGENT_ROOT: agentRoot,
|
|
37
|
-
KUBB_AGENT_CONFIG: agentConfigPath,
|
|
38
|
-
KUBB_AGENT_ALLOW_WRITE: String(resolvedAllowWrite),
|
|
39
|
-
KUBB_AGENT_ALLOW_ALL: String(resolvedAllowAll),
|
|
40
|
-
KUBB_AGENT_TOKEN: node_process.env.KUBB_AGENT_TOKEN,
|
|
41
|
-
KUBB_AGENT_RETRY_TIMEOUT: node_process.env.KUBB_AGENT_RETRY_TIMEOUT ?? require_constants.agentDefaults.retryTimeout,
|
|
42
|
-
KUBB_STUDIO_URL: node_process.env.KUBB_STUDIO_URL ?? require_constants.agentDefaults.studioUrl
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function isPortAvailable(port, host) {
|
|
47
|
-
return new Promise((resolve) => {
|
|
48
|
-
const server = node_net.default.createServer();
|
|
49
|
-
server.once("error", () => resolve(false));
|
|
50
|
-
server.once("listening", () => {
|
|
51
|
-
server.close();
|
|
52
|
-
resolve(true);
|
|
53
|
-
});
|
|
54
|
-
server.listen(port, host);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }) {
|
|
58
|
-
const hrStart = node_process.hrtime();
|
|
59
|
-
try {
|
|
60
|
-
try {
|
|
61
|
-
node_process.loadEnvFile();
|
|
62
|
-
} catch {}
|
|
63
|
-
let agentPkgUrl;
|
|
64
|
-
try {
|
|
65
|
-
agentPkgUrl = {}.resolve("@kubb/agent/package.json");
|
|
66
|
-
} catch (_e) {
|
|
67
|
-
console.error(`Import of '@kubb/agent' is required to start the Agent server`);
|
|
68
|
-
node_process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
const agentPkgPath = (0, node_url.fileURLToPath)(agentPkgUrl);
|
|
71
|
-
const agentDir = node_path.default.dirname(agentPkgPath);
|
|
72
|
-
const serverPath = node_path.default.join(agentDir, require_constants.agentDefaults.serverEntryPath);
|
|
73
|
-
const resolvedEnv = resolveAgentStartEnvironment({
|
|
74
|
-
port,
|
|
75
|
-
host,
|
|
76
|
-
configPath,
|
|
77
|
-
allowWrite,
|
|
78
|
-
allowAll
|
|
79
|
-
});
|
|
80
|
-
const numericPort = Number(resolvedEnv.port);
|
|
81
|
-
if (!Number.isInteger(numericPort) || numericPort <= 0) throw new Error(`Invalid port "${resolvedEnv.port}". Provide a positive integer with --port or PORT.`);
|
|
82
|
-
_clack_prompts.log.step((0, node_util.styleText)("cyan", "Starting agent server..."));
|
|
83
|
-
_clack_prompts.log.info((0, node_util.styleText)("dim", `Config: ${resolvedEnv.agentConfigPath}`));
|
|
84
|
-
_clack_prompts.log.info((0, node_util.styleText)("dim", `Host: ${resolvedEnv.host}`));
|
|
85
|
-
_clack_prompts.log.info((0, node_util.styleText)("dim", `Port: ${resolvedEnv.port}`));
|
|
86
|
-
if (!resolvedEnv.allowWrite && !resolvedEnv.allowAll) _clack_prompts.log.warn((0, node_util.styleText)("yellow", "Filesystem writes disabled. Use --allow-write or --allow-all to enable."));
|
|
87
|
-
if (!await isPortAvailable(numericPort, resolvedEnv.host)) {
|
|
88
|
-
_clack_prompts.log.error((0, node_util.styleText)("red", `Port ${resolvedEnv.port} is already in use. Stop the existing process or choose a different port with --port.`));
|
|
89
|
-
node_process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
await require_shell.spawnAsync("node", [serverPath], {
|
|
92
|
-
env: resolvedEnv.env,
|
|
93
|
-
cwd: node_process.cwd()
|
|
94
|
-
});
|
|
95
|
-
await require_telemetry.sendTelemetry(require_telemetry.buildTelemetryEvent({
|
|
96
|
-
command: "agent",
|
|
97
|
-
kubbVersion: version,
|
|
98
|
-
hrStart,
|
|
99
|
-
status: "success"
|
|
100
|
-
}));
|
|
101
|
-
} catch (error) {
|
|
102
|
-
await require_telemetry.sendTelemetry(require_telemetry.buildTelemetryEvent({
|
|
103
|
-
command: "agent",
|
|
104
|
-
kubbVersion: version,
|
|
105
|
-
hrStart,
|
|
106
|
-
status: "failed"
|
|
107
|
-
}));
|
|
108
|
-
_clack_prompts.log.error((0, node_util.styleText)("red", "Failed to start agent server"));
|
|
109
|
-
console.error(error);
|
|
110
|
-
node_process.exit(1);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
//#endregion
|
|
114
|
-
exports.runAgentStart = runAgentStart;
|
|
115
|
-
|
|
116
|
-
//# sourceMappingURL=agent-B_pirbeB.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-B_pirbeB.cjs","names":["process","agentDefaults","path","net","spawnAsync","sendTelemetry","buildTelemetryEvent"],"sources":["../src/runners/agent.ts"],"sourcesContent":["import net from 'node:net'\nimport path from 'node:path'\nimport * as process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { spawnAsync } from '@internals/utils'\nimport { agentDefaults } from '../constants.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype AgentStartOptions = {\n port: string | undefined\n host: string\n configPath: string | undefined\n allowWrite: boolean\n allowAll: boolean\n version: string\n}\n\ntype ResolvedAgentStartEnvironment = {\n port: string\n host: string\n allowWrite: boolean\n allowAll: boolean\n agentConfigPath: string\n env: NodeJS.ProcessEnv\n}\n\n/**\n * Resolves the environment passed to the detached agent process using CLI values first, then environment values, then CLI defaults.\n */\nfunction resolveAgentStartEnvironment({ port, host, configPath, allowWrite, allowAll }: Omit<AgentStartOptions, 'version'>): ResolvedAgentStartEnvironment {\n const resolvedPort = port ?? process.env.PORT ?? agentDefaults.port\n const resolvedHost = host !== agentDefaults.host ? host : (process.env.HOST ?? agentDefaults.host)\n const resolvedAllowAll = allowAll || process.env.KUBB_AGENT_ALLOW_ALL === 'true'\n const resolvedAllowWrite = resolvedAllowAll || allowWrite || process.env.KUBB_AGENT_ALLOW_WRITE === 'true'\n const agentRoot = process.env.KUBB_AGENT_ROOT ?? process.cwd()\n const agentConfigPath = path.resolve(process.cwd(), configPath || process.env.KUBB_AGENT_CONFIG || agentDefaults.configFile)\n\n return {\n port: resolvedPort,\n host: resolvedHost,\n allowWrite: resolvedAllowWrite,\n allowAll: resolvedAllowAll,\n agentConfigPath,\n env: {\n ...process.env,\n PORT: resolvedPort,\n HOST: resolvedHost,\n KUBB_AGENT_ROOT: agentRoot,\n KUBB_AGENT_CONFIG: agentConfigPath,\n KUBB_AGENT_ALLOW_WRITE: String(resolvedAllowWrite),\n KUBB_AGENT_ALLOW_ALL: String(resolvedAllowAll),\n KUBB_AGENT_TOKEN: process.env.KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT: process.env.KUBB_AGENT_RETRY_TIMEOUT ?? agentDefaults.retryTimeout,\n KUBB_STUDIO_URL: process.env.KUBB_STUDIO_URL ?? agentDefaults.studioUrl,\n },\n }\n}\n\nfunction isPortAvailable(port: number, host: string): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer()\n server.once('error', () => resolve(false))\n server.once('listening', () => {\n server.close()\n resolve(true)\n })\n server.listen(port, host)\n })\n}\n\nexport async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }: AgentStartOptions): Promise<void> {\n const hrStart = process.hrtime()\n\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist; ignore\n }\n\n // Resolve the @kubb/agent package path\n let agentPkgUrl: string\n try {\n agentPkgUrl = import.meta.resolve('@kubb/agent/package.json')\n } catch (_e) {\n console.error(`Import of '@kubb/agent' is required to start the Agent server`)\n process.exit(1)\n }\n const agentPkgPath = fileURLToPath(agentPkgUrl)\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, agentDefaults.serverEntryPath)\n\n const resolvedEnv = resolveAgentStartEnvironment({\n port,\n host,\n configPath,\n allowWrite,\n allowAll,\n })\n const numericPort = Number(resolvedEnv.port)\n\n if (!Number.isInteger(numericPort) || numericPort <= 0) {\n throw new Error(`Invalid port \"${resolvedEnv.port}\". Provide a positive integer with --port or PORT.`)\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${resolvedEnv.agentConfigPath}`))\n clack.log.info(styleText('dim', `Host: ${resolvedEnv.host}`))\n clack.log.info(styleText('dim', `Port: ${resolvedEnv.port}`))\n if (!resolvedEnv.allowWrite && !resolvedEnv.allowAll) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n if (!(await isPortAvailable(numericPort, resolvedEnv.host))) {\n clack.log.error(styleText('red', `Port ${resolvedEnv.port} is already in use. Stop the existing process or choose a different port with --port.`))\n process.exit(1)\n }\n\n // Spawns the server as a detached background process so the CLI can exit independently.\n await spawnAsync('node', [serverPath], {\n env: resolvedEnv.env,\n cwd: process.cwd(),\n })\n\n await sendTelemetry(\n buildTelemetryEvent({\n command: 'agent',\n kubbVersion: version,\n hrStart,\n status: 'success',\n }),\n )\n } catch (error) {\n await sendTelemetry(\n buildTelemetryEvent({\n command: 'agent',\n kubbVersion: version,\n hrStart,\n status: 'failed',\n }),\n )\n clack.log.error(styleText('red', 'Failed to start agent server'))\n console.error(error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,SAAS,6BAA6B,EAAE,MAAM,MAAM,YAAY,YAAY,YAA+E;CACzJ,MAAM,eAAe,QAAQA,aAAQ,IAAI,QAAQC,kBAAAA,cAAc;CAC/D,MAAM,eAAe,SAASA,kBAAAA,cAAc,OAAO,OAAQD,aAAQ,IAAI,QAAQC,kBAAAA,c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OAAO,+BAA+B,CAAC;AACjE,UAAQ,MAAM,MAAM;AACpB,eAAQ,KAAK,EAAE"}
|
package/dist/agent-CTdJEHEs.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as defineCommand } from "./define-Ctii4bel.js";
|
|
3
|
-
import { t as version } from "./package-DqZsMLZ9.js";
|
|
4
|
-
import { s as agentDefaults } from "./constants-aL3CP_Wq.js";
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/commands/agent.ts
|
|
7
|
-
const command = defineCommand({
|
|
8
|
-
name: "agent",
|
|
9
|
-
description: "Manage the Kubb Agent server",
|
|
10
|
-
subCommands: [defineCommand({
|
|
11
|
-
name: "start",
|
|
12
|
-
description: "Start the Agent server",
|
|
13
|
-
options: {
|
|
14
|
-
config: {
|
|
15
|
-
type: "string",
|
|
16
|
-
description: "Path to the Kubb config",
|
|
17
|
-
short: "c"
|
|
18
|
-
},
|
|
19
|
-
port: {
|
|
20
|
-
type: "string",
|
|
21
|
-
description: `Port for the server (default: ${agentDefaults.port})`,
|
|
22
|
-
short: "p"
|
|
23
|
-
},
|
|
24
|
-
host: {
|
|
25
|
-
type: "string",
|
|
26
|
-
description: "Host for the server",
|
|
27
|
-
default: agentDefaults.host
|
|
28
|
-
},
|
|
29
|
-
"allow-write": {
|
|
30
|
-
type: "boolean",
|
|
31
|
-
description: "Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.",
|
|
32
|
-
default: false
|
|
33
|
-
},
|
|
34
|
-
"allow-all": {
|
|
35
|
-
type: "boolean",
|
|
36
|
-
description: "Grant all permissions (implies --allow-write).",
|
|
37
|
-
default: false
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
async run({ values }) {
|
|
41
|
-
const { runAgentStart } = await import("./agent-Ev5hU5hH.js");
|
|
42
|
-
await runAgentStart({
|
|
43
|
-
port: values.port !== void 0 ? values.port : void 0,
|
|
44
|
-
host: values.host,
|
|
45
|
-
configPath: values.config,
|
|
46
|
-
allowWrite: values["allow-write"],
|
|
47
|
-
allowAll: values["allow-all"],
|
|
48
|
-
version
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
})]
|
|
52
|
-
});
|
|
53
|
-
//#endregion
|
|
54
|
-
export { command };
|
|
55
|
-
|
|
56
|
-
//# sourceMappingURL=agent-CTdJEHEs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-CTdJEHEs.js","names":["command","startCommand"],"sources":["../src/commands/agent/start.ts","../src/commands/agent.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../../package.json'\nimport { agentDefaults } from '../../constants.ts'\n\nexport const command = defineCommand({\n name: 'start',\n description: 'Start the Agent server',\n options: {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n port: {\n type: 'string',\n description: `Port for the server (default: ${agentDefaults.port})`,\n short: 'p',\n },\n host: {\n type: 'string',\n description: 'Host for the server',\n default: agentDefaults.host,\n },\n 'allow-write': {\n type: 'boolean',\n description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',\n default: false,\n },\n 'allow-all': {\n type: 'boolean',\n description: 'Grant all permissions (implies --allow-write).',\n default: false,\n },\n },\n async run({ values }) {\n const { runAgentStart } = await import('../../runners/agent.ts')\n\n await runAgentStart({\n port: values.port !== undefined ? values.port : undefined,\n host: values.host,\n configPath: values.config,\n allowWrite: values['allow-write'],\n allowAll: values['allow-all'],\n version,\n })\n },\n})\n","import { defineCommand } from '@internals/utils'\nimport { command as startCommand } from './agent/start.ts'\n\nexport const command = defineCommand({\n name: 'agent',\n description: 'Manage the Kubb Agent server',\n subCommands: [startCommand],\n})\n"],"mappings":";;;;;;ACGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,aAAa,CDFQ,cAAc;EACnC,MAAM;EACN,aAAa;EACb,SAAS;GACP,QAAQ;IACN,MAAM;IACN,aAAa;IACb,OAAO;IACR;GACD,MAAM;IACJ,MAAM;IACN,aAAa,iCAAiC,cAAc,KAAK;IACjE,OAAO;IACR;GACD,MAAM;IACJ,MAAM;IACN,aAAa;IACb,SAAS,cAAc;IACxB;GACD,eAAe;IACb,MAAM;IACN,aAAa;IACb,SAAS;IACV;GACD,aAAa;IACX,MAAM;IACN,aAAa;IACb,SAAS;IACV;GACF;EACD,MAAM,IAAI,EAAE,UAAU;GACpB,MAAM,EAAE,kBAAkB,MAAM,OAAO;AAEvC,SAAM,cAAc;IAClB,MAAM,OAAO,SAAS,KAAA,IAAY,OAAO,OAAO,KAAA;IAChD,MAAM,OAAO;IACb,YAAY,OAAO;IACnB,YAAY,OAAO;IACnB,UAAU,OAAO;IACjB;IACD,CAAC;;EAEL,CCxCeC,CAAa;CAC5B,CAAC"}
|