@kubb/cli 3.18.3 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{generate-CKnWsDnu.cjs → generate-BALD2C5T.cjs} +84 -92
- package/dist/generate-BALD2C5T.cjs.map +1 -0
- package/dist/{generate-jMDBjxTU.js → generate-BqNABk2X.js} +56 -95
- package/dist/generate-BqNABk2X.js.map +1 -0
- package/dist/{generate-Bu9WyH1N.cjs → generate-DKlT22M0.cjs} +74 -104
- package/dist/generate-DKlT22M0.cjs.map +1 -0
- package/dist/{generate-DvSF6lmv.js → generate-vHDmA5Mm.js} +44 -72
- package/dist/generate-vHDmA5Mm.js.map +1 -0
- package/dist/index.cjs +16 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/{mcp-DcaOAt6B.js → mcp-C4KjGtQv.js} +9 -10
- package/dist/mcp-C4KjGtQv.js.map +1 -0
- package/dist/{mcp-Cmiw4RpU.cjs → mcp-CLmIdoaC.cjs} +17 -14
- package/dist/mcp-CLmIdoaC.cjs.map +1 -0
- package/dist/{validate-DD5UaudC.js → validate-8i6chavn.js} +18 -20
- package/dist/validate-8i6chavn.js.map +1 -0
- package/dist/{validate-ClewPP5U.cjs → validate-DNbDDWp4.cjs} +26 -24
- package/dist/validate-DNbDDWp4.cjs.map +1 -0
- package/package.json +8 -11
- package/src/commands/generate.ts +0 -43
- package/dist/generate-Bu9WyH1N.cjs.map +0 -1
- package/dist/generate-CKnWsDnu.cjs.map +0 -1
- package/dist/generate-DvSF6lmv.js.map +0 -1
- package/dist/generate-jMDBjxTU.js.map +0 -1
- package/dist/mcp-Cmiw4RpU.cjs.map +0 -1
- package/dist/mcp-DcaOAt6B.js.map +0 -1
- package/dist/validate-ClewPP5U.cjs.map +0 -1
- package/dist/validate-DD5UaudC.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
let citty = require("citty");
|
|
3
|
+
citty = require_chunk.__toESM(citty);
|
|
4
|
+
let consola = require("consola");
|
|
5
|
+
consola = require_chunk.__toESM(consola);
|
|
6
|
+
let gradient_string = require("gradient-string");
|
|
7
|
+
gradient_string = require_chunk.__toESM(gradient_string);
|
|
8
|
+
let latest_version = require("latest-version");
|
|
9
|
+
latest_version = require_chunk.__toESM(latest_version);
|
|
10
|
+
let semver = require("semver");
|
|
11
|
+
semver = require_chunk.__toESM(semver);
|
|
7
12
|
|
|
8
13
|
//#region package.json
|
|
9
|
-
var version = "
|
|
14
|
+
var version = "4.0.2";
|
|
10
15
|
|
|
11
16
|
//#endregion
|
|
12
17
|
//#region src/index.ts
|
|
13
|
-
const name = "kubb";
|
|
14
18
|
const main = (0, citty.defineCommand)({
|
|
15
19
|
meta: {
|
|
16
|
-
name,
|
|
20
|
+
name: "kubb",
|
|
17
21
|
version,
|
|
18
22
|
description: "Kubb generation"
|
|
19
23
|
},
|
|
@@ -51,15 +55,15 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
51
55
|
"mcp"
|
|
52
56
|
].includes(rawArgs[0])) {
|
|
53
57
|
console.log(rawArgs[0]);
|
|
54
|
-
const generateCommand = await Promise.resolve().then(() => require("./generate-
|
|
58
|
+
const generateCommand = await Promise.resolve().then(() => require("./generate-DKlT22M0.cjs")).then((r) => r.default);
|
|
55
59
|
await (0, citty.runCommand)(generateCommand, { rawArgs });
|
|
56
60
|
process.exit(0);
|
|
57
61
|
}
|
|
58
62
|
},
|
|
59
63
|
subCommands: {
|
|
60
|
-
generate: () => Promise.resolve().then(() => require("./generate-
|
|
61
|
-
validate: () => Promise.resolve().then(() => require("./validate-
|
|
62
|
-
mcp: () => Promise.resolve().then(() => require("./mcp-
|
|
64
|
+
generate: () => Promise.resolve().then(() => require("./generate-DKlT22M0.cjs")).then((r) => r.default),
|
|
65
|
+
validate: () => Promise.resolve().then(() => require("./validate-DNbDDWp4.cjs")).then((r) => r.default),
|
|
66
|
+
mcp: () => Promise.resolve().then(() => require("./mcp-CLmIdoaC.cjs")).then((r) => r.default)
|
|
63
67
|
}
|
|
64
68
|
});
|
|
65
69
|
async function run(_argv) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@kubb/cli\",\n \"version\": \"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@kubb/cli\",\n \"version\": \"4.0.2\",\n \"description\": \"Command-line interface for Kubb, enabling easy generation of TypeScript, React-Query, Zod, and other code from OpenAPI specifications.\",\n \"keywords\": [\n \"cli\",\n \"command-line\",\n \"typescript\",\n \"openapi\",\n \"swagger\",\n \"code-generator\",\n \"codegen\",\n \"plugins\",\n \"kubb\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/kubb-labs/kubb.git\",\n \"directory\": \"packages/cli\"\n },\n \"license\": \"MIT\",\n \"author\": \"stijnvanhulle\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.cts\",\n \"bin\": {\n \"kubb\": \"bin/kubb.cjs\"\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsdown\",\n \"clean\": \"npx rimraf ./dist\",\n \"lint\": \"bun biome lint .\",\n \"lint:fix\": \"bun biome lint --fix --unsafe .\",\n \"release\": \"pnpm publish --no-git-check\",\n \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check\",\n \"start\": \"tsdown --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"chokidar\": \"^4.0.3\",\n \"citty\": \"^0.1.6\",\n \"cli-progress\": \"^3.12.0\",\n \"consola\": \"^3.4.2\",\n \"cosmiconfig\": \"^9.0.0\",\n \"execa\": \"^9.6.0\",\n \"gradient-string\": \"^3.0.0\",\n \"jiti\": \"^2.6.0\",\n \"latest-version\": \"^9.0.0\",\n \"picocolors\": \"^1.1.1\",\n \"semver\": \"^7.7.2\",\n \"string-argv\": \"^0.3.2\"\n },\n \"devDependencies\": {\n \"@kubb/mcp\": \"workspace:*\",\n \"@kubb/oas\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"catalog:\",\n \"@types/semver\": \"^7.7.1\",\n \"source-map-support\": \"^0.5.21\",\n \"tsdown\": \"catalog:\",\n \"typescript\": \"catalog:\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"preferGlobal\": true,\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import { defineCommand, runCommand, runMain } from 'citty'\nimport consola from 'consola'\nimport { default as gradientString } from 'gradient-string'\nimport getLatestVersion from 'latest-version'\nimport { lt } from 'semver'\nimport { version } from '../package.json'\n\nconst name = 'kubb'\n\nconst main = defineCommand({\n meta: {\n name,\n version,\n description: 'Kubb generation',\n },\n args: {\n version: {\n type: 'boolean',\n alias: 'v',\n description: 'Show version number',\n },\n },\n async setup({ rawArgs, args }) {\n if (args.version) {\n console.log(version)\n process.exit(0)\n }\n try {\n consola.log(gradientString(['#F58517', '#F5A217', '#F55A17'])('Kubb CLI:'))\n\n const latestVersion = await getLatestVersion('@kubb/cli')\n\n if (lt(version, latestVersion)) {\n consola.box({\n title: 'Update available for `Kubb` ',\n message: `\\`v${version}\\` → \\`v${latestVersion}\\`\nRun \\`npm install -g @kubb/cli\\` to update`,\n style: {\n padding: 2,\n borderColor: 'yellow',\n borderStyle: 'rounded',\n },\n })\n }\n } catch (_e) {}\n\n if (!['generate', 'validate', 'mcp'].includes(rawArgs[0] as string)) {\n console.log(rawArgs[0])\n // generate is not being used\n const generateCommand = await import('./commands/generate.ts').then((r) => r.default)\n\n await runCommand(generateCommand, { rawArgs })\n\n process.exit(0)\n }\n },\n subCommands: {\n generate: () => import('./commands/generate.ts').then((r) => r.default),\n validate: () => import('./commands/validate.ts').then((r) => r.default),\n mcp: () => import('./commands/mcp.ts').then((r) => r.default),\n },\n})\n\nexport async function run(_argv?: string[]): Promise<void> {\n await runMain(main)\n}\n"],"mappings":";;;;;;;;;;;;;cAEa;;;;ACOb,MAAM,gCAAqB;CACzB,MAAM;EACJ,MAJS;EAKT;EACA,aAAa;EACd;CACD,MAAM,EACJ,SAAS;EACP,MAAM;EACN,OAAO;EACP,aAAa;EACd,EACF;CACD,MAAM,MAAM,EAAE,SAAS,QAAQ;AAC7B,MAAI,KAAK,SAAS;AAChB,WAAQ,IAAI,QAAQ;AACpB,WAAQ,KAAK,EAAE;;AAEjB,MAAI;AACF,mBAAQ,iCAAmB;IAAC;IAAW;IAAW;IAAU,CAAC,CAAC,YAAY,CAAC;GAE3E,MAAM,gBAAgB,kCAAuB,YAAY;AAEzD,sBAAO,SAAS,cAAc,CAC5B,iBAAQ,IAAI;IACV,OAAO;IACP,SAAS,MAAM,QAAQ,UAAU,cAAc;;IAE/C,OAAO;KACL,SAAS;KACT,aAAa;KACb,aAAa;KACd;IACF,CAAC;WAEG,IAAI;AAEb,MAAI,CAAC;GAAC;GAAY;GAAY;GAAM,CAAC,SAAS,QAAQ,GAAa,EAAE;AACnE,WAAQ,IAAI,QAAQ,GAAG;GAEvB,MAAM,kBAAkB,2CAAM,4BAAiC,MAAM,MAAM,EAAE,QAAQ;AAErF,+BAAiB,iBAAiB,EAAE,SAAS,CAAC;AAE9C,WAAQ,KAAK,EAAE;;;CAGnB,aAAa;EACX,qDAAgB,4BAAiC,MAAM,MAAM,EAAE,QAAQ;EACvE,qDAAgB,4BAAiC,MAAM,MAAM,EAAE,QAAQ;EACvE,gDAAW,uBAA4B,MAAM,MAAM,EAAE,QAAQ;EAC9D;CACF,CAAC;AAEF,eAAsB,IAAI,OAAiC;AACzD,0BAAc,KAAK"}
|
package/dist/index.js
CHANGED
|
@@ -5,14 +5,13 @@ import getLatestVersion from "latest-version";
|
|
|
5
5
|
import { lt } from "semver";
|
|
6
6
|
|
|
7
7
|
//#region package.json
|
|
8
|
-
var version = "
|
|
8
|
+
var version = "4.0.2";
|
|
9
9
|
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/index.ts
|
|
12
|
-
const name = "kubb";
|
|
13
12
|
const main = defineCommand({
|
|
14
13
|
meta: {
|
|
15
|
-
name,
|
|
14
|
+
name: "kubb",
|
|
16
15
|
version,
|
|
17
16
|
description: "Kubb generation"
|
|
18
17
|
},
|
|
@@ -50,15 +49,15 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
50
49
|
"mcp"
|
|
51
50
|
].includes(rawArgs[0])) {
|
|
52
51
|
console.log(rawArgs[0]);
|
|
53
|
-
const generateCommand = await import("./generate-
|
|
52
|
+
const generateCommand = await import("./generate-BqNABk2X.js").then((r) => r.default);
|
|
54
53
|
await runCommand(generateCommand, { rawArgs });
|
|
55
54
|
process.exit(0);
|
|
56
55
|
}
|
|
57
56
|
},
|
|
58
57
|
subCommands: {
|
|
59
|
-
generate: () => import("./generate-
|
|
60
|
-
validate: () => import("./validate-
|
|
61
|
-
mcp: () => import("./mcp-
|
|
58
|
+
generate: () => import("./generate-BqNABk2X.js").then((r) => r.default),
|
|
59
|
+
validate: () => import("./validate-8i6chavn.js").then((r) => r.default),
|
|
60
|
+
mcp: () => import("./mcp-C4KjGtQv.js").then((r) => r.default)
|
|
62
61
|
}
|
|
63
62
|
});
|
|
64
63
|
async function run(_argv) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@kubb/cli\",\n \"version\": \"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@kubb/cli\",\n \"version\": \"4.0.2\",\n \"description\": \"Command-line interface for Kubb, enabling easy generation of TypeScript, React-Query, Zod, and other code from OpenAPI specifications.\",\n \"keywords\": [\n \"cli\",\n \"command-line\",\n \"typescript\",\n \"openapi\",\n \"swagger\",\n \"code-generator\",\n \"codegen\",\n \"plugins\",\n \"kubb\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/kubb-labs/kubb.git\",\n \"directory\": \"packages/cli\"\n },\n \"license\": \"MIT\",\n \"author\": \"stijnvanhulle\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.cts\",\n \"bin\": {\n \"kubb\": \"bin/kubb.cjs\"\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsdown\",\n \"clean\": \"npx rimraf ./dist\",\n \"lint\": \"bun biome lint .\",\n \"lint:fix\": \"bun biome lint --fix --unsafe .\",\n \"release\": \"pnpm publish --no-git-check\",\n \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check\",\n \"start\": \"tsdown --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"chokidar\": \"^4.0.3\",\n \"citty\": \"^0.1.6\",\n \"cli-progress\": \"^3.12.0\",\n \"consola\": \"^3.4.2\",\n \"cosmiconfig\": \"^9.0.0\",\n \"execa\": \"^9.6.0\",\n \"gradient-string\": \"^3.0.0\",\n \"jiti\": \"^2.6.0\",\n \"latest-version\": \"^9.0.0\",\n \"picocolors\": \"^1.1.1\",\n \"semver\": \"^7.7.2\",\n \"string-argv\": \"^0.3.2\"\n },\n \"devDependencies\": {\n \"@kubb/mcp\": \"workspace:*\",\n \"@kubb/oas\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"catalog:\",\n \"@types/semver\": \"^7.7.1\",\n \"source-map-support\": \"^0.5.21\",\n \"tsdown\": \"catalog:\",\n \"typescript\": \"catalog:\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"preferGlobal\": true,\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import { defineCommand, runCommand, runMain } from 'citty'\nimport consola from 'consola'\nimport { default as gradientString } from 'gradient-string'\nimport getLatestVersion from 'latest-version'\nimport { lt } from 'semver'\nimport { version } from '../package.json'\n\nconst name = 'kubb'\n\nconst main = defineCommand({\n meta: {\n name,\n version,\n description: 'Kubb generation',\n },\n args: {\n version: {\n type: 'boolean',\n alias: 'v',\n description: 'Show version number',\n },\n },\n async setup({ rawArgs, args }) {\n if (args.version) {\n console.log(version)\n process.exit(0)\n }\n try {\n consola.log(gradientString(['#F58517', '#F5A217', '#F55A17'])('Kubb CLI:'))\n\n const latestVersion = await getLatestVersion('@kubb/cli')\n\n if (lt(version, latestVersion)) {\n consola.box({\n title: 'Update available for `Kubb` ',\n message: `\\`v${version}\\` → \\`v${latestVersion}\\`\nRun \\`npm install -g @kubb/cli\\` to update`,\n style: {\n padding: 2,\n borderColor: 'yellow',\n borderStyle: 'rounded',\n },\n })\n }\n } catch (_e) {}\n\n if (!['generate', 'validate', 'mcp'].includes(rawArgs[0] as string)) {\n console.log(rawArgs[0])\n // generate is not being used\n const generateCommand = await import('./commands/generate.ts').then((r) => r.default)\n\n await runCommand(generateCommand, { rawArgs })\n\n process.exit(0)\n }\n },\n subCommands: {\n generate: () => import('./commands/generate.ts').then((r) => r.default),\n validate: () => import('./commands/validate.ts').then((r) => r.default),\n mcp: () => import('./commands/mcp.ts').then((r) => r.default),\n },\n})\n\nexport async function run(_argv?: string[]): Promise<void> {\n await runMain(main)\n}\n"],"mappings":";;;;;;;cAEa;;;;ACOb,MAAM,OAAO,cAAc;CACzB,MAAM;EACJ,MAJS;EAKT;EACA,aAAa;EACd;CACD,MAAM,EACJ,SAAS;EACP,MAAM;EACN,OAAO;EACP,aAAa;EACd,EACF;CACD,MAAM,MAAM,EAAE,SAAS,QAAQ;AAC7B,MAAI,KAAK,SAAS;AAChB,WAAQ,IAAI,QAAQ;AACpB,WAAQ,KAAK,EAAE;;AAEjB,MAAI;AACF,WAAQ,IAAI,eAAe;IAAC;IAAW;IAAW;IAAU,CAAC,CAAC,YAAY,CAAC;GAE3E,MAAM,gBAAgB,MAAM,iBAAiB,YAAY;AAEzD,OAAI,GAAG,SAAS,cAAc,CAC5B,SAAQ,IAAI;IACV,OAAO;IACP,SAAS,MAAM,QAAQ,UAAU,cAAc;;IAE/C,OAAO;KACL,SAAS;KACT,aAAa;KACb,aAAa;KACd;IACF,CAAC;WAEG,IAAI;AAEb,MAAI,CAAC;GAAC;GAAY;GAAY;GAAM,CAAC,SAAS,QAAQ,GAAa,EAAE;AACnE,WAAQ,IAAI,QAAQ,GAAG;GAEvB,MAAM,kBAAkB,MAAM,OAAO,0BAA0B,MAAM,MAAM,EAAE,QAAQ;AAErF,SAAM,WAAW,iBAAiB,EAAE,SAAS,CAAC;AAE9C,WAAQ,KAAK,EAAE;;;CAGnB,aAAa;EACX,gBAAgB,OAAO,0BAA0B,MAAM,MAAM,EAAE,QAAQ;EACvE,gBAAgB,OAAO,0BAA0B,MAAM,MAAM,EAAE,QAAQ;EACvE,WAAW,OAAO,qBAAqB,MAAM,MAAM,EAAE,QAAQ;EAC9D;CACF,CAAC;AAEF,eAAsB,IAAI,OAAiC;AACzD,OAAM,QAAQ,KAAK"}
|
|
@@ -5,21 +5,20 @@ import { createJiti } from "jiti";
|
|
|
5
5
|
|
|
6
6
|
//#region src/commands/mcp.ts
|
|
7
7
|
const jiti = createJiti(import.meta.url, { sourceMaps: true });
|
|
8
|
-
const args = { help: {
|
|
9
|
-
type: "boolean",
|
|
10
|
-
description: "Show help",
|
|
11
|
-
alias: "h",
|
|
12
|
-
default: false
|
|
13
|
-
} };
|
|
14
8
|
const command = defineCommand({
|
|
15
9
|
meta: {
|
|
16
10
|
name: "mcp",
|
|
17
11
|
description: "Start the server to enable the MCP client to interact with the LLM."
|
|
18
12
|
},
|
|
19
|
-
args
|
|
13
|
+
args: { help: {
|
|
14
|
+
type: "boolean",
|
|
15
|
+
description: "Show help",
|
|
16
|
+
alias: "h",
|
|
17
|
+
default: false
|
|
18
|
+
} },
|
|
20
19
|
async run(commandContext) {
|
|
21
|
-
const { args
|
|
22
|
-
if (args
|
|
20
|
+
const { args } = commandContext;
|
|
21
|
+
if (args.help) return showUsage(command);
|
|
23
22
|
let mod;
|
|
24
23
|
try {
|
|
25
24
|
mod = await jiti.import("@kubb/mcp", { default: true });
|
|
@@ -40,4 +39,4 @@ var mcp_default = command;
|
|
|
40
39
|
|
|
41
40
|
//#endregion
|
|
42
41
|
export { mcp_default as default };
|
|
43
|
-
//# sourceMappingURL=mcp-
|
|
42
|
+
//# sourceMappingURL=mcp-C4KjGtQv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-C4KjGtQv.js","names":["mod: any"],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import type { ArgsDef, ParsedArgs } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport consola from 'consola'\nimport pc from 'picocolors'\nimport { createJiti } from 'jiti'\n\nconst jiti = createJiti(import.meta.url, {\n sourceMaps: true,\n})\n\nconst args = {\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nexport type Args = ParsedArgs<typeof args>\n\nconst command = defineCommand({\n meta: {\n name: 'mcp',\n description: 'Start the server to enable the MCP client to interact with the LLM.',\n },\n args,\n async run(commandContext) {\n const { args } = commandContext\n\n if (args.help) {\n return showUsage(command)\n }\n\n let mod: any\n try {\n mod = await jiti.import('@kubb/mcp', { default: true })\n } catch (_e) {\n consola.error(`Import of '@kubb/mcp' is required to start the MCP server`)\n }\n\n const { startServer } = mod\n try {\n consola.start('Starting MCP server...')\n consola.warn(pc.yellow('This feature is still under development — use with caution'))\n await startServer()\n } catch (e) {\n consola.error((e as Error)?.message)\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;AAMA,MAAM,OAAO,WAAW,OAAO,KAAK,KAAK,EACvC,YAAY,MACb,CAAC;AAaF,MAAM,UAAU,cAAc;CAC5B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAhBW,EACX,MAAM;EACJ,MAAM;EACN,aAAa;EACb,OAAO;EACP,SAAS;EACV,EACF;CAUC,MAAM,IAAI,gBAAgB;EACxB,MAAM,EAAE,SAAS;AAEjB,MAAI,KAAK,KACP,QAAO,UAAU,QAAQ;EAG3B,IAAIA;AACJ,MAAI;AACF,SAAM,MAAM,KAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;WAChD,IAAI;AACX,WAAQ,MAAM,4DAA4D;;EAG5E,MAAM,EAAE,gBAAgB;AACxB,MAAI;AACF,WAAQ,MAAM,yBAAyB;AACvC,WAAQ,KAAK,GAAG,OAAO,6DAA6D,CAAC;AACrF,SAAM,aAAa;WACZ,GAAG;AACV,WAAQ,MAAO,GAAa,QAAQ;;;CAGzC,CAAC;AAEF,kBAAe"}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
let citty = require("citty");
|
|
3
|
+
citty = require_chunk.__toESM(citty);
|
|
4
|
+
let consola = require("consola");
|
|
5
|
+
consola = require_chunk.__toESM(consola);
|
|
6
|
+
let picocolors = require("picocolors");
|
|
7
|
+
picocolors = require_chunk.__toESM(picocolors);
|
|
8
|
+
let jiti = require("jiti");
|
|
9
|
+
jiti = require_chunk.__toESM(jiti);
|
|
6
10
|
|
|
7
11
|
//#region src/commands/mcp.ts
|
|
8
12
|
const jiti$1 = (0, jiti.createJiti)(require("url").pathToFileURL(__filename).href, { sourceMaps: true });
|
|
9
|
-
const args = { help: {
|
|
10
|
-
type: "boolean",
|
|
11
|
-
description: "Show help",
|
|
12
|
-
alias: "h",
|
|
13
|
-
default: false
|
|
14
|
-
} };
|
|
15
13
|
const command = (0, citty.defineCommand)({
|
|
16
14
|
meta: {
|
|
17
15
|
name: "mcp",
|
|
18
16
|
description: "Start the server to enable the MCP client to interact with the LLM."
|
|
19
17
|
},
|
|
20
|
-
args
|
|
18
|
+
args: { help: {
|
|
19
|
+
type: "boolean",
|
|
20
|
+
description: "Show help",
|
|
21
|
+
alias: "h",
|
|
22
|
+
default: false
|
|
23
|
+
} },
|
|
21
24
|
async run(commandContext) {
|
|
22
|
-
const { args
|
|
23
|
-
if (args
|
|
25
|
+
const { args } = commandContext;
|
|
26
|
+
if (args.help) return (0, citty.showUsage)(command);
|
|
24
27
|
let mod;
|
|
25
28
|
try {
|
|
26
29
|
mod = await jiti$1.import("@kubb/mcp", { default: true });
|
|
@@ -41,4 +44,4 @@ var mcp_default = command;
|
|
|
41
44
|
|
|
42
45
|
//#endregion
|
|
43
46
|
exports.default = mcp_default;
|
|
44
|
-
//# sourceMappingURL=mcp-
|
|
47
|
+
//# sourceMappingURL=mcp-CLmIdoaC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-CLmIdoaC.cjs","names":["jiti","mod: any","pc"],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import type { ArgsDef, ParsedArgs } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport consola from 'consola'\nimport pc from 'picocolors'\nimport { createJiti } from 'jiti'\n\nconst jiti = createJiti(import.meta.url, {\n sourceMaps: true,\n})\n\nconst args = {\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nexport type Args = ParsedArgs<typeof args>\n\nconst command = defineCommand({\n meta: {\n name: 'mcp',\n description: 'Start the server to enable the MCP client to interact with the LLM.',\n },\n args,\n async run(commandContext) {\n const { args } = commandContext\n\n if (args.help) {\n return showUsage(command)\n }\n\n let mod: any\n try {\n mod = await jiti.import('@kubb/mcp', { default: true })\n } catch (_e) {\n consola.error(`Import of '@kubb/mcp' is required to start the MCP server`)\n }\n\n const { startServer } = mod\n try {\n consola.start('Starting MCP server...')\n consola.warn(pc.yellow('This feature is still under development — use with caution'))\n await startServer()\n } catch (e) {\n consola.error((e as Error)?.message)\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;;;;;;AAMA,MAAMA,6EAAmC,EACvC,YAAY,MACb,CAAC;AAaF,MAAM,mCAAwB;CAC5B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAhBW,EACX,MAAM;EACJ,MAAM;EACN,aAAa;EACb,OAAO;EACP,SAAS;EACV,EACF;CAUC,MAAM,IAAI,gBAAgB;EACxB,MAAM,EAAE,SAAS;AAEjB,MAAI,KAAK,KACP,6BAAiB,QAAQ;EAG3B,IAAIC;AACJ,MAAI;AACF,SAAM,MAAMD,OAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;WAChD,IAAI;AACX,mBAAQ,MAAM,4DAA4D;;EAG5E,MAAM,EAAE,gBAAgB;AACxB,MAAI;AACF,mBAAQ,MAAM,yBAAyB;AACvC,mBAAQ,KAAKE,mBAAG,OAAO,6DAA6D,CAAC;AACrF,SAAM,aAAa;WACZ,GAAG;AACV,mBAAQ,MAAO,GAAa,QAAQ;;;CAGzC,CAAC;AAEF,kBAAe"}
|
|
@@ -5,29 +5,28 @@ import { createJiti } from "jiti";
|
|
|
5
5
|
|
|
6
6
|
//#region src/commands/validate.ts
|
|
7
7
|
const jiti = createJiti(import.meta.url, { sourceMaps: true });
|
|
8
|
-
const args = {
|
|
9
|
-
input: {
|
|
10
|
-
type: "string",
|
|
11
|
-
description: "Path to Swagger/OpenAPI file",
|
|
12
|
-
alias: "i"
|
|
13
|
-
},
|
|
14
|
-
help: {
|
|
15
|
-
type: "boolean",
|
|
16
|
-
description: "Show help",
|
|
17
|
-
alias: "h",
|
|
18
|
-
default: false
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
8
|
const command = defineCommand({
|
|
22
9
|
meta: {
|
|
23
10
|
name: "validate",
|
|
24
11
|
description: "Validate a Swagger/OpenAPI file"
|
|
25
12
|
},
|
|
26
|
-
args
|
|
13
|
+
args: {
|
|
14
|
+
input: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "Path to Swagger/OpenAPI file",
|
|
17
|
+
alias: "i"
|
|
18
|
+
},
|
|
19
|
+
help: {
|
|
20
|
+
type: "boolean",
|
|
21
|
+
description: "Show help",
|
|
22
|
+
alias: "h",
|
|
23
|
+
default: false
|
|
24
|
+
}
|
|
25
|
+
},
|
|
27
26
|
async run(commandContext) {
|
|
28
|
-
const { args
|
|
29
|
-
if (args
|
|
30
|
-
if (args
|
|
27
|
+
const { args } = commandContext;
|
|
28
|
+
if (args.help) return showUsage(command);
|
|
29
|
+
if (args.input) {
|
|
31
30
|
let mod;
|
|
32
31
|
try {
|
|
33
32
|
mod = await jiti.import("@kubb/oas", { default: true });
|
|
@@ -36,8 +35,7 @@ const command = defineCommand({
|
|
|
36
35
|
}
|
|
37
36
|
const { parse } = mod;
|
|
38
37
|
try {
|
|
39
|
-
|
|
40
|
-
await oas.valdiate();
|
|
38
|
+
await (await parse(args.input)).valdiate();
|
|
41
39
|
consola.success("Validation success");
|
|
42
40
|
} catch (e) {
|
|
43
41
|
consola.fail("Validation failed");
|
|
@@ -51,4 +49,4 @@ var validate_default = command;
|
|
|
51
49
|
|
|
52
50
|
//#endregion
|
|
53
51
|
export { validate_default as default };
|
|
54
|
-
//# sourceMappingURL=validate-
|
|
52
|
+
//# sourceMappingURL=validate-8i6chavn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-8i6chavn.js","names":["mod: any"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport type { ArgsDef, ParsedArgs } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport consola from 'consola'\nimport { createJiti } from 'jiti'\n\nconst jiti = createJiti(import.meta.url, {\n sourceMaps: true,\n})\n\nconst args = {\n input: {\n type: 'string',\n description: 'Path to Swagger/OpenAPI file',\n alias: 'i',\n },\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nexport type Args = ParsedArgs<typeof args>\n\nconst command = defineCommand({\n meta: {\n name: 'validate',\n description: 'Validate a Swagger/OpenAPI file',\n },\n args,\n async run(commandContext) {\n const { args } = commandContext\n\n if (args.help) {\n return showUsage(command)\n }\n\n if (args.input) {\n let mod: any\n try {\n mod = await jiti.import('@kubb/oas', { default: true })\n } catch (_e) {\n consola.error(`Import of '@kubb/oas' is required to do validation`)\n }\n\n const { parse } = mod\n try {\n const oas = await parse(args.input)\n await oas.valdiate()\n\n consola.success('Validation success')\n } catch (e) {\n consola.fail('Validation failed')\n consola.log((e as Error)?.message)\n process.exit(1)\n }\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;AAMA,MAAM,OAAO,WAAW,OAAO,KAAK,KAAK,EACvC,YAAY,MACb,CAAC;AAkBF,MAAM,UAAU,cAAc;CAC5B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MArBW;EACX,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACR;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACF;CAUC,MAAM,IAAI,gBAAgB;EACxB,MAAM,EAAE,SAAS;AAEjB,MAAI,KAAK,KACP,QAAO,UAAU,QAAQ;AAG3B,MAAI,KAAK,OAAO;GACd,IAAIA;AACJ,OAAI;AACF,UAAM,MAAM,KAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;YAChD,IAAI;AACX,YAAQ,MAAM,qDAAqD;;GAGrE,MAAM,EAAE,UAAU;AAClB,OAAI;AAEF,WADY,MAAM,MAAM,KAAK,MAAM,EACzB,UAAU;AAEpB,YAAQ,QAAQ,qBAAqB;YAC9B,GAAG;AACV,YAAQ,KAAK,oBAAoB;AACjC,YAAQ,IAAK,GAAa,QAAQ;AAClC,YAAQ,KAAK,EAAE;;;;CAItB,CAAC;AAEF,uBAAe"}
|
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
let citty = require("citty");
|
|
3
|
+
citty = require_chunk.__toESM(citty);
|
|
4
|
+
let consola = require("consola");
|
|
5
|
+
consola = require_chunk.__toESM(consola);
|
|
6
|
+
let node_process = require("node:process");
|
|
7
|
+
node_process = require_chunk.__toESM(node_process);
|
|
8
|
+
let jiti = require("jiti");
|
|
9
|
+
jiti = require_chunk.__toESM(jiti);
|
|
6
10
|
|
|
7
11
|
//#region src/commands/validate.ts
|
|
8
12
|
const jiti$1 = (0, jiti.createJiti)(require("url").pathToFileURL(__filename).href, { sourceMaps: true });
|
|
9
|
-
const args = {
|
|
10
|
-
input: {
|
|
11
|
-
type: "string",
|
|
12
|
-
description: "Path to Swagger/OpenAPI file",
|
|
13
|
-
alias: "i"
|
|
14
|
-
},
|
|
15
|
-
help: {
|
|
16
|
-
type: "boolean",
|
|
17
|
-
description: "Show help",
|
|
18
|
-
alias: "h",
|
|
19
|
-
default: false
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
13
|
const command = (0, citty.defineCommand)({
|
|
23
14
|
meta: {
|
|
24
15
|
name: "validate",
|
|
25
16
|
description: "Validate a Swagger/OpenAPI file"
|
|
26
17
|
},
|
|
27
|
-
args
|
|
18
|
+
args: {
|
|
19
|
+
input: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "Path to Swagger/OpenAPI file",
|
|
22
|
+
alias: "i"
|
|
23
|
+
},
|
|
24
|
+
help: {
|
|
25
|
+
type: "boolean",
|
|
26
|
+
description: "Show help",
|
|
27
|
+
alias: "h",
|
|
28
|
+
default: false
|
|
29
|
+
}
|
|
30
|
+
},
|
|
28
31
|
async run(commandContext) {
|
|
29
|
-
const { args
|
|
30
|
-
if (args
|
|
31
|
-
if (args
|
|
32
|
+
const { args } = commandContext;
|
|
33
|
+
if (args.help) return (0, citty.showUsage)(command);
|
|
34
|
+
if (args.input) {
|
|
32
35
|
let mod;
|
|
33
36
|
try {
|
|
34
37
|
mod = await jiti$1.import("@kubb/oas", { default: true });
|
|
@@ -37,8 +40,7 @@ const command = (0, citty.defineCommand)({
|
|
|
37
40
|
}
|
|
38
41
|
const { parse } = mod;
|
|
39
42
|
try {
|
|
40
|
-
|
|
41
|
-
await oas.valdiate();
|
|
43
|
+
await (await parse(args.input)).valdiate();
|
|
42
44
|
consola.default.success("Validation success");
|
|
43
45
|
} catch (e) {
|
|
44
46
|
consola.default.fail("Validation failed");
|
|
@@ -52,4 +54,4 @@ var validate_default = command;
|
|
|
52
54
|
|
|
53
55
|
//#endregion
|
|
54
56
|
exports.default = validate_default;
|
|
55
|
-
//# sourceMappingURL=validate-
|
|
57
|
+
//# sourceMappingURL=validate-DNbDDWp4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-DNbDDWp4.cjs","names":["jiti","mod: any"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport type { ArgsDef, ParsedArgs } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport consola from 'consola'\nimport { createJiti } from 'jiti'\n\nconst jiti = createJiti(import.meta.url, {\n sourceMaps: true,\n})\n\nconst args = {\n input: {\n type: 'string',\n description: 'Path to Swagger/OpenAPI file',\n alias: 'i',\n },\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nexport type Args = ParsedArgs<typeof args>\n\nconst command = defineCommand({\n meta: {\n name: 'validate',\n description: 'Validate a Swagger/OpenAPI file',\n },\n args,\n async run(commandContext) {\n const { args } = commandContext\n\n if (args.help) {\n return showUsage(command)\n }\n\n if (args.input) {\n let mod: any\n try {\n mod = await jiti.import('@kubb/oas', { default: true })\n } catch (_e) {\n consola.error(`Import of '@kubb/oas' is required to do validation`)\n }\n\n const { parse } = mod\n try {\n const oas = await parse(args.input)\n await oas.valdiate()\n\n consola.success('Validation success')\n } catch (e) {\n consola.fail('Validation failed')\n consola.log((e as Error)?.message)\n process.exit(1)\n }\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;;;;;;AAMA,MAAMA,6EAAmC,EACvC,YAAY,MACb,CAAC;AAkBF,MAAM,mCAAwB;CAC5B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MArBW;EACX,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACR;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACF;CAUC,MAAM,IAAI,gBAAgB;EACxB,MAAM,EAAE,SAAS;AAEjB,MAAI,KAAK,KACP,6BAAiB,QAAQ;AAG3B,MAAI,KAAK,OAAO;GACd,IAAIC;AACJ,OAAI;AACF,UAAM,MAAMD,OAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;YAChD,IAAI;AACX,oBAAQ,MAAM,qDAAqD;;GAGrE,MAAM,EAAE,UAAU;AAClB,OAAI;AAEF,WADY,MAAM,MAAM,KAAK,MAAM,EACzB,UAAU;AAEpB,oBAAQ,QAAQ,qBAAqB;YAC9B,GAAG;AACV,oBAAQ,KAAK,oBAAoB;AACjC,oBAAQ,IAAK,GAAa,QAAQ;AAClC,yBAAQ,KAAK,EAAE;;;;CAItB,CAAC;AAEF,uBAAe"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Command-line interface for Kubb, enabling easy generation of TypeScript, React-Query, Zod, and other code from OpenAPI specifications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -50,26 +50,23 @@
|
|
|
50
50
|
"cosmiconfig": "^9.0.0",
|
|
51
51
|
"execa": "^9.6.0",
|
|
52
52
|
"gradient-string": "^3.0.0",
|
|
53
|
-
"jiti": "^2.
|
|
53
|
+
"jiti": "^2.6.0",
|
|
54
54
|
"latest-version": "^9.0.0",
|
|
55
|
-
"open": "^10.2.0",
|
|
56
55
|
"picocolors": "^1.1.1",
|
|
57
56
|
"semver": "^7.7.2",
|
|
58
57
|
"string-argv": "^0.3.2",
|
|
59
|
-
"@kubb/core": "
|
|
60
|
-
"@kubb/ui": "3.18.3"
|
|
58
|
+
"@kubb/core": "4.0.2"
|
|
61
59
|
},
|
|
62
60
|
"devDependencies": {
|
|
63
61
|
"@types/cli-progress": "^3.11.6",
|
|
64
|
-
"@types/node": "^20.19.
|
|
65
|
-
"@types/semver": "^7.7.
|
|
62
|
+
"@types/node": "^20.19.17",
|
|
63
|
+
"@types/semver": "^7.7.1",
|
|
66
64
|
"source-map-support": "^0.5.21",
|
|
67
65
|
"tsdown": "^0.14.2",
|
|
68
66
|
"typescript": "^5.9.2",
|
|
69
|
-
"@kubb/
|
|
70
|
-
"@kubb/
|
|
71
|
-
"@kubb/oas": "
|
|
72
|
-
"@kubb/plugin-oas": "3.18.3"
|
|
67
|
+
"@kubb/mcp": "4.0.2",
|
|
68
|
+
"@kubb/oas": "4.0.2",
|
|
69
|
+
"@kubb/plugin-oas": "4.0.2"
|
|
73
70
|
},
|
|
74
71
|
"engines": {
|
|
75
72
|
"node": ">=20"
|
package/src/commands/generate.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { createLogger, LogMapper } from '@kubb/core/logger'
|
|
|
5
5
|
import type { ArgsDef, ParsedArgs } from 'citty'
|
|
6
6
|
import { defineCommand, showUsage } from 'citty'
|
|
7
7
|
import type { SingleBar } from 'cli-progress'
|
|
8
|
-
import open from 'open'
|
|
9
8
|
import pc from 'picocolors'
|
|
10
9
|
import { getConfig } from '../utils/getConfig.ts'
|
|
11
10
|
import { getCosmiConfig } from '../utils/getCosmiConfig.ts'
|
|
@@ -40,12 +39,6 @@ const args = {
|
|
|
40
39
|
alias: 'd',
|
|
41
40
|
default: false,
|
|
42
41
|
},
|
|
43
|
-
ui: {
|
|
44
|
-
type: 'boolean',
|
|
45
|
-
description: 'Open ui',
|
|
46
|
-
alias: 'u',
|
|
47
|
-
default: false,
|
|
48
|
-
},
|
|
49
42
|
help: {
|
|
50
43
|
type: 'boolean',
|
|
51
44
|
description: 'Show help',
|
|
@@ -63,7 +56,6 @@ const command = defineCommand({
|
|
|
63
56
|
},
|
|
64
57
|
args,
|
|
65
58
|
async run(commandContext) {
|
|
66
|
-
let name = ''
|
|
67
59
|
const progressCache = new Map<string, SingleBar>()
|
|
68
60
|
|
|
69
61
|
const { args } = commandContext
|
|
@@ -95,7 +87,6 @@ const command = defineCommand({
|
|
|
95
87
|
if (Array.isArray(config)) {
|
|
96
88
|
const promiseManager = new PromiseManager()
|
|
97
89
|
const promises = config.map((c) => () => {
|
|
98
|
-
name = c.name || ''
|
|
99
90
|
progressCache.clear()
|
|
100
91
|
|
|
101
92
|
return generate({
|
|
@@ -122,40 +113,6 @@ const command = defineCommand({
|
|
|
122
113
|
return
|
|
123
114
|
}
|
|
124
115
|
|
|
125
|
-
if (args.ui) {
|
|
126
|
-
const { startServer } = await import('@kubb/ui')
|
|
127
|
-
|
|
128
|
-
await startServer(
|
|
129
|
-
{
|
|
130
|
-
stop: () => process.exit(1),
|
|
131
|
-
restart: () => start(),
|
|
132
|
-
getMeta: () => {
|
|
133
|
-
const entries = [...progressCache.entries()]
|
|
134
|
-
|
|
135
|
-
const percentages = entries.reduce(
|
|
136
|
-
(acc, [key, singleBar]) => {
|
|
137
|
-
acc[key] = singleBar.getProgress()
|
|
138
|
-
|
|
139
|
-
return acc
|
|
140
|
-
},
|
|
141
|
-
{} as Record<string, number>,
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
name,
|
|
146
|
-
percentages,
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
(info) => {
|
|
151
|
-
const url = `${info.address}:${info.port}`.replace('::', 'http://localhost')
|
|
152
|
-
logger.consola?.start(`Starting ui on ${url}`)
|
|
153
|
-
|
|
154
|
-
open(url)
|
|
155
|
-
},
|
|
156
|
-
)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
116
|
if (args.watch) {
|
|
160
117
|
if (Array.isArray(config)) {
|
|
161
118
|
throw new Error('Cannot use watcher with multiple Configs(array)')
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-Bu9WyH1N.cjs","names":["args","results: Array<Config>","jiti","path","pc","args","LogMapper","pc","path","process","PromiseManager"],"sources":["../src/utils/getPlugins.ts","../src/utils/getConfig.ts","../src/utils/getCosmiConfig.ts","../src/utils/watcher.ts","../src/commands/generate.ts"],"sourcesContent":["import type { UserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: UserConfig['plugins']) {\n return !!(plugins as any)?.some((plugin: any) => {\n return Array.isArray(plugin) && typeof plugin?.at(0) === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: UserConfig['plugins']): plugins is any {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nexport function getPlugins(plugins: UserConfig['plugins']): Promise<UserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n throw new Error('Object plugins are not supported anymore, best to use http://kubb.dev/getting-started/configure#json')\n }\n\n if (isJSONPlugins(plugins)) {\n throw new Error('JSON plugins are not supported anymore, best to use http://kubb.dev/getting-started/configure#json')\n }\n\n return Promise.resolve(plugins)\n}\n","import { isPromise } from '@kubb/core/utils'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { Config, UserConfig } from '@kubb/core'\nimport type { Args } from '../commands/generate.ts'\nimport type { CosmiconfigResult } from './getCosmiConfig.ts'\n\n/**\n * Converting UserConfig to Config without a change in the object beside the JSON convert.\n */\nexport async function getConfig(result: CosmiconfigResult, args: Args): Promise<Array<Config> | Config> {\n const config = result?.config\n let kubbUserConfig = Promise.resolve(config) as Promise<UserConfig | Array<UserConfig>>\n\n // for ts or js files\n if (typeof config === 'function') {\n const possiblePromise = config(args)\n if (isPromise(possiblePromise)) {\n kubbUserConfig = possiblePromise\n }\n kubbUserConfig = Promise.resolve(possiblePromise)\n }\n\n let JSONConfig = await kubbUserConfig\n\n if (Array.isArray(JSONConfig)) {\n const results: Array<Config> = []\n\n for (const item of JSONConfig) {\n const plugins = item.plugins ? await getPlugins(item.plugins) : undefined\n\n results.push({\n ...item,\n plugins,\n } as Config)\n }\n\n return results\n }\n\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as Config\n}\n","import type { defineConfig, UserConfig } from '@kubb/core'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { createJiti } from 'jiti'\n\nexport type CosmiconfigResult = {\n filepath: string\n isEmpty?: boolean\n config: ReturnType<typeof defineConfig> | UserConfig\n}\n\nconst tsLoader = async (configFile: string) => {\n const jiti = createJiti(import.meta.url, {\n jsx: {\n runtime: 'automatic',\n importSource: '@kubb/react',\n },\n sourceMaps: true,\n })\n\n const mod = await jiti.import(configFile, { default: true })\n\n return mod\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string): Promise<CosmiconfigResult> {\n const searchPlaces = [\n 'package.json',\n `.${moduleName}rc`,\n `.${moduleName}rc.json`,\n `.${moduleName}rc.yaml`,\n `.${moduleName}rc.yml`,\n\n `.${moduleName}rc.ts`,\n `.${moduleName}rc.js`,\n `.${moduleName}rc.mjs`,\n `.${moduleName}rc.cjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ]\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n searchPlaces: [\n ...searchPlaces.map((searchPlace) => {\n return `.config/${searchPlace}`\n }),\n ...searchPlaces.map((searchPlace) => {\n return `configs/${searchPlace}`\n }),\n ...searchPlaces,\n ],\n loaders: {\n '.ts': tsLoader,\n },\n })\n\n const result = config ? await explorer.load(config) : await explorer.search()\n\n if (result?.isEmpty || !result || !result.config) {\n throw new Error('Config not defined, create a kubb.config.js or pass through your config with the option --config')\n }\n\n return result as CosmiconfigResult\n}\n","import { createLogger } from '@kubb/core/logger'\nimport pc from 'picocolors'\n\nexport async function startWatcher(path: string[], cb: (path: string[]) => Promise<void>): Promise<void> {\n const { watch } = await import('chokidar')\n const logger = createLogger()\n\n const ignored = '**/{.git,node_modules}/**'\n\n const watcher = watch(path, {\n ignorePermissionErrors: true,\n ignored,\n })\n watcher.on('all', (type, file) => {\n logger?.emit('info', pc.yellow(pc.bold(`Change detected: ${type} ${file}`)))\n\n try {\n cb(path)\n } catch (_e) {\n logger?.emit('warning', pc.red('Watcher failed'))\n }\n })\n}\n","import path from 'node:path'\nimport * as process from 'node:process'\nimport { isInputPath, PromiseManager } from '@kubb/core'\nimport { createLogger, LogMapper } from '@kubb/core/logger'\nimport type { ArgsDef, ParsedArgs } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport type { SingleBar } from 'cli-progress'\nimport open from 'open'\nimport pc from 'picocolors'\nimport { getConfig } from '../utils/getConfig.ts'\nimport { getCosmiConfig } from '../utils/getCosmiConfig.ts'\nimport { startWatcher } from '../utils/watcher.ts'\n\ndeclare global {\n var isDevtoolsEnabled: any\n}\n\nconst args = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n alias: 'c',\n },\n logLevel: {\n type: 'string',\n description: 'Info, silent or debug',\n alias: 'l',\n default: 'info',\n valueHint: 'silent|info|debug',\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n alias: 'w',\n default: false,\n },\n debug: {\n type: 'boolean',\n description: 'Override logLevel to debug',\n alias: 'd',\n default: false,\n },\n ui: {\n type: 'boolean',\n description: 'Open ui',\n alias: 'u',\n default: false,\n },\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nexport type Args = ParsedArgs<typeof args>\n\nconst command = defineCommand({\n meta: {\n name: 'generate',\n description: \"[input] Generate files based on a 'kubb.config.ts' file\",\n },\n args,\n async run(commandContext) {\n let name = ''\n const progressCache = new Map<string, SingleBar>()\n\n const { args } = commandContext\n\n const input = args._[0]\n\n if (args.help) {\n return showUsage(command)\n }\n\n if (args.debug) {\n args.logLevel = 'debug'\n }\n\n const logLevel = LogMapper[args.logLevel as keyof typeof LogMapper] || 3\n const logger = createLogger({\n logLevel,\n })\n const { generate } = await import('../runners/generate.ts')\n\n logger.emit('start', 'Loading config')\n\n const result = await getCosmiConfig('kubb', args.config)\n logger.emit('success', `Config loaded(${pc.dim(path.relative(process.cwd(), result.filepath))})`)\n\n const config = await getConfig(result, args)\n\n const start = async () => {\n if (Array.isArray(config)) {\n const promiseManager = new PromiseManager()\n const promises = config.map((c) => () => {\n name = c.name || ''\n progressCache.clear()\n\n return generate({\n input,\n config: c,\n args,\n progressCache,\n })\n })\n\n await promiseManager.run('seq', promises)\n return\n }\n\n progressCache.clear()\n\n await generate({\n input,\n config,\n progressCache,\n args,\n })\n\n return\n }\n\n if (args.ui) {\n const { startServer } = await import('@kubb/ui')\n\n await startServer(\n {\n stop: () => process.exit(1),\n restart: () => start(),\n getMeta: () => {\n const entries = [...progressCache.entries()]\n\n const percentages = entries.reduce(\n (acc, [key, singleBar]) => {\n acc[key] = singleBar.getProgress()\n\n return acc\n },\n {} as Record<string, number>,\n )\n\n return {\n name,\n percentages,\n }\n },\n },\n (info) => {\n const url = `${info.address}:${info.port}`.replace('::', 'http://localhost')\n logger.consola?.start(`Starting ui on ${url}`)\n\n open(url)\n },\n )\n }\n\n if (args.watch) {\n if (Array.isArray(config)) {\n throw new Error('Cannot use watcher with multiple Configs(array)')\n }\n\n if (isInputPath(config)) {\n return startWatcher([input || config.input.path], async (paths) => {\n await start()\n logger.emit('start', pc.yellow(pc.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n }\n\n await start()\n\n if (globalThis.isDevtoolsEnabled) {\n const canRestart = await logger.consola?.prompt('Restart(could be used to validate the profiler)?', {\n type: 'confirm',\n initial: false,\n })\n\n if (canRestart) {\n await start()\n } else {\n process.exit(1)\n }\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;;;;;;;;AAEA,SAAS,cAAc,SAAgC;AACrD,QAAO,CAAC,CAAE,SAAiB,MAAM,WAAgB;AAC/C,SAAO,MAAM,QAAQ,WAAW,OAAO,QAAQ,GAAG,OAAO;;;AAI7D,SAAS,gBAAgB,SAAgD;AACvE,QAAO,mBAAmB,UAAU,CAAC,MAAM,QAAQ;;AAGrD,SAAgB,WAAW,SAAgE;AACzF,KAAI,gBAAgB,SAClB,OAAM,IAAI,MAAM;AAGlB,KAAI,cAAc,SAChB,OAAM,IAAI,MAAM;AAGlB,QAAO,QAAQ,QAAQ;;;;;;;;ACVzB,eAAsB,UAAU,QAA2B,QAA6C;CACtG,MAAM,SAAS,QAA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