diff options
| author | Kenneth Lien <kenneth@anthropic.com> | 2026-03-18 16:56:11 -0700 |
|---|---|---|
| committer | Kenneth Lien <kenneth@anthropic.com> | 2026-03-18 16:56:11 -0700 |
| commit | f0fdb72a020f26c456ecfd7c91208bce96c0cc40 (patch) | |
| tree | ba57046579da68b1896f6601159b9d2d92c8279a /.github/scripts | |
| parent | 158ef95c6f7fc1b5629b5a915e2af2c07d15e237 (diff) | |
Enforce alphabetical sort on marketplace.json pluginsmarketplace-sorted
Adds a sort check as a second step in the existing validate-marketplace
workflow. The script supports --fix to sort in place.
Sorts the existing 86 entries — pure reorder, no content change.
Previously grouped loosely by kind (LSPs first, then internal, then
external); now strictly alphabetical so insertion point is unambiguous.
Diffstat (limited to '.github/scripts')
| -rw-r--r-- | .github/scripts/check-marketplace-sorted.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/.github/scripts/check-marketplace-sorted.ts b/.github/scripts/check-marketplace-sorted.ts new file mode 100644 index 00000000..0fcbf3be --- /dev/null +++ b/.github/scripts/check-marketplace-sorted.ts @@ -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`); |
