#!/usr/bin/env node import fs from "fs"; import path from "path"; import { fileURLToPath } from "url"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); function processDir(src, dest, processFile) { if (!fs.existsSync(src)) { console.warn(`Source directory not found: ${src}`); return; } if (fs.existsSync(dest)) { fs.rmSync(dest, { recursive: true, force: true }); } fs.mkdirSync(dest, { recursive: true }); const entries = fs.readdirSync(src, { withFileTypes: true }); for (const entry of entries) { const srcPath = path.join(src, entry.name); const destPath = path.join(dest, entry.name); if (entry.isDirectory()) { processDir(srcPath, destPath, processFile); } else { processFile(srcPath, destPath); } } } function copyFile(src, dest) { fs.copyFileSync(src, dest); } function processAndCopyFile(src, dest) { let content = fs.readFileSync(src, "utf-8"); // Fix relative imports to include .ts extension for Vercel // This helps Node.js module resolution work correctly at runtime if (src.endsWith(".ts")) { // Add .ts extension to relative imports if not already present content = content.replace( /from\s+['"](\.[^'"]*?)(?