fix: improve JSON schema generation and publishing
- Refactor JSON schema generation to use zod-to-json-schema - Publish manifest schema to schemas/ directory - Update package.json exports for schema files - Add WIP version 0.3 support - Clean up schema generation scripts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d595dd66dc
commit
2a0ba89918
1 changed files with 363 additions and 15 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import {
|
||||
McpbManifestSchema,
|
||||
McpbSignatureInfoSchema,
|
||||
} from "../dist/schemas.js";
|
||||
import * as z from "zod/v4";
|
||||
} from "../dist/schemas/latest.js";
|
||||
import { zodToJsonSchema } from "zod-to-json-schema";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
|
|
@ -11,15 +11,23 @@ const schemasToWrite = {
|
|||
"mcpb-signature-info": McpbSignatureInfoSchema,
|
||||
};
|
||||
|
||||
await fs.mkdir(path.join(import.meta.dirname, "../dist"), { recursive: true });
|
||||
const distDir = path.join(import.meta.dirname, "../dist");
|
||||
const schemasDir = path.join(import.meta.dirname, "../schemas");
|
||||
|
||||
// Generate all schemas to dist/
|
||||
await fs.mkdir(distDir, { 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",
|
||||
},
|
||||
);
|
||||
const schema = zodToJsonSchema(schemasToWrite[key]);
|
||||
const filePath = path.join(distDir, `${key}.schema.json`);
|
||||
await fs.writeFile(filePath, JSON.stringify(schema, null, 2), {
|
||||
encoding: "utf8",
|
||||
});
|
||||
}
|
||||
|
||||
// Generate only manifest schema to schemas/
|
||||
await fs.mkdir(schemasDir, { recursive: true });
|
||||
const manifestSchema = zodToJsonSchema(McpbManifestSchema);
|
||||
const manifestPath = path.join(schemasDir, "mcpb-manifest.schema.json");
|
||||
await fs.writeFile(manifestPath, JSON.stringify(manifestSchema, null, 2), {
|
||||
encoding: "utf8",
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue