1// Saves copies of the site's databases into `.clover`, which is all that a
2// clone of this repository lacks to build the site. With CLOVER_SOT_KEY, the
3// copies are whole; without it, they hold what the site shows anyone.
4const site = "https://paperclover.net";
5const token = process.env.CLOVER_SOT_KEY ?? null;
6
7export async function main() {
8 // for (const name of ["cache.sqlite", "questions.sqlite"]) {
9 // using node = progress.start(`download ${name}`, { units: "bytes" });
10 // const response = await fetch(`${site}/db/${name}`, { headers: token ? { Authorization: token } : {} });
11 // if (!response.ok || !response.body) {
12 // throw new Error(`${site}/db/${name} responded ${response.status} ${response.statusText}`);
13 // }
14 // node.total = Number(response.headers.get("Content-Length"));
15 // await getDatabase(name).restore(response.body.pipeThrough(
16 // new TransformStream({
17 // transform(chunk, controller) {
18 // node.value += chunk.byteLength;
19 // controller.enqueue(chunk);
20 // },
21 // }),
22 // ));
23 // }
24}
25
26import { getDatabase } from "#sitegen/drizzle";
27import * as progress from "@clo/lib/progress";