2026-08-01 10:20:43 -04:00
|
|
|
import { readFile, writeFile, readdir, copyFile, stat } from "fs/promises";
|
|
|
|
|
|
2026-08-01 11:00:23 -04:00
|
|
|
const PAGES_BASE = "https://rp.jarviscli.dev";
|
2026-08-01 10:20:43 -04:00
|
|
|
const REPO_BASE = "https://github.com/everestmcarthur/revenge-plugins";
|
|
|
|
|
|
|
|
|
|
const meta = JSON.parse(await readFile("./site/meta.json", "utf8"));
|
|
|
|
|
const plugins = [];
|
|
|
|
|
|
|
|
|
|
for (const id of await readdir("./dist")) {
|
|
|
|
|
const dir = `./dist/${id}`;
|
|
|
|
|
if (!(await stat(dir)).isDirectory()) continue;
|
|
|
|
|
|
|
|
|
|
let manifest;
|
|
|
|
|
try {
|
2026-08-01 11:00:23 -04:00
|
|
|
manifest = JSON.parse(await readFile(`${dir}/install/manifest.json`, "utf8"));
|
2026-08-01 10:20:43 -04:00
|
|
|
} catch {
|
|
|
|
|
continue; // not a plugin output directory
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const info = meta[id] ?? {};
|
|
|
|
|
|
|
|
|
|
plugins.push({
|
|
|
|
|
id,
|
|
|
|
|
name: manifest.name,
|
|
|
|
|
description: manifest.description,
|
|
|
|
|
authors: (manifest.authors ?? []).map((a) => a.name),
|
|
|
|
|
category: info.category ?? "Other",
|
|
|
|
|
status: info.status ?? "new",
|
2026-08-01 10:54:05 -04:00
|
|
|
accent: info.accent ?? "#5865f2",
|
|
|
|
|
tagline: info.tagline ?? manifest.description,
|
2026-08-01 10:20:43 -04:00
|
|
|
note: info.note ?? "",
|
2026-08-01 10:54:05 -04:00
|
|
|
howItWorks: info.howItWorks ?? "",
|
|
|
|
|
features: info.features ?? [],
|
|
|
|
|
commands: info.commands ?? [],
|
|
|
|
|
limitations: info.limitations ?? "",
|
2026-08-01 11:00:23 -04:00
|
|
|
pageUrl: `${PAGES_BASE}/${id}/`,
|
|
|
|
|
installUrl: `${PAGES_BASE}/${id}/install/`,
|
2026-08-01 10:20:43 -04:00
|
|
|
sourceUrl: `${REPO_BASE}/tree/main/plugins/${id}`,
|
|
|
|
|
issueUrl: `${REPO_BASE}/issues/new?title=${encodeURIComponent(`[${manifest.name}] `)}`
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
plugins.sort((a, b) => a.category.localeCompare(b.category) || a.name.localeCompare(b.name));
|
|
|
|
|
|
|
|
|
|
await writeFile("./dist/plugins-data.json", JSON.stringify(plugins, null, 2));
|
|
|
|
|
await copyFile("./site/index.html", "./dist/index.html");
|
|
|
|
|
await copyFile("./site/index.html", "./dist/404.html");
|
2026-08-01 11:00:23 -04:00
|
|
|
await copyFile("./site/CNAME", "./dist/CNAME");
|
|
|
|
|
|
|
|
|
|
// Each plugin gets its own real, bookmarkable page at /<id>/ (not just a hash route) - it's the
|
|
|
|
|
// same SPA shell, which reads location.pathname on boot to know which plugin to show directly.
|
|
|
|
|
for (const p of plugins) {
|
|
|
|
|
await copyFile("./site/index.html", `./dist/${p.id}/index.html`);
|
|
|
|
|
}
|
2026-08-01 10:20:43 -04:00
|
|
|
|
|
|
|
|
console.log(`Generated site data for ${plugins.length} plugin(s).`);
|