#!/bin/bash

# Clean build script for cPanel deployment
# This script helps prevent file system related build errors

echo "🧹 Cleaning up build artifacts..."

# Remove existing build directories
rm -rf .next
rm -rf out
rm -rf dist

# Clear npm/yarn cache
echo "🗑️  Clearing package manager cache..."
npm cache clean --force 2>/dev/null || true

# Clean node_modules if needed (uncomment if having persistent issues)
# echo "🗑️  Removing node_modules..."
# rm -rf node_modules
# npm install

echo "✅ Cleanup complete! Ready for build."

# Run the build
echo "🏗️  Starting build..."
npm run build

echo "🎉 Build completed successfully!"
