@kubb/core 5.14.6 → 5.15.1
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-CyMsl7Bl.js → Hookable-C9bM5HsI.js} +86 -74
- package/dist/Hookable-C9bM5HsI.js.map +1 -0
- package/dist/{createAdapter-BD4waEKc.d.ts → createAdapter-CCe-Oddm.d.ts} +35 -49
- package/dist/html/ui.iife.js +3 -3
- package/dist/index.cjs +128 -124
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -85
- package/dist/index.d.ts +38 -39
- package/dist/index.js +45 -56
- package/dist/index.js.map +1 -1
- package/dist/mocks.d.ts +1 -3
- package/dist/mocks.js +10 -6
- package/dist/mocks.js.map +1 -1
- package/package.json +2 -2
- package/dist/Hookable-CyMsl7Bl.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,37 @@
|
|
|
1
|
-
import { $ as defineGenerator, $t as
|
|
1
|
+
import { $ as defineGenerator, $t as GenerationResult, A as PluginFactory, At as KubbHooks, B as ResolveImportsOptions, Bt as HookResult, C as NormalizedPlugin, Ct as KubbFilesProcessingUpdateContext, D as Override, Dt as KubbHookEndContext, E as OutputOptions, Et as KubbGenerationSummaryContext, F as definePlugin, Ft as KubbSuccessContext, G as ResolverFile, Gt as Hookable, H as ResolvePathOptions, Ht as runHook, I as BannerMeta, It as KubbWarnContext, J as ResolverPatch, Jt as Renderer, K as ResolverFileParams, Kt as OutputManifest, L as ResolveBannerContext, Lt as PossibleConfig, M as PluginType, Mt as KubbLifecycleStartContext, N as ResolvePluginOptions, Nt as KubbMessageContext, O as Plugin, Ot as KubbHookLineContext, P as assertPluginOption, Pt as KubbPluginsEndContext, Q as GeneratorContext, Qt as createStorage, R as ResolveBannerFile, Rt as PostGenerateCommand, S as KubbPluginStartContext, St as KubbFilesProcessingStartContext, T as OutputMode, Tt as KubbGenerationStartContext, U as Resolver, Ut as KubbDriver, V as ResolveNameOptions, Vt as RunHookOptions, W as ResolverDefault, Wt as Memo, X as ResolveOptionsContext, Xt as createRenderer, Y as ResolverPathParams, Yt as RendererFactory, Z as Generator, Zt as Storage, _ as Filter, _t as KubbBuildStartContext, a as AdapterSource, an as createReporter, at as DiagnosticSeverity, b as KubbPluginEndContext, bt as KubbFileProcessingUpdate, c as ExtensionDependency, cn as SerializedDiagnostic, ct as ProblemCode, d as ExtensionKind, dn as ParserFactory, dt as BuildOutput, en as Reporter, et as NodeCache, f as ExtensionMeta, fn as defineParser, ft as CLIOptions, g as Exclude, gt as KubbBuildEndContext, h as resolveMeta, ht as Input, i as AdapterFactoryOptions, in as UserReporter, it as DiagnosticLocation, j as PluginName, jt as KubbInfoContext, k as PluginDefinition, kt as KubbHookStartContext, l as ExtensionDependencyRecord, ln as Parser, lt as ProblemDiagnostic, m as defineExtension, mt as FilesContext, n as AdapterDefinition, nn as ReporterName, nt as DiagnosticDoc, o as createAdapter, on as logLevel, ot as Diagnostics, p as checkCompatibility, pt as Config, q as ResolverFilePathParams, qt as createOutputManifest, r as AdapterFactory, rn as ReporterPluginFiles, rt as DiagnosticKind, s as ExtensionDependencies, sn as DiagnosticFormatOptions, st as PerformanceDiagnostic, t as Adapter, tn as ReporterContext, tt as Diagnostic, u as ExtensionFactory, un as ParserDefinition, ut as UpdateDiagnostic, v as Group, vt as KubbDiagnosticContext, w as Output, wt as KubbGenerationEndContext, x as KubbPluginSetupContext, xt as KubbFilesProcessingEndContext, y as Include, yt as KubbErrorContext, z as ResolveFileOptions, zt as UserConfig } from "./createAdapter-CCe-Oddm.js";
|
|
2
2
|
import { FileNode, Macro, UserFileNode } from "@kubb/ast";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import net from "node:net";
|
|
5
|
-
|
|
5
|
+
type Options = {
|
|
6
|
+
/**
|
|
7
|
+
* Text prepended before casing is applied.
|
|
8
|
+
*/
|
|
9
|
+
prefix?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Text appended before casing is applied.
|
|
12
|
+
*/
|
|
13
|
+
suffix?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Converts `text` to camelCase.
|
|
17
|
+
*
|
|
18
|
+
* @example Word boundaries
|
|
19
|
+
* `camelCase('hello-world') // 'helloWorld'`
|
|
20
|
+
*
|
|
21
|
+
* @example With a prefix
|
|
22
|
+
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
23
|
+
*/
|
|
24
|
+
export declare function camelCase(text: string, { prefix, suffix }?: Options): string;
|
|
25
|
+
/**
|
|
26
|
+
* Converts `text` to PascalCase.
|
|
27
|
+
*
|
|
28
|
+
* @example Word boundaries
|
|
29
|
+
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
30
|
+
*
|
|
31
|
+
* @example With a suffix
|
|
32
|
+
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
33
|
+
*/
|
|
34
|
+
export declare function pascalCase(text: string, { prefix, suffix }?: Options): string;
|
|
6
35
|
/**
|
|
7
36
|
* Holds the setup context of the plugin whose `setup` or `kubb:plugin:setup` is running. `KubbDriver` sets it for each plugin.
|
|
8
37
|
*
|
|
@@ -42,6 +71,10 @@ export declare function setMacros(macros: ReadonlyArray<Macro>): void;
|
|
|
42
71
|
* Adds a raw file to the build output, like `ctx.injectFile`.
|
|
43
72
|
*/
|
|
44
73
|
export declare function injectFile(file: UserFileNode): void;
|
|
74
|
+
/**
|
|
75
|
+
* Returns a value computed once per build and shared by every plugin, like `ctx.memo`.
|
|
76
|
+
*/
|
|
77
|
+
export declare const memo: Memo;
|
|
45
78
|
/**
|
|
46
79
|
* Returns the options the user passed to the plugin being set up, like `ctx.options`.
|
|
47
80
|
*/
|
|
@@ -58,8 +91,6 @@ export declare function useConfig(): Config;
|
|
|
58
91
|
* Returns another plugin from the config, typed through `Kubb.PluginRegistry`, like `ctx.requirePlugin`.
|
|
59
92
|
*/
|
|
60
93
|
export declare function requirePlugin<TName extends PluginName>(name: TName): NormalizedPlugin<ResolvePluginOptions<TName>>;
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/output/runOutputPasses.d.ts
|
|
63
94
|
type RunOutputPassesOptions = {
|
|
64
95
|
config: Config;
|
|
65
96
|
/**
|
|
@@ -82,8 +113,6 @@ type RunOutputPassesOptions = {
|
|
|
82
113
|
* ```
|
|
83
114
|
*/
|
|
84
115
|
export declare function runOutputPasses({ config, outputPath, hooks, signal }: RunOutputPassesOptions): Promise<Array<Diagnostic>>;
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/createKubb.d.ts
|
|
87
116
|
type CreateKubbOptions = {
|
|
88
117
|
/**
|
|
89
118
|
* Receives Kubb lifecycle hooks for the run.
|
|
@@ -199,8 +228,6 @@ declare class Kubb {
|
|
|
199
228
|
* ```
|
|
200
229
|
*/
|
|
201
230
|
export declare function createKubb(userConfig: UserConfig, options?: CreateKubbOptions): Kubb;
|
|
202
|
-
//#endregion
|
|
203
|
-
//#region src/reporters/summary.d.ts
|
|
204
231
|
/**
|
|
205
232
|
* Writes the summary through the host's output, or plain console lines by default.
|
|
206
233
|
*/
|
|
@@ -208,8 +235,6 @@ type SummaryRenderer = (lines: ReadonlyArray<string>, meta: {
|
|
|
208
235
|
title: string;
|
|
209
236
|
status: 'success' | 'failed';
|
|
210
237
|
}) => void;
|
|
211
|
-
//#endregion
|
|
212
|
-
//#region src/reporters/cliReporter.d.ts
|
|
213
238
|
/**
|
|
214
239
|
* Builds a `cli` reporter that renders the {@link Report} for each config as it finishes.
|
|
215
240
|
* Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
|
|
@@ -230,8 +255,6 @@ export declare function createCliReporter({ render }?: {
|
|
|
230
255
|
* logger view.
|
|
231
256
|
*/
|
|
232
257
|
export declare const cliReporter: Reporter;
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region src/reporters/fileReporter.d.ts
|
|
235
258
|
/**
|
|
236
259
|
* The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
|
|
237
260
|
* plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same lines the
|
|
@@ -243,8 +266,6 @@ export declare const cliReporter: Reporter;
|
|
|
243
266
|
* the run is attached to a TTY.
|
|
244
267
|
*/
|
|
245
268
|
export declare const fileReporter: Reporter;
|
|
246
|
-
//#endregion
|
|
247
|
-
//#region src/reporters/jsonReporter.d.ts
|
|
248
269
|
/**
|
|
249
270
|
* The `json` reporter. `report` returns one config's {@link Report}, which {@link createReporter}
|
|
250
271
|
* buffers, and `drain` writes them as a single pretty-printed JSON array on `kubb:lifecycle:end`.
|
|
@@ -253,14 +274,10 @@ export declare const fileReporter: Reporter;
|
|
|
253
274
|
* stdout stays valid JSON.
|
|
254
275
|
*/
|
|
255
276
|
export declare const jsonReporter: Reporter;
|
|
256
|
-
//#endregion
|
|
257
|
-
//#region src/reporters/htmlReporter.d.ts
|
|
258
277
|
/**
|
|
259
278
|
* Writes a static HTML report directory selected with `--reporter html`.
|
|
260
279
|
*/
|
|
261
280
|
export declare const htmlReporter: Reporter;
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/createResolver.d.ts
|
|
264
281
|
/**
|
|
265
282
|
* The plugin-specific resolver fields handed to `createResolver`. `name` and `file` fall
|
|
266
283
|
* back to the built-ins when omitted. Every method reaches sibling helpers through `this`,
|
|
@@ -283,7 +300,7 @@ type ResolverOptions<T extends PluginType> = Omit<T['resolver'], keyof Resolver>
|
|
|
283
300
|
* export const resolverTs = createResolver<PluginTs>({
|
|
284
301
|
* pluginName: 'plugin-ts',
|
|
285
302
|
* name(name) {
|
|
286
|
-
* return ensureValidVarName(pascalCase(name))
|
|
303
|
+
* return this.memo(`name:${name}`, () => ensureValidVarName(pascalCase(name)))
|
|
287
304
|
* },
|
|
288
305
|
* })
|
|
289
306
|
* ```
|
|
@@ -316,8 +333,6 @@ type ResolverOptions<T extends PluginType> = Omit<T['resolver'], keyof Resolver>
|
|
|
316
333
|
* ```
|
|
317
334
|
*/
|
|
318
335
|
export declare function createResolver<T extends PluginType>(options: ResolverOptions<T>): T['resolver'];
|
|
319
|
-
//#endregion
|
|
320
|
-
//#region src/gitInput.d.ts
|
|
321
336
|
/**
|
|
322
337
|
* Fetches one commit of a git repository into a temporary directory with a shallow `git fetch`,
|
|
323
338
|
* so any host and the user's own git credentials work, and relative `$ref` files resolve.
|
|
@@ -334,16 +349,12 @@ export declare function checkoutGitInput(input: string, signal?: AbortSignal, {
|
|
|
334
349
|
path: string;
|
|
335
350
|
dispose: () => Promise<void>;
|
|
336
351
|
}>;
|
|
337
|
-
//#endregion
|
|
338
|
-
//#region src/publicAddress.d.ts
|
|
339
352
|
/**
|
|
340
353
|
* Whether `address` is a routable public IP. Loopback, private, link-local, cloud metadata, and
|
|
341
354
|
* multicast ranges are not, and an IPv4-mapped IPv6 address counts as the IPv4 address it wraps.
|
|
342
355
|
* Pass `blocked` to replace the ranges.
|
|
343
356
|
*/
|
|
344
357
|
export declare function isPublicAddress(address: string, blocked?: net.BlockList): boolean;
|
|
345
|
-
//#endregion
|
|
346
|
-
//#region src/input.d.ts
|
|
347
358
|
/**
|
|
348
359
|
* What an `input` value points at, once Kubb has looked at it.
|
|
349
360
|
*
|
|
@@ -363,8 +374,6 @@ type InputKind = 'file' | 'url' | 'git' | 'inline' | 'object';
|
|
|
363
374
|
* one, or a `file` path.
|
|
364
375
|
*/
|
|
365
376
|
export declare function getInputKind(input: NonNullable<Input>): InputKind;
|
|
366
|
-
//#endregion
|
|
367
|
-
//#region src/storages/cacheStorage.d.ts
|
|
368
377
|
type CacheStorageOptions = {
|
|
369
378
|
/**
|
|
370
379
|
* Project root the cache directory is derived from.
|
|
@@ -395,8 +404,6 @@ export declare function resolveCacheDir(root: string): string;
|
|
|
395
404
|
* ```
|
|
396
405
|
*/
|
|
397
406
|
export declare const cacheStorage: (options?: CacheStorageOptions | undefined) => import("@kubb/kit").Storage;
|
|
398
|
-
//#endregion
|
|
399
|
-
//#region src/storages/fsStorage.d.ts
|
|
400
407
|
/**
|
|
401
408
|
* Built-in filesystem storage driver.
|
|
402
409
|
*
|
|
@@ -410,6 +417,7 @@ export declare const cacheStorage: (options?: CacheStorageOptions | undefined) =
|
|
|
410
417
|
* a formatter left behind
|
|
411
418
|
* - missing parent directories are created automatically
|
|
412
419
|
* - `FileManager.write` bounds in-flight writes, so this driver does not pace itself
|
|
420
|
+
* - `empty` moves the directory aside and deletes it in the background
|
|
413
421
|
*
|
|
414
422
|
* @example
|
|
415
423
|
* ```ts
|
|
@@ -424,8 +432,6 @@ export declare const cacheStorage: (options?: CacheStorageOptions | undefined) =
|
|
|
424
432
|
* ```
|
|
425
433
|
*/
|
|
426
434
|
export declare const fsStorage: (options?: Record<string, never> | undefined) => import("@kubb/kit").Storage;
|
|
427
|
-
//#endregion
|
|
428
|
-
//#region src/storages/kubbStorage.d.ts
|
|
429
435
|
type KubbStorageOptions = {
|
|
430
436
|
/**
|
|
431
437
|
* Folder inside the Kubb home, or an absolute path such as `<cwd>/.kubb`.
|
|
@@ -456,8 +462,6 @@ export declare function kubbStorage({ base }?: KubbStorageOptions): {
|
|
|
456
462
|
setItem(key: string, value: unknown): Promise<void>;
|
|
457
463
|
removeItem(key: string): Promise<void>;
|
|
458
464
|
};
|
|
459
|
-
//#endregion
|
|
460
|
-
//#region src/storages/memoryStorage.d.ts
|
|
461
465
|
/**
|
|
462
466
|
* In-memory storage driver. Useful for testing and dry-run scenarios where
|
|
463
467
|
* generated output should be captured without touching the filesystem.
|
|
@@ -478,8 +482,6 @@ export declare function kubbStorage({ base }?: KubbStorageOptions): {
|
|
|
478
482
|
* ```
|
|
479
483
|
*/
|
|
480
484
|
export declare const memoryStorage: (options?: Record<string, never> | undefined) => import("@kubb/kit").Storage;
|
|
481
|
-
//#endregion
|
|
482
|
-
//#region src/manifest.d.ts
|
|
483
485
|
/** A value that survives `JSON.stringify` and `JSON.parse` unchanged. */
|
|
484
486
|
type JSONValue = string | number | boolean | null | Array<JSONValue> | {
|
|
485
487
|
[key: string]: JSONValue;
|
|
@@ -629,8 +631,6 @@ export declare function isExtensionManifest(value: unknown): value is ExtensionM
|
|
|
629
631
|
* an npm or GitHub artifact pinned to a valid version, and a valid manifest of the entry's kind.
|
|
630
632
|
*/
|
|
631
633
|
export declare function isRegistryEntry(value: unknown): value is RegistryEntry;
|
|
632
|
-
//#endregion
|
|
633
|
-
//#region src/installedPackages.d.ts
|
|
634
634
|
type InstalledPackage = {
|
|
635
635
|
package: string;
|
|
636
636
|
version?: string;
|
|
@@ -647,6 +647,5 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
|
|
|
647
647
|
packages?: Iterable<string>;
|
|
648
648
|
resolveFrom?: Array<string>;
|
|
649
649
|
}): Promise<Array<InstalledPackage>>;
|
|
650
|
-
|
|
651
|
-
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 ResolveNameOptions, 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 };
|
|
650
|
+
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 Memo, 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 ResolveNameOptions, 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 };
|
|
652
651
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as resolveMeta, B as rm$1, C as setResolver, D as useOptions, E as useKubb, F as exists, G as pascalCase, H as writeRaw, I as existsSync$1, L as isPathInside, M as formatMs, N as getElapsedMs, O as checkCompatibility, P as inParallel, R as listFiles, S as setOptions, T as useConfig, U as toError, V as write, W as camelCase, _ as injectFile, b as requirePlugin, c as Resolver, d as isPublicAddress, g as addMacro, h as addGenerator, j as Diagnostics, k as defineExtension, l as getInputKind, m as definePlugin, n as KubbDriver, o as _usingCtx, p as assertPluginOption, s as createResolver, t as Hookable, u as checkoutGitInput, v as kubbContext, w as tryUseKubb, x as setMacros, y as memo, z as read } from "./Hookable-C9bM5HsI.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
|
-
import { readFile } from "node:fs/promises";
|
|
7
|
-
import path, { isAbsolute, join, relative, resolve } from "node:path";
|
|
6
|
+
import { readFile, readdir, rename } from "node:fs/promises";
|
|
7
|
+
import path, { basename, dirname, 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 { homedir, tmpdir } from "node:os";
|
|
11
11
|
import { hash, randomUUID } from "node:crypto";
|
|
12
12
|
import { createInterface } from "node:readline";
|
|
13
13
|
import { fileURLToPath } from "node:url";
|
|
14
|
-
|
|
14
|
+
// ../../internals/utils/src/isCIEnvironment.ts
|
|
15
15
|
/**
|
|
16
16
|
* Returns `true` when a known CI provider has set its environment variable.
|
|
17
17
|
* `CI=false` and `CI=0` count as not CI, so a user can opt out locally.
|
|
@@ -20,8 +20,7 @@ function isCIEnvironment() {
|
|
|
20
20
|
const ci = process$1.env.CI;
|
|
21
21
|
return !!(ci && ci !== "false" && ci !== "0" || process$1.env.GITHUB_ACTIONS || process$1.env.GITLAB_CI || process$1.env.BITBUCKET_BUILD_NUMBER || process$1.env.JENKINS_URL || process$1.env.CIRCLECI || process$1.env.TRAVIS || process$1.env.TEAMCITY_VERSION || process$1.env.BUILDKITE || process$1.env.TF_BUILD);
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
//#region ../../internals/utils/src/openInBrowser.ts
|
|
23
|
+
// ../../internals/utils/src/openInBrowser.ts
|
|
25
24
|
const ignore = () => {};
|
|
26
25
|
/**
|
|
27
26
|
* Opens a URL or local file in the default browser, unless running in CI.
|
|
@@ -39,8 +38,7 @@ function openInBrowser(target) {
|
|
|
39
38
|
}
|
|
40
39
|
x(process$1.platform === "darwin" ? "open" : "xdg-open", [target]).then(ignore, ignore);
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
//#region ../../internals/utils/src/tools.ts
|
|
41
|
+
// ../../internals/utils/src/tools.ts
|
|
44
42
|
/**
|
|
45
43
|
* CLI command descriptors for each supported code formatter.
|
|
46
44
|
*/
|
|
@@ -148,8 +146,7 @@ async function detectTool(candidates, cwd) {
|
|
|
148
146
|
function tokenize(command) {
|
|
149
147
|
return (command.match(/[^\s"']+|"([^"]*)"|'([^']*)'/g) ?? []).map((token) => token.replace(/^["']|["']$/g, ""));
|
|
150
148
|
}
|
|
151
|
-
|
|
152
|
-
//#region src/createAdapter.ts
|
|
149
|
+
// src/createAdapter.ts
|
|
153
150
|
/**
|
|
154
151
|
* Defines a custom adapter that translates a spec format into Kubb's universal
|
|
155
152
|
* AST, for example GraphQL, gRPC, or AsyncAPI. The built-in `@kubb/adapter-oas`
|
|
@@ -166,8 +163,7 @@ function createAdapter(definition) {
|
|
|
166
163
|
...definition
|
|
167
164
|
});
|
|
168
165
|
}
|
|
169
|
-
|
|
170
|
-
//#region src/outputManifest.ts
|
|
166
|
+
// src/outputManifest.ts
|
|
171
167
|
/**
|
|
172
168
|
* Bumped when the stored shape changes, so an older cache is discarded instead of misread.
|
|
173
169
|
*/
|
|
@@ -229,8 +225,7 @@ async function createOutputManifest({ storage, cache }) {
|
|
|
229
225
|
}
|
|
230
226
|
};
|
|
231
227
|
}
|
|
232
|
-
|
|
233
|
-
//#region src/createStorage.ts
|
|
228
|
+
// src/createStorage.ts
|
|
234
229
|
/**
|
|
235
230
|
* Defines a custom storage backend. The builder receives user options and
|
|
236
231
|
* returns a `Storage` implementation. Kubb ships with filesystem and in-memory
|
|
@@ -267,8 +262,7 @@ async function createOutputManifest({ storage, cache }) {
|
|
|
267
262
|
* ```
|
|
268
263
|
*/
|
|
269
264
|
const createStorage = (build) => (options) => build(options ?? {});
|
|
270
|
-
|
|
271
|
-
//#region src/storages/fsStorage.ts
|
|
265
|
+
// src/storages/fsStorage.ts
|
|
272
266
|
/**
|
|
273
267
|
* Built-in filesystem storage driver.
|
|
274
268
|
*
|
|
@@ -282,6 +276,7 @@ const createStorage = (build) => (options) => build(options ?? {});
|
|
|
282
276
|
* a formatter left behind
|
|
283
277
|
* - missing parent directories are created automatically
|
|
284
278
|
* - `FileManager.write` bounds in-flight writes, so this driver does not pace itself
|
|
279
|
+
* - `empty` moves the directory aside and deletes it in the background
|
|
285
280
|
*
|
|
286
281
|
* @example
|
|
287
282
|
* ```ts
|
|
@@ -323,14 +318,26 @@ const fsStorage = createStorage(() => ({
|
|
|
323
318
|
},
|
|
324
319
|
async empty(base) {
|
|
325
320
|
if (!base) return;
|
|
326
|
-
|
|
321
|
+
const dir = resolve(base);
|
|
322
|
+
const parent = dirname(dir);
|
|
323
|
+
const prefix = `.${basename(dir)}.kubb-old-`;
|
|
324
|
+
try {
|
|
325
|
+
await rename(dir, join(parent, `${prefix}${process.pid}-${Date.now()}`));
|
|
326
|
+
} catch (_error) {
|
|
327
|
+
await rm$1(dir, {
|
|
328
|
+
recursive: true,
|
|
329
|
+
force: true
|
|
330
|
+
});
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const trash = (await readdir(parent)).filter((name) => name.startsWith(prefix));
|
|
334
|
+
Promise.all(trash.map((name) => rm$1(join(parent, name), {
|
|
327
335
|
recursive: true,
|
|
328
336
|
force: true
|
|
329
|
-
});
|
|
337
|
+
}))).catch(() => {});
|
|
330
338
|
}
|
|
331
339
|
}));
|
|
332
|
-
|
|
333
|
-
//#region src/storages/cacheStorage.ts
|
|
340
|
+
// src/storages/cacheStorage.ts
|
|
334
341
|
/**
|
|
335
342
|
* Directory Kubb keeps build caches in. A project with a `node_modules` gets
|
|
336
343
|
* `node_modules/.cache/kubb`, the convention babel and eslint already use, so the cache stays out
|
|
@@ -372,8 +379,7 @@ const cacheStorage = createStorage(({ root = process.cwd() }) => {
|
|
|
372
379
|
empty: async (base) => base ? fs.empty(toPath(base)) : void 0
|
|
373
380
|
};
|
|
374
381
|
});
|
|
375
|
-
|
|
376
|
-
//#region src/output/runHook.ts
|
|
382
|
+
// src/output/runHook.ts
|
|
377
383
|
const KILL_GRACE_MS = 2e3;
|
|
378
384
|
async function settle(proc, hooks, id, commandWithArgs) {
|
|
379
385
|
let childError = null;
|
|
@@ -452,8 +458,7 @@ async function runHook({ hooks, command, args = [], name, cwd = process$1.cwd(),
|
|
|
452
458
|
});
|
|
453
459
|
return result;
|
|
454
460
|
}
|
|
455
|
-
|
|
456
|
-
//#region src/output/runOutputPasses.ts
|
|
461
|
+
// src/output/runOutputPasses.ts
|
|
457
462
|
/**
|
|
458
463
|
* Format and lint are one pass over the output directory that differs only in these values.
|
|
459
464
|
* `label` and `verb` are spelled out: deriving them from `kind` gives "lintter" and "lintting".
|
|
@@ -565,8 +570,7 @@ async function runOutputPasses({ config, outputPath, hooks, signal }) {
|
|
|
565
570
|
await hooks.callHook("kubb:hooks:end");
|
|
566
571
|
return diagnostics;
|
|
567
572
|
}
|
|
568
|
-
|
|
569
|
-
//#region src/createKubb.ts
|
|
573
|
+
// src/createKubb.ts
|
|
570
574
|
function resolveConfig(userConfig) {
|
|
571
575
|
return {
|
|
572
576
|
...userConfig,
|
|
@@ -807,8 +811,7 @@ var Kubb = class {
|
|
|
807
811
|
function createKubb(userConfig, options = {}) {
|
|
808
812
|
return new Kubb(userConfig, options);
|
|
809
813
|
}
|
|
810
|
-
|
|
811
|
-
//#region src/createReporter.ts
|
|
814
|
+
// src/createReporter.ts
|
|
812
815
|
/**
|
|
813
816
|
* Numeric log-level thresholds used internally to compare verbosity.
|
|
814
817
|
*
|
|
@@ -863,8 +866,7 @@ function createReporter(reporter) {
|
|
|
863
866
|
}
|
|
864
867
|
};
|
|
865
868
|
}
|
|
866
|
-
|
|
867
|
-
//#region src/reporters/report.ts
|
|
869
|
+
// src/reporters/report.ts
|
|
868
870
|
/**
|
|
869
871
|
* Builds the normalized {@link Report} for one config from its {@link GenerationResult}. Splits the
|
|
870
872
|
* diagnostics into problems and per-plugin timings (slowest first) and derives the plugin and issue
|
|
@@ -899,8 +901,7 @@ function buildReport(result) {
|
|
|
899
901
|
diagnostics: problems.map((diagnostic) => Diagnostics.serialize(diagnostic))
|
|
900
902
|
};
|
|
901
903
|
}
|
|
902
|
-
|
|
903
|
-
//#region src/reporters/summary.ts
|
|
904
|
+
// src/reporters/summary.ts
|
|
904
905
|
/**
|
|
905
906
|
* Puts the outcome first, followed by file counts, labeled plugin results, and the output path.
|
|
906
907
|
* Hosts that collect file changes get a compact diff section. Verbose output adds plugin timings.
|
|
@@ -947,8 +948,7 @@ function formatSummary(report, { showTimings }) {
|
|
|
947
948
|
}
|
|
948
949
|
return lines;
|
|
949
950
|
}
|
|
950
|
-
|
|
951
|
-
//#region src/reporters/cliReporter.ts
|
|
951
|
+
// src/reporters/cliReporter.ts
|
|
952
952
|
/**
|
|
953
953
|
* Renders the summary as plain `console.log` lines so it works in every CLI (no clack/TTY
|
|
954
954
|
* dependency): a blank line, the config name colored by status, then the summary rows.
|
|
@@ -988,8 +988,7 @@ function createCliReporter({ render = consoleRenderer } = {}) {
|
|
|
988
988
|
* logger view.
|
|
989
989
|
*/
|
|
990
990
|
const cliReporter = createCliReporter();
|
|
991
|
-
|
|
992
|
-
//#region src/storages/kubbStorage.ts
|
|
991
|
+
// src/storages/kubbStorage.ts
|
|
993
992
|
function ensurePrivateDir(dir) {
|
|
994
993
|
mkdirSync(dir, {
|
|
995
994
|
recursive: true,
|
|
@@ -1050,8 +1049,7 @@ function kubbStorage({ base } = {}) {
|
|
|
1050
1049
|
}
|
|
1051
1050
|
};
|
|
1052
1051
|
}
|
|
1053
|
-
|
|
1054
|
-
//#region src/reporters/fileReporter.ts
|
|
1052
|
+
// src/reporters/fileReporter.ts
|
|
1055
1053
|
/**
|
|
1056
1054
|
* Builds the `## Problems` section: each problem rendered in the miette block format, blocks
|
|
1057
1055
|
* separated by a blank line. Returns an empty array when there are no problems, so the caller
|
|
@@ -1099,8 +1097,7 @@ const fileReporter = createReporter({
|
|
|
1099
1097
|
console.error(`Debug log written to ${relative(process$1.cwd(), join(dir, baseName))}`);
|
|
1100
1098
|
}
|
|
1101
1099
|
});
|
|
1102
|
-
|
|
1103
|
-
//#region src/reporters/jsonReporter.ts
|
|
1100
|
+
// src/reporters/jsonReporter.ts
|
|
1104
1101
|
/**
|
|
1105
1102
|
* The `json` reporter. `report` returns one config's {@link Report}, which {@link createReporter}
|
|
1106
1103
|
* buffers, and `drain` writes them as a single pretty-printed JSON array on `kubb:lifecycle:end`.
|
|
@@ -1117,8 +1114,7 @@ const jsonReporter = createReporter({
|
|
|
1117
1114
|
process$1.stdout.write(`${JSON.stringify(reports, null, 2)}\n`);
|
|
1118
1115
|
}
|
|
1119
1116
|
});
|
|
1120
|
-
|
|
1121
|
-
//#region src/reporters/htmlReporter.ts
|
|
1117
|
+
// src/reporters/htmlReporter.ts
|
|
1122
1118
|
function serializeReport(result) {
|
|
1123
1119
|
return `globalThis.__KUBB_REPORT__ = ${JSON.stringify({
|
|
1124
1120
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1152,8 +1148,7 @@ const htmlReporter = createReporter({
|
|
|
1152
1148
|
openInBrowser(reportPath);
|
|
1153
1149
|
}
|
|
1154
1150
|
});
|
|
1155
|
-
|
|
1156
|
-
//#region src/createRenderer.ts
|
|
1151
|
+
// src/createRenderer.ts
|
|
1157
1152
|
/**
|
|
1158
1153
|
* Defines a renderer factory. Renderers turn the generator's return value
|
|
1159
1154
|
* (JSX, a template string, a tree of any shape) into `FileNode`s that get
|
|
@@ -1186,8 +1181,7 @@ const htmlReporter = createReporter({
|
|
|
1186
1181
|
function createRenderer(factory) {
|
|
1187
1182
|
return factory;
|
|
1188
1183
|
}
|
|
1189
|
-
|
|
1190
|
-
//#region src/defineGenerator.ts
|
|
1184
|
+
// src/defineGenerator.ts
|
|
1191
1185
|
/**
|
|
1192
1186
|
* Defines a generator: a unit of work that runs during the plugin's AST walk
|
|
1193
1187
|
* and produces files. Plugins register generators via `ctx.addGenerator()`
|
|
@@ -1219,8 +1213,7 @@ function createRenderer(factory) {
|
|
|
1219
1213
|
function defineGenerator(generator) {
|
|
1220
1214
|
return generator;
|
|
1221
1215
|
}
|
|
1222
|
-
|
|
1223
|
-
//#region src/defineParser.ts
|
|
1216
|
+
// src/defineParser.ts
|
|
1224
1217
|
/**
|
|
1225
1218
|
* Defines a parser from one object and returns a factory that takes the user's options.
|
|
1226
1219
|
* Register the result in the `parsers` array on `defineConfig`.
|
|
@@ -1233,8 +1226,7 @@ function defineParser(definition) {
|
|
|
1233
1226
|
...definition
|
|
1234
1227
|
});
|
|
1235
1228
|
}
|
|
1236
|
-
|
|
1237
|
-
//#region src/storages/memoryStorage.ts
|
|
1229
|
+
// src/storages/memoryStorage.ts
|
|
1238
1230
|
/**
|
|
1239
1231
|
* In-memory storage driver. Useful for testing and dry-run scenarios where
|
|
1240
1232
|
* generated output should be captured without touching the filesystem.
|
|
@@ -1280,8 +1272,7 @@ const memoryStorage = createStorage(() => {
|
|
|
1280
1272
|
}
|
|
1281
1273
|
};
|
|
1282
1274
|
});
|
|
1283
|
-
|
|
1284
|
-
//#region src/manifest.ts
|
|
1275
|
+
// src/manifest.ts
|
|
1285
1276
|
const EXTENSION_KINDS = /* @__PURE__ */ new Set([
|
|
1286
1277
|
"plugin",
|
|
1287
1278
|
"adapter",
|
|
@@ -1368,8 +1359,7 @@ function isRegistryEntry(value) {
|
|
|
1368
1359
|
const { id, kind, type, artifact, manifest } = value;
|
|
1369
1360
|
return typeof id === "string" && REGISTRY_ID.test(id) && EXTENSION_KINDS.has(kind) && (type === "official" || type === "community") && isRegistryArtifact(artifact) && isExtensionManifest(manifest) && manifest.kind === kind;
|
|
1370
1361
|
}
|
|
1371
|
-
|
|
1372
|
-
//#region src/installedPackages.ts
|
|
1362
|
+
// src/installedPackages.ts
|
|
1373
1363
|
/** Reads and parses a JSON file. Throws when it is missing or not JSON. */
|
|
1374
1364
|
const readJSON = async (file) => JSON.parse(await readFile(file, "utf8"));
|
|
1375
1365
|
/**
|
|
@@ -1405,7 +1395,6 @@ async function readInstalledPackages({ root, packages = [], resolveFrom = [] })
|
|
|
1405
1395
|
}
|
|
1406
1396
|
}));
|
|
1407
1397
|
}
|
|
1408
|
-
|
|
1409
|
-
export { Diagnostics, Hookable, KubbDriver, Resolver, addGenerator, addMacro, assertPluginOption, cacheStorage, checkCompatibility, checkoutGitInput, cliReporter, createAdapter, createCliReporter, createKubb, createOutputManifest, createRenderer, createReporter, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, htmlReporter, injectFile, isExtensionManifest, isPackageName, isPublicAddress, isRegistryEntry, jsonReporter, kubbContext, kubbStorage, logLevel, manifestProblems, memoryStorage, readInstalledPackages, requirePlugin, resolveCacheDir, resolveKubbDir, resolveMeta, runHook, runOutputPasses, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
|
|
1398
|
+
export { Diagnostics, Hookable, KubbDriver, Resolver, addGenerator, addMacro, assertPluginOption, cacheStorage, camelCase, checkCompatibility, checkoutGitInput, cliReporter, createAdapter, createCliReporter, createKubb, createOutputManifest, createRenderer, createReporter, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, htmlReporter, injectFile, isExtensionManifest, isPackageName, isPublicAddress, isRegistryEntry, jsonReporter, kubbContext, kubbStorage, logLevel, manifestProblems, memo, memoryStorage, pascalCase, readInstalledPackages, requirePlugin, resolveCacheDir, resolveKubbDir, resolveMeta, runHook, runOutputPasses, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
|
|
1410
1399
|
|
|
1411
1400
|
//# sourceMappingURL=index.js.map
|