@kubb/core 5.10.0 → 5.10.2

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
@@ -1,13 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_Hookable = require("./Hookable-XjiJoKGb.cjs");
2
+ const require_Hookable = require("./Hookable-RTuEiBd9.cjs");
3
3
  let verkit = require("verkit");
4
- let node_util = require("node:util");
5
4
  let node_process = require("node:process");
6
5
  node_process = require_Hookable.__toESM(node_process, 1);
7
6
  let tinyexec = require("tinyexec");
8
7
  let node_fs_promises = require("node:fs/promises");
9
8
  let node_path = require("node:path");
10
9
  node_path = require_Hookable.__toESM(node_path, 1);
10
+ let node_util = require("node:util");
11
11
  let node_crypto = require("node:crypto");
12
12
  let node_fs = require("node:fs");
13
13
  let node_os = require("node:os");
@@ -635,7 +635,11 @@ var Kubb = class {
635
635
  return this.config.storage;
636
636
  }
637
637
  get driver() {
638
- if (!this.#driver) throw new Error("[kubb] setup() must be called before accessing driver");
638
+ if (!this.#driver) throw new require_Hookable.Diagnostics.Error({
639
+ code: require_Hookable.Diagnostics.code.internalError,
640
+ severity: "error",
641
+ message: "[kubb] setup() must be called before accessing driver"
642
+ });
639
643
  return this.#driver;
640
644
  }
641
645
  /**
@@ -723,19 +727,23 @@ var Kubb = class {
723
727
  const { hooks, config } = this;
724
728
  const hrStart = process.hrtime();
725
729
  await hooks.callHook("kubb:generation:start", { config });
726
- await hooks.callHook("kubb:setup:start");
727
- await this.setup();
728
- await hooks.callHook("kubb:setup:end");
729
- const { files, diagnostics, storage } = await this.safeBuild();
730
- signal?.throwIfAborted();
731
- for (const diagnostic of diagnostics) {
732
- if (!require_Hookable.Diagnostics.isProblem(diagnostic)) continue;
733
- if (diagnostic.code === require_Hookable.Diagnostics.code.unknown) {
734
- await hooks.callHook("kubb:error", { error: diagnostic.cause ?? new Error(diagnostic.message) });
735
- continue;
736
- }
737
- await require_Hookable.Diagnostics.emit(hooks, diagnostic);
730
+ let output;
731
+ try {
732
+ await hooks.callHook("kubb:setup:start");
733
+ await this.setup();
734
+ await hooks.callHook("kubb:setup:end");
735
+ output = await this.safeBuild();
736
+ } catch (caughtError) {
737
+ if (signal?.aborted) throw caughtError;
738
+ output = {
739
+ files: [],
740
+ diagnostics: [require_Hookable.Diagnostics.from(caughtError)]
741
+ };
738
742
  }
743
+ const { files, diagnostics } = output;
744
+ const storage = this.storage;
745
+ signal?.throwIfAborted();
746
+ for (const diagnostic of diagnostics) if (require_Hookable.Diagnostics.isProblem(diagnostic)) await require_Hookable.Diagnostics.emit(hooks, diagnostic);
739
747
  if (require_Hookable.Diagnostics.hasError(diagnostics)) {
740
748
  await hooks.callHook("kubb:generation:end", {
741
749
  config,
@@ -876,7 +884,7 @@ function buildReport(result) {
876
884
  name: config.name ?? "",
877
885
  status,
878
886
  plugins: {
879
- passed: total - failed.length,
887
+ passed: status === "failed" && timings.length === 0 ? 0 : total - failed.length,
880
888
  failed,
881
889
  total
882
890
  },
@@ -898,7 +906,12 @@ function buildReport(result) {
898
906
  function formatSummary(report, { showTimings }) {
899
907
  const { status, plugins, counts, filesCreated, durationMs, output, timings } = report;
900
908
  const rows = [];
901
- rows.push(["Plugins", status === "success" ? `${(0, node_util.styleText)("green", `${plugins.passed} passed`)} (${plugins.total})` : `${(0, node_util.styleText)("green", `${plugins.passed} passed`)} | ${(0, node_util.styleText)("red", `${plugins.failed.length} failed`)} (${plugins.total})`]);
909
+ const notRun = plugins.total - plugins.passed - plugins.failed.length;
910
+ rows.push(["Plugins", status === "success" ? `${(0, node_util.styleText)("green", `${plugins.passed} passed`)} (${plugins.total})` : [
911
+ (0, node_util.styleText)("green", `${plugins.passed} passed`),
912
+ (0, node_util.styleText)("red", `${plugins.failed.length} failed`),
913
+ notRun > 0 ? (0, node_util.styleText)("dim", `${notRun} not run`) : void 0
914
+ ].filter(Boolean).join(" | ") + ` (${plugins.total})`]);
902
915
  if (status === "failed" && plugins.failed.length > 0) rows.push(["Failed", plugins.failed.map((name) => (0, node_util.styleText)("red", name)).join(", ")]);
903
916
  if (counts.errors > 0 || counts.warnings > 0) {
904
917
  const issues = [counts.errors > 0 ? (0, node_util.styleText)("red", `${counts.errors} ${counts.errors === 1 ? "error" : "errors"}`) : void 0, counts.warnings > 0 ? (0, node_util.styleText)("yellow", `${counts.warnings} ${counts.warnings === 1 ? "warning" : "warnings"}`) : void 0].filter(Boolean).join(" | ");
@@ -1014,7 +1027,7 @@ function buildProblemSection(diagnostics) {
1014
1027
  return [
1015
1028
  "## Problems",
1016
1029
  "",
1017
- problems.map((diagnostic) => require_Hookable.Diagnostics.formatLines(diagnostic).join("\n")).join("\n\n")
1030
+ problems.map((diagnostic) => require_Hookable.Diagnostics.format(diagnostic, { verbose: true }).join("\n")).join("\n\n")
1018
1031
  ];
1019
1032
  }
1020
1033
  /**