a8c48e7409
Deploy Indiekit Server / deploy (push) Successful in 1m44s
require.resolve() failed with ERR_PACKAGE_PATH_NOT_EXPORTED because the package exports field doesn't expose ./lib/federation-setup.js as a public path. Rewritten to use filesystem candidates array like all other patches.
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
/**
|
|
* Patch @rmdes/indiekit-endpoint-activitypub federation-setup.js:
|
|
* - personOptions.alsoKnownAs → personOptions.aliases (Fedify uses 'aliases')
|
|
* - Add movedTo → personOptions.successor (Fedify uses 'successor')
|
|
*/
|
|
|
|
import { access, readFile, writeFile } from "node:fs/promises";
|
|
|
|
const candidates = [
|
|
"node_modules/@rmdes/indiekit-endpoint-activitypub/lib/federation-setup.js",
|
|
"node_modules/@indiekit/indiekit/node_modules/@rmdes/indiekit-endpoint-activitypub/lib/federation-setup.js",
|
|
];
|
|
|
|
const MARKER = "// patch-actor-aliases-successor: applied";
|
|
|
|
const OLD = ` if (profile.alsoKnownAs?.length > 0) {
|
|
personOptions.alsoKnownAs = profile.alsoKnownAs.map((u) => new URL(u));
|
|
}`;
|
|
|
|
const NEW = ` if (profile.alsoKnownAs?.length > 0) {
|
|
personOptions.aliases = profile.alsoKnownAs.map((u) => new URL(u));
|
|
}
|
|
if (profile.movedTo) {
|
|
personOptions.successor = new URL(profile.movedTo);
|
|
}
|
|
${MARKER}`;
|
|
|
|
async function exists(p) {
|
|
try { await access(p); return true; } catch { return false; }
|
|
}
|
|
|
|
let patched = false;
|
|
for (const filePath of candidates) {
|
|
if (!(await exists(filePath))) continue;
|
|
const src = await readFile(filePath, "utf8");
|
|
if (src.includes(MARKER)) {
|
|
console.log(`[postinstall] patch-actor-aliases-successor: already applied in ${filePath}`);
|
|
patched = true;
|
|
break;
|
|
}
|
|
if (!src.includes(OLD)) {
|
|
console.log(`[postinstall] patch-actor-aliases-successor: target not found in ${filePath}`);
|
|
continue;
|
|
}
|
|
await writeFile(filePath, src.replace(OLD, NEW), "utf8");
|
|
console.log(`[postinstall] patch-actor-aliases-successor: applied to ${filePath}`);
|
|
patched = true;
|
|
break;
|
|
}
|
|
|
|
if (!patched) {
|
|
console.log("[postinstall] patch-actor-aliases-successor: no target file found");
|
|
}
|