@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/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_KubbDriver = require("./KubbDriver-DxWuvJWV.cjs");
2
+ const require_KubbDriver = require("./KubbDriver-Iv2StSPa.cjs");
3
3
  let verkit = require("verkit");
4
4
  let node_util = require("node:util");
5
5
  let node_process = require("node:process");
@@ -1362,6 +1362,9 @@ const OPTION_TYPES = /* @__PURE__ */ new Set([
1362
1362
  const PACKAGE_NAME = /^(?:@[a-z0-9~][a-z0-9._~-]*\/)?[a-z0-9~][a-z0-9._~-]*$/;
1363
1363
  const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
1364
1364
  const REGISTRY_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
1365
+ const GITHUB_OWNER = /^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$/;
1366
+ const GITHUB_REPO = /^(?!\.\.?$)[A-Za-z0-9._-]{1,100}$/;
1367
+ const COMMIT = /^[0-9a-f]{40}$/;
1365
1368
  /** Option path segments that would reach an object's prototype when Studio writes the value by path. */
1366
1369
  const UNSAFE_KEYS = /* @__PURE__ */ new Set([
1367
1370
  "__proto__",
@@ -1371,6 +1374,7 @@ const UNSAFE_KEYS = /* @__PURE__ */ new Set([
1371
1374
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1372
1375
  const isOptionalString = (value) => value === void 0 || typeof value === "string";
1373
1376
  const isFilledString = (value) => typeof value === "string" && value !== "";
1377
+ const matches = (pattern, value) => typeof value === "string" && pattern.test(value);
1374
1378
  /** Serializes with sorted object keys, so equal JSON values give equal strings whatever their key order. */
1375
1379
  const canonicalJSON = (value) => JSON.stringify(value, (_key, item) => isObject(item) ? Object.fromEntries(Object.keys(item).sort().map((key) => [key, item[key]])) : item);
1376
1380
  /**
@@ -1381,6 +1385,9 @@ const canonicalJSON = (value) => JSON.stringify(value, (_key, item) => isObject(
1381
1385
  function isPackageName(name) {
1382
1386
  return typeof name === "string" && name.length <= 214 && PACKAGE_NAME.test(name);
1383
1387
  }
1388
+ function isMaintainer(value) {
1389
+ return isObject(value) && Object.keys(value).every((key) => key === "name" || key === "github") && isFilledString(value.name) && (value.github === void 0 || isFilledString(value.github));
1390
+ }
1384
1391
  /** Checks the shape of one manifest option, including that its path cannot reach a prototype. */
1385
1392
  function isOption(value) {
1386
1393
  if (!isObject(value)) return false;
@@ -1408,17 +1415,23 @@ function manifestProblems({ options = [] }) {
1408
1415
  */
1409
1416
  function isExtensionManifest(value) {
1410
1417
  if (!isObject(value)) return false;
1411
- const { kind, name, export: exportName, displayName, description, compatibility, options } = value;
1412
- 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;
1418
+ const { kind, name, export: exportName, displayName, description, maintainers, dependencies, compatibility, options } = value;
1419
+ 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;
1420
+ }
1421
+ /** Checks that no artifact field can reach a package manager as a flag or path, and that a GitHub tag names the version. */
1422
+ function isRegistryArtifact(value) {
1423
+ if (!isObject(value) || !isPackageName(value.package) || typeof value.version !== "string" || !(0, verkit.isValid)(value.version)) return false;
1424
+ if (value.kind === "npm") return true;
1425
+ 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);
1413
1426
  }
1414
1427
  /**
1415
1428
  * Checks one entry of a registry's `index.json` or `<owner>/<slug>.json`: a full `<owner>/<slug>` id,
1416
- * an npm artifact pinned to a valid version, and a valid manifest of the entry's kind.
1429
+ * an npm or GitHub artifact pinned to a valid version, and a valid manifest of the entry's kind.
1417
1430
  */
1418
1431
  function isRegistryEntry(value) {
1419
1432
  if (!isObject(value)) return false;
1420
1433
  const { id, kind, type, artifact, manifest } = value;
1421
- return typeof id === "string" && REGISTRY_ID.test(id) && EXTENSION_KINDS.has(kind) && (type === "official" || type === "community") && isObject(artifact) && artifact.kind === "npm" && isPackageName(artifact.package) && typeof artifact.version === "string" && (0, verkit.isValid)(artifact.version) && isExtensionManifest(manifest) && manifest.kind === kind;
1434
+ return typeof id === "string" && REGISTRY_ID.test(id) && EXTENSION_KINDS.has(kind) && (type === "official" || type === "community") && isRegistryArtifact(artifact) && isExtensionManifest(manifest) && manifest.kind === kind;
1422
1435
  }
1423
1436
  //#endregion
1424
1437
  //#region src/installedPackages.ts