Add validation to ensure the manifest_version matches the current expected version (0.2) during the mcpb pack command. This prevents users from packing extensions with outdated or incorrect manifest versions. Changes: - Add CURRENT_MANIFEST_VERSION constant to centralize version management - Validate manifest version in pack command before creating bundle - Update init command to use version constant - Update tests to use version constant - Fix prettier formatting issues
25 lines
643 B
JavaScript
25 lines
643 B
JavaScript
import {
|
|
McpbManifestSchema,
|
|
McpbSignatureInfoSchema,
|
|
} from "../dist/schemas.js";
|
|
import * as z from "zod/v4";
|
|
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
|
|
const schemasToWrite = {
|
|
"mcpb-manifest": McpbManifestSchema,
|
|
"mcpb-signature-info": McpbSignatureInfoSchema,
|
|
};
|
|
|
|
await fs.mkdir(path.join(import.meta.dirname, "../dist"), { recursive: true });
|
|
|
|
for (const key in schemasToWrite) {
|
|
const schema = z.toJSONSchema(schemasToWrite[key]);
|
|
await fs.writeFile(
|
|
path.join(import.meta.dirname, "../dist", `${key}.schema.json`),
|
|
JSON.stringify(schema, null, 2),
|
|
{
|
|
encoding: "utf8",
|
|
},
|
|
);
|
|
}
|