Files
indiekit-server/scripts/patch-store-github-error-message.mjs
Sven 2d5b713b7d
Some checks failed
Deploy Indiekit Server / deploy (push) Failing after 7s
chore: point svemagie fork deps and docs at Gitea
- Switch 4 svemagie fork deps from github: shorthand to git+https://gitea.giersig.eu/svemagie/...
- Add patch-store-github-error-message.mjs to replace hardcoded github.com token URL with gitea.giersig.eu
- Update CLAUDE.md and README.md fork dependency docs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 15:05:49 +02:00

56 lines
1.5 KiB
JavaScript

import { access, readFile, writeFile } from "node:fs/promises";
const candidates = [
"node_modules/@indiekit/store-github/index.js",
];
const MARKER = "// [patched] store-github-error-message";
const OLD_SNIPPET = ` \`Ensure the GitHub token is not expired and has the necessary permissions\`,
\`You can check your tokens here: https://github.com/settings/tokens\`,`;
const NEW_SNIPPET = ` \`Ensure the Gitea token is not expired and has the necessary permissions\`,
\`You can check your tokens here: https://gitea.giersig.eu/user/settings/applications\`, ${MARKER}`;
async function exists(path) {
try {
await access(path);
return true;
} catch {
return false;
}
}
let checked = 0;
let patched = 0;
for (const filePath of candidates) {
if (!(await exists(filePath))) {
continue;
}
checked += 1;
const source = await readFile(filePath, "utf8");
if (source.includes(MARKER)) {
console.log("[postinstall] store-github error message already patched");
continue;
}
if (!source.includes(OLD_SNIPPET)) {
console.warn("[postinstall] store-github: unexpected source layout, skipping");
continue;
}
const updated = source.replace(OLD_SNIPPET, NEW_SNIPPET);
await writeFile(filePath, updated, "utf8");
patched += 1;
}
if (checked === 0) {
console.log("[postinstall] No store-github index.js found");
} else if (patched > 0) {
console.log(`[postinstall] Patched store-github error message in ${patched} file(s)`);
}