feat: use 0.2 as the default schema (#145)

This commit is contained in:
Samuel Attard 2025-11-01 12:31:25 -07:00 • committed by GitHub
commit 98126b777e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,9 +7,10 @@ import prettyBytes from "pretty-bytes";
import { unpackExtension } from "../cli/unpack.js";
import {
LATEST_MANIFEST_SCHEMA,
LATEST_MANIFEST_SCHEMA_LOOSE,
MANIFEST_SCHEMAS,
MANIFEST_SCHEMAS_LOOSE,
} from "../shared/constants.js";
import { getManifestVersionFromRawData } from "../shared/manifestVersionResolve.js";
/**
* Check if a buffer contains a valid PNG file signature
@ -119,8 +120,13 @@ export function validateManifest(inputPath: string): boolean {
const manifestContent = readFileSync(manifestPath, "utf-8");
const manifestData = JSON.parse(manifestContent);
const manifestVersion = getManifestVersionFromRawData(manifestData);
if (!manifestVersion) {
console.log("Unrecognized or unsupported manifest version");
return false;
}
const result = LATEST_MANIFEST_SCHEMA.safeParse(manifestData);
const result = MANIFEST_SCHEMAS[manifestVersion].safeParse(manifestData);
if (result.success) {
console.log("Manifest schema validation passes!");
@ -192,7 +198,12 @@ export async function cleanMcpb(inputPath: string) {
const manifestPath = resolve(unpackPath, "manifest.json");
const originalManifest = await fs.readFile(manifestPath, "utf-8");
const manifestData = JSON.parse(originalManifest);
const result = LATEST_MANIFEST_SCHEMA_LOOSE.safeParse(manifestData);
const manifestVersion = getManifestVersionFromRawData(manifestData);
if (!manifestVersion) {
throw new Error("Unrecognized or unsupported manifest version");
}
const result =
MANIFEST_SCHEMAS_LOOSE[manifestVersion].safeParse(manifestData);
if (!result.success) {
throw new Error(