@kubb/core 5.11.4 → 5.11.5
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/{Hookable-C2bwJUE5.js → Hookable-7Kv_oj72.js} +95 -73
- package/dist/Hookable-7Kv_oj72.js.map +1 -0
- package/dist/{createAdapter-D6osJ_0O.d.ts → createAdapter-DtX_MKL-.d.ts} +77 -14
- package/dist/index.cjs +148 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -16
- package/dist/index.d.ts +3 -5
- package/dist/index.js +56 -38
- package/dist/index.js.map +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/package.json +2 -2
- package/dist/Hookable-C2bwJUE5.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -321,6 +321,16 @@ type DiagnosticFormatOptions = {
|
|
|
321
321
|
* @default 0
|
|
322
322
|
*/
|
|
323
323
|
width?: number;
|
|
324
|
+
/**
|
|
325
|
+
* Where the diagnostic's pointer sits in the input file, when the host resolved it. Replaces the
|
|
326
|
+
* pointer on the `at` row, and an error's `human` layout draws `frame` under it.
|
|
327
|
+
*/
|
|
328
|
+
position?: {
|
|
329
|
+
file: string;
|
|
330
|
+
line: number;
|
|
331
|
+
column: number;
|
|
332
|
+
frame?: Array<string>;
|
|
333
|
+
};
|
|
324
334
|
};
|
|
325
335
|
/**
|
|
326
336
|
* A {@link Diagnostic} reduced to its JSON-safe fields plus a `docsUrl`, for
|
|
@@ -372,7 +382,7 @@ declare function serialize(diagnostic: Diagnostic): SerializedDiagnostic;
|
|
|
372
382
|
* with `at`, `fix`, the first cause, and `Learn more` for an error, and one row for a warning.
|
|
373
383
|
* `verbose` adds the full stack.
|
|
374
384
|
*/
|
|
375
|
-
declare function format(diagnostic: Diagnostic, { audience, verbose, width }?: DiagnosticFormatOptions): Array<string>;
|
|
385
|
+
declare function format(diagnostic: Diagnostic, { audience, verbose, width, position }?: DiagnosticFormatOptions): Array<string>;
|
|
376
386
|
//#endregion
|
|
377
387
|
//#region src/createReporter.d.ts
|
|
378
388
|
/**
|
|
@@ -415,9 +425,28 @@ type GenerationResult = {
|
|
|
415
425
|
*/
|
|
416
426
|
diagnostics: Array<Diagnostic>;
|
|
417
427
|
/**
|
|
418
|
-
* Number of files
|
|
428
|
+
* Number of generated files for this config, including unchanged files.
|
|
419
429
|
*/
|
|
420
430
|
filesCreated: number;
|
|
431
|
+
/**
|
|
432
|
+
* Number of generated files whose content matches the previous output.
|
|
433
|
+
*/
|
|
434
|
+
filesUnchanged?: number;
|
|
435
|
+
/**
|
|
436
|
+
* Changes compared with the output before this run, when the host collected them.
|
|
437
|
+
* Line totals include added and deleted files.
|
|
438
|
+
*/
|
|
439
|
+
fileChanges?: {
|
|
440
|
+
added: number;
|
|
441
|
+
modified: number;
|
|
442
|
+
deleted: number;
|
|
443
|
+
linesAdded: number;
|
|
444
|
+
linesRemoved: number;
|
|
445
|
+
};
|
|
446
|
+
/**
|
|
447
|
+
* The result previews generation without writing output.
|
|
448
|
+
*/
|
|
449
|
+
dryRun?: boolean;
|
|
421
450
|
status: 'success' | 'failed';
|
|
422
451
|
/**
|
|
423
452
|
* `process.hrtime()` snapshot taken when this config started generating.
|
|
@@ -454,10 +483,10 @@ type Reporter = {
|
|
|
454
483
|
*/
|
|
455
484
|
report: (result: GenerationResult, context: ReporterContext) => void | Promise<void>;
|
|
456
485
|
/**
|
|
457
|
-
*
|
|
458
|
-
*
|
|
486
|
+
* Runs once after the run's last config, on `kubb:lifecycle:end`. Only a reporter that collects
|
|
487
|
+
* its configs' reports into one document, such as `json`, has one.
|
|
459
488
|
*/
|
|
460
|
-
drain
|
|
489
|
+
drain?: (context: ReporterContext) => void | Promise<void>;
|
|
461
490
|
/**
|
|
462
491
|
* Whether the host should collect files from `kubb:plugin:end` hooks.
|
|
463
492
|
*/
|
|
@@ -676,6 +705,19 @@ type OutputManifest = {
|
|
|
676
705
|
*/
|
|
677
706
|
commit(): Promise<void>;
|
|
678
707
|
};
|
|
708
|
+
/**
|
|
709
|
+
* Loads the stored manifest, starting empty when it is missing, unreadable, or from an older
|
|
710
|
+
* version. `storage` holds the generated files, `cache` holds the manifest itself.
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
* ```ts
|
|
714
|
+
* const manifest = await createOutputManifest({ storage: config.storage, cache: cacheStorage({ root: config.root }) })
|
|
715
|
+
* ```
|
|
716
|
+
*/
|
|
717
|
+
export declare function createOutputManifest({ storage, cache }: {
|
|
718
|
+
storage: Storage;
|
|
719
|
+
cache: Storage;
|
|
720
|
+
}): Promise<OutputManifest>;
|
|
679
721
|
//#endregion
|
|
680
722
|
//#region src/Hookable.d.ts
|
|
681
723
|
/**
|
|
@@ -775,7 +817,7 @@ type WriteOptions = ParseOptions & {
|
|
|
775
817
|
*/
|
|
776
818
|
manifest?: OutputManifest;
|
|
777
819
|
/**
|
|
778
|
-
* Receives `kubb:files:processing:start`, `:update` (
|
|
820
|
+
* Receives `kubb:files:processing:start`, `:update` (in input order, as files finish) and `:end` for the write. `config` fills the update rows.
|
|
779
821
|
*/
|
|
780
822
|
hooks?: Hookable<KubbHooks>;
|
|
781
823
|
config?: Config;
|
|
@@ -820,11 +862,12 @@ declare class FileManager {
|
|
|
820
862
|
* Parses and writes every file through a bounded pool of workers. A small spec runs all its files
|
|
821
863
|
* at once; a spec with thousands of files keeps at most {@link FILE_CONCURRENCY} parsed sources in
|
|
822
864
|
* memory rather than holding every source, while still overlapping each file's write with the
|
|
823
|
-
* next file's parse. Files finish in whatever order they parse, so
|
|
824
|
-
*
|
|
865
|
+
* next file's parse. Files finish in whatever order they parse, so each finished file flushes the
|
|
866
|
+
* run of finished files ahead of it as one `kubb:files:processing:update`, keeping rows in input order.
|
|
825
867
|
*
|
|
826
868
|
* A file the storage already holds is skipped, so a rebuild that generates identical output
|
|
827
|
-
* writes nothing and leaves every mtime where it was.
|
|
869
|
+
* writes nothing and leaves every mtime where it was. `kubb:files:processing:end` lists the
|
|
870
|
+
* skipped paths as `unchanged`.
|
|
828
871
|
*/
|
|
829
872
|
write(files: Array<FileNode>, { storage, parsers, manifest, signal, hooks, config }: WriteOptions): Promise<void>;
|
|
830
873
|
}
|
|
@@ -1369,6 +1412,13 @@ export type KubbBuildStartContext = FilesContext & {
|
|
|
1369
1412
|
* To observe individual schemas and operations use the `kubb:generate:schema` / `kubb:generate:operation` hooks.
|
|
1370
1413
|
*/
|
|
1371
1414
|
meta: InputMeta | undefined;
|
|
1415
|
+
/**
|
|
1416
|
+
* How many schemas and operations the parsed document holds, the totals for a progress display.
|
|
1417
|
+
*/
|
|
1418
|
+
nodeCounts: {
|
|
1419
|
+
schemas: number;
|
|
1420
|
+
operations: number;
|
|
1421
|
+
};
|
|
1372
1422
|
/**
|
|
1373
1423
|
* Looks up a registered plugin by name, typed by the plugin registry.
|
|
1374
1424
|
*/
|
|
@@ -1520,6 +1570,10 @@ export type KubbFilesProcessingEndContext = {
|
|
|
1520
1570
|
* All files that were serialized in this batch.
|
|
1521
1571
|
*/
|
|
1522
1572
|
files: Array<FileNode>;
|
|
1573
|
+
/**
|
|
1574
|
+
* Paths of the files the storage already held with the same content, so they were not written.
|
|
1575
|
+
*/
|
|
1576
|
+
unchanged: Array<string>;
|
|
1523
1577
|
};
|
|
1524
1578
|
export type KubbHookStartContext = {
|
|
1525
1579
|
/**
|
|
@@ -1757,7 +1811,7 @@ type Diagnostic = ProblemDiagnostic | PerformanceDiagnostic | UpdateDiagnostic;
|
|
|
1757
1811
|
* Static helpers for working with {@link Diagnostic}s, plus the run-scoped sink
|
|
1758
1812
|
* that lets deep code report a diagnostic without threading a callback.
|
|
1759
1813
|
*
|
|
1760
|
-
* The sink lives in a single `AsyncLocalStorage`
|
|
1814
|
+
* The sink lives in a single `AsyncLocalStorage` on `globalThis`, shared by every copy of `@kubb/core`.
|
|
1761
1815
|
* `Diagnostics.scope` activates it for a run, so anything inside that run (the
|
|
1762
1816
|
* adapter parse, a generator) reports through `Diagnostics.report` and lands
|
|
1763
1817
|
* in the same run.
|
|
@@ -3097,9 +3151,11 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
|
3097
3151
|
name: TOptions['name'];
|
|
3098
3152
|
meta?: ExtensionMeta<TOptions['name']>;
|
|
3099
3153
|
/**
|
|
3100
|
-
*
|
|
3154
|
+
* The options the adapter was created with, before `setup` applied defaults, as a plugin keeps its
|
|
3155
|
+
* own. Kubb Studio merges its overrides onto these, so a default derived from another option, such
|
|
3156
|
+
* as `emptySchemaType` from `unknownType`, follows a change to it.
|
|
3101
3157
|
*/
|
|
3102
|
-
options: TOptions['
|
|
3158
|
+
options: TOptions['options'];
|
|
3103
3159
|
/**
|
|
3104
3160
|
* Parsed source document after the first `parse()` call. `null` before parsing.
|
|
3105
3161
|
*/
|
|
@@ -3121,6 +3177,13 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
|
3121
3177
|
validate: (input: string, options?: {
|
|
3122
3178
|
throwOnError?: boolean;
|
|
3123
3179
|
}) => Promise<void>;
|
|
3180
|
+
/**
|
|
3181
|
+
* Zero-based UTF-16 offsets of a diagnostic in `source` for a code frame, `end` exclusive; `undefined` when it cannot be found.
|
|
3182
|
+
*/
|
|
3183
|
+
locate?: (source: string, location: DiagnosticLocation) => {
|
|
3184
|
+
start: number;
|
|
3185
|
+
end: number;
|
|
3186
|
+
} | undefined;
|
|
3124
3187
|
};
|
|
3125
3188
|
/**
|
|
3126
3189
|
* The object passed to `defineExtension` with `kind: 'adapter'`.
|
|
@@ -3353,9 +3416,7 @@ export declare function createKubb(userConfig: UserConfig, options?: CreateKubbO
|
|
|
3353
3416
|
//#endregion
|
|
3354
3417
|
//#region src/reporters/summary.d.ts
|
|
3355
3418
|
/**
|
|
3356
|
-
* Writes
|
|
3357
|
-
* so the caller decides where they land: plain `console.log` by default, or the active logger's own
|
|
3358
|
-
* output when a host installs one.
|
|
3419
|
+
* Writes the summary through the host's output, or plain console lines by default.
|
|
3359
3420
|
*/
|
|
3360
3421
|
type SummaryRenderer = (lines: ReadonlyArray<string>, meta: {
|
|
3361
3422
|
title: string;
|
|
@@ -3768,5 +3829,5 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
|
|
|
3768
3829
|
resolveFrom?: Array<string>;
|
|
3769
3830
|
}): Promise<Array<InstalledPackage>>;
|
|
3770
3831
|
//#endregion
|
|
3771
|
-
export type { Adapter, AdapterDefinition, AdapterFactory, AdapterFactoryOptions, AdapterSource, BannerMeta, CreateKubbOptions, Diagnostic, DiagnosticDoc, DiagnosticFormatOptions, DiagnosticKind, DiagnosticLocation, DiagnosticSeverity, Exclude$1 as Exclude, ExtensionDependencies, ExtensionDependency, ExtensionDependencyRecord, ExtensionFactory, ExtensionKind, ExtensionManifest, ExtensionManifestOption, ExtensionMeta, Filter, GenerateOptions, GenerateResult, GenerationResult, Generator, GeneratorContext, Group, HookResult, Include, InputKind, InstalledPackage, JSONValue, Kubb$1 as Kubb, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, NodeCache, NormalizedPlugin, Output, OutputMode, OutputOptions, Override, Parser, ParserDefinition, ParserFactory, PerformanceDiagnostic, Plugin, PluginDefinition, PluginFactory, PluginName, PluginType, ProblemCode, ProblemDiagnostic, RegistryArtifact, RegistryDetail, RegistryEntry, RegistryGuide, RegistryIndex, Renderer, RendererFactory, Reporter, ReporterContext, ReporterName, ReporterPluginFiles, ResolveBannerContext, ResolveBannerFile, ResolveFileOptions, ResolveImportsOptions, ResolveOptionsContext, ResolvePathOptions, ResolvePluginOptions, ResolverDefault, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, ResolverPathParams, RunHookOptions, RunOutputPassesOptions, SerializedDiagnostic, Storage, SummaryRenderer, UpdateDiagnostic, UserReporter };
|
|
3832
|
+
export type { Adapter, AdapterDefinition, AdapterFactory, AdapterFactoryOptions, AdapterSource, BannerMeta, CreateKubbOptions, Diagnostic, DiagnosticDoc, DiagnosticFormatOptions, DiagnosticKind, DiagnosticLocation, DiagnosticSeverity, Exclude$1 as Exclude, ExtensionDependencies, ExtensionDependency, ExtensionDependencyRecord, ExtensionFactory, ExtensionKind, ExtensionManifest, ExtensionManifestOption, ExtensionMeta, Filter, GenerateOptions, GenerateResult, GenerationResult, Generator, GeneratorContext, Group, HookResult, Include, InputKind, InstalledPackage, JSONValue, Kubb$1 as Kubb, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, NodeCache, NormalizedPlugin, Output, OutputManifest, OutputMode, OutputOptions, Override, Parser, ParserDefinition, ParserFactory, PerformanceDiagnostic, Plugin, PluginDefinition, PluginFactory, PluginName, PluginType, ProblemCode, ProblemDiagnostic, RegistryArtifact, RegistryDetail, RegistryEntry, RegistryGuide, RegistryIndex, Renderer, RendererFactory, Reporter, ReporterContext, ReporterName, ReporterPluginFiles, ResolveBannerContext, ResolveBannerFile, ResolveFileOptions, ResolveImportsOptions, ResolveOptionsContext, ResolvePathOptions, ResolvePluginOptions, ResolverDefault, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, ResolverPathParams, RunHookOptions, RunOutputPassesOptions, SerializedDiagnostic, Storage, SummaryRenderer, UpdateDiagnostic, UserReporter };
|
|
3772
3833
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as NodeCache, $t as
|
|
1
|
+
import { $ as NodeCache, $t as ReporterContext, 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 createOutputManifest, H as ResolvePathOptions, Ht as KubbDriver, I as BannerMeta, It as PossibleConfig, J as ResolverPatch, Jt as createRenderer, K as ResolverFileParams, Kt as Renderer, 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 Reporter, 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 OutputManifest, X as Generator, Xt as createStorage, Y as ResolverPathParams, Yt as Storage, Z as GeneratorContext, Zt as GenerationResult, _ as Filter, _t as KubbDiagnosticContext, a as AdapterSource, an as DiagnosticFormatOptions, at as Diagnostics, b as KubbPluginEndContext, bt as KubbFilesProcessingEndContext, c as ExtensionDependency, cn as ParserDefinition, ct as ProblemDiagnostic, d as ExtensionKind, dt as CLIOptions, en as ReporterName, 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 logLevel, it as DiagnosticSeverity, j as PluginName, jt as KubbLifecycleStartContext, k as PluginDefinition, kt as KubbHooks, l as ExtensionDependencyRecord, ln as ParserFactory, lt as UpdateDiagnostic, m as defineExtension, mt as Input, n as AdapterDefinition, nn as UserReporter, nt as DiagnosticKind, o as createAdapter, on as SerializedDiagnostic, ot as PerformanceDiagnostic, p as checkCompatibility, pt as FilesContext, q as ResolverFilePathParams, qt as RendererFactory, r as AdapterFactory, rn as createReporter, rt as DiagnosticLocation, s as ExtensionDependencies, sn as Parser, st as ProblemCode, t as Adapter, tn as ReporterPluginFiles, tt as DiagnosticDoc, u as ExtensionFactory, un as defineParser, 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-DtX_MKL-.js";
|
|
2
2
|
import { FileNode, Macro, UserFileNode } from "@kubb/ast";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
//#region src/composables.d.ts
|
|
@@ -201,9 +201,7 @@ export declare function createKubb(userConfig: UserConfig, options?: CreateKubbO
|
|
|
201
201
|
//#endregion
|
|
202
202
|
//#region src/reporters/summary.d.ts
|
|
203
203
|
/**
|
|
204
|
-
* Writes
|
|
205
|
-
* so the caller decides where they land: plain `console.log` by default, or the active logger's own
|
|
206
|
-
* output when a host installs one.
|
|
204
|
+
* Writes the summary through the host's output, or plain console lines by default.
|
|
207
205
|
*/
|
|
208
206
|
type SummaryRenderer = (lines: ReadonlyArray<string>, meta: {
|
|
209
207
|
title: string;
|
|
@@ -616,5 +614,5 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
|
|
|
616
614
|
resolveFrom?: Array<string>;
|
|
617
615
|
}): Promise<Array<InstalledPackage>>;
|
|
618
616
|
//#endregion
|
|
619
|
-
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 };
|
|
617
|
+
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 OutputManifest, 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, createOutputManifest, createRenderer, createReporter, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, logLevel, resolveMeta, runHook };
|
|
620
618
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { A as inParallel, C as useOptions, D as Diagnostics, E as resolveMeta, F as rm, I as write, L as writeRaw, M as isPathInside, N as listFiles, O as formatMs, P as read, R as toError, 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 existsSync$1, 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-
|
|
1
|
+
import { A as inParallel, C as useOptions, D as Diagnostics, E as resolveMeta, F as rm, I as write, L as writeRaw, M as isPathInside, N as listFiles, O as formatMs, P as read, R as toError, 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 existsSync$1, 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-7Kv_oj72.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { isValid } from "verkit";
|
|
4
4
|
import process$1 from "node:process";
|
|
5
5
|
import { x } from "tinyexec";
|
|
6
6
|
import { readFile } from "node:fs/promises";
|
|
7
|
-
import path, { join, relative, resolve } from "node:path";
|
|
7
|
+
import path, { isAbsolute, join, relative, resolve } from "node:path";
|
|
8
8
|
import { chmodSync, existsSync, mkdirSync } from "node:fs";
|
|
9
9
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
10
10
|
import { hash, randomUUID } from "node:crypto";
|
|
@@ -845,17 +845,23 @@ const logLevel = {
|
|
|
845
845
|
* ```
|
|
846
846
|
*/
|
|
847
847
|
function createReporter(reporter) {
|
|
848
|
+
const { name, needsPluginFiles, drain } = reporter;
|
|
849
|
+
if (!drain) return {
|
|
850
|
+
name,
|
|
851
|
+
needsPluginFiles,
|
|
852
|
+
async report(result, context) {
|
|
853
|
+
await reporter.report(result, context);
|
|
854
|
+
}
|
|
855
|
+
};
|
|
848
856
|
const reports = [];
|
|
849
857
|
return {
|
|
850
|
-
name
|
|
851
|
-
needsPluginFiles
|
|
858
|
+
name,
|
|
859
|
+
needsPluginFiles,
|
|
852
860
|
async report(result, context) {
|
|
853
|
-
|
|
854
|
-
if (reporter.drain) reports.push(report);
|
|
861
|
+
reports.push(await reporter.report(result, context));
|
|
855
862
|
},
|
|
856
863
|
async drain(context) {
|
|
857
|
-
await
|
|
858
|
-
reports.length = 0;
|
|
864
|
+
await drain(context, reports.splice(0));
|
|
859
865
|
}
|
|
860
866
|
};
|
|
861
867
|
}
|
|
@@ -867,7 +873,7 @@ function createReporter(reporter) {
|
|
|
867
873
|
* counts, so every reporter renders the same data.
|
|
868
874
|
*/
|
|
869
875
|
function buildReport(result) {
|
|
870
|
-
const { config, diagnostics, filesCreated, status, hrStart } = result;
|
|
876
|
+
const { config, diagnostics, filesCreated, filesUnchanged = 0, status, hrStart } = result;
|
|
871
877
|
const failed = Diagnostics.failedPlugins(diagnostics);
|
|
872
878
|
const total = config.plugins?.length ?? 0;
|
|
873
879
|
const counts = Diagnostics.count(diagnostics);
|
|
@@ -886,6 +892,9 @@ function buildReport(result) {
|
|
|
886
892
|
},
|
|
887
893
|
counts,
|
|
888
894
|
filesCreated,
|
|
895
|
+
filesUnchanged,
|
|
896
|
+
fileChanges: result.fileChanges,
|
|
897
|
+
dryRun: result.dryRun,
|
|
889
898
|
durationMs: getElapsedMs(hrStart),
|
|
890
899
|
output: resolve(config.root, config.output.path),
|
|
891
900
|
timings,
|
|
@@ -895,39 +904,48 @@ function buildReport(result) {
|
|
|
895
904
|
//#endregion
|
|
896
905
|
//#region src/reporters/summary.ts
|
|
897
906
|
/**
|
|
898
|
-
*
|
|
899
|
-
*
|
|
900
|
-
* can render the same lines through whatever output it already owns.
|
|
907
|
+
* Puts the outcome first, followed by file counts, labeled plugin results, and the output path.
|
|
908
|
+
* Hosts that collect file changes get a compact diff section. Verbose output adds plugin timings.
|
|
901
909
|
*/
|
|
902
910
|
function formatSummary(report, { showTimings }) {
|
|
903
|
-
const { status, plugins, counts, filesCreated, durationMs, output, timings } = report;
|
|
904
|
-
const
|
|
911
|
+
const { status, plugins, counts, filesCreated, filesUnchanged, fileChanges, dryRun, durationMs, output, timings } = report;
|
|
912
|
+
const failed = status === "failed";
|
|
913
|
+
const successTone = counts.warnings ? "yellow" : "green";
|
|
914
|
+
const tone = failed ? "red" : successTone;
|
|
915
|
+
const title = (() => {
|
|
916
|
+
if (failed) return "✗ Generation failed";
|
|
917
|
+
if (dryRun) return "◇ Dry run complete";
|
|
918
|
+
if (counts.warnings) return "✓ Generation complete with warnings";
|
|
919
|
+
if (filesCreated > 0 && filesCreated === filesUnchanged) return "✓ Already up to date";
|
|
920
|
+
return "✓ Generation complete";
|
|
921
|
+
})();
|
|
922
|
+
const separator = styleText("dim", " · ");
|
|
923
|
+
const generated = Math.max(0, filesCreated - filesUnchanged);
|
|
924
|
+
const fileLabel = `${generated} ${generated === 1 ? "file" : "files"} ${dryRun ? "planned" : "generated"}`;
|
|
925
|
+
const lines = [
|
|
926
|
+
`${styleText(tone, title)} ${styleText("dim", formatMs(durationMs))}`,
|
|
927
|
+
"",
|
|
928
|
+
` ${styleText(generated ? "bold" : "dim", fileLabel)}${filesUnchanged ? separator + styleText("dim", `${filesUnchanged} unchanged`) : ""}`
|
|
929
|
+
];
|
|
905
930
|
const notRun = plugins.total - plugins.passed - plugins.failed.length;
|
|
906
|
-
|
|
907
|
-
styleText("green", `${plugins.passed} passed`),
|
|
908
|
-
styleText("red", `${plugins.failed.length} failed`),
|
|
931
|
+
const pluginCounts = [
|
|
932
|
+
plugins.passed > 0 ? styleText("green", `${plugins.passed} passed`) : void 0,
|
|
933
|
+
plugins.failed.length > 0 ? styleText("red", `${plugins.failed.length} failed`) : void 0,
|
|
909
934
|
notRun > 0 ? styleText("dim", `${notRun} not run`) : void 0
|
|
910
|
-
].filter(Boolean)
|
|
911
|
-
|
|
912
|
-
if (
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
const lines = rows.map(([label, value]) => `${styleText("dim", label.padStart(labelWidth))} ${value}`);
|
|
935
|
+
].filter(Boolean);
|
|
936
|
+
lines.push(` ${styleText("dim", "Plugins")} ${pluginCounts.join(separator) || styleText("dim", "none configured")}`);
|
|
937
|
+
if (plugins.failed.length) lines.push(` ${styleText("dim", "Failed plugins")} ${styleText("red", plugins.failed.join(", "))}`);
|
|
938
|
+
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);
|
|
939
|
+
if (issues.length) lines.push(` ${styleText("dim", "Issues")} ${issues.join(separator)}`);
|
|
940
|
+
const destination = relative(process.cwd(), output);
|
|
941
|
+
const displayPath = destination.startsWith("..") || isAbsolute(destination) ? output : `./${destination}`;
|
|
942
|
+
lines.push(` ${styleText("dim", failed || dryRun ? "Target" : "Output")} ${styleText(failed ? "dim" : "cyan", displayPath)}`);
|
|
943
|
+
if (dryRun) lines.push(` ${styleText("dim", "Nothing was written.")}`);
|
|
944
|
+
if (fileChanges) lines.push("", styleText("bold", dryRun ? "Planned file changes" : "File changes"), ` ${styleText(fileChanges.added ? "green" : "dim", `${fileChanges.added} added`)}${separator}${styleText(fileChanges.modified ? "yellow" : "dim", `${fileChanges.modified} modified`)}${separator}${styleText(fileChanges.deleted ? "red" : "dim", `${fileChanges.deleted} deleted`)}`, ` ${styleText("dim", "Lines")} ${styleText(fileChanges.linesAdded ? "green" : "dim", `+${fileChanges.linesAdded}`)} ${styleText(fileChanges.linesRemoved ? "red" : "dim", `−${fileChanges.linesRemoved}`)}`);
|
|
921
945
|
if (showTimings && timings.length > 0) {
|
|
922
|
-
const nameWidth = Math.max(
|
|
923
|
-
|
|
924
|
-
lines.push(styleText("dim",
|
|
925
|
-
for (const timing of timings) {
|
|
926
|
-
const timeStr = formatMs(timing.durationMs);
|
|
927
|
-
const barLength = Math.min(Math.ceil(timing.durationMs / 100), 10);
|
|
928
|
-
const bar = styleText("dim", "█".repeat(barLength));
|
|
929
|
-
lines.push(`${indent}${styleText("dim", "•")} ${timing.plugin.padEnd(nameWidth)} ${bar} ${timeStr}`);
|
|
930
|
-
}
|
|
946
|
+
const nameWidth = Math.max(...timings.map((timing) => timing.plugin.length));
|
|
947
|
+
lines.push("", styleText("dim", "Plugin timings"));
|
|
948
|
+
for (const timing of timings) lines.push(` ${timing.plugin.padEnd(nameWidth)} ${styleText("dim", formatMs(timing.durationMs))}`);
|
|
931
949
|
}
|
|
932
950
|
return lines;
|
|
933
951
|
}
|
|
@@ -1366,6 +1384,6 @@ async function readInstalledPackages({ root, packages = [], resolveFrom = [] })
|
|
|
1366
1384
|
}));
|
|
1367
1385
|
}
|
|
1368
1386
|
//#endregion
|
|
1369
|
-
export { Diagnostics, Hookable, KubbDriver, Resolver, addGenerator, addMacro, assertPluginOption, cacheStorage, checkCompatibility, cliReporter, createAdapter, createCliReporter, createKubb, createRenderer, createReporter, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, htmlReporter, injectFile, isExtensionManifest, isPackageName, isRegistryEntry, jsonReporter, kubbContext, kubbStorage, logLevel, manifestProblems, memoryStorage, readInstalledPackages, requirePlugin, resolveCacheDir, resolveKubbDir, resolveMeta, runHook, runOutputPasses, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
|
|
1387
|
+
export { Diagnostics, Hookable, KubbDriver, Resolver, addGenerator, addMacro, assertPluginOption, cacheStorage, checkCompatibility, cliReporter, createAdapter, createCliReporter, createKubb, createOutputManifest, createRenderer, createReporter, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, htmlReporter, injectFile, isExtensionManifest, isPackageName, isRegistryEntry, jsonReporter, kubbContext, kubbStorage, logLevel, manifestProblems, memoryStorage, readInstalledPackages, requirePlugin, resolveCacheDir, resolveKubbDir, resolveMeta, runHook, runOutputPasses, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
|
|
1370
1388
|
|
|
1371
1389
|
//# sourceMappingURL=index.js.map
|