@kubb/core 5.8.2 → 5.8.4
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/{KubbDriver-DBm4hRKA.js → KubbDriver-DbOEJvzz.js} +2 -2
- package/dist/{KubbDriver-DBm4hRKA.js.map → KubbDriver-DbOEJvzz.js.map} +1 -1
- package/dist/{KubbDriver-DxWuvJWV.cjs → KubbDriver-Iv2StSPa.cjs} +2 -2
- package/dist/{KubbDriver-DxWuvJWV.cjs.map → KubbDriver-Iv2StSPa.cjs.map} +1 -1
- package/dist/index.cjs +18 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +37 -9
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.js +1 -1
- package/package.json +2 -2
- package/schemas/kubb-extension.json +19 -1
package/dist/index.d.ts
CHANGED
|
@@ -529,6 +529,13 @@ type ExtensionManifest = {
|
|
|
529
529
|
media?: Array<string>;
|
|
530
530
|
tags?: Array<string>;
|
|
531
531
|
docs?: string;
|
|
532
|
+
/** People who maintain the extension, shown on its kubb.dev page. */
|
|
533
|
+
maintainers?: Array<{
|
|
534
|
+
name: string;
|
|
535
|
+
github?: string;
|
|
536
|
+
}>;
|
|
537
|
+
/** Names of the extensions that must be in the same config, such as `['plugin-ts']`. */
|
|
538
|
+
dependencies?: Array<string>;
|
|
532
539
|
compatibility?: {
|
|
533
540
|
kubb?: string;
|
|
534
541
|
node?: string;
|
|
@@ -537,18 +544,30 @@ type ExtensionManifest = {
|
|
|
537
544
|
role?: 'client' | 'consumer';
|
|
538
545
|
options?: Array<ExtensionManifestOption>;
|
|
539
546
|
};
|
|
547
|
+
/** What `kubb add` installs: a reviewed npm version, or a GitHub release tag and the commit it points to. */
|
|
548
|
+
type RegistryArtifact = {
|
|
549
|
+
kind: 'npm';
|
|
550
|
+
package: string;
|
|
551
|
+
version: string;
|
|
552
|
+
} | {
|
|
553
|
+
kind: 'github';
|
|
554
|
+
/** The `name` in the root `package.json`, so the package installs under this name. */
|
|
555
|
+
package: string;
|
|
556
|
+
/** The release version, equal to `tag` without a leading `v`. */
|
|
557
|
+
version: string;
|
|
558
|
+
owner: string;
|
|
559
|
+
repo: string;
|
|
560
|
+
tag: string;
|
|
561
|
+
/** The full commit SHA the tag points to. */
|
|
562
|
+
commit: string;
|
|
563
|
+
};
|
|
540
564
|
/** One extension in a registry's `index.json`. */
|
|
541
565
|
type RegistryEntry = {
|
|
542
566
|
/** `<owner>/<slug>`, such as `kubb-labs/plugin-zod`. */
|
|
543
567
|
id: string;
|
|
544
568
|
kind: ExtensionKind;
|
|
545
569
|
type: 'official' | 'community';
|
|
546
|
-
|
|
547
|
-
artifact: {
|
|
548
|
-
kind: 'npm';
|
|
549
|
-
package: string;
|
|
550
|
-
version: string;
|
|
551
|
-
};
|
|
570
|
+
artifact: RegistryArtifact;
|
|
552
571
|
repository?: {
|
|
553
572
|
url: string;
|
|
554
573
|
};
|
|
@@ -568,9 +587,18 @@ type RegistryIndex = {
|
|
|
568
587
|
generatedAt: string;
|
|
569
588
|
extensions: Array<RegistryEntry>;
|
|
570
589
|
};
|
|
571
|
-
/**
|
|
590
|
+
/** One `docs/guides/<id>.md`: `id` is the file name, `title` its `#` heading, `description` the first paragraph. */
|
|
591
|
+
type RegistryGuide = {
|
|
592
|
+
id: string;
|
|
593
|
+
title: string;
|
|
594
|
+
description: string;
|
|
595
|
+
content: string;
|
|
596
|
+
};
|
|
597
|
+
/** The registry's `<owner>/<slug>.json`: an entry plus the Markdown docs its pinned version ships. */
|
|
572
598
|
type RegistryDetail = RegistryEntry & {
|
|
573
599
|
overview: string | null;
|
|
600
|
+
options?: string | null;
|
|
601
|
+
guides?: Array<RegistryGuide>;
|
|
574
602
|
};
|
|
575
603
|
/**
|
|
576
604
|
* Whether `name` is a valid npm package name, such as `@kubb/plugin-ts`. Rejects paths, URLs,
|
|
@@ -591,7 +619,7 @@ export declare function manifestProblems({ options }: ExtensionManifest): Array<
|
|
|
591
619
|
export declare function isExtensionManifest(value: unknown): value is ExtensionManifest;
|
|
592
620
|
/**
|
|
593
621
|
* Checks one entry of a registry's `index.json` or `<owner>/<slug>.json`: a full `<owner>/<slug>` id,
|
|
594
|
-
* an npm artifact pinned to a valid version, and a valid manifest of the entry's kind.
|
|
622
|
+
* an npm or GitHub artifact pinned to a valid version, and a valid manifest of the entry's kind.
|
|
595
623
|
*/
|
|
596
624
|
export declare function isRegistryEntry(value: unknown): value is RegistryEntry;
|
|
597
625
|
//#endregion
|
|
@@ -613,5 +641,5 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
|
|
|
613
641
|
resolveFrom?: Array<string>;
|
|
614
642
|
}): Promise<Array<InstalledPackage>>;
|
|
615
643
|
//#endregion
|
|
616
|
-
export { type Adapter, type AdapterDefinition, type AdapterFactory, 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 ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, type FileManagerHooks, 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 PluginFactoryOptions, type PluginName, type PluginType, PossibleConfig, PostGenerateCommand, type ProblemCode, type ProblemDiagnostic, type RegistryDetail, type RegistryEntry, 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 };
|
|
644
|
+
export { type Adapter, type AdapterDefinition, type AdapterFactory, 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 ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, type FileManagerHooks, 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 PluginFactoryOptions, 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
645
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
|
-
import { A as getElapsedMs, C as useOptions, D as resolveMeta, E as defineExtension, F as read, I as toPosixPath, L as write, M as clean, N as exists, O as Diagnostics, P as isPathInside, R as toError, S as useKubb, T as createExtensionFactory, _ as setMacros, a as _usingCtx, b as tryUseKubb, c as Resolver, d as definePlugin, f as addGenerator, g as requirePlugin, h as kubbContext, j as inParallel, k as formatMs, l as getInputKind, m as injectFile, o as Hookable, p as addMacro, s as createResolver, t as KubbDriver, u as assertPluginOption, v as setOptions, w as checkCompatibility, x as useConfig, y as setResolver } from "./KubbDriver-
|
|
2
|
+
import { A as getElapsedMs, C as useOptions, D as resolveMeta, E as defineExtension, F as read, I as toPosixPath, L as write, M as clean, N as exists, O as Diagnostics, P as isPathInside, R as toError, S as useKubb, T as createExtensionFactory, _ as setMacros, a as _usingCtx, b as tryUseKubb, c as Resolver, d as definePlugin, f as addGenerator, g as requirePlugin, h as kubbContext, j as inParallel, k as formatMs, l as getInputKind, m as injectFile, o as Hookable, p as addMacro, s as createResolver, t as KubbDriver, u as assertPluginOption, v as setOptions, w as checkCompatibility, x as useConfig, y as setResolver } from "./KubbDriver-DbOEJvzz.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { isValid } from "verkit";
|
|
5
5
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
@@ -1359,6 +1359,9 @@ const OPTION_TYPES = /* @__PURE__ */ new Set([
|
|
|
1359
1359
|
const PACKAGE_NAME = /^(?:@[a-z0-9~][a-z0-9._~-]*\/)?[a-z0-9~][a-z0-9._~-]*$/;
|
|
1360
1360
|
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
1361
1361
|
const REGISTRY_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
1362
|
+
const GITHUB_OWNER = /^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$/;
|
|
1363
|
+
const GITHUB_REPO = /^(?!\.\.?$)[A-Za-z0-9._-]{1,100}$/;
|
|
1364
|
+
const COMMIT = /^[0-9a-f]{40}$/;
|
|
1362
1365
|
/** Option path segments that would reach an object's prototype when Studio writes the value by path. */
|
|
1363
1366
|
const UNSAFE_KEYS = /* @__PURE__ */ new Set([
|
|
1364
1367
|
"__proto__",
|
|
@@ -1368,6 +1371,7 @@ const UNSAFE_KEYS = /* @__PURE__ */ new Set([
|
|
|
1368
1371
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1369
1372
|
const isOptionalString = (value) => value === void 0 || typeof value === "string";
|
|
1370
1373
|
const isFilledString = (value) => typeof value === "string" && value !== "";
|
|
1374
|
+
const matches = (pattern, value) => typeof value === "string" && pattern.test(value);
|
|
1371
1375
|
/** Serializes with sorted object keys, so equal JSON values give equal strings whatever their key order. */
|
|
1372
1376
|
const canonicalJSON = (value) => JSON.stringify(value, (_key, item) => isObject(item) ? Object.fromEntries(Object.keys(item).sort().map((key) => [key, item[key]])) : item);
|
|
1373
1377
|
/**
|
|
@@ -1378,6 +1382,9 @@ const canonicalJSON = (value) => JSON.stringify(value, (_key, item) => isObject(
|
|
|
1378
1382
|
function isPackageName(name) {
|
|
1379
1383
|
return typeof name === "string" && name.length <= 214 && PACKAGE_NAME.test(name);
|
|
1380
1384
|
}
|
|
1385
|
+
function isMaintainer(value) {
|
|
1386
|
+
return isObject(value) && Object.keys(value).every((key) => key === "name" || key === "github") && isFilledString(value.name) && (value.github === void 0 || isFilledString(value.github));
|
|
1387
|
+
}
|
|
1381
1388
|
/** Checks the shape of one manifest option, including that its path cannot reach a prototype. */
|
|
1382
1389
|
function isOption(value) {
|
|
1383
1390
|
if (!isObject(value)) return false;
|
|
@@ -1405,17 +1412,23 @@ function manifestProblems({ options = [] }) {
|
|
|
1405
1412
|
*/
|
|
1406
1413
|
function isExtensionManifest(value) {
|
|
1407
1414
|
if (!isObject(value)) return false;
|
|
1408
|
-
const { kind, name, export: exportName, displayName, description, compatibility, options } = value;
|
|
1409
|
-
return EXTENSION_KINDS.has(kind) && isPackageName(name) && typeof exportName === "string" && IDENTIFIER.test(exportName) && typeof displayName === "string" && typeof description === "string" && (compatibility === void 0 || isObject(compatibility) && Object.entries(compatibility).every(([key, range]) => (key === "kubb" || key === "node") && typeof range === "string")) && (options === void 0 || Array.isArray(options) && options.every(isOption)) && manifestProblems(value).length === 0;
|
|
1415
|
+
const { kind, name, export: exportName, displayName, description, maintainers, dependencies, compatibility, options } = value;
|
|
1416
|
+
return EXTENSION_KINDS.has(kind) && isPackageName(name) && typeof exportName === "string" && IDENTIFIER.test(exportName) && typeof displayName === "string" && typeof description === "string" && (maintainers === void 0 || Array.isArray(maintainers) && maintainers.every(isMaintainer)) && (dependencies === void 0 || Array.isArray(dependencies) && dependencies.every(isPackageName)) && (compatibility === void 0 || isObject(compatibility) && Object.entries(compatibility).every(([key, range]) => (key === "kubb" || key === "node") && typeof range === "string")) && (options === void 0 || Array.isArray(options) && options.every(isOption)) && manifestProblems(value).length === 0;
|
|
1417
|
+
}
|
|
1418
|
+
/** Checks that no artifact field can reach a package manager as a flag or path, and that a GitHub tag names the version. */
|
|
1419
|
+
function isRegistryArtifact(value) {
|
|
1420
|
+
if (!isObject(value) || !isPackageName(value.package) || typeof value.version !== "string" || !isValid(value.version)) return false;
|
|
1421
|
+
if (value.kind === "npm") return true;
|
|
1422
|
+
return value.kind === "github" && matches(GITHUB_OWNER, value.owner) && matches(GITHUB_REPO, value.repo) && (value.tag === value.version || value.tag === `v${value.version}`) && matches(COMMIT, value.commit);
|
|
1410
1423
|
}
|
|
1411
1424
|
/**
|
|
1412
1425
|
* Checks one entry of a registry's `index.json` or `<owner>/<slug>.json`: a full `<owner>/<slug>` id,
|
|
1413
|
-
* an npm artifact pinned to a valid version, and a valid manifest of the entry's kind.
|
|
1426
|
+
* an npm or GitHub artifact pinned to a valid version, and a valid manifest of the entry's kind.
|
|
1414
1427
|
*/
|
|
1415
1428
|
function isRegistryEntry(value) {
|
|
1416
1429
|
if (!isObject(value)) return false;
|
|
1417
1430
|
const { id, kind, type, artifact, manifest } = value;
|
|
1418
|
-
return typeof id === "string" && REGISTRY_ID.test(id) && EXTENSION_KINDS.has(kind) && (type === "official" || type === "community") &&
|
|
1431
|
+
return typeof id === "string" && REGISTRY_ID.test(id) && EXTENSION_KINDS.has(kind) && (type === "official" || type === "community") && isRegistryArtifact(artifact) && isExtensionManifest(manifest) && manifest.kind === kind;
|
|
1419
1432
|
}
|
|
1420
1433
|
//#endregion
|
|
1421
1434
|
//#region src/installedPackages.ts
|