@kubb/cli 5.0.0-beta.49 → 5.0.0-beta.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/LICENSE +17 -10
- package/README.md +1 -40
- package/dist/{chunk-CRm0XQPb.js → chunk-C0LytTxp.js} +0 -1
- package/dist/constants-BQ8LZB1P.js +23 -0
- package/dist/constants-BQ8LZB1P.js.map +1 -0
- package/dist/{constants-BtmponZ3.cjs → constants-MzEjK668.cjs} +1 -19
- package/dist/constants-MzEjK668.cjs.map +1 -0
- package/dist/{define-DNG1U8ha.js → define-C63T4jp6.js} +2 -2
- package/dist/{define-DNG1U8ha.js.map → define-C63T4jp6.js.map} +1 -1
- package/dist/{errors-CoxrNXaA.js → errors-BsemQCMn.js} +2 -2
- package/dist/{errors-CoxrNXaA.js.map → errors-BsemQCMn.js.map} +1 -1
- package/dist/{generate-Ua2_bX6F.js → generate-CKnn3tQa.js} +4 -4
- package/dist/{generate-Ua2_bX6F.js.map → generate-CKnn3tQa.js.map} +1 -1
- package/dist/{generate-CNqETcDC.cjs → generate-Q6GMu4L8.cjs} +2 -2
- package/dist/{generate-CNqETcDC.cjs.map → generate-Q6GMu4L8.cjs.map} +1 -1
- package/dist/index.cjs +6 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -10
- package/dist/index.js.map +1 -1
- package/dist/{init-Ga1vvbKs.cjs → init-C5iCqBwA.cjs} +3 -3
- package/dist/{init-Ga1vvbKs.cjs.map → init-C5iCqBwA.cjs.map} +1 -1
- package/dist/{init-o5XBcC-j.js → init-DyOF6CiQ.js} +5 -5
- package/dist/{init-o5XBcC-j.js.map → init-DyOF6CiQ.js.map} +1 -1
- package/dist/{mcp-B203R5_F.js → mcp-09FvxYWS.js} +5 -5
- package/dist/{mcp-B203R5_F.js.map → mcp-09FvxYWS.js.map} +1 -1
- package/dist/{mcp-HfHC9cPg.cjs → mcp-BN5HQYdK.cjs} +2 -2
- package/dist/{mcp-HfHC9cPg.cjs.map → mcp-BN5HQYdK.cjs.map} +1 -1
- package/dist/package-Bm6VUbtL.js +6 -0
- package/dist/package-Bm6VUbtL.js.map +1 -0
- package/dist/{package-BWUO2ZW7.cjs → package-DOVOGEEY.cjs} +2 -2
- package/dist/package-DOVOGEEY.cjs.map +1 -0
- package/dist/{run-CGf0KEts.js → run-BO7phoNN.js} +3 -3
- package/dist/{run-CGf0KEts.js.map → run-BO7phoNN.js.map} +1 -1
- package/dist/{run-B1Bc6OVr.cjs → run-BtjzfTz3.cjs} +133 -21
- package/dist/run-BtjzfTz3.cjs.map +1 -0
- package/dist/{run-BQzoaxjR.js → run-BzaKz_nl.js} +3 -3
- package/dist/{run-BQzoaxjR.js.map → run-BzaKz_nl.js.map} +1 -1
- package/dist/{run-CvEVkbIx.js → run-C-omuksC.js} +117 -5
- package/dist/run-C-omuksC.js.map +1 -0
- package/dist/{run--SXpHhbu.cjs → run-CrvmI4G2.cjs} +3 -3
- package/dist/{run--SXpHhbu.cjs.map → run-CrvmI4G2.cjs.map} +1 -1
- package/dist/{run-CCXgjDTA.js → run-DvZ5i2lT.js} +6 -6
- package/dist/{run-CCXgjDTA.js.map → run-DvZ5i2lT.js.map} +1 -1
- package/dist/{shell-BrqyJdB7.js → shell-DsgkfUSW.js} +2 -2
- package/dist/{shell-BrqyJdB7.js.map → shell-DsgkfUSW.js.map} +1 -1
- package/dist/{validate-DM2F50zr.js → validate-5atkOC73.js} +5 -5
- package/dist/{validate-DM2F50zr.js.map → validate-5atkOC73.js.map} +1 -1
- package/dist/{validate-D6ReW7QT.cjs → validate-C6KPFEex.cjs} +2 -2
- package/dist/{validate-D6ReW7QT.cjs.map → validate-C6KPFEex.cjs.map} +1 -1
- package/package.json +6 -10
- package/src/constants.ts +0 -14
- package/src/index.ts +1 -2
- package/src/runners/init/run.ts +0 -2
- package/dist/agent-BKMdKAIJ.cjs +0 -70
- package/dist/agent-BKMdKAIJ.cjs.map +0 -1
- package/dist/agent-yMycIvOI.js +0 -68
- package/dist/agent-yMycIvOI.js.map +0 -1
- package/dist/constants-84a47qA-.js +0 -35
- package/dist/constants-84a47qA-.js.map +0 -1
- package/dist/constants-AHhyFH15.cjs +0 -139
- package/dist/constants-AHhyFH15.cjs.map +0 -1
- package/dist/constants-BtmponZ3.cjs.map +0 -1
- package/dist/constants-C94RKp3A.js +0 -116
- package/dist/constants-C94RKp3A.js.map +0 -1
- package/dist/package-BWUO2ZW7.cjs.map +0 -1
- package/dist/package-BxAq00xt.js +0 -6
- package/dist/package-BxAq00xt.js.map +0 -1
- package/dist/run-B1Bc6OVr.cjs.map +0 -1
- package/dist/run-Bm3WebIl.js +0 -121
- package/dist/run-Bm3WebIl.js.map +0 -1
- package/dist/run-CZC17tSi.cjs +0 -125
- package/dist/run-CZC17tSi.cjs.map +0 -1
- package/dist/run-CvEVkbIx.js.map +0 -1
- package/src/commands/agent/start.ts +0 -50
- package/src/commands/agent.ts +0 -10
- package/src/runners/agent/run.ts +0 -115
- package/src/runners/agent/utils.ts +0 -98
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
import { n as defineCommand } from "./define-
|
|
3
|
-
import { t as version } from "./package-
|
|
1
|
+
import "./chunk-C0LytTxp.js";
|
|
2
|
+
import { n as defineCommand } from "./define-C63T4jp6.js";
|
|
3
|
+
import { t as version } from "./package-Bm6VUbtL.js";
|
|
4
4
|
//#region src/commands/init.ts
|
|
5
5
|
const command = defineCommand({
|
|
6
6
|
name: "init",
|
|
@@ -37,7 +37,7 @@ const command = defineCommand({
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
async run({ values }) {
|
|
40
|
-
const { run } = await import("./run-
|
|
40
|
+
const { run } = await import("./run-C-omuksC.js");
|
|
41
41
|
await run({
|
|
42
42
|
yes: values.yes,
|
|
43
43
|
version,
|
|
@@ -50,4 +50,4 @@ const command = defineCommand({
|
|
|
50
50
|
//#endregion
|
|
51
51
|
export { command };
|
|
52
52
|
|
|
53
|
-
//# sourceMappingURL=init-
|
|
53
|
+
//# sourceMappingURL=init-DyOF6CiQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-
|
|
1
|
+
{"version":3,"file":"init-DyOF6CiQ.js","names":[],"sources":["../src/commands/init.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-client,plugin-react-query',\n ],\n options: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n hint: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n hint: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-client, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n hint: 'plugin-ts,plugin-zod,...',\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;CACF;CACA,SAAS;EACP,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,MAAM;EACR;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,MAAM;EACR;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,MAAM;EACR;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GACR,KAAK,OAAO;GACZ;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;EAClB,CAAC;CACH;AACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
import { n as defineCommand } from "./define-
|
|
3
|
-
import { t as version } from "./package-
|
|
1
|
+
import "./chunk-C0LytTxp.js";
|
|
2
|
+
import { n as defineCommand } from "./define-C63T4jp6.js";
|
|
3
|
+
import { t as version } from "./package-Bm6VUbtL.js";
|
|
4
4
|
//#region src/commands/mcp.ts
|
|
5
5
|
const command = defineCommand({
|
|
6
6
|
name: "mcp",
|
|
@@ -25,7 +25,7 @@ const command = defineCommand({
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
async run({ values }) {
|
|
28
|
-
const { run } = await import("./run-
|
|
28
|
+
const { run } = await import("./run-BzaKz_nl.js");
|
|
29
29
|
await run({
|
|
30
30
|
version,
|
|
31
31
|
port: values.port,
|
|
@@ -36,4 +36,4 @@ const command = defineCommand({
|
|
|
36
36
|
//#endregion
|
|
37
37
|
export { command };
|
|
38
38
|
|
|
39
|
-
//# sourceMappingURL=mcp-
|
|
39
|
+
//# sourceMappingURL=mcp-09FvxYWS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-
|
|
1
|
+
{"version":3,"file":"mcp-09FvxYWS.js","names":[],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'mcp',\n description:\n 'Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.',\n examples: [\n 'kubb mcp',\n 'kubb mcp --port 3001',\n '# Then add to your MCP client config:',\n '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }',\n ],\n options: {\n port: {\n type: 'string',\n short: 'p',\n description: 'Port for HTTP MCP server (omit for stdio)',\n hint: 'number',\n },\n host: {\n type: 'string',\n description: 'Hostname to bind to (HTTP mode only)',\n default: 'localhost',\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/mcp/run.ts')\n\n await run({\n version,\n port: values.port,\n host: values.host,\n })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;CACF;CACA,SAAS;EACP,MAAM;GACJ,MAAM;GACN,OAAO;GACP,aAAa;GACb,MAAM;EACR;EACA,MAAM;GACJ,MAAM;GACN,aAAa;GACb,SAAS;EACX;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GACR;GACA,MAAM,OAAO;GACb,MAAM,OAAO;EACf,CAAC;CACH;AACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("./chunk-Bx3C2hgW.cjs");
|
|
2
2
|
const require_define = require("./define-C4AB3POr.cjs");
|
|
3
|
-
const require_package = require("./package-
|
|
3
|
+
const require_package = require("./package-DOVOGEEY.cjs");
|
|
4
4
|
//#region src/commands/mcp.ts
|
|
5
5
|
const command = require_define.defineCommand({
|
|
6
6
|
name: "mcp",
|
|
@@ -36,4 +36,4 @@ const command = require_define.defineCommand({
|
|
|
36
36
|
//#endregion
|
|
37
37
|
exports.command = command;
|
|
38
38
|
|
|
39
|
-
//# sourceMappingURL=mcp-
|
|
39
|
+
//# sourceMappingURL=mcp-BN5HQYdK.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-
|
|
1
|
+
{"version":3,"file":"mcp-BN5HQYdK.cjs","names":["defineCommand"],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'mcp',\n description:\n 'Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.',\n examples: [\n 'kubb mcp',\n 'kubb mcp --port 3001',\n '# Then add to your MCP client config:',\n '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }',\n ],\n options: {\n port: {\n type: 'string',\n short: 'p',\n description: 'Port for HTTP MCP server (omit for stdio)',\n hint: 'number',\n },\n host: {\n type: 'string',\n description: 'Hostname to bind to (HTTP mode only)',\n default: 'localhost',\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/mcp/run.ts')\n\n await run({\n version,\n port: values.port,\n host: values.host,\n })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAUA,eAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;CACF;CACA,SAAS;EACP,MAAM;GACJ,MAAM;GACN,OAAO;GACP,aAAa;GACb,MAAM;EACR;EACA,MAAM;GACJ,MAAM;GACN,aAAa;GACb,SAAS;EACX;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,SAAA,gBAAA;GACA,MAAM,OAAO;GACb,MAAM,OAAO;EACf,CAAC;CACH;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-Bm6VUbtL.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region package.json
|
|
2
|
-
var version = "5.0.0-beta.
|
|
2
|
+
var version = "5.0.0-beta.50";
|
|
3
3
|
//#endregion
|
|
4
4
|
Object.defineProperty(exports, "version", {
|
|
5
5
|
enumerable: true,
|
|
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "version", {
|
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
//# sourceMappingURL=package-
|
|
11
|
+
//# sourceMappingURL=package-DOVOGEEY.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-DOVOGEEY.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
import { t as getErrorMessage } from "./errors-
|
|
1
|
+
import "./chunk-C0LytTxp.js";
|
|
2
|
+
import { t as getErrorMessage } from "./errors-BsemQCMn.js";
|
|
3
3
|
import { styleText } from "node:util";
|
|
4
4
|
import { Telemetry } from "@kubb/core";
|
|
5
5
|
import process from "node:process";
|
|
@@ -48,4 +48,4 @@ async function run({ input, version }, dependencies = { loadValidateModule }) {
|
|
|
48
48
|
//#endregion
|
|
49
49
|
export { run };
|
|
50
50
|
|
|
51
|
-
//# sourceMappingURL=run-
|
|
51
|
+
//# sourceMappingURL=run-BO7phoNN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-BO7phoNN.js","names":[],"sources":["../src/runners/validate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { Telemetry } from '@kubb/core'\n\ntype ValidateOptions = {\n /**\n * Path or URL to the OpenAPI/Swagger file to validate.\n */\n input: string\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n}\n\ntype ValidateModule = typeof import('@kubb/adapter-oas')\ntype ValidateDependencies = {\n /**\n * Loads `@kubb/adapter-oas`. Injected so tests can substitute a mock.\n */\n loadValidateModule: () => Promise<ValidateModule>\n}\n\n/**\n * Dynamically loads `@kubb/adapter-oas` for OpenAPI validation.\n */\nexport function loadValidateModule(): Promise<ValidateModule> {\n return import('@kubb/adapter-oas') as Promise<ValidateModule>\n}\n\n/**\n * Validates an OpenAPI/Swagger file at `input` using `@kubb/adapter-oas`.\n * Exits the process with code 1 on validation failure or missing dependency.\n */\nexport async function run({ input, version }: ValidateOptions, dependencies: ValidateDependencies = { loadValidateModule }): Promise<void> {\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => Telemetry.send(Telemetry.build({ command: 'validate', kubbVersion: version, hrStart, status }))\n try {\n const { adapterOas } = await dependencies.loadValidateModule()\n const adapter = adapterOas()\n if (!adapter.validate) {\n throw new Error('The loaded adapter does not support validation.')\n }\n await adapter.validate(input, { throwOnError: true })\n await report('success')\n console.log('✅ Validation success')\n } catch (error) {\n await report('failed')\n if (error instanceof Error && /@kubb\\/adapter-oas/.test(error.message)) {\n console.error(styleText('red', 'The @kubb/adapter-oas package is not installed.'))\n console.error('')\n console.error('Install it with:')\n console.error(styleText('cyan', ' npm install @kubb/adapter-oas'))\n console.error(styleText('cyan', ' # or'))\n console.error(styleText('cyan', ' pnpm install @kubb/adapter-oas'))\n console.error('')\n }\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,qBAA8C;CAC5D,OAAO,OAAO;AAChB;;;;;AAMA,eAAsB,IAAI,EAAE,OAAO,WAA4B,eAAqC,EAAE,mBAAmB,GAAkB;CACzI,MAAM,UAAU,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiC,UAAU,KAAK,UAAU,MAAM;EAAE,SAAS;EAAY,aAAa;EAAS;EAAS;CAAO,CAAC,CAAC;CAC/I,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,aAAa,mBAAmB;EAC7D,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,QAAQ,UACX,MAAM,IAAI,MAAM,iDAAiD;EAEnE,MAAM,QAAQ,SAAS,OAAO,EAAE,cAAc,KAAK,CAAC;EACpD,MAAM,OAAO,SAAS;EACtB,QAAQ,IAAI,sBAAsB;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,IAAI,iBAAiB,SAAS,qBAAqB,KAAK,MAAM,OAAO,GAAG;GACtE,QAAQ,MAAM,UAAU,OAAO,iDAAiD,CAAC;GACjF,QAAQ,MAAM,EAAE;GAChB,QAAQ,MAAM,kBAAkB;GAChC,QAAQ,MAAM,UAAU,QAAQ,iCAAiC,CAAC;GAClE,QAAQ,MAAM,UAAU,QAAQ,QAAQ,CAAC;GACzC,QAAQ,MAAM,UAAU,QAAQ,kCAAkC,CAAC;GACnE,QAAQ,MAAM,EAAE;EAClB;EACA,QAAQ,MAAM,qBAAqB;EACnC,QAAQ,MAAM,gBAAgB,KAAK,CAAC;EACpC,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Bx3C2hgW.cjs");
|
|
2
2
|
const require_shell = require("./shell-Lh-vLWwH.cjs");
|
|
3
|
-
const require_constants = require("./constants-AHhyFH15.cjs");
|
|
4
3
|
let node_util = require("node:util");
|
|
5
4
|
let node_fs = require("node:fs");
|
|
6
5
|
node_fs = require_chunk.__toESM(node_fs, 1);
|
|
@@ -66,6 +65,119 @@ function detectPackageManager(cwd = process.cwd()) {
|
|
|
66
65
|
return packageManagers.npm;
|
|
67
66
|
}
|
|
68
67
|
//#endregion
|
|
68
|
+
//#region ../../internals/shared/src/constants.ts
|
|
69
|
+
const KUBB_CONFIG_FILENAME = "kubb.config.ts";
|
|
70
|
+
const initDefaults = {
|
|
71
|
+
inputPath: "./openapi.yaml",
|
|
72
|
+
outputPath: "./src/gen",
|
|
73
|
+
plugins: ["plugin-ts"]
|
|
74
|
+
};
|
|
75
|
+
const availablePlugins = [
|
|
76
|
+
{
|
|
77
|
+
value: "plugin-ts",
|
|
78
|
+
label: "TypeScript",
|
|
79
|
+
hint: "Recommended",
|
|
80
|
+
packageName: "@kubb/plugin-ts",
|
|
81
|
+
importName: "pluginTs",
|
|
82
|
+
category: "types"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
value: "plugin-client",
|
|
86
|
+
label: "Client (Fetch/Axios)",
|
|
87
|
+
packageName: "@kubb/plugin-client",
|
|
88
|
+
importName: "pluginClient",
|
|
89
|
+
category: "client"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
value: "plugin-react-query",
|
|
93
|
+
label: "React Query / TanStack Query",
|
|
94
|
+
packageName: "@kubb/plugin-react-query",
|
|
95
|
+
importName: "pluginReactQuery",
|
|
96
|
+
category: "framework"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
value: "plugin-vue-query",
|
|
100
|
+
label: "Vue Query",
|
|
101
|
+
packageName: "@kubb/plugin-vue-query",
|
|
102
|
+
importName: "pluginVueQuery",
|
|
103
|
+
category: "framework"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
value: "plugin-zod",
|
|
107
|
+
label: "Zod Schemas",
|
|
108
|
+
packageName: "@kubb/plugin-zod",
|
|
109
|
+
importName: "pluginZod",
|
|
110
|
+
category: "validation"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
value: "plugin-faker",
|
|
114
|
+
label: "Faker.js Mocks",
|
|
115
|
+
packageName: "@kubb/plugin-faker",
|
|
116
|
+
importName: "pluginFaker",
|
|
117
|
+
category: "mocks"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
value: "plugin-msw",
|
|
121
|
+
label: "MSW Handlers",
|
|
122
|
+
packageName: "@kubb/plugin-msw",
|
|
123
|
+
importName: "pluginMsw",
|
|
124
|
+
category: "mocks"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
value: "plugin-cypress",
|
|
128
|
+
label: "Cypress Tests",
|
|
129
|
+
packageName: "@kubb/plugin-cypress",
|
|
130
|
+
importName: "pluginCypress",
|
|
131
|
+
category: "testing"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
value: "plugin-mcp",
|
|
135
|
+
label: "MCP Server (AI / Model Context Protocol)",
|
|
136
|
+
packageName: "@kubb/plugin-mcp",
|
|
137
|
+
importName: "pluginMcp",
|
|
138
|
+
category: "ai"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
value: "plugin-redoc",
|
|
142
|
+
label: "ReDoc Documentation",
|
|
143
|
+
packageName: "@kubb/plugin-redoc",
|
|
144
|
+
importName: "pluginRedoc",
|
|
145
|
+
category: "documentation"
|
|
146
|
+
}
|
|
147
|
+
];
|
|
148
|
+
const pluginDefaultConfigs = {
|
|
149
|
+
"plugin-ts": `pluginTs({
|
|
150
|
+
output: { path: 'models' },
|
|
151
|
+
})`,
|
|
152
|
+
"plugin-client": `pluginClient({
|
|
153
|
+
output: { path: 'clients' },
|
|
154
|
+
})`,
|
|
155
|
+
"plugin-react-query": `pluginReactQuery({
|
|
156
|
+
output: { path: 'hooks' },
|
|
157
|
+
})`,
|
|
158
|
+
"plugin-vue-query": `pluginVueQuery({
|
|
159
|
+
output: { path: 'hooks' },
|
|
160
|
+
})`,
|
|
161
|
+
"plugin-zod": `pluginZod({
|
|
162
|
+
output: { path: 'zod' },
|
|
163
|
+
})`,
|
|
164
|
+
"plugin-faker": `pluginFaker({
|
|
165
|
+
output: { path: 'mocks' },
|
|
166
|
+
})`,
|
|
167
|
+
"plugin-msw": `pluginMsw({
|
|
168
|
+
output: { path: 'msw' },
|
|
169
|
+
})`,
|
|
170
|
+
"plugin-cypress": `pluginCypress({
|
|
171
|
+
output: { path: 'cypress' },
|
|
172
|
+
})`,
|
|
173
|
+
"plugin-mcp": `pluginMcp({
|
|
174
|
+
output: { path: 'mcp' },
|
|
175
|
+
})`,
|
|
176
|
+
"plugin-redoc": `pluginRedoc({
|
|
177
|
+
output: { path: 'redoc' },
|
|
178
|
+
})`
|
|
179
|
+
};
|
|
180
|
+
//#endregion
|
|
69
181
|
//#region ../../internals/shared/src/init.ts
|
|
70
182
|
function generateConfigFile({ selectedPlugins, inputPath, outputPath }) {
|
|
71
183
|
return `import { defineConfig } from 'kubb'
|
|
@@ -82,7 +194,7 @@ export default defineConfig({
|
|
|
82
194
|
},
|
|
83
195
|
plugins: [
|
|
84
196
|
${selectedPlugins.map((plugin) => {
|
|
85
|
-
return ` ${
|
|
197
|
+
return ` ${pluginDefaultConfigs[plugin.value] ?? `${plugin.importName}()`},`;
|
|
86
198
|
}).join("\n")}
|
|
87
199
|
],
|
|
88
200
|
})
|
|
@@ -161,28 +273,28 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
|
|
|
161
273
|
}
|
|
162
274
|
const packageManager = detectPackageManager(cwd);
|
|
163
275
|
if (hasPackageJson(cwd)) _clack_prompts.log.info(`Detected package manager: ${(0, node_util.styleText)("cyan", packageManager.name)}`);
|
|
164
|
-
const inputPath = await resolveOrPrompt(inputFlag,
|
|
276
|
+
const inputPath = await resolveOrPrompt(inputFlag, initDefaults.inputPath, "Using input path", () => _clack_prompts.text({
|
|
165
277
|
message: "Where is your OpenAPI specification located?",
|
|
166
|
-
placeholder:
|
|
167
|
-
defaultValue:
|
|
278
|
+
placeholder: initDefaults.inputPath,
|
|
279
|
+
defaultValue: initDefaults.inputPath,
|
|
168
280
|
validate: (value) => {
|
|
169
281
|
if (!value) return "Input path is required";
|
|
170
282
|
}
|
|
171
283
|
}));
|
|
172
|
-
const outputPath = await resolveOrPrompt(outputFlag,
|
|
284
|
+
const outputPath = await resolveOrPrompt(outputFlag, initDefaults.outputPath, "Using output path", () => _clack_prompts.text({
|
|
173
285
|
message: "Where should the generated files be output?",
|
|
174
|
-
placeholder:
|
|
175
|
-
defaultValue:
|
|
286
|
+
placeholder: initDefaults.outputPath,
|
|
287
|
+
defaultValue: initDefaults.outputPath,
|
|
176
288
|
validate: (value) => {
|
|
177
289
|
if (!value) return "Output path is required";
|
|
178
290
|
}
|
|
179
291
|
}));
|
|
180
|
-
const defaultPlugins =
|
|
292
|
+
const defaultPlugins = availablePlugins.filter((p) => initDefaults.plugins.includes(p.value));
|
|
181
293
|
const pluginLabel = (plugins) => (0, node_util.styleText)("cyan", plugins.map((p) => p.label).join(", "));
|
|
182
294
|
const selectedPlugins = await (async () => {
|
|
183
295
|
if (pluginsFlag) {
|
|
184
296
|
const requested = pluginsFlag.split(",").map((v) => v.trim()).filter(Boolean);
|
|
185
|
-
const plugins =
|
|
297
|
+
const plugins = availablePlugins.filter((p) => requested.includes(p.value));
|
|
186
298
|
if (plugins.length === 0) {
|
|
187
299
|
_clack_prompts.log.warn(`No valid plugins found in --plugins value; falling back to default: ${pluginLabel(defaultPlugins)}`);
|
|
188
300
|
return defaultPlugins;
|
|
@@ -196,16 +308,16 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
|
|
|
196
308
|
}
|
|
197
309
|
const values = await _clack_prompts.multiselect({
|
|
198
310
|
message: "Select plugins to use:",
|
|
199
|
-
options:
|
|
311
|
+
options: availablePlugins.map(({ value, label, hint }) => ({
|
|
200
312
|
value,
|
|
201
313
|
label,
|
|
202
314
|
hint
|
|
203
315
|
})),
|
|
204
|
-
initialValues: [...
|
|
316
|
+
initialValues: [...initDefaults.plugins],
|
|
205
317
|
required: true
|
|
206
318
|
});
|
|
207
319
|
if (_clack_prompts.isCancel(values)) cancelAndExit();
|
|
208
|
-
return
|
|
320
|
+
return availablePlugins.filter((p) => values.includes(p.value));
|
|
209
321
|
})();
|
|
210
322
|
const packagesToInstall = ["kubb", ...selectedPlugins.map((p) => p.packageName)];
|
|
211
323
|
const spinner = _clack_prompts.spinner();
|
|
@@ -218,27 +330,27 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
|
|
|
218
330
|
throw error;
|
|
219
331
|
}
|
|
220
332
|
const configSpinner = _clack_prompts.spinner();
|
|
221
|
-
configSpinner.start(`Creating ${
|
|
333
|
+
configSpinner.start(`Creating ${KUBB_CONFIG_FILENAME}`);
|
|
222
334
|
const configContent = generateConfigFile({
|
|
223
335
|
selectedPlugins,
|
|
224
336
|
inputPath,
|
|
225
337
|
outputPath
|
|
226
338
|
});
|
|
227
|
-
const configPath = node_path.default.join(cwd,
|
|
339
|
+
const configPath = node_path.default.join(cwd, KUBB_CONFIG_FILENAME);
|
|
228
340
|
if (node_fs.default.existsSync(configPath)) {
|
|
229
|
-
configSpinner.stop(`${
|
|
341
|
+
configSpinner.stop(`${KUBB_CONFIG_FILENAME} already exists`);
|
|
230
342
|
if (!yes) {
|
|
231
343
|
const shouldOverwrite = await _clack_prompts.confirm({
|
|
232
|
-
message: `${
|
|
344
|
+
message: `${KUBB_CONFIG_FILENAME} already exists. Overwrite?`,
|
|
233
345
|
initialValue: false
|
|
234
346
|
});
|
|
235
347
|
if (_clack_prompts.isCancel(shouldOverwrite) || !shouldOverwrite) cancelAndExit("Keeping existing configuration. Packages have been installed.");
|
|
236
348
|
}
|
|
237
|
-
configSpinner.start(`Overwriting ${
|
|
349
|
+
configSpinner.start(`Overwriting ${KUBB_CONFIG_FILENAME}`);
|
|
238
350
|
}
|
|
239
351
|
await node_fs.default.promises.writeFile(configPath, configContent, "utf-8");
|
|
240
|
-
configSpinner.stop(`Created ${
|
|
241
|
-
_clack_prompts.outro((0, node_util.styleText)("green", "✓ All set!") + "\n\n" + (0, node_util.styleText)("dim", "Next steps:") + "\n" + (0, node_util.styleText)("cyan", ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) + "\n" + (0, node_util.styleText)("cyan", " 2. Generate code with: npx kubb generate") + "\n" + (0, node_util.styleText)("cyan",
|
|
352
|
+
configSpinner.stop(`Created ${KUBB_CONFIG_FILENAME}`);
|
|
353
|
+
_clack_prompts.outro((0, node_util.styleText)("green", "✓ All set!") + "\n\n" + (0, node_util.styleText)("dim", "Next steps:") + "\n" + (0, node_util.styleText)("cyan", ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) + "\n" + (0, node_util.styleText)("cyan", " 2. Generate code with: npx kubb generate") + "\n" + (0, node_util.styleText)("cyan", ` 3. Find generated files in: ${outputPath}`) + "\n\n" + (0, node_util.styleText)("dim", `Using ${packageManager.name} • Kubb v${version}`));
|
|
242
354
|
} catch (error) {
|
|
243
355
|
_clack_prompts.log.error((0, node_util.styleText)("red", "An error occurred during initialization"));
|
|
244
356
|
if (error instanceof Error) _clack_prompts.log.error(error.message);
|
|
@@ -248,4 +360,4 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
|
|
|
248
360
|
//#endregion
|
|
249
361
|
exports.run = run;
|
|
250
362
|
|
|
251
|
-
//# sourceMappingURL=run-
|
|
363
|
+
//# sourceMappingURL=run-BtjzfTz3.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-BtjzfTz3.cjs","names":["process","fs","path","spawnAsync","process","clack","path","fs"],"sources":["../../../internals/utils/src/packageManager.ts","../../../internals/shared/src/constants.ts","../../../internals/shared/src/init.ts","../src/runners/init/utils.ts","../src/runners/init/run.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\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 * 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","import type { PluginOption } from './types.ts'\n\nexport const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const\n\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-ts'],\n} as const\n\nexport const availablePlugins: PluginOption[] = [\n {\n value: 'plugin-ts',\n label: 'TypeScript',\n hint: 'Recommended',\n packageName: '@kubb/plugin-ts',\n importName: 'pluginTs',\n category: 'types',\n },\n {\n value: 'plugin-client',\n label: 'Client (Fetch/Axios)',\n packageName: '@kubb/plugin-client',\n importName: 'pluginClient',\n category: 'client',\n },\n {\n value: 'plugin-react-query',\n label: 'React Query / TanStack Query',\n packageName: '@kubb/plugin-react-query',\n importName: 'pluginReactQuery',\n category: 'framework',\n },\n {\n value: 'plugin-vue-query',\n label: 'Vue Query',\n packageName: '@kubb/plugin-vue-query',\n importName: 'pluginVueQuery',\n category: 'framework',\n },\n {\n value: 'plugin-zod',\n label: 'Zod Schemas',\n packageName: '@kubb/plugin-zod',\n importName: 'pluginZod',\n category: 'validation',\n },\n {\n value: 'plugin-faker',\n label: 'Faker.js Mocks',\n packageName: '@kubb/plugin-faker',\n importName: 'pluginFaker',\n category: 'mocks',\n },\n {\n value: 'plugin-msw',\n label: 'MSW Handlers',\n packageName: '@kubb/plugin-msw',\n importName: 'pluginMsw',\n category: 'mocks',\n },\n {\n value: 'plugin-cypress',\n label: 'Cypress Tests',\n packageName: '@kubb/plugin-cypress',\n importName: 'pluginCypress',\n category: 'testing',\n },\n {\n value: 'plugin-mcp',\n label: 'MCP Server (AI / Model Context Protocol)',\n packageName: '@kubb/plugin-mcp',\n importName: 'pluginMcp',\n category: 'ai',\n },\n {\n value: 'plugin-redoc',\n label: 'ReDoc Documentation',\n packageName: '@kubb/plugin-redoc',\n importName: 'pluginRedoc',\n category: 'documentation',\n },\n]\n\nexport const pluginDefaultConfigs = {\n 'plugin-ts': `pluginTs({\n output: { path: 'models' },\n })`,\n 'plugin-client': `pluginClient({\n output: { path: 'clients' },\n })`,\n 'plugin-react-query': `pluginReactQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-vue-query': `pluginVueQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-zod': `pluginZod({\n output: { path: 'zod' },\n })`,\n 'plugin-faker': `pluginFaker({\n output: { path: 'mocks' },\n })`,\n 'plugin-msw': `pluginMsw({\n output: { path: 'msw' },\n })`,\n 'plugin-cypress': `pluginCypress({\n output: { path: 'cypress' },\n })`,\n 'plugin-mcp': `pluginMcp({\n output: { path: 'mcp' },\n })`,\n 'plugin-redoc': `pluginRedoc({\n output: { path: 'redoc' },\n })`,\n} as const satisfies Record<string, string>\n","import { pluginDefaultConfigs } from './constants.ts'\nimport type { PluginOption } from './types.ts'\n\nexport function generateConfigFile({\n selectedPlugins,\n inputPath,\n outputPath,\n}: {\n selectedPlugins: PluginOption[]\n inputPath: string\n outputPath: string\n}): string {\n const imports = selectedPlugins.map((plugin) => `import { ${plugin.importName} } from '${plugin.packageName}'`).join('\\n')\n\n const pluginConfigs = selectedPlugins\n .map((plugin) => {\n const config = (pluginDefaultConfigs as Record<string, string>)[plugin.value] ?? `${plugin.importName}()`\n return ` ${config},`\n })\n .join('\\n')\n\n return `import { defineConfig } from 'kubb'\n${imports}\n\nexport default defineConfig({\n root: '.',\n input: {\n path: '${inputPath}',\n },\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [\n${pluginConfigs}\n ],\n})\n`\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport type { PackageManagerInfo, PackageManagerName } from '@internals/utils'\nimport { spawnAsync } from '@internals/utils'\n\n/**\n * Returns `true` when a `package.json` exists at `cwd`.\n */\nexport function hasPackageJson(cwd: string = process.cwd()): boolean {\n return fs.existsSync(path.join(cwd, 'package.json'))\n}\n\n/**\n * Initializes a new `package.json` at `cwd` using the detected package manager.\n */\nexport async function initPackageJson(cwd: string, packageManager: PackageManagerInfo): Promise<void> {\n const commands: Record<PackageManagerName, Array<string>> = {\n npm: ['init', '-y'],\n pnpm: ['init'],\n yarn: ['init', '-y'],\n bun: ['init', '-y'],\n }\n\n await spawnAsync(packageManager.name, commands[packageManager.name], { cwd })\n}\n\n/**\n * Installs the given packages at `cwd` using the detected package manager.\n */\nexport async function installPackages(packages: Array<string>, packageManager: PackageManagerInfo, cwd: string = process.cwd()): Promise<void> {\n await spawnAsync(packageManager.name, [...packageManager.installCommand, ...packages], { cwd })\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { detectPackageManager } from '@internals/utils'\nimport { availablePlugins, generateConfigFile, initDefaults, KUBB_CONFIG_FILENAME, type PluginOption } from '@internals/shared'\nimport { hasPackageJson, initPackageJson, installPackages } from './utils.ts'\n\nfunction cancelAndExit(message = 'Operation canceled.'): never {\n clack.cancel(message)\n process.exit(0)\n}\n\ntype InitOptions = {\n /**\n * When `true`, skips all interactive prompts and uses default values.\n */\n yes: boolean\n /**\n * Current `@kubb/cli` version string, shown in the outro and used for package installation.\n */\n version: string\n /**\n * Input path flag value from `--input`. When provided, skips the input prompt.\n */\n input?: string\n /**\n * Output directory flag value from `--output`. When provided, skips the output prompt.\n */\n output?: string\n /**\n * Comma-separated plugin list from `--plugins`, e.g. `'plugin-ts,plugin-zod'`. When provided, skips the plugin selection prompt.\n */\n plugins?: string\n}\n\n/**\n * Runs the interactive Kubb scaffolding wizard.\n * Detects the package manager, prompts for input/output paths and plugins, installs packages, and writes `kubb.config.ts`.\n * Pass `yes: true` to skip all prompts and use defaults.\n */\nexport async function run({ yes, version, input: inputFlag, output: outputFlag, plugins: pluginsFlag }: InitOptions): Promise<void> {\n const cwd = process.cwd()\n\n clack.intro(styleText('bgCyan', styleText('black', ' Kubb Init ')))\n\n /**\n * Returns `flag` when provided, the `defaultValue` when `yes` is set,\n * or calls `prompt()` for interactive input. Exits on cancellation.\n */\n async function resolveOrPrompt<T>(flag: T | undefined, defaultValue: T, logLabel: string, prompt: () => Promise<T | symbol>): Promise<T> {\n if (flag !== undefined) {\n clack.log.info(`${logLabel}: ${styleText('cyan', String(flag))}`)\n return flag\n }\n if (yes) {\n clack.log.info(`${logLabel}: ${styleText('cyan', String(defaultValue))}`)\n return defaultValue\n }\n const result = await prompt()\n if (clack.isCancel(result)) cancelAndExit()\n return result as T\n }\n\n try {\n // Check/create package.json, detect package manager once after the block\n if (!hasPackageJson(cwd)) {\n if (!yes) {\n const shouldInit = await clack.confirm({\n message: 'No package.json found. Would you like to create one?',\n initialValue: true,\n })\n\n if (clack.isCancel(shouldInit) || !shouldInit) {\n cancelAndExit()\n }\n }\n\n const packageManager = detectPackageManager(cwd)\n const spinner = clack.spinner()\n spinner.start(`Initializing package.json with ${packageManager.name}`)\n await initPackageJson(cwd, packageManager)\n spinner.stop(`Created package.json with ${packageManager.name}`)\n }\n\n const packageManager = detectPackageManager(cwd)\n if (hasPackageJson(cwd)) {\n clack.log.info(`Detected package manager: ${styleText('cyan', packageManager.name)}`)\n }\n\n // Prompt for OpenAPI spec path\n const inputPath = await resolveOrPrompt(inputFlag, initDefaults.inputPath, 'Using input path', () =>\n clack.text({\n message: 'Where is your OpenAPI specification located?',\n placeholder: initDefaults.inputPath,\n defaultValue: initDefaults.inputPath,\n validate: (value) => {\n if (!value) return 'Input path is required'\n },\n }),\n )\n\n // Prompt for output directory\n const outputPath = await resolveOrPrompt(outputFlag, initDefaults.outputPath, 'Using output path', () =>\n clack.text({\n message: 'Where should the generated files be output?',\n placeholder: initDefaults.outputPath,\n defaultValue: initDefaults.outputPath,\n validate: (value) => {\n if (!value) return 'Output path is required'\n },\n }),\n )\n\n // Plugin selection\n const defaultPlugins = availablePlugins.filter((p) => (initDefaults.plugins as ReadonlyArray<string>).includes(p.value))\n const pluginLabel = (plugins: Array<PluginOption>) => styleText('cyan', plugins.map((p) => p.label).join(', '))\n\n const selectedPlugins: Array<PluginOption> = await (async () => {\n if (pluginsFlag) {\n const requested = pluginsFlag\n .split(',')\n .map((v) => v.trim())\n .filter(Boolean)\n const plugins = availablePlugins.filter((p) => requested.includes(p.value))\n if (plugins.length === 0) {\n clack.log.warn(`No valid plugins found in --plugins value; falling back to default: ${pluginLabel(defaultPlugins)}`)\n return defaultPlugins\n }\n clack.log.info(`Using plugins: ${pluginLabel(plugins)}`)\n return plugins\n }\n if (yes) {\n clack.log.info(`Using plugins: ${pluginLabel(defaultPlugins)}`)\n return defaultPlugins\n }\n const values = await clack.multiselect({\n message: 'Select plugins to use:',\n options: availablePlugins.map(({ value, label, hint }) => ({ value, label, hint })),\n initialValues: [...initDefaults.plugins],\n required: true,\n })\n if (clack.isCancel(values)) cancelAndExit()\n return availablePlugins.filter((p) => (values as Array<string>).includes(p.value))\n })()\n\n // Install packages\n const packagesToInstall = ['kubb', ...selectedPlugins.map((p) => p.packageName)]\n\n const spinner = clack.spinner()\n spinner.start(`Installing ${packagesToInstall.length} packages with ${packageManager.name}`)\n\n try {\n await installPackages(packagesToInstall, packageManager, cwd)\n spinner.stop(`Installed ${packagesToInstall.length} packages`)\n } catch (error) {\n spinner.stop('Installation failed')\n throw error\n }\n\n // Generate config file\n const configSpinner = clack.spinner()\n configSpinner.start(`Creating ${KUBB_CONFIG_FILENAME}`)\n\n const configContent = generateConfigFile({ selectedPlugins, inputPath, outputPath })\n const configPath = path.join(cwd, KUBB_CONFIG_FILENAME)\n\n if (fs.existsSync(configPath)) {\n configSpinner.stop(`${KUBB_CONFIG_FILENAME} already exists`)\n\n if (!yes) {\n const shouldOverwrite = await clack.confirm({\n message: `${KUBB_CONFIG_FILENAME} already exists. Overwrite?`,\n initialValue: false,\n })\n\n if (clack.isCancel(shouldOverwrite) || !shouldOverwrite) {\n cancelAndExit('Keeping existing configuration. Packages have been installed.')\n }\n }\n\n configSpinner.start(`Overwriting ${KUBB_CONFIG_FILENAME}`)\n }\n\n await fs.promises.writeFile(configPath, configContent, 'utf-8')\n\n configSpinner.stop(`Created ${KUBB_CONFIG_FILENAME}`)\n\n clack.outro(\n styleText('green', '✓ All set!') +\n '\\n\\n' +\n styleText('dim', 'Next steps:') +\n '\\n' +\n styleText('cyan', ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) +\n '\\n' +\n styleText('cyan', ' 2. Generate code with: npx kubb generate') +\n '\\n' +\n styleText('cyan', ` 3. Find generated files in: ${outputPath}`) +\n '\\n\\n' +\n styleText('dim', `Using ${packageManager.name} • Kubb v${version}`),\n )\n } catch (error) {\n clack.log.error(styleText('red', 'An error occurred during initialization'))\n if (error instanceof Error) {\n clack.log.error(error.message)\n }\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,kBAAkE;CACtE,MAAM;EACJ,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,OAAO,IAAI;CAC9B;CACA,MAAM;EACJ,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,OAAO,IAAI;CAC9B;CACA,KAAK;EACH,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,OAAO,IAAI;CAC9B;CACA,KAAK;EACH,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,WAAW,YAAY;CAC1C;AACF;;;;;;;;;;;;AAuBA,SAAgB,qBAAqB,MAAc,QAAQ,IAAI,GAAuB;CACpF,MAAM,mBAAA,GAAA,UAAA,KAAA,CAAuB,KAAK,cAAc;CAChD,KAAA,GAAA,QAAA,WAAA,CAAe,eAAe,GAC5B,IAAI;EAEF,MAAM,UADc,KAAK,OAAA,GAAA,QAAA,aAAA,CAAmB,iBAAiB,OAAO,CAC1C,CAAC,CAAC;EAC5B,IAAI,OAAO,YAAY,UAAU;GAC/B,MAAM,OAAO,QAAQ,MAAM,GAAG,CAAC,CAAC;GAChC,IAAI,QAAQ,QAAQ,iBAClB,OAAO,gBAAgB;EAE3B;CACF,QAAQ,CAER;CAGF,KAAK,MAAM,MAAM,OAAO,OAAO,eAAe,GAC5C,KAAA,GAAA,QAAA,WAAA,EAAA,GAAA,UAAA,KAAA,CAAoB,KAAK,GAAG,QAAQ,CAAC,GACnC,OAAO;CAIX,OAAO,gBAAgB;AACzB;;;ACzGA,MAAa,uBAAuB;AAEpC,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,WAAW;AACvB;AAEA,MAAa,mBAAmC;CAC9C;EACE,OAAO;EACP,OAAO;EACP,MA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UAAU,GAAG;GAC7B,cAAc,KAAK,GAAG,qBAAqB,gBAAgB;GAE3D,IAAI,CAAC,KAAK;IACR,MAAM,kBAAkB,MAAMF,eAAM,QAAQ;KAC1C,SAAS,GAAG,qBAAqB;KACjC,cAAc;IAChB,CAAC;IAED,IAAIA,eAAM,SAAS,eAAe,KAAK,CAAC,iBACtC,cAAc,+DAA+D;GAEjF;GAEA,cAAc,MAAM,eAAe,sBAAsB;EAC3D;EAEA,MAAME,QAAAA,QAAG,SAAS,UAAU,YAAY,eAAe,OAAO;EAE9D,cAAc,KAAK,WAAW,sBAAsB;EAEpD,eAAM,OAAA,GAAA,UAAA,UAAA,CACM,SAAS,YAAY,IAC7B,UAAA,GAAA,UAAA,UAAA,CACU,OAAO,aAAa,IAC9B,QAAA,GAAA,UAAA,UAAA,CACU,QAAQ,2CAA2C,WAAW,IACxE,QAAA,GAAA,UAAA,UAAA,CACU,QAAQ,4CAA4C,IAC9D,QAAA,GAAA,UAAA,UAAA,CACU,QAAQ,iCAAiC,YAAY,IAC/D,UAAA,GAAA,UAAA,UAAA,CACU,OAAO,SAAS,eAAe,KAAK,WAAW,SAAS,CACtE;CACF,SAAS,OAAO;EACd,eAAM,IAAI,OAAA,GAAA,UAAA,UAAA,CAAgB,OAAO,yCAAyC,CAAC;EAC3E,IAAI,iBAAiB,OACnB,eAAM,IAAI,MAAM,MAAM,OAAO;EAE/B,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
import { t as getErrorMessage } from "./errors-
|
|
1
|
+
import "./chunk-C0LytTxp.js";
|
|
2
|
+
import { t as getErrorMessage } from "./errors-BsemQCMn.js";
|
|
3
3
|
import { styleText } from "node:util";
|
|
4
4
|
import { Telemetry } from "@kubb/core";
|
|
5
5
|
import process from "node:process";
|
|
@@ -29,4 +29,4 @@ async function run({ version, port, host }) {
|
|
|
29
29
|
//#endregion
|
|
30
30
|
export { run };
|
|
31
31
|
|
|
32
|
-
//# sourceMappingURL=run-
|
|
32
|
+
//# sourceMappingURL=run-BzaKz_nl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-BzaKz_nl.js","names":[],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { Telemetry } from '@kubb/core'\nimport type * as McpModule from '@kubb/mcp'\n\ntype McpOptions = {\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n /**\n * TCP port for the HTTP MCP server. When `undefined`, the server uses stdio transport.\n */\n port?: string\n /**\n * Hostname to bind to when running in HTTP mode.\n *\n * @default 'localhost'\n */\n host?: string\n}\n\nexport async function run({ version, port, host }: McpOptions): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => Telemetry.send(Telemetry.build({ command: 'mcp', kubbVersion: version, hrStart, status }))\n try {\n console.log(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n await startMcpServer(undefined, { port: port !== undefined ? Number(port) : undefined, host })\n await report('success')\n } catch (error) {\n await report('failed')\n console.error(getErrorMessage(error))\n }\n}\n"],"mappings":";;;;;;AAuBA,eAAsB,IAAI,EAAE,SAAS,MAAM,QAAmC;CAC5E,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAC9C,MAAM,UAAU,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiC,UAAU,KAAK,UAAU,MAAM;EAAE,SAAS;EAAO,aAAa;EAAS;EAAS;CAAO,CAAC,CAAC;CAC1I,IAAI;EACF,QAAQ,IAAI,UAAU,QAAQ,0BAA0B,CAAC;EACzD,QAAQ,KAAK,UAAU,UAAU,2DAA2D,CAAC;EAC7F,MAAM,eAAe,KAAA,GAAW;GAAE,MAAM,SAAS,KAAA,IAAY,OAAO,IAAI,IAAI,KAAA;GAAW;EAAK,CAAC;EAC7F,MAAM,OAAO,SAAS;CACxB,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,QAAQ,MAAM,gBAAgB,KAAK,CAAC;CACtC;AACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
import { t as spawnAsync } from "./shell-
|
|
3
|
-
import { i as pluginDefaultConfigs, n as availablePlugins, r as initDefaults, t as KUBB_CONFIG_FILENAME } from "./constants-C94RKp3A.js";
|
|
1
|
+
import "./chunk-C0LytTxp.js";
|
|
2
|
+
import { t as spawnAsync } from "./shell-DsgkfUSW.js";
|
|
4
3
|
import { styleText } from "node:util";
|
|
5
4
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
6
5
|
import path, { join } from "node:path";
|
|
@@ -62,6 +61,119 @@ function detectPackageManager(cwd = process.cwd()) {
|
|
|
62
61
|
return packageManagers.npm;
|
|
63
62
|
}
|
|
64
63
|
//#endregion
|
|
64
|
+
//#region ../../internals/shared/src/constants.ts
|
|
65
|
+
const KUBB_CONFIG_FILENAME = "kubb.config.ts";
|
|
66
|
+
const initDefaults = {
|
|
67
|
+
inputPath: "./openapi.yaml",
|
|
68
|
+
outputPath: "./src/gen",
|
|
69
|
+
plugins: ["plugin-ts"]
|
|
70
|
+
};
|
|
71
|
+
const availablePlugins = [
|
|
72
|
+
{
|
|
73
|
+
value: "plugin-ts",
|
|
74
|
+
label: "TypeScript",
|
|
75
|
+
hint: "Recommended",
|
|
76
|
+
packageName: "@kubb/plugin-ts",
|
|
77
|
+
importName: "pluginTs",
|
|
78
|
+
category: "types"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
value: "plugin-client",
|
|
82
|
+
label: "Client (Fetch/Axios)",
|
|
83
|
+
packageName: "@kubb/plugin-client",
|
|
84
|
+
importName: "pluginClient",
|
|
85
|
+
category: "client"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
value: "plugin-react-query",
|
|
89
|
+
label: "React Query / TanStack Query",
|
|
90
|
+
packageName: "@kubb/plugin-react-query",
|
|
91
|
+
importName: "pluginReactQuery",
|
|
92
|
+
category: "framework"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
value: "plugin-vue-query",
|
|
96
|
+
label: "Vue Query",
|
|
97
|
+
packageName: "@kubb/plugin-vue-query",
|
|
98
|
+
importName: "pluginVueQuery",
|
|
99
|
+
category: "framework"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
value: "plugin-zod",
|
|
103
|
+
label: "Zod Schemas",
|
|
104
|
+
packageName: "@kubb/plugin-zod",
|
|
105
|
+
importName: "pluginZod",
|
|
106
|
+
category: "validation"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
value: "plugin-faker",
|
|
110
|
+
label: "Faker.js Mocks",
|
|
111
|
+
packageName: "@kubb/plugin-faker",
|
|
112
|
+
importName: "pluginFaker",
|
|
113
|
+
category: "mocks"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
value: "plugin-msw",
|
|
117
|
+
label: "MSW Handlers",
|
|
118
|
+
packageName: "@kubb/plugin-msw",
|
|
119
|
+
importName: "pluginMsw",
|
|
120
|
+
category: "mocks"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
value: "plugin-cypress",
|
|
124
|
+
label: "Cypress Tests",
|
|
125
|
+
packageName: "@kubb/plugin-cypress",
|
|
126
|
+
importName: "pluginCypress",
|
|
127
|
+
category: "testing"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
value: "plugin-mcp",
|
|
131
|
+
label: "MCP Server (AI / Model Context Protocol)",
|
|
132
|
+
packageName: "@kubb/plugin-mcp",
|
|
133
|
+
importName: "pluginMcp",
|
|
134
|
+
category: "ai"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
value: "plugin-redoc",
|
|
138
|
+
label: "ReDoc Documentation",
|
|
139
|
+
packageName: "@kubb/plugin-redoc",
|
|
140
|
+
importName: "pluginRedoc",
|
|
141
|
+
category: "documentation"
|
|
142
|
+
}
|
|
143
|
+
];
|
|
144
|
+
const pluginDefaultConfigs = {
|
|
145
|
+
"plugin-ts": `pluginTs({
|
|
146
|
+
output: { path: 'models' },
|
|
147
|
+
})`,
|
|
148
|
+
"plugin-client": `pluginClient({
|
|
149
|
+
output: { path: 'clients' },
|
|
150
|
+
})`,
|
|
151
|
+
"plugin-react-query": `pluginReactQuery({
|
|
152
|
+
output: { path: 'hooks' },
|
|
153
|
+
})`,
|
|
154
|
+
"plugin-vue-query": `pluginVueQuery({
|
|
155
|
+
output: { path: 'hooks' },
|
|
156
|
+
})`,
|
|
157
|
+
"plugin-zod": `pluginZod({
|
|
158
|
+
output: { path: 'zod' },
|
|
159
|
+
})`,
|
|
160
|
+
"plugin-faker": `pluginFaker({
|
|
161
|
+
output: { path: 'mocks' },
|
|
162
|
+
})`,
|
|
163
|
+
"plugin-msw": `pluginMsw({
|
|
164
|
+
output: { path: 'msw' },
|
|
165
|
+
})`,
|
|
166
|
+
"plugin-cypress": `pluginCypress({
|
|
167
|
+
output: { path: 'cypress' },
|
|
168
|
+
})`,
|
|
169
|
+
"plugin-mcp": `pluginMcp({
|
|
170
|
+
output: { path: 'mcp' },
|
|
171
|
+
})`,
|
|
172
|
+
"plugin-redoc": `pluginRedoc({
|
|
173
|
+
output: { path: 'redoc' },
|
|
174
|
+
})`
|
|
175
|
+
};
|
|
176
|
+
//#endregion
|
|
65
177
|
//#region ../../internals/shared/src/init.ts
|
|
66
178
|
function generateConfigFile({ selectedPlugins, inputPath, outputPath }) {
|
|
67
179
|
return `import { defineConfig } from 'kubb'
|
|
@@ -234,7 +346,7 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
|
|
|
234
346
|
}
|
|
235
347
|
await fs.promises.writeFile(configPath, configContent, "utf-8");
|
|
236
348
|
configSpinner.stop(`Created ${KUBB_CONFIG_FILENAME}`);
|
|
237
|
-
clack.outro(styleText("green", "✓ All set!") + "\n\n" + styleText("dim", "Next steps:") + "\n" + styleText("cyan", ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) + "\n" + styleText("cyan", " 2. Generate code with: npx kubb generate") + "\n" + styleText("cyan",
|
|
349
|
+
clack.outro(styleText("green", "✓ All set!") + "\n\n" + styleText("dim", "Next steps:") + "\n" + styleText("cyan", ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) + "\n" + styleText("cyan", " 2. Generate code with: npx kubb generate") + "\n" + styleText("cyan", ` 3. Find generated files in: ${outputPath}`) + "\n\n" + styleText("dim", `Using ${packageManager.name} • Kubb v${version}`));
|
|
238
350
|
} catch (error) {
|
|
239
351
|
clack.log.error(styleText("red", "An error occurred during initialization"));
|
|
240
352
|
if (error instanceof Error) clack.log.error(error.message);
|
|
@@ -244,4 +356,4 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
|
|
|
244
356
|
//#endregion
|
|
245
357
|
export { run };
|
|
246
358
|
|
|
247
|
-
//# sourceMappingURL=run-
|
|
359
|
+
//# sourceMappingURL=run-C-omuksC.js.map
|