import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const srcDir = path.resolve(__dirname, "..", "src");
const distDir = path.resolve(__dirname, "..", "dist");

fs.rmSync(distDir, { recursive: true, force: true });
fs.mkdirSync(distDir, { recursive: true });

for (const file of fs.readdirSync(srcDir)) {
  if (!file.endsWith(".js")) continue;
  fs.copyFileSync(path.join(srcDir, file), path.join(distDir, file));
}

console.log("Built @nebula/core -> dist/");
