@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __name } from "./
|
|
1
|
+
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
2
|
import { Enforce, FileNode, HttpMethod, ImportNode, InputMeta, InputNode, Macro, Node, OperationNode, SchemaNode, UserFileNode } from "@kubb/ast";
|
|
3
3
|
|
|
4
4
|
//#region ../../internals/utils/src/asyncEventEmitter.d.ts
|
|
@@ -225,12 +225,12 @@ type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) =
|
|
|
225
225
|
* options,
|
|
226
226
|
* document: null,
|
|
227
227
|
* async parse(_source) {
|
|
228
|
-
* // Convert
|
|
228
|
+
* // Convert the source (path or inline data) into an InputNode.
|
|
229
229
|
* return ast.factory.createInput()
|
|
230
230
|
* },
|
|
231
231
|
* getImports: () => [],
|
|
232
232
|
* async validate() {
|
|
233
|
-
* // Throw
|
|
233
|
+
* // Throw here when the spec is invalid.
|
|
234
234
|
* },
|
|
235
235
|
* }))
|
|
236
236
|
* ```
|
|
@@ -371,13 +371,13 @@ type GenerationResult = {
|
|
|
371
371
|
hrStart: [number, number];
|
|
372
372
|
};
|
|
373
373
|
/**
|
|
374
|
-
* Render
|
|
375
|
-
*
|
|
374
|
+
* Render settings passed alongside the {@link GenerationResult}. These are not part of the run
|
|
375
|
+
* data, such as the output verbosity.
|
|
376
376
|
*/
|
|
377
377
|
type ReporterContext = {
|
|
378
378
|
/**
|
|
379
379
|
* Output verbosity. Use the `logLevel` constants exported from `@kubb/core`
|
|
380
|
-
* (`silent`, `error`, `warn`, `info`, `verbose
|
|
380
|
+
* (`silent`, `error`, `warn`, `info`, `verbose`).
|
|
381
381
|
*/
|
|
382
382
|
logLevel: (typeof logLevel)[keyof typeof logLevel];
|
|
383
383
|
};
|
|
@@ -397,7 +397,7 @@ type Reporter = {
|
|
|
397
397
|
report: (result: GenerationResult, context: ReporterContext) => void | Promise<void>;
|
|
398
398
|
/**
|
|
399
399
|
* Optional finalizer called once after the run's last config. The host wires it to
|
|
400
|
-
* `kubb:lifecycle:end`. {@link createReporter} closes it over the
|
|
400
|
+
* `kubb:lifecycle:end`. {@link createReporter} closes it over the values that `report` returned.
|
|
401
401
|
*/
|
|
402
402
|
drain?: (context: ReporterContext) => void | Promise<void>;
|
|
403
403
|
};
|
|
@@ -471,8 +471,8 @@ type Storage = {
|
|
|
471
471
|
*/
|
|
472
472
|
clear(base?: string): Promise<void>;
|
|
473
473
|
/**
|
|
474
|
-
* Optional teardown hook
|
|
475
|
-
*
|
|
474
|
+
* Optional teardown hook for a backend to flush buffers, close connections,
|
|
475
|
+
* or release file locks.
|
|
476
476
|
*/
|
|
477
477
|
dispose?(): Promise<void>;
|
|
478
478
|
};
|
|
@@ -950,8 +950,8 @@ type Group = {
|
|
|
950
950
|
*/
|
|
951
951
|
type: 'tag' | 'path';
|
|
952
952
|
/**
|
|
953
|
-
* Returns the subdirectory name from the group key. Defaults to the
|
|
954
|
-
*
|
|
953
|
+
* Returns the subdirectory name from the group key. Defaults to the camelCased tag for
|
|
954
|
+
* `tag` groups, or the camelCased first path segment for `path` groups.
|
|
955
955
|
*/
|
|
956
956
|
name?: (context: {
|
|
957
957
|
group: string;
|
|
@@ -1017,11 +1017,12 @@ type ByPath = {
|
|
|
1017
1017
|
};
|
|
1018
1018
|
type ByMethod = {
|
|
1019
1019
|
/**
|
|
1020
|
-
* Filter by HTTP method: `'
|
|
1020
|
+
* Filter by HTTP method: `'GET'`, `'POST'`, `'PUT'`, `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`.
|
|
1021
1021
|
*/
|
|
1022
1022
|
type: 'method';
|
|
1023
1023
|
/**
|
|
1024
|
-
* HTTP method to match
|
|
1024
|
+
* HTTP method to match, as one of the `HttpMethod` values (`'GET'`, `'POST'`, `'PUT'`,
|
|
1025
|
+
* `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`) or a regex.
|
|
1025
1026
|
*/
|
|
1026
1027
|
pattern: HttpMethod | RegExp;
|
|
1027
1028
|
};
|
|
@@ -1186,7 +1187,7 @@ type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
1186
1187
|
*
|
|
1187
1188
|
* - `'pre'` runs before all normal plugins.
|
|
1188
1189
|
* - `'post'` runs after all normal plugins.
|
|
1189
|
-
* - `undefined` (default)
|
|
1190
|
+
* - `undefined` (default) runs in declaration order among normal plugins.
|
|
1190
1191
|
*
|
|
1191
1192
|
* Dependency constraints always take precedence over `enforce`.
|
|
1192
1193
|
*/
|
|
@@ -1340,13 +1341,19 @@ declare class KubbDriver {
|
|
|
1340
1341
|
readonly fileManager: FileManager;
|
|
1341
1342
|
readonly plugins: Map<string, NormalizedPlugin>;
|
|
1342
1343
|
constructor(config: Config, options: Options);
|
|
1344
|
+
/**
|
|
1345
|
+
* Normalizes every configured plugin, orders them, and registers their lifecycle handlers.
|
|
1346
|
+
* A plugin that another lists as a dependency runs first, then `enforce: 'pre'` before
|
|
1347
|
+
* `'post'`. When the config has an adapter, the adapter source is resolved from the input
|
|
1348
|
+
* so `run` can parse it later.
|
|
1349
|
+
*/
|
|
1343
1350
|
setup(): Promise<void>;
|
|
1344
1351
|
get hooks(): AsyncEventEmitter<KubbHooks>;
|
|
1345
1352
|
/**
|
|
1346
1353
|
* Emits the `kubb:plugin:setup` event so that all registered hook-style plugin listeners
|
|
1347
1354
|
* can configure generators, resolvers, macros and renderers before `buildStart` runs.
|
|
1348
1355
|
*
|
|
1349
|
-
*
|
|
1356
|
+
* Called once from `run` before the plugin execution loop begins.
|
|
1350
1357
|
*/
|
|
1351
1358
|
emitSetupHooks(): Promise<void>;
|
|
1352
1359
|
/**
|
|
@@ -1437,11 +1444,11 @@ declare class KubbDriver {
|
|
|
1437
1444
|
//#endregion
|
|
1438
1445
|
//#region src/defineGenerator.d.ts
|
|
1439
1446
|
/**
|
|
1440
|
-
* Context
|
|
1447
|
+
* Context passed to a generator's `schema`, `operation`, and `operations` methods.
|
|
1441
1448
|
*
|
|
1442
|
-
* The adapter
|
|
1443
|
-
*
|
|
1444
|
-
* filtering for
|
|
1449
|
+
* The driver sets `adapter` on the context before it runs a generator, so methods can read it
|
|
1450
|
+
* without a null check. `ctx.options` carries the per-node options after exclude/include/override
|
|
1451
|
+
* filtering for `schema` and `operation`, or the plugin-level options for `operations`.
|
|
1445
1452
|
*/
|
|
1446
1453
|
type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
1447
1454
|
/**
|
|
@@ -1536,9 +1543,10 @@ type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
1536
1543
|
/**
|
|
1537
1544
|
* Declares a named generator unit that walks the AST and emits files.
|
|
1538
1545
|
*
|
|
1539
|
-
*
|
|
1540
|
-
* JSX-based generators require a `renderer` factory.
|
|
1541
|
-
* `ctx.upsertFile()` manually and return `null` to
|
|
1546
|
+
* `schema` runs for each schema node and `operation` for each operation node. `operations` runs
|
|
1547
|
+
* once after every operation node is walked. JSX-based generators require a `renderer` factory.
|
|
1548
|
+
* Return `Array<FileNode>` directly, or call `ctx.upsertFile()` manually and return `null` to
|
|
1549
|
+
* bypass rendering.
|
|
1542
1550
|
*
|
|
1543
1551
|
* @note Generators are consumed by plugins and registered via `ctx.addGenerator()` in `kubb:plugin:setup`.
|
|
1544
1552
|
*
|
|
@@ -1646,8 +1654,9 @@ type Parser<TMeta extends object = object, TNode = unknown> = {
|
|
|
1646
1654
|
*/
|
|
1647
1655
|
name: string;
|
|
1648
1656
|
/**
|
|
1649
|
-
* File extensions this parser handles.
|
|
1650
|
-
*
|
|
1657
|
+
* File extensions this parser handles. The driver registers the parser for each
|
|
1658
|
+
* extension in this list. A parser with `undefined` here is not registered, so
|
|
1659
|
+
* files of an unclaimed extension fall back to joining their sources verbatim.
|
|
1651
1660
|
*
|
|
1652
1661
|
* @example
|
|
1653
1662
|
* `['.ts', '.js']`
|
|
@@ -1698,9 +1707,8 @@ type CreateKubbOptions = {
|
|
|
1698
1707
|
* config in the constructor, so `config` is available right away, and shares `hooks`,
|
|
1699
1708
|
* `storage`, and `driver` across the `setup → build` lifecycle.
|
|
1700
1709
|
*
|
|
1701
|
-
* `createKubb` takes a plain
|
|
1702
|
-
*
|
|
1703
|
-
* fingerprinted and validated against the shipped JSON schema.
|
|
1710
|
+
* `createKubb` takes a plain config object (the shape `defineConfig` produces),
|
|
1711
|
+
* not a fluent builder.
|
|
1704
1712
|
*
|
|
1705
1713
|
* Attach event listeners to `.hooks` before calling `setup()` or `build()`.
|
|
1706
1714
|
*
|
|
@@ -1929,7 +1937,7 @@ type Config<TInput = Input> = {
|
|
|
1929
1937
|
*
|
|
1930
1938
|
* @example
|
|
1931
1939
|
* ```ts
|
|
1932
|
-
* format: 'auto' // auto-detect
|
|
1940
|
+
* format: 'auto' // auto-detect oxfmt, biome, or prettier
|
|
1933
1941
|
* format: 'prettier' // force prettier
|
|
1934
1942
|
* format: false // skip formatting
|
|
1935
1943
|
* ```
|
|
@@ -2701,7 +2709,7 @@ declare function narrow<C extends DiagnosticCode>(diagnostic: Diagnostic, code:
|
|
|
2701
2709
|
/**
|
|
2702
2710
|
* A {@link Diagnostic} reduced to its JSON-safe fields plus a `docsUrl`, for
|
|
2703
2711
|
* machine-readable output (the `--reporter json` report, the MCP tools). Drops the
|
|
2704
|
-
* non-serializable `cause` and the `
|
|
2712
|
+
* non-serializable `cause` and the `kind`/`duration` bookkeeping.
|
|
2705
2713
|
*/
|
|
2706
2714
|
type SerializedDiagnostic = {
|
|
2707
2715
|
code: DiagnosticCode;
|
|
@@ -2850,8 +2858,8 @@ declare class Diagnostics {
|
|
|
2850
2858
|
*/
|
|
2851
2859
|
static failedPlugins(diagnostics: ReadonlyArray<Diagnostic>): Array<string>;
|
|
2852
2860
|
/**
|
|
2853
|
-
* Counts `problem` diagnostics by severity for the run summary. `
|
|
2854
|
-
* diagnostics are ignored.
|
|
2861
|
+
* Counts `problem` diagnostics by severity for the run summary. `performance` and
|
|
2862
|
+
* `update` diagnostics are ignored.
|
|
2855
2863
|
*/
|
|
2856
2864
|
static count(diagnostics: ReadonlyArray<Diagnostic>): {
|
|
2857
2865
|
errors: number;
|
|
@@ -2881,24 +2889,23 @@ declare class Diagnostics {
|
|
|
2881
2889
|
*/
|
|
2882
2890
|
static serialize(diagnostic: Diagnostic): SerializedDiagnostic;
|
|
2883
2891
|
/**
|
|
2884
|
-
* Renders a {@link Diagnostic} for terminal output as its parts: the
|
|
2885
|
-
* (the
|
|
2886
|
-
* `at
|
|
2892
|
+
* Renders a {@link Diagnostic} for terminal output as its parts: the `headline`
|
|
2893
|
+
* (`[CODE] plugin: message`, with the code in the severity color) and the indented `details`
|
|
2894
|
+
* rows (`at:` pointer, `fix:` help, `see:` docs link).
|
|
2887
2895
|
*
|
|
2888
|
-
* Hosts compose these to fit their gutter: a clack logger passes `
|
|
2889
|
-
*
|
|
2896
|
+
* Hosts compose these to fit their gutter: a clack logger passes `[headline, ...details]` as the
|
|
2897
|
+
* message with no gutter symbol, while plain text outputs use {@link Diagnostics.formatLines}.
|
|
2890
2898
|
*/
|
|
2891
2899
|
static format(diagnostic: Diagnostic): {
|
|
2892
|
-
symbol: string;
|
|
2893
2900
|
headline: string;
|
|
2894
2901
|
details: Array<string>;
|
|
2895
2902
|
};
|
|
2896
2903
|
/**
|
|
2897
|
-
* The self-contained block form of {@link Diagnostics.format}:
|
|
2898
|
-
*
|
|
2904
|
+
* The self-contained block form of {@link Diagnostics.format}: the `headline` followed by the
|
|
2905
|
+
* indented detail rows. Used where there is no gutter (plain and file output).
|
|
2899
2906
|
*/
|
|
2900
2907
|
static formatLines(diagnostic: Diagnostic): Array<string>;
|
|
2901
2908
|
}
|
|
2902
2909
|
//#endregion
|
|
2903
2910
|
export { KubbPluginSetupContext as $, KubbHookStartContext as A, Adapter as At, ParsedFile as B, KubbFilesProcessingEndContext as C, GenerationResult as Ct, KubbGenerationStartContext as D, UserReporter as Dt, KubbGenerationEndContext as E, ReporterName as Et, KubbSuccessContext as F, Generator$1 as G, createKubb as H, KubbWarnContext as I, KubbDriver as J, GeneratorContext as K, PossibleConfig as L, KubbInfoContext as M, AdapterSource as Mt, KubbLifecycleStartContext as N, createAdapter as Nt, KubbHookEndContext as O, createReporter as Ot, KubbPluginsEndContext as P, AsyncEventEmitter as Pt, KubbPluginEndContext as Q, UserConfig as R, KubbFileProcessingUpdate as S, createStorage as St, KubbFilesProcessingUpdateContext as T, ReporterContext as Tt, Parser as U, Kubb$1 as V, defineParser as W, Group as X, Exclude$1 as Y, Include as Z, InputPath as _, defineResolver as _t, DiagnosticLocation as a, Override as at, KubbDiagnosticContext as b, createRenderer as bt, PerformanceDiagnostic as c, definePlugin as ct, SerializedDiagnostic as d, ResolveBannerFile as dt, KubbPluginStartContext as et, UpdateDiagnostic as f, ResolveOptionsContext as ft, InputData as g, ResolverPathParams as gt, Config as h, ResolverFileParams as ht, DiagnosticKind as i, OutputOptions as it, KubbHooks as j, AdapterFactoryOptions as jt, KubbHookLineContext as k, logLevel as kt, ProblemCode as l, BannerMeta as lt, CLIOptions as m, ResolverContext as mt, DiagnosticByCode as n, Output as nt, DiagnosticSeverity as o, Plugin as ot, BuildOutput as p, Resolver as pt, defineGenerator as q, DiagnosticDoc as r, OutputMode as rt, Diagnostics as s, PluginFactoryOptions as st, Diagnostic as t, NormalizedPlugin as tt, ProblemDiagnostic as u, ResolveBannerContext as ut, KubbBuildEndContext as v, Renderer as vt, KubbFilesProcessingStartContext as w, Reporter as wt, KubbErrorContext as x, Storage as xt, KubbBuildStartContext as y, RendererFactory as yt, FileProcessorHooks as z };
|
|
2904
|
-
//# sourceMappingURL=diagnostics-
|
|
2911
|
+
//# sourceMappingURL=diagnostics-BqiNAWVS.d.ts.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_memoryStorage = require("./memoryStorage-
|
|
2
|
+
const require_memoryStorage = require("./memoryStorage-mojU6pbA.cjs");
|
|
3
3
|
let node_crypto = require("node:crypto");
|
|
4
4
|
let node_util = require("node:util");
|
|
5
5
|
let node_fs_promises = require("node:fs/promises");
|
|
6
6
|
let node_path = require("node:path");
|
|
7
7
|
node_path = require_memoryStorage.__toESM(node_path, 1);
|
|
8
8
|
let _kubb_ast = require("@kubb/ast");
|
|
9
|
-
_kubb_ast = require_memoryStorage.__toESM(_kubb_ast, 1);
|
|
10
9
|
let node_async_hooks = require("node:async_hooks");
|
|
11
10
|
let _kubb_ast_factory = require("@kubb/ast/factory");
|
|
12
11
|
_kubb_ast_factory = require_memoryStorage.__toESM(_kubb_ast_factory, 1);
|
|
@@ -593,12 +592,12 @@ var Url = class Url {
|
|
|
593
592
|
* options,
|
|
594
593
|
* document: null,
|
|
595
594
|
* async parse(_source) {
|
|
596
|
-
* // Convert
|
|
595
|
+
* // Convert the source (path or inline data) into an InputNode.
|
|
597
596
|
* return ast.factory.createInput()
|
|
598
597
|
* },
|
|
599
598
|
* getImports: () => [],
|
|
600
599
|
* async validate() {
|
|
601
|
-
* // Throw
|
|
600
|
+
* // Throw here when the spec is invalid.
|
|
602
601
|
* },
|
|
603
602
|
* }))
|
|
604
603
|
* ```
|
|
@@ -611,7 +610,7 @@ function createAdapter(build) {
|
|
|
611
610
|
/**
|
|
612
611
|
* Docs major version, derived from the package version so the link tracks the published major.
|
|
613
612
|
*/
|
|
614
|
-
const docsMajor = "5.0.0-beta.
|
|
613
|
+
const docsMajor = "5.0.0-beta.64".split(".")[0] ?? "5";
|
|
615
614
|
/**
|
|
616
615
|
* Narrows a {@link Diagnostic} to the variant for `code`, or `null` when it does not match.
|
|
617
616
|
*
|
|
@@ -665,22 +664,13 @@ const isPerformance = isKind("performance");
|
|
|
665
664
|
*/
|
|
666
665
|
const isUpdate = isKind("update");
|
|
667
666
|
/**
|
|
668
|
-
*
|
|
669
|
-
*
|
|
667
|
+
* Accent color per severity. The color tints the `[CODE]` tag (red error, yellow warning,
|
|
668
|
+
* blue info).
|
|
670
669
|
*/
|
|
671
670
|
const severityStyle = {
|
|
672
|
-
error: {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
},
|
|
676
|
-
warning: {
|
|
677
|
-
glyph: "⚠",
|
|
678
|
-
color: "yellow"
|
|
679
|
-
},
|
|
680
|
-
info: {
|
|
681
|
-
glyph: "ℹ",
|
|
682
|
-
color: "blue"
|
|
683
|
-
}
|
|
671
|
+
error: { color: "red" },
|
|
672
|
+
warning: { color: "yellow" },
|
|
673
|
+
info: { color: "blue" }
|
|
684
674
|
};
|
|
685
675
|
/**
|
|
686
676
|
* Explanation for every {@link diagnosticCode}. Use {@link Diagnostics.explain} to look one up
|
|
@@ -931,8 +921,8 @@ var Diagnostics = class Diagnostics {
|
|
|
931
921
|
return [...names];
|
|
932
922
|
}
|
|
933
923
|
/**
|
|
934
|
-
* Counts `problem` diagnostics by severity for the run summary. `
|
|
935
|
-
* diagnostics are ignored.
|
|
924
|
+
* Counts `problem` diagnostics by severity for the run summary. `performance` and
|
|
925
|
+
* `update` diagnostics are ignored.
|
|
936
926
|
*/
|
|
937
927
|
static count(diagnostics) {
|
|
938
928
|
let errors = 0;
|
|
@@ -1003,35 +993,35 @@ var Diagnostics = class Diagnostics {
|
|
|
1003
993
|
};
|
|
1004
994
|
}
|
|
1005
995
|
/**
|
|
1006
|
-
* Renders a {@link Diagnostic} for terminal output as its parts: the
|
|
1007
|
-
* (the
|
|
1008
|
-
* `at
|
|
996
|
+
* Renders a {@link Diagnostic} for terminal output as its parts: the `headline`
|
|
997
|
+
* (`[CODE] plugin: message`, with the code in the severity color) and the indented `details`
|
|
998
|
+
* rows (`at:` pointer, `fix:` help, `see:` docs link).
|
|
1009
999
|
*
|
|
1010
|
-
* Hosts compose these to fit their gutter: a clack logger passes `
|
|
1011
|
-
*
|
|
1000
|
+
* Hosts compose these to fit their gutter: a clack logger passes `[headline, ...details]` as the
|
|
1001
|
+
* message with no gutter symbol, while plain text outputs use {@link Diagnostics.formatLines}.
|
|
1012
1002
|
*/
|
|
1013
1003
|
static format(diagnostic) {
|
|
1014
1004
|
const { code, severity, message } = diagnostic;
|
|
1015
|
-
const {
|
|
1005
|
+
const { color } = severityStyle[severity];
|
|
1016
1006
|
const problem = isProblem(diagnostic) ? diagnostic : void 0;
|
|
1017
|
-
const
|
|
1007
|
+
const tag = (0, node_util.styleText)(color, (0, node_util.styleText)("bold", `[${code}]`));
|
|
1008
|
+
const headline = problem?.plugin ? `${tag} ${problem.plugin}: ${message}` : `${tag}: ${message}`;
|
|
1018
1009
|
const details = [];
|
|
1019
|
-
if (problem?.location && "pointer" in problem.location) details.push(` ${(0, node_util.styleText)("dim", "at")} ${(0, node_util.styleText)("cyan", problem.location.pointer)}`);
|
|
1020
|
-
if (problem?.help) details.push(` ${(0, node_util.styleText)("cyan", "
|
|
1021
|
-
if (code !== require_memoryStorage.diagnosticCode.unknown) details.push(` ${(0, node_util.styleText)("dim", "
|
|
1010
|
+
if (problem?.location && "pointer" in problem.location) details.push(` ${(0, node_util.styleText)("dim", "at:")} ${(0, node_util.styleText)("cyan", problem.location.pointer)}`);
|
|
1011
|
+
if (problem?.help) details.push(` ${(0, node_util.styleText)("cyan", "fix:")} ${problem.help}`);
|
|
1012
|
+
if (code !== require_memoryStorage.diagnosticCode.unknown) details.push(` ${(0, node_util.styleText)("dim", "see:")} ${(0, node_util.styleText)("cyan", Diagnostics.docsUrl(code))}`);
|
|
1022
1013
|
return {
|
|
1023
|
-
|
|
1024
|
-
headline: `${rule}: ${message}`,
|
|
1014
|
+
headline,
|
|
1025
1015
|
details
|
|
1026
1016
|
};
|
|
1027
1017
|
}
|
|
1028
1018
|
/**
|
|
1029
|
-
* The self-contained block form of {@link Diagnostics.format}:
|
|
1030
|
-
*
|
|
1019
|
+
* The self-contained block form of {@link Diagnostics.format}: the `headline` followed by the
|
|
1020
|
+
* indented detail rows. Used where there is no gutter (plain and file output).
|
|
1031
1021
|
*/
|
|
1032
1022
|
static formatLines(diagnostic) {
|
|
1033
|
-
const {
|
|
1034
|
-
return [
|
|
1023
|
+
const { headline, details } = Diagnostics.format(diagnostic);
|
|
1024
|
+
return [headline, ...details];
|
|
1035
1025
|
}
|
|
1036
1026
|
};
|
|
1037
1027
|
//#endregion
|
|
@@ -1500,7 +1490,7 @@ function defineResolver(build) {
|
|
|
1500
1490
|
* leaves the tree untouched, so callers can detect a no-op by identity.
|
|
1501
1491
|
*
|
|
1502
1492
|
* Registration order matches the order setup hooks fire, which the driver has already sorted by
|
|
1503
|
-
* `enforce` and dependency edges. The registry preserves that order
|
|
1493
|
+
* `enforce` and dependency edges. The registry preserves that order. Macro `enforce` only reorders
|
|
1504
1494
|
* within a single plugin's list.
|
|
1505
1495
|
*/
|
|
1506
1496
|
var Transform = class {
|
|
@@ -1633,6 +1623,12 @@ var KubbDriver = class {
|
|
|
1633
1623
|
this.hooks.on(event, handler);
|
|
1634
1624
|
this.#listeners.push([event, handler]);
|
|
1635
1625
|
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Normalizes every configured plugin, orders them, and registers their lifecycle handlers.
|
|
1628
|
+
* A plugin that another lists as a dependency runs first, then `enforce: 'pre'` before
|
|
1629
|
+
* `'post'`. When the config has an adapter, the adapter source is resolved from the input
|
|
1630
|
+
* so `run` can parse it later.
|
|
1631
|
+
*/
|
|
1636
1632
|
async setup() {
|
|
1637
1633
|
const normalized = this.config.plugins.map((rawPlugin) => this.#normalizePlugin(rawPlugin));
|
|
1638
1634
|
const dependenciesByName = new Map(normalized.map((plugin) => [plugin.name, new Set(plugin.dependencies ?? [])]));
|
|
@@ -1652,8 +1648,9 @@ var KubbDriver = class {
|
|
|
1652
1648
|
return this.options.hooks;
|
|
1653
1649
|
}
|
|
1654
1650
|
/**
|
|
1655
|
-
*
|
|
1656
|
-
* its lifecycle handlers
|
|
1651
|
+
* Builds a `NormalizedPlugin` from a hook-style plugin, filling in default
|
|
1652
|
+
* options and copying `apply` when present. Registering its lifecycle handlers
|
|
1653
|
+
* on the `AsyncEventEmitter` is done separately by `#registerPlugin`.
|
|
1657
1654
|
*/
|
|
1658
1655
|
#normalizePlugin(plugin) {
|
|
1659
1656
|
const normalized = {
|
|
@@ -1758,7 +1755,7 @@ var KubbDriver = class {
|
|
|
1758
1755
|
* Emits the `kubb:plugin:setup` event so that all registered hook-style plugin listeners
|
|
1759
1756
|
* can configure generators, resolvers, macros and renderers before `buildStart` runs.
|
|
1760
1757
|
*
|
|
1761
|
-
*
|
|
1758
|
+
* Called once from `run` before the plugin execution loop begins.
|
|
1762
1759
|
*/
|
|
1763
1760
|
async emitSetupHooks() {
|
|
1764
1761
|
const noop = () => {};
|
|
@@ -1953,8 +1950,8 @@ var KubbDriver = class {
|
|
|
1953
1950
|
* That ordering is what drives the CLI's `Plugins N/M` counter. Without it the bar would
|
|
1954
1951
|
* sit at the initial value until the very end of the run.
|
|
1955
1952
|
*
|
|
1956
|
-
* When `
|
|
1957
|
-
*
|
|
1953
|
+
* When `this.inputNode` is `null`, every entry still gets a `kubb:plugin:end` so
|
|
1954
|
+
* post-plugin listeners (the barrel writer and friends) complete.
|
|
1958
1955
|
*/
|
|
1959
1956
|
async #runGenerators(entries, flushPending) {
|
|
1960
1957
|
const diagnostics = [];
|
|
@@ -2445,9 +2442,8 @@ function resolveConfig(userConfig) {
|
|
|
2445
2442
|
* config in the constructor, so `config` is available right away, and shares `hooks`,
|
|
2446
2443
|
* `storage`, and `driver` across the `setup → build` lifecycle.
|
|
2447
2444
|
*
|
|
2448
|
-
* `createKubb` takes a plain
|
|
2449
|
-
*
|
|
2450
|
-
* fingerprinted and validated against the shipped JSON schema.
|
|
2445
|
+
* `createKubb` takes a plain config object (the shape `defineConfig` produces),
|
|
2446
|
+
* not a fluent builder.
|
|
2451
2447
|
*
|
|
2452
2448
|
* Attach event listeners to `.hooks` before calling `setup()` or `build()`.
|
|
2453
2449
|
*
|
|
@@ -2756,12 +2752,11 @@ function buildTimingSection(report) {
|
|
|
2756
2752
|
* The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
|
|
2757
2753
|
* plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same counts the
|
|
2758
2754
|
* cli and json reporters expose, a `## Problems` section in the miette block format, and a
|
|
2759
|
-
* `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`)
|
|
2760
|
-
* old `--debug` flag.
|
|
2755
|
+
* `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`).
|
|
2761
2756
|
*
|
|
2762
|
-
* @note
|
|
2763
|
-
*
|
|
2764
|
-
*
|
|
2757
|
+
* @note It captures the collected diagnostics once a config finishes, not the live
|
|
2758
|
+
* `kubb:info`/`kubb:plugin` event stream. Color is stripped so the file stays plain text even when
|
|
2759
|
+
* the run is attached to a TTY.
|
|
2765
2760
|
*/
|
|
2766
2761
|
const fileReporter = createReporter({
|
|
2767
2762
|
name: "file",
|
|
@@ -2905,7 +2900,7 @@ exports.Url = Url;
|
|
|
2905
2900
|
Object.defineProperty(exports, "ast", {
|
|
2906
2901
|
enumerable: true,
|
|
2907
2902
|
get: function() {
|
|
2908
|
-
return _kubb_ast;
|
|
2903
|
+
return _kubb_ast.ast;
|
|
2909
2904
|
}
|
|
2910
2905
|
});
|
|
2911
2906
|
exports.cliReporter = cliReporter;
|