@kubb/core 5.0.0-beta.62 → 5.0.0-beta.64
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/{diagnostics-D0G07LHG.d.ts → diagnostics-BqiNAWVS.d.ts} +47 -40
- package/dist/index.cjs +47 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/index.js +49 -54
- package/dist/index.js.map +1 -1
- package/dist/{memoryStorage-CWFzAz4o.js → memoryStorage-DWnhqUf2.js} +3 -3
- package/dist/memoryStorage-DWnhqUf2.js.map +1 -0
- package/dist/{memoryStorage-CUj1hrxa.cjs → memoryStorage-mojU6pbA.cjs} +2 -2
- package/dist/memoryStorage-mojU6pbA.cjs.map +1 -0
- package/dist/mocks.cjs +2 -2
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +3 -3
- package/dist/mocks.js +3 -3
- package/dist/mocks.js.map +1 -1
- package/package.json +4 -5
- package/dist/memoryStorage-CUj1hrxa.cjs.map +0 -1
- package/dist/memoryStorage-CWFzAz4o.js.map +0 -1
- package/src/FileManager.ts +0 -137
- package/src/FileProcessor.ts +0 -212
- package/src/KubbDriver.ts +0 -893
- package/src/Transform.ts +0 -105
- package/src/constants.ts +0 -126
- package/src/createAdapter.ts +0 -127
- package/src/createKubb.ts +0 -196
- package/src/createRenderer.ts +0 -72
- package/src/createReporter.ts +0 -134
- package/src/createStorage.ts +0 -83
- package/src/defineGenerator.ts +0 -210
- package/src/defineParser.ts +0 -62
- package/src/definePlugin.ts +0 -437
- package/src/defineResolver.ts +0 -711
- package/src/diagnostics.ts +0 -662
- package/src/index.ts +0 -20
- package/src/mocks.ts +0 -249
- package/src/reporters/cliReporter.ts +0 -89
- package/src/reporters/fileReporter.ts +0 -103
- package/src/reporters/jsonReporter.ts +0 -20
- package/src/reporters/report.ts +0 -85
- package/src/storages/fsStorage.ts +0 -82
- package/src/storages/memoryStorage.ts +0 -55
- package/src/types.ts +0 -829
- /package/dist/{chunk-C0LytTxp.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as __name } from "./
|
|
2
|
-
import { $ as KubbPluginSetupContext, A as KubbHookStartContext, At as Adapter, B as ParsedFile, C as KubbFilesProcessingEndContext, Ct as GenerationResult, D as KubbGenerationStartContext, Dt as UserReporter, E as KubbGenerationEndContext, Et as ReporterName, F as KubbSuccessContext, G as Generator, H as createKubb, I as KubbWarnContext, J as KubbDriver, K as GeneratorContext, L as PossibleConfig, M as KubbInfoContext, Mt as AdapterSource, N as KubbLifecycleStartContext, Nt as createAdapter, O as KubbHookEndContext, Ot as createReporter, P as KubbPluginsEndContext, Pt as AsyncEventEmitter, Q as KubbPluginEndContext, R as UserConfig, S as KubbFileProcessingUpdate, St as createStorage, T as KubbFilesProcessingUpdateContext, Tt as ReporterContext, U as Parser, V as Kubb, W as defineParser, X as Group, Y as Exclude, Z as Include, _ as InputPath, _t as defineResolver, a as DiagnosticLocation, at as Override, b as KubbDiagnosticContext, bt as createRenderer, c as PerformanceDiagnostic, ct as definePlugin, d as SerializedDiagnostic, dt as ResolveBannerFile, et as KubbPluginStartContext, f as UpdateDiagnostic, ft as ResolveOptionsContext, g as InputData, gt as ResolverPathParams, h as Config, ht as ResolverFileParams, i as DiagnosticKind, it as OutputOptions, j as KubbHooks, jt as AdapterFactoryOptions, k as KubbHookLineContext, kt as logLevel, l as ProblemCode, lt as BannerMeta, m as CLIOptions, mt as ResolverContext, n as DiagnosticByCode, nt as Output, o as DiagnosticSeverity, ot as Plugin, p as BuildOutput, pt as Resolver, q as defineGenerator, r as DiagnosticDoc, rt as OutputMode, s as Diagnostics, st as PluginFactoryOptions, t as Diagnostic, tt as NormalizedPlugin, u as ProblemDiagnostic, ut as ResolveBannerContext, v as KubbBuildEndContext, vt as Renderer, w as KubbFilesProcessingStartContext, wt as Reporter, x as KubbErrorContext, xt as Storage, y as KubbBuildStartContext, yt as RendererFactory, z as FileProcessorHooks } from "./diagnostics-
|
|
3
|
-
import
|
|
1
|
+
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { $ as KubbPluginSetupContext, A as KubbHookStartContext, At as Adapter, B as ParsedFile, C as KubbFilesProcessingEndContext, Ct as GenerationResult, D as KubbGenerationStartContext, Dt as UserReporter, E as KubbGenerationEndContext, Et as ReporterName, F as KubbSuccessContext, G as Generator, H as createKubb, I as KubbWarnContext, J as KubbDriver, K as GeneratorContext, L as PossibleConfig, M as KubbInfoContext, Mt as AdapterSource, N as KubbLifecycleStartContext, Nt as createAdapter, O as KubbHookEndContext, Ot as createReporter, P as KubbPluginsEndContext, Pt as AsyncEventEmitter, Q as KubbPluginEndContext, R as UserConfig, S as KubbFileProcessingUpdate, St as createStorage, T as KubbFilesProcessingUpdateContext, Tt as ReporterContext, U as Parser, V as Kubb, W as defineParser, X as Group, Y as Exclude, Z as Include, _ as InputPath, _t as defineResolver, a as DiagnosticLocation, at as Override, b as KubbDiagnosticContext, bt as createRenderer, c as PerformanceDiagnostic, ct as definePlugin, d as SerializedDiagnostic, dt as ResolveBannerFile, et as KubbPluginStartContext, f as UpdateDiagnostic, ft as ResolveOptionsContext, g as InputData, gt as ResolverPathParams, h as Config, ht as ResolverFileParams, i as DiagnosticKind, it as OutputOptions, j as KubbHooks, jt as AdapterFactoryOptions, k as KubbHookLineContext, kt as logLevel, l as ProblemCode, lt as BannerMeta, m as CLIOptions, mt as ResolverContext, n as DiagnosticByCode, nt as Output, o as DiagnosticSeverity, ot as Plugin, p as BuildOutput, pt as Resolver, q as defineGenerator, r as DiagnosticDoc, rt as OutputMode, s as Diagnostics, st as PluginFactoryOptions, t as Diagnostic, tt as NormalizedPlugin, u as ProblemDiagnostic, ut as ResolveBannerContext, v as KubbBuildEndContext, vt as Renderer, w as KubbFilesProcessingStartContext, wt as Reporter, x as KubbErrorContext, xt as Storage, y as KubbBuildStartContext, yt as RendererFactory, z as FileProcessorHooks } from "./diagnostics-BqiNAWVS.js";
|
|
3
|
+
import { ast } from "@kubb/ast";
|
|
4
4
|
|
|
5
5
|
//#region ../../internals/utils/src/url.d.ts
|
|
6
6
|
type URLObject = {
|
|
@@ -113,12 +113,11 @@ declare const cliReporter: Reporter;
|
|
|
113
113
|
* The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
|
|
114
114
|
* plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same counts the
|
|
115
115
|
* cli and json reporters expose, a `## Problems` section in the miette block format, and a
|
|
116
|
-
* `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`)
|
|
117
|
-
* old `--debug` flag.
|
|
116
|
+
* `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`).
|
|
118
117
|
*
|
|
119
|
-
* @note
|
|
120
|
-
*
|
|
121
|
-
*
|
|
118
|
+
* @note It captures the collected diagnostics once a config finishes, not the live
|
|
119
|
+
* `kubb:info`/`kubb:plugin` event stream. Color is stripped so the file stays plain text even when
|
|
120
|
+
* the run is attached to a TTY.
|
|
122
121
|
*/
|
|
123
122
|
declare const fileReporter: Reporter;
|
|
124
123
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { a as createStorage, c as camelCase, d as BuildError, f as getErrorMessage, i as FileManager, l as pascalCase, n as _usingCtx, o as OPERATION_FILTER_TYPES, r as FileProcessor, s as diagnosticCode, t as memoryStorage, u as AsyncEventEmitter } from "./memoryStorage-
|
|
3
|
-
import { hash } from "node:crypto";
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { a as createStorage, c as camelCase, d as BuildError, f as getErrorMessage, i as FileManager, l as pascalCase, n as _usingCtx, o as OPERATION_FILTER_TYPES, r as FileProcessor, s as diagnosticCode, t as memoryStorage, u as AsyncEventEmitter } from "./memoryStorage-DWnhqUf2.js";
|
|
4
3
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
4
|
+
import { hash } from "node:crypto";
|
|
5
5
|
import { access, glob, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
6
6
|
import path, { dirname, join, relative, resolve } from "node:path";
|
|
7
|
-
import
|
|
8
|
-
import { composeMacros, operationDef, schemaDef, transform } from "@kubb/ast";
|
|
7
|
+
import { ast, composeMacros, operationDef, schemaDef, transform } from "@kubb/ast";
|
|
9
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
9
|
import * as factory from "@kubb/ast/factory";
|
|
11
10
|
import { collectUsedSchemaNames } from "@kubb/ast/utils";
|
|
@@ -590,12 +589,12 @@ var Url = class Url {
|
|
|
590
589
|
* options,
|
|
591
590
|
* document: null,
|
|
592
591
|
* async parse(_source) {
|
|
593
|
-
* // Convert
|
|
592
|
+
* // Convert the source (path or inline data) into an InputNode.
|
|
594
593
|
* return ast.factory.createInput()
|
|
595
594
|
* },
|
|
596
595
|
* getImports: () => [],
|
|
597
596
|
* async validate() {
|
|
598
|
-
* // Throw
|
|
597
|
+
* // Throw here when the spec is invalid.
|
|
599
598
|
* },
|
|
600
599
|
* }))
|
|
601
600
|
* ```
|
|
@@ -608,7 +607,7 @@ function createAdapter(build) {
|
|
|
608
607
|
/**
|
|
609
608
|
* Docs major version, derived from the package version so the link tracks the published major.
|
|
610
609
|
*/
|
|
611
|
-
const docsMajor = "5.0.0-beta.
|
|
610
|
+
const docsMajor = "5.0.0-beta.64".split(".")[0] ?? "5";
|
|
612
611
|
/**
|
|
613
612
|
* Narrows a {@link Diagnostic} to the variant for `code`, or `null` when it does not match.
|
|
614
613
|
*
|
|
@@ -662,22 +661,13 @@ const isPerformance = isKind("performance");
|
|
|
662
661
|
*/
|
|
663
662
|
const isUpdate = isKind("update");
|
|
664
663
|
/**
|
|
665
|
-
*
|
|
666
|
-
*
|
|
664
|
+
* Accent color per severity. The color tints the `[CODE]` tag (red error, yellow warning,
|
|
665
|
+
* blue info).
|
|
667
666
|
*/
|
|
668
667
|
const severityStyle = {
|
|
669
|
-
error: {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
},
|
|
673
|
-
warning: {
|
|
674
|
-
glyph: "⚠",
|
|
675
|
-
color: "yellow"
|
|
676
|
-
},
|
|
677
|
-
info: {
|
|
678
|
-
glyph: "ℹ",
|
|
679
|
-
color: "blue"
|
|
680
|
-
}
|
|
668
|
+
error: { color: "red" },
|
|
669
|
+
warning: { color: "yellow" },
|
|
670
|
+
info: { color: "blue" }
|
|
681
671
|
};
|
|
682
672
|
/**
|
|
683
673
|
* Explanation for every {@link diagnosticCode}. Use {@link Diagnostics.explain} to look one up
|
|
@@ -928,8 +918,8 @@ var Diagnostics = class Diagnostics {
|
|
|
928
918
|
return [...names];
|
|
929
919
|
}
|
|
930
920
|
/**
|
|
931
|
-
* Counts `problem` diagnostics by severity for the run summary. `
|
|
932
|
-
* diagnostics are ignored.
|
|
921
|
+
* Counts `problem` diagnostics by severity for the run summary. `performance` and
|
|
922
|
+
* `update` diagnostics are ignored.
|
|
933
923
|
*/
|
|
934
924
|
static count(diagnostics) {
|
|
935
925
|
let errors = 0;
|
|
@@ -1000,35 +990,35 @@ var Diagnostics = class Diagnostics {
|
|
|
1000
990
|
};
|
|
1001
991
|
}
|
|
1002
992
|
/**
|
|
1003
|
-
* Renders a {@link Diagnostic} for terminal output as its parts: the
|
|
1004
|
-
* (the
|
|
1005
|
-
* `at
|
|
993
|
+
* Renders a {@link Diagnostic} for terminal output as its parts: the `headline`
|
|
994
|
+
* (`[CODE] plugin: message`, with the code in the severity color) and the indented `details`
|
|
995
|
+
* rows (`at:` pointer, `fix:` help, `see:` docs link).
|
|
1006
996
|
*
|
|
1007
|
-
* Hosts compose these to fit their gutter: a clack logger passes `
|
|
1008
|
-
*
|
|
997
|
+
* Hosts compose these to fit their gutter: a clack logger passes `[headline, ...details]` as the
|
|
998
|
+
* message with no gutter symbol, while plain text outputs use {@link Diagnostics.formatLines}.
|
|
1009
999
|
*/
|
|
1010
1000
|
static format(diagnostic) {
|
|
1011
1001
|
const { code, severity, message } = diagnostic;
|
|
1012
|
-
const {
|
|
1002
|
+
const { color } = severityStyle[severity];
|
|
1013
1003
|
const problem = isProblem(diagnostic) ? diagnostic : void 0;
|
|
1014
|
-
const
|
|
1004
|
+
const tag = styleText(color, styleText("bold", `[${code}]`));
|
|
1005
|
+
const headline = problem?.plugin ? `${tag} ${problem.plugin}: ${message}` : `${tag}: ${message}`;
|
|
1015
1006
|
const details = [];
|
|
1016
|
-
if (problem?.location && "pointer" in problem.location) details.push(` ${styleText("dim", "at")} ${styleText("cyan", problem.location.pointer)}`);
|
|
1017
|
-
if (problem?.help) details.push(` ${styleText("cyan", "
|
|
1018
|
-
if (code !== diagnosticCode.unknown) details.push(` ${styleText("dim", "
|
|
1007
|
+
if (problem?.location && "pointer" in problem.location) details.push(` ${styleText("dim", "at:")} ${styleText("cyan", problem.location.pointer)}`);
|
|
1008
|
+
if (problem?.help) details.push(` ${styleText("cyan", "fix:")} ${problem.help}`);
|
|
1009
|
+
if (code !== diagnosticCode.unknown) details.push(` ${styleText("dim", "see:")} ${styleText("cyan", Diagnostics.docsUrl(code))}`);
|
|
1019
1010
|
return {
|
|
1020
|
-
|
|
1021
|
-
headline: `${rule}: ${message}`,
|
|
1011
|
+
headline,
|
|
1022
1012
|
details
|
|
1023
1013
|
};
|
|
1024
1014
|
}
|
|
1025
1015
|
/**
|
|
1026
|
-
* The self-contained block form of {@link Diagnostics.format}:
|
|
1027
|
-
*
|
|
1016
|
+
* The self-contained block form of {@link Diagnostics.format}: the `headline` followed by the
|
|
1017
|
+
* indented detail rows. Used where there is no gutter (plain and file output).
|
|
1028
1018
|
*/
|
|
1029
1019
|
static formatLines(diagnostic) {
|
|
1030
|
-
const {
|
|
1031
|
-
return [
|
|
1020
|
+
const { headline, details } = Diagnostics.format(diagnostic);
|
|
1021
|
+
return [headline, ...details];
|
|
1032
1022
|
}
|
|
1033
1023
|
};
|
|
1034
1024
|
//#endregion
|
|
@@ -1497,7 +1487,7 @@ function defineResolver(build) {
|
|
|
1497
1487
|
* leaves the tree untouched, so callers can detect a no-op by identity.
|
|
1498
1488
|
*
|
|
1499
1489
|
* Registration order matches the order setup hooks fire, which the driver has already sorted by
|
|
1500
|
-
* `enforce` and dependency edges. The registry preserves that order
|
|
1490
|
+
* `enforce` and dependency edges. The registry preserves that order. Macro `enforce` only reorders
|
|
1501
1491
|
* within a single plugin's list.
|
|
1502
1492
|
*/
|
|
1503
1493
|
var Transform = class {
|
|
@@ -1630,6 +1620,12 @@ var KubbDriver = class {
|
|
|
1630
1620
|
this.hooks.on(event, handler);
|
|
1631
1621
|
this.#listeners.push([event, handler]);
|
|
1632
1622
|
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Normalizes every configured plugin, orders them, and registers their lifecycle handlers.
|
|
1625
|
+
* A plugin that another lists as a dependency runs first, then `enforce: 'pre'` before
|
|
1626
|
+
* `'post'`. When the config has an adapter, the adapter source is resolved from the input
|
|
1627
|
+
* so `run` can parse it later.
|
|
1628
|
+
*/
|
|
1633
1629
|
async setup() {
|
|
1634
1630
|
const normalized = this.config.plugins.map((rawPlugin) => this.#normalizePlugin(rawPlugin));
|
|
1635
1631
|
const dependenciesByName = new Map(normalized.map((plugin) => [plugin.name, new Set(plugin.dependencies ?? [])]));
|
|
@@ -1649,8 +1645,9 @@ var KubbDriver = class {
|
|
|
1649
1645
|
return this.options.hooks;
|
|
1650
1646
|
}
|
|
1651
1647
|
/**
|
|
1652
|
-
*
|
|
1653
|
-
* its lifecycle handlers
|
|
1648
|
+
* Builds a `NormalizedPlugin` from a hook-style plugin, filling in default
|
|
1649
|
+
* options and copying `apply` when present. Registering its lifecycle handlers
|
|
1650
|
+
* on the `AsyncEventEmitter` is done separately by `#registerPlugin`.
|
|
1654
1651
|
*/
|
|
1655
1652
|
#normalizePlugin(plugin) {
|
|
1656
1653
|
const normalized = {
|
|
@@ -1755,7 +1752,7 @@ var KubbDriver = class {
|
|
|
1755
1752
|
* Emits the `kubb:plugin:setup` event so that all registered hook-style plugin listeners
|
|
1756
1753
|
* can configure generators, resolvers, macros and renderers before `buildStart` runs.
|
|
1757
1754
|
*
|
|
1758
|
-
*
|
|
1755
|
+
* Called once from `run` before the plugin execution loop begins.
|
|
1759
1756
|
*/
|
|
1760
1757
|
async emitSetupHooks() {
|
|
1761
1758
|
const noop = () => {};
|
|
@@ -1950,8 +1947,8 @@ var KubbDriver = class {
|
|
|
1950
1947
|
* That ordering is what drives the CLI's `Plugins N/M` counter. Without it the bar would
|
|
1951
1948
|
* sit at the initial value until the very end of the run.
|
|
1952
1949
|
*
|
|
1953
|
-
* When `
|
|
1954
|
-
*
|
|
1950
|
+
* When `this.inputNode` is `null`, every entry still gets a `kubb:plugin:end` so
|
|
1951
|
+
* post-plugin listeners (the barrel writer and friends) complete.
|
|
1955
1952
|
*/
|
|
1956
1953
|
async #runGenerators(entries, flushPending) {
|
|
1957
1954
|
const diagnostics = [];
|
|
@@ -2442,9 +2439,8 @@ function resolveConfig(userConfig) {
|
|
|
2442
2439
|
* config in the constructor, so `config` is available right away, and shares `hooks`,
|
|
2443
2440
|
* `storage`, and `driver` across the `setup → build` lifecycle.
|
|
2444
2441
|
*
|
|
2445
|
-
* `createKubb` takes a plain
|
|
2446
|
-
*
|
|
2447
|
-
* fingerprinted and validated against the shipped JSON schema.
|
|
2442
|
+
* `createKubb` takes a plain config object (the shape `defineConfig` produces),
|
|
2443
|
+
* not a fluent builder.
|
|
2448
2444
|
*
|
|
2449
2445
|
* Attach event listeners to `.hooks` before calling `setup()` or `build()`.
|
|
2450
2446
|
*
|
|
@@ -2753,12 +2749,11 @@ function buildTimingSection(report) {
|
|
|
2753
2749
|
* The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
|
|
2754
2750
|
* plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same counts the
|
|
2755
2751
|
* cli and json reporters expose, a `## Problems` section in the miette block format, and a
|
|
2756
|
-
* `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`)
|
|
2757
|
-
* old `--debug` flag.
|
|
2752
|
+
* `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`).
|
|
2758
2753
|
*
|
|
2759
|
-
* @note
|
|
2760
|
-
*
|
|
2761
|
-
*
|
|
2754
|
+
* @note It captures the collected diagnostics once a config finishes, not the live
|
|
2755
|
+
* `kubb:info`/`kubb:plugin` event stream. Color is stripped so the file stays plain text even when
|
|
2756
|
+
* the run is attached to a TTY.
|
|
2762
2757
|
*/
|
|
2763
2758
|
const fileReporter = createReporter({
|
|
2764
2759
|
name: "file",
|