17 lines
1.1 KiB
JavaScript
17 lines
1.1 KiB
JavaScript
import { mkdir, readFile, rm, writeFile, copyFile } from "node:fs/promises";
|
|
|
|
const text = (file) => readFile(new URL(`../public/${file}`, import.meta.url), "utf8");
|
|
const dist = new URL("../dist/", import.meta.url);
|
|
const server = new URL("../dist/server/", import.meta.url);
|
|
const meta = new URL("../dist/.openai/", import.meta.url);
|
|
|
|
await rm(dist, { recursive: true, force: true });
|
|
await Promise.all([mkdir(server, { recursive: true }), mkdir(meta, { recursive: true })]);
|
|
const [rawIndexHtml, addonsJs] = await Promise.all([text("index.html"), text("addons.js")]);
|
|
const release = "1.0.0";
|
|
const indexHtml = rawIndexHtml.replace('src="addons.js"', `src="addons.js?v=${release}"`);
|
|
await writeFile(new URL("assets.js", server), `export const indexHtml=${JSON.stringify(indexHtml)};\nexport const addonsJs=${JSON.stringify(addonsJs)};\n`);
|
|
await copyFile(new URL("../worker/index.js", import.meta.url), new URL("index.js", server));
|
|
await copyFile(new URL("../.openai/hosting.json", import.meta.url), new URL("hosting.json", meta));
|
|
console.log("Built Life OS Worker artifact");
|