@kubb/cli 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -6,6 +6,7 @@ var ora = require('ora');
6
6
  var pc3 = require('picocolors');
7
7
  var core = require('@kubb/core');
8
8
  var execa = require('execa');
9
+ var perf_hooks = require('perf_hooks');
9
10
  var stringArgv = require('string-argv');
10
11
  var stream = require('stream');
11
12
  var cosmiconfig = require('cosmiconfig');
@@ -31,7 +32,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
31
32
  });
32
33
 
33
34
  // package.json
34
- var version = "1.2.0";
35
+ var version = "1.2.1";
35
36
  var presets = {
36
37
  simple: {
37
38
  "kubb.config": `
@@ -59,7 +60,7 @@ export default defineConfig({
59
60
  packages: ["@kubb/core", "@kubb/cli", "@kubb/swagger", "@kubb/swagger-ts", "@kubb/swagger-tanstack-query"]
60
61
  }
61
62
  };
62
- async function init({ preset = "simple", logLevel = "silent", packageManager = "pnpm" }) {
63
+ async function init({ preset = "simple", logLevel = core.LogLevel.silent, packageManager = "pnpm" }) {
63
64
  spinner.start("\u{1F4E6} Initializing Kubb");
64
65
  const presetMeta = presets[preset];
65
66
  const path = pathParser__default.default.resolve(process.cwd(), "./kubb.config.js");
@@ -76,7 +77,7 @@ async function init({ preset = "simple", logLevel = "silent", packageManager = "
76
77
  return stdout;
77
78
  })
78
79
  ]);
79
- if (logLevel === "info") {
80
+ if (core.canLogHierarchy(logLevel, core.LogLevel.info)) {
80
81
  results.forEach((result) => {
81
82
  if (core.isPromiseFulfilledResult(result)) {
82
83
  console.log(result.value);
@@ -92,9 +93,7 @@ function parseHrtimeToSeconds(hrtime) {
92
93
  const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
93
94
  return seconds;
94
95
  }
95
-
96
- // src/utils/parseText.ts
97
- function parseText(baseText, config, logLevel = "silent") {
96
+ function parseText(baseText, config, logLevel = core.LogLevel.silent) {
98
97
  return `${baseText}${config[logLevel] || ""}`;
99
98
  }
100
99
  var OraWritable = class extends stream.Writable {
@@ -114,90 +113,100 @@ ${pc3__default.default.bold(pc3__default.default.blue(this.command))}: ${chunk?.
114
113
  };
115
114
 
116
115
  // src/run.ts
117
- async function run({ config, options }) {
118
- const hrstart = process.hrtime();
119
- const logger = core.createLogger(spinner);
120
- const executeHooks = async (hooks, logLevel) => {
121
- if (!hooks?.done) {
122
- return;
116
+ async function executeHooks({ hooks, logLevel }) {
117
+ if (!hooks?.done) {
118
+ return;
119
+ }
120
+ const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done];
121
+ if (core.canLogHierarchy(logLevel, core.LogLevel.silent)) {
122
+ spinner.start(`Executing hooks`);
123
+ }
124
+ const executers = commands.map(async (command) => {
125
+ const oraWritable = new OraWritable(spinner, command);
126
+ const abortController = new AbortController();
127
+ const [cmd, ..._args] = [...stringArgv.parseArgsStringToArgv(command)];
128
+ spinner.start(parseText(`Executing hook`, { info: ` ${pc3__default.default.dim(command)}` }, logLevel));
129
+ const subProcess = await execa.execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout(oraWritable);
130
+ spinner.suffixText = "";
131
+ if (core.canLogHierarchy(logLevel, core.LogLevel.info)) {
132
+ spinner.succeed(parseText(`Executing hook`, { info: ` ${pc3__default.default.dim(command)}` }, logLevel));
133
+ console.log(subProcess.stdout);
123
134
  }
124
- const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done];
125
- if (logLevel === "silent") {
126
- spinner.start(`\u{1FA82} Executing hooks`);
135
+ await core.timeout(100);
136
+ oraWritable.destroy();
137
+ return { subProcess, abort: abortController.abort.bind(abortController) };
138
+ });
139
+ await Promise.all(executers);
140
+ if (core.canLogHierarchy(logLevel, core.LogLevel.silent)) {
141
+ spinner.succeed(`Executing hooks`);
142
+ }
143
+ }
144
+ function getSummary({ pluginManager, status, hrstart, config, logLevel }) {
145
+ const logs = [];
146
+ const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart));
147
+ const buildStartPlugins = [
148
+ ...new Set(pluginManager.executed.filter((item) => item.hookName === "buildStart" && item.plugin.name !== "core").map((item) => item.plugin.name))
149
+ ];
150
+ const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.includes(plugin.name))?.map((plugin) => plugin.name);
151
+ const pluginsCount = config.plugins?.length || 0;
152
+ const files = pluginManager.fileManager.files.sort((a, b) => {
153
+ if (!a.meta?.pluginName || !b.meta?.pluginName) {
154
+ return 0;
127
155
  }
128
- const executers = commands.map(async (command) => {
129
- const oraWritable = new OraWritable(spinner, command);
130
- const abortController = new AbortController();
131
- const [cmd, ..._args] = [...stringArgv.parseArgsStringToArgv(command)];
132
- spinner.start(parseText(`\u{1FA82} Executing hook`, { info: ` ${pc3__default.default.dim(command)}` }, logLevel));
133
- const subProcess = await execa.execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout(oraWritable);
134
- spinner.suffixText = "";
135
- if (logLevel === "info") {
136
- spinner.succeed(parseText(`\u{1FA82} Executing hook`, { info: ` ${pc3__default.default.dim(command)}` }, logLevel));
137
- console.log(subProcess.stdout);
138
- }
139
- await core.timeout(50);
140
- oraWritable.destroy();
141
- return { subProcess, abort: abortController.abort.bind(abortController) };
142
- });
143
- await Promise.all(executers);
144
- if (logLevel === "silent") {
145
- spinner.succeed(`\u{1FA82} Executing hooks`);
156
+ if (a.meta?.pluginName.length < b.meta?.pluginName.length) {
157
+ return 1;
146
158
  }
147
- };
148
- const getSummary = (pluginManager, status) => {
149
- const logs = [];
150
- const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart));
151
- const buildStartPlugins = [
152
- ...new Set(pluginManager.executed.filter((item) => item.hookName === "buildStart" && item.plugin.name !== "core").map((item) => item.plugin.name))
153
- ];
154
- const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.includes(plugin.name))?.map((plugin) => plugin.name);
155
- const pluginsCount = config.plugins?.length || 0;
156
- const files = pluginManager.fileManager.files.sort((a, b) => {
157
- if (!a.meta?.pluginName || !b.meta?.pluginName) {
158
- return 0;
159
- }
160
- if (a.meta?.pluginName.length < b.meta?.pluginName.length) {
161
- return 1;
162
- }
163
- if (a.meta?.pluginName.length > b.meta?.pluginName.length) {
164
- return -1;
165
- }
166
- return 0;
167
- });
168
- const meta = {
169
- plugins: status === "success" ? `${pc3__default.default.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${pc3__default.default.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,
170
- pluginsFailed: status === "failed" ? failedPlugins?.join(", ") : void 0,
171
- filesCreated: files.length,
172
- time: pc3__default.default.yellow(`${elapsedSeconds}s`),
173
- output: pathParser__default.default.resolve(config.root, config.output.path)
174
- };
175
- if (options.debug) {
176
- logs.push(pc3__default.default.bold("Generated files:\n"));
177
- logs.push(files.map((file) => `${pc3__default.default.blue(file.meta?.pluginName)} ${file.path}`).join("\n"));
159
+ if (a.meta?.pluginName.length > b.meta?.pluginName.length) {
160
+ return -1;
178
161
  }
179
- logs.push(
180
- [
181
- [` ${pc3__default.default.bold("Plugins:")} ${meta.plugins}`, true],
182
- [` ${pc3__default.default.dim("Failed:")} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
183
- [`${pc3__default.default.bold("Generated:")} ${meta.filesCreated} files`, true],
184
- [` ${pc3__default.default.bold("Time:")} ${meta.time}`, true],
185
- [` ${pc3__default.default.bold("Output:")} ${meta.output}`, true],
186
- [`
187
- `, true]
188
- ].map((item) => {
189
- if (item.at(1)) {
190
- return item.at(0);
191
- }
192
- return void 0;
193
- }).filter(Boolean).join("\n")
194
- );
195
- return logs;
162
+ return 0;
163
+ });
164
+ const meta = {
165
+ plugins: status === "success" ? `${pc3__default.default.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${pc3__default.default.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,
166
+ pluginsFailed: status === "failed" ? failedPlugins?.map((name) => core.randomPicoColour(name))?.join(", ") : void 0,
167
+ filesCreated: files.length,
168
+ time: pc3__default.default.yellow(`${elapsedSeconds}s`),
169
+ output: pathParser__default.default.resolve(config.root, config.output.path)
196
170
  };
171
+ if (core.canLogHierarchy(logLevel, "stacktrace")) {
172
+ logs.push(pc3__default.default.bold("Generated files:\n"));
173
+ logs.push(files.map((file) => `${core.randomPicoColour(file.meta?.pluginName)} ${file.path}`).join("\n"));
174
+ }
175
+ logs.push(
176
+ [
177
+ [`
178
+ `, true],
179
+ [` ${pc3__default.default.bold("Plugins:")} ${meta.plugins}`, true],
180
+ [` ${pc3__default.default.dim("Failed:")} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
181
+ [`${pc3__default.default.bold("Generated:")} ${meta.filesCreated} files`, true],
182
+ [` ${pc3__default.default.bold("Time:")} ${meta.time}`, true],
183
+ [` ${pc3__default.default.bold("Output:")} ${meta.output}`, true],
184
+ [`
185
+ `, true]
186
+ ].map((item) => {
187
+ if (item.at(1)) {
188
+ return item.at(0);
189
+ }
190
+ return void 0;
191
+ }).filter(Boolean).join("\n")
192
+ );
193
+ return logs;
194
+ }
195
+ async function run({ config, CLIOptions }) {
196
+ const hrstart = process.hrtime();
197
+ const logger = core.createLogger(spinner);
198
+ const performanceOpserver = new perf_hooks.PerformanceObserver((items) => {
199
+ const message = `${items.getEntries()[0].duration.toFixed(0)}ms`;
200
+ spinner.suffixText = pc3__default.default.yellow(message);
201
+ perf_hooks.performance.clearMarks();
202
+ });
203
+ if (CLIOptions.debug) {
204
+ performanceOpserver.observe({ type: "measure" });
205
+ }
197
206
  try {
198
207
  const { root: _root, ...userConfig } = config;
199
- const logLevel = options.logLevel ?? userConfig.logLevel ?? "silent";
200
- const inputPath = options.input ?? userConfig.input.path;
208
+ const logLevel = CLIOptions.logLevel ?? userConfig.logLevel ?? core.LogLevel.silent;
209
+ const inputPath = CLIOptions.input ?? userConfig.input.path;
201
210
  spinner.start(parseText(`\u{1F680} Building`, { info: `(${pc3__default.default.dim(inputPath)})` }, logLevel));
202
211
  const output = await core.build({
203
212
  config: {
@@ -213,18 +222,21 @@ async function run({ config, options }) {
213
222
  ...userConfig.output
214
223
  }
215
224
  },
216
- logger
225
+ logger,
226
+ debug: CLIOptions.debug
217
227
  });
228
+ spinner.suffixText = "";
218
229
  spinner.succeed(parseText(`\u{1F680} Build completed`, { info: `(${pc3__default.default.dim(inputPath)})` }, logLevel));
219
- await executeHooks(config.hooks, logLevel);
220
- const summary = getSummary(output.pluginManager, "success");
230
+ await core.timeout(100);
231
+ await executeHooks({ hooks: config.hooks, logLevel, debug: CLIOptions.debug });
232
+ const summary = getSummary({ pluginManager: output.pluginManager, config, status: "success", hrstart, logLevel: CLIOptions.logLevel });
221
233
  console.log(summary.join(""));
222
234
  } catch (error) {
235
+ let summary = [];
223
236
  if (error instanceof core.PluginError || error instanceof core.ParallelPluginError) {
224
- const summary = getSummary(error.pluginManager, "failed");
225
- throw new core.SummaryError("Something went wrong\n", { cause: error, summary });
237
+ summary = getSummary({ pluginManager: error.pluginManager, config, status: "failed", hrstart, logLevel: CLIOptions.logLevel });
226
238
  }
227
- throw new core.SummaryError("Something went wrong\n", { cause: error });
239
+ throw new core.SummaryError("Something went wrong\n", { cause: error, summary });
228
240
  }
229
241
  }
230
242
  function isJSONPlugins(plugins) {
@@ -257,11 +269,11 @@ function getPlugins(plugins) {
257
269
  }
258
270
 
259
271
  // src/utils/getConfig.ts
260
- async function getConfig(result, options) {
272
+ async function getConfig(result, CLIOptions) {
261
273
  const config = result?.config;
262
274
  let kubbUserConfig = Promise.resolve(config);
263
275
  if (typeof config === "function") {
264
- const possiblePromise = config(options);
276
+ const possiblePromise = config(CLIOptions);
265
277
  if (core.isPromise(possiblePromise)) {
266
278
  kubbUserConfig = possiblePromise;
267
279
  }
@@ -367,14 +379,14 @@ function getErrorCauses(errors) {
367
379
  return prev;
368
380
  }, []).filter(Boolean);
369
381
  }
370
- function renderErrors(error, { prefixText, debug = false }) {
382
+ function renderErrors(error, { prefixText, logLevel = core.LogLevel.silent }) {
371
383
  if (!error) {
372
384
  return "";
373
385
  }
374
386
  if (error instanceof core.ParallelPluginError) {
375
- return [prefixText, ...error.errors.map((e) => renderErrors(e, { debug }))].filter(Boolean).join("\n");
387
+ return [prefixText, ...error.errors.map((e) => renderErrors(e, { logLevel }))].filter(Boolean).join("\n");
376
388
  }
377
- if (debug) {
389
+ if (core.canLogHierarchy(logLevel, "stacktrace")) {
378
390
  const errors = getErrorCauses([error]);
379
391
  return [prefixText, ...errors].filter(Boolean).join("\n");
380
392
  }
@@ -388,20 +400,41 @@ var moduleName = "kubb";
388
400
  var spinner = ora__default.default({
389
401
  spinner: "clock"
390
402
  });
403
+ function programCatcher(e, CLIOptions) {
404
+ const originalError = e;
405
+ let error = originalError;
406
+ const summaryError = error instanceof core.SummaryError ? error : void 0;
407
+ if (summaryError) {
408
+ error = summaryError.cause;
409
+ }
410
+ const message = renderErrors(error, { logLevel: CLIOptions.logLevel, prefixText: pc3__default.default.red(originalError?.message) });
411
+ if (error instanceof core.Warning) {
412
+ spinner.warn(pc3__default.default.yellow(error.message));
413
+ process.exit(0);
414
+ }
415
+ if (core.canLogHierarchy(CLIOptions.logLevel, core.LogLevel.silent)) {
416
+ spinner.fail(message);
417
+ process.exit(1);
418
+ }
419
+ spinner.fail([message, ...summaryError?.summary || []].join("\n"));
420
+ process.exit(1);
421
+ }
391
422
  var program = new commander.Command(moduleName).name(moduleName).description("Kubb").version(version, "-v").exitOverride((err) => {
392
423
  if (err instanceof commander.CommanderError) {
393
424
  process.exit(1);
394
425
  }
395
426
  }).configureOutput({
396
427
  outputError: (message, write2) => {
397
- const options = program.opts();
428
+ const CLIOptions = program.opts();
398
429
  write2(
399
- renderErrors(new Error(message, { cause: void 0 }), { debug: options.debug, prefixText: pc3__default.default.red("Something went wrong with processing the CLI\n") }) + "\n"
430
+ renderErrors(new Error(message, { cause: void 0 }), {
431
+ logLevel: CLIOptions.logLevel,
432
+ prefixText: pc3__default.default.red("Something went wrong with processing the CLI\n")
433
+ }) + "\n"
400
434
  );
401
435
  }
402
- }).addOption(new commander.Option("-c, --config <path>", "Path to the Kubb config")).addOption(new commander.Option("-i, --input <path>", "Path of the input file(overrides the one in `kubb.config.js`)")).addOption(new commander.Option("-l, --logLevel <type>", "Type of the logging(overrides the one in `kubb.config.js`)").choices(["error", "info", "silent"])).addOption(new commander.Option("--init", "Init Kubb")).addOption(new commander.Option("-d, --debug", "Debug mode").default(false)).addOption(new commander.Option("-w, --watch", "Watch mode based on the input file")).action(async (options) => {
436
+ }).addOption(new commander.Option("-c, --config <path>", "Path to the Kubb config")).addOption(new commander.Option("-i, --input <path>", "Path of the input file(overrides the one in `kubb.config.js`)")).addOption(new commander.Option("-l, --logLevel <type>", "Type of the logging(overrides the one in `kubb.config.js`)").choices(["info", "silent", "stacktrace"])).addOption(new commander.Option("--init", "Init Kubb")).addOption(new commander.Option("-d, --debug", "Debug mode").default(false)).addOption(new commander.Option("-w, --watch", "Watch mode based on the input file")).action(async (options) => {
403
437
  try {
404
- spinner.start();
405
438
  if (options.init) {
406
439
  return init({ logLevel: options.logLevel });
407
440
  }
@@ -411,27 +444,15 @@ var program = new commander.Command(moduleName).name(moduleName).description("Ku
411
444
  if (options.watch) {
412
445
  const config2 = await getConfig(result, options);
413
446
  return startWatcher([config2.input.path], async (paths) => {
414
- await run({ config: config2, options });
447
+ await run({ config: config2, CLIOptions: options });
415
448
  spinner.spinner = "simpleDotsScrolling";
416
449
  spinner.start(pc3__default.default.yellow(pc3__default.default.bold(`Watching for changes in ${paths.join(" and ")}`)));
417
450
  });
418
451
  }
419
452
  const config = await getConfig(result, options);
420
- await run({ config, options });
453
+ await run({ config, CLIOptions: options });
421
454
  } catch (e) {
422
- const originalError = e;
423
- let error = originalError;
424
- const summaryError = error instanceof core.SummaryError ? error : void 0;
425
- if (summaryError) {
426
- error = summaryError.cause;
427
- }
428
- const message = renderErrors(error, { debug: options.debug, prefixText: pc3__default.default.red(originalError?.message) });
429
- if (error instanceof core.Warning) {
430
- spinner.warn(pc3__default.default.yellow(error.message));
431
- process.exit(0);
432
- }
433
- spinner.fail([message, ...summaryError?.summary || []].join("\n"));
434
- process.exit(1);
455
+ programCatcher(e, options);
435
456
  }
436
457
  });
437
458
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/program.ts","../package.json","../src/init.ts","../src/run.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/parseText.ts","../src/utils/OraWritable.ts","../src/utils/getConfig.ts","../src/utils/getPlugins.ts","../src/utils/watcher.ts","../src/utils/getCosmiConfig.ts","../src/utils/renderErrors.ts","../src/index.ts"],"names":["pathParser","pc","spinner","importModule","moduleName","ParallelPluginError","SummaryError","write","config"],"mappings":";;;;;;;;;AAAA,OAAOA,iBAAgB;AAEvB,SAAS,SAAS,gBAAgB,cAAc;AAChD,OAAO,SAAS;AAChB,OAAOC,SAAQ;;;ACFb,cAAW;;;ACFb,OAAO,gBAAgB;AAEvB,SAAS,0BAA0B,aAAa;AAEhD,SAAS,SAAS;AAClB,OAAO,QAAQ;AA6Bf,IAAM,UAAsC;AAAA,EAC1C,QAAQ;AAAA,IACN,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAsBf,UAAU,CAAC,cAAc,aAAa,iBAAiB,oBAAoB,8BAA8B;AAAA,EAC3G;AACF;AAEA,eAAsB,KAAK,EAAE,SAAS,UAAU,WAAW,UAAU,iBAAiB,OAAO,GAAiC;AAC5H,UAAQ,MAAM,6BAAsB;AAEpC,QAAM,aAAa,QAAQ,MAAM;AACjC,QAAM,OAAO,WAAW,QAAQ,QAAQ,IAAI,GAAG,kBAAkB;AACjE,QAAM,iBAAiB,mBAAmB,QAAQ,YAAY;AAE9D,UAAQ,MAAM,wCAAiC,GAAG,IAAI,IAAI,GAAG;AAC7D,Q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import pc from 'picocolors'\n\nimport { version } from '../package.json'\nimport { init } from './init.ts'\nimport { run } from './run.ts'\nimport { getConfig, getCosmiConfig, renderErrors, startWatcher } from './utils/index.ts'\n\nimport { SummaryError } from '@kubb/core'\nimport type { CLIOptions } from '@kubb/core'\nimport { Warning } from '@kubb/core'\n\nconst moduleName = 'kubb'\n\nexport const spinner = ora({\n spinner: 'clock',\n})\n\nexport const program = new Command(moduleName)\n .name(moduleName)\n .description('Kubb')\n .version(version, '-v')\n .exitOverride((err) => {\n if (err instanceof CommanderError) {\n process.exit(1)\n }\n })\n .configureOutput({\n outputError: (message, write) => {\n const options: CLIOptions = program.opts()\n\n write(\n renderErrors(new Error(message, { cause: undefined }), { debug: options.debug, prefixText: pc.red('Something went wrong with processing the CLI\\n') }) +\n '\\n'\n )\n },\n })\n .addOption(new Option('-c, --config <path>', 'Path to the Kubb config'))\n .addOption(new Option('-i, --input <path>', 'Path of the input file(overrides the one in `kubb.config.js`)'))\n .addOption(new Option('-l, --logLevel <type>', 'Type of the logging(overrides the one in `kubb.config.js`)').choices(['error', 'info', 'silent']))\n .addOption(new Option('--init', 'Init Kubb'))\n .addOption(new Option('-d, --debug', 'Debug mode').default(false))\n .addOption(new Option('-w, --watch', 'Watch mode based on the input file'))\n .action(async (options: CLIOptions) => {\n try {\n spinner.start()\n\n if (options.init) {\n return init({ logLevel: options.logLevel })\n }\n\n // CONFIG\n // TODO use options.config to show path instead of relying on the `result`\n spinner.start('💾 Loading config')\n const result = await getCosmiConfig(moduleName, options.config)\n spinner.succeed(`💾 Config loaded(${pc.dim(pathParser.relative(process.cwd(), result.filepath))})`)\n // END CONFIG\n\n if (options.watch) {\n const config = await getConfig(result, options)\n\n return startWatcher([config.input.path], async (paths) => {\n await run({ config, options })\n spinner.spinner = 'simpleDotsScrolling'\n spinner.start(pc.yellow(pc.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n\n const config = await getConfig(result, options)\n\n await run({ config, options })\n } catch (e: any) {\n const originalError = e as Error\n let error = originalError\n\n // summaryError check\n const summaryError = error instanceof SummaryError ? error : undefined\n\n if (summaryError) {\n // use the real error from summaryError and use the case of SummaryError to display a summary of plugins that failed\n error = summaryError.cause as Error\n }\n\n const message = renderErrors(error, { debug: options.debug, prefixText: pc.red(originalError?.message) })\n\n if (error instanceof Warning) {\n spinner.warn(pc.yellow(error.message))\n process.exit(0)\n }\n\n spinner.fail([message, ...(summaryError?.summary || [])].join('\\n'))\n process.exit(1)\n }\n })\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"1.2.0\",\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.js\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"kubb\": \"bin/kubb.js\"\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf ./dist\",\n \"lint\": \"eslint --format pretty ./src\",\n \"lint-fix\": \"bun run lint --quiet --fix\",\n \"release\": \"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 \"@swc/core\": \"^1.3.64\",\n \"chokidar\": \"^3.5.3\",\n \"commander\": \"^10.0.1\",\n \"cosmiconfig\": \"^8.2.0\",\n \"execa\": \"^7.1.1\",\n \"ora\": \"^6.3.1\",\n \"picocolors\": \"^1.0.0\",\n \"pretty-error\": \"^4.0.0\",\n \"string-argv\": \"^0.3.2\",\n \"ts-node\": \"^10.9.1\",\n \"yaml\": \"^2.3.1\"\n },\n \"devDependencies\": {\n \"@kubb/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.3.1\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.1.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 pathParser from 'node:path'\n\nimport { isPromiseFulfilledResult, write } from '@kubb/core'\n\nimport { $ } from 'execa'\nimport pc from 'picocolors'\n\nimport type { LogLevel } from '@kubb/core'\nimport { spinner } from './program.ts'\n\nexport type Preset = 'simple'\n\nexport type PackageManager = 'pnpm' | 'npm' | 'yarn'\n\nexport type PresetMeta = {\n 'kubb.config': string\n packages: string[]\n}\n\ntype RunProps = {\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 createSwagger from '@kubb/swagger'\nimport createSwaggerTS from '@kubb/swagger-ts'\nimport 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 logLevel: 'info',\n plugins: [createSwagger({}), createSwaggerTS({ output: 'models', enumType: 'enum' }), createSwaggerTanstackQuery({ output: './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 = 'silent', packageManager = 'pnpm' }: RunProps): Promise<undefined> {\n spinner.start('📦 Initializing Kubb')\n\n const presetMeta = presets[preset]\n const path = pathParser.resolve(process.cwd(), './kubb.config.js')\n const installCommand = packageManager === 'npm' ? 'install' : 'add'\n\n spinner.start(`📀 Writing \\`kubb.config.js\\` ${pc.dim(path)}`)\n await write(presetMeta['kubb.config'], path)\n spinner.succeed(`📀 Wrote \\`kubb.config.js\\` ${pc.dim(path)}`)\n\n const results = await Promise.allSettled([\n $`npm init es6 -y`,\n ...presetMeta.packages.map(async (pack) => {\n spinner.start(`📀 Installing ${pc.dim(pack)}`)\n const { stdout } = await $({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`\n spinner.succeed(`📀 Installed ${pc.dim(pack)}`)\n\n return stdout\n }),\n ])\n\n if (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 pathParser from 'node:path'\n\nimport { build, ParallelPluginError, PluginError, SummaryError, timeout, createLogger } from '@kubb/core'\n\nimport type { ExecaReturnValue } from 'execa'\nimport { execa } from 'execa'\nimport pc from 'picocolors'\n\nimport { parseArgsStringToArgv } from 'string-argv'\n\nimport { parseHrtimeToSeconds } from './utils/parseHrtimeToSeconds.ts'\nimport { parseText } from './utils/parseText.ts'\n\nimport type { BuildOutput, CLIOptions, KubbConfig, LogLevel } from '@kubb/core'\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { spinner } from './program.ts'\n\ntype RunProps = {\n config: KubbConfig\n options: CLIOptions\n}\n\nexport async function run({ config, options }: RunProps): Promise<void> {\n const hrstart = process.hrtime()\n\n const logger = createLogger(spinner)\n\n const executeHooks = async (hooks: KubbConfig['hooks'], logLevel: LogLevel) => {\n if (!hooks?.done) {\n return\n }\n\n const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done]\n\n if (logLevel === 'silent') {\n spinner.start(`🪂 Executing hooks`)\n }\n type Executer = { subProcess: ExecaReturnValue<string>; abort: AbortController['abort'] }\n\n const executers: Promise<Executer>[] = commands.map(async (command) => {\n const oraWritable = new OraWritable(spinner, command)\n const abortController = new AbortController()\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n spinner.start(parseText(`🪂 Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout!(oraWritable)\n spinner.suffixText = ''\n\n if (logLevel === 'info') {\n spinner.succeed(parseText(`🪂 Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n console.log(subProcess.stdout)\n }\n\n // wait for 50ms to be sure that all open files are close(fs)\n await timeout(50)\n\n oraWritable.destroy()\n return { subProcess, abort: abortController.abort.bind(abortController) }\n })\n\n await Promise.all(executers)\n\n if (logLevel === 'silent') {\n spinner.succeed(`🪂 Executing hooks`)\n }\n }\n\n const getSummary = (pluginManager: BuildOutput['pluginManager'], status: 'success' | 'failed'): string[] => {\n const logs: string[] = []\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))\n\n const buildStartPlugins = [\n ...new Set(pluginManager.executed.filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core').map((item) => item.plugin.name)),\n ]\n\n const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.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?.pluginName || !b.meta?.pluginName) {\n return 0\n }\n if (a.meta?.pluginName.length < b.meta?.pluginName.length) {\n return 1\n }\n if (a.meta?.pluginName.length > b.meta?.pluginName.length) {\n return -1\n }\n return 0\n })\n\n const meta = {\n plugins:\n status === 'success'\n ? `${pc.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`\n : `${pc.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? failedPlugins?.join(', ') : undefined,\n filesCreated: files.length,\n time: pc.yellow(`${elapsedSeconds}s`),\n output: pathParser.resolve(config.root, config.output.path),\n } as const\n\n if (options.debug) {\n logs.push(pc.bold('Generated files:\\n'))\n logs.push(files.map((file) => `${pc.blue(file.meta?.pluginName)} ${file.path}`).join('\\n'))\n }\n\n logs.push(\n [\n [` ${pc.bold('Plugins:')} ${meta.plugins}`, true],\n [` ${pc.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${pc.bold('Generated:')} ${meta.filesCreated} files`, true],\n [` ${pc.bold('Time:')} ${meta.time}`, true],\n [` ${pc.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\n try {\n const { root: _root, ...userConfig } = config\n const logLevel = options.logLevel ?? userConfig.logLevel ?? 'silent'\n const inputPath = options.input ?? userConfig.input.path\n\n spinner.start(parseText(`🚀 Building`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n const output = await build({\n config: {\n root: process.cwd(),\n ...userConfig,\n logLevel,\n input: {\n ...userConfig.input,\n path: inputPath,\n },\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n })\n\n spinner.succeed(parseText(`🚀 Build completed`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n await executeHooks(config.hooks, logLevel)\n\n const summary = getSummary(output.pluginManager, 'success')\n console.log(summary.join(''))\n } catch (error: any) {\n if (error instanceof PluginError || error instanceof ParallelPluginError) {\n const summary = getSummary(error.pluginManager, 'failed')\n\n throw new SummaryError('Something went wrong\\n', { cause: error, summary })\n }\n\n throw new SummaryError('Something went wrong\\n', { cause: error })\n }\n}\n","export function parseHrtimeToSeconds(hrtime: [number, number]) {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","import type { LogLevel } from '@kubb/core'\n\nexport function parseText(baseText: string, config: Partial<Record<LogLevel, string>>, logLevel: LogLevel = 'silent') {\n return `${baseText}${config[logLevel] || ''}`\n}\n","import type { WritableOptions } from 'node:stream'\nimport { Writable } from 'node:stream'\nimport type { Ora } from 'ora'\nimport pc from 'picocolors'\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: NodeJS.BufferEncoding, callback: (error?: Error | null) => void) {\n this.spinner.suffixText = `\\n\\n${pc.bold(pc.blue(this.command))}: ${chunk?.toString()}`\n\n callback()\n }\n}\n","import { isPromise } from '@kubb/core'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { CLIOptions, KubbConfig, KubbUserConfig } from '@kubb/core'\nimport type { CosmiconfigResult } from '../types.ts'\n\nexport async function getConfig(result: CosmiconfigResult, options: CLIOptions): Promise<KubbConfig> {\n const config = result?.config\n let kubbUserConfig: Promise<KubbUserConfig> = Promise.resolve(config) as Promise<KubbUserConfig>\n\n // for ts or js files\n if (typeof config === 'function') {\n const possiblePromise = config(options)\n if (isPromise(possiblePromise)) {\n kubbUserConfig = possiblePromise\n }\n kubbUserConfig = Promise.resolve(possiblePromise)\n }\n\n let JSONConfig = await kubbUserConfig\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as KubbConfig\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n\nimport { importModule } from '@kubb/core'\n\nimport type { KubbJSONPlugins, KubbObjectPlugin, KubbUserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbJSONPlugins[] {\n return !!(plugins as KubbJSONPlugins[])?.some((plugin) => {\n return typeof plugin?.[0] === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbObjectPlugin {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nasync function importPlugin(name: string, options: object): Promise<KubbUserConfig['plugins']> {\n const importedPlugin: any = process.env.NODE_ENV === 'test' ? await import(name) : await importModule(name, process.cwd())\n\n // eslint-disable-next-line\n return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options)\n}\n\nexport function getPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[] | KubbObjectPlugin[]): Promise<KubbUserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n const promises = Object.keys(plugins).map((name) => {\n return importPlugin(name, plugins[name as keyof typeof plugins])\n })\n return Promise.all(promises)\n }\n\n if (isJSONPlugins(plugins)) {\n const promises = plugins.map((plugin) => {\n const [name, options = {}] = plugin\n return importPlugin(name, options)\n })\n return Promise.all(promises)\n }\n\n return Promise.resolve(plugins)\n}\n","import pc from 'picocolors'\n\nimport { spinner } from '../program'\n\nexport async function startWatcher(path: string[], cb: (path: string[]) => 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(pc.yellow(pc.bold(`Change detected: ${type} ${file}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n } catch (e) {\n spinner.warn(pc.red('Watcher failed'))\n }\n })\n\n return\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { importModule } from '@kubb/core'\n\nimport { cosmiconfig } from 'cosmiconfig'\nimport tsNode from 'ts-node'\nimport yaml from 'yaml'\n\nimport type { CosmiconfigResult } from '../types.ts'\n\nconst jsLoader = async (configFile: string) => {\n return importModule(configFile)\n}\n// TODO fix tsLoader for node 20 when using ESM only\n// https://github.com/TypeStrong/ts-node/issues/1997\nconst tsLoader = (configFile: string) => {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n let registerer = { enabled() {} }\n\n try {\n // Register TypeScript compiler instance\n registerer = tsNode.register({\n compilerOptions: { module: 'commonjs' },\n swc: true,\n typeCheck: false,\n })\n\n const module = require(configFile)\n\n return module.default\n } catch (err: any) {\n if (err.code === 'MODULE_NOT_FOUND') {\n throw new Error(`'ts-node' is required for the TypeScript configuration files. Make sure it is installed\\nError: ${err.message}`)\n }\n\n throw err\n } finally {\n registerer.enabled()\n }\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string) {\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n 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.cjs`,\n `.${moduleName}rc.mjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.cjs`,\n `${moduleName}.config.mjs`,\n ],\n loaders: {\n '.yaml': (filepath, content) => yaml.parse(content),\n '.yml': (filepath, content) => yaml.parse(content),\n '.js': jsLoader,\n '.cjs': jsLoader,\n '.mjs': jsLoader,\n '.ts': tsLoader,\n noExt: jsLoader,\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 { ParallelPluginError } from '@kubb/core'\nimport PrettyError from 'pretty-error'\n\nexport const prettyError = new PrettyError()\n .skipPackage('commander')\n .skip(function (traceLine, lineNumber) {\n // exclude renderErrors.ts\n const pattern = new RegExp('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[]): string[] {\n return errors\n .reduce((prev, error) => {\n const causedError = error?.cause as Error\n if (causedError) {\n prev = [...prev, ...getErrorCauses([causedError])]\n }\n prev = [...prev, prettyError.render(error)]\n\n return prev\n }, [] as string[])\n .filter(Boolean)\n}\n\nexport function renderErrors(error: Error | undefined, { prefixText, debug = false }: { prefixText?: string; debug?: boolean }): string {\n if (!error) {\n return ''\n }\n\n if (error instanceof ParallelPluginError) {\n return [prefixText, ...error.errors.map((e) => renderErrors(e, { debug }))].filter(Boolean).join('\\n')\n }\n\n if (debug) {\n const errors = getErrorCauses([error])\n\n return [prefixText, ...errors].filter(Boolean).join('\\n')\n }\n\n // skip when no debug is set\n prettyError.skipNodeFiles()\n prettyError.skip(function () {\n return true\n } as PrettyError.Callback)\n\n return [prefixText, prettyError.render(error.message)].filter(Boolean).join('\\n')\n}\n","import type { Command } from 'commander'\n\nimport { program } from './program.ts'\n\nexport default function runCLI(argv?: readonly string[]): Command {\n return program.parse(argv)\n}\n"]}
1
+ {"version":3,"sources":["../src/program.ts","../package.json","../src/init.ts","../src/run.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/parseText.ts","../src/utils/OraWritable.ts","../src/utils/getConfig.ts","../src/utils/getPlugins.ts","../src/utils/watcher.ts","../src/utils/getCosmiConfig.ts","../src/utils/renderErrors.ts","../src/index.ts"],"names":["pathParser","pc","LogLevel","canLogHierarchy","spinner","importModule","moduleName","ParallelPluginError","SummaryError","write","config"],"mappings":";;;;;;;;;AAAA,OAAOA,iBAAgB;AAEvB,SAAS,SAAS,gBAAgB,cAAc;AAChD,OAAO,SAAS;AAChB,OAAOC,SAAQ;;;ACFb,cAAW;;;ACFb,OAAO,gBAAgB;AAEvB,SAAS,UAAU,0BAA0B,OAAO,uBAAuB;AAE3E,SAAS,SAAS;AAClB,OAAO,QAAQ;AA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OAAO,GAAG,CAAC,CAAC;AAAA,MACpF,CAAC;AAAA,IACH;AAEA,UAAM,SAAS,MAAM,UAAU,QAAQ,OAAO;AAE9C,UAAM,IAAI,EAAE,QAAQ,YAAY,QAAQ,CAAC;AAAA,EAC3C,SAAS,GAAP;AACA,mBAAe,GAAG,OAAO;AAAA,EAC3B;AACF,CAAC;;;AYpGY,SAAR,OAAwB,MAAmC;AAChE,SAAO,QAAQ,MAAM,IAAI;AAC3B","sourcesContent":["import pathParser from 'node:path'\n\nimport { Command, CommanderError, Option } from 'commander'\nimport ora from 'ora'\nimport pc from 'picocolors'\n\nimport { version } from '../package.json'\nimport { init } from './init.ts'\nimport { run } from './run.ts'\nimport { getConfig, getCosmiConfig, renderErrors, startWatcher } from './utils/index.ts'\n\nimport { LogLevel, SummaryError, canLogHierarchy } from '@kubb/core'\nimport type { CLIOptions } from '@kubb/core'\nimport { Warning } from '@kubb/core'\n\nconst moduleName = 'kubb'\n\nexport const spinner = ora({\n spinner: 'clock',\n})\n\nfunction programCatcher(e: unknown, CLIOptions: CLIOptions): void {\n const originalError = e as Error\n let error = originalError\n\n // summaryError check\n const summaryError = error instanceof SummaryError ? error : undefined\n\n if (summaryError) {\n // use the real error from summaryError and use the case of SummaryError to display a summary of plugins that failed\n error = summaryError.cause as Error\n }\n\n const message = renderErrors(error, { logLevel: CLIOptions.logLevel, prefixText: pc.red(originalError?.message) })\n\n if (error instanceof Warning) {\n spinner.warn(pc.yellow(error.message))\n process.exit(0)\n }\n\n if (canLogHierarchy(CLIOptions.logLevel, LogLevel.silent)) {\n spinner.fail(message)\n process.exit(1)\n }\n\n spinner.fail([message, ...(summaryError?.summary || [])].join('\\n'))\n process.exit(1)\n}\n\nexport const program = new Command(moduleName)\n .name(moduleName)\n .description('Kubb')\n .version(version, '-v')\n .exitOverride((err) => {\n if (err instanceof CommanderError) {\n process.exit(1)\n }\n })\n .configureOutput({\n outputError: (message, write) => {\n const CLIOptions: CLIOptions = program.opts()\n\n write(\n renderErrors(new Error(message, { cause: undefined }), {\n logLevel: CLIOptions.logLevel,\n prefixText: pc.red('Something went wrong with processing the CLI\\n'),\n }) + '\\n'\n )\n },\n })\n .addOption(new Option('-c, --config <path>', 'Path to the Kubb config'))\n .addOption(new Option('-i, --input <path>', 'Path of the input file(overrides the one in `kubb.config.js`)'))\n .addOption(new Option('-l, --logLevel <type>', 'Type of the logging(overrides the one in `kubb.config.js`)').choices(['info', 'silent', 'stacktrace']))\n .addOption(new Option('--init', 'Init Kubb'))\n .addOption(new Option('-d, --debug', 'Debug mode').default(false))\n .addOption(new Option('-w, --watch', 'Watch mode based on the input file'))\n .action(async (options: CLIOptions) => {\n try {\n if (options.init) {\n return init({ logLevel: options.logLevel })\n }\n\n // CONFIG\n spinner.start('💾 Loading config')\n const result = await getCosmiConfig(moduleName, options.config)\n spinner.succeed(`💾 Config loaded(${pc.dim(pathParser.relative(process.cwd(), result.filepath))})`)\n // END CONFIG\n\n if (options.watch) {\n const config = await getConfig(result, options)\n\n return startWatcher([config.input.path], async (paths) => {\n await run({ config, CLIOptions: options })\n spinner.spinner = 'simpleDotsScrolling'\n spinner.start(pc.yellow(pc.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n\n const config = await getConfig(result, options)\n\n await run({ config, CLIOptions: options })\n } catch (e) {\n programCatcher(e, options)\n }\n })\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"1.2.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.js\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"kubb\": \"bin/kubb.js\"\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf ./dist\",\n \"lint\": \"eslint --format pretty ./src\",\n \"lint-fix\": \"bun run lint --quiet --fix\",\n \"release\": \"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 \"@swc/core\": \"^1.3.64\",\n \"chokidar\": \"^3.5.3\",\n \"commander\": \"^10.0.1\",\n \"cosmiconfig\": \"^8.2.0\",\n \"execa\": \"^7.1.1\",\n \"ora\": \"^6.3.1\",\n \"picocolors\": \"^1.0.0\",\n \"pretty-error\": \"^4.0.0\",\n \"string-argv\": \"^0.3.2\",\n \"ts-node\": \"^10.9.1\",\n \"yaml\": \"^2.3.1\"\n },\n \"devDependencies\": {\n \"@kubb/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.3.1\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.1.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 pathParser from 'node:path'\n\nimport { LogLevel, isPromiseFulfilledResult, write, canLogHierarchy } from '@kubb/core'\n\nimport { $ } from 'execa'\nimport pc from 'picocolors'\n\nimport type { LogLevels } from '@kubb/core'\nimport { spinner } from './program.ts'\n\nexport type Preset = 'simple'\n\nexport type PackageManager = 'pnpm' | 'npm' | 'yarn'\n\nexport type PresetMeta = {\n 'kubb.config': string\n packages: string[]\n}\n\ntype RunProps = {\n /**\n * @default `'silent'`\n */\n logLevel?: LogLevels\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 createSwagger from '@kubb/swagger'\nimport createSwaggerTS from '@kubb/swagger-ts'\nimport 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 logLevel: 'info',\n plugins: [createSwagger({}), createSwaggerTS({ output: 'models', enumType: 'enum' }), createSwaggerTanstackQuery({ output: './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' }: RunProps): Promise<undefined> {\n spinner.start('📦 Initializing Kubb')\n\n const presetMeta = presets[preset]\n const path = pathParser.resolve(process.cwd(), './kubb.config.js')\n const installCommand = packageManager === 'npm' ? 'install' : 'add'\n\n spinner.start(`📀 Writing \\`kubb.config.js\\` ${pc.dim(path)}`)\n await write(presetMeta['kubb.config'], path)\n spinner.succeed(`📀 Wrote \\`kubb.config.js\\` ${pc.dim(path)}`)\n\n const results = await Promise.allSettled([\n $`npm init es6 -y`,\n ...presetMeta.packages.map(async (pack) => {\n spinner.start(`📀 Installing ${pc.dim(pack)}`)\n const { stdout } = await $({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`\n spinner.succeed(`📀 Installed ${pc.dim(pack)}`)\n\n return stdout\n }),\n ])\n\n if (canLogHierarchy(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 pathParser from 'node:path'\n\nimport { build, ParallelPluginError, PluginError, SummaryError, timeout, createLogger, randomPicoColour, LogLevel, canLogHierarchy } from '@kubb/core'\n\nimport type { ExecaReturnValue } from 'execa'\n\nimport { performance, PerformanceObserver } from 'node:perf_hooks'\nimport { execa } from 'execa'\nimport pc from 'picocolors'\n\nimport { parseArgsStringToArgv } from 'string-argv'\n\nimport { parseHrtimeToSeconds } from './utils/parseHrtimeToSeconds.ts'\nimport { parseText } from './utils/parseText.ts'\n\nimport type { BuildOutput, CLIOptions, KubbConfig, LogLevels } from '@kubb/core'\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { spinner } from './program.ts'\n\ntype RunProps = {\n config: KubbConfig\n CLIOptions: CLIOptions\n}\n\ntype ExecutingHooksProps = {\n hooks: KubbConfig['hooks']\n logLevel: LogLevels\n debug?: boolean\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 (canLogHierarchy(logLevel, LogLevel.silent)) {\n spinner.start(`Executing hooks`)\n }\n type Executer = { subProcess: ExecaReturnValue<string>; abort: AbortController['abort'] }\n\n const executers: Promise<Executer>[] = commands.map(async (command) => {\n const oraWritable = new OraWritable(spinner, command)\n const abortController = new AbortController()\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n spinner.start(parseText(`Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout!(oraWritable)\n spinner.suffixText = ''\n\n if (canLogHierarchy(logLevel, LogLevel.info)) {\n spinner.succeed(parseText(`Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n console.log(subProcess.stdout)\n }\n\n // wait for 100ms to be sure that all open files are close(fs)\n await timeout(100)\n\n oraWritable.destroy()\n return { subProcess, abort: abortController.abort.bind(abortController) }\n })\n\n await Promise.all(executers)\n\n if (canLogHierarchy(logLevel, LogLevel.silent)) {\n spinner.succeed(`Executing hooks`)\n }\n}\n\ntype SummaryProps = {\n pluginManager: BuildOutput['pluginManager']\n status: 'success' | 'failed'\n hrstart: [number, number]\n config: KubbConfig\n logLevel?: LogLevels\n}\n\nfunction getSummary({ pluginManager, status, hrstart, config, logLevel }: SummaryProps): string[] {\n const logs: string[] = []\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))\n\n const buildStartPlugins = [\n ...new Set(pluginManager.executed.filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core').map((item) => item.plugin.name)),\n ]\n\n const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.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?.pluginName || !b.meta?.pluginName) {\n return 0\n }\n if (a.meta?.pluginName.length < b.meta?.pluginName.length) {\n return 1\n }\n if (a.meta?.pluginName.length > b.meta?.pluginName.length) {\n return -1\n }\n return 0\n })\n\n const meta = {\n plugins:\n status === 'success'\n ? `${pc.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`\n : `${pc.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? failedPlugins?.map((name) => randomPicoColour(name))?.join(', ') : undefined,\n filesCreated: files.length,\n time: pc.yellow(`${elapsedSeconds}s`),\n output: pathParser.resolve(config.root, config.output.path),\n } as const\n\n if (canLogHierarchy(logLevel, 'stacktrace')) {\n logs.push(pc.bold('Generated files:\\n'))\n logs.push(files.map((file) => `${randomPicoColour(file.meta?.pluginName)} ${file.path}`).join('\\n'))\n }\n\n logs.push(\n [\n [`\\n`, true],\n [` ${pc.bold('Plugins:')} ${meta.plugins}`, true],\n [` ${pc.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${pc.bold('Generated:')} ${meta.filesCreated} files`, true],\n [` ${pc.bold('Time:')} ${meta.time}`, true],\n [` ${pc.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\nexport async function run({ config, CLIOptions }: RunProps): Promise<void> {\n const hrstart = process.hrtime()\n const logger = createLogger(spinner)\n\n const performanceOpserver = new PerformanceObserver((items) => {\n const message = `${items.getEntries()[0].duration.toFixed(0)}ms`\n\n spinner.suffixText = pc.yellow(message)\n\n performance.clearMarks()\n })\n\n if (CLIOptions.debug) {\n performanceOpserver.observe({ type: 'measure' })\n }\n\n try {\n const { root: _root, ...userConfig } = config\n const logLevel = CLIOptions.logLevel ?? userConfig.logLevel ?? LogLevel.silent\n const inputPath = CLIOptions.input ?? userConfig.input.path\n\n spinner.start(parseText(`🚀 Building`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n const output = await build({\n config: {\n root: process.cwd(),\n ...userConfig,\n logLevel,\n input: {\n ...userConfig.input,\n path: inputPath,\n },\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n debug: CLIOptions.debug,\n })\n\n spinner.suffixText = ''\n spinner.succeed(parseText(`🚀 Build completed`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n await timeout(100)\n await executeHooks({ hooks: config.hooks, logLevel, debug: CLIOptions.debug })\n\n const summary = getSummary({ pluginManager: output.pluginManager, config, status: 'success', hrstart, logLevel: CLIOptions.logLevel })\n console.log(summary.join(''))\n } catch (error: any) {\n let summary: string[] = []\n\n if (error instanceof PluginError || error instanceof ParallelPluginError) {\n summary = getSummary({ pluginManager: error.pluginManager, config, status: 'failed', hrstart, logLevel: CLIOptions.logLevel })\n }\n\n throw new SummaryError('Something went wrong\\n', { cause: error, summary })\n }\n}\n","export function parseHrtimeToSeconds(hrtime: [number, number]) {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","import { LogLevel } from '@kubb/core'\nimport type { LogLevels } from '@kubb/core'\n\nexport function parseText(baseText: string, config: Partial<Record<LogLevels, string>>, logLevel: LogLevels = LogLevel.silent) {\n return `${baseText}${config[logLevel] || ''}`\n}\n","import type { WritableOptions } from 'node:stream'\nimport { Writable } from 'node:stream'\nimport type { Ora } from 'ora'\nimport pc from 'picocolors'\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: NodeJS.BufferEncoding, callback: (error?: Error | null) => void) {\n this.spinner.suffixText = `\\n\\n${pc.bold(pc.blue(this.command))}: ${chunk?.toString()}`\n\n callback()\n }\n}\n","import { isPromise } from '@kubb/core'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { CLIOptions, KubbConfig, KubbUserConfig } from '@kubb/core'\nimport type { CosmiconfigResult } from '../types.ts'\n\nexport async function getConfig(result: CosmiconfigResult, CLIOptions: CLIOptions): Promise<KubbConfig> {\n const config = result?.config\n let kubbUserConfig: Promise<KubbUserConfig> = Promise.resolve(config) as Promise<KubbUserConfig>\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 JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as KubbConfig\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n\nimport { importModule } from '@kubb/core'\n\nimport type { KubbJSONPlugins, KubbObjectPlugin, KubbUserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbJSONPlugins[] {\n return !!(plugins as KubbJSONPlugins[])?.some((plugin) => {\n return typeof plugin?.[0] === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbObjectPlugin {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nasync function importPlugin(name: string, options: object): Promise<KubbUserConfig['plugins']> {\n const importedPlugin: any = process.env.NODE_ENV === 'test' ? await import(name) : await importModule(name, process.cwd())\n\n // eslint-disable-next-line\n return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options)\n}\n\nexport function getPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[] | KubbObjectPlugin[]): Promise<KubbUserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n const promises = Object.keys(plugins).map((name) => {\n return importPlugin(name, plugins[name as keyof typeof plugins])\n })\n return Promise.all(promises)\n }\n\n if (isJSONPlugins(plugins)) {\n const promises = plugins.map((plugin) => {\n const [name, options = {}] = plugin\n return importPlugin(name, options)\n })\n return Promise.all(promises)\n }\n\n return Promise.resolve(plugins)\n}\n","import pc from 'picocolors'\n\nimport { spinner } from '../program'\n\nexport async function startWatcher(path: string[], cb: (path: string[]) => 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(pc.yellow(pc.bold(`Change detected: ${type} ${file}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n } catch (e) {\n spinner.warn(pc.red('Watcher failed'))\n }\n })\n\n return\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { importModule } from '@kubb/core'\n\nimport { cosmiconfig } from 'cosmiconfig'\nimport tsNode from 'ts-node'\nimport yaml from 'yaml'\n\nimport type { CosmiconfigResult } from '../types.ts'\n\nconst jsLoader = async (configFile: string) => {\n return importModule(configFile)\n}\n// TODO fix tsLoader for node 20 when using ESM only\n// https://github.com/TypeStrong/ts-node/issues/1997\nconst tsLoader = (configFile: string) => {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n let registerer = { enabled() {} }\n\n try {\n // Register TypeScript compiler instance\n registerer = tsNode.register({\n compilerOptions: { module: 'commonjs' },\n swc: true,\n typeCheck: false,\n })\n\n const module = require(configFile)\n\n return module.default\n } catch (err: any) {\n if (err.code === 'MODULE_NOT_FOUND') {\n throw new Error(`'ts-node' is required for the TypeScript configuration files. Make sure it is installed\\nError: ${err.message}`)\n }\n\n throw err\n } finally {\n registerer.enabled()\n }\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string) {\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n 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.cjs`,\n `.${moduleName}rc.mjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.cjs`,\n `${moduleName}.config.mjs`,\n ],\n loaders: {\n '.yaml': (filepath, content) => yaml.parse(content),\n '.yml': (filepath, content) => yaml.parse(content),\n '.js': jsLoader,\n '.cjs': jsLoader,\n '.mjs': jsLoader,\n '.ts': tsLoader,\n noExt: jsLoader,\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 type { LogLevels } from '@kubb/core'\nimport { LogLevel, ParallelPluginError, canLogHierarchy } from '@kubb/core'\nimport PrettyError from 'pretty-error'\n\nexport const prettyError = new PrettyError()\n .skipPackage('commander')\n .skip(function (traceLine, lineNumber) {\n // exclude renderErrors.ts\n const pattern = new RegExp('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[]): string[] {\n return errors\n .reduce((prev, error) => {\n const causedError = error?.cause as Error\n if (causedError) {\n prev = [...prev, ...getErrorCauses([causedError])]\n }\n prev = [...prev, prettyError.render(error)]\n\n return prev\n }, [] as string[])\n .filter(Boolean)\n}\n\nexport function renderErrors(error: Error | undefined, { prefixText, logLevel = LogLevel.silent }: { prefixText?: string; logLevel?: LogLevels }): string {\n if (!error) {\n return ''\n }\n\n if (error instanceof ParallelPluginError) {\n return [prefixText, ...error.errors.map((e) => renderErrors(e, { logLevel }))].filter(Boolean).join('\\n')\n }\n\n if (canLogHierarchy(logLevel, 'stacktrace')) {\n const errors = getErrorCauses([error])\n\n return [prefixText, ...errors].filter(Boolean).join('\\n')\n }\n\n // skip when no debug is set\n prettyError.skipNodeFiles()\n prettyError.skip(function () {\n return true\n } as PrettyError.Callback)\n\n return [prefixText, prettyError.render(error.message)].filter(Boolean).join('\\n')\n}\n","import type { Command } from 'commander'\n\nimport { program } from './program.ts'\n\nexport default function runCLI(argv?: readonly string[]): Command {\n return program.parse(argv)\n}\n"]}
package/dist/index.js CHANGED
@@ -3,8 +3,9 @@ import pathParser from 'node:path';
3
3
  import { Command, CommanderError, Option } from 'commander';
4
4
  import ora from 'ora';
5
5
  import pc3 from 'picocolors';
6
- import { Warning, write, isPromiseFulfilledResult, createLogger, build, PluginError, ParallelPluginError, SummaryError, isPromise, timeout, importModule } from '@kubb/core';
6
+ import { write, canLogHierarchy, LogLevel, isPromiseFulfilledResult, createLogger, build, timeout, PluginError, ParallelPluginError, SummaryError, isPromise, Warning, randomPicoColour, importModule } from '@kubb/core';
7
7
  import { $, execa } from 'execa';
8
+ import { PerformanceObserver, performance } from 'node:perf_hooks';
8
9
  import { parseArgsStringToArgv } from 'string-argv';
9
10
  import { Writable } from 'node:stream';
10
11
  import { cosmiconfig } from 'cosmiconfig';
@@ -23,7 +24,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
23
24
  });
24
25
 
25
26
  // package.json
26
- var version = "1.2.0";
27
+ var version = "1.2.1";
27
28
  var presets = {
28
29
  simple: {
29
30
  "kubb.config": `
@@ -51,7 +52,7 @@ export default defineConfig({
51
52
  packages: ["@kubb/core", "@kubb/cli", "@kubb/swagger", "@kubb/swagger-ts", "@kubb/swagger-tanstack-query"]
52
53
  }
53
54
  };
54
- async function init({ preset = "simple", logLevel = "silent", packageManager = "pnpm" }) {
55
+ async function init({ preset = "simple", logLevel = LogLevel.silent, packageManager = "pnpm" }) {
55
56
  spinner.start("\u{1F4E6} Initializing Kubb");
56
57
  const presetMeta = presets[preset];
57
58
  const path = pathParser.resolve(process.cwd(), "./kubb.config.js");
@@ -68,7 +69,7 @@ async function init({ preset = "simple", logLevel = "silent", packageManager = "
68
69
  return stdout;
69
70
  })
70
71
  ]);
71
- if (logLevel === "info") {
72
+ if (canLogHierarchy(logLevel, LogLevel.info)) {
72
73
  results.forEach((result) => {
73
74
  if (isPromiseFulfilledResult(result)) {
74
75
  console.log(result.value);
@@ -84,9 +85,7 @@ function parseHrtimeToSeconds(hrtime) {
84
85
  const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
85
86
  return seconds;
86
87
  }
87
-
88
- // src/utils/parseText.ts
89
- function parseText(baseText, config, logLevel = "silent") {
88
+ function parseText(baseText, config, logLevel = LogLevel.silent) {
90
89
  return `${baseText}${config[logLevel] || ""}`;
91
90
  }
92
91
  var OraWritable = class extends Writable {
@@ -106,90 +105,100 @@ ${pc3.bold(pc3.blue(this.command))}: ${chunk?.toString()}`;
106
105
  };
107
106
 
108
107
  // src/run.ts
109
- async function run({ config, options }) {
110
- const hrstart = process.hrtime();
111
- const logger = createLogger(spinner);
112
- const executeHooks = async (hooks, logLevel) => {
113
- if (!hooks?.done) {
114
- return;
108
+ async function executeHooks({ hooks, logLevel }) {
109
+ if (!hooks?.done) {
110
+ return;
111
+ }
112
+ const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done];
113
+ if (canLogHierarchy(logLevel, LogLevel.silent)) {
114
+ spinner.start(`Executing hooks`);
115
+ }
116
+ const executers = commands.map(async (command) => {
117
+ const oraWritable = new OraWritable(spinner, command);
118
+ const abortController = new AbortController();
119
+ const [cmd, ..._args] = [...parseArgsStringToArgv(command)];
120
+ spinner.start(parseText(`Executing hook`, { info: ` ${pc3.dim(command)}` }, logLevel));
121
+ const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout(oraWritable);
122
+ spinner.suffixText = "";
123
+ if (canLogHierarchy(logLevel, LogLevel.info)) {
124
+ spinner.succeed(parseText(`Executing hook`, { info: ` ${pc3.dim(command)}` }, logLevel));
125
+ console.log(subProcess.stdout);
115
126
  }
116
- const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done];
117
- if (logLevel === "silent") {
118
- spinner.start(`\u{1FA82} Executing hooks`);
127
+ await timeout(100);
128
+ oraWritable.destroy();
129
+ return { subProcess, abort: abortController.abort.bind(abortController) };
130
+ });
131
+ await Promise.all(executers);
132
+ if (canLogHierarchy(logLevel, LogLevel.silent)) {
133
+ spinner.succeed(`Executing hooks`);
134
+ }
135
+ }
136
+ function getSummary({ pluginManager, status, hrstart, config, logLevel }) {
137
+ const logs = [];
138
+ const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart));
139
+ const buildStartPlugins = [
140
+ ...new Set(pluginManager.executed.filter((item) => item.hookName === "buildStart" && item.plugin.name !== "core").map((item) => item.plugin.name))
141
+ ];
142
+ const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.includes(plugin.name))?.map((plugin) => plugin.name);
143
+ const pluginsCount = config.plugins?.length || 0;
144
+ const files = pluginManager.fileManager.files.sort((a, b) => {
145
+ if (!a.meta?.pluginName || !b.meta?.pluginName) {
146
+ return 0;
119
147
  }
120
- const executers = commands.map(async (command) => {
121
- const oraWritable = new OraWritable(spinner, command);
122
- const abortController = new AbortController();
123
- const [cmd, ..._args] = [...parseArgsStringToArgv(command)];
124
- spinner.start(parseText(`\u{1FA82} Executing hook`, { info: ` ${pc3.dim(command)}` }, logLevel));
125
- const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout(oraWritable);
126
- spinner.suffixText = "";
127
- if (logLevel === "info") {
128
- spinner.succeed(parseText(`\u{1FA82} Executing hook`, { info: ` ${pc3.dim(command)}` }, logLevel));
129
- console.log(subProcess.stdout);
130
- }
131
- await timeout(50);
132
- oraWritable.destroy();
133
- return { subProcess, abort: abortController.abort.bind(abortController) };
134
- });
135
- await Promise.all(executers);
136
- if (logLevel === "silent") {
137
- spinner.succeed(`\u{1FA82} Executing hooks`);
148
+ if (a.meta?.pluginName.length < b.meta?.pluginName.length) {
149
+ return 1;
138
150
  }
139
- };
140
- const getSummary = (pluginManager, status) => {
141
- const logs = [];
142
- const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart));
143
- const buildStartPlugins = [
144
- ...new Set(pluginManager.executed.filter((item) => item.hookName === "buildStart" && item.plugin.name !== "core").map((item) => item.plugin.name))
145
- ];
146
- const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.includes(plugin.name))?.map((plugin) => plugin.name);
147
- const pluginsCount = config.plugins?.length || 0;
148
- const files = pluginManager.fileManager.files.sort((a, b) => {
149
- if (!a.meta?.pluginName || !b.meta?.pluginName) {
150
- return 0;
151
- }
152
- if (a.meta?.pluginName.length < b.meta?.pluginName.length) {
153
- return 1;
154
- }
155
- if (a.meta?.pluginName.length > b.meta?.pluginName.length) {
156
- return -1;
157
- }
158
- return 0;
159
- });
160
- const meta = {
161
- plugins: status === "success" ? `${pc3.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${pc3.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,
162
- pluginsFailed: status === "failed" ? failedPlugins?.join(", ") : void 0,
163
- filesCreated: files.length,
164
- time: pc3.yellow(`${elapsedSeconds}s`),
165
- output: pathParser.resolve(config.root, config.output.path)
166
- };
167
- if (options.debug) {
168
- logs.push(pc3.bold("Generated files:\n"));
169
- logs.push(files.map((file) => `${pc3.blue(file.meta?.pluginName)} ${file.path}`).join("\n"));
151
+ if (a.meta?.pluginName.length > b.meta?.pluginName.length) {
152
+ return -1;
170
153
  }
171
- logs.push(
172
- [
173
- [` ${pc3.bold("Plugins:")} ${meta.plugins}`, true],
174
- [` ${pc3.dim("Failed:")} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
175
- [`${pc3.bold("Generated:")} ${meta.filesCreated} files`, true],
176
- [` ${pc3.bold("Time:")} ${meta.time}`, true],
177
- [` ${pc3.bold("Output:")} ${meta.output}`, true],
178
- [`
179
- `, true]
180
- ].map((item) => {
181
- if (item.at(1)) {
182
- return item.at(0);
183
- }
184
- return void 0;
185
- }).filter(Boolean).join("\n")
186
- );
187
- return logs;
154
+ return 0;
155
+ });
156
+ const meta = {
157
+ plugins: status === "success" ? `${pc3.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${pc3.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,
158
+ pluginsFailed: status === "failed" ? failedPlugins?.map((name) => randomPicoColour(name))?.join(", ") : void 0,
159
+ filesCreated: files.length,
160
+ time: pc3.yellow(`${elapsedSeconds}s`),
161
+ output: pathParser.resolve(config.root, config.output.path)
188
162
  };
163
+ if (canLogHierarchy(logLevel, "stacktrace")) {
164
+ logs.push(pc3.bold("Generated files:\n"));
165
+ logs.push(files.map((file) => `${randomPicoColour(file.meta?.pluginName)} ${file.path}`).join("\n"));
166
+ }
167
+ logs.push(
168
+ [
169
+ [`
170
+ `, true],
171
+ [` ${pc3.bold("Plugins:")} ${meta.plugins}`, true],
172
+ [` ${pc3.dim("Failed:")} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
173
+ [`${pc3.bold("Generated:")} ${meta.filesCreated} files`, true],
174
+ [` ${pc3.bold("Time:")} ${meta.time}`, true],
175
+ [` ${pc3.bold("Output:")} ${meta.output}`, true],
176
+ [`
177
+ `, true]
178
+ ].map((item) => {
179
+ if (item.at(1)) {
180
+ return item.at(0);
181
+ }
182
+ return void 0;
183
+ }).filter(Boolean).join("\n")
184
+ );
185
+ return logs;
186
+ }
187
+ async function run({ config, CLIOptions }) {
188
+ const hrstart = process.hrtime();
189
+ const logger = createLogger(spinner);
190
+ const performanceOpserver = new PerformanceObserver((items) => {
191
+ const message = `${items.getEntries()[0].duration.toFixed(0)}ms`;
192
+ spinner.suffixText = pc3.yellow(message);
193
+ performance.clearMarks();
194
+ });
195
+ if (CLIOptions.debug) {
196
+ performanceOpserver.observe({ type: "measure" });
197
+ }
189
198
  try {
190
199
  const { root: _root, ...userConfig } = config;
191
- const logLevel = options.logLevel ?? userConfig.logLevel ?? "silent";
192
- const inputPath = options.input ?? userConfig.input.path;
200
+ const logLevel = CLIOptions.logLevel ?? userConfig.logLevel ?? LogLevel.silent;
201
+ const inputPath = CLIOptions.input ?? userConfig.input.path;
193
202
  spinner.start(parseText(`\u{1F680} Building`, { info: `(${pc3.dim(inputPath)})` }, logLevel));
194
203
  const output = await build({
195
204
  config: {
@@ -205,18 +214,21 @@ async function run({ config, options }) {
205
214
  ...userConfig.output
206
215
  }
207
216
  },
208
- logger
217
+ logger,
218
+ debug: CLIOptions.debug
209
219
  });
220
+ spinner.suffixText = "";
210
221
  spinner.succeed(parseText(`\u{1F680} Build completed`, { info: `(${pc3.dim(inputPath)})` }, logLevel));
211
- await executeHooks(config.hooks, logLevel);
212
- const summary = getSummary(output.pluginManager, "success");
222
+ await timeout(100);
223
+ await executeHooks({ hooks: config.hooks, logLevel, debug: CLIOptions.debug });
224
+ const summary = getSummary({ pluginManager: output.pluginManager, config, status: "success", hrstart, logLevel: CLIOptions.logLevel });
213
225
  console.log(summary.join(""));
214
226
  } catch (error) {
227
+ let summary = [];
215
228
  if (error instanceof PluginError || error instanceof ParallelPluginError) {
216
- const summary = getSummary(error.pluginManager, "failed");
217
- throw new SummaryError("Something went wrong\n", { cause: error, summary });
229
+ summary = getSummary({ pluginManager: error.pluginManager, config, status: "failed", hrstart, logLevel: CLIOptions.logLevel });
218
230
  }
219
- throw new SummaryError("Something went wrong\n", { cause: error });
231
+ throw new SummaryError("Something went wrong\n", { cause: error, summary });
220
232
  }
221
233
  }
222
234
  function isJSONPlugins(plugins) {
@@ -249,11 +261,11 @@ function getPlugins(plugins) {
249
261
  }
250
262
 
251
263
  // src/utils/getConfig.ts
252
- async function getConfig(result, options) {
264
+ async function getConfig(result, CLIOptions) {
253
265
  const config = result?.config;
254
266
  let kubbUserConfig = Promise.resolve(config);
255
267
  if (typeof config === "function") {
256
- const possiblePromise = config(options);
268
+ const possiblePromise = config(CLIOptions);
257
269
  if (isPromise(possiblePromise)) {
258
270
  kubbUserConfig = possiblePromise;
259
271
  }
@@ -359,14 +371,14 @@ function getErrorCauses(errors) {
359
371
  return prev;
360
372
  }, []).filter(Boolean);
361
373
  }
362
- function renderErrors(error, { prefixText, debug = false }) {
374
+ function renderErrors(error, { prefixText, logLevel = LogLevel.silent }) {
363
375
  if (!error) {
364
376
  return "";
365
377
  }
366
378
  if (error instanceof ParallelPluginError) {
367
- return [prefixText, ...error.errors.map((e) => renderErrors(e, { debug }))].filter(Boolean).join("\n");
379
+ return [prefixText, ...error.errors.map((e) => renderErrors(e, { logLevel }))].filter(Boolean).join("\n");
368
380
  }
369
- if (debug) {
381
+ if (canLogHierarchy(logLevel, "stacktrace")) {
370
382
  const errors = getErrorCauses([error]);
371
383
  return [prefixText, ...errors].filter(Boolean).join("\n");
372
384
  }
@@ -380,20 +392,41 @@ var moduleName = "kubb";
380
392
  var spinner = ora({
381
393
  spinner: "clock"
382
394
  });
395
+ function programCatcher(e, CLIOptions) {
396
+ const originalError = e;
397
+ let error = originalError;
398
+ const summaryError = error instanceof SummaryError ? error : void 0;
399
+ if (summaryError) {
400
+ error = summaryError.cause;
401
+ }
402
+ const message = renderErrors(error, { logLevel: CLIOptions.logLevel, prefixText: pc3.red(originalError?.message) });
403
+ if (error instanceof Warning) {
404
+ spinner.warn(pc3.yellow(error.message));
405
+ process.exit(0);
406
+ }
407
+ if (canLogHierarchy(CLIOptions.logLevel, LogLevel.silent)) {
408
+ spinner.fail(message);
409
+ process.exit(1);
410
+ }
411
+ spinner.fail([message, ...summaryError?.summary || []].join("\n"));
412
+ process.exit(1);
413
+ }
383
414
  var program = new Command(moduleName).name(moduleName).description("Kubb").version(version, "-v").exitOverride((err) => {
384
415
  if (err instanceof CommanderError) {
385
416
  process.exit(1);
386
417
  }
387
418
  }).configureOutput({
388
419
  outputError: (message, write2) => {
389
- const options = program.opts();
420
+ const CLIOptions = program.opts();
390
421
  write2(
391
- renderErrors(new Error(message, { cause: void 0 }), { debug: options.debug, prefixText: pc3.red("Something went wrong with processing the CLI\n") }) + "\n"
422
+ renderErrors(new Error(message, { cause: void 0 }), {
423
+ logLevel: CLIOptions.logLevel,
424
+ prefixText: pc3.red("Something went wrong with processing the CLI\n")
425
+ }) + "\n"
392
426
  );
393
427
  }
394
- }).addOption(new Option("-c, --config <path>", "Path to the Kubb config")).addOption(new Option("-i, --input <path>", "Path of the input file(overrides the one in `kubb.config.js`)")).addOption(new Option("-l, --logLevel <type>", "Type of the logging(overrides the one in `kubb.config.js`)").choices(["error", "info", "silent"])).addOption(new Option("--init", "Init Kubb")).addOption(new Option("-d, --debug", "Debug mode").default(false)).addOption(new Option("-w, --watch", "Watch mode based on the input file")).action(async (options) => {
428
+ }).addOption(new Option("-c, --config <path>", "Path to the Kubb config")).addOption(new Option("-i, --input <path>", "Path of the input file(overrides the one in `kubb.config.js`)")).addOption(new Option("-l, --logLevel <type>", "Type of the logging(overrides the one in `kubb.config.js`)").choices(["info", "silent", "stacktrace"])).addOption(new Option("--init", "Init Kubb")).addOption(new Option("-d, --debug", "Debug mode").default(false)).addOption(new Option("-w, --watch", "Watch mode based on the input file")).action(async (options) => {
395
429
  try {
396
- spinner.start();
397
430
  if (options.init) {
398
431
  return init({ logLevel: options.logLevel });
399
432
  }
@@ -403,27 +436,15 @@ var program = new Command(moduleName).name(moduleName).description("Kubb").versi
403
436
  if (options.watch) {
404
437
  const config2 = await getConfig(result, options);
405
438
  return startWatcher([config2.input.path], async (paths) => {
406
- await run({ config: config2, options });
439
+ await run({ config: config2, CLIOptions: options });
407
440
  spinner.spinner = "simpleDotsScrolling";
408
441
  spinner.start(pc3.yellow(pc3.bold(`Watching for changes in ${paths.join(" and ")}`)));
409
442
  });
410
443
  }
411
444
  const config = await getConfig(result, options);
412
- await run({ config, options });
445
+ await run({ config, CLIOptions: options });
413
446
  } catch (e) {
414
- const originalError = e;
415
- let error = originalError;
416
- const summaryError = error instanceof SummaryError ? error : void 0;
417
- if (summaryError) {
418
- error = summaryError.cause;
419
- }
420
- const message = renderErrors(error, { debug: options.debug, prefixText: pc3.red(originalError?.message) });
421
- if (error instanceof Warning) {
422
- spinner.warn(pc3.yellow(error.message));
423
- process.exit(0);
424
- }
425
- spinner.fail([message, ...summaryError?.summary || []].join("\n"));
426
- process.exit(1);
447
+ programCatcher(e, options);
427
448
  }
428
449
  });
429
450
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/program.ts","../package.json","../src/init.ts","../src/run.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/parseText.ts","../src/utils/OraWritable.ts","../src/utils/getConfig.ts","../src/utils/getPlugins.ts","../src/utils/watcher.ts","../src/utils/getCosmiConfig.ts","../src/utils/renderErrors.ts","../src/index.ts"],"names":["pathParser","pc","spinner","importModule","moduleName","ParallelPluginError","SummaryError","write","config"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,iBAAgB;AAEvB,SAAS,SAAS,gBAAgB,cAAc;AAChD,OAAO,SAAS;AAChB,OAAOC,SAAQ;;;ACFb,cAAW;;;ACFb,OAAO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/B,SAAS,GAAP;AACA,UAAM,gBAAgB;AACtB,QAAI,QAAQ;AAGZ,UAAM,eAAe,iBAAiBK,gBAAe,QAAQ;AAE7D,QAAI,cAAc;AAEhB,cAAQ,aAAa;AAAA,IACvB;AAEA,UAAM,UAAU,aAAa,OAAO,EAAE,OAAO,QAAQ,OAAO,YAAYL,IAAG,IAAI,eAAe,OAAO,EAAE,CAAC;AAExG,QAAI,iBAAiB,SAAS;AAC5B,cAAQ,KAAKA,IAAG,OAAO,MAAM,OAAO,CAAC;AACrC,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,KAAK,CAAC,SAAS,GAAI,cAAc,WAAW,CAAC,CAAE,EAAE,KAAK,IAAI,CAAC;AACnE,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;;;AY5FY,SAAR,OAAwB,MAAmC;AAChE,SAAO,QAAQ,MAAM,IAAI;AAC3B","sourcesContent":["import pathParser from 'node:path'\n\nimport { Command, CommanderError, Option } from 'commander'\nimport ora from 'ora'\nimport pc from 'picocolors'\n\nimport { version } from '../package.json'\nimport { init } from './init.ts'\nimport { run } from './run.ts'\nimport { getConfig, getCosmiConfig, renderErrors, startWatcher } from './utils/index.ts'\n\nimport { SummaryError } from '@kubb/core'\nimport type { CLIOptions } from '@kubb/core'\nimport { Warning } from '@kubb/core'\n\nconst moduleName = 'kubb'\n\nexport const spinner = ora({\n spinner: 'clock',\n})\n\nexport const program = new Command(moduleName)\n .name(moduleName)\n .description('Kubb')\n .version(version, '-v')\n .exitOverride((err) => {\n if (err instanceof CommanderError) {\n process.exit(1)\n }\n })\n .configureOutput({\n outputError: (message, write) => {\n const options: CLIOptions = program.opts()\n\n write(\n renderErrors(new Error(message, { cause: undefined }), { debug: options.debug, prefixText: pc.red('Something went wrong with processing the CLI\\n') }) +\n '\\n'\n )\n },\n })\n .addOption(new Option('-c, --config <path>', 'Path to the Kubb config'))\n .addOption(new Option('-i, --input <path>', 'Path of the input file(overrides the one in `kubb.config.js`)'))\n .addOption(new Option('-l, --logLevel <type>', 'Type of the logging(overrides the one in `kubb.config.js`)').choices(['error', 'info', 'silent']))\n .addOption(new Option('--init', 'Init Kubb'))\n .addOption(new Option('-d, --debug', 'Debug mode').default(false))\n .addOption(new Option('-w, --watch', 'Watch mode based on the input file'))\n .action(async (options: CLIOptions) => {\n try {\n spinner.start()\n\n if (options.init) {\n return init({ logLevel: options.logLevel })\n }\n\n // CONFIG\n // TODO use options.config to show path instead of relying on the `result`\n spinner.start('💾 Loading config')\n const result = await getCosmiConfig(moduleName, options.config)\n spinner.succeed(`💾 Config loaded(${pc.dim(pathParser.relative(process.cwd(), result.filepath))})`)\n // END CONFIG\n\n if (options.watch) {\n const config = await getConfig(result, options)\n\n return startWatcher([config.input.path], async (paths) => {\n await run({ config, options })\n spinner.spinner = 'simpleDotsScrolling'\n spinner.start(pc.yellow(pc.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n\n const config = await getConfig(result, options)\n\n await run({ config, options })\n } catch (e: any) {\n const originalError = e as Error\n let error = originalError\n\n // summaryError check\n const summaryError = error instanceof SummaryError ? error : undefined\n\n if (summaryError) {\n // use the real error from summaryError and use the case of SummaryError to display a summary of plugins that failed\n error = summaryError.cause as Error\n }\n\n const message = renderErrors(error, { debug: options.debug, prefixText: pc.red(originalError?.message) })\n\n if (error instanceof Warning) {\n spinner.warn(pc.yellow(error.message))\n process.exit(0)\n }\n\n spinner.fail([message, ...(summaryError?.summary || [])].join('\\n'))\n process.exit(1)\n }\n })\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"1.2.0\",\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.js\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"kubb\": \"bin/kubb.js\"\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf ./dist\",\n \"lint\": \"eslint --format pretty ./src\",\n \"lint-fix\": \"bun run lint --quiet --fix\",\n \"release\": \"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 \"@swc/core\": \"^1.3.64\",\n \"chokidar\": \"^3.5.3\",\n \"commander\": \"^10.0.1\",\n \"cosmiconfig\": \"^8.2.0\",\n \"execa\": \"^7.1.1\",\n \"ora\": \"^6.3.1\",\n \"picocolors\": \"^1.0.0\",\n \"pretty-error\": \"^4.0.0\",\n \"string-argv\": \"^0.3.2\",\n \"ts-node\": \"^10.9.1\",\n \"yaml\": \"^2.3.1\"\n },\n \"devDependencies\": {\n \"@kubb/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.3.1\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.1.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 pathParser from 'node:path'\n\nimport { isPromiseFulfilledResult, write } from '@kubb/core'\n\nimport { $ } from 'execa'\nimport pc from 'picocolors'\n\nimport type { LogLevel } from '@kubb/core'\nimport { spinner } from './program.ts'\n\nexport type Preset = 'simple'\n\nexport type PackageManager = 'pnpm' | 'npm' | 'yarn'\n\nexport type PresetMeta = {\n 'kubb.config': string\n packages: string[]\n}\n\ntype RunProps = {\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 createSwagger from '@kubb/swagger'\nimport createSwaggerTS from '@kubb/swagger-ts'\nimport 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 logLevel: 'info',\n plugins: [createSwagger({}), createSwaggerTS({ output: 'models', enumType: 'enum' }), createSwaggerTanstackQuery({ output: './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 = 'silent', packageManager = 'pnpm' }: RunProps): Promise<undefined> {\n spinner.start('📦 Initializing Kubb')\n\n const presetMeta = presets[preset]\n const path = pathParser.resolve(process.cwd(), './kubb.config.js')\n const installCommand = packageManager === 'npm' ? 'install' : 'add'\n\n spinner.start(`📀 Writing \\`kubb.config.js\\` ${pc.dim(path)}`)\n await write(presetMeta['kubb.config'], path)\n spinner.succeed(`📀 Wrote \\`kubb.config.js\\` ${pc.dim(path)}`)\n\n const results = await Promise.allSettled([\n $`npm init es6 -y`,\n ...presetMeta.packages.map(async (pack) => {\n spinner.start(`📀 Installing ${pc.dim(pack)}`)\n const { stdout } = await $({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`\n spinner.succeed(`📀 Installed ${pc.dim(pack)}`)\n\n return stdout\n }),\n ])\n\n if (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 pathParser from 'node:path'\n\nimport { build, ParallelPluginError, PluginError, SummaryError, timeout, createLogger } from '@kubb/core'\n\nimport type { ExecaReturnValue } from 'execa'\nimport { execa } from 'execa'\nimport pc from 'picocolors'\n\nimport { parseArgsStringToArgv } from 'string-argv'\n\nimport { parseHrtimeToSeconds } from './utils/parseHrtimeToSeconds.ts'\nimport { parseText } from './utils/parseText.ts'\n\nimport type { BuildOutput, CLIOptions, KubbConfig, LogLevel } from '@kubb/core'\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { spinner } from './program.ts'\n\ntype RunProps = {\n config: KubbConfig\n options: CLIOptions\n}\n\nexport async function run({ config, options }: RunProps): Promise<void> {\n const hrstart = process.hrtime()\n\n const logger = createLogger(spinner)\n\n const executeHooks = async (hooks: KubbConfig['hooks'], logLevel: LogLevel) => {\n if (!hooks?.done) {\n return\n }\n\n const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done]\n\n if (logLevel === 'silent') {\n spinner.start(`🪂 Executing hooks`)\n }\n type Executer = { subProcess: ExecaReturnValue<string>; abort: AbortController['abort'] }\n\n const executers: Promise<Executer>[] = commands.map(async (command) => {\n const oraWritable = new OraWritable(spinner, command)\n const abortController = new AbortController()\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n spinner.start(parseText(`🪂 Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout!(oraWritable)\n spinner.suffixText = ''\n\n if (logLevel === 'info') {\n spinner.succeed(parseText(`🪂 Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n console.log(subProcess.stdout)\n }\n\n // wait for 50ms to be sure that all open files are close(fs)\n await timeout(50)\n\n oraWritable.destroy()\n return { subProcess, abort: abortController.abort.bind(abortController) }\n })\n\n await Promise.all(executers)\n\n if (logLevel === 'silent') {\n spinner.succeed(`🪂 Executing hooks`)\n }\n }\n\n const getSummary = (pluginManager: BuildOutput['pluginManager'], status: 'success' | 'failed'): string[] => {\n const logs: string[] = []\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))\n\n const buildStartPlugins = [\n ...new Set(pluginManager.executed.filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core').map((item) => item.plugin.name)),\n ]\n\n const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.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?.pluginName || !b.meta?.pluginName) {\n return 0\n }\n if (a.meta?.pluginName.length < b.meta?.pluginName.length) {\n return 1\n }\n if (a.meta?.pluginName.length > b.meta?.pluginName.length) {\n return -1\n }\n return 0\n })\n\n const meta = {\n plugins:\n status === 'success'\n ? `${pc.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`\n : `${pc.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? failedPlugins?.join(', ') : undefined,\n filesCreated: files.length,\n time: pc.yellow(`${elapsedSeconds}s`),\n output: pathParser.resolve(config.root, config.output.path),\n } as const\n\n if (options.debug) {\n logs.push(pc.bold('Generated files:\\n'))\n logs.push(files.map((file) => `${pc.blue(file.meta?.pluginName)} ${file.path}`).join('\\n'))\n }\n\n logs.push(\n [\n [` ${pc.bold('Plugins:')} ${meta.plugins}`, true],\n [` ${pc.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${pc.bold('Generated:')} ${meta.filesCreated} files`, true],\n [` ${pc.bold('Time:')} ${meta.time}`, true],\n [` ${pc.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\n try {\n const { root: _root, ...userConfig } = config\n const logLevel = options.logLevel ?? userConfig.logLevel ?? 'silent'\n const inputPath = options.input ?? userConfig.input.path\n\n spinner.start(parseText(`🚀 Building`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n const output = await build({\n config: {\n root: process.cwd(),\n ...userConfig,\n logLevel,\n input: {\n ...userConfig.input,\n path: inputPath,\n },\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n })\n\n spinner.succeed(parseText(`🚀 Build completed`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n await executeHooks(config.hooks, logLevel)\n\n const summary = getSummary(output.pluginManager, 'success')\n console.log(summary.join(''))\n } catch (error: any) {\n if (error instanceof PluginError || error instanceof ParallelPluginError) {\n const summary = getSummary(error.pluginManager, 'failed')\n\n throw new SummaryError('Something went wrong\\n', { cause: error, summary })\n }\n\n throw new SummaryError('Something went wrong\\n', { cause: error })\n }\n}\n","export function parseHrtimeToSeconds(hrtime: [number, number]) {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","import type { LogLevel } from '@kubb/core'\n\nexport function parseText(baseText: string, config: Partial<Record<LogLevel, string>>, logLevel: LogLevel = 'silent') {\n return `${baseText}${config[logLevel] || ''}`\n}\n","import type { WritableOptions } from 'node:stream'\nimport { Writable } from 'node:stream'\nimport type { Ora } from 'ora'\nimport pc from 'picocolors'\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: NodeJS.BufferEncoding, callback: (error?: Error | null) => void) {\n this.spinner.suffixText = `\\n\\n${pc.bold(pc.blue(this.command))}: ${chunk?.toString()}`\n\n callback()\n }\n}\n","import { isPromise } from '@kubb/core'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { CLIOptions, KubbConfig, KubbUserConfig } from '@kubb/core'\nimport type { CosmiconfigResult } from '../types.ts'\n\nexport async function getConfig(result: CosmiconfigResult, options: CLIOptions): Promise<KubbConfig> {\n const config = result?.config\n let kubbUserConfig: Promise<KubbUserConfig> = Promise.resolve(config) as Promise<KubbUserConfig>\n\n // for ts or js files\n if (typeof config === 'function') {\n const possiblePromise = config(options)\n if (isPromise(possiblePromise)) {\n kubbUserConfig = possiblePromise\n }\n kubbUserConfig = Promise.resolve(possiblePromise)\n }\n\n let JSONConfig = await kubbUserConfig\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as KubbConfig\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n\nimport { importModule } from '@kubb/core'\n\nimport type { KubbJSONPlugins, KubbObjectPlugin, KubbUserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbJSONPlugins[] {\n return !!(plugins as KubbJSONPlugins[])?.some((plugin) => {\n return typeof plugin?.[0] === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbObjectPlugin {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nasync function importPlugin(name: string, options: object): Promise<KubbUserConfig['plugins']> {\n const importedPlugin: any = process.env.NODE_ENV === 'test' ? await import(name) : await importModule(name, process.cwd())\n\n // eslint-disable-next-line\n return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options)\n}\n\nexport function getPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[] | KubbObjectPlugin[]): Promise<KubbUserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n const promises = Object.keys(plugins).map((name) => {\n return importPlugin(name, plugins[name as keyof typeof plugins])\n })\n return Promise.all(promises)\n }\n\n if (isJSONPlugins(plugins)) {\n const promises = plugins.map((plugin) => {\n const [name, options = {}] = plugin\n return importPlugin(name, options)\n })\n return Promise.all(promises)\n }\n\n return Promise.resolve(plugins)\n}\n","import pc from 'picocolors'\n\nimport { spinner } from '../program'\n\nexport async function startWatcher(path: string[], cb: (path: string[]) => 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(pc.yellow(pc.bold(`Change detected: ${type} ${file}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n } catch (e) {\n spinner.warn(pc.red('Watcher failed'))\n }\n })\n\n return\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { importModule } from '@kubb/core'\n\nimport { cosmiconfig } from 'cosmiconfig'\nimport tsNode from 'ts-node'\nimport yaml from 'yaml'\n\nimport type { CosmiconfigResult } from '../types.ts'\n\nconst jsLoader = async (configFile: string) => {\n return importModule(configFile)\n}\n// TODO fix tsLoader for node 20 when using ESM only\n// https://github.com/TypeStrong/ts-node/issues/1997\nconst tsLoader = (configFile: string) => {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n let registerer = { enabled() {} }\n\n try {\n // Register TypeScript compiler instance\n registerer = tsNode.register({\n compilerOptions: { module: 'commonjs' },\n swc: true,\n typeCheck: false,\n })\n\n const module = require(configFile)\n\n return module.default\n } catch (err: any) {\n if (err.code === 'MODULE_NOT_FOUND') {\n throw new Error(`'ts-node' is required for the TypeScript configuration files. Make sure it is installed\\nError: ${err.message}`)\n }\n\n throw err\n } finally {\n registerer.enabled()\n }\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string) {\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n 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.cjs`,\n `.${moduleName}rc.mjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.cjs`,\n `${moduleName}.config.mjs`,\n ],\n loaders: {\n '.yaml': (filepath, content) => yaml.parse(content),\n '.yml': (filepath, content) => yaml.parse(content),\n '.js': jsLoader,\n '.cjs': jsLoader,\n '.mjs': jsLoader,\n '.ts': tsLoader,\n noExt: jsLoader,\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 { ParallelPluginError } from '@kubb/core'\nimport PrettyError from 'pretty-error'\n\nexport const prettyError = new PrettyError()\n .skipPackage('commander')\n .skip(function (traceLine, lineNumber) {\n // exclude renderErrors.ts\n const pattern = new RegExp('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[]): string[] {\n return errors\n .reduce((prev, error) => {\n const causedError = error?.cause as Error\n if (causedError) {\n prev = [...prev, ...getErrorCauses([causedError])]\n }\n prev = [...prev, prettyError.render(error)]\n\n return prev\n }, [] as string[])\n .filter(Boolean)\n}\n\nexport function renderErrors(error: Error | undefined, { prefixText, debug = false }: { prefixText?: string; debug?: boolean }): string {\n if (!error) {\n return ''\n }\n\n if (error instanceof ParallelPluginError) {\n return [prefixText, ...error.errors.map((e) => renderErrors(e, { debug }))].filter(Boolean).join('\\n')\n }\n\n if (debug) {\n const errors = getErrorCauses([error])\n\n return [prefixText, ...errors].filter(Boolean).join('\\n')\n }\n\n // skip when no debug is set\n prettyError.skipNodeFiles()\n prettyError.skip(function () {\n return true\n } as PrettyError.Callback)\n\n return [prefixText, prettyError.render(error.message)].filter(Boolean).join('\\n')\n}\n","import type { Command } from 'commander'\n\nimport { program } from './program.ts'\n\nexport default function runCLI(argv?: readonly string[]): Command {\n return program.parse(argv)\n}\n"]}
1
+ {"version":3,"sources":["../src/program.ts","../package.json","../src/init.ts","../src/run.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/parseText.ts","../src/utils/OraWritable.ts","../src/utils/getConfig.ts","../src/utils/getPlugins.ts","../src/utils/watcher.ts","../src/utils/getCosmiConfig.ts","../src/utils/renderErrors.ts","../src/index.ts"],"names":["pathParser","pc","LogLevel","canLogHierarchy","spinner","importModule","moduleName","ParallelPluginError","SummaryError","write","config"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,iBAAgB;AAEvB,SAAS,SAAS,gBAAgB,cAAc;AAChD,OAAO,SAAS;AAChB,OAAOC,SAAQ;;;ACFb,cAAW;;;ACFb,OAAO,gBAAgB;AAEvB,SAAS,UAAU,0BAA0B,OAAO,uBAAuB;AAE3E,SAAS,SAAS;AAClB,OAAO,QAAQ;AA6Bf,IAAM,UAAsC;AAAA,EAC1C,QAAQ;AAAA,IACN,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAsBf,UAAU,CAAC,cAAc,aAAa,iBAAiB,oBAAoB,8BAA8B;AAAA,EAC3G;AACF;AAEA,eAAsB,KAAK,EAAE,SAAS,UAAU,WAAW,SAAS,QAAQ,iBAAiB,OAAO,GAAiC;AACnI,UAAQ,MAAM,6BAAsB;AAEpC,QAAM,aAAa,QAAQ,MAAM;AACjC,QAAM,OAAO,WAAW,QAAQ,QAAQ,IAAI,GAAG,kBAAkB;AACjE,QAAM,iBAAiB,mBAAmB,QAAQ,YAAY;AAE9D,UAAQ,MAAM,wCAAiC,GAAG,IAAI,IAAI,GAAG;AAC7D,QAAM,MAAM,WAAW,aAAa,GAA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AAQ,KAAK,CAAC,EAChE,UAAU,IAAI,OAAO,eAAe,oCAAoC,CAAC,EACzE,OAAO,OAAO,YAAwB;AACrC,MAAI;AACF,QAAI,QAAQ,MAAM;AAChB,aAAO,KAAK,EAAE,UAAU,QAAQ,SAAS,CAAC;AAAA,IAC5C;AAGA,YAAQ,MAAM,0BAAmB;AACjC,UAAM,SAAS,MAAM,eAAe,YAAY,QAAQ,MAAM;AAC9D,YAAQ,QAAQ,2BAAoBA,IAAG,IAAID,YAAW,SAAS,QAAQ,IAAI,GAAG,OAAO,QAAQ,CAAC,IAAI;AAGlG,QAAI,QAAQ,OAAO;AACjB,YAAMU,UAAS,MAAM,UAAU,QAAQ,OAAO;AAE9C,aAAO,aAAa,CAACA,QAAO,MAAM,IAAI,GAAG,OAAO,UAAU;AACxD,cAAM,IAAI,EAAE,QAAAA,SAAQ,YAAY,QAAQ,CAAC;AACzC,gBAAQ,UAAU;AAClB,gBAAQ,MAAMT,IAAG,OAAOA,IAAG,KAAK,2BAA2B,MAAM,KAAK,OAAO,GAAG,CAAC,CAAC;AAAA,MACpF,CAAC;AAAA,IACH;AAEA,UAAM,SAAS,MAAM,UAAU,QAAQ,OAAO;AAE9C,UAAM,IAAI,EAAE,QAAQ,YAAY,QAAQ,CAAC;AAAA,EAC3C,SAAS,GAAP;AACA,mBAAe,GAAG,OAAO;AAAA,EAC3B;AACF,CAAC;;;AYpGY,SAAR,OAAwB,MAAmC;AAChE,SAAO,QAAQ,MAAM,IAAI;AAC3B","sourcesContent":["import pathParser from 'node:path'\n\nimport { Command, CommanderError, Option } from 'commander'\nimport ora from 'ora'\nimport pc from 'picocolors'\n\nimport { version } from '../package.json'\nimport { init } from './init.ts'\nimport { run } from './run.ts'\nimport { getConfig, getCosmiConfig, renderErrors, startWatcher } from './utils/index.ts'\n\nimport { LogLevel, SummaryError, canLogHierarchy } from '@kubb/core'\nimport type { CLIOptions } from '@kubb/core'\nimport { Warning } from '@kubb/core'\n\nconst moduleName = 'kubb'\n\nexport const spinner = ora({\n spinner: 'clock',\n})\n\nfunction programCatcher(e: unknown, CLIOptions: CLIOptions): void {\n const originalError = e as Error\n let error = originalError\n\n // summaryError check\n const summaryError = error instanceof SummaryError ? error : undefined\n\n if (summaryError) {\n // use the real error from summaryError and use the case of SummaryError to display a summary of plugins that failed\n error = summaryError.cause as Error\n }\n\n const message = renderErrors(error, { logLevel: CLIOptions.logLevel, prefixText: pc.red(originalError?.message) })\n\n if (error instanceof Warning) {\n spinner.warn(pc.yellow(error.message))\n process.exit(0)\n }\n\n if (canLogHierarchy(CLIOptions.logLevel, LogLevel.silent)) {\n spinner.fail(message)\n process.exit(1)\n }\n\n spinner.fail([message, ...(summaryError?.summary || [])].join('\\n'))\n process.exit(1)\n}\n\nexport const program = new Command(moduleName)\n .name(moduleName)\n .description('Kubb')\n .version(version, '-v')\n .exitOverride((err) => {\n if (err instanceof CommanderError) {\n process.exit(1)\n }\n })\n .configureOutput({\n outputError: (message, write) => {\n const CLIOptions: CLIOptions = program.opts()\n\n write(\n renderErrors(new Error(message, { cause: undefined }), {\n logLevel: CLIOptions.logLevel,\n prefixText: pc.red('Something went wrong with processing the CLI\\n'),\n }) + '\\n'\n )\n },\n })\n .addOption(new Option('-c, --config <path>', 'Path to the Kubb config'))\n .addOption(new Option('-i, --input <path>', 'Path of the input file(overrides the one in `kubb.config.js`)'))\n .addOption(new Option('-l, --logLevel <type>', 'Type of the logging(overrides the one in `kubb.config.js`)').choices(['info', 'silent', 'stacktrace']))\n .addOption(new Option('--init', 'Init Kubb'))\n .addOption(new Option('-d, --debug', 'Debug mode').default(false))\n .addOption(new Option('-w, --watch', 'Watch mode based on the input file'))\n .action(async (options: CLIOptions) => {\n try {\n if (options.init) {\n return init({ logLevel: options.logLevel })\n }\n\n // CONFIG\n spinner.start('💾 Loading config')\n const result = await getCosmiConfig(moduleName, options.config)\n spinner.succeed(`💾 Config loaded(${pc.dim(pathParser.relative(process.cwd(), result.filepath))})`)\n // END CONFIG\n\n if (options.watch) {\n const config = await getConfig(result, options)\n\n return startWatcher([config.input.path], async (paths) => {\n await run({ config, CLIOptions: options })\n spinner.spinner = 'simpleDotsScrolling'\n spinner.start(pc.yellow(pc.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n\n const config = await getConfig(result, options)\n\n await run({ config, CLIOptions: options })\n } catch (e) {\n programCatcher(e, options)\n }\n })\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"1.2.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.js\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"kubb\": \"bin/kubb.js\"\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf ./dist\",\n \"lint\": \"eslint --format pretty ./src\",\n \"lint-fix\": \"bun run lint --quiet --fix\",\n \"release\": \"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 \"@swc/core\": \"^1.3.64\",\n \"chokidar\": \"^3.5.3\",\n \"commander\": \"^10.0.1\",\n \"cosmiconfig\": \"^8.2.0\",\n \"execa\": \"^7.1.1\",\n \"ora\": \"^6.3.1\",\n \"picocolors\": \"^1.0.0\",\n \"pretty-error\": \"^4.0.0\",\n \"string-argv\": \"^0.3.2\",\n \"ts-node\": \"^10.9.1\",\n \"yaml\": \"^2.3.1\"\n },\n \"devDependencies\": {\n \"@kubb/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.3.1\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.1.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 pathParser from 'node:path'\n\nimport { LogLevel, isPromiseFulfilledResult, write, canLogHierarchy } from '@kubb/core'\n\nimport { $ } from 'execa'\nimport pc from 'picocolors'\n\nimport type { LogLevels } from '@kubb/core'\nimport { spinner } from './program.ts'\n\nexport type Preset = 'simple'\n\nexport type PackageManager = 'pnpm' | 'npm' | 'yarn'\n\nexport type PresetMeta = {\n 'kubb.config': string\n packages: string[]\n}\n\ntype RunProps = {\n /**\n * @default `'silent'`\n */\n logLevel?: LogLevels\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 createSwagger from '@kubb/swagger'\nimport createSwaggerTS from '@kubb/swagger-ts'\nimport 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 logLevel: 'info',\n plugins: [createSwagger({}), createSwaggerTS({ output: 'models', enumType: 'enum' }), createSwaggerTanstackQuery({ output: './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' }: RunProps): Promise<undefined> {\n spinner.start('📦 Initializing Kubb')\n\n const presetMeta = presets[preset]\n const path = pathParser.resolve(process.cwd(), './kubb.config.js')\n const installCommand = packageManager === 'npm' ? 'install' : 'add'\n\n spinner.start(`📀 Writing \\`kubb.config.js\\` ${pc.dim(path)}`)\n await write(presetMeta['kubb.config'], path)\n spinner.succeed(`📀 Wrote \\`kubb.config.js\\` ${pc.dim(path)}`)\n\n const results = await Promise.allSettled([\n $`npm init es6 -y`,\n ...presetMeta.packages.map(async (pack) => {\n spinner.start(`📀 Installing ${pc.dim(pack)}`)\n const { stdout } = await $({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`\n spinner.succeed(`📀 Installed ${pc.dim(pack)}`)\n\n return stdout\n }),\n ])\n\n if (canLogHierarchy(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 pathParser from 'node:path'\n\nimport { build, ParallelPluginError, PluginError, SummaryError, timeout, createLogger, randomPicoColour, LogLevel, canLogHierarchy } from '@kubb/core'\n\nimport type { ExecaReturnValue } from 'execa'\n\nimport { performance, PerformanceObserver } from 'node:perf_hooks'\nimport { execa } from 'execa'\nimport pc from 'picocolors'\n\nimport { parseArgsStringToArgv } from 'string-argv'\n\nimport { parseHrtimeToSeconds } from './utils/parseHrtimeToSeconds.ts'\nimport { parseText } from './utils/parseText.ts'\n\nimport type { BuildOutput, CLIOptions, KubbConfig, LogLevels } from '@kubb/core'\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { spinner } from './program.ts'\n\ntype RunProps = {\n config: KubbConfig\n CLIOptions: CLIOptions\n}\n\ntype ExecutingHooksProps = {\n hooks: KubbConfig['hooks']\n logLevel: LogLevels\n debug?: boolean\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 (canLogHierarchy(logLevel, LogLevel.silent)) {\n spinner.start(`Executing hooks`)\n }\n type Executer = { subProcess: ExecaReturnValue<string>; abort: AbortController['abort'] }\n\n const executers: Promise<Executer>[] = commands.map(async (command) => {\n const oraWritable = new OraWritable(spinner, command)\n const abortController = new AbortController()\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n spinner.start(parseText(`Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout!(oraWritable)\n spinner.suffixText = ''\n\n if (canLogHierarchy(logLevel, LogLevel.info)) {\n spinner.succeed(parseText(`Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n console.log(subProcess.stdout)\n }\n\n // wait for 100ms to be sure that all open files are close(fs)\n await timeout(100)\n\n oraWritable.destroy()\n return { subProcess, abort: abortController.abort.bind(abortController) }\n })\n\n await Promise.all(executers)\n\n if (canLogHierarchy(logLevel, LogLevel.silent)) {\n spinner.succeed(`Executing hooks`)\n }\n}\n\ntype SummaryProps = {\n pluginManager: BuildOutput['pluginManager']\n status: 'success' | 'failed'\n hrstart: [number, number]\n config: KubbConfig\n logLevel?: LogLevels\n}\n\nfunction getSummary({ pluginManager, status, hrstart, config, logLevel }: SummaryProps): string[] {\n const logs: string[] = []\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))\n\n const buildStartPlugins = [\n ...new Set(pluginManager.executed.filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core').map((item) => item.plugin.name)),\n ]\n\n const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.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?.pluginName || !b.meta?.pluginName) {\n return 0\n }\n if (a.meta?.pluginName.length < b.meta?.pluginName.length) {\n return 1\n }\n if (a.meta?.pluginName.length > b.meta?.pluginName.length) {\n return -1\n }\n return 0\n })\n\n const meta = {\n plugins:\n status === 'success'\n ? `${pc.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`\n : `${pc.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? failedPlugins?.map((name) => randomPicoColour(name))?.join(', ') : undefined,\n filesCreated: files.length,\n time: pc.yellow(`${elapsedSeconds}s`),\n output: pathParser.resolve(config.root, config.output.path),\n } as const\n\n if (canLogHierarchy(logLevel, 'stacktrace')) {\n logs.push(pc.bold('Generated files:\\n'))\n logs.push(files.map((file) => `${randomPicoColour(file.meta?.pluginName)} ${file.path}`).join('\\n'))\n }\n\n logs.push(\n [\n [`\\n`, true],\n [` ${pc.bold('Plugins:')} ${meta.plugins}`, true],\n [` ${pc.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${pc.bold('Generated:')} ${meta.filesCreated} files`, true],\n [` ${pc.bold('Time:')} ${meta.time}`, true],\n [` ${pc.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\nexport async function run({ config, CLIOptions }: RunProps): Promise<void> {\n const hrstart = process.hrtime()\n const logger = createLogger(spinner)\n\n const performanceOpserver = new PerformanceObserver((items) => {\n const message = `${items.getEntries()[0].duration.toFixed(0)}ms`\n\n spinner.suffixText = pc.yellow(message)\n\n performance.clearMarks()\n })\n\n if (CLIOptions.debug) {\n performanceOpserver.observe({ type: 'measure' })\n }\n\n try {\n const { root: _root, ...userConfig } = config\n const logLevel = CLIOptions.logLevel ?? userConfig.logLevel ?? LogLevel.silent\n const inputPath = CLIOptions.input ?? userConfig.input.path\n\n spinner.start(parseText(`🚀 Building`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n const output = await build({\n config: {\n root: process.cwd(),\n ...userConfig,\n logLevel,\n input: {\n ...userConfig.input,\n path: inputPath,\n },\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n debug: CLIOptions.debug,\n })\n\n spinner.suffixText = ''\n spinner.succeed(parseText(`🚀 Build completed`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n await timeout(100)\n await executeHooks({ hooks: config.hooks, logLevel, debug: CLIOptions.debug })\n\n const summary = getSummary({ pluginManager: output.pluginManager, config, status: 'success', hrstart, logLevel: CLIOptions.logLevel })\n console.log(summary.join(''))\n } catch (error: any) {\n let summary: string[] = []\n\n if (error instanceof PluginError || error instanceof ParallelPluginError) {\n summary = getSummary({ pluginManager: error.pluginManager, config, status: 'failed', hrstart, logLevel: CLIOptions.logLevel })\n }\n\n throw new SummaryError('Something went wrong\\n', { cause: error, summary })\n }\n}\n","export function parseHrtimeToSeconds(hrtime: [number, number]) {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","import { LogLevel } from '@kubb/core'\nimport type { LogLevels } from '@kubb/core'\n\nexport function parseText(baseText: string, config: Partial<Record<LogLevels, string>>, logLevel: LogLevels = LogLevel.silent) {\n return `${baseText}${config[logLevel] || ''}`\n}\n","import type { WritableOptions } from 'node:stream'\nimport { Writable } from 'node:stream'\nimport type { Ora } from 'ora'\nimport pc from 'picocolors'\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: NodeJS.BufferEncoding, callback: (error?: Error | null) => void) {\n this.spinner.suffixText = `\\n\\n${pc.bold(pc.blue(this.command))}: ${chunk?.toString()}`\n\n callback()\n }\n}\n","import { isPromise } from '@kubb/core'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { CLIOptions, KubbConfig, KubbUserConfig } from '@kubb/core'\nimport type { CosmiconfigResult } from '../types.ts'\n\nexport async function getConfig(result: CosmiconfigResult, CLIOptions: CLIOptions): Promise<KubbConfig> {\n const config = result?.config\n let kubbUserConfig: Promise<KubbUserConfig> = Promise.resolve(config) as Promise<KubbUserConfig>\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 JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as KubbConfig\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n\nimport { importModule } from '@kubb/core'\n\nimport type { KubbJSONPlugins, KubbObjectPlugin, KubbUserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbJSONPlugins[] {\n return !!(plugins as KubbJSONPlugins[])?.some((plugin) => {\n return typeof plugin?.[0] === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbObjectPlugin {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nasync function importPlugin(name: string, options: object): Promise<KubbUserConfig['plugins']> {\n const importedPlugin: any = process.env.NODE_ENV === 'test' ? await import(name) : await importModule(name, process.cwd())\n\n // eslint-disable-next-line\n return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options)\n}\n\nexport function getPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[] | KubbObjectPlugin[]): Promise<KubbUserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n const promises = Object.keys(plugins).map((name) => {\n return importPlugin(name, plugins[name as keyof typeof plugins])\n })\n return Promise.all(promises)\n }\n\n if (isJSONPlugins(plugins)) {\n const promises = plugins.map((plugin) => {\n const [name, options = {}] = plugin\n return importPlugin(name, options)\n })\n return Promise.all(promises)\n }\n\n return Promise.resolve(plugins)\n}\n","import pc from 'picocolors'\n\nimport { spinner } from '../program'\n\nexport async function startWatcher(path: string[], cb: (path: string[]) => 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(pc.yellow(pc.bold(`Change detected: ${type} ${file}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n } catch (e) {\n spinner.warn(pc.red('Watcher failed'))\n }\n })\n\n return\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { importModule } from '@kubb/core'\n\nimport { cosmiconfig } from 'cosmiconfig'\nimport tsNode from 'ts-node'\nimport yaml from 'yaml'\n\nimport type { CosmiconfigResult } from '../types.ts'\n\nconst jsLoader = async (configFile: string) => {\n return importModule(configFile)\n}\n// TODO fix tsLoader for node 20 when using ESM only\n// https://github.com/TypeStrong/ts-node/issues/1997\nconst tsLoader = (configFile: string) => {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n let registerer = { enabled() {} }\n\n try {\n // Register TypeScript compiler instance\n registerer = tsNode.register({\n compilerOptions: { module: 'commonjs' },\n swc: true,\n typeCheck: false,\n })\n\n const module = require(configFile)\n\n return module.default\n } catch (err: any) {\n if (err.code === 'MODULE_NOT_FOUND') {\n throw new Error(`'ts-node' is required for the TypeScript configuration files. Make sure it is installed\\nError: ${err.message}`)\n }\n\n throw err\n } finally {\n registerer.enabled()\n }\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string) {\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n 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.cjs`,\n `.${moduleName}rc.mjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.cjs`,\n `${moduleName}.config.mjs`,\n ],\n loaders: {\n '.yaml': (filepath, content) => yaml.parse(content),\n '.yml': (filepath, content) => yaml.parse(content),\n '.js': jsLoader,\n '.cjs': jsLoader,\n '.mjs': jsLoader,\n '.ts': tsLoader,\n noExt: jsLoader,\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 type { LogLevels } from '@kubb/core'\nimport { LogLevel, ParallelPluginError, canLogHierarchy } from '@kubb/core'\nimport PrettyError from 'pretty-error'\n\nexport const prettyError = new PrettyError()\n .skipPackage('commander')\n .skip(function (traceLine, lineNumber) {\n // exclude renderErrors.ts\n const pattern = new RegExp('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[]): string[] {\n return errors\n .reduce((prev, error) => {\n const causedError = error?.cause as Error\n if (causedError) {\n prev = [...prev, ...getErrorCauses([causedError])]\n }\n prev = [...prev, prettyError.render(error)]\n\n return prev\n }, [] as string[])\n .filter(Boolean)\n}\n\nexport function renderErrors(error: Error | undefined, { prefixText, logLevel = LogLevel.silent }: { prefixText?: string; logLevel?: LogLevels }): string {\n if (!error) {\n return ''\n }\n\n if (error instanceof ParallelPluginError) {\n return [prefixText, ...error.errors.map((e) => renderErrors(e, { logLevel }))].filter(Boolean).join('\\n')\n }\n\n if (canLogHierarchy(logLevel, 'stacktrace')) {\n const errors = getErrorCauses([error])\n\n return [prefixText, ...errors].filter(Boolean).join('\\n')\n }\n\n // skip when no debug is set\n prettyError.skipNodeFiles()\n prettyError.skip(function () {\n return true\n } as PrettyError.Callback)\n\n return [prefixText, prettyError.render(error.message)].filter(Boolean).join('\\n')\n}\n","import type { Command } from 'commander'\n\nimport { program } from './program.ts'\n\nexport default function runCLI(argv?: readonly string[]): Command {\n return program.parse(argv)\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Generator cli",
5
5
  "keywords": [
6
6
  "typescript",
@@ -42,14 +42,14 @@
42
42
  "string-argv": "^0.3.2",
43
43
  "ts-node": "^10.9.1",
44
44
  "yaml": "^2.3.1",
45
- "@kubb/core": "1.2.0"
45
+ "@kubb/core": "1.2.1"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^20.3.1",
49
49
  "source-map-support": "^0.5.21",
50
50
  "tsup": "^6.7.0",
51
51
  "typescript": "^5.1.3",
52
- "@kubb/swagger": "1.2.0",
52
+ "@kubb/swagger": "1.2.1",
53
53
  "@kubb/ts-config": "0.1.0",
54
54
  "@kubb/tsup-config": "1.1.8"
55
55
  },