scripts/stage-site.ts

1import { cp, mkdir, rm, writeFile } from "node:fs/promises";
2
3// Publish the fixed-source reader artifact, rather than the research workspace.
4// Keep this staging directory distinct from the live local preview's build.
5const source = new URL("../.docs-site/", import.meta.url);
6const destination = new URL("../.local/vercel-static/", import.meta.url);
7await rm(destination, { recursive: true, force: true });
8await mkdir(destination, { recursive: true });
9await cp(source, destination, { recursive: true });
10await writeFile(
11  new URL("vercel.json", destination),
12  JSON.stringify(
13    {
14      $schema: "https://openapi.vercel.sh/vercel.json",
15      framework: null,
16      buildCommand: "",
17      installCommand: "",
18      outputDirectory: ".",
19      redirects: [
20        {
21          source: "/",
22          destination: "/getting-started/index.html",
23          permanent: false,
24        },
25      ],
26    },
27    null,
28    2,
29  ) + "\n",
30);
31console.log(`Staged static site at ${destination.pathname}`);