mirror of
https://github.com/Manavarya09/design-extract.git
synced 2026-09-19 02:41:14 +08:00
78fdf58add
scripts/check-plugin-version.mjs fails loud when plugin.json or marketplace.json drift from package.json; wired as 'npm run check-plugin' and enforced by tests/plugin-version.test.js (also asserts every new command has a backing file and is described). Prevents the drift recurring. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
// Guard: the Claude-plugin manifests must stay in lockstep with package.json.
|
|
//
|
|
// They silently drifted 12 releases behind once (12.10.1 vs 12.22.0). This
|
|
// fails loud — in CI and via the test suite — so it can't happen again.
|
|
|
|
import { readFileSync } from 'fs';
|
|
import { dirname, resolve } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
const read = (p) => JSON.parse(readFileSync(resolve(root, p), 'utf-8'));
|
|
|
|
export function checkPluginVersions() {
|
|
const pkg = read('package.json');
|
|
const plugin = read('.claude-plugin/plugin.json');
|
|
const market = read('.claude-plugin/marketplace.json');
|
|
const marketVersion = market.plugins?.[0]?.version;
|
|
|
|
const problems = [];
|
|
if (plugin.version !== pkg.version) {
|
|
problems.push(`.claude-plugin/plugin.json is ${plugin.version}, expected ${pkg.version}`);
|
|
}
|
|
if (marketVersion !== pkg.version) {
|
|
problems.push(`.claude-plugin/marketplace.json plugin is ${marketVersion}, expected ${pkg.version}`);
|
|
}
|
|
return { ok: problems.length === 0, version: pkg.version, problems };
|
|
}
|
|
|
|
// CLI entry: exit non-zero on drift.
|
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
const { ok, version, problems } = checkPluginVersions();
|
|
if (ok) {
|
|
console.log(`✓ plugin manifests in sync at ${version}`);
|
|
} else {
|
|
console.error('✗ plugin version drift:');
|
|
for (const p of problems) console.error(` - ${p}`);
|
|
process.exit(1);
|
|
}
|
|
}
|