/** * Creates dist/visit-waterschurch--.zip from ./out for upload * through cPanel File Manager (Upload → Extract). Also copies private/.env.example * next to it as a reminder of what must be configured server-side. */ import { execFileSync } from "node:child_process"; import { promises as fs } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const OUT = path.join(ROOT, "out"); const DIST = path.join(ROOT, "dist"); const pkg = JSON.parse(await fs.readFile(path.join(ROOT, "package.json"), "utf8")); const stamp = new Date().toISOString().slice(0, 10); await fs.mkdir(DIST, { recursive: true }); const zip = path.join(DIST, `visit-waterschurch-${pkg.version}-${stamp}.zip`); await fs.rm(zip, { force: true }); // -X strips extended attributes; -r recursive; . includes dot-files (.htaccess) execFileSync("zip", ["-X", "-r", zip, "."], { cwd: OUT, stdio: "inherit" }); await fs.copyFile(path.join(ROOT, ".env.example"), path.join(DIST, "env.example.txt")); const size = (await fs.stat(zip)).size; console.log(`package: ${path.relative(ROOT, zip)} (${(size / 1024 / 1024).toFixed(1)} MB)`);