@kubb/core 5.2.8 → 5.3.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/html/index.html +357 -0
- package/dist/html/ui.iife.js +25 -0
- package/dist/index.cjs +70 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +69 -4
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{types-D6fWCd9O.d.ts → types-DIHOpbmO.d.ts} +36 -8
- package/dist/{usingCtx-xMZZh-09.js → usingCtx-BfeNtY1B.js} +6 -2
- package/dist/usingCtx-BfeNtY1B.js.map +1 -0
- package/dist/{usingCtx-1W_18hcP.cjs → usingCtx-CBWq26N5.cjs} +11 -1
- package/dist/usingCtx-CBWq26N5.cjs.map +1 -0
- package/package.json +5 -4
- package/dist/usingCtx-1W_18hcP.cjs.map +0 -1
- package/dist/usingCtx-xMZZh-09.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { $ as PluginFactoryOptions, A as Kubb, At as
|
|
2
|
+
import { $ as PluginFactoryOptions, A as Kubb, At as Diagnostic, B as Exclude, Bt as UpdateDiagnostic, C as KubbWarnContext, Ct as Reporter, D as CreateKubbOptions, Dt as UserReporter, E as UserConfig, Et as ReporterPluginFiles, F as NodeCache, Ft as Diagnostics, G as KubbPluginSetupContext, Gt as createAdapter, H as Group, Ht as Adapter, I as KubbDriver, It as PerformanceDiagnostic, J as Output, K as KubbPluginStartContext, L as FileManagerHooks, Lt as ProblemCode, M as Generator, Mt as DiagnosticKind, N as GeneratorContext, Nt as DiagnosticLocation, O as GenerateOptions, Ot as createReporter, P as defineGenerator, Pt as DiagnosticSeverity, Q as Plugin, R as Parser, Rt as ProblemDiagnostic, S as KubbSuccessContext, St as GenerationResult, T as PostGenerateCommand, Tt as ReporterName, U as Include, Ut as AdapterFactoryOptions, V as Filter, Vt as Hookable, W as KubbPluginEndContext, Wt as AdapterSource, X as OutputOptions, Y as OutputMode, Z as Override, _ as KubbHookStartContext, _t as Renderer, a as KubbBuildEndContext, at as ResolveBannerFile, b as KubbLifecycleStartContext, bt as Storage, c as KubbErrorContext, ct as ResolveOptionsContext, d as KubbFilesProcessingStartContext, dt as ResolverDefault, et as PluginName, f as KubbFilesProcessingUpdateContext, ft as ResolverFile, g as KubbHookLineContext, gt as ResolverPathParams, h as KubbHookEndContext, ht as ResolverPatch, i as Input, it as ResolveBannerContext, j as createKubb, jt as DiagnosticDoc, k as GenerateResult, kt as logLevel, l as KubbFileProcessingUpdate, lt as ResolvePathOptions, m as KubbGenerationStartContext, mt as ResolverFilePathParams, n as CLIOptions, nt as definePlugin, o as KubbBuildStartContext, ot as ResolveFileOptions, p as KubbGenerationEndContext, pt as ResolverFileParams, q as NormalizedPlugin, r as Config, rt as BannerMeta, s as KubbDiagnosticContext, st as ResolveImportsOptions, t as BuildOutput, tt as ResolvePluginOptions, u as KubbFilesProcessingEndContext, ut as Resolver, v as KubbHooks, vt as RendererFactory, w as PossibleConfig, wt as ReporterContext, x as KubbPluginsEndContext, xt as createStorage, y as KubbInfoContext, yt as createRenderer, z as defineParser, zt as SerializedDiagnostic } from "./types-DIHOpbmO.js";
|
|
3
3
|
//#region src/applyConfigDefaults.d.ts
|
|
4
4
|
type ApplyConfigDefaultsOptions<TOutput> = {
|
|
5
5
|
defaultAdapter: Adapter;
|
|
@@ -55,6 +55,12 @@ export declare const fileReporter: Reporter;
|
|
|
55
55
|
*/
|
|
56
56
|
export declare const jsonReporter: Reporter;
|
|
57
57
|
//#endregion
|
|
58
|
+
//#region src/reporters/htmlReporter.d.ts
|
|
59
|
+
/**
|
|
60
|
+
* Writes a static HTML report directory selected with `--reporter html`.
|
|
61
|
+
*/
|
|
62
|
+
export declare const htmlReporter: Reporter;
|
|
63
|
+
//#endregion
|
|
58
64
|
//#region src/createResolver.d.ts
|
|
59
65
|
/**
|
|
60
66
|
* The plugin-specific resolver fields handed to `createResolver`. `name` and `file` fall
|
|
@@ -184,5 +190,5 @@ export declare const fsStorage: (options?: Record<string, never> | undefined) =>
|
|
|
184
190
|
*/
|
|
185
191
|
export declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
|
|
186
192
|
//#endregion
|
|
187
|
-
export { type Adapter, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, BuildOutput, CLIOptions, Config, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type FileManagerHooks, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, Hookable, type Include, Input, type InputKind, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NodeCache, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type PerformanceDiagnostic, type Plugin, type PluginFactoryOptions, type PluginName, PossibleConfig, PostGenerateCommand, type ProblemCode, type ProblemDiagnostic, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, 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 SerializedDiagnostic, type Storage, type UpdateDiagnostic, UserConfig, type UserReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineParser, definePlugin, logLevel };
|
|
193
|
+
export { type Adapter, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, BuildOutput, CLIOptions, Config, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type FileManagerHooks, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, Hookable, type Include, Input, type InputKind, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NodeCache, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type PerformanceDiagnostic, type Plugin, type PluginFactoryOptions, type PluginName, PossibleConfig, PostGenerateCommand, type ProblemCode, type ProblemDiagnostic, 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 SerializedDiagnostic, type Storage, type UpdateDiagnostic, UserConfig, type UserReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineParser, definePlugin, logLevel };
|
|
188
194
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { a as OPERATION_FILTER_TYPES, c as clean, d as
|
|
2
|
+
import { a as OPERATION_FILTER_TYPES, c as clean, d as toPosixPath, f as write, h as camelCase, i as Hookable, l as isPathInside, m as toError, n as createNodeCache, o as diagnosticCode, p as getErrorMessage, r as FileManager, s as inParallel, t as _usingCtx, u as read } from "./usingCtx-BfeNtY1B.js";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
5
|
+
import process$1 from "node:process";
|
|
6
|
+
import { execFile } from "node:child_process";
|
|
5
7
|
import { access, glob, readFile, rm } from "node:fs/promises";
|
|
6
8
|
import path, { join, relative, resolve } from "node:path";
|
|
7
9
|
import { ast, collectImportedRefNames, collectUsedSchemaNames, composeMacros, operationDef, schemaDef, transform } from "@kubb/ast";
|
|
8
10
|
import { hash } from "node:crypto";
|
|
9
11
|
import { existsSync } from "node:fs";
|
|
10
12
|
import { tmpdir } from "node:os";
|
|
11
|
-
import
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
12
14
|
//#region src/createAdapter.ts
|
|
13
15
|
/**
|
|
14
16
|
* Defines a custom adapter that translates a spec format into Kubb's universal
|
|
@@ -63,6 +65,29 @@ function applyConfigDefaults(config, { defaultAdapter, barrelPlugin, barrelPlugi
|
|
|
63
65
|
};
|
|
64
66
|
}
|
|
65
67
|
//#endregion
|
|
68
|
+
//#region ../../internals/utils/src/isCIEnvironment.ts
|
|
69
|
+
/**
|
|
70
|
+
* Returns `true` when a known CI provider has set its environment variable.
|
|
71
|
+
*/
|
|
72
|
+
function isCIEnvironment() {
|
|
73
|
+
return !!(process$1.env.CI || 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);
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region ../../internals/utils/src/openInBrowser.ts
|
|
77
|
+
/**
|
|
78
|
+
* Opens a URL or local file in the default browser, unless running in CI.
|
|
79
|
+
*/
|
|
80
|
+
function openInBrowser(target) {
|
|
81
|
+
if (isCIEnvironment()) return;
|
|
82
|
+
if (process$1.platform === "win32") execFile("cmd", [
|
|
83
|
+
"/c",
|
|
84
|
+
"start",
|
|
85
|
+
"",
|
|
86
|
+
target
|
|
87
|
+
], () => {});
|
|
88
|
+
else execFile(process$1.platform === "darwin" ? "open" : "xdg-open", [target], () => {});
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
66
91
|
//#region ../../internals/utils/src/time.ts
|
|
67
92
|
/**
|
|
68
93
|
* Calculates elapsed time in milliseconds from a high-resolution `process.hrtime` start time.
|
|
@@ -100,7 +125,7 @@ function formatMs(ms) {
|
|
|
100
125
|
/**
|
|
101
126
|
* Docs major version, derived from the package version so the link tracks the published major.
|
|
102
127
|
*/
|
|
103
|
-
const docsMajor = "5.
|
|
128
|
+
const docsMajor = "5.3.1".split(".")[0] ?? "5";
|
|
104
129
|
/**
|
|
105
130
|
* Builds a type guard that narrows a {@link Diagnostic} to the variant for `kind`. A diagnostic
|
|
106
131
|
* with no `kind` is treated as a `problem`.
|
|
@@ -263,6 +288,11 @@ const diagnosticCatalog = {
|
|
|
263
288
|
cause: "The linter pass over the generated files failed.",
|
|
264
289
|
fix: "Check the linter (oxlint, biome, or eslint) is installed and its config is valid, then run it manually on the output."
|
|
265
290
|
},
|
|
291
|
+
[diagnosticCode.barrelDuplicateExport]: {
|
|
292
|
+
title: "Duplicate barrel export",
|
|
293
|
+
cause: "Two generated modules export the same name, so the barrel cannot re-export both.",
|
|
294
|
+
fix: "Rename one of the colliding declarations, or configure the plugin resolver to produce distinct names."
|
|
295
|
+
},
|
|
266
296
|
[diagnosticCode.performance]: {
|
|
267
297
|
title: "Performance",
|
|
268
298
|
cause: "Not a failure. Records a plugin’s elapsed time, summed into the run total.",
|
|
@@ -2340,6 +2370,7 @@ function createReporter(reporter) {
|
|
|
2340
2370
|
const reports = [];
|
|
2341
2371
|
return {
|
|
2342
2372
|
name: reporter.name,
|
|
2373
|
+
needsPluginFiles: reporter.needsPluginFiles,
|
|
2343
2374
|
async report(result, context) {
|
|
2344
2375
|
const report = await reporter.report(result, context);
|
|
2345
2376
|
if (reporter.drain) reports.push(report);
|
|
@@ -2577,6 +2608,40 @@ const jsonReporter = createReporter({
|
|
|
2577
2608
|
}
|
|
2578
2609
|
});
|
|
2579
2610
|
//#endregion
|
|
2611
|
+
//#region src/reporters/htmlReporter.ts
|
|
2612
|
+
function serializeReport(result) {
|
|
2613
|
+
return `globalThis.__KUBB_REPORT__ = ${JSON.stringify({
|
|
2614
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2615
|
+
report: buildReport(result),
|
|
2616
|
+
pluginFiles: result.pluginFiles ?? []
|
|
2617
|
+
}).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026")}\n`;
|
|
2618
|
+
}
|
|
2619
|
+
/**
|
|
2620
|
+
* Writes a static HTML report directory selected with `--reporter html`.
|
|
2621
|
+
*/
|
|
2622
|
+
const htmlReporter = createReporter({
|
|
2623
|
+
name: "html",
|
|
2624
|
+
needsPluginFiles: true,
|
|
2625
|
+
async report(result) {
|
|
2626
|
+
const baseName = [
|
|
2627
|
+
"kubb",
|
|
2628
|
+
result.config.name?.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, ""),
|
|
2629
|
+
Date.now()
|
|
2630
|
+
].filter(Boolean).join("-");
|
|
2631
|
+
const pathName = resolve(process.cwd(), ".kubb", baseName);
|
|
2632
|
+
const assets = new URL("./html/", import.meta.url);
|
|
2633
|
+
const [html, ui] = await Promise.all([read(fileURLToPath(new URL("index.html", assets))), read(fileURLToPath(new URL("ui.iife.js", assets)))]);
|
|
2634
|
+
await Promise.all([
|
|
2635
|
+
write(resolve(pathName, "index.html"), html),
|
|
2636
|
+
write(resolve(pathName, "ui.iife.js"), ui),
|
|
2637
|
+
write(resolve(pathName, "data.js"), serializeReport(result))
|
|
2638
|
+
]);
|
|
2639
|
+
const reportPath = resolve(pathName, "index.html");
|
|
2640
|
+
console.error(`HTML report written to ${relative(process.cwd(), reportPath)}`);
|
|
2641
|
+
openInBrowser(reportPath);
|
|
2642
|
+
}
|
|
2643
|
+
});
|
|
2644
|
+
//#endregion
|
|
2580
2645
|
//#region src/createRenderer.ts
|
|
2581
2646
|
/**
|
|
2582
2647
|
* Defines a renderer factory. Renderers turn the generator's return value
|
|
@@ -2726,6 +2791,6 @@ const memoryStorage = createStorage(() => {
|
|
|
2726
2791
|
};
|
|
2727
2792
|
});
|
|
2728
2793
|
//#endregion
|
|
2729
|
-
export { Diagnostics, Hookable, KubbDriver, Resolver, applyConfigDefaults, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, jsonReporter, logLevel, memoryStorage };
|
|
2794
|
+
export { Diagnostics, Hookable, KubbDriver, Resolver, applyConfigDefaults, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, htmlReporter, jsonReporter, logLevel, memoryStorage };
|
|
2730
2795
|
|
|
2731
2796
|
//# sourceMappingURL=index.js.map
|