clawdie-ai/scripts/update-readme-version.mjs
Operator & Codex d8cbd5ca70 chore(multitenant): harden agent workflow and README sync
Move the multitenant agent-workflow decision into repo docs, enforce effective author/committer identities in the pre-commit hook, and replace the shell-based README version rewrite with a reusable Node helper.

---
Build: pass | Tests: pass — node scripts/update-readme-version.mjs --check; sh -n hooks/pre-commit

---
Build: FAIL | Tests: FAIL — Tests  58 failed | 1109 passed (1167)

---
Build: FAIL | Tests: FAIL — Tests  58 failed | 1107 passed (1165)
2026-04-25 07:58:18 +02:00

34 lines
1.1 KiB
JavaScript

import { readFile, writeFile } from 'node:fs/promises';
const checkOnly = process.argv.includes('--check');
const packageJson = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
const readmeUrl = new URL('../README.md', import.meta.url);
const readme = await readFile(readmeUrl, 'utf8');
const currentReleaseHeader = '## Current Release';
const expectedLine = `\`v${packageJson.version}\``;
const versionLinePattern = /^`v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*`/m;
if (!readme.includes(currentReleaseHeader)) {
console.error('update-readme-version: README.md is missing the Current Release section');
process.exit(1);
}
if (!versionLinePattern.test(readme)) {
console.error('update-readme-version: could not find the README Current Release version line');
process.exit(1);
}
const updated = readme.replace(versionLinePattern, expectedLine);
if (checkOnly) {
if (updated !== readme) {
console.error(`update-readme-version: README.md is out of sync; expected ${expectedLine}`);
process.exit(1);
}
process.exit(0);
}
if (updated !== readme) {
await writeFile(readmeUrl, updated, 'utf8');
}