@kubb/core 5.10.1 → 5.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,12 +1,11 @@
1
- import "./rolldown-runtime-CRm0XQPb.js";
2
- import { A as inParallel, C as useOptions, D as Diagnostics, E as resolveMeta, F as toError, M as read, N as toPosixPath, O as formatMs, P as write, S as useKubb, T as defineExtension, _ as setMacros, b as tryUseKubb, c as Resolver, d as definePlugin, f as addGenerator, g as requirePlugin, h as kubbContext, j as isPathInside, k as getElapsedMs, l as getInputKind, m as injectFile, n as KubbDriver, o as _usingCtx, p as addMacro, s as createResolver, t as Hookable, u as assertPluginOption, v as setOptions, w as checkCompatibility, x as useConfig, y as setResolver } from "./Hookable-ZX2OqaPh.js";
1
+ import { A as inParallel, C as useOptions, D as Diagnostics, E as resolveMeta, F as toError, M as read, N as toPosixPath, O as formatMs, P as write, S as useKubb, T as defineExtension, _ as setMacros, b as tryUseKubb, c as Resolver, d as definePlugin, f as addGenerator, g as requirePlugin, h as kubbContext, j as isPathInside, k as getElapsedMs, l as getInputKind, m as injectFile, n as KubbDriver, o as _usingCtx, p as addMacro, s as createResolver, t as Hookable, u as assertPluginOption, v as setOptions, w as checkCompatibility, x as useConfig, y as setResolver } from "./Hookable-BsWZ8pHO.js";
3
2
  import { createRequire } from "node:module";
4
3
  import { isValid } from "verkit";
5
- import { stripVTControlCharacters, styleText } from "node:util";
6
4
  import process$1 from "node:process";
7
5
  import { x } from "tinyexec";
8
6
  import { glob, readFile, rm } from "node:fs/promises";
9
7
  import path, { join, relative, resolve } from "node:path";
8
+ import { stripVTControlCharacters, styleText } from "node:util";
10
9
  import { hash, randomUUID } from "node:crypto";
11
10
  import { chmodSync, existsSync, mkdirSync } from "node:fs";
12
11
  import { homedir, tmpdir } from "node:os";
@@ -632,7 +631,11 @@ var Kubb = class {
632
631
  return this.config.storage;
633
632
  }
634
633
  get driver() {
635
- if (!this.#driver) throw new Error("[kubb] setup() must be called before accessing driver");
634
+ if (!this.#driver) throw new Diagnostics.Error({
635
+ code: Diagnostics.code.internalError,
636
+ severity: "error",
637
+ message: "[kubb] setup() must be called before accessing driver"
638
+ });
636
639
  return this.#driver;
637
640
  }
638
641
  /**
@@ -720,19 +723,23 @@ var Kubb = class {
720
723
  const { hooks, config } = this;
721
724
  const hrStart = process.hrtime();
722
725
  await hooks.callHook("kubb:generation:start", { config });
723
- await hooks.callHook("kubb:setup:start");
724
- await this.setup();
725
- await hooks.callHook("kubb:setup:end");
726
- const { files, diagnostics, storage } = await this.safeBuild();
727
- signal?.throwIfAborted();
728
- for (const diagnostic of diagnostics) {
729
- if (!Diagnostics.isProblem(diagnostic)) continue;
730
- if (diagnostic.code === Diagnostics.code.unknown) {
731
- await hooks.callHook("kubb:error", { error: diagnostic.cause ?? new Error(diagnostic.message) });
732
- continue;
733
- }
734
- await Diagnostics.emit(hooks, diagnostic);
726
+ let output;
727
+ try {
728
+ await hooks.callHook("kubb:setup:start");
729
+ await this.setup();
730
+ await hooks.callHook("kubb:setup:end");
731
+ output = await this.safeBuild();
732
+ } catch (caughtError) {
733
+ if (signal?.aborted) throw caughtError;
734
+ output = {
735
+ files: [],
736
+ diagnostics: [Diagnostics.from(caughtError)]
737
+ };
735
738
  }
739
+ const { files, diagnostics } = output;
740
+ const storage = this.storage;
741
+ signal?.throwIfAborted();
742
+ for (const diagnostic of diagnostics) if (Diagnostics.isProblem(diagnostic)) await Diagnostics.emit(hooks, diagnostic);
736
743
  if (Diagnostics.hasError(diagnostics)) {
737
744
  await hooks.callHook("kubb:generation:end", {
738
745
  config,
@@ -873,7 +880,7 @@ function buildReport(result) {
873
880
  name: config.name ?? "",
874
881
  status,
875
882
  plugins: {
876
- passed: total - failed.length,
883
+ passed: status === "failed" && timings.length === 0 ? 0 : total - failed.length,
877
884
  failed,
878
885
  total
879
886
  },
@@ -895,7 +902,12 @@ function buildReport(result) {
895
902
  function formatSummary(report, { showTimings }) {
896
903
  const { status, plugins, counts, filesCreated, durationMs, output, timings } = report;
897
904
  const rows = [];
898
- rows.push(["Plugins", status === "success" ? `${styleText("green", `${plugins.passed} passed`)} (${plugins.total})` : `${styleText("green", `${plugins.passed} passed`)} | ${styleText("red", `${plugins.failed.length} failed`)} (${plugins.total})`]);
905
+ const notRun = plugins.total - plugins.passed - plugins.failed.length;
906
+ rows.push(["Plugins", status === "success" ? `${styleText("green", `${plugins.passed} passed`)} (${plugins.total})` : [
907
+ styleText("green", `${plugins.passed} passed`),
908
+ styleText("red", `${plugins.failed.length} failed`),
909
+ notRun > 0 ? styleText("dim", `${notRun} not run`) : void 0
910
+ ].filter(Boolean).join(" | ") + ` (${plugins.total})`]);
899
911
  if (status === "failed" && plugins.failed.length > 0) rows.push(["Failed", plugins.failed.map((name) => styleText("red", name)).join(", ")]);
900
912
  if (counts.errors > 0 || counts.warnings > 0) {
901
913
  const issues = [counts.errors > 0 ? styleText("red", `${counts.errors} ${counts.errors === 1 ? "error" : "errors"}`) : void 0, counts.warnings > 0 ? styleText("yellow", `${counts.warnings} ${counts.warnings === 1 ? "warning" : "warnings"}`) : void 0].filter(Boolean).join(" | ");
@@ -1011,7 +1023,7 @@ function buildProblemSection(diagnostics) {
1011
1023
  return [
1012
1024
  "## Problems",
1013
1025
  "",
1014
- problems.map((diagnostic) => Diagnostics.formatLines(diagnostic).join("\n")).join("\n\n")
1026
+ problems.map((diagnostic) => Diagnostics.format(diagnostic, { verbose: true }).join("\n")).join("\n\n")
1015
1027
  ];
1016
1028
  }
1017
1029
  /**