@kubb/cli 2.12.1 → 2.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/bkubb.cjs ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import('../dist/index.js').then(({ run }) => {
4
+ process.title = 'Kubb'
5
+ run(process.argv)
6
+ })
package/bin/kubb.cjs CHANGED
@@ -1,8 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  try {
3
+ const cachedSourceMaps = new Map()
4
+
3
5
  require('source-map-support').install({
4
- environment: 'node',
5
- handleUncaughtExceptions: false,
6
+ retrieveSourceMap(source) {
7
+ if (cachedSourceMaps.has(source)) {
8
+ return cachedSourceMaps.get(source)
9
+ }
10
+ return null
11
+ },
6
12
  })
7
13
  } catch (err) {}
8
14
 
package/dist/index.cjs CHANGED
@@ -2607,11 +2607,10 @@ var _tty = require('tty'); var _tty2 = _interopRequireDefault(_tty);
2607
2607
  var p2 = w(_tty.isatty.call(void 0, 1));
2608
2608
 
2609
2609
  // package.json
2610
- var version = "2.12.1";
2610
+ var version = "2.12.3";
2611
2611
 
2612
2612
  // src/generate.ts
2613
2613
  init_cjs_shims();
2614
-
2615
2614
  var _logger = require('@kubb/core/logger');
2616
2615
 
2617
2616
  // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.js
@@ -4251,6 +4250,7 @@ function create$(options) {
4251
4250
  var $ = create$();
4252
4251
 
4253
4252
  // src/generate.ts
4253
+ var _jsruntime = require('js-runtime');
4254
4254
  var _stringargv = require('string-argv');
4255
4255
 
4256
4256
  // src/utils/OraWritable.ts
@@ -4270,74 +4270,6 @@ ${p2.bold(p2.blue(this.command))}: ${_optionalChain([chunk, 'optionalAccess', _6
4270
4270
  }
4271
4271
  };
4272
4272
 
4273
- // src/utils/getSummary.ts
4274
- init_cjs_shims();
4275
-
4276
-
4277
-
4278
- // src/utils/parseHrtimeToSeconds.ts
4279
- init_cjs_shims();
4280
- function parseHrtimeToSeconds(hrtime) {
4281
- const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
4282
- return seconds;
4283
- }
4284
-
4285
- // src/utils/getSummary.ts
4286
- function getSummary({ pluginManager, status, hrstart, config, logger }) {
4287
- const { logLevel } = logger;
4288
- const logs = [];
4289
- const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart));
4290
- const buildStartPlugins = pluginManager.executed.filter((item) => item.hookName === "buildStart" && item.plugin.name !== "core").map((item) => item.plugin.name);
4291
- const buildEndPlugins = pluginManager.executed.filter((item) => item.hookName === "buildEnd" && item.plugin.name !== "core").map((item) => item.plugin.name);
4292
- const failedPlugins = _optionalChain([config, 'access', _8 => _8.plugins, 'optionalAccess', _9 => _9.filter, 'call', _10 => _10((plugin) => !buildEndPlugins.includes(plugin.name)), 'optionalAccess', _11 => _11.map, 'call', _12 => _12((plugin) => plugin.name)]);
4293
- const pluginsCount = _optionalChain([config, 'access', _13 => _13.plugins, 'optionalAccess', _14 => _14.length]) || 0;
4294
- const files = pluginManager.fileManager.files.sort((a, b2) => {
4295
- if (!_optionalChain([a, 'access', _15 => _15.meta, 'optionalAccess', _16 => _16.pluginKey, 'optionalAccess', _17 => _17[0]]) || !_optionalChain([b2, 'access', _18 => _18.meta, 'optionalAccess', _19 => _19.pluginKey, 'optionalAccess', _20 => _20[0]])) {
4296
- return 0;
4297
- }
4298
- if (_optionalChain([a, 'access', _21 => _21.meta, 'optionalAccess', _22 => _22.pluginKey, 'optionalAccess', _23 => _23[0], 'optionalAccess', _24 => _24.length]) < _optionalChain([b2, 'access', _25 => _25.meta, 'optionalAccess', _26 => _26.pluginKey, 'optionalAccess', _27 => _27[0], 'optionalAccess', _28 => _28.length])) {
4299
- return 1;
4300
- }
4301
- if (_optionalChain([a, 'access', _29 => _29.meta, 'optionalAccess', _30 => _30.pluginKey, 'optionalAccess', _31 => _31[0], 'optionalAccess', _32 => _32.length]) > _optionalChain([b2, 'access', _33 => _33.meta, 'optionalAccess', _34 => _34.pluginKey, 'optionalAccess', _35 => _35[0], 'optionalAccess', _36 => _36.length])) {
4302
- return -1;
4303
- }
4304
- return 0;
4305
- });
4306
- const meta = {
4307
- name: config.name,
4308
- plugins: status === "success" ? `${p2.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${p2.red(`${_nullishCoalesce(_optionalChain([failedPlugins, 'optionalAccess', _37 => _37.length]), () => ( 1))} failed`)}, ${pluginsCount} total`,
4309
- pluginsFailed: status === "failed" ? _optionalChain([failedPlugins, 'optionalAccess', _38 => _38.map, 'call', _39 => _39((name) => _logger.randomCliColour.call(void 0, name)), 'optionalAccess', _40 => _40.join, 'call', _41 => _41(", ")]) : void 0,
4310
- filesCreated: files.length,
4311
- time: p2.yellow(`${elapsedSeconds}s`),
4312
- output: _path2.default.isAbsolute(config.root) ? _path2.default.resolve(config.root, config.output.path) : config.root
4313
- };
4314
- if (logLevel === _logger.LogLevel.debug) {
4315
- logger.emit("debug", ["\nGenerated files:\n"]);
4316
- logger.emit(
4317
- "debug",
4318
- files.map((file) => `${_logger.randomCliColour.call(void 0, JSON.stringify(_optionalChain([file, 'access', _42 => _42.meta, 'optionalAccess', _43 => _43.pluginKey])))} ${file.path}`)
4319
- );
4320
- }
4321
- logs.push(
4322
- [
4323
- ["\n", true],
4324
- [` ${p2.bold("Name:")} ${meta.name}`, !!meta.name],
4325
- [` ${p2.bold("Plugins:")} ${meta.plugins}`, true],
4326
- [` ${p2.dim("Failed:")} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
4327
- [`${p2.bold("Generated:")} ${meta.filesCreated} files`, true],
4328
- [` ${p2.bold("Time:")} ${meta.time}`, true],
4329
- [` ${p2.bold("Output:")} ${meta.output}`, true],
4330
- ["\n", true]
4331
- ].map((item) => {
4332
- if (item.at(1)) {
4333
- return item.at(0);
4334
- }
4335
- return void 0;
4336
- }).filter(Boolean).join("\n")
4337
- );
4338
- return logs;
4339
- }
4340
-
4341
4273
  // src/utils/spinner.ts
4342
4274
  init_cjs_shims();
4343
4275
 
@@ -5400,6 +5332,75 @@ var spinner = ora({
5400
5332
  spinner: "clock"
5401
5333
  });
5402
5334
 
5335
+ // src/generate.ts
5336
+
5337
+
5338
+ // src/utils/getSummary.ts
5339
+ init_cjs_shims();
5340
+
5341
+
5342
+
5343
+ // src/utils/parseHrtimeToSeconds.ts
5344
+ init_cjs_shims();
5345
+ function parseHrtimeToSeconds(hrtime) {
5346
+ const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
5347
+ return seconds;
5348
+ }
5349
+
5350
+ // src/utils/getSummary.ts
5351
+ function getSummary({ pluginManager, status, hrstart, config, logger }) {
5352
+ const { logLevel } = logger;
5353
+ const logs = [];
5354
+ const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart));
5355
+ const buildStartPlugins = pluginManager.executed.filter((item) => item.hookName === "buildStart" && item.plugin.name !== "core").map((item) => item.plugin.name);
5356
+ const buildEndPlugins = pluginManager.executed.filter((item) => item.hookName === "buildEnd" && item.plugin.name !== "core").map((item) => item.plugin.name);
5357
+ const failedPlugins = _optionalChain([config, 'access', _8 => _8.plugins, 'optionalAccess', _9 => _9.filter, 'call', _10 => _10((plugin) => !buildEndPlugins.includes(plugin.name)), 'optionalAccess', _11 => _11.map, 'call', _12 => _12((plugin) => plugin.name)]);
5358
+ const pluginsCount = _optionalChain([config, 'access', _13 => _13.plugins, 'optionalAccess', _14 => _14.length]) || 0;
5359
+ const files = pluginManager.fileManager.files.sort((a, b2) => {
5360
+ if (!_optionalChain([a, 'access', _15 => _15.meta, 'optionalAccess', _16 => _16.pluginKey, 'optionalAccess', _17 => _17[0]]) || !_optionalChain([b2, 'access', _18 => _18.meta, 'optionalAccess', _19 => _19.pluginKey, 'optionalAccess', _20 => _20[0]])) {
5361
+ return 0;
5362
+ }
5363
+ if (_optionalChain([a, 'access', _21 => _21.meta, 'optionalAccess', _22 => _22.pluginKey, 'optionalAccess', _23 => _23[0], 'optionalAccess', _24 => _24.length]) < _optionalChain([b2, 'access', _25 => _25.meta, 'optionalAccess', _26 => _26.pluginKey, 'optionalAccess', _27 => _27[0], 'optionalAccess', _28 => _28.length])) {
5364
+ return 1;
5365
+ }
5366
+ if (_optionalChain([a, 'access', _29 => _29.meta, 'optionalAccess', _30 => _30.pluginKey, 'optionalAccess', _31 => _31[0], 'optionalAccess', _32 => _32.length]) > _optionalChain([b2, 'access', _33 => _33.meta, 'optionalAccess', _34 => _34.pluginKey, 'optionalAccess', _35 => _35[0], 'optionalAccess', _36 => _36.length])) {
5367
+ return -1;
5368
+ }
5369
+ return 0;
5370
+ });
5371
+ const meta = {
5372
+ name: config.name,
5373
+ plugins: status === "success" ? `${p2.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${p2.red(`${_nullishCoalesce(_optionalChain([failedPlugins, 'optionalAccess', _37 => _37.length]), () => ( 1))} failed`)}, ${pluginsCount} total`,
5374
+ pluginsFailed: status === "failed" ? _optionalChain([failedPlugins, 'optionalAccess', _38 => _38.map, 'call', _39 => _39((name) => _logger.randomCliColour.call(void 0, name)), 'optionalAccess', _40 => _40.join, 'call', _41 => _41(", ")]) : void 0,
5375
+ filesCreated: files.length,
5376
+ time: p2.yellow(`${elapsedSeconds}s`),
5377
+ output: _path2.default.isAbsolute(config.root) ? _path2.default.resolve(config.root, config.output.path) : config.root
5378
+ };
5379
+ logger.emit("debug", ["\nGenerated files:\n"]);
5380
+ logger.emit(
5381
+ "debug",
5382
+ files.map((file) => `${_logger.randomCliColour.call(void 0, JSON.stringify(_optionalChain([file, 'access', _42 => _42.meta, 'optionalAccess', _43 => _43.pluginKey])))} ${file.path}`)
5383
+ );
5384
+ logs.push(
5385
+ [
5386
+ ["\n", true],
5387
+ [` ${p2.bold("Name:")} ${meta.name}`, !!meta.name],
5388
+ [` ${p2.bold("Plugins:")} ${meta.plugins}`, true],
5389
+ [` ${p2.dim("Failed:")} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
5390
+ [`${p2.bold("Generated:")} ${meta.filesCreated} files`, true],
5391
+ [` ${p2.bold("Time:")} ${meta.time}`, true],
5392
+ [` ${p2.bold("Output:")} ${meta.output}`, true],
5393
+ ["\n", true]
5394
+ ].map((item) => {
5395
+ if (item.at(1)) {
5396
+ return item.at(0);
5397
+ }
5398
+ return void 0;
5399
+ }).filter(Boolean).join("\n")
5400
+ );
5401
+ return logs;
5402
+ }
5403
+
5403
5404
  // src/generate.ts
5404
5405
  async function executeHooks({ hooks, logLevel }) {
5405
5406
  if (!_optionalChain([hooks, 'optionalAccess', _44 => _44.done])) {
@@ -5458,7 +5459,7 @@ async function generate({ input, config, CLIOptions }) {
5458
5459
  const { root: _root, ...userConfig } = config;
5459
5460
  const logLevel = logger.logLevel;
5460
5461
  const inputPath = _nullishCoalesce(input, () => ( ("path" in userConfig.input ? userConfig.input.path : void 0)));
5461
- spinner.start(`\u{1F680} Building ${logLevel !== "silent" ? p2.dim(inputPath) : ""}`);
5462
+ spinner.start(`\u{1F680} Building with ${_jsruntime.get.call(void 0, )} ${logLevel !== "silent" ? p2.dim(inputPath) : ""}`);
5462
5463
  const definedConfig = {
5463
5464
  root: process.cwd(),
5464
5465
  ...userConfig,
@@ -5490,7 +5491,7 @@ async function generate({ input, config, CLIOptions }) {
5490
5491
  }
5491
5492
  await executeHooks({ hooks: config.hooks, logLevel });
5492
5493
  spinner.suffixText = "";
5493
- spinner.succeed(`\u{1F680} Build completed ${logLevel !== "silent" ? p2.dim(inputPath) : ""}`);
5494
+ spinner.succeed(`\u{1F680} Build completed with ${_jsruntime.get.call(void 0, )} ${logLevel !== "silent" ? p2.dim(inputPath) : ""}`);
5494
5495
  console.log(summary.join(""));
5495
5496
  }
5496
5497
 
@@ -5745,6 +5746,11 @@ function programCatcher(e, CLIOptions) {
5745
5746
  process.exit(1);
5746
5747
  }
5747
5748
  async function generateAction(input, CLIOptions) {
5749
+ if (CLIOptions.bun) {
5750
+ const command = process.argv.splice(2).filter((item) => item !== "--bun");
5751
+ await execa("bkubb", command, { stdout: process.stdout, stderr: process.stderr });
5752
+ return;
5753
+ }
5748
5754
  spinner.start("\u{1F50D} Loading config");
5749
5755
  const result = await getCosmiConfig(moduleName, CLIOptions.config);
5750
5756
  spinner.succeed(`\u{1F50D} Config loaded(${p2.dim(_path2.default.relative(process.cwd(), result.filepath))})`);
@@ -5771,8 +5777,8 @@ async function generateAction(input, CLIOptions) {
5771
5777
  }
5772
5778
  async function run(argv) {
5773
5779
  const program = _cac.cac.call(void 0, moduleName);
5774
- program.command("[input]", "Path of the input file(overrides the one in `kubb.config.js`)").option("-c, --config <path>", "Path to the Kubb config").option("-l, --log-level <type>", "Info, silent or debug").option("-w, --watch", "Watch mode based on the input file").action(generateAction);
5775
- program.command("generate [input]", "Path of the input file(overrides the one in `kubb.config.js`)").option("-c, --config <path>", "Path to the Kubb config").option("-l, --log-level <type>", "Info, silent or debug").option("-w, --watch", "Watch mode based on the input file").action(generateAction);
5780
+ program.command("[input]", "Path of the input file(overrides the one in `kubb.config.js`)").option("-c, --config <path>", "Path to the Kubb config").option("-l, --log-level <type>", "Info, silent or debug").option("-w, --watch", "Watch mode based on the input file").option("-b, --bun", "Run Kubb with Bun").action(generateAction);
5781
+ program.command("generate [input]", "Path of the input file(overrides the one in `kubb.config.js`)").option("-c, --config <path>", "Path to the Kubb config").option("-l, --log-level <type>", "Info, silent or debug").option("-w, --watch", "Watch mode based on the input file").option("-b, --bun", "Run Kubb with Bun").action(generateAction);
5776
5782
  program.command("init", "Init Kubb").action(async () => {
5777
5783
  return init({ logLevel: "info" });
5778
5784
  });