@kubb/core 5.2.7 → 5.3.0
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 +65 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +64 -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-D6I-1WdH.d.ts} +25 -3
- package/dist/{usingCtx-1W_18hcP.cjs → usingCtx-DxKUGwsR.cjs} +7 -1
- package/dist/{usingCtx-1W_18hcP.cjs.map → usingCtx-DxKUGwsR.cjs.map} +1 -1
- package/dist/{usingCtx-xMZZh-09.js → usingCtx-y6z42CxR.js} +2 -2
- package/dist/{usingCtx-xMZZh-09.js.map → usingCtx-y6z42CxR.js.map} +1 -1
- package/package.json +5 -4
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-D6I-1WdH.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-y6z42CxR.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.0".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`.
|
|
@@ -2340,6 +2365,7 @@ function createReporter(reporter) {
|
|
|
2340
2365
|
const reports = [];
|
|
2341
2366
|
return {
|
|
2342
2367
|
name: reporter.name,
|
|
2368
|
+
needsPluginFiles: reporter.needsPluginFiles,
|
|
2343
2369
|
async report(result, context) {
|
|
2344
2370
|
const report = await reporter.report(result, context);
|
|
2345
2371
|
if (reporter.drain) reports.push(report);
|
|
@@ -2577,6 +2603,40 @@ const jsonReporter = createReporter({
|
|
|
2577
2603
|
}
|
|
2578
2604
|
});
|
|
2579
2605
|
//#endregion
|
|
2606
|
+
//#region src/reporters/htmlReporter.ts
|
|
2607
|
+
function serializeReport(result) {
|
|
2608
|
+
return `globalThis.__KUBB_REPORT__ = ${JSON.stringify({
|
|
2609
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2610
|
+
report: buildReport(result),
|
|
2611
|
+
pluginFiles: result.pluginFiles ?? []
|
|
2612
|
+
}).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026")}\n`;
|
|
2613
|
+
}
|
|
2614
|
+
/**
|
|
2615
|
+
* Writes a static HTML report directory selected with `--reporter html`.
|
|
2616
|
+
*/
|
|
2617
|
+
const htmlReporter = createReporter({
|
|
2618
|
+
name: "html",
|
|
2619
|
+
needsPluginFiles: true,
|
|
2620
|
+
async report(result) {
|
|
2621
|
+
const baseName = [
|
|
2622
|
+
"kubb",
|
|
2623
|
+
result.config.name?.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, ""),
|
|
2624
|
+
Date.now()
|
|
2625
|
+
].filter(Boolean).join("-");
|
|
2626
|
+
const pathName = resolve(process.cwd(), ".kubb", baseName);
|
|
2627
|
+
const assets = new URL("./html/", import.meta.url);
|
|
2628
|
+
const [html, ui] = await Promise.all([read(fileURLToPath(new URL("index.html", assets))), read(fileURLToPath(new URL("ui.iife.js", assets)))]);
|
|
2629
|
+
await Promise.all([
|
|
2630
|
+
write(resolve(pathName, "index.html"), html),
|
|
2631
|
+
write(resolve(pathName, "ui.iife.js"), ui),
|
|
2632
|
+
write(resolve(pathName, "data.js"), serializeReport(result))
|
|
2633
|
+
]);
|
|
2634
|
+
const reportPath = resolve(pathName, "index.html");
|
|
2635
|
+
console.error(`HTML report written to ${relative(process.cwd(), reportPath)}`);
|
|
2636
|
+
openInBrowser(reportPath);
|
|
2637
|
+
}
|
|
2638
|
+
});
|
|
2639
|
+
//#endregion
|
|
2580
2640
|
//#region src/createRenderer.ts
|
|
2581
2641
|
/**
|
|
2582
2642
|
* Defines a renderer factory. Renderers turn the generator's return value
|
|
@@ -2726,6 +2786,6 @@ const memoryStorage = createStorage(() => {
|
|
|
2726
2786
|
};
|
|
2727
2787
|
});
|
|
2728
2788
|
//#endregion
|
|
2729
|
-
export { Diagnostics, Hookable, KubbDriver, Resolver, applyConfigDefaults, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, jsonReporter, logLevel, memoryStorage };
|
|
2789
|
+
export { Diagnostics, Hookable, KubbDriver, Resolver, applyConfigDefaults, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, htmlReporter, jsonReporter, logLevel, memoryStorage };
|
|
2730
2790
|
|
|
2731
2791
|
//# sourceMappingURL=index.js.map
|