mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-27 07:58:01 +01:00
Serves the standalone Meetings showcase from public/meetings/ at /hex/meetings/ (the Worker 301s /hex/meetings there so relative paths resolve). `bun run import:meetings <bundle>` copies only the files the page loads and drops session ids and the bundle's social tags; the build writes the canonical address, Open Graph and Twitter tags for its origin and refuses missing references or files over 25 MiB. Adds og-meetings.png (Hex mark, "Hex Meetings", a meeting pill), Meetings links in the landing page header and footer, and sitemap and llms.txt entries.
34 lines
1.8 KiB
TypeScript
34 lines
1.8 KiB
TypeScript
#!/usr/bin/env bun
|
|
// Replaces the Meetings showcase in public/meetings/ with a new cut of the
|
|
// standalone page, copying only the files it loads (scripts/meetings-bundle.ts)
|
|
// and keeping the social card. Build tools, shader sources, reports, and raw
|
|
// audio stay behind. The page's social tags come from the build
|
|
// (scripts/meetings.ts), so the bundle's own are dropped here.
|
|
//
|
|
// bun run import:meetings ~/code/home/artifacts/<date>-hex-meetings-v15
|
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs"
|
|
import { dirname, join, resolve } from "node:path"
|
|
import { MEETINGS_CARD, runtimeFiles, stripHead } from "./meetings-bundle"
|
|
|
|
const source = process.argv[2]
|
|
if (!source || !existsSync(join(source, "index.html"))) throw new Error("usage: bun run import:meetings <bundle folder with index.html>")
|
|
const dest = resolve(import.meta.dirname, "../public/meetings")
|
|
|
|
const bundle = runtimeFiles(source)
|
|
if (bundle.missing.length) {
|
|
throw new Error(`The bundle names files it doesn't have:\n${bundle.missing.map((m) => ` ${m.from}: ${m.ref}`).join("\n")}`)
|
|
}
|
|
|
|
mkdirSync(dest, { recursive: true })
|
|
for (const name of readdirSync(dest)) if (name !== MEETINGS_CARD) rmSync(join(dest, name), { recursive: true, force: true })
|
|
let bytes = 0
|
|
for (const file of bundle.files) {
|
|
mkdirSync(dirname(join(dest, file)), { recursive: true })
|
|
copyFileSync(join(source, file), join(dest, file))
|
|
bytes += statSync(join(dest, file)).size
|
|
}
|
|
|
|
// Session ids and the bundle's own social and canonical tags never ship.
|
|
const index = join(dest, "index.html")
|
|
writeFileSync(index, stripHead(readFileSync(index, "utf8")))
|
|
console.log(`Meetings: ${bundle.files.length} files, ${(bytes / 1024 / 1024).toFixed(2)} MiB from ${source}`)
|