@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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./rolldown-runtime-CRm0XQPb.js";
2
- import { $ as NodeCache, $t as UpdateDiagnostic, A as PluginFactory, At as RunHookOptions, B as ResolveImportsOptions, Bt as UserReporter, C as NormalizedPlugin, Ct as KubbPluginsEndContext, D as Override, Dt as PostGenerateCommand, E as OutputOptions, Et as PossibleConfig, F as definePlugin, Ft as GenerationResult, G as ResolverFile, Gt as DiagnosticKind, H as ResolvePathOptions, Ht as logLevel, I as BannerMeta, It as Reporter, J as ResolverPatch, Jt as Diagnostics, K as ResolverFileParams, Kt as DiagnosticLocation, L as ResolveBannerContext, Lt as ReporterContext, M as PluginType, Mt as KubbDriver, N as ResolvePluginOptions, Nt as Storage, O as Plugin, Ot as UserConfig, P as assertPluginOption, Pt as createStorage, Q as defineGenerator, Qt as SerializedDiagnostic, R as ResolveBannerFile, Rt as ReporterName, S as KubbPluginStartContext, St as KubbMessageContext, T as OutputMode, Tt as KubbWarnContext, U as Resolver, Ut as Diagnostic, V as ResolveOptionsContext, Vt as createReporter, W as ResolverDefault, Wt as DiagnosticDoc, X as Generator, Xt as ProblemCode, Y as ResolverPathParams, Yt as PerformanceDiagnostic, Z as GeneratorContext, Zt as ProblemDiagnostic, _ as Filter, _t as KubbHookLineContext, a as AdapterSource, an as ParserDefinition, at as KubbBuildEndContext, b as KubbPluginEndContext, bt as KubbInfoContext, c as ExtensionDependency, ct as KubbErrorContext, d as ExtensionKind, dt as KubbFilesProcessingStartContext, en as Hookable, et as BuildOutput, f as ExtensionMeta, ft as KubbFilesProcessingUpdateContext, g as Exclude, gt as KubbHookEndContext, h as resolveMeta, ht as KubbGenerationSummaryContext, i as AdapterFactoryOptions, in as Parser, it as Input, j as PluginName, jt as runHook, k as PluginDefinition, kt as HookResult, l as ExtensionDependencyRecord, lt as KubbFileProcessingUpdate, m as defineExtension, mt as KubbGenerationStartContext, n as AdapterDefinition, nn as RendererFactory, nt as Config, o as createAdapter, on as ParserFactory, ot as KubbBuildStartContext, p as checkCompatibility, pt as KubbGenerationEndContext, q as ResolverFilePathParams, qt as DiagnosticSeverity, r as AdapterFactory, rn as createRenderer, rt as FilesContext, s as ExtensionDependencies, sn as defineParser, st as KubbDiagnosticContext, t as Adapter, tn as Renderer, tt as CLIOptions, u as ExtensionFactory, ut as KubbFilesProcessingEndContext, v as Group, vt as KubbHookStartContext, w as Output, wt as KubbSuccessContext, x as KubbPluginSetupContext, xt as KubbLifecycleStartContext, y as Include, yt as KubbHooks, z as ResolveFileOptions, zt as ReporterPluginFiles } from "./createAdapter-D55JE9lX.js";
2
+ import { $ as NodeCache, $t as ReporterPluginFiles, A as PluginFactory, At as KubbInfoContext, B as ResolveImportsOptions, Bt as RunHookOptions, C as NormalizedPlugin, Ct as KubbGenerationEndContext, D as Override, Dt as KubbHookLineContext, E as OutputOptions, Et as KubbHookEndContext, F as definePlugin, Ft as KubbWarnContext, G as ResolverFile, Gt as RendererFactory, H as ResolvePathOptions, Ht as KubbDriver, I as BannerMeta, It as PossibleConfig, J as ResolverPatch, Jt as createStorage, K as ResolverFileParams, Kt as createRenderer, L as ResolveBannerContext, Lt as PostGenerateCommand, M as PluginType, Mt as KubbMessageContext, N as ResolvePluginOptions, Nt as KubbPluginsEndContext, O as Plugin, Ot as KubbHookStartContext, P as assertPluginOption, Pt as KubbSuccessContext, Q as defineGenerator, Qt as ReporterName, R as ResolveBannerFile, Rt as UserConfig, S as KubbPluginStartContext, St as KubbFilesProcessingUpdateContext, T as OutputMode, Tt as KubbGenerationSummaryContext, U as Resolver, Ut as Hookable, V as ResolveOptionsContext, Vt as runHook, W as ResolverDefault, Wt as Renderer, X as Generator, Xt as Reporter, Y as ResolverPathParams, Yt as GenerationResult, Z as GeneratorContext, Zt as ReporterContext, _ as Filter, _t as KubbDiagnosticContext, a as AdapterSource, an as Parser, at as Diagnostics, b as KubbPluginEndContext, bt as KubbFilesProcessingEndContext, c as ExtensionDependency, cn as defineParser, ct as ProblemDiagnostic, d as ExtensionKind, dt as CLIOptions, en as UserReporter, et as Diagnostic, f as ExtensionMeta, ft as Config, g as Exclude, gt as KubbBuildStartContext, h as resolveMeta, ht as KubbBuildEndContext, i as AdapterFactoryOptions, in as SerializedDiagnostic, it as DiagnosticSeverity, j as PluginName, jt as KubbLifecycleStartContext, k as PluginDefinition, kt as KubbHooks, l as ExtensionDependencyRecord, lt as UpdateDiagnostic, m as defineExtension, mt as Input, n as AdapterDefinition, nn as logLevel, nt as DiagnosticKind, o as createAdapter, on as ParserDefinition, ot as PerformanceDiagnostic, p as checkCompatibility, pt as FilesContext, q as ResolverFilePathParams, qt as Storage, r as AdapterFactory, rn as DiagnosticFormatOptions, rt as DiagnosticLocation, s as ExtensionDependencies, sn as ParserFactory, st as ProblemCode, t as Adapter, tn as createReporter, tt as DiagnosticDoc, u as ExtensionFactory, ut as BuildOutput, v as Group, vt as KubbErrorContext, w as Output, wt as KubbGenerationStartContext, x as KubbPluginSetupContext, xt as KubbFilesProcessingStartContext, y as Include, yt as KubbFileProcessingUpdate, z as ResolveFileOptions, zt as HookResult } from "./createAdapter-CMnLz31B.js";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import { FileNode, Macro, UserFileNode } from "@kubb/ast";
5
5
  //#region src/composables.d.ts
@@ -617,5 +617,5 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
617
617
  resolveFrom?: Array<string>;
618
618
  }): Promise<Array<InstalledPackage>>;
619
619
  //#endregion
620
- export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, BuildOutput, CLIOptions, Config, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, FilesContext, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, type HookResult, Hookable, type Include, Input, type InputKind, type InstalledPackage, type JSONValue, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbGenerationSummaryContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, KubbMessageContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NodeCache, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type ParserDefinition, type ParserFactory, type PerformanceDiagnostic, type Plugin, type PluginDefinition, type PluginFactory, type PluginName, type PluginType, PossibleConfig, PostGenerateCommand, type ProblemCode, type ProblemDiagnostic, type RegistryArtifact, type RegistryDetail, type RegistryEntry, type RegistryGuide, type RegistryIndex, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ReporterPluginFiles, type ResolveBannerContext, type ResolveBannerFile, type ResolveFileOptions, type ResolveImportsOptions, type ResolveOptionsContext, type ResolvePathOptions, type ResolvePluginOptions, Resolver, type ResolverDefault, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type ResolverPathParams, type RunHookOptions, type RunOutputPassesOptions, type SerializedDiagnostic, type Storage, type SummaryRenderer, type UpdateDiagnostic, UserConfig, type UserReporter, assertPluginOption, checkCompatibility, createAdapter, createRenderer, createReporter, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, logLevel, resolveMeta, runHook };
620
+ export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, BuildOutput, CLIOptions, Config, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticFormatOptions, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, FilesContext, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, type HookResult, Hookable, type Include, Input, type InputKind, type InstalledPackage, type JSONValue, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbGenerationSummaryContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, KubbMessageContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NodeCache, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type ParserDefinition, type ParserFactory, type PerformanceDiagnostic, type Plugin, type PluginDefinition, type PluginFactory, type PluginName, type PluginType, PossibleConfig, PostGenerateCommand, type ProblemCode, type ProblemDiagnostic, type RegistryArtifact, type RegistryDetail, type RegistryEntry, type RegistryGuide, type RegistryIndex, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ReporterPluginFiles, type ResolveBannerContext, type ResolveBannerFile, type ResolveFileOptions, type ResolveImportsOptions, type ResolveOptionsContext, type ResolvePathOptions, type ResolvePluginOptions, Resolver, type ResolverDefault, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type ResolverPathParams, type RunHookOptions, type RunOutputPassesOptions, type SerializedDiagnostic, type Storage, type SummaryRenderer, type UpdateDiagnostic, UserConfig, type UserReporter, assertPluginOption, checkCompatibility, createAdapter, createRenderer, createReporter, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, logLevel, resolveMeta, runHook };
621
621
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
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-DBB42ADP.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-Bjfoua7Y.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { isValid } from "verkit";
5
- import { stripVTControlCharacters, styleText } from "node:util";
6
5
  import process$1 from "node:process";
7
6
  import { x } from "tinyexec";
8
7
  import { glob, readFile, rm } from "node:fs/promises";
9
8
  import path, { join, relative, resolve } from "node:path";
9
+ import { stripVTControlCharacters, styleText } from "node:util";
10
10
  import { hash, randomUUID } from "node:crypto";
11
11
  import { chmodSync, existsSync, mkdirSync } from "node:fs";
12
12
  import { homedir, tmpdir } from "node:os";
@@ -632,7 +632,11 @@ var Kubb = class {
632
632
  return this.config.storage;
633
633
  }
634
634
  get driver() {
635
- if (!this.#driver) throw new Error("[kubb] setup() must be called before accessing driver");
635
+ if (!this.#driver) throw new Diagnostics.Error({
636
+ code: Diagnostics.code.internalError,
637
+ severity: "error",
638
+ message: "[kubb] setup() must be called before accessing driver"
639
+ });
636
640
  return this.#driver;
637
641
  }
638
642
  /**
@@ -720,19 +724,23 @@ var Kubb = class {
720
724
  const { hooks, config } = this;
721
725
  const hrStart = process.hrtime();
722
726
  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);
727
+ let output;
728
+ try {
729
+ await hooks.callHook("kubb:setup:start");
730
+ await this.setup();
731
+ await hooks.callHook("kubb:setup:end");
732
+ output = await this.safeBuild();
733
+ } catch (caughtError) {
734
+ if (signal?.aborted) throw caughtError;
735
+ output = {
736
+ files: [],
737
+ diagnostics: [Diagnostics.from(caughtError)]
738
+ };
735
739
  }
740
+ const { files, diagnostics } = output;
741
+ const storage = this.storage;
742
+ signal?.throwIfAborted();
743
+ for (const diagnostic of diagnostics) if (Diagnostics.isProblem(diagnostic)) await Diagnostics.emit(hooks, diagnostic);
736
744
  if (Diagnostics.hasError(diagnostics)) {
737
745
  await hooks.callHook("kubb:generation:end", {
738
746
  config,
@@ -873,7 +881,7 @@ function buildReport(result) {
873
881
  name: config.name ?? "",
874
882
  status,
875
883
  plugins: {
876
- passed: total - failed.length,
884
+ passed: status === "failed" && timings.length === 0 ? 0 : total - failed.length,
877
885
  failed,
878
886
  total
879
887
  },
@@ -895,7 +903,12 @@ function buildReport(result) {
895
903
  function formatSummary(report, { showTimings }) {
896
904
  const { status, plugins, counts, filesCreated, durationMs, output, timings } = report;
897
905
  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})`]);
906
+ const notRun = plugins.total - plugins.passed - plugins.failed.length;
907
+ rows.push(["Plugins", status === "success" ? `${styleText("green", `${plugins.passed} passed`)} (${plugins.total})` : [
908
+ styleText("green", `${plugins.passed} passed`),
909
+ styleText("red", `${plugins.failed.length} failed`),
910
+ notRun > 0 ? styleText("dim", `${notRun} not run`) : void 0
911
+ ].filter(Boolean).join(" | ") + ` (${plugins.total})`]);
899
912
  if (status === "failed" && plugins.failed.length > 0) rows.push(["Failed", plugins.failed.map((name) => styleText("red", name)).join(", ")]);
900
913
  if (counts.errors > 0 || counts.warnings > 0) {
901
914
  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 +1024,7 @@ function buildProblemSection(diagnostics) {
1011
1024
  return [
1012
1025
  "## Problems",
1013
1026
  "",
1014
- problems.map((diagnostic) => Diagnostics.formatLines(diagnostic).join("\n")).join("\n\n")
1027
+ problems.map((diagnostic) => Diagnostics.format(diagnostic, { verbose: true }).join("\n")).join("\n\n")
1015
1028
  ];
1016
1029
  }
1017
1030
  /**