mirror of
https://github.com/anthropics/claude-plugins-official.git
synced 2026-03-17 10:33:08 +00:00
Add CI workflow to validate marketplace.json on PRs
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>
This commit is contained in:
committed by
Tobin South
parent
b36fd4b753
commit
7d7f29cf27
49
.github/scripts/validate-marketplace.ts
vendored
Normal file
49
.github/scripts/validate-marketplace.ts
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/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);
|
||||
});
|
||||
Reference in New Issue
Block a user