mirror of
https://github.com/anthropics/claude-plugins-official.git
synced 2026-03-20 11:33:08 +00:00
Merge pull request #740 from anthropics/marketplace-sorted
Enforce alphabetical sort on marketplace.json plugins
This commit is contained in:
File diff suppressed because it is too large
Load Diff
42
.github/scripts/check-marketplace-sorted.ts
vendored
Normal file
42
.github/scripts/check-marketplace-sorted.ts
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bun
|
||||||
|
/**
|
||||||
|
* Checks that marketplace.json plugins are alphabetically sorted by name.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* bun check-marketplace-sorted.ts # check, exit 1 if unsorted
|
||||||
|
* bun check-marketplace-sorted.ts --fix # sort in place
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { readFileSync, writeFileSync } from "fs";
|
||||||
|
import { join } from "path";
|
||||||
|
|
||||||
|
const MARKETPLACE = join(import.meta.dir, "../../.claude-plugin/marketplace.json");
|
||||||
|
|
||||||
|
type Plugin = { name: string; [k: string]: unknown };
|
||||||
|
type Marketplace = { plugins: Plugin[]; [k: string]: unknown };
|
||||||
|
|
||||||
|
const raw = readFileSync(MARKETPLACE, "utf8");
|
||||||
|
const mp: Marketplace = JSON.parse(raw);
|
||||||
|
|
||||||
|
const cmp = (a: Plugin, b: Plugin) =>
|
||||||
|
a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
||||||
|
|
||||||
|
if (process.argv.includes("--fix")) {
|
||||||
|
mp.plugins.sort(cmp);
|
||||||
|
writeFileSync(MARKETPLACE, JSON.stringify(mp, null, 2) + "\n");
|
||||||
|
console.log(`sorted ${mp.plugins.length} plugins`);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 1; i < mp.plugins.length; i++) {
|
||||||
|
if (cmp(mp.plugins[i - 1], mp.plugins[i]) > 0) {
|
||||||
|
console.error(
|
||||||
|
`marketplace.json plugins are not sorted: ` +
|
||||||
|
`'${mp.plugins[i - 1].name}' should come after '${mp.plugins[i].name}' (index ${i})`,
|
||||||
|
);
|
||||||
|
console.error(` run: bun .github/scripts/check-marketplace-sorted.ts --fix`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`ok: ${mp.plugins.length} plugins sorted`);
|
||||||
3
.github/workflows/validate-marketplace.yml
vendored
3
.github/workflows/validate-marketplace.yml
vendored
@@ -15,3 +15,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Validate marketplace.json
|
- name: Validate marketplace.json
|
||||||
run: bun .github/scripts/validate-marketplace.ts .claude-plugin/marketplace.json
|
run: bun .github/scripts/validate-marketplace.ts .claude-plugin/marketplace.json
|
||||||
|
|
||||||
|
- name: Check plugins sorted
|
||||||
|
run: bun .github/scripts/check-marketplace-sorted.ts
|
||||||
|
|||||||
Reference in New Issue
Block a user