@kubb/cli 2.18.3 → 2.18.5

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/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- declare function run(argv?: string[]): Promise<void>;
1
+ declare function run(_argv?: string[]): Promise<void>;
2
2
 
3
- export { run as default, run };
3
+ export { run };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare function run(argv?: string[]): Promise<void>;
1
+ declare function run(_argv?: string[]): Promise<void>;
2
2
 
3
- export { run as default, run };
3
+ export { run };
package/dist/index.js CHANGED
@@ -1,501 +1,51 @@
1
1
  // src/index.ts
2
- import path3 from "path";
3
- import { PromiseManager, Warning, isInputPath } from "@kubb/core";
4
- import { cac } from "cac";
5
- import c6 from "tinyrainbow";
2
+ import { defineCommand, runCommand, runMain } from "citty";
3
+ import getLatestVersion from "latest-version";
4
+ import { lt } from "semver";
5
+ import consola from "consola";
6
6
 
7
7
  // package.json
8
- var version = "2.18.3";
8
+ var version = "2.18.5";
9
9
 
10
- // src/generate.ts
11
- import { LogLevel, createLogger, randomCliColour as randomCliColour2 } from "@kubb/core/logger";
12
- import { execa } from "execa";
13
- import { get } from "js-runtime";
14
- import { parseArgsStringToArgv } from "string-argv";
15
- import c3 from "tinyrainbow";
16
-
17
- // src/utils/OraWritable.ts
18
- import { Writable } from "stream";
19
- import c from "tinyrainbow";
20
- var OraWritable = class extends Writable {
21
- constructor(spinner2, command, opts) {
22
- super(opts);
23
- this.command = command;
24
- this.spinner = spinner2;
25
- }
26
- _write(chunk, _encoding, callback2) {
27
- this.spinner.suffixText = `
28
-
29
- ${c.bold(c.blue(this.command))}: ${chunk?.toString()}`;
30
- callback2();
31
- }
32
- };
33
-
34
- // src/utils/spinner.ts
35
- import ora from "ora";
36
- var spinner = ora({
37
- spinner: "clock"
38
- });
39
-
40
- // src/generate.ts
41
- import { safeBuild } from "@kubb/core";
42
-
43
- // src/utils/getSummary.ts
44
- import path from "path";
45
- import { randomCliColour } from "@kubb/core/logger";
46
- import c2 from "tinyrainbow";
47
-
48
- // src/utils/parseHrtimeToSeconds.ts
49
- function parseHrtimeToSeconds(hrtime) {
50
- const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
51
- return seconds;
52
- }
53
-
54
- // src/utils/getSummary.ts
55
- function getSummary({ pluginManager, status, hrstart, config, logger }) {
56
- const { logLevel } = logger;
57
- const logs = [];
58
- const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart));
59
- const buildStartPlugins = pluginManager.executed.filter((item) => item.hookName === "buildStart" && item.plugin.name !== "core").map((item) => item.plugin.name);
60
- const buildEndPlugins = pluginManager.executed.filter((item) => item.hookName === "buildEnd" && item.plugin.name !== "core").map((item) => item.plugin.name);
61
- const failedPlugins = config.plugins?.filter((plugin) => !buildEndPlugins.includes(plugin.name))?.map((plugin) => plugin.name);
62
- const pluginsCount = config.plugins?.length || 0;
63
- const files = pluginManager.fileManager.files.sort((a, b) => {
64
- if (!a.meta?.pluginKey?.[0] || !b.meta?.pluginKey?.[0]) {
65
- return 0;
66
- }
67
- if (a.meta?.pluginKey?.[0]?.length < b.meta?.pluginKey?.[0]?.length) {
68
- return 1;
69
- }
70
- if (a.meta?.pluginKey?.[0]?.length > b.meta?.pluginKey?.[0]?.length) {
71
- return -1;
72
- }
73
- return 0;
74
- });
75
- const meta = {
76
- name: config.name,
77
- plugins: status === "success" ? `${c2.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${c2.red(`${failedPlugins?.length ?? 1} failed`)}, ${pluginsCount} total`,
78
- pluginsFailed: status === "failed" ? failedPlugins?.map((name) => randomCliColour(name))?.join(", ") : void 0,
79
- filesCreated: files.length,
80
- time: c2.yellow(`${elapsedSeconds}s`),
81
- endTime: c2.yellow(Date()),
82
- output: path.isAbsolute(config.root) ? path.resolve(config.root, config.output.path) : config.root
83
- };
84
- logger.emit("debug", ["\nGenerated files:\n"]);
85
- logger.emit(
86
- "debug",
87
- files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`)
88
- );
89
- logs.push(
90
- [
91
- ["\n", true],
92
- [` ${c2.bold("Name:")} ${meta.name}`, !!meta.name],
93
- [` ${c2.bold("Plugins:")} ${meta.plugins}`, true],
94
- [` ${c2.dim("Failed:")} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
95
- [`${c2.bold("Generated:")} ${meta.filesCreated} files`, true],
96
- [` ${c2.bold("Time:")} ${meta.time}`, true],
97
- [` ${c2.bold("Ended:")} ${meta.endTime}`, true],
98
- [` ${c2.bold("Output:")} ${meta.output}`, true],
99
- ["\n", true]
100
- ].map((item) => {
101
- if (item.at(1)) {
102
- return item.at(0);
103
- }
104
- return void 0;
105
- }).filter(Boolean).join("\n")
106
- );
107
- return logs;
108
- }
109
-
110
- // src/generate.ts
111
- async function executeHooks({ hooks, logLevel }) {
112
- if (!hooks?.done) {
113
- return;
114
- }
115
- const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done];
116
- if (logLevel === LogLevel.silent) {
117
- spinner.start("Executing hooks");
118
- }
119
- const executers = commands.map(async (command) => {
120
- const oraWritable = new OraWritable(spinner, command);
121
- const abortController = new AbortController();
122
- const [cmd, ..._args] = [...parseArgsStringToArgv(command)];
123
- if (!cmd) {
124
- return null;
125
- }
126
- spinner.start(`Executing hook ${logLevel !== "silent" ? c3.dim(command) : ""}`);
127
- const subProcess = await execa(cmd, _args, {
128
- detached: true,
129
- signal: abortController.signal
130
- }).pipeStdout?.(oraWritable);
131
- spinner.suffixText = "";
132
- if (logLevel === LogLevel.silent) {
133
- spinner.succeed(`Executing hook ${logLevel !== "silent" ? c3.dim(command) : ""}`);
134
- if (subProcess) {
135
- console.log(subProcess.stdout);
136
- }
137
- }
138
- oraWritable.destroy();
139
- return { subProcess, abort: abortController.abort.bind(abortController) };
140
- }).filter(Boolean);
141
- await Promise.all(executers);
142
- if (logLevel === LogLevel.silent) {
143
- spinner.succeed("Executing hooks");
144
- }
145
- }
146
- async function generate({ input, config, CLIOptions }) {
147
- const logger = createLogger({
148
- logLevel: CLIOptions.logLevel || LogLevel.silent,
149
- name: config.name,
150
- spinner
151
- });
152
- if (logger.name) {
153
- spinner.prefixText = randomCliColour2(logger.name);
154
- }
155
- const hrstart = process.hrtime();
156
- if (CLIOptions.logLevel === LogLevel.debug) {
157
- const { performance, PerformanceObserver } = await import("perf_hooks");
158
- const performanceOpserver = new PerformanceObserver((items) => {
159
- const message = `${items.getEntries()[0]?.duration.toFixed(0)}ms`;
160
- spinner.suffixText = c3.yellow(message);
161
- performance.clearMarks();
162
- });
163
- performanceOpserver.observe({ type: "measure" });
164
- }
165
- const { root: _root, ...userConfig } = config;
166
- const logLevel = logger.logLevel;
167
- const inputPath = input ?? ("path" in userConfig.input ? userConfig.input.path : void 0);
168
- spinner.start(`\u{1F680} Building with ${get()} ${logLevel !== "silent" ? c3.dim(inputPath) : ""}`);
169
- const definedConfig = {
170
- root: process.cwd(),
171
- ...userConfig,
172
- input: inputPath ? {
173
- ...userConfig.input,
174
- path: inputPath
175
- } : userConfig.input,
176
- output: {
177
- write: true,
178
- ...userConfig.output
179
- }
180
- };
181
- const { pluginManager, error } = await safeBuild({
182
- config: definedConfig,
183
- logger
184
- });
185
- const summary = getSummary({
186
- pluginManager,
187
- config: definedConfig,
188
- status: error ? "failed" : "success",
189
- hrstart,
190
- logger
191
- });
192
- if (error) {
193
- spinner.suffixText = "";
194
- spinner.fail(`\u{1F680} Build failed ${logLevel !== "silent" ? c3.dim(inputPath) : ""}`);
195
- console.log(summary.join(""));
196
- throw error;
197
- }
198
- await executeHooks({ hooks: config.hooks, logLevel });
199
- spinner.suffixText = "";
200
- spinner.succeed(`\u{1F680} Build completed with ${get()} ${logLevel !== "silent" ? c3.dim(inputPath) : ""}`);
201
- console.log(summary.join(""));
202
- }
203
-
204
- // src/init.ts
205
- import path2 from "path";
206
- import { write } from "@kubb/core/fs";
207
- import { LogLevel as LogLevel2 } from "@kubb/core/logger";
208
- import { isPromiseFulfilledResult } from "@kubb/core/utils";
209
- import { $ } from "execa";
210
- import c4 from "tinyrainbow";
211
- var presets = {
212
- simple: {
213
- "kubb.config": `
214
- import { defineConfig } from '@kubb/core'
215
- import { pluginOas } from '@kubb/plugin-oas'
216
- import { pluginTs } from '@kubb/swagger-ts'
217
- import { pluginTanstackQuery } from '@kubb/swagger-tanstack-query'
218
-
219
- export default defineConfig({
220
- root: '.',
221
- input: {
222
- path: 'https://petstore3.swagger.io/api/v3/openapi.json',
223
- },
224
- output: {
225
- path: './src/gen',
226
- clean: true,
227
- },
228
- hooks: {
229
- done: ['echo "\u{1F389} done"'],
10
+ // src/index.ts
11
+ var name = "kubb";
12
+ var main = defineCommand({
13
+ meta: {
14
+ name,
15
+ version,
16
+ description: "Kubb generation"
230
17
  },
231
- plugins: [pluginOas({}), pluginTs({ output: { path: 'models'}, enumType: 'enum' }), pluginTanstackQuery({ output: { path: './hooks' } })],
232
- })
233
- `,
234
- packages: ["@kubb/core", "@kubb/cli", "@kubb/swagger", "@kubb/swagger-ts", "@kubb/swagger-tanstack-query"]
235
- }
236
- };
237
- async function init({ preset = "simple", logLevel = LogLevel2.silent, packageManager = "pnpm" }) {
238
- spinner.start("\u{1F4E6} Initializing Kubb");
239
- const presetMeta = presets[preset];
240
- const configPath = path2.resolve(process.cwd(), "./kubb.config.js");
241
- const installCommand = packageManager === "npm" ? "install" : "add";
242
- spinner.start(`\u{1F4C0} Writing \`kubb.config.js\` ${c4.dim(configPath)}`);
243
- await write(presetMeta["kubb.config"], configPath);
244
- spinner.succeed(`\u{1F4C0} Wrote \`kubb.config.js\` ${c4.dim(configPath)}`);
245
- const results = await Promise.allSettled([
246
- $`npm init es6 -y`,
247
- ...presetMeta.packages.map(async (pack) => {
248
- spinner.start(`\u{1F4C0} Installing ${c4.dim(pack)}`);
249
- const { stdout } = await $({
250
- preferLocal: false
251
- })`${packageManager} ${installCommand} ${pack}`;
252
- spinner.succeed(`\u{1F4C0} Installed ${c4.dim(pack)}`);
253
- return stdout;
254
- })
255
- ]);
256
- if (logLevel === LogLevel2.info) {
257
- results.forEach((result) => {
258
- if (isPromiseFulfilledResult(result)) {
259
- console.log(result.value);
260
- }
261
- });
262
- }
263
- spinner.succeed("\u{1F4E6} initialized Kubb");
264
- return;
265
- }
266
-
267
- // src/utils/getConfig.ts
268
- import { isPromise } from "@kubb/core/utils";
269
-
270
- // src/utils/getPlugins.ts
271
- import { PackageManager } from "@kubb/core";
272
- function isJSONPlugins(plugins) {
273
- return !!plugins?.some((plugin) => {
274
- return Array.isArray(plugin) && typeof plugin?.at(0) === "string";
275
- });
276
- }
277
- function isObjectPlugins(plugins) {
278
- return plugins instanceof Object && !Array.isArray(plugins);
279
- }
280
- async function importPlugin(name, options) {
281
- const packageManager = new PackageManager(process.cwd());
282
- const importedPlugin = process.env.NODE_ENV === "test" ? await import(name) : await packageManager.import(name);
283
- return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options);
284
- }
285
- function getPlugins(plugins) {
286
- if (isObjectPlugins(plugins)) {
287
- throw new Error("Object plugins are not supported anymore, best to use http://kubb.dev/guide/configure#json");
288
- }
289
- if (isJSONPlugins(plugins)) {
290
- const jsonPlugins = plugins;
291
- const promises = jsonPlugins.map((plugin) => {
292
- const [name, options = {}] = plugin;
293
- return importPlugin(name, options);
294
- });
295
- return Promise.all(promises);
296
- }
297
- return Promise.resolve(plugins);
298
- }
299
-
300
- // src/utils/getConfig.ts
301
- async function getConfig(result, CLIOptions) {
302
- const config = result?.config;
303
- let kubbUserConfig = Promise.resolve(config);
304
- if (typeof config === "function") {
305
- const possiblePromise = config(CLIOptions);
306
- if (isPromise(possiblePromise)) {
307
- kubbUserConfig = possiblePromise;
308
- }
309
- kubbUserConfig = Promise.resolve(possiblePromise);
310
- }
311
- let JSONConfig = await kubbUserConfig;
312
- if (Array.isArray(JSONConfig)) {
313
- const promises = JSONConfig.map(async (item) => {
314
- return {
315
- ...item,
316
- plugins: item.plugins ? await getPlugins(item.plugins) : void 0
317
- };
318
- });
319
- return Promise.all(promises);
320
- }
321
- JSONConfig = {
322
- ...JSONConfig,
323
- plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : void 0
324
- };
325
- return JSONConfig;
326
- }
327
-
328
- // src/utils/getCosmiConfig.ts
329
- import { bundleRequire } from "bundle-require";
330
- import { cosmiconfig } from "cosmiconfig";
331
- var tsLoader = async (configFile) => {
332
- const { mod } = await bundleRequire({
333
- filepath: configFile,
334
- preserveTemporaryFile: false
335
- });
336
- return mod.default;
337
- };
338
- async function getCosmiConfig(moduleName2, config) {
339
- const searchPlaces = [
340
- "package.json",
341
- `.${moduleName2}rc`,
342
- `.${moduleName2}rc.json`,
343
- `.${moduleName2}rc.yaml`,
344
- `.${moduleName2}rc.yml`,
345
- `.${moduleName2}rc.ts`,
346
- `.${moduleName2}rc.js`,
347
- `.${moduleName2}rc.mjs`,
348
- `.${moduleName2}rc.cjs`,
349
- `${moduleName2}.config.ts`,
350
- `${moduleName2}.config.js`,
351
- `${moduleName2}.config.mjs`,
352
- `${moduleName2}.config.cjs`
353
- ];
354
- const explorer = cosmiconfig(moduleName2, {
355
- cache: false,
356
- searchPlaces: [
357
- ...searchPlaces.map((searchPlace) => {
358
- return `.config/${searchPlace}`;
359
- }),
360
- ...searchPlaces.map((searchPlace) => {
361
- return `configs/${searchPlace}`;
362
- }),
363
- ...searchPlaces
364
- ],
365
- loaders: {
366
- ".ts": tsLoader
367
- }
368
- });
369
- const result = config ? await explorer.load(config) : await explorer.search();
370
- if (result?.isEmpty || !result || !result.config) {
371
- throw new Error("Config not defined, create a kubb.config.js or pass through your config with the option --config");
372
- }
373
- return result;
374
- }
375
-
376
- // src/utils/renderErrors.ts
377
- import { LogLevel as LogLevel3 } from "@kubb/core/logger";
378
- import PrettyError from "pretty-error";
379
- var prettyError = new PrettyError().skipPackage("commander").skip(function callback(traceLine) {
380
- const pattern = /renderErrors/;
381
- const hasMatch = traceLine?.file?.match(pattern);
382
- if (typeof traceLine.packageName !== "undefined" && hasMatch) {
383
- return true;
384
- }
385
- }).start();
386
- function getErrorCauses(errors) {
387
- return errors.reduce((prev, error) => {
388
- const causedError = error?.cause;
389
- if (causedError) {
390
- prev = [...prev, ...getErrorCauses([causedError])];
391
- return prev;
392
- }
393
- prev = [...prev, error];
394
- return prev;
395
- }, []).filter(Boolean);
396
- }
397
- function renderErrors(error, { logLevel = LogLevel3.silent }) {
398
- if (!error) {
399
- return "";
400
- }
401
- if (logLevel === LogLevel3.silent) {
402
- prettyError.skipNodeFiles();
403
- prettyError.skip(function skip() {
404
- return true;
405
- });
406
- return [prettyError.render(error)].filter(Boolean).join("\n");
407
- }
408
- const errors = getErrorCauses([error]);
409
- if (logLevel === LogLevel3.debug) {
410
- console.log(errors);
411
- }
412
- return errors.filter(Boolean).map((error2) => prettyError.render(error2)).join("\n");
413
- }
414
-
415
- // src/utils/watcher.ts
416
- import c5 from "tinyrainbow";
417
- async function startWatcher(path4, cb) {
418
- const { watch } = await import("chokidar");
419
- const ignored = ["**/{.git,node_modules}/**"];
420
- const watcher = watch(path4, {
421
- ignorePermissionErrors: true,
422
- ignored
423
- });
424
- watcher.on("all", (type, file) => {
425
- spinner.succeed(c5.yellow(c5.bold(`Change detected: ${type} ${file}`)));
426
- spinner.spinner = "clock";
18
+ async setup({ rawArgs }) {
427
19
  try {
428
- cb(path4);
429
- } catch (e) {
430
- spinner.warn(c5.red("Watcher failed"));
431
- }
432
- });
433
- return;
434
- }
435
-
436
- // src/index.ts
437
- import { execa as execa2 } from "execa";
438
- var moduleName = "kubb";
439
- function programCatcher(e, CLIOptions) {
440
- const error = e;
441
- const message = renderErrors(error, { logLevel: CLIOptions.logLevel });
442
- if (error instanceof Warning) {
443
- spinner.warn(c6.yellow(error.message));
444
- process.exit(0);
445
- }
446
- spinner.fail(message);
447
- process.exit(1);
448
- }
449
- async function generateAction(input, CLIOptions) {
450
- if (CLIOptions.bun) {
451
- const command = process.argv.splice(2).filter((item) => item !== "--bun");
452
- await execa2("bkubb", command, { stdout: process.stdout, stderr: process.stderr });
453
- return;
454
- }
455
- spinner.start("\u{1F50D} Loading config");
456
- const result = await getCosmiConfig(moduleName, CLIOptions.config);
457
- spinner.succeed(`\u{1F50D} Config loaded(${c6.dim(path3.relative(process.cwd(), result.filepath))})`);
458
- const config = await getConfig(result, CLIOptions);
459
- if (CLIOptions.watch) {
460
- if (Array.isArray(config)) {
461
- throw new Error("Cannot use watcher with multiple Configs(array)");
20
+ const latestVersion = await getLatestVersion("@kubb/cli");
21
+ if (lt(version, latestVersion)) {
22
+ consola.box({
23
+ title: "Update available for `Kubb` ",
24
+ message: `\`v${version}\` \u2192 \`v${latestVersion}\`
25
+ Run \`npm install -g @kubb/cli\` to update`,
26
+ style: {
27
+ padding: 2,
28
+ borderColor: "yellow",
29
+ borderStyle: "rounded"
30
+ }
31
+ });
32
+ }
33
+ } catch (_e) {
462
34
  }
463
- if (isInputPath(config)) {
464
- return startWatcher([input || config.input.path], async (paths) => {
465
- await generate({ config, CLIOptions });
466
- spinner.spinner = "simpleDotsScrolling";
467
- spinner.start(c6.yellow(c6.bold(`Watching for changes in ${paths.join(" and ")}`)));
468
- });
35
+ if (rawArgs[0] !== "generate") {
36
+ const generateCommand = await import("./generate-INH7FPTG.js").then((r) => r.default);
37
+ await runCommand(generateCommand, { rawArgs });
38
+ process.exit(0);
469
39
  }
40
+ },
41
+ subCommands: {
42
+ generate: () => import("./generate-INH7FPTG.js").then((r) => r.default)
470
43
  }
471
- if (Array.isArray(config)) {
472
- const promiseManager = new PromiseManager();
473
- const promises = config.map((item) => () => generate({ input, config: item, CLIOptions }));
474
- await promiseManager.run("seq", promises);
475
- return;
476
- }
477
- await generate({ input, config, CLIOptions });
478
- }
479
- async function run(argv) {
480
- const program = cac(moduleName);
481
- program.command("[input]", "Path of the input file(overrides the one in `kubb.config.js`)").option("-c, --config <path>", "Path to the Kubb config").option("-l, --log-level <type>", "Info, silent or debug").option("-w, --watch", "Watch mode based on the input file").option("-b, --bun", "Run Kubb with Bun").action(generateAction);
482
- program.command("generate [input]", "Path of the input file(overrides the one in `kubb.config.js`)").option("-c, --config <path>", "Path to the Kubb config").option("-l, --log-level <type>", "Info, silent or debug").option("-w, --watch", "Watch mode based on the input file").option("-b, --bun", "Run Kubb with Bun").action(generateAction);
483
- program.command("init", "Init Kubb").action(async () => {
484
- return init({ logLevel: "info" });
485
- });
486
- program.help();
487
- program.version(version);
488
- program.parse(argv, { run: false });
489
- try {
490
- await program.runMatchedCommand();
491
- process.exit(0);
492
- } catch (e) {
493
- programCatcher(e, program.options);
494
- }
44
+ });
45
+ async function run(_argv) {
46
+ await runMain(main);
495
47
  }
496
- var src_default = run;
497
48
  export {
498
- src_default as default,
499
49
  run
500
50
  };
501
51
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../package.json","../src/generate.ts","../src/utils/OraWritable.ts","../src/utils/spinner.ts","../src/utils/getSummary.ts","../src/utils/parseHrtimeToSeconds.ts","../src/init.ts","../src/utils/getConfig.ts","../src/utils/getPlugins.ts","../src/utils/getCosmiConfig.ts","../src/utils/renderErrors.ts","../src/utils/watcher.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { PromiseManager, Warning, isInputPath } from '@kubb/core'\n\nimport { cac } from 'cac'\nimport c from 'tinyrainbow'\n\nimport { version } from '../package.json'\nimport { generate } from './generate.ts'\nimport { init } from './init.ts'\nimport { getConfig } from './utils/getConfig.ts'\nimport { getCosmiConfig } from './utils/getCosmiConfig.ts'\nimport { renderErrors } from './utils/renderErrors.ts'\nimport { spinner } from './utils/spinner.ts'\nimport { startWatcher } from './utils/watcher.ts'\n\nimport type { CLIOptions } from '@kubb/core'\nimport { execa } from 'execa'\n\nconst moduleName = 'kubb'\n\nfunction programCatcher(e: unknown, CLIOptions: CLIOptions): void {\n const error = e as Error\n const message = renderErrors(error, { logLevel: CLIOptions.logLevel })\n\n if (error instanceof Warning) {\n spinner.warn(c.yellow(error.message))\n process.exit(0)\n }\n spinner.fail(message)\n process.exit(1)\n}\n\nasync function generateAction(input: string, CLIOptions: CLIOptions) {\n if (CLIOptions.bun) {\n const command = process.argv.splice(2).filter((item) => item !== '--bun')\n\n await execa('bkubb', command, { stdout: process.stdout, stderr: process.stderr })\n return\n }\n\n spinner.start('🔍 Loading config')\n const result = await getCosmiConfig(moduleName, CLIOptions.config)\n spinner.succeed(`🔍 Config loaded(${c.dim(path.relative(process.cwd(), result.filepath))})`)\n\n const config = await getConfig(result, CLIOptions)\n\n if (CLIOptions.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 generate({ config, CLIOptions })\n spinner.spinner = 'simpleDotsScrolling'\n spinner.start(c.yellow(c.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n }\n\n if (Array.isArray(config)) {\n const promiseManager = new PromiseManager()\n const promises = config.map((item) => () => generate({ input, config: item, CLIOptions }))\n\n await promiseManager.run('seq', promises)\n\n return\n }\n\n await generate({ input, config, CLIOptions })\n}\n\nexport async function run(argv?: string[]): Promise<void> {\n const program = cac(moduleName)\n\n program\n .command('[input]', 'Path of the input file(overrides the one in `kubb.config.js`)')\n .option('-c, --config <path>', 'Path to the Kubb config')\n .option('-l, --log-level <type>', 'Info, silent or debug')\n .option('-w, --watch', 'Watch mode based on the input file')\n .option('-b, --bun', 'Run Kubb with Bun')\n .action(generateAction)\n\n program\n .command('generate [input]', 'Path of the input file(overrides the one in `kubb.config.js`)')\n .option('-c, --config <path>', 'Path to the Kubb config')\n .option('-l, --log-level <type>', 'Info, silent or debug')\n .option('-w, --watch', 'Watch mode based on the input file')\n .option('-b, --bun', 'Run Kubb with Bun')\n .action(generateAction)\n\n program.command('init', 'Init Kubb').action(async () => {\n return init({ logLevel: 'info' })\n })\n\n program.help()\n program.version(version)\n program.parse(argv, { run: false })\n\n try {\n await program.runMatchedCommand()\n\n process.exit(0)\n } catch (e) {\n programCatcher(e, program.options)\n }\n}\n\nexport default run\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"2.18.3\",\n \"description\": \"Generator cli\",\n \"keywords\": [\n \"typescript\",\n \"plugins\",\n \"kubb\",\n \"codegen\",\n \"cli\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git://github.com/kubb-labs/kubb.git\",\n \"directory\": \"packages/cli\"\n },\n \"license\": \"MIT\",\n \"author\": \"Stijn Van Hulle <stijn@stijnvanhulle.be\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"bin\": {\n \"kubb\": \"bin/kubb.cjs\",\n \"bkubb\": \"bin/bkubb.cjs\"\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"npx rimraf ./dist\",\n \"lint\": \"bun biome lint .\",\n \"lint:fix\": \"bun biome lint --apply-unsafe .\",\n \"release\": \"pnpm publish --no-git-check\",\n \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check\",\n \"start\": \"tsup --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"bundle-require\": \"^4.1.0\",\n \"cac\": \"^6.7.14\",\n \"chokidar\": \"^3.6.0\",\n \"cosmiconfig\": \"^9.0.0\",\n \"esbuild\": \"^0.20.2\",\n \"execa\": \"^8.0.1\",\n \"js-runtime\": \"^0.0.8\",\n \"ora\": \"^8.0.1\",\n \"pretty-error\": \"^4.0.0\",\n \"string-argv\": \"^0.3.2\",\n \"tinyrainbow\": \"^1.1.1\"\n },\n \"devDependencies\": {\n \"@kubb/config-ts\": \"workspace:*\",\n \"@kubb/config-tsup\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/node\": \"^20.12.11\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.4.5\"\n },\n \"packageManager\": \"pnpm@9.0.5\",\n \"engines\": {\n \"node\": \">=18\",\n \"pnpm\": \">=8.15.0\"\n },\n \"preferGlobal\": true,\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import { LogLevel, createLogger, randomCliColour } from '@kubb/core/logger'\n\nimport { execa } from 'execa'\nimport { get } from 'js-runtime'\nimport { parseArgsStringToArgv } from 'string-argv'\nimport c from 'tinyrainbow'\n\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { spinner } from './utils/spinner.ts'\n\nimport type { Writable } from 'node:stream'\nimport { type CLIOptions, type Config, safeBuild } from '@kubb/core'\nimport { getSummary } from './utils/getSummary.ts'\n\ntype GenerateProps = {\n input?: string\n config: Config\n CLIOptions: CLIOptions\n}\n\ntype ExecutingHooksProps = {\n hooks: Config['hooks']\n logLevel: LogLevel\n}\n\nasync function executeHooks({ hooks, logLevel }: ExecutingHooksProps): Promise<void> {\n if (!hooks?.done) {\n return\n }\n\n const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done]\n\n if (logLevel === LogLevel.silent) {\n spinner.start('Executing hooks')\n }\n\n const executers = commands\n .map(async (command) => {\n const oraWritable = new OraWritable(spinner, command)\n const abortController = new AbortController()\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n if (!cmd) {\n return null\n }\n\n spinner.start(`Executing hook ${logLevel !== 'silent' ? c.dim(command) : ''}`)\n\n const subProcess = await execa(cmd, _args, {\n detached: true,\n signal: abortController.signal,\n }).pipeStdout?.(oraWritable as Writable)\n spinner.suffixText = ''\n\n if (logLevel === LogLevel.silent) {\n spinner.succeed(`Executing hook ${logLevel !== 'silent' ? c.dim(command) : ''}`)\n\n if (subProcess) {\n console.log(subProcess.stdout)\n }\n }\n\n oraWritable.destroy()\n return { subProcess, abort: abortController.abort.bind(abortController) }\n })\n .filter(Boolean)\n\n await Promise.all(executers)\n\n if (logLevel === LogLevel.silent) {\n spinner.succeed('Executing hooks')\n }\n}\n\nexport async function generate({ input, config, CLIOptions }: GenerateProps): Promise<void> {\n const logger = createLogger({\n logLevel: CLIOptions.logLevel || LogLevel.silent,\n name: config.name,\n spinner,\n })\n\n if (logger.name) {\n spinner.prefixText = randomCliColour(logger.name)\n }\n\n const hrstart = process.hrtime()\n\n if (CLIOptions.logLevel === LogLevel.debug) {\n const { performance, PerformanceObserver } = await import('node:perf_hooks')\n\n const performanceOpserver = new PerformanceObserver((items) => {\n const message = `${items.getEntries()[0]?.duration.toFixed(0)}ms`\n\n spinner.suffixText = c.yellow(message)\n\n performance.clearMarks()\n })\n\n performanceOpserver.observe({ type: 'measure' })\n }\n\n const { root: _root, ...userConfig } = config\n const logLevel = logger.logLevel\n const inputPath = input ?? ('path' in userConfig.input ? userConfig.input.path : undefined)\n\n spinner.start(`🚀 Building with ${get()} ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n const definedConfig: Config = {\n root: process.cwd(),\n ...userConfig,\n input: inputPath\n ? {\n ...userConfig.input,\n path: inputPath,\n }\n : userConfig.input,\n output: {\n write: true,\n ...userConfig.output,\n },\n }\n const { pluginManager, error } = await safeBuild({\n config: definedConfig,\n logger,\n })\n\n const summary = getSummary({\n pluginManager,\n config: definedConfig,\n status: error ? 'failed' : 'success',\n hrstart,\n logger,\n })\n\n if (error) {\n spinner.suffixText = ''\n spinner.fail(`🚀 Build failed ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n console.log(summary.join(''))\n\n throw error\n }\n\n await executeHooks({ hooks: config.hooks, logLevel })\n\n spinner.suffixText = ''\n spinner.succeed(`🚀 Build completed with ${get()} ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n console.log(summary.join(''))\n}\n","import { Writable } from 'node:stream'\n\nimport c from 'tinyrainbow'\n\nimport type { WritableOptions } from 'node:stream'\nimport type { Ora } from 'ora'\n\nexport class OraWritable extends Writable {\n public command: string\n public spinner: Ora\n constructor(spinner: Ora, command: string, opts?: WritableOptions) {\n super(opts)\n\n this.command = command\n this.spinner = spinner\n }\n _write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void {\n this.spinner.suffixText = `\\n\\n${c.bold(c.blue(this.command))}: ${chunk?.toString()}`\n\n callback()\n }\n}\n","import ora from 'ora'\n\nexport const spinner = ora({\n spinner: 'clock',\n})\n","import path from 'node:path'\n\nimport { randomCliColour } from '@kubb/core/logger'\n\nimport c from 'tinyrainbow'\n\nimport { parseHrtimeToSeconds } from './parseHrtimeToSeconds.ts'\n\nimport type { Config, PluginManager } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\n\ntype SummaryProps = {\n pluginManager: PluginManager\n status: 'success' | 'failed'\n hrstart: [number, number]\n config: Config\n logger: Logger\n}\n\nexport function getSummary({ pluginManager, status, hrstart, config, logger }: SummaryProps): string[] {\n const { logLevel } = logger\n const logs: string[] = []\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))\n\n const buildStartPlugins = pluginManager.executed\n .filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core')\n .map((item) => item.plugin.name)\n\n const buildEndPlugins = pluginManager.executed.filter((item) => item.hookName === 'buildEnd' && item.plugin.name !== 'core').map((item) => item.plugin.name)\n\n const failedPlugins = config.plugins?.filter((plugin) => !buildEndPlugins.includes(plugin.name))?.map((plugin) => plugin.name)\n const pluginsCount = config.plugins?.length || 0\n const files = pluginManager.fileManager.files.sort((a, b) => {\n if (!a.meta?.pluginKey?.[0] || !b.meta?.pluginKey?.[0]) {\n return 0\n }\n if (a.meta?.pluginKey?.[0]?.length < b.meta?.pluginKey?.[0]?.length) {\n return 1\n }\n if (a.meta?.pluginKey?.[0]?.length > b.meta?.pluginKey?.[0]?.length) {\n return -1\n }\n return 0\n })\n\n const meta = {\n name: config.name,\n plugins:\n status === 'success'\n ? `${c.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`\n : `${c.red(`${failedPlugins?.length ?? 1} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? failedPlugins?.map((name) => randomCliColour(name))?.join(', ') : undefined,\n filesCreated: files.length,\n time: c.yellow(`${elapsedSeconds}s`),\n endTime: c.yellow(Date()),\n output: path.isAbsolute(config.root) ? path.resolve(config.root, config.output.path) : config.root,\n } as const\n\n logger.emit('debug', ['\\nGenerated files:\\n'])\n logger.emit(\n 'debug',\n files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`),\n )\n\n logs.push(\n [\n ['\\n', true],\n [` ${c.bold('Name:')} ${meta.name}`, !!meta.name],\n [` ${c.bold('Plugins:')} ${meta.plugins}`, true],\n [` ${c.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${c.bold('Generated:')} ${meta.filesCreated} files`, true],\n [` ${c.bold('Time:')} ${meta.time}`, true],\n [` ${c.bold('Ended:')} ${meta.endTime}`, true],\n [` ${c.bold('Output:')} ${meta.output}`, true],\n ['\\n', true],\n ]\n .map((item) => {\n if (item.at(1)) {\n return item.at(0)\n }\n return undefined\n })\n .filter(Boolean)\n .join('\\n'),\n )\n\n return logs\n}\n","export function parseHrtimeToSeconds(hrtime: [number, number]): string {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","import path from 'node:path'\n\nimport { write } from '@kubb/core/fs'\nimport { LogLevel } from '@kubb/core/logger'\nimport { isPromiseFulfilledResult } from '@kubb/core/utils'\n\nimport { $ } from 'execa'\nimport c from 'tinyrainbow'\n\nimport { spinner } from './utils/spinner.ts'\n\ntype Preset = 'simple'\n\ntype PackageManager = 'pnpm' | 'npm' | 'yarn'\n\ntype PresetMeta = {\n 'kubb.config': string\n packages: string[]\n}\n\ntype InitProps = {\n /**\n * @default `'silent'`\n */\n logLevel?: LogLevel\n /**\n * @default `'simple'`\n */\n preset?: Preset\n /**\n * @default `'pnpm'`\n */\n packageManager?: PackageManager\n}\n\nconst presets: Record<Preset, PresetMeta> = {\n simple: {\n 'kubb.config': `\nimport { defineConfig } from '@kubb/core'\nimport { pluginOas } from '@kubb/plugin-oas'\nimport { pluginTs } from '@kubb/swagger-ts'\nimport { pluginTanstackQuery } from '@kubb/swagger-tanstack-query'\n\nexport default defineConfig({\n root: '.',\n input: {\n path: 'https://petstore3.swagger.io/api/v3/openapi.json',\n },\n output: {\n path: './src/gen',\n clean: true,\n },\n hooks: {\n done: ['echo \"🎉 done\"'],\n },\n plugins: [pluginOas({}), pluginTs({ output: { path: 'models'}, enumType: 'enum' }), pluginTanstackQuery({ output: { path: './hooks' } })],\n})\n `,\n packages: ['@kubb/core', '@kubb/cli', '@kubb/swagger', '@kubb/swagger-ts', '@kubb/swagger-tanstack-query'],\n },\n}\n\nexport async function init({ preset = 'simple', logLevel = LogLevel.silent, packageManager = 'pnpm' }: InitProps): Promise<undefined> {\n spinner.start('📦 Initializing Kubb')\n\n const presetMeta = presets[preset]\n const configPath = path.resolve(process.cwd(), './kubb.config.js')\n const installCommand = packageManager === 'npm' ? 'install' : 'add'\n\n spinner.start(`📀 Writing \\`kubb.config.js\\` ${c.dim(configPath)}`)\n await write(presetMeta['kubb.config'], configPath)\n spinner.succeed(`📀 Wrote \\`kubb.config.js\\` ${c.dim(configPath)}`)\n\n const results = await Promise.allSettled([\n $`npm init es6 -y`,\n ...presetMeta.packages.map(async (pack) => {\n spinner.start(`📀 Installing ${c.dim(pack)}`)\n const { stdout } = await $({\n preferLocal: false,\n })`${packageManager} ${installCommand} ${pack}`\n spinner.succeed(`📀 Installed ${c.dim(pack)}`)\n\n return stdout\n }),\n ])\n\n if (logLevel === LogLevel.info) {\n results.forEach((result) => {\n if (isPromiseFulfilledResult(result)) {\n console.log(result.value)\n }\n })\n }\n spinner.succeed('📦 initialized Kubb')\n\n return\n}\n","import { isPromise } from '@kubb/core/utils'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { CLIOptions, Config, UserConfig, defineConfig } from '@kubb/core'\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, CLIOptions: CLIOptions): 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(CLIOptions)\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 promises = JSONConfig.map(async (item) => {\n return {\n ...item,\n plugins: item.plugins ? await getPlugins(item.plugins) : undefined,\n }\n }) as unknown as Array<Promise<Config>>\n\n return Promise.all(promises)\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 { PackageManager } from '@kubb/core'\n\nimport type { UserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: UserConfig['plugins']): plugins is Array<[name: string, options: object]> {\n return !!(plugins as Array<[name: string, options: object]>[])?.some((plugin) => {\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\nasync function importPlugin(name: string, options: object): Promise<UserConfig['plugins']> {\n const packageManager = new PackageManager(process.cwd())\n\n const importedPlugin: any = process.env.NODE_ENV === 'test' ? await import(name) : await packageManager.import(name)\n\n return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options)\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/guide/configure#json')\n }\n\n if (isJSONPlugins(plugins)) {\n const jsonPlugins = plugins as Array<[name: string, options: object]>\n const promises = jsonPlugins.map((plugin) => {\n const [name, options = {}] = plugin\n return importPlugin(name, options)\n })\n return Promise.all(promises) as Promise<UserConfig['plugins']>\n }\n\n return Promise.resolve(plugins)\n}\n","import { bundleRequire } from 'bundle-require'\nimport { cosmiconfig } from 'cosmiconfig'\n\nimport type { UserConfig, defineConfig } from '@kubb/core'\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 { mod } = await bundleRequire({\n filepath: configFile,\n preserveTemporaryFile: false,\n })\n\n return mod.default\n}\n\nconst jsLoader = async (configFile: string) => {\n const { mod } = await bundleRequire({\n filepath: configFile,\n preserveTemporaryFile: false,\n format: 'cjs',\n })\n\n return mod.default || 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 { LogLevel } from '@kubb/core/logger'\n\nimport PrettyError from 'pretty-error'\n\nexport const prettyError = new PrettyError()\n .skipPackage('commander')\n .skip(function callback(traceLine: any) {\n // exclude renderErrors.ts\n const pattern = /renderErrors/\n\n const hasMatch = traceLine?.file?.match(pattern)\n\n if (typeof traceLine.packageName !== 'undefined' && hasMatch) {\n return true\n }\n } as PrettyError.Callback)\n .start()\n\nfunction getErrorCauses(errors: Error[]): Error[] {\n return errors\n .reduce((prev, error) => {\n const causedError = error?.cause as Error\n if (causedError) {\n prev = [...prev, ...getErrorCauses([causedError])]\n return prev\n }\n prev = [...prev, error]\n\n return prev\n }, [] as Error[])\n .filter(Boolean)\n}\n\nexport function renderErrors(error: Error | undefined, { logLevel = LogLevel.silent }: { logLevel?: LogLevel }): string {\n if (!error) {\n return ''\n }\n\n if (logLevel === LogLevel.silent) {\n // skip when no debug is set\n prettyError.skipNodeFiles()\n prettyError.skip(function skip() {\n return true\n } as PrettyError.Callback)\n\n return [prettyError.render(error)].filter(Boolean).join('\\n')\n }\n\n const errors = getErrorCauses([error])\n\n if (logLevel === LogLevel.debug) {\n console.log(errors)\n }\n\n return errors\n .filter(Boolean)\n .map((error) => prettyError.render(error))\n .join('\\n')\n}\n","import c from 'tinyrainbow'\n\nimport { spinner } from './spinner.ts'\n\nexport async function startWatcher(path: string[], cb: (path: string[]) => Promise<void>): Promise<void> {\n const { watch } = await import('chokidar')\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 spinner.succeed(c.yellow(c.bold(`Change detected: ${type} ${file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AExC;AAAA,EACF;AAEA,QAAM,SAAS,EAAE,OAAO,QAAQ,WAAW,CAAC;AAC9C;AAEA,eAAsB,IAAI,MAAgC;AACxD,QAAM,UAAU,IAAI,UAAU;AAE9B,UACG,QAAQ,WAAW,+DAA+D,EAClF,OAAO,uBAAuB,yBAAyB,EACvD,OAAO,0BAA0B,uBAAuB,EACxD,OAAO,eAAe,oCAAoC,EAC1D,OAAO,aAAa,mBAAmB,EACvC,OAAO,cAAc;AAExB,UACG,QAAQ,oBAAoB,+DAA+D,EAC3F,OAAO,uBAAuB,yBAAyB,EACvD,OAAO,0BAA0B,uBAAuB,EACxD,OAAO,eAAe,oCAAoC,EAC1D,OAAO,aAAa,mBAAmB,EACvC,OAAO,cAAc;AAExB,UAAQ,QAAQ,QAAQ,WAAW,EAAE,OAAO,YAAY;AACtD,WAAO,KAAK,EAAE,UAAU,OAAO,CAAC;AAAA,EAClC,CAAC;AAED,UAAQ,KAAK;AACb,UAAQ,QAAQ,OAAO;AACvB,UAAQ,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC;AAElC,MAAI;AACF,UAAM,QAAQ,kBAAkB;AAEhC,YAAQ,KAAK,CAAC;AAAA,EAChB,SAAS,GAAG;AACV,mBAAe,GAAG,QAAQ,OAAO;AAAA,EACnC;AACF;AAEA,IAAO,cAAQ;","names":["path","c","randomCliColour","c","spinner","callback","c","c","c","randomCliColour","path","LogLevel","c","LogLevel","path","c","moduleName","LogLevel","error","c","path","c","execa","c","path"]}
1
+ {"version":3,"sources":["../src/index.ts","../package.json"],"sourcesContent":["import { defineCommand, runCommand, runMain } from 'citty'\nimport getLatestVersion from 'latest-version'\nimport { lt } from 'semver'\n\nimport consola from 'consola'\nimport { version } from '../package.json'\n\nconst name = 'kubb'\n\nconst main = defineCommand({\n meta: {\n name,\n version,\n description: 'Kubb generation',\n },\n async setup({ rawArgs }) {\n try {\n const latestVersion = await getLatestVersion('@kubb/cli')\n\n if (lt(version, latestVersion)) {\n consola.box({\n title: 'Update available for `Kubb` ',\n message: `\\`v${version}\\` → \\`v${latestVersion}\\`\nRun \\`npm install -g @kubb/cli\\` to update`,\n style: {\n padding: 2,\n borderColor: 'yellow',\n borderStyle: 'rounded',\n },\n })\n }\n } catch (_e) {}\n\n if (rawArgs[0] !== 'generate') {\n // generate is not being used\n const generateCommand = await import('./commands/generate.ts').then((r) => r.default)\n\n await runCommand(generateCommand, { rawArgs })\n\n process.exit(0)\n }\n },\n subCommands: {\n generate: () => import('./commands/generate.ts').then((r) => r.default),\n },\n})\n\nexport async function run(_argv?: string[]): Promise<void> {\n await runMain(main)\n}\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"2.18.5\",\n \"description\": \"Generator cli\",\n \"keywords\": [\n \"typescript\",\n \"plugins\",\n \"kubb\",\n \"codegen\",\n \"cli\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git://github.com/kubb-labs/kubb.git\",\n \"directory\": \"packages/cli\"\n },\n \"license\": \"MIT\",\n \"author\": \"Stijn Van Hulle <stijn@stijnvanhulle.be\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"bin\": {\n \"kubb\": \"bin/kubb.cjs\",\n \"bkubb\": \"bin/bkubb.cjs\"\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"npx rimraf ./dist\",\n \"lint\": \"bun biome lint .\",\n \"lint:fix\": \"bun biome lint --apply-unsafe .\",\n \"release\": \"pnpm publish --no-git-check\",\n \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check\",\n \"start\": \"tsup --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"@kubb/fs\": \"workspace:*\",\n \"bundle-require\": \"^4.1.0\",\n \"chokidar\": \"^3.6.0\",\n \"citty\": \"^0.1.6\",\n \"consola\": \"^3.2.3\",\n \"cosmiconfig\": \"^9.0.0\",\n \"esbuild\": \"^0.20.2\",\n \"execa\": \"^8.0.1\",\n \"js-runtime\": \"^0.0.8\",\n \"latest-version\": \"^9.0.0\",\n \"ora\": \"^8.0.1\",\n \"semver\": \"^7.6.2\",\n \"string-argv\": \"^0.3.2\",\n \"tinyrainbow\": \"^1.1.1\"\n },\n \"devDependencies\": {\n \"@kubb/config-ts\": \"workspace:*\",\n \"@kubb/config-tsup\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/node\": \"^20.12.11\",\n \"@types/semver\": \"^7.5.8\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.4.5\"\n },\n \"packageManager\": \"pnpm@9.0.5\",\n \"engines\": {\n \"node\": \">=18\",\n \"pnpm\": \">=8.15.0\"\n },\n \"preferGlobal\": true,\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n"],"mappings":";AAAA,SAAS,eAAe,YAAY,eAAe;AACnD,OAAO,sBAAsB;AAC7B,SAAS,UAAU;AAEnB,OAAO,aAAa;;;ACFlB,cAAW;;;ADKb,IAAM,OAAO;AAEb,IAAM,OAAO,cAAc;AAAA,EACzB,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,aAAa;AAAA,EACf;AAAA,EACA,MAAM,MAAM,EAAE,QAAQ,GAAG;AACvB,QAAI;AACF,YAAM,gBAAgB,MAAM,iBAAiB,WAAW;AAExD,UAAI,GAAG,SAAS,aAAa,GAAG;AAC9B,gBAAQ,IAAI;AAAA,UACV,OAAO;AAAA,UACP,SAAS,MAAM,OAAO,gBAAW,aAAa;AAAA;AAAA,UAE9C,OAAO;AAAA,YACL,SAAS;AAAA,YACT,aAAa;AAAA,YACb,aAAa;AAAA,UACf;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF,SAAS,IAAI;AAAA,IAAC;AAEd,QAAI,QAAQ,CAAC,MAAM,YAAY;AAE7B,YAAM,kBAAkB,MAAM,OAAO,wBAAwB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;AAEpF,YAAM,WAAW,iBAAiB,EAAE,QAAQ,CAAC;AAE7C,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAAA,EACA,aAAa;AAAA,IACX,UAAU,MAAM,OAAO,wBAAwB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;AAAA,EACxE;AACF,CAAC;AAED,eAAsB,IAAI,OAAiC;AACzD,QAAM,QAAQ,IAAI;AACpB;","names":[]}