@kubb/cli 4.32.4 → 4.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-Bd1QdPVV.cjs +91 -0
- package/dist/agent-Bd1QdPVV.cjs.map +1 -0
- package/dist/agent-D83d9Pud.cjs +60 -0
- package/dist/agent-D83d9Pud.cjs.map +1 -0
- package/dist/agent-DgKQXSmR.js +57 -0
- package/dist/agent-DgKQXSmR.js.map +1 -0
- package/dist/agent-u_Ehwz6r.js +87 -0
- package/dist/agent-u_Ehwz6r.js.map +1 -0
- package/dist/constants-BTUap0zs.cjs +108 -0
- package/dist/constants-BTUap0zs.cjs.map +1 -0
- package/dist/constants-CM3dJzjK.js +67 -0
- package/dist/constants-CM3dJzjK.js.map +1 -0
- package/dist/define--M_JMcDC.js +25 -0
- package/dist/define--M_JMcDC.js.map +1 -0
- package/dist/define-D6Kfm7-Z.cjs +36 -0
- package/dist/define-D6Kfm7-Z.cjs.map +1 -0
- package/dist/errors-6mF_WKxg.js +27 -0
- package/dist/errors-6mF_WKxg.js.map +1 -0
- package/dist/errors-DBW0N9w4.cjs +44 -0
- package/dist/errors-DBW0N9w4.cjs.map +1 -0
- package/dist/generate-Bn8n4w1O.cjs +65 -0
- package/dist/generate-Bn8n4w1O.cjs.map +1 -0
- package/dist/{generate-CpWtSc45.js → generate-CAsV9wSx.js} +656 -689
- package/dist/generate-CAsV9wSx.js.map +1 -0
- package/dist/generate-D-59YK0L.js +66 -0
- package/dist/generate-D-59YK0L.js.map +1 -0
- package/dist/{generate-COj0aMS6.cjs → generate-JC65igQh.cjs} +662 -694
- package/dist/generate-JC65igQh.cjs.map +1 -0
- package/dist/index.cjs +226 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +226 -35
- package/dist/index.js.map +1 -1
- package/dist/init-C-InrmSY.js +302 -0
- package/dist/init-C-InrmSY.js.map +1 -0
- package/dist/init-CXP8OfMe.js +25 -0
- package/dist/init-CXP8OfMe.js.map +1 -0
- package/dist/init-CbeE-L-0.cjs +25 -0
- package/dist/init-CbeE-L-0.cjs.map +1 -0
- package/dist/init-hmolV6B4.cjs +306 -0
- package/dist/init-hmolV6B4.cjs.map +1 -0
- package/dist/jiti-Cd3S0xwr.cjs +16 -0
- package/dist/jiti-Cd3S0xwr.cjs.map +1 -0
- package/dist/jiti-e08mD2Ph.js +11 -0
- package/dist/jiti-e08mD2Ph.js.map +1 -0
- package/dist/mcp-BDxg2oJm.cjs +16 -0
- package/dist/mcp-BDxg2oJm.cjs.map +1 -0
- package/dist/mcp-ChHFPRzD.cjs +42 -0
- package/dist/mcp-ChHFPRzD.cjs.map +1 -0
- package/dist/mcp-D2SHEg_d.js +41 -0
- package/dist/mcp-D2SHEg_d.js.map +1 -0
- package/dist/mcp-MSoE4vNA.js +16 -0
- package/dist/mcp-MSoE4vNA.js.map +1 -0
- package/dist/{package-aNQWvWbS.cjs → package-CUVyeIbt.cjs} +2 -2
- package/dist/package-CUVyeIbt.cjs.map +1 -0
- package/dist/package-Cbd8OC6q.js +6 -0
- package/dist/package-Cbd8OC6q.js.map +1 -0
- package/dist/shell-7HPrTCJ5.cjs +57 -0
- package/dist/shell-7HPrTCJ5.cjs.map +1 -0
- package/dist/shell-DqqWsHCD.js +46 -0
- package/dist/shell-DqqWsHCD.js.map +1 -0
- package/dist/{telemetry-BDSSqUiG.cjs → telemetry-Cn9X1I5B.cjs} +79 -9
- package/dist/telemetry-Cn9X1I5B.cjs.map +1 -0
- package/dist/{telemetry-DYWvlxqs.js → telemetry-DxiR7clS.js} +63 -11
- package/dist/telemetry-DxiR7clS.js.map +1 -0
- package/dist/validate-BG8A3aQS.cjs +25 -0
- package/dist/validate-BG8A3aQS.cjs.map +1 -0
- package/dist/validate-BZ1UFkwA.js +25 -0
- package/dist/validate-BZ1UFkwA.js.map +1 -0
- package/dist/validate-Bbrn3Q-A.cjs +42 -0
- package/dist/validate-Bbrn3Q-A.cjs.map +1 -0
- package/dist/validate-l8vLmwKA.js +41 -0
- package/dist/validate-l8vLmwKA.js.map +1 -0
- package/package.json +6 -6
- package/src/commands/agent/start.ts +27 -136
- package/src/commands/agent.ts +6 -25
- package/src/commands/generate.ts +26 -158
- package/src/commands/init.ts +9 -360
- package/src/commands/mcp.ts +7 -52
- package/src/commands/validate.ts +9 -60
- package/src/constants.ts +76 -0
- package/src/index.ts +36 -42
- package/src/loggers/clackLogger.ts +65 -165
- package/src/loggers/fileSystemLogger.ts +2 -14
- package/src/loggers/githubActionsLogger.ts +58 -125
- package/src/loggers/plainLogger.ts +44 -92
- package/src/loggers/utils.ts +67 -4
- package/src/runners/agent.ts +100 -0
- package/src/runners/generate.ts +223 -102
- package/src/runners/init.ts +323 -0
- package/src/runners/mcp.ts +32 -0
- package/src/runners/validate.ts +35 -0
- package/src/utils/Writables.ts +2 -2
- package/src/utils/executeHooks.ts +20 -8
- package/src/utils/getCosmiConfig.ts +10 -11
- package/src/utils/getIntro.ts +1 -81
- package/src/utils/getSummary.ts +12 -17
- package/src/utils/jiti.ts +9 -0
- package/src/utils/packageManager.ts +4 -4
- package/src/utils/runHook.ts +75 -0
- package/src/utils/telemetry.ts +8 -26
- package/src/utils/watcher.ts +2 -4
- package/dist/agent-6COck3B9.cjs +0 -20
- package/dist/agent-6COck3B9.cjs.map +0 -1
- package/dist/agent-DMm6c5Vg.js +0 -20
- package/dist/agent-DMm6c5Vg.js.map +0 -1
- package/dist/generate-COj0aMS6.cjs.map +0 -1
- package/dist/generate-CpWtSc45.js.map +0 -1
- package/dist/init-Bdn3_qir.js +0 -304
- package/dist/init-Bdn3_qir.js.map +0 -1
- package/dist/init-CFW2kWY8.cjs +0 -308
- package/dist/init-CFW2kWY8.cjs.map +0 -1
- package/dist/mcp-DkwtARfo.cjs +0 -57
- package/dist/mcp-DkwtARfo.cjs.map +0 -1
- package/dist/mcp-DrH93Vq4.js +0 -57
- package/dist/mcp-DrH93Vq4.js.map +0 -1
- package/dist/package-BnJbGmLm.js +0 -6
- package/dist/package-BnJbGmLm.js.map +0 -1
- package/dist/package-aNQWvWbS.cjs.map +0 -1
- package/dist/start-CqTUu14n.js +0 -131
- package/dist/start-CqTUu14n.js.map +0 -1
- package/dist/start-D-rsIJGo.cjs +0 -134
- package/dist/start-D-rsIJGo.cjs.map +0 -1
- package/dist/telemetry-BDSSqUiG.cjs.map +0 -1
- package/dist/telemetry-DYWvlxqs.js.map +0 -1
- package/dist/validate-BlV8L8gC.js +0 -66
- package/dist/validate-BlV8L8gC.js.map +0 -1
- package/dist/validate-COhZUXF8.cjs +0 -66
- package/dist/validate-COhZUXF8.cjs.map +0 -1
- package/src/loggers/envDetection.ts +0 -28
- package/src/loggers/index.ts +0 -5
- package/src/utils/formatMsWithColor.ts +0 -22
- package/src/utils/randomColor.ts +0 -23
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
2
|
+
const require_telemetry = require("./telemetry-Cn9X1I5B.cjs");
|
|
3
|
+
const require_shell = require("./shell-7HPrTCJ5.cjs");
|
|
4
|
+
const require_constants = require("./constants-BTUap0zs.cjs");
|
|
5
|
+
let node_util = require("node:util");
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
node_path = require_chunk.__toESM(node_path);
|
|
8
|
+
let node_process = require("node:process");
|
|
9
|
+
node_process = require_chunk.__toESM(node_process);
|
|
10
|
+
let node_net = require("node:net");
|
|
11
|
+
node_net = require_chunk.__toESM(node_net);
|
|
12
|
+
let node_url = require("node:url");
|
|
13
|
+
let _clack_prompts = require("@clack/prompts");
|
|
14
|
+
_clack_prompts = require_chunk.__toESM(_clack_prompts);
|
|
15
|
+
//#region src/runners/agent.ts
|
|
16
|
+
function isPortAvailable(port, host) {
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
const server = node_net.default.createServer();
|
|
19
|
+
server.once("error", () => resolve(false));
|
|
20
|
+
server.once("listening", () => {
|
|
21
|
+
server.close();
|
|
22
|
+
resolve(true);
|
|
23
|
+
});
|
|
24
|
+
server.listen(port, host);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }) {
|
|
28
|
+
const hrStart = node_process.hrtime();
|
|
29
|
+
try {
|
|
30
|
+
try {
|
|
31
|
+
node_process.loadEnvFile();
|
|
32
|
+
} catch {}
|
|
33
|
+
const agentPkgPath = (0, node_url.fileURLToPath)({}.resolve("@kubb/agent/package.json"));
|
|
34
|
+
const agentDir = node_path.default.dirname(agentPkgPath);
|
|
35
|
+
const serverPath = node_path.default.join(agentDir, require_constants.agentDefaults.serverEntryPath);
|
|
36
|
+
const PORT = port !== void 0 ? port : node_process.env.PORT ?? require_constants.agentDefaults.port;
|
|
37
|
+
const HOST = host !== require_constants.agentDefaults.host ? host : node_process.env.HOST ?? require_constants.agentDefaults.host;
|
|
38
|
+
const KUBB_AGENT_ROOT = node_process.env.KUBB_AGENT_ROOT ?? node_process.cwd();
|
|
39
|
+
const KUBB_AGENT_CONFIG = configPath !== require_constants.agentDefaults.configFile ? configPath : node_process.env.KUBB_AGENT_CONFIG ?? require_constants.agentDefaults.configFile;
|
|
40
|
+
const KUBB_AGENT_ALLOW_WRITE = allowAll || allowWrite ? "true" : node_process.env.KUBB_AGENT_ALLOW_WRITE ?? "false";
|
|
41
|
+
const KUBB_AGENT_ALLOW_ALL = allowAll ? "true" : node_process.env.KUBB_AGENT_ALLOW_ALL ?? "false";
|
|
42
|
+
const KUBB_AGENT_TOKEN = node_process.env.KUBB_AGENT_TOKEN;
|
|
43
|
+
const KUBB_AGENT_RETRY_TIMEOUT = node_process.env.KUBB_AGENT_RETRY_TIMEOUT ?? require_constants.agentDefaults.retryTimeout;
|
|
44
|
+
const KUBB_STUDIO_URL = node_process.env.KUBB_STUDIO_URL ?? require_constants.agentDefaults.studioUrl;
|
|
45
|
+
const env = {
|
|
46
|
+
...node_process.env,
|
|
47
|
+
PORT,
|
|
48
|
+
HOST,
|
|
49
|
+
KUBB_AGENT_ROOT,
|
|
50
|
+
KUBB_AGENT_CONFIG,
|
|
51
|
+
KUBB_AGENT_ALLOW_WRITE,
|
|
52
|
+
KUBB_AGENT_ALLOW_ALL,
|
|
53
|
+
KUBB_AGENT_TOKEN,
|
|
54
|
+
KUBB_AGENT_RETRY_TIMEOUT,
|
|
55
|
+
KUBB_STUDIO_URL
|
|
56
|
+
};
|
|
57
|
+
_clack_prompts.log.step((0, node_util.styleText)("cyan", "Starting agent server..."));
|
|
58
|
+
_clack_prompts.log.info((0, node_util.styleText)("dim", `Config: ${KUBB_AGENT_CONFIG}`));
|
|
59
|
+
_clack_prompts.log.info((0, node_util.styleText)("dim", `Host: ${HOST}`));
|
|
60
|
+
_clack_prompts.log.info((0, node_util.styleText)("dim", `Port: ${PORT}`));
|
|
61
|
+
if (!KUBB_AGENT_ALLOW_WRITE && !KUBB_AGENT_ALLOW_ALL) _clack_prompts.log.warn((0, node_util.styleText)("yellow", "Filesystem writes disabled. Use --allow-write or --allow-all to enable."));
|
|
62
|
+
if (!await isPortAvailable(Number(PORT), HOST)) {
|
|
63
|
+
_clack_prompts.log.error((0, node_util.styleText)("red", `Port ${PORT} is already in use. Stop the existing process or choose a different port with --port.`));
|
|
64
|
+
node_process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
await require_shell.spawnAsync("node", [serverPath], {
|
|
67
|
+
env,
|
|
68
|
+
cwd: node_process.cwd()
|
|
69
|
+
});
|
|
70
|
+
await require_telemetry.sendTelemetry(require_telemetry.buildTelemetryEvent({
|
|
71
|
+
command: "agent",
|
|
72
|
+
kubbVersion: version,
|
|
73
|
+
hrStart,
|
|
74
|
+
status: "success"
|
|
75
|
+
}));
|
|
76
|
+
} catch (error) {
|
|
77
|
+
await require_telemetry.sendTelemetry(require_telemetry.buildTelemetryEvent({
|
|
78
|
+
command: "agent",
|
|
79
|
+
kubbVersion: version,
|
|
80
|
+
hrStart,
|
|
81
|
+
status: "failed"
|
|
82
|
+
}));
|
|
83
|
+
_clack_prompts.log.error((0, node_util.styleText)("red", "Failed to start agent server"));
|
|
84
|
+
console.error(error);
|
|
85
|
+
node_process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
exports.runAgentStart = runAgentStart;
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=agent-Bd1QdPVV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-Bd1QdPVV.cjs","names":["net","process","path","agentDefaults","spawnAsync","sendTelemetry","buildTelemetryEvent"],"sources":["../src/runners/agent.ts"],"sourcesContent":["import net from 'node:net'\nimport path from 'node:path'\nimport * as process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { spawnAsync } from '@internals/utils'\nimport { agentDefaults } from '../constants.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype AgentStartOptions = {\n port: string | undefined\n host: string\n configPath: string\n allowWrite: boolean\n allowAll: boolean\n version: string\n}\n\nfunction isPortAvailable(port: number, host: string): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer()\n server.once('error', () => resolve(false))\n server.once('listening', () => {\n server.close()\n resolve(true)\n })\n server.listen(port, host)\n })\n}\n\nexport async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }: AgentStartOptions): Promise<void> {\n const hrStart = process.hrtime()\n\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist; ignore\n }\n\n // Resolve the @kubb/agent package path\n const agentPkgUrl = import.meta.resolve('@kubb/agent/package.json')\n const agentPkgPath = fileURLToPath(agentPkgUrl)\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, agentDefaults.serverEntryPath)\n\n // CLI params take priority over process.env; process.env fills in what the CLI didn't specify;\n // agentDefaults are the last resort. Build env as: defaults ← process.env ← CLI.\n const PORT = port !== undefined ? port : (process.env.PORT ?? agentDefaults.port)\n const HOST = host !== agentDefaults.host ? host : (process.env.HOST ?? agentDefaults.host)\n const KUBB_AGENT_ROOT = process.env.KUBB_AGENT_ROOT ?? process.cwd()\n const KUBB_AGENT_CONFIG = configPath !== agentDefaults.configFile ? configPath : (process.env.KUBB_AGENT_CONFIG ?? agentDefaults.configFile)\n const KUBB_AGENT_ALLOW_WRITE = allowAll || allowWrite ? 'true' : (process.env.KUBB_AGENT_ALLOW_WRITE ?? 'false')\n const KUBB_AGENT_ALLOW_ALL = allowAll ? 'true' : (process.env.KUBB_AGENT_ALLOW_ALL ?? 'false')\n const KUBB_AGENT_TOKEN = process.env.KUBB_AGENT_TOKEN\n const KUBB_AGENT_RETRY_TIMEOUT = process.env.KUBB_AGENT_RETRY_TIMEOUT ?? agentDefaults.retryTimeout\n const KUBB_STUDIO_URL = process.env.KUBB_STUDIO_URL ?? agentDefaults.studioUrl\n\n const env = {\n ...process.env,\n PORT,\n HOST,\n KUBB_AGENT_ROOT,\n KUBB_AGENT_CONFIG,\n KUBB_AGENT_ALLOW_WRITE,\n KUBB_AGENT_ALLOW_ALL,\n KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT,\n KUBB_STUDIO_URL,\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${KUBB_AGENT_CONFIG}`))\n clack.log.info(styleText('dim', `Host: ${HOST}`))\n clack.log.info(styleText('dim', `Port: ${PORT}`))\n if (!KUBB_AGENT_ALLOW_WRITE && !KUBB_AGENT_ALLOW_ALL) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n if (!(await isPortAvailable(Number(PORT), HOST))) {\n clack.log.error(styleText('red', `Port ${PORT} is already in use. Stop the existing process or choose a different port with --port.`))\n process.exit(1)\n }\n\n // Spawns the server as a detached background process so the CLI can exit independently.\n await spawnAsync('node', [serverPath], {\n env,\n cwd: process.cwd(),\n })\n\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'success' }))\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'failed' }))\n clack.log.error(styleText('red', 'Failed to start agent server'))\n console.error(error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAS,gBAAgB,MAAc,MAAgC;AACrE,QAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,SAASA,SAAAA,QAAI,cAAc;AACjC,SAAO,KAAK,eAAe,QAAQ,MAAM,CAAC;AAC1C,SAAO,KAAK,mBAAmB;AAC7B,UAAO,OAAO;AACd,WAAQ,KAAK;IACb;AACF,SAAO,OAAO,MAAM,KAAK;GACzB;;AAGJ,eAAsB,cAAc,EAAE,MAAM,MAAM,YAAY,YAAY,UAAU,WAA6C;CAC/H,MAAM,UAAUC,aAAQ,QAAQ;AAEhC,KAAI;AAEF,MAAI;AACF,gBAAQ,aAAa;UACf;EAMR,MAAM,gBAAA,GAAA,SAAA,eAAA,EAAA,CAD0B,QAAQ,2BAA2B,CACpB;EAC/C,MAAM,WAAWC,UAAAA,QAAK,QAAQ,aAAa;EAC3C,MAAM,aAAaA,UAAAA,QAAK,KAAK,UAAUC,kBAAAA,cAAc,gBAAgB;EAIrE,MAAM,OAAO,SAAS,KAAA,IAAY,OAAQF,aAAQ,IAAI,QAAQE,kBAAAA,cAAc;EAC5E,MAAM,OAAO,SAASA,kBAAAA,cAAc,OAAO,OAAQF,aAAQ,IAAI,QAAQE,kBAAAA,cAAc;EACrF,MAAM,kBAAkBF,aAAQ,IAAI,mBAAmBA,aAAQ,KAAK;EACpE,MAAM,oBAAoB,eAAeE,kBAAAA,cAAc,aAAa,aAAcF,aAAQ,IAAI,qBAAqBE,kBAAAA,cAAc;EACjI,MAAM,yBAAyB,YAAY,aAAa,SAAUF,aAAQ,IAAI,0BAA0B;EACxG,MAAM,uBAAuB,WAAW,SAAUA,aAAQ,IAAI,wBAAwB;EACtF,MAAM,mBAAmBA,aAAQ,IAAI;EACrC,MAAM,2BAA2BA,aAAQ,IAAI,4BAA4BE,kBAAAA,cAAc;EACvF,MAAM,kBAAkBF,aAAQ,IAAI,mBAAmBE,kBAAAA,cAAc;EAErE,MAAM,MAAM;GACV,GAAGF,aAAQ;GACX;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;AAED,iBAAM,IAAI,MAAA,GAAA,UAAA,WAAe,QAAQ,2BAA2B,CAAC;AAC7D,iBAAM,IAAI,MAAA,GAAA,UAAA,WAAe,OAAO,WAAW,oBAAoB,CAAC;AAChE,iBAAM,IAAI,MAAA,GAAA,UAAA,WAAe,OAAO,SAAS,OAAO,CAAC;AACjD,iBAAM,IAAI,MAAA,GAAA,UAAA,WAAe,OAAO,SAAS,OAAO,CAAC;AACjD,MAAI,CAAC,0BAA0B,CAAC,qBAC9B,gBAAM,IAAI,MAAA,GAAA,UAAA,WAAe,UAAU,0EAA0E,CAAC;AAGhH,MAAI,CAAE,MAAM,gBAAgB,OAAO,KAAK,EAAE,KAAK,EAAG;AAChD,kBAAM,IAAI,OAAA,GAAA,UAAA,WAAgB,OAAO,QAAQ,KAAK,uFAAuF,CAAC;AACtI,gBAAQ,KAAK,EAAE;;AAIjB,QAAMG,cAAAA,WAAW,QAAQ,CAAC,WAAW,EAAE;GACrC;GACA,KAAKH,aAAQ,KAAK;GACnB,CAAC;AAEF,QAAMI,kBAAAA,cAAcC,kBAAAA,oBAAoB;GAAE,SAAS;GAAS,aAAa;GAAS;GAAS,QAAQ;GAAW,CAAC,CAAC;UACzG,OAAO;AACd,QAAMD,kBAAAA,cAAcC,kBAAAA,oBAAoB;GAAE,SAAS;GAAS,aAAa;GAAS;GAAS,QAAQ;GAAU,CAAC,CAAC;AAC/G,iBAAM,IAAI,OAAA,GAAA,UAAA,WAAgB,OAAO,+BAA+B,CAAC;AACjE,UAAQ,MAAM,MAAM;AACpB,eAAQ,KAAK,EAAE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
2
|
+
const require_define = require("./define-D6Kfm7-Z.cjs");
|
|
3
|
+
const require_package = require("./package-CUVyeIbt.cjs");
|
|
4
|
+
const require_constants = require("./constants-BTUap0zs.cjs");
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
node_path = require_chunk.__toESM(node_path);
|
|
7
|
+
//#region src/commands/agent/start.ts
|
|
8
|
+
const command$1 = require_define.defineCommand({
|
|
9
|
+
name: "start",
|
|
10
|
+
description: "Start the Agent server",
|
|
11
|
+
options: {
|
|
12
|
+
config: {
|
|
13
|
+
type: "string",
|
|
14
|
+
description: "Path to the Kubb config",
|
|
15
|
+
short: "c"
|
|
16
|
+
},
|
|
17
|
+
port: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: `Port for the server (default: ${require_constants.agentDefaults.port})`,
|
|
20
|
+
short: "p"
|
|
21
|
+
},
|
|
22
|
+
host: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Host for the server",
|
|
25
|
+
default: require_constants.agentDefaults.host
|
|
26
|
+
},
|
|
27
|
+
"allow-write": {
|
|
28
|
+
type: "boolean",
|
|
29
|
+
description: "Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.",
|
|
30
|
+
default: false
|
|
31
|
+
},
|
|
32
|
+
"allow-all": {
|
|
33
|
+
type: "boolean",
|
|
34
|
+
description: "Grant all permissions (implies --allow-write).",
|
|
35
|
+
default: false
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
async run({ values }) {
|
|
39
|
+
const { runAgentStart } = await Promise.resolve().then(() => require("./agent-Bd1QdPVV.cjs"));
|
|
40
|
+
await runAgentStart({
|
|
41
|
+
port: values.port !== void 0 ? values.port : void 0,
|
|
42
|
+
host: values.host,
|
|
43
|
+
configPath: node_path.default.resolve(process.cwd(), values.config ?? require_constants.agentDefaults.configFile),
|
|
44
|
+
allowWrite: values["allow-write"],
|
|
45
|
+
allowAll: values["allow-all"],
|
|
46
|
+
version: require_package.version
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/commands/agent.ts
|
|
52
|
+
const command = require_define.defineCommand({
|
|
53
|
+
name: "agent",
|
|
54
|
+
description: "Manage the Kubb Agent server",
|
|
55
|
+
subCommands: [command$1]
|
|
56
|
+
});
|
|
57
|
+
//#endregion
|
|
58
|
+
exports.command = command;
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=agent-D83d9Pud.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-D83d9Pud.cjs","names":["command","defineCommand","agentDefaults","path","defineCommand","startCommand"],"sources":["../src/commands/agent/start.ts","../src/commands/agent.ts"],"sourcesContent":["import path from 'node:path'\nimport { defineCommand } from '@internals/utils'\nimport { version } from '../../../package.json'\nimport { agentDefaults } from '../../constants.ts'\n\nexport const command = defineCommand({\n name: 'start',\n description: 'Start the Agent server',\n options: {\n config: { type: 'string', description: 'Path to the Kubb config', short: 'c' },\n port: { type: 'string', description: `Port for the server (default: ${agentDefaults.port})`, short: 'p' },\n host: { type: 'string', description: 'Host for the server', default: agentDefaults.host },\n 'allow-write': {\n type: 'boolean',\n description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',\n default: false,\n },\n 'allow-all': { type: 'boolean', description: 'Grant all permissions (implies --allow-write).', default: false },\n },\n async run({ values }) {\n const { runAgentStart } = await import('../../runners/agent.ts')\n\n await runAgentStart({\n port: values.port !== undefined ? values.port : undefined,\n host: values.host,\n configPath: path.resolve(process.cwd(), values.config ?? agentDefaults.configFile),\n allowWrite: values['allow-write'],\n allowAll: values['allow-all'],\n version,\n })\n },\n})\n","import { defineCommand } from '@internals/utils'\nimport { command as startCommand } from './agent/start.ts'\n\nexport const command = defineCommand({\n name: 'agent',\n description: 'Manage the Kubb Agent server',\n subCommands: [startCommand],\n})\n"],"mappings":";;;;;;;AAKA,MAAaA,YAAUC,eAAAA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ;GAAE,MAAM;GAAU,aAAa;GAA2B,OAAO;GAAK;EAC9E,MAAM;GAAE,MAAM;GAAU,aAAa,iCAAiCC,kBAAAA,cAAc,KAAK;GAAI,OAAO;GAAK;EACzG,MAAM;GAAE,MAAM;GAAU,aAAa;GAAuB,SAASA,kBAAAA,cAAc;GAAM;EACzF,eAAe;GACb,MAAM;GACN,aAAa;GACb,SAAS;GACV;EACD,aAAa;GAAE,MAAM;GAAW,aAAa;GAAkD,SAAS;GAAO;EAChH;CACD,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,kBAAkB,MAAA,QAAA,SAAA,CAAA,WAAA,QAAM,uBAAA,CAAA;AAEhC,QAAM,cAAc;GAClB,MAAM,OAAO,SAAS,KAAA,IAAY,OAAO,OAAO,KAAA;GAChD,MAAM,OAAO;GACb,YAAYC,UAAAA,QAAK,QAAQ,QAAQ,KAAK,EAAE,OAAO,UAAUD,kBAAAA,cAAc,WAAW;GAClF,YAAY,OAAO;GACnB,UAAU,OAAO;GACjB,SAAA,gBAAA;GACD,CAAC;;CAEL,CAAC;;;AC5BF,MAAa,UAAUE,eAAAA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,aAAa,CAACC,UAAa;CAC5B,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { n as defineCommand } from "./define--M_JMcDC.js";
|
|
3
|
+
import { t as version } from "./package-Cbd8OC6q.js";
|
|
4
|
+
import { a as agentDefaults } from "./constants-CM3dJzjK.js";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/commands/agent.ts
|
|
8
|
+
const command = defineCommand({
|
|
9
|
+
name: "agent",
|
|
10
|
+
description: "Manage the Kubb Agent server",
|
|
11
|
+
subCommands: [defineCommand({
|
|
12
|
+
name: "start",
|
|
13
|
+
description: "Start the Agent server",
|
|
14
|
+
options: {
|
|
15
|
+
config: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Path to the Kubb config",
|
|
18
|
+
short: "c"
|
|
19
|
+
},
|
|
20
|
+
port: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: `Port for the server (default: ${agentDefaults.port})`,
|
|
23
|
+
short: "p"
|
|
24
|
+
},
|
|
25
|
+
host: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Host for the server",
|
|
28
|
+
default: agentDefaults.host
|
|
29
|
+
},
|
|
30
|
+
"allow-write": {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
description: "Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.",
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
"allow-all": {
|
|
36
|
+
type: "boolean",
|
|
37
|
+
description: "Grant all permissions (implies --allow-write).",
|
|
38
|
+
default: false
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
async run({ values }) {
|
|
42
|
+
const { runAgentStart } = await import("./agent-u_Ehwz6r.js");
|
|
43
|
+
await runAgentStart({
|
|
44
|
+
port: values.port !== void 0 ? values.port : void 0,
|
|
45
|
+
host: values.host,
|
|
46
|
+
configPath: path.resolve(process.cwd(), values.config ?? agentDefaults.configFile),
|
|
47
|
+
allowWrite: values["allow-write"],
|
|
48
|
+
allowAll: values["allow-all"],
|
|
49
|
+
version
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
54
|
+
//#endregion
|
|
55
|
+
export { command };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=agent-DgKQXSmR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-DgKQXSmR.js","names":["command","startCommand"],"sources":["../src/commands/agent/start.ts","../src/commands/agent.ts"],"sourcesContent":["import path from 'node:path'\nimport { defineCommand } from '@internals/utils'\nimport { version } from '../../../package.json'\nimport { agentDefaults } from '../../constants.ts'\n\nexport const command = defineCommand({\n name: 'start',\n description: 'Start the Agent server',\n options: {\n config: { type: 'string', description: 'Path to the Kubb config', short: 'c' },\n port: { type: 'string', description: `Port for the server (default: ${agentDefaults.port})`, short: 'p' },\n host: { type: 'string', description: 'Host for the server', default: agentDefaults.host },\n 'allow-write': {\n type: 'boolean',\n description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',\n default: false,\n },\n 'allow-all': { type: 'boolean', description: 'Grant all permissions (implies --allow-write).', default: false },\n },\n async run({ values }) {\n const { runAgentStart } = await import('../../runners/agent.ts')\n\n await runAgentStart({\n port: values.port !== undefined ? values.port : undefined,\n host: values.host,\n configPath: path.resolve(process.cwd(), values.config ?? agentDefaults.configFile),\n allowWrite: values['allow-write'],\n allowAll: values['allow-all'],\n version,\n })\n },\n})\n","import { defineCommand } from '@internals/utils'\nimport { command as startCommand } from './agent/start.ts'\n\nexport const command = defineCommand({\n name: 'agent',\n description: 'Manage the Kubb Agent server',\n subCommands: [startCommand],\n})\n"],"mappings":";;;;;;;ACGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,aAAa,CDDQ,cAAc;EACnC,MAAM;EACN,aAAa;EACb,SAAS;GACP,QAAQ;IAAE,MAAM;IAAU,aAAa;IAA2B,OAAO;IAAK;GAC9E,MAAM;IAAE,MAAM;IAAU,aAAa,iCAAiC,cAAc,KAAK;IAAI,OAAO;IAAK;GACzG,MAAM;IAAE,MAAM;IAAU,aAAa;IAAuB,SAAS,cAAc;IAAM;GACzF,eAAe;IACb,MAAM;IACN,aAAa;IACb,SAAS;IACV;GACD,aAAa;IAAE,MAAM;IAAW,aAAa;IAAkD,SAAS;IAAO;GAChH;EACD,MAAM,IAAI,EAAE,UAAU;GACpB,MAAM,EAAE,kBAAkB,MAAM,OAAO;AAEvC,SAAM,cAAc;IAClB,MAAM,OAAO,SAAS,KAAA,IAAY,OAAO,OAAO,KAAA;IAChD,MAAM,OAAO;IACb,YAAY,KAAK,QAAQ,QAAQ,KAAK,EAAE,OAAO,UAAU,cAAc,WAAW;IAClF,YAAY,OAAO;IACnB,UAAU,OAAO;IACjB;IACD,CAAC;;EAEL,CAAC,CCzB2B;CAC5B,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-DxiR7clS.js";
|
|
3
|
+
import { t as spawnAsync } from "./shell-DqqWsHCD.js";
|
|
4
|
+
import { a as agentDefaults } from "./constants-CM3dJzjK.js";
|
|
5
|
+
import { styleText } from "node:util";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import * as process$1 from "node:process";
|
|
8
|
+
import net from "node:net";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import * as clack from "@clack/prompts";
|
|
11
|
+
//#region src/runners/agent.ts
|
|
12
|
+
function isPortAvailable(port, host) {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
const server = net.createServer();
|
|
15
|
+
server.once("error", () => resolve(false));
|
|
16
|
+
server.once("listening", () => {
|
|
17
|
+
server.close();
|
|
18
|
+
resolve(true);
|
|
19
|
+
});
|
|
20
|
+
server.listen(port, host);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }) {
|
|
24
|
+
const hrStart = process$1.hrtime();
|
|
25
|
+
try {
|
|
26
|
+
try {
|
|
27
|
+
process$1.loadEnvFile();
|
|
28
|
+
} catch {}
|
|
29
|
+
const agentPkgPath = fileURLToPath(import.meta.resolve("@kubb/agent/package.json"));
|
|
30
|
+
const agentDir = path.dirname(agentPkgPath);
|
|
31
|
+
const serverPath = path.join(agentDir, agentDefaults.serverEntryPath);
|
|
32
|
+
const PORT = port !== void 0 ? port : process$1.env.PORT ?? agentDefaults.port;
|
|
33
|
+
const HOST = host !== agentDefaults.host ? host : process$1.env.HOST ?? agentDefaults.host;
|
|
34
|
+
const KUBB_AGENT_ROOT = process$1.env.KUBB_AGENT_ROOT ?? process$1.cwd();
|
|
35
|
+
const KUBB_AGENT_CONFIG = configPath !== agentDefaults.configFile ? configPath : process$1.env.KUBB_AGENT_CONFIG ?? agentDefaults.configFile;
|
|
36
|
+
const KUBB_AGENT_ALLOW_WRITE = allowAll || allowWrite ? "true" : process$1.env.KUBB_AGENT_ALLOW_WRITE ?? "false";
|
|
37
|
+
const KUBB_AGENT_ALLOW_ALL = allowAll ? "true" : process$1.env.KUBB_AGENT_ALLOW_ALL ?? "false";
|
|
38
|
+
const KUBB_AGENT_TOKEN = process$1.env.KUBB_AGENT_TOKEN;
|
|
39
|
+
const KUBB_AGENT_RETRY_TIMEOUT = process$1.env.KUBB_AGENT_RETRY_TIMEOUT ?? agentDefaults.retryTimeout;
|
|
40
|
+
const KUBB_STUDIO_URL = process$1.env.KUBB_STUDIO_URL ?? agentDefaults.studioUrl;
|
|
41
|
+
const env = {
|
|
42
|
+
...process$1.env,
|
|
43
|
+
PORT,
|
|
44
|
+
HOST,
|
|
45
|
+
KUBB_AGENT_ROOT,
|
|
46
|
+
KUBB_AGENT_CONFIG,
|
|
47
|
+
KUBB_AGENT_ALLOW_WRITE,
|
|
48
|
+
KUBB_AGENT_ALLOW_ALL,
|
|
49
|
+
KUBB_AGENT_TOKEN,
|
|
50
|
+
KUBB_AGENT_RETRY_TIMEOUT,
|
|
51
|
+
KUBB_STUDIO_URL
|
|
52
|
+
};
|
|
53
|
+
clack.log.step(styleText("cyan", "Starting agent server..."));
|
|
54
|
+
clack.log.info(styleText("dim", `Config: ${KUBB_AGENT_CONFIG}`));
|
|
55
|
+
clack.log.info(styleText("dim", `Host: ${HOST}`));
|
|
56
|
+
clack.log.info(styleText("dim", `Port: ${PORT}`));
|
|
57
|
+
if (!KUBB_AGENT_ALLOW_WRITE && !KUBB_AGENT_ALLOW_ALL) clack.log.warn(styleText("yellow", "Filesystem writes disabled. Use --allow-write or --allow-all to enable."));
|
|
58
|
+
if (!await isPortAvailable(Number(PORT), HOST)) {
|
|
59
|
+
clack.log.error(styleText("red", `Port ${PORT} is already in use. Stop the existing process or choose a different port with --port.`));
|
|
60
|
+
process$1.exit(1);
|
|
61
|
+
}
|
|
62
|
+
await spawnAsync("node", [serverPath], {
|
|
63
|
+
env,
|
|
64
|
+
cwd: process$1.cwd()
|
|
65
|
+
});
|
|
66
|
+
await sendTelemetry(buildTelemetryEvent({
|
|
67
|
+
command: "agent",
|
|
68
|
+
kubbVersion: version,
|
|
69
|
+
hrStart,
|
|
70
|
+
status: "success"
|
|
71
|
+
}));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
await sendTelemetry(buildTelemetryEvent({
|
|
74
|
+
command: "agent",
|
|
75
|
+
kubbVersion: version,
|
|
76
|
+
hrStart,
|
|
77
|
+
status: "failed"
|
|
78
|
+
}));
|
|
79
|
+
clack.log.error(styleText("red", "Failed to start agent server"));
|
|
80
|
+
console.error(error);
|
|
81
|
+
process$1.exit(1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { runAgentStart };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=agent-u_Ehwz6r.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-u_Ehwz6r.js","names":["process"],"sources":["../src/runners/agent.ts"],"sourcesContent":["import net from 'node:net'\nimport path from 'node:path'\nimport * as process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { spawnAsync } from '@internals/utils'\nimport { agentDefaults } from '../constants.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype AgentStartOptions = {\n port: string | undefined\n host: string\n configPath: string\n allowWrite: boolean\n allowAll: boolean\n version: string\n}\n\nfunction isPortAvailable(port: number, host: string): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer()\n server.once('error', () => resolve(false))\n server.once('listening', () => {\n server.close()\n resolve(true)\n })\n server.listen(port, host)\n })\n}\n\nexport async function runAgentStart({ port, host, configPath, allowWrite, allowAll, version }: AgentStartOptions): Promise<void> {\n const hrStart = process.hrtime()\n\n try {\n // Load .env file into process.env using Node.js built-in (v20.12.0+)\n try {\n process.loadEnvFile()\n } catch {\n // .env file may not exist; ignore\n }\n\n // Resolve the @kubb/agent package path\n const agentPkgUrl = import.meta.resolve('@kubb/agent/package.json')\n const agentPkgPath = fileURLToPath(agentPkgUrl)\n const agentDir = path.dirname(agentPkgPath)\n const serverPath = path.join(agentDir, agentDefaults.serverEntryPath)\n\n // CLI params take priority over process.env; process.env fills in what the CLI didn't specify;\n // agentDefaults are the last resort. Build env as: defaults ← process.env ← CLI.\n const PORT = port !== undefined ? port : (process.env.PORT ?? agentDefaults.port)\n const HOST = host !== agentDefaults.host ? host : (process.env.HOST ?? agentDefaults.host)\n const KUBB_AGENT_ROOT = process.env.KUBB_AGENT_ROOT ?? process.cwd()\n const KUBB_AGENT_CONFIG = configPath !== agentDefaults.configFile ? configPath : (process.env.KUBB_AGENT_CONFIG ?? agentDefaults.configFile)\n const KUBB_AGENT_ALLOW_WRITE = allowAll || allowWrite ? 'true' : (process.env.KUBB_AGENT_ALLOW_WRITE ?? 'false')\n const KUBB_AGENT_ALLOW_ALL = allowAll ? 'true' : (process.env.KUBB_AGENT_ALLOW_ALL ?? 'false')\n const KUBB_AGENT_TOKEN = process.env.KUBB_AGENT_TOKEN\n const KUBB_AGENT_RETRY_TIMEOUT = process.env.KUBB_AGENT_RETRY_TIMEOUT ?? agentDefaults.retryTimeout\n const KUBB_STUDIO_URL = process.env.KUBB_STUDIO_URL ?? agentDefaults.studioUrl\n\n const env = {\n ...process.env,\n PORT,\n HOST,\n KUBB_AGENT_ROOT,\n KUBB_AGENT_CONFIG,\n KUBB_AGENT_ALLOW_WRITE,\n KUBB_AGENT_ALLOW_ALL,\n KUBB_AGENT_TOKEN,\n KUBB_AGENT_RETRY_TIMEOUT,\n KUBB_STUDIO_URL,\n }\n\n clack.log.step(styleText('cyan', 'Starting agent server...'))\n clack.log.info(styleText('dim', `Config: ${KUBB_AGENT_CONFIG}`))\n clack.log.info(styleText('dim', `Host: ${HOST}`))\n clack.log.info(styleText('dim', `Port: ${PORT}`))\n if (!KUBB_AGENT_ALLOW_WRITE && !KUBB_AGENT_ALLOW_ALL) {\n clack.log.warn(styleText('yellow', 'Filesystem writes disabled. Use --allow-write or --allow-all to enable.'))\n }\n\n if (!(await isPortAvailable(Number(PORT), HOST))) {\n clack.log.error(styleText('red', `Port ${PORT} is already in use. Stop the existing process or choose a different port with --port.`))\n process.exit(1)\n }\n\n // Spawns the server as a detached background process so the CLI can exit independently.\n await spawnAsync('node', [serverPath], {\n env,\n cwd: process.cwd(),\n })\n\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'success' }))\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'agent', kubbVersion: version, hrStart, status: 'failed' }))\n clack.log.error(styleText('red', 'Failed to start agent server'))\n console.error(error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;AAmBA,SAAS,gBAAgB,MAAc,MAAgC;AACrE,QAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,SAAS,IAAI,cAAc;AACjC,SAAO,KAAK,eAAe,QAAQ,MAAM,CAAC;AAC1C,SAAO,KAAK,mBAAmB;AAC7B,UAAO,OAAO;AACd,WAAQ,KAAK;IACb;AACF,SAAO,OAAO,MAAM,KAAK;GACzB;;AAGJ,eAAsB,cAAc,EAAE,MAAM,MAAM,YAAY,YAAY,UAAU,WAA6C;CAC/H,MAAM,UAAUA,UAAQ,QAAQ;AAEhC,KAAI;AAEF,MAAI;AACF,aAAQ,aAAa;UACf;EAMR,MAAM,eAAe,cADD,OAAO,KAAK,QAAQ,2BAA2B,CACpB;EAC/C,MAAM,WAAW,KAAK,QAAQ,aAAa;EAC3C,MAAM,aAAa,KAAK,KAAK,UAAU,cAAc,gBAAgB;EAIrE,MAAM,OAAO,SAAS,KAAA,IAAY,OAAQA,UAAQ,IAAI,QAAQ,cAAc;EAC5E,MAAM,OAAO,SAAS,cAAc,OAAO,OAAQA,UAAQ,IAAI,QAAQ,cAAc;EACrF,MAAM,kBAAkBA,UAAQ,IAAI,mBAAmBA,UAAQ,KAAK;EACpE,MAAM,oBAAoB,eAAe,cAAc,aAAa,aAAcA,UAAQ,IAAI,qBAAqB,cAAc;EACjI,MAAM,yBAAyB,YAAY,aAAa,SAAUA,UAAQ,IAAI,0BAA0B;EACxG,MAAM,uBAAuB,WAAW,SAAUA,UAAQ,IAAI,wBAAwB;EACtF,MAAM,mBAAmBA,UAAQ,IAAI;EACrC,MAAM,2BAA2BA,UAAQ,IAAI,4BAA4B,cAAc;EACvF,MAAM,kBAAkBA,UAAQ,IAAI,mBAAmB,cAAc;EAErE,MAAM,MAAM;GACV,GAAGA,UAAQ;GACX;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;AAED,QAAM,IAAI,KAAK,UAAU,QAAQ,2BAA2B,CAAC;AAC7D,QAAM,IAAI,KAAK,UAAU,OAAO,WAAW,oBAAoB,CAAC;AAChE,QAAM,IAAI,KAAK,UAAU,OAAO,SAAS,OAAO,CAAC;AACjD,QAAM,IAAI,KAAK,UAAU,OAAO,SAAS,OAAO,CAAC;AACjD,MAAI,CAAC,0BAA0B,CAAC,qBAC9B,OAAM,IAAI,KAAK,UAAU,UAAU,0EAA0E,CAAC;AAGhH,MAAI,CAAE,MAAM,gBAAgB,OAAO,KAAK,EAAE,KAAK,EAAG;AAChD,SAAM,IAAI,MAAM,UAAU,OAAO,QAAQ,KAAK,uFAAuF,CAAC;AACtI,aAAQ,KAAK,EAAE;;AAIjB,QAAM,WAAW,QAAQ,CAAC,WAAW,EAAE;GACrC;GACA,KAAKA,UAAQ,KAAK;GACnB,CAAC;AAEF,QAAM,cAAc,oBAAoB;GAAE,SAAS;GAAS,aAAa;GAAS;GAAS,QAAQ;GAAW,CAAC,CAAC;UACzG,OAAO;AACd,QAAM,cAAc,oBAAoB;GAAE,SAAS;GAAS,aAAa;GAAS;GAAS,QAAQ;GAAU,CAAC,CAAC;AAC/G,QAAM,IAAI,MAAM,UAAU,OAAO,+BAA+B,CAAC;AACjE,UAAQ,MAAM,MAAM;AACpB,YAAQ,KAAK,EAAE"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
/** NPM registry endpoint used to check for @kubb/cli updates. */
|
|
3
|
+
const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
|
|
4
|
+
/** OpenTelemetry ingestion endpoint for anonymous usage telemetry. */
|
|
5
|
+
const OTLP_ENDPOINT = "https://otlp.kubb.dev";
|
|
6
|
+
/** Horizontal rule rendered above/below the plain-logger generation summary. */
|
|
7
|
+
const SUMMARY_SEPARATOR = "─".repeat(27);
|
|
8
|
+
/** Glob pattern for paths the file watcher ignores. */
|
|
9
|
+
const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
|
|
10
|
+
/** Default runtime values for the `agent start` command. */
|
|
11
|
+
const agentDefaults = {
|
|
12
|
+
port: "3000",
|
|
13
|
+
host: "localhost",
|
|
14
|
+
configFile: "kubb.config.ts",
|
|
15
|
+
retryTimeout: "30000",
|
|
16
|
+
studioUrl: "https://studio.kubb.dev",
|
|
17
|
+
serverEntryPath: ".output/server/index.mjs"
|
|
18
|
+
};
|
|
19
|
+
/** Default values used during interactive `init` scaffolding. */
|
|
20
|
+
const initDefaults = {
|
|
21
|
+
inputPath: "./openapi.yaml",
|
|
22
|
+
outputPath: "./src/gen",
|
|
23
|
+
plugins: ["plugin-oas", "plugin-ts"]
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Maps each plugin value to the default config snippet inserted by `init`.
|
|
27
|
+
* The `satisfies` constraint ensures all values remain plain strings while
|
|
28
|
+
* `as const` keeps the object deeply immutable.
|
|
29
|
+
*/
|
|
30
|
+
const pluginDefaultConfigs = {
|
|
31
|
+
"plugin-oas": "pluginOas()",
|
|
32
|
+
"plugin-ts": `pluginTs({
|
|
33
|
+
output: { path: 'models' },
|
|
34
|
+
})`,
|
|
35
|
+
"plugin-client": `pluginClient({
|
|
36
|
+
output: { path: 'clients' },
|
|
37
|
+
})`,
|
|
38
|
+
"plugin-react-query": `pluginReactQuery({
|
|
39
|
+
output: { path: 'hooks' },
|
|
40
|
+
})`,
|
|
41
|
+
"plugin-solid-query": `pluginSolidQuery({
|
|
42
|
+
output: { path: 'hooks' },
|
|
43
|
+
})`,
|
|
44
|
+
"plugin-svelte-query": `pluginSvelteQuery({
|
|
45
|
+
output: { path: 'hooks' },
|
|
46
|
+
})`,
|
|
47
|
+
"plugin-vue-query": `pluginVueQuery({
|
|
48
|
+
output: { path: 'hooks' },
|
|
49
|
+
})`,
|
|
50
|
+
"plugin-swr": `pluginSwr({
|
|
51
|
+
output: { path: 'hooks' },
|
|
52
|
+
})`,
|
|
53
|
+
"plugin-zod": `pluginZod({
|
|
54
|
+
output: { path: 'zod' },
|
|
55
|
+
})`,
|
|
56
|
+
"plugin-faker": `pluginFaker({
|
|
57
|
+
output: { path: 'mocks' },
|
|
58
|
+
})`,
|
|
59
|
+
"plugin-msw": `pluginMsw({
|
|
60
|
+
output: { path: 'msw' },
|
|
61
|
+
})`
|
|
62
|
+
};
|
|
63
|
+
/** Color palette used by randomCliColor() for deterministic plugin name coloring. */
|
|
64
|
+
//#endregion
|
|
65
|
+
Object.defineProperty(exports, "KUBB_NPM_PACKAGE_URL", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function() {
|
|
68
|
+
return KUBB_NPM_PACKAGE_URL;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(exports, "OTLP_ENDPOINT", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function() {
|
|
74
|
+
return OTLP_ENDPOINT;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, "SUMMARY_SEPARATOR", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function() {
|
|
80
|
+
return SUMMARY_SEPARATOR;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(exports, "WATCHER_IGNORED_PATHS", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function() {
|
|
86
|
+
return WATCHER_IGNORED_PATHS;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "agentDefaults", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function() {
|
|
92
|
+
return agentDefaults;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(exports, "initDefaults", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function() {
|
|
98
|
+
return initDefaults;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(exports, "pluginDefaultConfigs", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function() {
|
|
104
|
+
return pluginDefaultConfigs;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=constants-BTUap0zs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-BTUap0zs.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/** NPM registry endpoint used to check for @kubb/cli updates. */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** OpenTelemetry ingestion endpoint for anonymous usage telemetry. */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\n/** Horizontal rule rendered above/below the plain-logger generation summary. */\nexport const SUMMARY_SEPARATOR = '─'.repeat(27)\n\n/** Maximum number of █ characters in a plugin timing bar. */\nexport const SUMMARY_MAX_BAR_LENGTH = 10 as const\n\n/** Divides elapsed milliseconds into bar-length units (1 block per 100 ms). */\nexport const SUMMARY_TIME_SCALE_DIVISOR = 100 as const\n\n/** Glob pattern for paths the file watcher ignores. */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/** Default runtime values for the `agent start` command. */\nexport const agentDefaults = {\n port: '3000',\n host: 'localhost',\n configFile: 'kubb.config.ts',\n retryTimeout: '30000',\n studioUrl: 'https://studio.kubb.dev',\n /** Relative path from the @kubb/agent package root to the server entry. */\n serverEntryPath: '.output/server/index.mjs',\n} as const\n\n/** Default values used during interactive `init` scaffolding. */\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-oas', 'plugin-ts'],\n} as const\n\n/**\n * Maps each plugin value to the default config snippet inserted by `init`.\n * The `satisfies` constraint ensures all values remain plain strings while\n * `as const` keeps the object deeply immutable.\n */\nexport const pluginDefaultConfigs = {\n 'plugin-oas': 'pluginOas()',\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-solid-query': `pluginSolidQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-svelte-query': `pluginSvelteQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-vue-query': `pluginVueQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-swr': `pluginSwr({\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} as const satisfies Record<string, string>\n\n/** Color palette used by randomCliColor() for deterministic plugin name coloring. */\n"],"mappings":";;AACA,MAAa,uBAAuB;;AAGpC,MAAa,gBAAgB;;AAG7B,MAAa,oBAAoB,IAAI,OAAO,GAAG;;AAS/C,MAAa,wBAAwB;;AAGrC,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,YAAY;CACZ,cAAc;CACd,WAAW;CAEX,iBAAiB;CAClB;;AAGD,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,cAAc,YAAY;CACrC;;;;;;AAOD,MAAa,uBAAuB;CAClC,cAAc;CACd,aAAa;;;CAGb,iBAAiB;;;CAGjB,sBAAsB;;;CAGtB,sBAAsB;;;CAGtB,uBAAuB;;;CAGvB,oBAAoB;;;CAGpB,cAAc;;;CAGd,cAAc;;;CAGd,gBAAgB;;;CAGhB,cAAc;;;CAGf"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
/** NPM registry endpoint used to check for @kubb/cli updates. */
|
|
3
|
+
const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
|
|
4
|
+
/** OpenTelemetry ingestion endpoint for anonymous usage telemetry. */
|
|
5
|
+
const OTLP_ENDPOINT = "https://otlp.kubb.dev";
|
|
6
|
+
/** Horizontal rule rendered above/below the plain-logger generation summary. */
|
|
7
|
+
const SUMMARY_SEPARATOR = "─".repeat(27);
|
|
8
|
+
/** Glob pattern for paths the file watcher ignores. */
|
|
9
|
+
const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
|
|
10
|
+
/** Default runtime values for the `agent start` command. */
|
|
11
|
+
const agentDefaults = {
|
|
12
|
+
port: "3000",
|
|
13
|
+
host: "localhost",
|
|
14
|
+
configFile: "kubb.config.ts",
|
|
15
|
+
retryTimeout: "30000",
|
|
16
|
+
studioUrl: "https://studio.kubb.dev",
|
|
17
|
+
serverEntryPath: ".output/server/index.mjs"
|
|
18
|
+
};
|
|
19
|
+
/** Default values used during interactive `init` scaffolding. */
|
|
20
|
+
const initDefaults = {
|
|
21
|
+
inputPath: "./openapi.yaml",
|
|
22
|
+
outputPath: "./src/gen",
|
|
23
|
+
plugins: ["plugin-oas", "plugin-ts"]
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Maps each plugin value to the default config snippet inserted by `init`.
|
|
27
|
+
* The `satisfies` constraint ensures all values remain plain strings while
|
|
28
|
+
* `as const` keeps the object deeply immutable.
|
|
29
|
+
*/
|
|
30
|
+
const pluginDefaultConfigs = {
|
|
31
|
+
"plugin-oas": "pluginOas()",
|
|
32
|
+
"plugin-ts": `pluginTs({
|
|
33
|
+
output: { path: 'models' },
|
|
34
|
+
})`,
|
|
35
|
+
"plugin-client": `pluginClient({
|
|
36
|
+
output: { path: 'clients' },
|
|
37
|
+
})`,
|
|
38
|
+
"plugin-react-query": `pluginReactQuery({
|
|
39
|
+
output: { path: 'hooks' },
|
|
40
|
+
})`,
|
|
41
|
+
"plugin-solid-query": `pluginSolidQuery({
|
|
42
|
+
output: { path: 'hooks' },
|
|
43
|
+
})`,
|
|
44
|
+
"plugin-svelte-query": `pluginSvelteQuery({
|
|
45
|
+
output: { path: 'hooks' },
|
|
46
|
+
})`,
|
|
47
|
+
"plugin-vue-query": `pluginVueQuery({
|
|
48
|
+
output: { path: 'hooks' },
|
|
49
|
+
})`,
|
|
50
|
+
"plugin-swr": `pluginSwr({
|
|
51
|
+
output: { path: 'hooks' },
|
|
52
|
+
})`,
|
|
53
|
+
"plugin-zod": `pluginZod({
|
|
54
|
+
output: { path: 'zod' },
|
|
55
|
+
})`,
|
|
56
|
+
"plugin-faker": `pluginFaker({
|
|
57
|
+
output: { path: 'mocks' },
|
|
58
|
+
})`,
|
|
59
|
+
"plugin-msw": `pluginMsw({
|
|
60
|
+
output: { path: 'msw' },
|
|
61
|
+
})`
|
|
62
|
+
};
|
|
63
|
+
/** Color palette used by randomCliColor() for deterministic plugin name coloring. */
|
|
64
|
+
//#endregion
|
|
65
|
+
export { agentDefaults as a, WATCHER_IGNORED_PATHS as i, OTLP_ENDPOINT as n, initDefaults as o, SUMMARY_SEPARATOR as r, pluginDefaultConfigs as s, KUBB_NPM_PACKAGE_URL as t };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=constants-CM3dJzjK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-CM3dJzjK.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/** NPM registry endpoint used to check for @kubb/cli updates. */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** OpenTelemetry ingestion endpoint for anonymous usage telemetry. */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\n/** Horizontal rule rendered above/below the plain-logger generation summary. */\nexport const SUMMARY_SEPARATOR = '─'.repeat(27)\n\n/** Maximum number of █ characters in a plugin timing bar. */\nexport const SUMMARY_MAX_BAR_LENGTH = 10 as const\n\n/** Divides elapsed milliseconds into bar-length units (1 block per 100 ms). */\nexport const SUMMARY_TIME_SCALE_DIVISOR = 100 as const\n\n/** Glob pattern for paths the file watcher ignores. */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/** Default runtime values for the `agent start` command. */\nexport const agentDefaults = {\n port: '3000',\n host: 'localhost',\n configFile: 'kubb.config.ts',\n retryTimeout: '30000',\n studioUrl: 'https://studio.kubb.dev',\n /** Relative path from the @kubb/agent package root to the server entry. */\n serverEntryPath: '.output/server/index.mjs',\n} as const\n\n/** Default values used during interactive `init` scaffolding. */\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-oas', 'plugin-ts'],\n} as const\n\n/**\n * Maps each plugin value to the default config snippet inserted by `init`.\n * The `satisfies` constraint ensures all values remain plain strings while\n * `as const` keeps the object deeply immutable.\n */\nexport const pluginDefaultConfigs = {\n 'plugin-oas': 'pluginOas()',\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-solid-query': `pluginSolidQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-svelte-query': `pluginSvelteQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-vue-query': `pluginVueQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-swr': `pluginSwr({\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} as const satisfies Record<string, string>\n\n/** Color palette used by randomCliColor() for deterministic plugin name coloring. */\n"],"mappings":";;AACA,MAAa,uBAAuB;;AAGpC,MAAa,gBAAgB;;AAG7B,MAAa,oBAAoB,IAAI,OAAO,GAAG;;AAS/C,MAAa,wBAAwB;;AAGrC,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,YAAY;CACZ,cAAc;CACd,WAAW;CAEX,iBAAiB;CAClB;;AAGD,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,cAAc,YAAY;CACrC;;;;;;AAOD,MAAa,uBAAuB;CAClC,cAAc;CACd,aAAa;;;CAGb,iBAAiB;;;CAGjB,sBAAsB;;;CAGtB,sBAAsB;;;CAGtB,uBAAuB;;;CAGvB,oBAAoB;;;CAGpB,cAAc;;;CAGd,cAAc;;;CAGd,gBAAgB;;;CAGhB,cAAc;;;CAGf"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
//#region ../../internals/utils/src/cli/define.ts
|
|
3
|
+
/** Returns a `CLIAdapter` with type inference. Pass a different adapter to `createCLI` to swap the CLI engine. */
|
|
4
|
+
function defineCLIAdapter(adapter) {
|
|
5
|
+
return adapter;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns a `CommandDefinition` with typed `values` in `run()`.
|
|
9
|
+
* The callback receives `values` typed from the declared options — no casts needed.
|
|
10
|
+
*/
|
|
11
|
+
function defineCommand(def) {
|
|
12
|
+
const { run, ...rest } = def;
|
|
13
|
+
if (!run) return rest;
|
|
14
|
+
return {
|
|
15
|
+
...rest,
|
|
16
|
+
run: (args) => run({
|
|
17
|
+
values: args.values,
|
|
18
|
+
positionals: args.positionals
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { defineCommand as n, defineCLIAdapter as t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=define--M_JMcDC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define--M_JMcDC.js","names":[],"sources":["../../../internals/utils/src/cli/define.ts"],"sourcesContent":["import type { CLIAdapter, CommandDefinition, OptionDefinition } from './types.ts'\n\ntype OptionTypeMap = { string: string; boolean: boolean }\n\ntype IsRequired<O extends OptionDefinition> = O['default'] extends string | boolean ? true : O['required'] extends true ? true : false\n\n/** Infers typed values from an options record. Options with a `default` or `required: true` are always defined. */\ntype InferValues<O extends Record<string, OptionDefinition>> = {\n [K in keyof O as IsRequired<O[K]> extends true ? K : never]: OptionTypeMap[O[K]['type']]\n} & {\n [K in keyof O as IsRequired<O[K]> extends true ? never : K]?: OptionTypeMap[O[K]['type']]\n}\n\n/** Returns a `CLIAdapter` with type inference. Pass a different adapter to `createCLI` to swap the CLI engine. */\nexport function defineCLIAdapter(adapter: CLIAdapter): CLIAdapter {\n return adapter\n}\n\n/**\n * Returns a `CommandDefinition` with typed `values` in `run()`.\n * The callback receives `values` typed from the declared options — no casts needed.\n */\nexport function defineCommand<O extends Record<string, OptionDefinition>>(def: {\n name: string\n description: string\n arguments?: string[]\n options?: O\n subCommands?: CommandDefinition[]\n run?: (args: { values: InferValues<O>; positionals: string[] }) => Promise<void>\n}): CommandDefinition {\n const { run, ...rest } = def\n if (!run) return rest\n return {\n ...rest,\n run: (args) => run({ values: args.values as InferValues<O>, positionals: args.positionals }),\n }\n}\n"],"mappings":";;;AAcA,SAAgB,iBAAiB,SAAiC;AAChE,QAAO;;;;;;AAOT,SAAgB,cAA0D,KAOpD;CACpB,MAAM,EAAE,KAAK,GAAG,SAAS;AACzB,KAAI,CAAC,IAAK,QAAO;AACjB,QAAO;EACL,GAAG;EACH,MAAM,SAAS,IAAI;GAAE,QAAQ,KAAK;GAA0B,aAAa,KAAK;GAAa,CAAC;EAC7F"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require("./chunk-ByKO4r7w.cjs");
|
|
2
|
+
//#region ../../internals/utils/src/cli/define.ts
|
|
3
|
+
/** Returns a `CLIAdapter` with type inference. Pass a different adapter to `createCLI` to swap the CLI engine. */
|
|
4
|
+
function defineCLIAdapter(adapter) {
|
|
5
|
+
return adapter;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns a `CommandDefinition` with typed `values` in `run()`.
|
|
9
|
+
* The callback receives `values` typed from the declared options — no casts needed.
|
|
10
|
+
*/
|
|
11
|
+
function defineCommand(def) {
|
|
12
|
+
const { run, ...rest } = def;
|
|
13
|
+
if (!run) return rest;
|
|
14
|
+
return {
|
|
15
|
+
...rest,
|
|
16
|
+
run: (args) => run({
|
|
17
|
+
values: args.values,
|
|
18
|
+
positionals: args.positionals
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
Object.defineProperty(exports, "defineCLIAdapter", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return defineCLIAdapter;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "defineCommand", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function() {
|
|
32
|
+
return defineCommand;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=define-D6Kfm7-Z.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-D6Kfm7-Z.cjs","names":[],"sources":["../../../internals/utils/src/cli/define.ts"],"sourcesContent":["import type { CLIAdapter, CommandDefinition, OptionDefinition } from './types.ts'\n\ntype OptionTypeMap = { string: string; boolean: boolean }\n\ntype IsRequired<O extends OptionDefinition> = O['default'] extends string | boolean ? true : O['required'] extends true ? true : false\n\n/** Infers typed values from an options record. Options with a `default` or `required: true` are always defined. */\ntype InferValues<O extends Record<string, OptionDefinition>> = {\n [K in keyof O as IsRequired<O[K]> extends true ? K : never]: OptionTypeMap[O[K]['type']]\n} & {\n [K in keyof O as IsRequired<O[K]> extends true ? never : K]?: OptionTypeMap[O[K]['type']]\n}\n\n/** Returns a `CLIAdapter` with type inference. Pass a different adapter to `createCLI` to swap the CLI engine. */\nexport function defineCLIAdapter(adapter: CLIAdapter): CLIAdapter {\n return adapter\n}\n\n/**\n * Returns a `CommandDefinition` with typed `values` in `run()`.\n * The callback receives `values` typed from the declared options — no casts needed.\n */\nexport function defineCommand<O extends Record<string, OptionDefinition>>(def: {\n name: string\n description: string\n arguments?: string[]\n options?: O\n subCommands?: CommandDefinition[]\n run?: (args: { values: InferValues<O>; positionals: string[] }) => Promise<void>\n}): CommandDefinition {\n const { run, ...rest } = def\n if (!run) return rest\n return {\n ...rest,\n run: (args) => run({ values: args.values as InferValues<O>, positionals: args.positionals }),\n }\n}\n"],"mappings":";;;AAcA,SAAgB,iBAAiB,SAAiC;AAChE,QAAO;;;;;;AAOT,SAAgB,cAA0D,KAOpD;CACpB,MAAM,EAAE,KAAK,GAAG,SAAS;AACzB,KAAI,CAAC,IAAK,QAAO;AACjB,QAAO;EACL,GAAG;EACH,MAAM,SAAS,IAAI;GAAE,QAAQ,KAAK;GAA0B,aAAa,KAAK;GAAa,CAAC;EAC7F"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
//#region ../../internals/utils/src/errors.ts
|
|
3
|
+
/**
|
|
4
|
+
* Coerces an unknown thrown value to an `Error` instance.
|
|
5
|
+
* When the value is already an `Error` it is returned as-is;
|
|
6
|
+
* otherwise a new `Error` is created whose message is `String(value)`.
|
|
7
|
+
*/
|
|
8
|
+
function toError(value) {
|
|
9
|
+
return value instanceof Error ? value : new Error(String(value));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Safely extracts a human-readable message from any thrown value.
|
|
13
|
+
*/
|
|
14
|
+
function getErrorMessage(value) {
|
|
15
|
+
return value instanceof Error ? value.message : String(value);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Extracts the `.cause` of an `Error` as an `Error | undefined`.
|
|
19
|
+
* Returns `undefined` when the cause is absent or is not an `Error`.
|
|
20
|
+
*/
|
|
21
|
+
function toCause(error) {
|
|
22
|
+
return error.cause instanceof Error ? error.cause : void 0;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { toCause as n, toError as r, getErrorMessage as t };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=errors-6mF_WKxg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-6mF_WKxg.js","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/** Thrown when a plugin's configuration or input fails validation. */\nexport class ValidationPluginError extends Error {}\n\n/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * When the value is already an `Error` it is returned as-is;\n * otherwise a new `Error` is created whose message is `String(value)`.\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Safely extracts a human-readable message from any thrown value.\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error | undefined`.\n * Returns `undefined` when the cause is absent or is not an `Error`.\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,QAAQ,OAAuB;AAC7C,QAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;;;;;AAMlE,SAAgB,gBAAgB,OAAwB;AACtD,QAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;;;;;;AAO/D,SAAgB,QAAQ,OAAiC;AACvD,QAAO,MAAM,iBAAiB,QAAQ,MAAM,QAAQ,KAAA"}
|