import { cpSync, mkdirSync, rmSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const buildDir = path.join(rootDir, "build");
const viewDir = path.join(rootDir, "dist", "mainview");

rmSync(viewDir, { recursive: true, force: true });
mkdirSync(viewDir, { recursive: true });
cpSync(buildDir, viewDir, { recursive: true });

console.log(`Synced renderer build to ${viewDir}`);
