@kubb/cli 5.0.0-beta.8 → 5.0.0-beta.80
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 +48 -79
- package/bin/kubb.js +9 -3
- package/dist/Telemetry-jtbchpQE.cjs +315 -0
- package/dist/Telemetry-jtbchpQE.cjs.map +1 -0
- package/dist/Telemetry-ugO-B77y.js +284 -0
- package/dist/Telemetry-ugO-B77y.js.map +1 -0
- package/dist/{define-Bdn8j5VM.cjs → defineCommand-Bo3yZTWI.cjs} +3 -21
- package/dist/defineCommand-Bo3yZTWI.cjs.map +1 -0
- package/dist/{define-m_fp-Aqm.js → defineCommand-DMEeqliP.js} +4 -16
- package/dist/defineCommand-DMEeqliP.js.map +1 -0
- package/dist/{errors-CINO1EIv.js → errors-Dc_d7BfX.js} +2 -2
- package/dist/{errors-CINO1EIv.js.map → errors-Dc_d7BfX.js.map} +1 -1
- package/dist/{errors-CLCjoSg0.cjs → errors-gxFK0vrp.cjs} +2 -2
- package/dist/{errors-CLCjoSg0.cjs.map → errors-gxFK0vrp.cjs.map} +1 -1
- package/dist/{generate-DzC1brc9.js → generate-BlZcYrow.js} +21 -16
- package/dist/generate-BlZcYrow.js.map +1 -0
- package/dist/{generate-CiBa5UMJ.cjs → generate-Cjdgf9Z6.cjs} +21 -16
- package/dist/generate-Cjdgf9Z6.cjs.map +1 -0
- package/dist/index.cjs +87 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +87 -152
- package/dist/index.js.map +1 -1
- package/dist/{init-BVYkUQ-b.cjs → init-CUizzH-m.cjs} +8 -8
- package/dist/init-CUizzH-m.cjs.map +1 -0
- package/dist/{init-BYlb-ua0.js → init-VzGkYfCD.js} +7 -7
- package/dist/init-VzGkYfCD.js.map +1 -0
- package/dist/mcp-Cx_R7N4Y.js +21 -0
- package/dist/mcp-Cx_R7N4Y.js.map +1 -0
- package/dist/mcp-D-U9peKl.cjs +21 -0
- package/dist/mcp-D-U9peKl.cjs.map +1 -0
- package/dist/package-CfrcA3AM.js +6 -0
- package/dist/package-CfrcA3AM.js.map +1 -0
- package/dist/{package-BvBzYG6c.cjs → package-D4dpxvXZ.cjs} +2 -2
- package/dist/package-D4dpxvXZ.cjs.map +1 -0
- package/dist/{chunk-BvFE5Tac.js → rolldown-runtime-C0LytTxp.js} +0 -1
- package/dist/{run-CF97BWVa.js → run-44Zxh8Ec.js} +130 -85
- package/dist/run-44Zxh8Ec.js.map +1 -0
- package/dist/run-BBLhhWZu.js +32 -0
- package/dist/run-BBLhhWZu.js.map +1 -0
- package/dist/run-Bz6ZUrhp.cjs +33 -0
- package/dist/run-Bz6ZUrhp.cjs.map +1 -0
- package/dist/{run-CCZ24VKk.js → run-CPBFfbI7.js} +5 -5
- package/dist/run-CPBFfbI7.js.map +1 -0
- package/dist/run-Cb40ABb_.js +1323 -0
- package/dist/run-Cb40ABb_.js.map +1 -0
- package/dist/run-Csyo6UFC.cjs +1326 -0
- package/dist/run-Csyo6UFC.cjs.map +1 -0
- package/dist/{run-YsoCk5we.cjs → run-DXEMoDFa.cjs} +143 -98
- package/dist/run-DXEMoDFa.cjs.map +1 -0
- package/dist/{run-CQbj3ley.cjs → run-DYkciQ4u.cjs} +6 -6
- package/dist/run-DYkciQ4u.cjs.map +1 -0
- package/dist/tools-CZT9wSA6.cjs +175 -0
- package/dist/tools-CZT9wSA6.cjs.map +1 -0
- package/dist/tools-D0UogMU3.js +152 -0
- package/dist/tools-D0UogMU3.js.map +1 -0
- package/dist/{validate-BYuHYBhg.cjs → validate-BbsWghwr.cjs} +6 -6
- package/dist/{validate-BYuHYBhg.cjs.map → validate-BbsWghwr.cjs.map} +1 -1
- package/dist/{validate-Da2LIDVc.js → validate-DhoFtPVz.js} +5 -5
- package/dist/{validate-Da2LIDVc.js.map → validate-DhoFtPVz.js.map} +1 -1
- package/package.json +13 -25
- package/dist/agent-DPLjUza1.cjs +0 -70
- package/dist/agent-DPLjUza1.cjs.map +0 -1
- package/dist/agent-DTeGTNl7.js +0 -68
- package/dist/agent-DTeGTNl7.js.map +0 -1
- package/dist/constants-B2JTeRBb.js +0 -42
- package/dist/constants-B2JTeRBb.js.map +0 -1
- package/dist/constants-BINTA5VZ.cjs +0 -77
- package/dist/constants-BINTA5VZ.cjs.map +0 -1
- package/dist/constants-BYGmiFs0.cjs +0 -139
- package/dist/constants-BYGmiFs0.cjs.map +0 -1
- package/dist/constants-DSJ-Xrbv.js +0 -116
- package/dist/constants-DSJ-Xrbv.js.map +0 -1
- package/dist/define-Bdn8j5VM.cjs.map +0 -1
- package/dist/define-m_fp-Aqm.js.map +0 -1
- package/dist/generate-CiBa5UMJ.cjs.map +0 -1
- package/dist/generate-DzC1brc9.js.map +0 -1
- package/dist/init-BVYkUQ-b.cjs.map +0 -1
- package/dist/init-BYlb-ua0.js.map +0 -1
- package/dist/mcp-Bm2Q7YdS.js +0 -39
- package/dist/mcp-Bm2Q7YdS.js.map +0 -1
- package/dist/mcp-CiNoagVX.cjs +0 -39
- package/dist/mcp-CiNoagVX.cjs.map +0 -1
- package/dist/package-BvBzYG6c.cjs.map +0 -1
- package/dist/package-s8PvCnk-.js +0 -6
- package/dist/package-s8PvCnk-.js.map +0 -1
- package/dist/run-BzpYYOQs.js +0 -121
- package/dist/run-BzpYYOQs.js.map +0 -1
- package/dist/run-CCZ24VKk.js.map +0 -1
- package/dist/run-CF97BWVa.js.map +0 -1
- package/dist/run-CQbj3ley.cjs.map +0 -1
- package/dist/run-CXTVu3Wl.js +0 -1738
- package/dist/run-CXTVu3Wl.js.map +0 -1
- package/dist/run-D0hmRpHy.js +0 -49
- package/dist/run-D0hmRpHy.js.map +0 -1
- package/dist/run-DwdAwnLG.cjs +0 -125
- package/dist/run-DwdAwnLG.cjs.map +0 -1
- package/dist/run-Lr0Ctnu0.cjs +0 -50
- package/dist/run-Lr0Ctnu0.cjs.map +0 -1
- package/dist/run-QyqW2rPC.cjs +0 -1741
- package/dist/run-QyqW2rPC.cjs.map +0 -1
- package/dist/run-YsoCk5we.cjs.map +0 -1
- package/dist/shell-475fQKaX.cjs +0 -62
- package/dist/shell-475fQKaX.cjs.map +0 -1
- package/dist/shell-CN6DNqeC.js +0 -51
- package/dist/shell-CN6DNqeC.js.map +0 -1
- package/dist/telemetry-B2iWkY5e.cjs +0 -280
- package/dist/telemetry-B2iWkY5e.cjs.map +0 -1
- package/dist/telemetry-BkektVz6.js +0 -243
- package/dist/telemetry-BkektVz6.js.map +0 -1
- package/src/commands/agent/start.ts +0 -50
- package/src/commands/agent.ts +0 -10
- package/src/commands/generate.ts +0 -59
- package/src/commands/init.ts +0 -51
- package/src/commands/mcp.ts +0 -36
- package/src/commands/validate.ts +0 -22
- package/src/constants.ts +0 -48
- package/src/index.ts +0 -45
- package/src/loggers/clackLogger.ts +0 -460
- package/src/loggers/fileSystemLogger.ts +0 -151
- package/src/loggers/githubActionsLogger.ts +0 -367
- package/src/loggers/plainLogger.ts +0 -243
- package/src/loggers/types.ts +0 -7
- package/src/loggers/utils.ts +0 -252
- package/src/runners/agent/run.ts +0 -113
- package/src/runners/agent/utils.ts +0 -98
- package/src/runners/generate/run.ts +0 -276
- package/src/runners/generate/utils.ts +0 -209
- package/src/runners/init/run.ts +0 -211
- package/src/runners/init/utils.ts +0 -33
- package/src/runners/mcp/run.ts +0 -55
- package/src/runners/validate/run.ts +0 -63
- package/src/telemetry.ts +0 -280
- /package/dist/{chunk-ByKO4r7w.cjs → rolldown-runtime-Bx3C2hgW.cjs} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_errors = require("./errors-
|
|
3
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
+
const require_errors = require("./errors-gxFK0vrp.cjs");
|
|
3
|
+
const require_Telemetry = require("./Telemetry-jtbchpQE.cjs");
|
|
4
4
|
let node_util = require("node:util");
|
|
5
5
|
let node_process = require("node:process");
|
|
6
|
-
node_process =
|
|
6
|
+
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
7
7
|
//#region src/runners/validate/run.ts
|
|
8
8
|
/**
|
|
9
9
|
* Dynamically loads `@kubb/adapter-oas` for OpenAPI validation.
|
|
@@ -17,7 +17,7 @@ function loadValidateModule() {
|
|
|
17
17
|
*/
|
|
18
18
|
async function run({ input, version }, dependencies = { loadValidateModule }) {
|
|
19
19
|
const hrStart = node_process.default.hrtime();
|
|
20
|
-
const report = (status) =>
|
|
20
|
+
const report = (status) => require_Telemetry.Telemetry.send(require_Telemetry.Telemetry.build({
|
|
21
21
|
command: "validate",
|
|
22
22
|
kubbVersion: version,
|
|
23
23
|
hrStart,
|
|
@@ -49,4 +49,4 @@ async function run({ input, version }, dependencies = { loadValidateModule }) {
|
|
|
49
49
|
//#endregion
|
|
50
50
|
exports.run = run;
|
|
51
51
|
|
|
52
|
-
//# sourceMappingURL=run-
|
|
52
|
+
//# sourceMappingURL=run-DYkciQ4u.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-DYkciQ4u.cjs","names":["process","Telemetry","getErrorMessage"],"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 '../../Telemetry.ts'\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,UAAUA,aAAAA,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiCC,kBAAAA,UAAU,KAAKA,kBAAAA,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,OAAA,GAAA,UAAA,UAAA,CAAgB,OAAO,iDAAiD,CAAC;GACjF,QAAQ,MAAM,EAAE;GAChB,QAAQ,MAAM,kBAAkB;GAChC,QAAQ,OAAA,GAAA,UAAA,UAAA,CAAgB,QAAQ,iCAAiC,CAAC;GAClE,QAAQ,OAAA,GAAA,UAAA,UAAA,CAAgB,QAAQ,QAAQ,CAAC;GACzC,QAAQ,OAAA,GAAA,UAAA,UAAA,CAAgB,QAAQ,kCAAkC,CAAC;GACnE,QAAQ,MAAM,EAAE;EAClB;EACA,QAAQ,MAAM,qBAAqB;EACnC,QAAQ,MAAMC,eAAAA,gBAAgB,KAAK,CAAC;EACpC,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
+
let node_child_process = require("node:child_process");
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
//#region ../../internals/utils/src/tools.ts
|
|
6
|
+
/**
|
|
7
|
+
* CLI command descriptors for each supported code formatter.
|
|
8
|
+
*
|
|
9
|
+
* Each entry contains the executable `command`, an `args` factory that maps an
|
|
10
|
+
* output path to the correct argument list, and an `errorMessage` shown when
|
|
11
|
+
* the formatter is not found.
|
|
12
|
+
*/
|
|
13
|
+
const formatters = {
|
|
14
|
+
prettier: {
|
|
15
|
+
command: "prettier",
|
|
16
|
+
args: (outputPath) => [
|
|
17
|
+
"--ignore-unknown",
|
|
18
|
+
"--write",
|
|
19
|
+
outputPath
|
|
20
|
+
],
|
|
21
|
+
errorMessage: "Prettier not found"
|
|
22
|
+
},
|
|
23
|
+
biome: {
|
|
24
|
+
command: "biome",
|
|
25
|
+
args: (outputPath) => [
|
|
26
|
+
"format",
|
|
27
|
+
"--write",
|
|
28
|
+
outputPath
|
|
29
|
+
],
|
|
30
|
+
errorMessage: "Biome not found"
|
|
31
|
+
},
|
|
32
|
+
oxfmt: {
|
|
33
|
+
command: "oxfmt",
|
|
34
|
+
args: (outputPath) => [outputPath],
|
|
35
|
+
errorMessage: "Oxfmt not found"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* CLI command descriptors for each supported linter.
|
|
40
|
+
*
|
|
41
|
+
* Each entry contains the executable `command`, an `args` factory that maps an
|
|
42
|
+
* output path to the correct argument list, and an `errorMessage` shown when
|
|
43
|
+
* the linter is not found.
|
|
44
|
+
*/
|
|
45
|
+
const linters = {
|
|
46
|
+
eslint: {
|
|
47
|
+
command: "eslint",
|
|
48
|
+
args: (outputPath) => [outputPath, "--fix"],
|
|
49
|
+
errorMessage: "Eslint not found"
|
|
50
|
+
},
|
|
51
|
+
biome: {
|
|
52
|
+
command: "biome",
|
|
53
|
+
args: (outputPath) => [
|
|
54
|
+
"lint",
|
|
55
|
+
"--fix",
|
|
56
|
+
outputPath
|
|
57
|
+
],
|
|
58
|
+
errorMessage: "Biome not found"
|
|
59
|
+
},
|
|
60
|
+
oxlint: {
|
|
61
|
+
command: "oxlint",
|
|
62
|
+
args: (outputPath) => [
|
|
63
|
+
"--fix",
|
|
64
|
+
"--no-ignore",
|
|
65
|
+
outputPath
|
|
66
|
+
],
|
|
67
|
+
errorMessage: "Oxlint not found"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Resolves to `true` when running `tool --version` exits with code 0.
|
|
72
|
+
*/
|
|
73
|
+
async function isToolAvailable(tool) {
|
|
74
|
+
return new Promise((resolve) => {
|
|
75
|
+
const child = (0, node_child_process.spawn)(tool, ["--version"], { stdio: "ignore" });
|
|
76
|
+
child.on("close", (code) => resolve(code === 0));
|
|
77
|
+
child.on("error", () => resolve(false));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the first installed tool from `candidates`, checked in order, or `null` when none are found.
|
|
82
|
+
*
|
|
83
|
+
* Availability is probed by running `<tool> --version` and checking for a zero exit code.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const formatter = await detectTool(['oxfmt', 'biome', 'prettier'] as const)
|
|
88
|
+
* const linter = await detectTool(['oxlint', 'biome', 'eslint'] as const)
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
async function detectTool(candidates) {
|
|
92
|
+
for (const tool of candidates) if (await isToolAvailable(tool)) return tool;
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Metadata for each supported package manager, keyed by its short name.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* packageManagers.pnpm.installCommand // ['add', '-D']
|
|
101
|
+
* packageManagers.npm.lockFile // 'package-lock.json'
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
const packageManagers = {
|
|
105
|
+
pnpm: {
|
|
106
|
+
name: "pnpm",
|
|
107
|
+
lockFile: "pnpm-lock.yaml",
|
|
108
|
+
installCommand: ["add", "-D"]
|
|
109
|
+
},
|
|
110
|
+
yarn: {
|
|
111
|
+
name: "yarn",
|
|
112
|
+
lockFile: "yarn.lock",
|
|
113
|
+
installCommand: ["add", "-D"]
|
|
114
|
+
},
|
|
115
|
+
bun: {
|
|
116
|
+
name: "bun",
|
|
117
|
+
lockFile: "bun.lockb",
|
|
118
|
+
installCommand: ["add", "-d"]
|
|
119
|
+
},
|
|
120
|
+
npm: {
|
|
121
|
+
name: "npm",
|
|
122
|
+
lockFile: "package-lock.json",
|
|
123
|
+
installCommand: ["install", "--save-dev"]
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Detects the active package manager for the given directory.
|
|
128
|
+
* Resolution order: `packageManager` field in `package.json`, then presence of a lock file.
|
|
129
|
+
* Falls back to `npm` when no signal is found.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }
|
|
134
|
+
* detectPackageManager() // falls back to npm when no lock file is found
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
function detectPackageManager(cwd = process.cwd()) {
|
|
138
|
+
const packageJsonPath = (0, node_path.join)(cwd, "package.json");
|
|
139
|
+
if ((0, node_fs.existsSync)(packageJsonPath)) try {
|
|
140
|
+
const pmField = JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf-8")).packageManager;
|
|
141
|
+
if (typeof pmField === "string") {
|
|
142
|
+
const name = pmField.split("@")[0];
|
|
143
|
+
if (name && name in packageManagers) return packageManagers[name];
|
|
144
|
+
}
|
|
145
|
+
} catch {}
|
|
146
|
+
for (const pm of Object.values(packageManagers)) if ((0, node_fs.existsSync)((0, node_path.join)(cwd, pm.lockFile))) return pm;
|
|
147
|
+
return packageManagers.npm;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
Object.defineProperty(exports, "detectPackageManager", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function() {
|
|
153
|
+
return detectPackageManager;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "detectTool", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function() {
|
|
159
|
+
return detectTool;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(exports, "formatters", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function() {
|
|
165
|
+
return formatters;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, "linters", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function() {
|
|
171
|
+
return linters;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
//# sourceMappingURL=tools-CZT9wSA6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools-CZT9wSA6.cjs","names":[],"sources":["../../../internals/utils/src/tools.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\n/**\n * CLI command descriptors for each supported code formatter.\n *\n * Each entry contains the executable `command`, an `args` factory that maps an\n * output path to the correct argument list, and an `errorMessage` shown when\n * the formatter is not found.\n */\nexport const formatters = {\n prettier: {\n command: 'prettier',\n args: (outputPath: string) => ['--ignore-unknown', '--write', outputPath],\n errorMessage: 'Prettier not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['format', '--write', outputPath],\n errorMessage: 'Biome not found',\n },\n oxfmt: {\n command: 'oxfmt',\n args: (outputPath: string) => [outputPath],\n errorMessage: 'Oxfmt not found',\n },\n} as const\n\n/**\n * CLI command descriptors for each supported linter.\n *\n * Each entry contains the executable `command`, an `args` factory that maps an\n * output path to the correct argument list, and an `errorMessage` shown when\n * the linter is not found.\n */\nexport const linters = {\n eslint: {\n command: 'eslint',\n args: (outputPath: string) => [outputPath, '--fix'],\n errorMessage: 'Eslint not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['lint', '--fix', outputPath],\n errorMessage: 'Biome not found',\n },\n oxlint: {\n command: 'oxlint',\n // --no-ignore so oxlint lints the folder even when it's gitignored (generated output dirs usually are).\n args: (outputPath: string) => ['--fix', '--no-ignore', outputPath],\n errorMessage: 'Oxlint not found',\n },\n} as const\n\n/**\n * Resolves to `true` when running `tool --version` exits with code 0.\n */\nasync function isToolAvailable(tool: string): Promise<boolean> {\n return new Promise((resolve) => {\n const child = spawn(tool, ['--version'], { stdio: 'ignore' })\n\n child.on('close', (code) => resolve(code === 0))\n child.on('error', () => resolve(false))\n })\n}\n\n/**\n * Returns the first installed tool from `candidates`, checked in order, or `null` when none are found.\n *\n * Availability is probed by running `<tool> --version` and checking for a zero exit code.\n *\n * @example\n * ```ts\n * const formatter = await detectTool(['oxfmt', 'biome', 'prettier'] as const)\n * const linter = await detectTool(['oxlint', 'biome', 'eslint'] as const)\n * ```\n */\nexport async function detectTool<TName extends string>(candidates: ReadonlyArray<TName>): Promise<TName | null> {\n for (const tool of candidates) {\n if (await isToolAvailable(tool)) {\n return tool\n }\n }\n\n return null\n}\n\n/**\n * Supported package manager identifiers.\n *\n * @example\n * ```ts\n * const pm: PackageManagerName = 'pnpm'\n * ```\n */\nexport type PackageManagerName = 'npm' | 'pnpm' | 'yarn' | 'bun'\n\n/**\n * Metadata describing a package manager's lock file and install command.\n */\nexport interface PackageManagerInfo {\n /**\n * Identifier used in CLI commands, e.g. `pnpm`, `yarn`.\n */\n name: PackageManagerName\n /**\n * Lock file name that uniquely identifies this package manager in a project root.\n */\n lockFile: string\n /**\n * Subcommands passed to the package manager binary to install a dev dependency.\n */\n installCommand: ReadonlyArray<string>\n}\n\n/**\n * Metadata for each supported package manager, keyed by its short name.\n *\n * @example\n * ```ts\n * packageManagers.pnpm.installCommand // ['add', '-D']\n * packageManagers.npm.lockFile // 'package-lock.json'\n * ```\n */\nconst packageManagers: Record<PackageManagerName, PackageManagerInfo> = {\n pnpm: {\n name: 'pnpm',\n lockFile: 'pnpm-lock.yaml',\n installCommand: ['add', '-D'],\n },\n yarn: {\n name: 'yarn',\n lockFile: 'yarn.lock',\n installCommand: ['add', '-D'],\n },\n bun: {\n name: 'bun',\n lockFile: 'bun.lockb',\n installCommand: ['add', '-d'],\n },\n npm: {\n name: 'npm',\n lockFile: 'package-lock.json',\n installCommand: ['install', '--save-dev'],\n },\n}\n\n/**\n * Minimal shape of `package.json` fields read during detection.\n */\ntype PackageJson = {\n /**\n * The `packageManager` field from `package.json` (e.g. `\"pnpm@9.0.0\"`).\n */\n packageManager?: string\n}\n\n/**\n * Detects the active package manager for the given directory.\n * Resolution order: `packageManager` field in `package.json`, then presence of a lock file.\n * Falls back to `npm` when no signal is found.\n *\n * @example\n * ```ts\n * detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }\n * detectPackageManager() // falls back to npm when no lock file is found\n * ```\n */\nexport function detectPackageManager(cwd: string = process.cwd()): PackageManagerInfo {\n const packageJsonPath = join(cwd, 'package.json')\n if (existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as PackageJson\n const pmField = packageJson.packageManager\n if (typeof pmField === 'string') {\n const name = pmField.split('@')[0]\n if (name && name in packageManagers) {\n return packageManagers[name as PackageManagerName]\n }\n }\n } catch {\n // Continue to lock file detection\n }\n }\n\n for (const pm of Object.values(packageManagers)) {\n if (existsSync(join(cwd, pm.lockFile))) {\n return pm\n }\n }\n\n return packageManagers.npm\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,aAAa;CACxB,UAAU;EACR,SAAS;EACT,OAAO,eAAuB;GAAC;GAAoB;GAAW;EAAU;EACxE,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAU;GAAW;EAAU;EAC9D,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB,CAAC,UAAU;EACzC,cAAc;CAChB;AACF;;;;;;;;AASA,MAAa,UAAU;CACrB,QAAQ;EACN,SAAS;EACT,OAAO,eAAuB,CAAC,YAAY,OAAO;EAClD,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAQ;GAAS;EAAU;EAC1D,cAAc;CAChB;CACA,QAAQ;EACN,SAAS;EAET,OAAO,eAAuB;GAAC;GAAS;GAAe;EAAU;EACjE,cAAc;CAChB;AACF;;;;AAKA,eAAe,gBAAgB,MAAgC;CAC7D,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,SAAA,GAAA,mBAAA,MAAA,CAAc,MAAM,CAAC,WAAW,GAAG,EAAE,OAAO,SAAS,CAAC;EAE5D,MAAM,GAAG,UAAU,SAAS,QAAQ,SAAS,CAAC,CAAC;EAC/C,MAAM,GAAG,eAAe,QAAQ,KAAK,CAAC;CACxC,CAAC;AACH;;;;;;;;;;;;AAaA,eAAsB,WAAiC,YAAyD;CAC9G,KAAK,MAAM,QAAQ,YACjB,IAAI,MAAM,gBAAgB,IAAI,GAC5B,OAAO;CAIX,OAAO;AACT;;;;;;;;;;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"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
//#region ../../internals/utils/src/tools.ts
|
|
6
|
+
/**
|
|
7
|
+
* CLI command descriptors for each supported code formatter.
|
|
8
|
+
*
|
|
9
|
+
* Each entry contains the executable `command`, an `args` factory that maps an
|
|
10
|
+
* output path to the correct argument list, and an `errorMessage` shown when
|
|
11
|
+
* the formatter is not found.
|
|
12
|
+
*/
|
|
13
|
+
const formatters = {
|
|
14
|
+
prettier: {
|
|
15
|
+
command: "prettier",
|
|
16
|
+
args: (outputPath) => [
|
|
17
|
+
"--ignore-unknown",
|
|
18
|
+
"--write",
|
|
19
|
+
outputPath
|
|
20
|
+
],
|
|
21
|
+
errorMessage: "Prettier not found"
|
|
22
|
+
},
|
|
23
|
+
biome: {
|
|
24
|
+
command: "biome",
|
|
25
|
+
args: (outputPath) => [
|
|
26
|
+
"format",
|
|
27
|
+
"--write",
|
|
28
|
+
outputPath
|
|
29
|
+
],
|
|
30
|
+
errorMessage: "Biome not found"
|
|
31
|
+
},
|
|
32
|
+
oxfmt: {
|
|
33
|
+
command: "oxfmt",
|
|
34
|
+
args: (outputPath) => [outputPath],
|
|
35
|
+
errorMessage: "Oxfmt not found"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* CLI command descriptors for each supported linter.
|
|
40
|
+
*
|
|
41
|
+
* Each entry contains the executable `command`, an `args` factory that maps an
|
|
42
|
+
* output path to the correct argument list, and an `errorMessage` shown when
|
|
43
|
+
* the linter is not found.
|
|
44
|
+
*/
|
|
45
|
+
const linters = {
|
|
46
|
+
eslint: {
|
|
47
|
+
command: "eslint",
|
|
48
|
+
args: (outputPath) => [outputPath, "--fix"],
|
|
49
|
+
errorMessage: "Eslint not found"
|
|
50
|
+
},
|
|
51
|
+
biome: {
|
|
52
|
+
command: "biome",
|
|
53
|
+
args: (outputPath) => [
|
|
54
|
+
"lint",
|
|
55
|
+
"--fix",
|
|
56
|
+
outputPath
|
|
57
|
+
],
|
|
58
|
+
errorMessage: "Biome not found"
|
|
59
|
+
},
|
|
60
|
+
oxlint: {
|
|
61
|
+
command: "oxlint",
|
|
62
|
+
args: (outputPath) => [
|
|
63
|
+
"--fix",
|
|
64
|
+
"--no-ignore",
|
|
65
|
+
outputPath
|
|
66
|
+
],
|
|
67
|
+
errorMessage: "Oxlint not found"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Resolves to `true` when running `tool --version` exits with code 0.
|
|
72
|
+
*/
|
|
73
|
+
async function isToolAvailable(tool) {
|
|
74
|
+
return new Promise((resolve) => {
|
|
75
|
+
const child = spawn(tool, ["--version"], { stdio: "ignore" });
|
|
76
|
+
child.on("close", (code) => resolve(code === 0));
|
|
77
|
+
child.on("error", () => resolve(false));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the first installed tool from `candidates`, checked in order, or `null` when none are found.
|
|
82
|
+
*
|
|
83
|
+
* Availability is probed by running `<tool> --version` and checking for a zero exit code.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const formatter = await detectTool(['oxfmt', 'biome', 'prettier'] as const)
|
|
88
|
+
* const linter = await detectTool(['oxlint', 'biome', 'eslint'] as const)
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
async function detectTool(candidates) {
|
|
92
|
+
for (const tool of candidates) if (await isToolAvailable(tool)) return tool;
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Metadata for each supported package manager, keyed by its short name.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* packageManagers.pnpm.installCommand // ['add', '-D']
|
|
101
|
+
* packageManagers.npm.lockFile // 'package-lock.json'
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
const packageManagers = {
|
|
105
|
+
pnpm: {
|
|
106
|
+
name: "pnpm",
|
|
107
|
+
lockFile: "pnpm-lock.yaml",
|
|
108
|
+
installCommand: ["add", "-D"]
|
|
109
|
+
},
|
|
110
|
+
yarn: {
|
|
111
|
+
name: "yarn",
|
|
112
|
+
lockFile: "yarn.lock",
|
|
113
|
+
installCommand: ["add", "-D"]
|
|
114
|
+
},
|
|
115
|
+
bun: {
|
|
116
|
+
name: "bun",
|
|
117
|
+
lockFile: "bun.lockb",
|
|
118
|
+
installCommand: ["add", "-d"]
|
|
119
|
+
},
|
|
120
|
+
npm: {
|
|
121
|
+
name: "npm",
|
|
122
|
+
lockFile: "package-lock.json",
|
|
123
|
+
installCommand: ["install", "--save-dev"]
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Detects the active package manager for the given directory.
|
|
128
|
+
* Resolution order: `packageManager` field in `package.json`, then presence of a lock file.
|
|
129
|
+
* Falls back to `npm` when no signal is found.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }
|
|
134
|
+
* detectPackageManager() // falls back to npm when no lock file is found
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
function detectPackageManager(cwd = process.cwd()) {
|
|
138
|
+
const packageJsonPath = join(cwd, "package.json");
|
|
139
|
+
if (existsSync(packageJsonPath)) try {
|
|
140
|
+
const pmField = JSON.parse(readFileSync(packageJsonPath, "utf-8")).packageManager;
|
|
141
|
+
if (typeof pmField === "string") {
|
|
142
|
+
const name = pmField.split("@")[0];
|
|
143
|
+
if (name && name in packageManagers) return packageManagers[name];
|
|
144
|
+
}
|
|
145
|
+
} catch {}
|
|
146
|
+
for (const pm of Object.values(packageManagers)) if (existsSync(join(cwd, pm.lockFile))) return pm;
|
|
147
|
+
return packageManagers.npm;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
export { linters as i, detectTool as n, formatters as r, detectPackageManager as t };
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=tools-D0UogMU3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools-D0UogMU3.js","names":[],"sources":["../../../internals/utils/src/tools.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\n/**\n * CLI command descriptors for each supported code formatter.\n *\n * Each entry contains the executable `command`, an `args` factory that maps an\n * output path to the correct argument list, and an `errorMessage` shown when\n * the formatter is not found.\n */\nexport const formatters = {\n prettier: {\n command: 'prettier',\n args: (outputPath: string) => ['--ignore-unknown', '--write', outputPath],\n errorMessage: 'Prettier not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['format', '--write', outputPath],\n errorMessage: 'Biome not found',\n },\n oxfmt: {\n command: 'oxfmt',\n args: (outputPath: string) => [outputPath],\n errorMessage: 'Oxfmt not found',\n },\n} as const\n\n/**\n * CLI command descriptors for each supported linter.\n *\n * Each entry contains the executable `command`, an `args` factory that maps an\n * output path to the correct argument list, and an `errorMessage` shown when\n * the linter is not found.\n */\nexport const linters = {\n eslint: {\n command: 'eslint',\n args: (outputPath: string) => [outputPath, '--fix'],\n errorMessage: 'Eslint not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['lint', '--fix', outputPath],\n errorMessage: 'Biome not found',\n },\n oxlint: {\n command: 'oxlint',\n // --no-ignore so oxlint lints the folder even when it's gitignored (generated output dirs usually are).\n args: (outputPath: string) => ['--fix', '--no-ignore', outputPath],\n errorMessage: 'Oxlint not found',\n },\n} as const\n\n/**\n * Resolves to `true` when running `tool --version` exits with code 0.\n */\nasync function isToolAvailable(tool: string): Promise<boolean> {\n return new Promise((resolve) => {\n const child = spawn(tool, ['--version'], { stdio: 'ignore' })\n\n child.on('close', (code) => resolve(code === 0))\n child.on('error', () => resolve(false))\n })\n}\n\n/**\n * Returns the first installed tool from `candidates`, checked in order, or `null` when none are found.\n *\n * Availability is probed by running `<tool> --version` and checking for a zero exit code.\n *\n * @example\n * ```ts\n * const formatter = await detectTool(['oxfmt', 'biome', 'prettier'] as const)\n * const linter = await detectTool(['oxlint', 'biome', 'eslint'] as const)\n * ```\n */\nexport async function detectTool<TName extends string>(candidates: ReadonlyArray<TName>): Promise<TName | null> {\n for (const tool of candidates) {\n if (await isToolAvailable(tool)) {\n return tool\n }\n }\n\n return null\n}\n\n/**\n * Supported package manager identifiers.\n *\n * @example\n * ```ts\n * const pm: PackageManagerName = 'pnpm'\n * ```\n */\nexport type PackageManagerName = 'npm' | 'pnpm' | 'yarn' | 'bun'\n\n/**\n * Metadata describing a package manager's lock file and install command.\n */\nexport interface PackageManagerInfo {\n /**\n * Identifier used in CLI commands, e.g. `pnpm`, `yarn`.\n */\n name: PackageManagerName\n /**\n * Lock file name that uniquely identifies this package manager in a project root.\n */\n lockFile: string\n /**\n * Subcommands passed to the package manager binary to install a dev dependency.\n */\n installCommand: ReadonlyArray<string>\n}\n\n/**\n * Metadata for each supported package manager, keyed by its short name.\n *\n * @example\n * ```ts\n * packageManagers.pnpm.installCommand // ['add', '-D']\n * packageManagers.npm.lockFile // 'package-lock.json'\n * ```\n */\nconst packageManagers: Record<PackageManagerName, PackageManagerInfo> = {\n pnpm: {\n name: 'pnpm',\n lockFile: 'pnpm-lock.yaml',\n installCommand: ['add', '-D'],\n },\n yarn: {\n name: 'yarn',\n lockFile: 'yarn.lock',\n installCommand: ['add', '-D'],\n },\n bun: {\n name: 'bun',\n lockFile: 'bun.lockb',\n installCommand: ['add', '-d'],\n },\n npm: {\n name: 'npm',\n lockFile: 'package-lock.json',\n installCommand: ['install', '--save-dev'],\n },\n}\n\n/**\n * Minimal shape of `package.json` fields read during detection.\n */\ntype PackageJson = {\n /**\n * The `packageManager` field from `package.json` (e.g. `\"pnpm@9.0.0\"`).\n */\n packageManager?: string\n}\n\n/**\n * Detects the active package manager for the given directory.\n * Resolution order: `packageManager` field in `package.json`, then presence of a lock file.\n * Falls back to `npm` when no signal is found.\n *\n * @example\n * ```ts\n * detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }\n * detectPackageManager() // falls back to npm when no lock file is found\n * ```\n */\nexport function detectPackageManager(cwd: string = process.cwd()): PackageManagerInfo {\n const packageJsonPath = join(cwd, 'package.json')\n if (existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as PackageJson\n const pmField = packageJson.packageManager\n if (typeof pmField === 'string') {\n const name = pmField.split('@')[0]\n if (name && name in packageManagers) {\n return packageManagers[name as PackageManagerName]\n }\n }\n } catch {\n // Continue to lock file detection\n }\n }\n\n for (const pm of Object.values(packageManagers)) {\n if (existsSync(join(cwd, pm.lockFile))) {\n return pm\n }\n }\n\n return packageManagers.npm\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,aAAa;CACxB,UAAU;EACR,SAAS;EACT,OAAO,eAAuB;GAAC;GAAoB;GAAW;EAAU;EACxE,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAU;GAAW;EAAU;EAC9D,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB,CAAC,UAAU;EACzC,cAAc;CAChB;AACF;;;;;;;;AASA,MAAa,UAAU;CACrB,QAAQ;EACN,SAAS;EACT,OAAO,eAAuB,CAAC,YAAY,OAAO;EAClD,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAQ;GAAS;EAAU;EAC1D,cAAc;CAChB;CACA,QAAQ;EACN,SAAS;EAET,OAAO,eAAuB;GAAC;GAAS;GAAe;EAAU;EACjE,cAAc;CAChB;AACF;;;;AAKA,eAAe,gBAAgB,MAAgC;CAC7D,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,QAAQ,MAAM,MAAM,CAAC,WAAW,GAAG,EAAE,OAAO,SAAS,CAAC;EAE5D,MAAM,GAAG,UAAU,SAAS,QAAQ,SAAS,CAAC,CAAC;EAC/C,MAAM,GAAG,eAAe,QAAQ,KAAK,CAAC;CACxC,CAAC;AACH;;;;;;;;;;;;AAaA,eAAsB,WAAiC,YAAyD;CAC9G,KAAK,MAAM,QAAQ,YACjB,IAAI,MAAM,gBAAgB,IAAI,GAC5B,OAAO;CAIX,OAAO;AACT;;;;;;;;;;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,kBAAkB,KAAK,KAAK,cAAc;CAChD,IAAI,WAAW,eAAe,GAC5B,IAAI;EAEF,MAAM,UADc,KAAK,MAAM,aAAa,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,IAAI,WAAW,KAAK,KAAK,GAAG,QAAQ,CAAC,GACnC,OAAO;CAIX,OAAO,gBAAgB;AACzB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require("./
|
|
2
|
-
const
|
|
3
|
-
const require_package = require("./package-
|
|
1
|
+
require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
+
const require_defineCommand = require("./defineCommand-Bo3yZTWI.cjs");
|
|
3
|
+
const require_package = require("./package-D4dpxvXZ.cjs");
|
|
4
4
|
//#region src/commands/validate.ts
|
|
5
|
-
const command =
|
|
5
|
+
const command = require_defineCommand.defineCommand({
|
|
6
6
|
name: "validate",
|
|
7
7
|
description: "Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.",
|
|
8
8
|
examples: ["kubb validate --input ./openapi.yaml", "kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json"],
|
|
@@ -13,7 +13,7 @@ const command = require_define.defineCommand({
|
|
|
13
13
|
required: true
|
|
14
14
|
} },
|
|
15
15
|
async run({ values }) {
|
|
16
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
16
|
+
const { run } = await Promise.resolve().then(() => require("./run-DYkciQ4u.cjs"));
|
|
17
17
|
await run({
|
|
18
18
|
input: values.input,
|
|
19
19
|
version: require_package.version
|
|
@@ -23,4 +23,4 @@ const command = require_define.defineCommand({
|
|
|
23
23
|
//#endregion
|
|
24
24
|
exports.command = command;
|
|
25
25
|
|
|
26
|
-
//# sourceMappingURL=validate-
|
|
26
|
+
//# sourceMappingURL=validate-BbsWghwr.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-BbsWghwr.cjs","names":["defineCommand"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description:\n 'Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAUA,sBAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,wEAAwE;CAC3H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO,SAAA,gBAAA;EAAQ,CAAC;CAC5C;AACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import {
|
|
3
|
-
import { t as version } from "./package-
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { t as defineCommand } from "./defineCommand-DMEeqliP.js";
|
|
3
|
+
import { t as version } from "./package-CfrcA3AM.js";
|
|
4
4
|
//#region src/commands/validate.ts
|
|
5
5
|
const command = defineCommand({
|
|
6
6
|
name: "validate",
|
|
@@ -13,7 +13,7 @@ const command = defineCommand({
|
|
|
13
13
|
required: true
|
|
14
14
|
} },
|
|
15
15
|
async run({ values }) {
|
|
16
|
-
const { run } = await import("./run-
|
|
16
|
+
const { run } = await import("./run-CPBFfbI7.js");
|
|
17
17
|
await run({
|
|
18
18
|
input: values.input,
|
|
19
19
|
version
|
|
@@ -23,4 +23,4 @@ const command = defineCommand({
|
|
|
23
23
|
//#endregion
|
|
24
24
|
export { command };
|
|
25
25
|
|
|
26
|
-
//# sourceMappingURL=validate-
|
|
26
|
+
//# sourceMappingURL=validate-DhoFtPVz.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-DhoFtPVz.js","names":[],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description:\n 'Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,wEAAwE;CAC3H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO;EAAQ,CAAC;CAC5C;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
4
|
-
"description": "Official CLI for Kubb. Run kubb generate, kubb init, kubb validate,
|
|
3
|
+
"version": "5.0.0-beta.80",
|
|
4
|
+
"description": "Official CLI for Kubb. Run kubb generate, kubb init, kubb validate, and kubb mcp to manage the full code generation lifecycle.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
7
7
|
"code-generator",
|
|
8
8
|
"codegen",
|
|
9
9
|
"kubb",
|
|
10
|
-
"
|
|
10
|
+
"meta-framework",
|
|
11
11
|
"sdk-generator",
|
|
12
|
-
"swagger",
|
|
13
12
|
"typescript"
|
|
14
13
|
],
|
|
15
14
|
"license": "MIT",
|
|
@@ -23,7 +22,6 @@
|
|
|
23
22
|
"kubb": "bin/kubb.js"
|
|
24
23
|
},
|
|
25
24
|
"files": [
|
|
26
|
-
"src",
|
|
27
25
|
"dist",
|
|
28
26
|
"bin",
|
|
29
27
|
"!/**/**.test.**",
|
|
@@ -47,52 +45,42 @@
|
|
|
47
45
|
"registry": "https://registry.npmjs.org/"
|
|
48
46
|
},
|
|
49
47
|
"dependencies": {
|
|
50
|
-
"@clack/prompts": "^1.
|
|
48
|
+
"@clack/prompts": "^1.6.0",
|
|
51
49
|
"chokidar": "^5.0.0",
|
|
52
|
-
"cosmiconfig": "^9.0.1",
|
|
53
50
|
"jiti": "^2.7.0",
|
|
54
|
-
"tinyexec": "^1.
|
|
55
|
-
"
|
|
51
|
+
"tinyexec": "^1.2.4",
|
|
52
|
+
"unconfig": "^7.5.0",
|
|
53
|
+
"@kubb/core": "5.0.0-beta.80"
|
|
56
54
|
},
|
|
57
55
|
"devDependencies": {
|
|
58
56
|
"@internals/shared": "0.0.0",
|
|
59
57
|
"@internals/utils": "0.0.0",
|
|
60
|
-
"@kubb/adapter-oas": "5.0.0-beta.
|
|
58
|
+
"@kubb/adapter-oas": "5.0.0-beta.80"
|
|
61
59
|
},
|
|
62
60
|
"peerDependencies": {
|
|
63
|
-
"@kubb/adapter-oas": "5.0.0-beta.
|
|
64
|
-
"@kubb/
|
|
65
|
-
"@kubb/mcp": "5.0.0-beta.8"
|
|
61
|
+
"@kubb/adapter-oas": "5.0.0-beta.80",
|
|
62
|
+
"@kubb/mcp": "5.0.0-beta.80"
|
|
66
63
|
},
|
|
67
64
|
"peerDependenciesMeta": {
|
|
68
65
|
"@kubb/adapter-oas": {
|
|
69
66
|
"optional": true
|
|
70
67
|
},
|
|
71
|
-
"@kubb/agent": {
|
|
72
|
-
"optional": true
|
|
73
|
-
},
|
|
74
68
|
"@kubb/mcp": {
|
|
75
69
|
"optional": true
|
|
76
70
|
}
|
|
77
71
|
},
|
|
78
|
-
"size-limit": [
|
|
79
|
-
{
|
|
80
|
-
"path": "./dist/*.js",
|
|
81
|
-
"limit": "510 KiB",
|
|
82
|
-
"gzip": true
|
|
83
|
-
}
|
|
84
|
-
],
|
|
85
72
|
"preferGlobal": true,
|
|
86
73
|
"engines": {
|
|
87
74
|
"node": ">=22"
|
|
88
75
|
},
|
|
89
76
|
"scripts": {
|
|
90
|
-
"build": "tsdown
|
|
91
|
-
"clean": "
|
|
77
|
+
"build": "tsdown",
|
|
78
|
+
"clean": "node -e \"require('node:fs').rmSync('./dist', {recursive:true,force:true})\"",
|
|
92
79
|
"lint": "oxlint .",
|
|
93
80
|
"lint:fix": "oxlint --fix .",
|
|
94
81
|
"release": "pnpm publish --no-git-check",
|
|
95
82
|
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
83
|
+
"release:stage": "pnpm stage publish --no-git-check",
|
|
96
84
|
"start": "tsdown --watch",
|
|
97
85
|
"test": "vitest --passWithNoTests",
|
|
98
86
|
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
package/dist/agent-DPLjUza1.cjs
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require("./chunk-ByKO4r7w.cjs");
|
|
2
|
-
const require_define = require("./define-Bdn8j5VM.cjs");
|
|
3
|
-
const require_package = require("./package-BvBzYG6c.cjs");
|
|
4
|
-
const require_constants = require("./constants-BINTA5VZ.cjs");
|
|
5
|
-
//#region src/commands/agent/start.ts
|
|
6
|
-
const command$1 = require_define.defineCommand({
|
|
7
|
-
name: "start",
|
|
8
|
-
description: "Start the Kubb Agent HTTP server. Exposes a REST API that accepts a kubb.config.ts patch and returns generated code as a stream. Use --allow-write to also write files to disk.",
|
|
9
|
-
examples: [
|
|
10
|
-
"kubb agent start",
|
|
11
|
-
"kubb agent start --port 4000",
|
|
12
|
-
"kubb agent start --allow-write",
|
|
13
|
-
"kubb agent start --config ./kubb.config.ts --allow-all"
|
|
14
|
-
],
|
|
15
|
-
options: {
|
|
16
|
-
config: {
|
|
17
|
-
type: "string",
|
|
18
|
-
description: "Path to the Kubb config file",
|
|
19
|
-
short: "c"
|
|
20
|
-
},
|
|
21
|
-
port: {
|
|
22
|
-
type: "string",
|
|
23
|
-
description: "Port the HTTP server listens on",
|
|
24
|
-
short: "p",
|
|
25
|
-
default: require_constants.agentDefaults.port
|
|
26
|
-
},
|
|
27
|
-
host: {
|
|
28
|
-
type: "string",
|
|
29
|
-
description: "Hostname the HTTP server binds to",
|
|
30
|
-
default: require_constants.agentDefaults.host
|
|
31
|
-
},
|
|
32
|
-
"allow-write": {
|
|
33
|
-
type: "boolean",
|
|
34
|
-
description: "Write generated files to the filesystem. When omitted, output is streamed only and no files are written.",
|
|
35
|
-
default: false
|
|
36
|
-
},
|
|
37
|
-
"allow-all": {
|
|
38
|
-
type: "boolean",
|
|
39
|
-
description: "Grant all permissions (implies --allow-write).",
|
|
40
|
-
default: false
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
async run({ values }) {
|
|
44
|
-
const { run } = await Promise.resolve().then(() => require("./run-DwdAwnLG.cjs"));
|
|
45
|
-
await run({
|
|
46
|
-
port: values.port !== void 0 ? values.port : void 0,
|
|
47
|
-
host: values.host,
|
|
48
|
-
configPath: values.config,
|
|
49
|
-
allowWrite: values["allow-write"],
|
|
50
|
-
allowAll: values["allow-all"],
|
|
51
|
-
version: require_package.version
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region src/commands/agent.ts
|
|
57
|
-
const command = require_define.defineCommand({
|
|
58
|
-
name: "agent",
|
|
59
|
-
description: "Manage the Kubb Agent — an HTTP server that lets AI agents trigger code generation programmatically via a REST API. Useful when an AI workflow needs to generate code without direct CLI access.",
|
|
60
|
-
examples: [
|
|
61
|
-
"kubb agent start",
|
|
62
|
-
"kubb agent start --port 4000 --allow-write",
|
|
63
|
-
"kubb agent start --config ./kubb.config.ts --allow-all"
|
|
64
|
-
],
|
|
65
|
-
subCommands: [command$1]
|
|
66
|
-
});
|
|
67
|
-
//#endregion
|
|
68
|
-
exports.command = command;
|
|
69
|
-
|
|
70
|
-
//# sourceMappingURL=agent-DPLjUza1.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-DPLjUza1.cjs","names":["command","defineCommand","agentDefaults","defineCommand","startCommand"],"sources":["../src/commands/agent/start.ts","../src/commands/agent.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../../package.json'\nimport { agentDefaults } from '../../constants.ts'\n\nexport const command = defineCommand({\n name: 'start',\n description:\n 'Start the Kubb Agent HTTP server. Exposes a REST API that accepts a kubb.config.ts patch and returns generated code as a stream. Use --allow-write to also write files to disk.',\n examples: ['kubb agent start', 'kubb agent start --port 4000', 'kubb agent start --allow-write', 'kubb agent start --config ./kubb.config.ts --allow-all'],\n options: {\n config: {\n type: 'string',\n description: 'Path to the Kubb config file',\n short: 'c',\n },\n port: {\n type: 'string',\n description: 'Port the HTTP server listens on',\n short: 'p',\n default: agentDefaults.port,\n },\n host: {\n type: 'string',\n description: 'Hostname the HTTP server binds to',\n default: agentDefaults.host,\n },\n 'allow-write': {\n type: 'boolean',\n description: 'Write generated files to the filesystem. When omitted, output is streamed only and no files are written.',\n default: false,\n },\n 'allow-all': {\n type: 'boolean',\n description: 'Grant all permissions (implies --allow-write).',\n default: false,\n },\n },\n async run({ values }) {\n const { run } = await import('../../runners/agent/run.ts')\n\n await run({\n port: values.port !== undefined ? values.port : undefined,\n host: values.host,\n configPath: values.config,\n allowWrite: values['allow-write'],\n allowAll: values['allow-all'],\n version,\n })\n },\n})\n","import { defineCommand } from '@internals/utils'\nimport { command as startCommand } from './agent/start.ts'\n\nexport const command = defineCommand({\n name: 'agent',\n description:\n 'Manage the Kubb Agent — an HTTP server that lets AI agents trigger code generation programmatically via a REST API. Useful when an AI workflow needs to generate code without direct CLI access.',\n examples: ['kubb agent start', 'kubb agent start --port 4000 --allow-write', 'kubb agent start --config ./kubb.config.ts --allow-all'],\n subCommands: [startCommand],\n})\n"],"mappings":";;;;;AAIA,MAAaA,YAAUC,eAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAoB;EAAgC;EAAkC;EAAyD;CAC1J,SAAS;EACP,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACR;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAASC,kBAAAA,cAAc;GACxB;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,SAASA,kBAAAA,cAAc;GACxB;EACD,eAAe;GACb,MAAM;GACN,aAAa;GACb,SAAS;GACV;EACD,aAAa;GACX,MAAM;GACN,aAAa;GACb,SAAS;GACV;EACF;CACD,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,SAAA,CAAA,WAAA,QAAM,qBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,MAAM,OAAO,SAAS,KAAA,IAAY,OAAO,OAAO,KAAA;GAChD,MAAM,OAAO;GACb,YAAY,OAAO;GACnB,YAAY,OAAO;GACnB,UAAU,OAAO;GACjB,SAAA,gBAAA;GACD,CAAC;;CAEL,CAAC;;;AC9CF,MAAa,UAAUC,eAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAoB;EAA8C;EAAyD;CACtI,aAAa,CAACC,UAAa;CAC5B,CAAC"}
|