@kubb/core 5.0.0-beta.40 → 5.0.0-beta.41
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/README.md +13 -13
- package/dist/{diagnostics-DhfW8YpT.d.ts → diagnostics-Ba-FcsPo.d.ts} +35 -28
- package/dist/index.cjs +4 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -19
- package/dist/index.js.map +1 -1
- package/dist/{memoryStorage-DTv1Kub1.js → memoryStorage-DA1bnMte.js} +27 -19
- package/dist/{memoryStorage-DTv1Kub1.js.map → memoryStorage-DA1bnMte.js.map} +1 -1
- package/dist/{memoryStorage-Dkxnid2K.cjs → memoryStorage-DZqlEW7H.cjs} +27 -19
- package/dist/{memoryStorage-Dkxnid2K.cjs.map → memoryStorage-DZqlEW7H.cjs.map} +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/package.json +4 -4
- package/src/KubbDriver.ts +38 -29
- package/src/createKubb.ts +24 -0
- package/src/defineLogger.ts +10 -28
- package/src/types.ts +1 -0
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
[![npm version][npm-version-src]][npm-version-href]
|
|
7
7
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
8
|
-
[![
|
|
8
|
+
[![Stars][stars-src]][stars-href]
|
|
9
9
|
[![License][license-src]][license-href]
|
|
10
|
-
[![
|
|
10
|
+
[![Node][node-src]][node-href]
|
|
11
11
|
|
|
12
12
|
<h4>
|
|
13
13
|
<a href="https://kubb.dev" target="_blank">Documentation</a>
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
Core engine for Kubb's plugin-based code generation system. Provides the plugin driver, file manager, `defineConfig`, `definePlugin`, `defineMiddleware`, and the build orchestration layer used by every Kubb plugin.
|
|
28
28
|
|
|
29
|
-
> **Note:** Most users should install the [`kubb`](https://
|
|
29
|
+
> **Note:** Most users should install the [`kubb`](https://npmx.dev/package/kubb) meta-package instead of `@kubb/core` directly. Install `@kubb/core` only when building custom plugins or extending the Kubb internals.
|
|
30
30
|
|
|
31
31
|
## Installation
|
|
32
32
|
|
|
@@ -57,13 +57,13 @@ Kubb is an open source project, and its development is funded entirely by sponso
|
|
|
57
57
|
|
|
58
58
|
<!-- Badges -->
|
|
59
59
|
|
|
60
|
-
[npm-version-src]: https://
|
|
61
|
-
[npm-version-href]: https://
|
|
62
|
-
[npm-downloads-src]: https://
|
|
63
|
-
[npm-downloads-href]: https://
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
69
|
-
[
|
|
60
|
+
[npm-version-src]: https://shieldcn.dev/npm/v/@kubb/core.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
61
|
+
[npm-version-href]: https://npmx.dev/package/@kubb/core
|
|
62
|
+
[npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/core.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
63
|
+
[npm-downloads-href]: https://npmx.dev/package/@kubb/core
|
|
64
|
+
[stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
65
|
+
[stars-href]: https://github.com/kubb-labs/kubb
|
|
66
|
+
[license-src]: https://shieldcn.dev/npm/license/@kubb/core.svg?variant=secondary&size=xs&theme=zinc
|
|
67
|
+
[license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
|
|
68
|
+
[node-src]: https://shieldcn.dev/npm/node/@kubb/core.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
69
|
+
[node-href]: https://npmx.dev/package/@kubb/core
|
|
@@ -524,27 +524,25 @@ type LoggerContext = AsyncEventEmitter<KubbHooks>;
|
|
|
524
524
|
/**
|
|
525
525
|
* Logger contract. A logger receives the build's event emitter and subscribes
|
|
526
526
|
* to whichever lifecycle events it wants to forward to its destination
|
|
527
|
-
* (console, file, remote
|
|
527
|
+
* (console, file, remote service).
|
|
528
528
|
*/
|
|
529
|
-
type Logger<TOptions extends LoggerOptions = LoggerOptions
|
|
529
|
+
type Logger<TOptions extends LoggerOptions = LoggerOptions> = {
|
|
530
530
|
/**
|
|
531
531
|
* Display name used in diagnostics.
|
|
532
532
|
*/
|
|
533
533
|
name: string;
|
|
534
534
|
/**
|
|
535
|
-
* Called once per build with the shared event emitter. Subscribe to
|
|
536
|
-
*
|
|
537
|
-
* logger, which is handy for sink factories.
|
|
535
|
+
* Called once per build with the shared event emitter. Subscribe to the
|
|
536
|
+
* lifecycle events the logger wants to forward to its destination.
|
|
538
537
|
*/
|
|
539
|
-
install: (context: LoggerContext, options?: TOptions) =>
|
|
538
|
+
install: (context: LoggerContext, options?: TOptions) => void | Promise<void>;
|
|
540
539
|
};
|
|
541
|
-
type UserLogger<TOptions extends LoggerOptions = LoggerOptions
|
|
540
|
+
type UserLogger<TOptions extends LoggerOptions = LoggerOptions> = Logger<TOptions>;
|
|
542
541
|
/**
|
|
543
|
-
* Defines a typed logger.
|
|
544
|
-
*
|
|
545
|
-
* or cleanup callback to the caller.
|
|
542
|
+
* Defines a typed logger. The `install` method subscribes to lifecycle events
|
|
543
|
+
* on the shared emitter and forwards them to the logger's destination.
|
|
546
544
|
*
|
|
547
|
-
* @example
|
|
545
|
+
* @example
|
|
548
546
|
* ```ts
|
|
549
547
|
* import { defineLogger } from '@kubb/core'
|
|
550
548
|
*
|
|
@@ -556,22 +554,8 @@ type UserLogger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn =
|
|
|
556
554
|
* },
|
|
557
555
|
* })
|
|
558
556
|
* ```
|
|
559
|
-
*
|
|
560
|
-
* @example Logger that returns a hook sink factory
|
|
561
|
-
* ```ts
|
|
562
|
-
* import { defineLogger, type LoggerOptions } from '@kubb/core'
|
|
563
|
-
* import type { HookSinkFactory } from './sinks'
|
|
564
|
-
*
|
|
565
|
-
* export const myLogger = defineLogger<LoggerOptions, HookSinkFactory>({
|
|
566
|
-
* name: 'my-logger',
|
|
567
|
-
* install(context) {
|
|
568
|
-
* // … register event handlers …
|
|
569
|
-
* return () => ({ onStdout: console.log })
|
|
570
|
-
* },
|
|
571
|
-
* })
|
|
572
|
-
* ```
|
|
573
557
|
*/
|
|
574
|
-
declare function defineLogger<Options extends LoggerOptions = LoggerOptions
|
|
558
|
+
declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(logger: UserLogger<Options>): Logger<Options>;
|
|
575
559
|
//#endregion
|
|
576
560
|
//#region src/createReporter.d.ts
|
|
577
561
|
/**
|
|
@@ -2218,6 +2202,7 @@ interface KubbHooks {
|
|
|
2218
2202
|
'kubb:hooks:start': [];
|
|
2219
2203
|
'kubb:hooks:end': [];
|
|
2220
2204
|
'kubb:hook:start': [ctx: KubbHookStartContext];
|
|
2205
|
+
'kubb:hook:line': [ctx: KubbHookLineContext];
|
|
2221
2206
|
'kubb:hook:end': [ctx: KubbHookEndContext];
|
|
2222
2207
|
'kubb:info': [ctx: KubbInfoContext];
|
|
2223
2208
|
'kubb:error': [ctx: KubbErrorContext];
|
|
@@ -2454,6 +2439,20 @@ type KubbHookStartContext = {
|
|
|
2454
2439
|
*/
|
|
2455
2440
|
args?: ReadonlyArray<string>;
|
|
2456
2441
|
};
|
|
2442
|
+
/**
|
|
2443
|
+
* Emitted for each line streamed from a hook's stdout while it runs.
|
|
2444
|
+
* A logger correlates the line to its active UI element via `id`.
|
|
2445
|
+
*/
|
|
2446
|
+
type KubbHookLineContext = {
|
|
2447
|
+
/**
|
|
2448
|
+
* Identifier matching the corresponding `kubb:hook:start` event.
|
|
2449
|
+
*/
|
|
2450
|
+
id: string;
|
|
2451
|
+
/**
|
|
2452
|
+
* A single streamed stdout line, without its trailing newline.
|
|
2453
|
+
*/
|
|
2454
|
+
line: string;
|
|
2455
|
+
};
|
|
2457
2456
|
type KubbHookEndContext = {
|
|
2458
2457
|
/**
|
|
2459
2458
|
* Optional identifier matching the corresponding `kubb:hook:start` event.
|
|
@@ -2475,6 +2474,14 @@ type KubbHookEndContext = {
|
|
|
2475
2474
|
* Error thrown by the command, or `null` on success.
|
|
2476
2475
|
*/
|
|
2477
2476
|
error: Error | null;
|
|
2477
|
+
/**
|
|
2478
|
+
* Captured stdout from the process, populated when it exits non-zero.
|
|
2479
|
+
*/
|
|
2480
|
+
stdout?: string;
|
|
2481
|
+
/**
|
|
2482
|
+
* Captured stderr from the process, populated when it exits non-zero.
|
|
2483
|
+
*/
|
|
2484
|
+
stderr?: string;
|
|
2478
2485
|
};
|
|
2479
2486
|
/**
|
|
2480
2487
|
* CLI options derived from command-line flags.
|
|
@@ -2959,5 +2966,5 @@ declare class Diagnostics {
|
|
|
2959
2966
|
static formatLines(diagnostic: Diagnostic): Array<string>;
|
|
2960
2967
|
}
|
|
2961
2968
|
//#endregion
|
|
2962
|
-
export {
|
|
2963
|
-
//# sourceMappingURL=diagnostics-
|
|
2969
|
+
export { Output as $, KubbHookEndContext as A, defineLogger as At, UserConfig as B, createAdapter as Bt, KubbErrorContext as C, UserReporter as Ct, KubbFilesProcessingUpdateContext as D, LoggerContext as Dt, KubbFilesProcessingStartContext as E, Logger as Et, KubbLifecycleStartContext as F, Storage as Ft, KubbDriver as G, Generator$1 as H, KubbPluginsEndContext as I, createStorage as It, Include as J, Exclude$1 as K, KubbSuccessContext as L, Adapter as Lt, KubbHookStartContext as M, Renderer as Mt, KubbHooks as N, RendererFactory as Nt, KubbGenerationEndContext as O, LoggerOptions as Ot, KubbInfoContext as P, createRenderer as Pt, NormalizedPlugin as Q, KubbWarnContext as R, AdapterFactoryOptions as Rt, KubbDiagnosticContext as S, ReporterName as St, KubbFilesProcessingEndContext as T, selectReporters as Tt, GeneratorContext as U, createKubb as V, AsyncEventEmitter as Vt, defineGenerator as W, KubbPluginSetupContext as X, KubbPluginEndContext as Y, KubbPluginStartContext as Z, InputPath as _, Parser as _t, DiagnosticLocation as a, ResolveBannerContext as at, KubbBuildStartContext as b, Reporter as bt, PerformanceDiagnostic as c, Resolver as ct, SerializedDiagnostic as d, ResolverPathParams as dt, Override as et, UpdateDiagnostic as f, defineResolver as ft, InputData as g, ParsedFile as gt, Config as h, FileProcessorHooks as ht, DiagnosticKind as i, BannerMeta as it, KubbHookLineContext as j, logLevel as jt, KubbGenerationStartContext as k, UserLogger as kt, ProblemCode as l, ResolverContext as lt, CLIOptions as m, defineMiddleware as mt, DiagnosticByCode as n, PluginFactoryOptions as nt, DiagnosticSeverity as o, ResolveBannerFile as ot, BuildOutput as p, Middleware as pt, Group as q, DiagnosticDoc as r, definePlugin as rt, Diagnostics as s, ResolveOptionsContext as st, Diagnostic as t, Plugin as tt, ProblemDiagnostic as u, ResolverFileParams as ut, Kubb$1 as v, defineParser as vt, KubbFileProcessingUpdate as w, createReporter as wt, KubbConfigEndContext as x, ReporterContext as xt, KubbBuildEndContext as y, GenerationResult as yt, PossibleConfig as z, AdapterSource as zt };
|
|
2970
|
+
//# sourceMappingURL=diagnostics-Ba-FcsPo.d.ts.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_memoryStorage = require("./memoryStorage-
|
|
2
|
+
const require_memoryStorage = require("./memoryStorage-DZqlEW7H.cjs");
|
|
3
3
|
let node_util = require("node:util");
|
|
4
4
|
let node_crypto = require("node:crypto");
|
|
5
5
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -531,11 +531,10 @@ const logLevel = {
|
|
|
531
531
|
verbose: 4
|
|
532
532
|
};
|
|
533
533
|
/**
|
|
534
|
-
* Defines a typed logger.
|
|
535
|
-
*
|
|
536
|
-
* or cleanup callback to the caller.
|
|
534
|
+
* Defines a typed logger. The `install` method subscribes to lifecycle events
|
|
535
|
+
* on the shared emitter and forwards them to the logger's destination.
|
|
537
536
|
*
|
|
538
|
-
* @example
|
|
537
|
+
* @example
|
|
539
538
|
* ```ts
|
|
540
539
|
* import { defineLogger } from '@kubb/core'
|
|
541
540
|
*
|
|
@@ -547,20 +546,6 @@ const logLevel = {
|
|
|
547
546
|
* },
|
|
548
547
|
* })
|
|
549
548
|
* ```
|
|
550
|
-
*
|
|
551
|
-
* @example Logger that returns a hook sink factory
|
|
552
|
-
* ```ts
|
|
553
|
-
* import { defineLogger, type LoggerOptions } from '@kubb/core'
|
|
554
|
-
* import type { HookSinkFactory } from './sinks'
|
|
555
|
-
*
|
|
556
|
-
* export const myLogger = defineLogger<LoggerOptions, HookSinkFactory>({
|
|
557
|
-
* name: 'my-logger',
|
|
558
|
-
* install(context) {
|
|
559
|
-
* // … register event handlers …
|
|
560
|
-
* return () => ({ onStdout: console.log })
|
|
561
|
-
* },
|
|
562
|
-
* })
|
|
563
|
-
* ```
|
|
564
549
|
*/
|
|
565
550
|
function defineLogger(logger) {
|
|
566
551
|
return logger;
|