mirror of
https://github.com/anthropics/claude-plugins-official.git
synced 2026-03-17 22:43:09 +00:00
Add a GitHub Actions workflow that validates marketplace.json is well-formed JSON with a plugins array whenever PRs modify it. Includes: - validate-marketplace.ts: Bun script that parses and validates the JSON - validate-marketplace.yml: GH Actions workflow triggered on PR changes - test-marketplace-check.js: Unit tests for the validation logic Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
#!/usr/bin/env bun
|
|
/**
|
|
* Validates that marketplace.json is well-formed JSON with a plugins array.
|
|
*
|
|
* Usage:
|
|
* bun validate-marketplace.ts <path-to-marketplace.json>
|
|
*/
|
|
|
|
import { readFile } from "fs/promises";
|
|
|
|
async function main() {
|
|
const filePath = process.argv[2];
|
|
if (!filePath) {
|
|
console.error("Usage: validate-marketplace.ts <path-to-marketplace.json>");
|
|
process.exit(2);
|
|
}
|
|
|
|
const content = await readFile(filePath, "utf-8");
|
|
|
|
let parsed: unknown;
|
|
try {
|
|
parsed = JSON.parse(content);
|
|
} catch (err) {
|
|
console.error(
|
|
`ERROR: ${filePath} is not valid JSON: ${err instanceof Error ? err.message : err}`
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
console.error(`ERROR: ${filePath} must be a JSON object`);
|
|
process.exit(1);
|
|
}
|
|
|
|
const marketplace = parsed as Record<string, unknown>;
|
|
if (!Array.isArray(marketplace.plugins)) {
|
|
console.error(`ERROR: ${filePath} missing "plugins" array`);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(
|
|
`marketplace.json is valid (${marketplace.plugins.length} plugins)`
|
|
);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error("Fatal error:", err);
|
|
process.exit(2);
|
|
});
|