@kubb/cli 3.18.3 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{generate-CKnWsDnu.cjs → generate-BALD2C5T.cjs} +84 -92
- package/dist/generate-BALD2C5T.cjs.map +1 -0
- package/dist/{generate-jMDBjxTU.js → generate-BqNABk2X.js} +56 -95
- package/dist/generate-BqNABk2X.js.map +1 -0
- package/dist/{generate-Bu9WyH1N.cjs → generate-DKlT22M0.cjs} +74 -104
- package/dist/generate-DKlT22M0.cjs.map +1 -0
- package/dist/{generate-DvSF6lmv.js → generate-vHDmA5Mm.js} +44 -72
- package/dist/generate-vHDmA5Mm.js.map +1 -0
- package/dist/index.cjs +16 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/{mcp-DcaOAt6B.js → mcp-C4KjGtQv.js} +9 -10
- package/dist/mcp-C4KjGtQv.js.map +1 -0
- package/dist/{mcp-Cmiw4RpU.cjs → mcp-CLmIdoaC.cjs} +17 -14
- package/dist/mcp-CLmIdoaC.cjs.map +1 -0
- package/dist/{validate-DD5UaudC.js → validate-8i6chavn.js} +18 -20
- package/dist/validate-8i6chavn.js.map +1 -0
- package/dist/{validate-ClewPP5U.cjs → validate-DNbDDWp4.cjs} +26 -24
- package/dist/validate-DNbDDWp4.cjs.map +1 -0
- package/package.json +8 -11
- package/src/commands/generate.ts +0 -43
- package/dist/generate-Bu9WyH1N.cjs.map +0 -1
- package/dist/generate-CKnWsDnu.cjs.map +0 -1
- package/dist/generate-DvSF6lmv.js.map +0 -1
- package/dist/generate-jMDBjxTU.js.map +0 -1
- package/dist/mcp-Cmiw4RpU.cjs.map +0 -1
- package/dist/mcp-DcaOAt6B.js.map +0 -1
- package/dist/validate-ClewPP5U.cjs.map +0 -1
- package/dist/validate-DD5UaudC.js.map +0 -1
|
@@ -3,7 +3,6 @@ import path from "node:path";
|
|
|
3
3
|
import * as process$1 from "node:process";
|
|
4
4
|
import { PromiseManager, isInputPath } from "@kubb/core";
|
|
5
5
|
import { LogMapper, createLogger } from "@kubb/core/logger";
|
|
6
|
-
import open from "open";
|
|
7
6
|
import pc from "picocolors";
|
|
8
7
|
import { isPromise } from "@kubb/core/utils";
|
|
9
8
|
import { cosmiconfig } from "cosmiconfig";
|
|
@@ -29,11 +28,11 @@ function getPlugins(plugins) {
|
|
|
29
28
|
/**
|
|
30
29
|
* Converting UserConfig to Config without a change in the object beside the JSON convert.
|
|
31
30
|
*/
|
|
32
|
-
async function getConfig(result, args
|
|
31
|
+
async function getConfig(result, args) {
|
|
33
32
|
const config = result?.config;
|
|
34
33
|
let kubbUserConfig = Promise.resolve(config);
|
|
35
34
|
if (typeof config === "function") {
|
|
36
|
-
const possiblePromise = config(args
|
|
35
|
+
const possiblePromise = config(args);
|
|
37
36
|
if (isPromise(possiblePromise)) kubbUserConfig = possiblePromise;
|
|
38
37
|
kubbUserConfig = Promise.resolve(possiblePromise);
|
|
39
38
|
}
|
|
@@ -59,15 +58,13 @@ async function getConfig(result, args$1) {
|
|
|
59
58
|
//#endregion
|
|
60
59
|
//#region src/utils/getCosmiConfig.ts
|
|
61
60
|
const tsLoader = async (configFile) => {
|
|
62
|
-
|
|
61
|
+
return await createJiti(import.meta.url, {
|
|
63
62
|
jsx: {
|
|
64
63
|
runtime: "automatic",
|
|
65
64
|
importSource: "@kubb/react"
|
|
66
65
|
},
|
|
67
66
|
sourceMaps: true
|
|
68
|
-
});
|
|
69
|
-
const mod = await jiti.import(configFile, { default: true });
|
|
70
|
-
return mod;
|
|
67
|
+
}).import(configFile, { default: true });
|
|
71
68
|
};
|
|
72
69
|
async function getCosmiConfig(moduleName, config) {
|
|
73
70
|
const searchPlaces = [
|
|
@@ -108,12 +105,10 @@ async function getCosmiConfig(moduleName, config) {
|
|
|
108
105
|
async function startWatcher(path$1, cb) {
|
|
109
106
|
const { watch } = await import("chokidar");
|
|
110
107
|
const logger = createLogger();
|
|
111
|
-
|
|
112
|
-
const watcher = watch(path$1, {
|
|
108
|
+
watch(path$1, {
|
|
113
109
|
ignorePermissionErrors: true,
|
|
114
|
-
ignored
|
|
115
|
-
})
|
|
116
|
-
watcher.on("all", (type, file) => {
|
|
110
|
+
ignored: "**/{.git,node_modules}/**"
|
|
111
|
+
}).on("all", (type, file) => {
|
|
117
112
|
logger?.emit("info", pc.yellow(pc.bold(`Change detected: ${type} ${file}`)));
|
|
118
113
|
try {
|
|
119
114
|
cb(path$1);
|
|
@@ -125,74 +120,65 @@ async function startWatcher(path$1, cb) {
|
|
|
125
120
|
|
|
126
121
|
//#endregion
|
|
127
122
|
//#region src/commands/generate.ts
|
|
128
|
-
const args = {
|
|
129
|
-
config: {
|
|
130
|
-
type: "string",
|
|
131
|
-
description: "Path to the Kubb config",
|
|
132
|
-
alias: "c"
|
|
133
|
-
},
|
|
134
|
-
logLevel: {
|
|
135
|
-
type: "string",
|
|
136
|
-
description: "Info, silent or debug",
|
|
137
|
-
alias: "l",
|
|
138
|
-
default: "info",
|
|
139
|
-
valueHint: "silent|info|debug"
|
|
140
|
-
},
|
|
141
|
-
watch: {
|
|
142
|
-
type: "boolean",
|
|
143
|
-
description: "Watch mode based on the input file",
|
|
144
|
-
alias: "w",
|
|
145
|
-
default: false
|
|
146
|
-
},
|
|
147
|
-
debug: {
|
|
148
|
-
type: "boolean",
|
|
149
|
-
description: "Override logLevel to debug",
|
|
150
|
-
alias: "d",
|
|
151
|
-
default: false
|
|
152
|
-
},
|
|
153
|
-
ui: {
|
|
154
|
-
type: "boolean",
|
|
155
|
-
description: "Open ui",
|
|
156
|
-
alias: "u",
|
|
157
|
-
default: false
|
|
158
|
-
},
|
|
159
|
-
help: {
|
|
160
|
-
type: "boolean",
|
|
161
|
-
description: "Show help",
|
|
162
|
-
alias: "h",
|
|
163
|
-
default: false
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
123
|
const command = defineCommand({
|
|
167
124
|
meta: {
|
|
168
125
|
name: "generate",
|
|
169
126
|
description: "[input] Generate files based on a 'kubb.config.ts' file"
|
|
170
127
|
},
|
|
171
|
-
args
|
|
128
|
+
args: {
|
|
129
|
+
config: {
|
|
130
|
+
type: "string",
|
|
131
|
+
description: "Path to the Kubb config",
|
|
132
|
+
alias: "c"
|
|
133
|
+
},
|
|
134
|
+
logLevel: {
|
|
135
|
+
type: "string",
|
|
136
|
+
description: "Info, silent or debug",
|
|
137
|
+
alias: "l",
|
|
138
|
+
default: "info",
|
|
139
|
+
valueHint: "silent|info|debug"
|
|
140
|
+
},
|
|
141
|
+
watch: {
|
|
142
|
+
type: "boolean",
|
|
143
|
+
description: "Watch mode based on the input file",
|
|
144
|
+
alias: "w",
|
|
145
|
+
default: false
|
|
146
|
+
},
|
|
147
|
+
debug: {
|
|
148
|
+
type: "boolean",
|
|
149
|
+
description: "Override logLevel to debug",
|
|
150
|
+
alias: "d",
|
|
151
|
+
default: false
|
|
152
|
+
},
|
|
153
|
+
help: {
|
|
154
|
+
type: "boolean",
|
|
155
|
+
description: "Show help",
|
|
156
|
+
alias: "h",
|
|
157
|
+
default: false
|
|
158
|
+
}
|
|
159
|
+
},
|
|
172
160
|
async run(commandContext) {
|
|
173
|
-
let name = "";
|
|
174
161
|
const progressCache = /* @__PURE__ */ new Map();
|
|
175
|
-
const { args
|
|
176
|
-
const input = args
|
|
177
|
-
if (args
|
|
178
|
-
if (args
|
|
179
|
-
const logLevel = LogMapper[args
|
|
162
|
+
const { args } = commandContext;
|
|
163
|
+
const input = args._[0];
|
|
164
|
+
if (args.help) return showUsage(command);
|
|
165
|
+
if (args.debug) args.logLevel = "debug";
|
|
166
|
+
const logLevel = LogMapper[args.logLevel] || 3;
|
|
180
167
|
const logger = createLogger({ logLevel });
|
|
181
|
-
const { generate } = await import("./generate-
|
|
168
|
+
const { generate } = await import("./generate-vHDmA5Mm.js");
|
|
182
169
|
logger.emit("start", "Loading config");
|
|
183
|
-
const result = await getCosmiConfig("kubb", args
|
|
170
|
+
const result = await getCosmiConfig("kubb", args.config);
|
|
184
171
|
logger.emit("success", `Config loaded(${pc.dim(path.relative(process$1.cwd(), result.filepath))})`);
|
|
185
|
-
const config = await getConfig(result, args
|
|
172
|
+
const config = await getConfig(result, args);
|
|
186
173
|
const start = async () => {
|
|
187
174
|
if (Array.isArray(config)) {
|
|
188
175
|
const promiseManager = new PromiseManager();
|
|
189
176
|
const promises = config.map((c) => () => {
|
|
190
|
-
name = c.name || "";
|
|
191
177
|
progressCache.clear();
|
|
192
178
|
return generate({
|
|
193
179
|
input,
|
|
194
180
|
config: c,
|
|
195
|
-
args
|
|
181
|
+
args,
|
|
196
182
|
progressCache
|
|
197
183
|
});
|
|
198
184
|
});
|
|
@@ -204,32 +190,10 @@ const command = defineCommand({
|
|
|
204
190
|
input,
|
|
205
191
|
config,
|
|
206
192
|
progressCache,
|
|
207
|
-
args
|
|
193
|
+
args
|
|
208
194
|
});
|
|
209
195
|
};
|
|
210
|
-
if (args
|
|
211
|
-
const { startServer } = await import("@kubb/ui");
|
|
212
|
-
await startServer({
|
|
213
|
-
stop: () => process$1.exit(1),
|
|
214
|
-
restart: () => start(),
|
|
215
|
-
getMeta: () => {
|
|
216
|
-
const entries = [...progressCache.entries()];
|
|
217
|
-
const percentages = entries.reduce((acc, [key, singleBar]) => {
|
|
218
|
-
acc[key] = singleBar.getProgress();
|
|
219
|
-
return acc;
|
|
220
|
-
}, {});
|
|
221
|
-
return {
|
|
222
|
-
name,
|
|
223
|
-
percentages
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
}, (info) => {
|
|
227
|
-
const url = `${info.address}:${info.port}`.replace("::", "http://localhost");
|
|
228
|
-
logger.consola?.start(`Starting ui on ${url}`);
|
|
229
|
-
open(url);
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
if (args$1.watch) {
|
|
196
|
+
if (args.watch) {
|
|
233
197
|
if (Array.isArray(config)) throw new Error("Cannot use watcher with multiple Configs(array)");
|
|
234
198
|
if (isInputPath(config)) return startWatcher([input || config.input.path], async (paths) => {
|
|
235
199
|
await start();
|
|
@@ -237,18 +201,15 @@ const command = defineCommand({
|
|
|
237
201
|
});
|
|
238
202
|
}
|
|
239
203
|
await start();
|
|
240
|
-
if (globalThis.isDevtoolsEnabled) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if (canRestart) await start();
|
|
246
|
-
else process$1.exit(1);
|
|
247
|
-
}
|
|
204
|
+
if (globalThis.isDevtoolsEnabled) if (await logger.consola?.prompt("Restart(could be used to validate the profiler)?", {
|
|
205
|
+
type: "confirm",
|
|
206
|
+
initial: false
|
|
207
|
+
})) await start();
|
|
208
|
+
else process$1.exit(1);
|
|
248
209
|
}
|
|
249
210
|
});
|
|
250
211
|
var generate_default = command;
|
|
251
212
|
|
|
252
213
|
//#endregion
|
|
253
214
|
export { generate_default as default };
|
|
254
|
-
//# sourceMappingURL=generate-
|
|
215
|
+
//# sourceMappingURL=generate-BqNABk2X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-BqNABk2X.js","names":["results: Array<Config>","path","process"],"sources":["../src/utils/getPlugins.ts","../src/utils/getConfig.ts","../src/utils/getCosmiConfig.ts","../src/utils/watcher.ts","../src/commands/generate.ts"],"sourcesContent":["import type { UserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: UserConfig['plugins']) {\n return !!(plugins as any)?.some((plugin: any) => {\n return Array.isArray(plugin) && typeof plugin?.at(0) === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: UserConfig['plugins']): plugins is any {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nexport function getPlugins(plugins: UserConfig['plugins']): Promise<UserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n throw new Error('Object plugins are not supported anymore, best to use http://kubb.dev/getting-started/configure#json')\n }\n\n if (isJSONPlugins(plugins)) {\n throw new Error('JSON plugins are not supported anymore, best to use http://kubb.dev/getting-started/configure#json')\n }\n\n return Promise.resolve(plugins)\n}\n","import { isPromise } from '@kubb/core/utils'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { Config, UserConfig } from '@kubb/core'\nimport type { Args } from '../commands/generate.ts'\nimport type { CosmiconfigResult } from './getCosmiConfig.ts'\n\n/**\n * Converting UserConfig to Config without a change in the object beside the JSON convert.\n */\nexport async function getConfig(result: CosmiconfigResult, args: Args): Promise<Array<Config> | Config> {\n const config = result?.config\n let kubbUserConfig = Promise.resolve(config) as Promise<UserConfig | Array<UserConfig>>\n\n // for ts or js files\n if (typeof config === 'function') {\n const possiblePromise = config(args)\n if (isPromise(possiblePromise)) {\n kubbUserConfig = possiblePromise\n }\n kubbUserConfig = Promise.resolve(possiblePromise)\n }\n\n let JSONConfig = await kubbUserConfig\n\n if (Array.isArray(JSONConfig)) {\n const results: Array<Config> = []\n\n for (const item of JSONConfig) {\n const plugins = item.plugins ? await getPlugins(item.plugins) : undefined\n\n results.push({\n ...item,\n plugins,\n } as Config)\n }\n\n return results\n }\n\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as Config\n}\n","import type { defineConfig, UserConfig } from '@kubb/core'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { createJiti } from 'jiti'\n\nexport type CosmiconfigResult = {\n filepath: string\n isEmpty?: boolean\n config: ReturnType<typeof defineConfig> | UserConfig\n}\n\nconst tsLoader = async (configFile: string) => {\n const jiti = createJiti(import.meta.url, {\n jsx: {\n runtime: 'automatic',\n importSource: '@kubb/react',\n },\n sourceMaps: true,\n })\n\n const mod = await jiti.import(configFile, { default: true })\n\n return mod\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string): Promise<CosmiconfigResult> {\n const searchPlaces = [\n 'package.json',\n `.${moduleName}rc`,\n `.${moduleName}rc.json`,\n `.${moduleName}rc.yaml`,\n `.${moduleName}rc.yml`,\n\n `.${moduleName}rc.ts`,\n `.${moduleName}rc.js`,\n `.${moduleName}rc.mjs`,\n `.${moduleName}rc.cjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ]\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n searchPlaces: [\n ...searchPlaces.map((searchPlace) => {\n return `.config/${searchPlace}`\n }),\n ...searchPlaces.map((searchPlace) => {\n return `configs/${searchPlace}`\n }),\n ...searchPlaces,\n ],\n loaders: {\n '.ts': tsLoader,\n },\n })\n\n const result = config ? await explorer.load(config) : await explorer.search()\n\n if (result?.isEmpty || !result || !result.config) {\n throw new Error('Config not defined, create a kubb.config.js or pass through your config with the option --config')\n }\n\n return result as CosmiconfigResult\n}\n","import { createLogger } from '@kubb/core/logger'\nimport pc from 'picocolors'\n\nexport async function startWatcher(path: string[], cb: (path: string[]) => Promise<void>): Promise<void> {\n const { watch } = await import('chokidar')\n const logger = createLogger()\n\n const ignored = '**/{.git,node_modules}/**'\n\n const watcher = watch(path, {\n ignorePermissionErrors: true,\n ignored,\n })\n watcher.on('all', (type, file) => {\n logger?.emit('info', pc.yellow(pc.bold(`Change detected: ${type} ${file}`)))\n\n try {\n cb(path)\n } catch (_e) {\n logger?.emit('warning', pc.red('Watcher failed'))\n }\n })\n}\n","import path from 'node:path'\nimport * as process from 'node:process'\nimport { isInputPath, PromiseManager } from '@kubb/core'\nimport { createLogger, LogMapper } from '@kubb/core/logger'\nimport type { ArgsDef, ParsedArgs } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport type { SingleBar } from 'cli-progress'\nimport pc from 'picocolors'\nimport { getConfig } from '../utils/getConfig.ts'\nimport { getCosmiConfig } from '../utils/getCosmiConfig.ts'\nimport { startWatcher } from '../utils/watcher.ts'\n\ndeclare global {\n var isDevtoolsEnabled: any\n}\n\nconst args = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n alias: 'c',\n },\n logLevel: {\n type: 'string',\n description: 'Info, silent or debug',\n alias: 'l',\n default: 'info',\n valueHint: 'silent|info|debug',\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n alias: 'w',\n default: false,\n },\n debug: {\n type: 'boolean',\n description: 'Override logLevel to debug',\n alias: 'd',\n default: false,\n },\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nexport type Args = ParsedArgs<typeof args>\n\nconst command = defineCommand({\n meta: {\n name: 'generate',\n description: \"[input] Generate files based on a 'kubb.config.ts' file\",\n },\n args,\n async run(commandContext) {\n const progressCache = new Map<string, SingleBar>()\n\n const { args } = commandContext\n\n const input = args._[0]\n\n if (args.help) {\n return showUsage(command)\n }\n\n if (args.debug) {\n args.logLevel = 'debug'\n }\n\n const logLevel = LogMapper[args.logLevel as keyof typeof LogMapper] || 3\n const logger = createLogger({\n logLevel,\n })\n const { generate } = await import('../runners/generate.ts')\n\n logger.emit('start', 'Loading config')\n\n const result = await getCosmiConfig('kubb', args.config)\n logger.emit('success', `Config loaded(${pc.dim(path.relative(process.cwd(), result.filepath))})`)\n\n const config = await getConfig(result, args)\n\n const start = async () => {\n if (Array.isArray(config)) {\n const promiseManager = new PromiseManager()\n const promises = config.map((c) => () => {\n progressCache.clear()\n\n return generate({\n input,\n config: c,\n args,\n progressCache,\n })\n })\n\n await promiseManager.run('seq', promises)\n return\n }\n\n progressCache.clear()\n\n await generate({\n input,\n config,\n progressCache,\n args,\n })\n\n return\n }\n\n if (args.watch) {\n if (Array.isArray(config)) {\n throw new Error('Cannot use watcher with multiple Configs(array)')\n }\n\n if (isInputPath(config)) {\n return startWatcher([input || config.input.path], async (paths) => {\n await start()\n logger.emit('start', pc.yellow(pc.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n }\n\n await start()\n\n if (globalThis.isDevtoolsEnabled) {\n const canRestart = await logger.consola?.prompt('Restart(could be used to validate the profiler)?', {\n type: 'confirm',\n initial: false,\n })\n\n if (canRestart) {\n await start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AAC,SAAS,OAAO,MAAM,KAAK,EAAE,OAAO,UAAU;AACjE,UAAM,OAAO;AACb,WAAO,KAAK,SAAS,GAAG,OAAO,GAAG,KAAK,2BAA2B,MAAM,KAAK,QAAQ,GAAG,CAAC,CAAC;KAC1F;;AAIN,QAAM,OAAO;AAEb,MAAI,WAAW,kBAMb,KALmB,MAAM,OAAO,SAAS,OAAO,oDAAoD;GAClG,MAAM;GACN,SAAS;GACV,CAAC,CAGA,OAAM,OAAO;MAEb,WAAQ,KAAK,EAAE;;CAItB,CAAC;AAEF,uBAAe"}
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
let citty = require("citty");
|
|
3
|
+
citty = require_chunk.__toESM(citty);
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
node_path = require_chunk.__toESM(node_path);
|
|
6
|
+
let node_process = require("node:process");
|
|
7
|
+
node_process = require_chunk.__toESM(node_process);
|
|
8
|
+
let __kubb_core = require("@kubb/core");
|
|
9
|
+
__kubb_core = require_chunk.__toESM(__kubb_core);
|
|
10
|
+
let __kubb_core_logger = require("@kubb/core/logger");
|
|
11
|
+
__kubb_core_logger = require_chunk.__toESM(__kubb_core_logger);
|
|
12
|
+
let picocolors = require("picocolors");
|
|
13
|
+
picocolors = require_chunk.__toESM(picocolors);
|
|
14
|
+
let __kubb_core_utils = require("@kubb/core/utils");
|
|
15
|
+
__kubb_core_utils = require_chunk.__toESM(__kubb_core_utils);
|
|
16
|
+
let cosmiconfig = require("cosmiconfig");
|
|
17
|
+
cosmiconfig = require_chunk.__toESM(cosmiconfig);
|
|
18
|
+
let jiti = require("jiti");
|
|
19
|
+
jiti = require_chunk.__toESM(jiti);
|
|
12
20
|
|
|
13
21
|
//#region src/utils/getPlugins.ts
|
|
14
22
|
function isJSONPlugins(plugins) {
|
|
@@ -30,11 +38,11 @@ function getPlugins(plugins) {
|
|
|
30
38
|
/**
|
|
31
39
|
* Converting UserConfig to Config without a change in the object beside the JSON convert.
|
|
32
40
|
*/
|
|
33
|
-
async function getConfig(result, args
|
|
41
|
+
async function getConfig(result, args) {
|
|
34
42
|
const config = result?.config;
|
|
35
43
|
let kubbUserConfig = Promise.resolve(config);
|
|
36
44
|
if (typeof config === "function") {
|
|
37
|
-
const possiblePromise = config(args
|
|
45
|
+
const possiblePromise = config(args);
|
|
38
46
|
if ((0, __kubb_core_utils.isPromise)(possiblePromise)) kubbUserConfig = possiblePromise;
|
|
39
47
|
kubbUserConfig = Promise.resolve(possiblePromise);
|
|
40
48
|
}
|
|
@@ -60,15 +68,13 @@ async function getConfig(result, args$1) {
|
|
|
60
68
|
//#endregion
|
|
61
69
|
//#region src/utils/getCosmiConfig.ts
|
|
62
70
|
const tsLoader = async (configFile) => {
|
|
63
|
-
|
|
71
|
+
return await (0, jiti.createJiti)(require("url").pathToFileURL(__filename).href, {
|
|
64
72
|
jsx: {
|
|
65
73
|
runtime: "automatic",
|
|
66
74
|
importSource: "@kubb/react"
|
|
67
75
|
},
|
|
68
76
|
sourceMaps: true
|
|
69
|
-
});
|
|
70
|
-
const mod = await jiti$1.import(configFile, { default: true });
|
|
71
|
-
return mod;
|
|
77
|
+
}).import(configFile, { default: true });
|
|
72
78
|
};
|
|
73
79
|
async function getCosmiConfig(moduleName, config) {
|
|
74
80
|
const searchPlaces = [
|
|
@@ -109,12 +115,10 @@ async function getCosmiConfig(moduleName, config) {
|
|
|
109
115
|
async function startWatcher(path$1, cb) {
|
|
110
116
|
const { watch } = await import("chokidar");
|
|
111
117
|
const logger = (0, __kubb_core_logger.createLogger)();
|
|
112
|
-
|
|
113
|
-
const watcher = watch(path$1, {
|
|
118
|
+
watch(path$1, {
|
|
114
119
|
ignorePermissionErrors: true,
|
|
115
|
-
ignored
|
|
116
|
-
})
|
|
117
|
-
watcher.on("all", (type, file) => {
|
|
120
|
+
ignored: "**/{.git,node_modules}/**"
|
|
121
|
+
}).on("all", (type, file) => {
|
|
118
122
|
logger?.emit("info", picocolors.default.yellow(picocolors.default.bold(`Change detected: ${type} ${file}`)));
|
|
119
123
|
try {
|
|
120
124
|
cb(path$1);
|
|
@@ -126,74 +130,65 @@ async function startWatcher(path$1, cb) {
|
|
|
126
130
|
|
|
127
131
|
//#endregion
|
|
128
132
|
//#region src/commands/generate.ts
|
|
129
|
-
const args = {
|
|
130
|
-
config: {
|
|
131
|
-
type: "string",
|
|
132
|
-
description: "Path to the Kubb config",
|
|
133
|
-
alias: "c"
|
|
134
|
-
},
|
|
135
|
-
logLevel: {
|
|
136
|
-
type: "string",
|
|
137
|
-
description: "Info, silent or debug",
|
|
138
|
-
alias: "l",
|
|
139
|
-
default: "info",
|
|
140
|
-
valueHint: "silent|info|debug"
|
|
141
|
-
},
|
|
142
|
-
watch: {
|
|
143
|
-
type: "boolean",
|
|
144
|
-
description: "Watch mode based on the input file",
|
|
145
|
-
alias: "w",
|
|
146
|
-
default: false
|
|
147
|
-
},
|
|
148
|
-
debug: {
|
|
149
|
-
type: "boolean",
|
|
150
|
-
description: "Override logLevel to debug",
|
|
151
|
-
alias: "d",
|
|
152
|
-
default: false
|
|
153
|
-
},
|
|
154
|
-
ui: {
|
|
155
|
-
type: "boolean",
|
|
156
|
-
description: "Open ui",
|
|
157
|
-
alias: "u",
|
|
158
|
-
default: false
|
|
159
|
-
},
|
|
160
|
-
help: {
|
|
161
|
-
type: "boolean",
|
|
162
|
-
description: "Show help",
|
|
163
|
-
alias: "h",
|
|
164
|
-
default: false
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
133
|
const command = (0, citty.defineCommand)({
|
|
168
134
|
meta: {
|
|
169
135
|
name: "generate",
|
|
170
136
|
description: "[input] Generate files based on a 'kubb.config.ts' file"
|
|
171
137
|
},
|
|
172
|
-
args
|
|
138
|
+
args: {
|
|
139
|
+
config: {
|
|
140
|
+
type: "string",
|
|
141
|
+
description: "Path to the Kubb config",
|
|
142
|
+
alias: "c"
|
|
143
|
+
},
|
|
144
|
+
logLevel: {
|
|
145
|
+
type: "string",
|
|
146
|
+
description: "Info, silent or debug",
|
|
147
|
+
alias: "l",
|
|
148
|
+
default: "info",
|
|
149
|
+
valueHint: "silent|info|debug"
|
|
150
|
+
},
|
|
151
|
+
watch: {
|
|
152
|
+
type: "boolean",
|
|
153
|
+
description: "Watch mode based on the input file",
|
|
154
|
+
alias: "w",
|
|
155
|
+
default: false
|
|
156
|
+
},
|
|
157
|
+
debug: {
|
|
158
|
+
type: "boolean",
|
|
159
|
+
description: "Override logLevel to debug",
|
|
160
|
+
alias: "d",
|
|
161
|
+
default: false
|
|
162
|
+
},
|
|
163
|
+
help: {
|
|
164
|
+
type: "boolean",
|
|
165
|
+
description: "Show help",
|
|
166
|
+
alias: "h",
|
|
167
|
+
default: false
|
|
168
|
+
}
|
|
169
|
+
},
|
|
173
170
|
async run(commandContext) {
|
|
174
|
-
let name = "";
|
|
175
171
|
const progressCache = /* @__PURE__ */ new Map();
|
|
176
|
-
const { args
|
|
177
|
-
const input = args
|
|
178
|
-
if (args
|
|
179
|
-
if (args
|
|
180
|
-
const logLevel = __kubb_core_logger.LogMapper[args
|
|
172
|
+
const { args } = commandContext;
|
|
173
|
+
const input = args._[0];
|
|
174
|
+
if (args.help) return (0, citty.showUsage)(command);
|
|
175
|
+
if (args.debug) args.logLevel = "debug";
|
|
176
|
+
const logLevel = __kubb_core_logger.LogMapper[args.logLevel] || 3;
|
|
181
177
|
const logger = (0, __kubb_core_logger.createLogger)({ logLevel });
|
|
182
|
-
const { generate } = await Promise.resolve().then(() => require("./generate-
|
|
178
|
+
const { generate } = await Promise.resolve().then(() => require("./generate-BALD2C5T.cjs"));
|
|
183
179
|
logger.emit("start", "Loading config");
|
|
184
|
-
const result = await getCosmiConfig("kubb", args
|
|
180
|
+
const result = await getCosmiConfig("kubb", args.config);
|
|
185
181
|
logger.emit("success", `Config loaded(${picocolors.default.dim(node_path.default.relative(node_process.cwd(), result.filepath))})`);
|
|
186
|
-
const config = await getConfig(result, args
|
|
182
|
+
const config = await getConfig(result, args);
|
|
187
183
|
const start = async () => {
|
|
188
184
|
if (Array.isArray(config)) {
|
|
189
185
|
const promiseManager = new __kubb_core.PromiseManager();
|
|
190
186
|
const promises = config.map((c) => () => {
|
|
191
|
-
name = c.name || "";
|
|
192
187
|
progressCache.clear();
|
|
193
188
|
return generate({
|
|
194
189
|
input,
|
|
195
190
|
config: c,
|
|
196
|
-
args
|
|
191
|
+
args,
|
|
197
192
|
progressCache
|
|
198
193
|
});
|
|
199
194
|
});
|
|
@@ -205,32 +200,10 @@ const command = (0, citty.defineCommand)({
|
|
|
205
200
|
input,
|
|
206
201
|
config,
|
|
207
202
|
progressCache,
|
|
208
|
-
args
|
|
203
|
+
args
|
|
209
204
|
});
|
|
210
205
|
};
|
|
211
|
-
if (args
|
|
212
|
-
const { startServer } = await import("@kubb/ui");
|
|
213
|
-
await startServer({
|
|
214
|
-
stop: () => node_process.exit(1),
|
|
215
|
-
restart: () => start(),
|
|
216
|
-
getMeta: () => {
|
|
217
|
-
const entries = [...progressCache.entries()];
|
|
218
|
-
const percentages = entries.reduce((acc, [key, singleBar]) => {
|
|
219
|
-
acc[key] = singleBar.getProgress();
|
|
220
|
-
return acc;
|
|
221
|
-
}, {});
|
|
222
|
-
return {
|
|
223
|
-
name,
|
|
224
|
-
percentages
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
}, (info) => {
|
|
228
|
-
const url = `${info.address}:${info.port}`.replace("::", "http://localhost");
|
|
229
|
-
logger.consola?.start(`Starting ui on ${url}`);
|
|
230
|
-
(0, open.default)(url);
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
if (args$1.watch) {
|
|
206
|
+
if (args.watch) {
|
|
234
207
|
if (Array.isArray(config)) throw new Error("Cannot use watcher with multiple Configs(array)");
|
|
235
208
|
if ((0, __kubb_core.isInputPath)(config)) return startWatcher([input || config.input.path], async (paths) => {
|
|
236
209
|
await start();
|
|
@@ -238,18 +211,15 @@ const command = (0, citty.defineCommand)({
|
|
|
238
211
|
});
|
|
239
212
|
}
|
|
240
213
|
await start();
|
|
241
|
-
if (globalThis.isDevtoolsEnabled) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
if (canRestart) await start();
|
|
247
|
-
else node_process.exit(1);
|
|
248
|
-
}
|
|
214
|
+
if (globalThis.isDevtoolsEnabled) if (await logger.consola?.prompt("Restart(could be used to validate the profiler)?", {
|
|
215
|
+
type: "confirm",
|
|
216
|
+
initial: false
|
|
217
|
+
})) await start();
|
|
218
|
+
else node_process.exit(1);
|
|
249
219
|
}
|
|
250
220
|
});
|
|
251
221
|
var generate_default = command;
|
|
252
222
|
|
|
253
223
|
//#endregion
|
|
254
224
|
exports.default = generate_default;
|
|
255
|
-
//# sourceMappingURL=generate-
|
|
225
|
+
//# sourceMappingURL=generate-DKlT22M0.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-DKlT22M0.cjs","names":["results: Array<Config>","path","pc","LogMapper","pc","path","process","PromiseManager"],"sources":["../src/utils/getPlugins.ts","../src/utils/getConfig.ts","../src/utils/getCosmiConfig.ts","../src/utils/watcher.ts","../src/commands/generate.ts"],"sourcesContent":["import type { UserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: UserConfig['plugins']) {\n return !!(plugins as any)?.some((plugin: any) => {\n return Array.isArray(plugin) && typeof plugin?.at(0) === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: UserConfig['plugins']): plugins is any {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nexport function getPlugins(plugins: UserConfig['plugins']): Promise<UserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n throw new Error('Object plugins are not supported anymore, best to use http://kubb.dev/getting-started/configure#json')\n }\n\n if (isJSONPlugins(plugins)) {\n throw new Error('JSON plugins are not supported anymore, best to use http://kubb.dev/getting-started/configure#json')\n }\n\n return Promise.resolve(plugins)\n}\n","import { isPromise } from '@kubb/core/utils'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { Config, UserConfig } from '@kubb/core'\nimport type { Args } from '../commands/generate.ts'\nimport type { CosmiconfigResult } from './getCosmiConfig.ts'\n\n/**\n * Converting UserConfig to Config without a change in the object beside the JSON convert.\n */\nexport async function getConfig(result: CosmiconfigResult, args: Args): Promise<Array<Config> | Config> {\n const config = result?.config\n let kubbUserConfig = Promise.resolve(config) as Promise<UserConfig | Array<UserConfig>>\n\n // for ts or js files\n if (typeof config === 'function') {\n const possiblePromise = config(args)\n if (isPromise(possiblePromise)) {\n kubbUserConfig = possiblePromise\n }\n kubbUserConfig = Promise.resolve(possiblePromise)\n }\n\n let JSONConfig = await kubbUserConfig\n\n if (Array.isArray(JSONConfig)) {\n const results: Array<Config> = []\n\n for (const item of JSONConfig) {\n const plugins = item.plugins ? await getPlugins(item.plugins) : undefined\n\n results.push({\n ...item,\n plugins,\n } as Config)\n }\n\n return results\n }\n\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as Config\n}\n","import type { defineConfig, UserConfig } from '@kubb/core'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { createJiti } from 'jiti'\n\nexport type CosmiconfigResult = {\n filepath: string\n isEmpty?: boolean\n config: ReturnType<typeof defineConfig> | UserConfig\n}\n\nconst tsLoader = async (configFile: string) => {\n const jiti = createJiti(import.meta.url, {\n jsx: {\n runtime: 'automatic',\n importSource: '@kubb/react',\n },\n sourceMaps: true,\n })\n\n const mod = await jiti.import(configFile, { default: true })\n\n return mod\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string): Promise<CosmiconfigResult> {\n const searchPlaces = [\n 'package.json',\n `.${moduleName}rc`,\n `.${moduleName}rc.json`,\n `.${moduleName}rc.yaml`,\n `.${moduleName}rc.yml`,\n\n `.${moduleName}rc.ts`,\n `.${moduleName}rc.js`,\n `.${moduleName}rc.mjs`,\n `.${moduleName}rc.cjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ]\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n searchPlaces: [\n ...searchPlaces.map((searchPlace) => {\n return `.config/${searchPlace}`\n }),\n ...searchPlaces.map((searchPlace) => {\n return `configs/${searchPlace}`\n }),\n ...searchPlaces,\n ],\n loaders: {\n '.ts': tsLoader,\n },\n })\n\n const result = config ? await explorer.load(config) : await explorer.search()\n\n if (result?.isEmpty || !result || !result.config) {\n throw new Error('Config not defined, create a kubb.config.js or pass through your config with the option --config')\n }\n\n return result as CosmiconfigResult\n}\n","import { createLogger } from '@kubb/core/logger'\nimport pc from 'picocolors'\n\nexport async function startWatcher(path: string[], cb: (path: string[]) => Promise<void>): Promise<void> {\n const { watch } = await import('chokidar')\n const logger = createLogger()\n\n const ignored = '**/{.git,node_modules}/**'\n\n const watcher = watch(path, {\n ignorePermissionErrors: true,\n ignored,\n })\n watcher.on('all', (type, file) => {\n logger?.emit('info', pc.yellow(pc.bold(`Change detected: ${type} ${file}`)))\n\n try {\n cb(path)\n } catch (_e) {\n logger?.emit('warning', pc.red('Watcher failed'))\n }\n })\n}\n","import path from 'node:path'\nimport * as process from 'node:process'\nimport { isInputPath, PromiseManager } from '@kubb/core'\nimport { createLogger, LogMapper } from '@kubb/core/logger'\nimport type { ArgsDef, ParsedArgs } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport type { SingleBar } from 'cli-progress'\nimport pc from 'picocolors'\nimport { getConfig } from '../utils/getConfig.ts'\nimport { getCosmiConfig } from '../utils/getCosmiConfig.ts'\nimport { startWatcher } from '../utils/watcher.ts'\n\ndeclare global {\n var isDevtoolsEnabled: any\n}\n\nconst args = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n alias: 'c',\n },\n logLevel: {\n type: 'string',\n description: 'Info, silent or debug',\n alias: 'l',\n default: 'info',\n valueHint: 'silent|info|debug',\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n alias: 'w',\n default: false,\n },\n debug: {\n type: 'boolean',\n description: 'Override logLevel to debug',\n alias: 'd',\n default: false,\n },\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nexport type Args = ParsedArgs<typeof args>\n\nconst command = defineCommand({\n meta: {\n name: 'generate',\n description: \"[input] Generate files based on a 'kubb.config.ts' file\",\n },\n args,\n async run(commandContext) {\n const progressCache = new Map<string, SingleBar>()\n\n const { args } = commandContext\n\n const input = args._[0]\n\n if (args.help) {\n return showUsage(command)\n }\n\n if (args.debug) {\n args.logLevel = 'debug'\n }\n\n const logLevel = LogMapper[args.logLevel as keyof typeof LogMapper] || 3\n const logger = createLogger({\n logLevel,\n })\n const { generate } = await import('../runners/generate.ts')\n\n logger.emit('start', 'Loading config')\n\n const result = await getCosmiConfig('kubb', args.config)\n logger.emit('success', `Config loaded(${pc.dim(path.relative(process.cwd(), result.filepath))})`)\n\n const config = await getConfig(result, args)\n\n const start = async () => {\n if (Array.isArray(config)) {\n const promiseManager = new PromiseManager()\n const promises = config.map((c) => () => {\n progressCache.clear()\n\n return generate({\n input,\n config: c,\n args,\n progressCache,\n })\n })\n\n await promiseManager.run('seq', promises)\n return\n }\n\n progressCache.clear()\n\n await generate({\n input,\n config,\n progressCache,\n args,\n })\n\n return\n }\n\n if (args.watch) {\n if (Array.isArray(config)) {\n throw new Error('Cannot use watcher with multiple Configs(array)')\n }\n\n if (isInputPath(config)) {\n return startWatcher([input || config.input.path], async (paths) => {\n await start()\n logger.emit('start', pc.yellow(pc.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n }\n\n await start()\n\n if (globalThis.isDevtoolsEnabled) {\n const canRestart = await logger.consola?.prompt('Restart(could be used to validate the profiler)?', {\n type: 'confirm',\n initial: false,\n })\n\n if (canRestart) {\n await start()\n } else {\n process.exit(1)\n }\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,cAAc,SAAgC;AACrD,QAAO,CAAC,CAAE,SAAiB,MAAM,WAAgB;AAC/C,SAAO,MAAM,QAAQ,OAAO,IAAI,OAAO,QAAQ,GAAG,EAAE,KAAK;GACzD;;AAGJ,SAAS,gBAAgB,SAAgD;AACvE,QAAO,mBAAmB,UAAU,CAAC,MAAM,QAAQ,QAAQ;;AAG7D,SAAgB,WAAW,SAAgE;AACzF,KAAI,gBAAgB,QAAQ,CAC1B,OAAM,IAAI,MAAM,uGAAuG;AAGzH,KAAI,cAAc,QAAQ,CACxB,OAAM,IAAI,MAAM,qGAAqG;AAGvH,QAAO,QAAQ,QAAQ,QAAQ;;;;;;;;ACVjC,eAAsB,UAAU,QAA2B,MAA6C;CACtG,MAAM,SAAS,QAAQ;CACvB,IAAI,iBAAiB,QAAQ,QAAQ,OAAO;AAG5C,KAAI,OAAO,WAAW,YAAY;EAChC,MAAM,kBAAkB,OAAO,KAAK;AACpC,uCAAc,gBAAgB,CAC5B,kBAAiB;AAEnB,mBAAiB,QAAQ,QAAQ,gBAAgB;;CAGnD,IAAI,aAAa,MAAM;AAEvB,KAAI,MAAM,QAAQ,WAAW,EAAE;EAC7B,MAAMA,UAAyB,EAAE;AAEjC,OAAK,MAAM,QAAQ,YAAY;GAC7B,MAAM,UAAU,KAAK,UAAU,MAAM,WAAW,KAAK,QAAQ,GAAG;AAEhE,WAAQ,KAAK;IACX,GAAG;IACH;IACD,CAAW;;AAGd,SAAO;;AAGT,cAAa;EACX,GAAG;EACH,SAAS,WAAW,UAAU,MAAM,WAAW,WAAW,QAAQ,GAAG;EACtE;AAED,QAAO;;;;;ACpCT,MAAM,WAAW,OAAO,eAAuB;AAW7C,QAFY,0EAR6B;EACvC,KAAK;GACH,SAAS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