@kubb/cli 2.12.1 → 2.12.3

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.js CHANGED
@@ -5,12 +5,12 @@ import { cac } from "cac";
5
5
  import c6 from "tinyrainbow";
6
6
 
7
7
  // package.json
8
- var version = "2.12.1";
8
+ var version = "2.12.3";
9
9
 
10
10
  // src/generate.ts
11
- import { safeBuild } from "@kubb/core";
12
- import { LogLevel as LogLevel2, createLogger, randomCliColour as randomCliColour2 } from "@kubb/core/logger";
11
+ import { LogLevel, createLogger, randomCliColour as randomCliColour2 } from "@kubb/core/logger";
13
12
  import { execa } from "execa";
13
+ import { get } from "js-runtime";
14
14
  import { parseArgsStringToArgv } from "string-argv";
15
15
  import c3 from "tinyrainbow";
16
16
 
@@ -31,9 +31,18 @@ ${c.bold(c.blue(this.command))}: ${chunk?.toString()}`;
31
31
  }
32
32
  };
33
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
+
34
43
  // src/utils/getSummary.ts
35
44
  import path from "path";
36
- import { LogLevel, randomCliColour } from "@kubb/core/logger";
45
+ import { randomCliColour } from "@kubb/core/logger";
37
46
  import c2 from "tinyrainbow";
38
47
 
39
48
  // src/utils/parseHrtimeToSeconds.ts
@@ -71,13 +80,11 @@ function getSummary({ pluginManager, status, hrstart, config, logger }) {
71
80
  time: c2.yellow(`${elapsedSeconds}s`),
72
81
  output: path.isAbsolute(config.root) ? path.resolve(config.root, config.output.path) : config.root
73
82
  };
74
- if (logLevel === LogLevel.debug) {
75
- logger.emit("debug", ["\nGenerated files:\n"]);
76
- logger.emit(
77
- "debug",
78
- files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`)
79
- );
80
- }
83
+ logger.emit("debug", ["\nGenerated files:\n"]);
84
+ logger.emit(
85
+ "debug",
86
+ files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`)
87
+ );
81
88
  logs.push(
82
89
  [
83
90
  ["\n", true],
@@ -98,19 +105,13 @@ function getSummary({ pluginManager, status, hrstart, config, logger }) {
98
105
  return logs;
99
106
  }
100
107
 
101
- // src/utils/spinner.ts
102
- import ora from "ora";
103
- var spinner = ora({
104
- spinner: "clock"
105
- });
106
-
107
108
  // src/generate.ts
108
109
  async function executeHooks({ hooks, logLevel }) {
109
110
  if (!hooks?.done) {
110
111
  return;
111
112
  }
112
113
  const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done];
113
- if (logLevel === LogLevel2.silent) {
114
+ if (logLevel === LogLevel.silent) {
114
115
  spinner.start("Executing hooks");
115
116
  }
116
117
  const executers = commands.map(async (command) => {
@@ -126,7 +127,7 @@ async function executeHooks({ hooks, logLevel }) {
126
127
  signal: abortController.signal
127
128
  }).pipeStdout?.(oraWritable);
128
129
  spinner.suffixText = "";
129
- if (logLevel === LogLevel2.silent) {
130
+ if (logLevel === LogLevel.silent) {
130
131
  spinner.succeed(`Executing hook ${logLevel !== "silent" ? c3.dim(command) : ""}`);
131
132
  if (subProcess) {
132
133
  console.log(subProcess.stdout);
@@ -136,13 +137,13 @@ async function executeHooks({ hooks, logLevel }) {
136
137
  return { subProcess, abort: abortController.abort.bind(abortController) };
137
138
  }).filter(Boolean);
138
139
  await Promise.all(executers);
139
- if (logLevel === LogLevel2.silent) {
140
+ if (logLevel === LogLevel.silent) {
140
141
  spinner.succeed("Executing hooks");
141
142
  }
142
143
  }
143
144
  async function generate({ input, config, CLIOptions }) {
144
145
  const logger = createLogger({
145
- logLevel: CLIOptions.logLevel || LogLevel2.silent,
146
+ logLevel: CLIOptions.logLevel || LogLevel.silent,
146
147
  name: config.name,
147
148
  spinner
148
149
  });
@@ -150,7 +151,7 @@ async function generate({ input, config, CLIOptions }) {
150
151
  spinner.prefixText = randomCliColour2(logger.name);
151
152
  }
152
153
  const hrstart = process.hrtime();
153
- if (CLIOptions.logLevel === LogLevel2.debug) {
154
+ if (CLIOptions.logLevel === LogLevel.debug) {
154
155
  const { performance, PerformanceObserver } = await import("perf_hooks");
155
156
  const performanceOpserver = new PerformanceObserver((items) => {
156
157
  const message = `${items.getEntries()[0]?.duration.toFixed(0)}ms`;
@@ -162,7 +163,7 @@ async function generate({ input, config, CLIOptions }) {
162
163
  const { root: _root, ...userConfig } = config;
163
164
  const logLevel = logger.logLevel;
164
165
  const inputPath = input ?? ("path" in userConfig.input ? userConfig.input.path : void 0);
165
- spinner.start(`\u{1F680} Building ${logLevel !== "silent" ? c3.dim(inputPath) : ""}`);
166
+ spinner.start(`\u{1F680} Building with ${get()} ${logLevel !== "silent" ? c3.dim(inputPath) : ""}`);
166
167
  const definedConfig = {
167
168
  root: process.cwd(),
168
169
  ...userConfig,
@@ -194,14 +195,14 @@ async function generate({ input, config, CLIOptions }) {
194
195
  }
195
196
  await executeHooks({ hooks: config.hooks, logLevel });
196
197
  spinner.suffixText = "";
197
- spinner.succeed(`\u{1F680} Build completed ${logLevel !== "silent" ? c3.dim(inputPath) : ""}`);
198
+ spinner.succeed(`\u{1F680} Build completed with ${get()} ${logLevel !== "silent" ? c3.dim(inputPath) : ""}`);
198
199
  console.log(summary.join(""));
199
200
  }
200
201
 
201
202
  // src/init.ts
202
203
  import path2 from "path";
203
204
  import { write } from "@kubb/core/fs";
204
- import { LogLevel as LogLevel3 } from "@kubb/core/logger";
205
+ import { LogLevel as LogLevel2 } from "@kubb/core/logger";
205
206
  import { isPromiseFulfilledResult } from "@kubb/core/utils";
206
207
  import { $ } from "execa";
207
208
  import c4 from "tinyrainbow";
@@ -231,7 +232,7 @@ export default defineConfig({
231
232
  packages: ["@kubb/core", "@kubb/cli", "@kubb/swagger", "@kubb/swagger-ts", "@kubb/swagger-tanstack-query"]
232
233
  }
233
234
  };
234
- async function init({ preset = "simple", logLevel = LogLevel3.silent, packageManager = "pnpm" }) {
235
+ async function init({ preset = "simple", logLevel = LogLevel2.silent, packageManager = "pnpm" }) {
235
236
  spinner.start("\u{1F4E6} Initializing Kubb");
236
237
  const presetMeta = presets[preset];
237
238
  const configPath = path2.resolve(process.cwd(), "./kubb.config.js");
@@ -250,7 +251,7 @@ async function init({ preset = "simple", logLevel = LogLevel3.silent, packageMan
250
251
  return stdout;
251
252
  })
252
253
  ]);
253
- if (logLevel === LogLevel3.info) {
254
+ if (logLevel === LogLevel2.info) {
254
255
  results.forEach((result) => {
255
256
  if (isPromiseFulfilledResult(result)) {
256
257
  console.log(result.value);
@@ -374,7 +375,7 @@ async function getCosmiConfig(moduleName2, config) {
374
375
  }
375
376
 
376
377
  // src/utils/renderErrors.ts
377
- import { LogLevel as LogLevel4 } from "@kubb/core/logger";
378
+ import { LogLevel as LogLevel3 } from "@kubb/core/logger";
378
379
  import PrettyError from "pretty-error";
379
380
  var prettyError = new PrettyError().skipPackage("commander").skip(function callback(traceLine) {
380
381
  const pattern = /renderErrors/;
@@ -394,11 +395,11 @@ function getErrorCauses(errors) {
394
395
  return prev;
395
396
  }, []).filter(Boolean);
396
397
  }
397
- function renderErrors(error, { logLevel = LogLevel4.silent }) {
398
+ function renderErrors(error, { logLevel = LogLevel3.silent }) {
398
399
  if (!error) {
399
400
  return "";
400
401
  }
401
- if (logLevel === LogLevel4.silent) {
402
+ if (logLevel === LogLevel3.silent) {
402
403
  prettyError.skipNodeFiles();
403
404
  prettyError.skip(function skip() {
404
405
  return true;
@@ -406,7 +407,7 @@ function renderErrors(error, { logLevel = LogLevel4.silent }) {
406
407
  return [prettyError.render(error)].filter(Boolean).join("\n");
407
408
  }
408
409
  const errors = getErrorCauses([error]);
409
- if (logLevel === LogLevel4.debug) {
410
+ if (logLevel === LogLevel3.debug) {
410
411
  console.log(errors);
411
412
  }
412
413
  return errors.filter(Boolean).map((error2) => prettyError.render(error2)).join("\n");
@@ -434,6 +435,7 @@ async function startWatcher(path4, cb) {
434
435
  }
435
436
 
436
437
  // src/index.ts
438
+ import { execa as execa2 } from "execa";
437
439
  var moduleName = "kubb";
438
440
  function programCatcher(e, CLIOptions) {
439
441
  const error = e;
@@ -446,6 +448,11 @@ function programCatcher(e, CLIOptions) {
446
448
  process.exit(1);
447
449
  }
448
450
  async function generateAction(input, CLIOptions) {
451
+ if (CLIOptions.bun) {
452
+ const command = process.argv.splice(2).filter((item) => item !== "--bun");
453
+ await execa2("bkubb", command, { stdout: process.stdout, stderr: process.stderr });
454
+ return;
455
+ }
449
456
  spinner.start("\u{1F50D} Loading config");
450
457
  const result = await getCosmiConfig(moduleName, CLIOptions.config);
451
458
  spinner.succeed(`\u{1F50D} Config loaded(${c6.dim(path3.relative(process.cwd(), result.filepath))})`);
@@ -472,8 +479,8 @@ async function generateAction(input, CLIOptions) {
472
479
  }
473
480
  async function run(argv) {
474
481
  const program = cac(moduleName);
475
- 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").action(generateAction);
476
- 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").action(generateAction);
482
+ 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);
483
+ 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);
477
484
  program.command("init", "Init Kubb").action(async () => {
478
485
  return init({ logLevel: "info" });
479
486
  });
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/getSummary.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/spinner.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'\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 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 .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 .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.12.1\",\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-project/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 },\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\": \"ESLINT_USE_FLAT_CONFIG=true eslint --format pretty .\",\n \"lint-fix\": \"bun run lint --quiet --fix\",\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.0.2\",\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 \"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/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.12.2\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.4.3\"\n },\n \"packageManager\": \"pnpm@8.3.0\",\n \"engines\": {\n \"node\": \">=18\",\n \"pnpm\": \">=8.3.0\"\n },\n \"preferGlobal\": true,\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import { safeBuild } from '@kubb/core'\nimport { LogLevel, createLogger, randomCliColour } from '@kubb/core/logger'\n\nimport { execa } from 'execa'\nimport { parseArgsStringToArgv } from 'string-argv'\nimport c from 'tinyrainbow'\n\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { getSummary } from './utils/getSummary.ts'\nimport { spinner } from './utils/spinner.ts'\n\nimport type { Writable } from 'node:stream'\nimport type { CLIOptions, Config } from '@kubb/core'\nimport type { ExecaReturnValue } from 'execa'\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\ntype Executer = {\n subProcess: ExecaReturnValue<string>\n abort: AbortController['abort']\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 ${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 ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n console.log(summary.join(''))\n}\n","/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\nimport { 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 path from 'node:path'\n\nimport { LogLevel, 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 output: path.isAbsolute(config.root) ? path.resolve(config.root, config.output.path) : config.root,\n } as const\n\n if (logLevel === LogLevel.debug) {\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\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('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 ora from 'ora'\n\nexport const spinner = ora({\n spinner: 'clock',\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 { definePlugin as createSwagger } from '@kubb/swagger'\nimport { definePlugin as createSwaggerTS } from '@kubb/swagger-ts'\nimport { definePlugin as createSwaggerTanstackQuery } 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: [createSwagger({}), createSwaggerTS({ output: { path: 'models'}, enumType: 'enum' }), createSwaggerTanstackQuery({ 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 } 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","/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport { 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 // eslint-disable-next-line\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","/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { bundleRequire } from 'bundle-require'\nimport { cosmiconfig } from 'cosmiconfig'\n\nimport type { defineConfig, UserConfig } 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 // makes it possible to use React and hooks\n // format: 'cjs',\n external: [/@mgx/],\n })\n\n return mod.default\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","/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport { 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}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n } catch (e) {\n spinner.warn(c.red('Watcher failed'))\n }\n })\n\n return\n}\n"],"mappings":";AAAA,OAAOA,WAAU;AAEjB,SAAS,gBAAgB,SAAS,mBAAmB;AAErD,SAAS,WAAW;AACpB,OAAOC,QAAO;;;ACHZ,cAAW;;;ACFb,SAAS,iBAAiB;AAC1B,SAAS,YAAAC,WAAU,cAAc,mBAAAC,wBAAuB;AAExD,SAAS,aAAa;AACtB,SAAS,6BAA6B;AACtC,OAAOC,QAAO;;;ACAd,SAAS,gBAAgB;AAEzB,OAAO,OAAO;AAKP,IAAM,cAA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G,QAAQ,OAAO;AAAA,EACnC;AACF;AAEA,IAAO,cAAQ;","names":["path","c","LogLevel","randomCliColour","c","spinner","callback","c","c","LogLevel","c","randomCliColour","path","LogLevel","c","LogLevel","path","c","moduleName","LogLevel","error","c","path","c","c","path"]}
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'\nimport { OraWritable } from './utils/OraWritable.ts'\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.12.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-project/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\": \"ESLINT_USE_FLAT_CONFIG=true eslint --format pretty .\",\n \"lint-fix\": \"bun run lint --quiet --fix\",\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.0.2\",\n \"js-runtime\": \"^0.0.7\",\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 \"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/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.12.2\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.4.3\"\n },\n \"packageManager\": \"pnpm@8.3.0\",\n \"engines\": {\n \"node\": \">=18\",\n \"pnpm\": \">=8.3.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","/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\nimport { 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 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('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 { definePlugin as createSwagger } from '@kubb/swagger'\nimport { definePlugin as createSwaggerTS } from '@kubb/swagger-ts'\nimport { definePlugin as createSwaggerTanstackQuery } 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: [createSwagger({}), createSwaggerTS({ output: { path: 'models'}, enumType: 'enum' }), createSwaggerTanstackQuery({ 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 } 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","/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport { 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 // eslint-disable-next-line\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","/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { bundleRequire } from 'bundle-require'\nimport { cosmiconfig } from 'cosmiconfig'\n\nimport type { defineConfig, UserConfig } 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 // makes it possible to use React and hooks\n // format: 'cjs',\n external: [/@mgx/],\n })\n\n return mod.default\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","/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport { 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}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n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;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","execa","path"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/cli",
3
- "version": "2.12.1",
3
+ "version": "2.12.3",
4
4
  "description": "Generator cli",
5
5
  "keywords": [
6
6
  "typescript",
@@ -29,7 +29,8 @@
29
29
  }
30
30
  },
31
31
  "bin": {
32
- "kubb": "bin/kubb.cjs"
32
+ "kubb": "bin/kubb.cjs",
33
+ "bkubb": "bin/bkubb.cjs"
33
34
  },
34
35
  "files": [
35
36
  "src",
@@ -40,6 +41,7 @@
40
41
  ],
41
42
  "dependencies": {
42
43
  "bundle-require": "^4.0.2",
44
+ "js-runtime": "^0.0.7",
43
45
  "cac": "^6.7.14",
44
46
  "chokidar": "^3.6.0",
45
47
  "cosmiconfig": "^9.0.0",
@@ -49,14 +51,14 @@
49
51
  "pretty-error": "^4.0.0",
50
52
  "string-argv": "^0.3.2",
51
53
  "tinyrainbow": "^1.1.1",
52
- "@kubb/core": "2.12.1"
54
+ "@kubb/core": "2.12.3"
53
55
  },
54
56
  "devDependencies": {
55
57
  "@types/node": "^20.12.2",
56
58
  "source-map-support": "^0.5.21",
57
59
  "tsup": "^8.0.2",
58
60
  "typescript": "^5.4.3",
59
- "@kubb/swagger": "2.12.1",
61
+ "@kubb/swagger": "2.12.3",
60
62
  "@kubb/ts-config": "0.1.0",
61
63
  "@kubb/tsup-config": "1.1.8"
62
64
  },
package/src/generate.ts CHANGED
@@ -1,17 +1,16 @@
1
- import { safeBuild } from '@kubb/core'
2
1
  import { LogLevel, createLogger, randomCliColour } from '@kubb/core/logger'
3
2
 
4
3
  import { execa } from 'execa'
4
+ import { get } from 'js-runtime'
5
5
  import { parseArgsStringToArgv } from 'string-argv'
6
6
  import c from 'tinyrainbow'
7
7
 
8
8
  import { OraWritable } from './utils/OraWritable.ts'
9
- import { getSummary } from './utils/getSummary.ts'
10
9
  import { spinner } from './utils/spinner.ts'
11
10
 
12
11
  import type { Writable } from 'node:stream'
13
- import type { CLIOptions, Config } from '@kubb/core'
14
- import type { ExecaReturnValue } from 'execa'
12
+ import { type CLIOptions, type Config, safeBuild } from '@kubb/core'
13
+ import { getSummary } from './utils/getSummary.ts'
15
14
 
16
15
  type GenerateProps = {
17
16
  input?: string
@@ -24,11 +23,6 @@ type ExecutingHooksProps = {
24
23
  logLevel: LogLevel
25
24
  }
26
25
 
27
- type Executer = {
28
- subProcess: ExecaReturnValue<string>
29
- abort: AbortController['abort']
30
- }
31
-
32
26
  async function executeHooks({ hooks, logLevel }: ExecutingHooksProps): Promise<void> {
33
27
  if (!hooks?.done) {
34
28
  return
@@ -109,7 +103,7 @@ export async function generate({ input, config, CLIOptions }: GenerateProps): Pr
109
103
  const logLevel = logger.logLevel
110
104
  const inputPath = input ?? ('path' in userConfig.input ? userConfig.input.path : undefined)
111
105
 
112
- spinner.start(`🚀 Building ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)
106
+ spinner.start(`🚀 Building with ${get()} ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)
113
107
 
114
108
  const definedConfig: Config = {
115
109
  root: process.cwd(),
@@ -150,7 +144,7 @@ export async function generate({ input, config, CLIOptions }: GenerateProps): Pr
150
144
  await executeHooks({ hooks: config.hooks, logLevel })
151
145
 
152
146
  spinner.suffixText = ''
153
- spinner.succeed(`🚀 Build completed ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)
147
+ spinner.succeed(`🚀 Build completed with ${get()} ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)
154
148
 
155
149
  console.log(summary.join(''))
156
150
  }
package/src/index.ts CHANGED
@@ -15,6 +15,8 @@ import { spinner } from './utils/spinner.ts'
15
15
  import { startWatcher } from './utils/watcher.ts'
16
16
 
17
17
  import type { CLIOptions } from '@kubb/core'
18
+ import { execa } from 'execa'
19
+ import { OraWritable } from './utils/OraWritable.ts'
18
20
 
19
21
  const moduleName = 'kubb'
20
22
 
@@ -31,6 +33,13 @@ function programCatcher(e: unknown, CLIOptions: CLIOptions): void {
31
33
  }
32
34
 
33
35
  async function generateAction(input: string, CLIOptions: CLIOptions) {
36
+ if (CLIOptions.bun) {
37
+ const command = process.argv.splice(2).filter((item) => item !== '--bun')
38
+
39
+ await execa('bkubb', command, { stdout: process.stdout, stderr: process.stderr })
40
+ return
41
+ }
42
+
34
43
  spinner.start('🔍 Loading config')
35
44
  const result = await getCosmiConfig(moduleName, CLIOptions.config)
36
45
  spinner.succeed(`🔍 Config loaded(${c.dim(path.relative(process.cwd(), result.filepath))})`)
@@ -71,6 +80,7 @@ export async function run(argv?: string[]): Promise<void> {
71
80
  .option('-c, --config <path>', 'Path to the Kubb config')
72
81
  .option('-l, --log-level <type>', 'Info, silent or debug')
73
82
  .option('-w, --watch', 'Watch mode based on the input file')
83
+ .option('-b, --bun', 'Run Kubb with Bun')
74
84
  .action(generateAction)
75
85
 
76
86
  program
@@ -78,6 +88,7 @@ export async function run(argv?: string[]): Promise<void> {
78
88
  .option('-c, --config <path>', 'Path to the Kubb config')
79
89
  .option('-l, --log-level <type>', 'Info, silent or debug')
80
90
  .option('-w, --watch', 'Watch mode based on the input file')
91
+ .option('-b, --bun', 'Run Kubb with Bun')
81
92
  .action(generateAction)
82
93
 
83
94
  program.command('init', 'Init Kubb').action(async () => {
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path'
2
2
 
3
- import { LogLevel, randomCliColour } from '@kubb/core/logger'
3
+ import { randomCliColour } from '@kubb/core/logger'
4
4
 
5
5
  import c from 'tinyrainbow'
6
6
 
@@ -55,13 +55,11 @@ export function getSummary({ pluginManager, status, hrstart, config, logger }: S
55
55
  output: path.isAbsolute(config.root) ? path.resolve(config.root, config.output.path) : config.root,
56
56
  } as const
57
57
 
58
- if (logLevel === LogLevel.debug) {
59
- logger.emit('debug', ['\nGenerated files:\n'])
60
- logger.emit(
61
- 'debug',
62
- files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`),
63
- )
64
- }
58
+ logger.emit('debug', ['\nGenerated files:\n'])
59
+ logger.emit(
60
+ 'debug',
61
+ files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`),
62
+ )
65
63
 
66
64
  logs.push(
67
65
  [