63 lines
1.9 KiB
Bash
Executable File
63 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Load shared libraries
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/../lib/init.sh"
|
|
|
|
# Cleanup Script
|
|
# Removes build artifacts, node_modules, and other generated files
|
|
|
|
set -e
|
|
|
|
echo "🧹 Cleaning workspace..."
|
|
|
|
read -p "This will remove node_modules, dist, build, and cache directories. Continue? (y/N) " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "Cancelled."
|
|
exit 1
|
|
fi
|
|
|
|
PROJECTS_DIR="."
|
|
CLEANED=0
|
|
|
|
clean_project() {
|
|
local project=$1
|
|
|
|
if [ -d "$project" ]; then
|
|
cd "$project"
|
|
|
|
# Remove common build artifacts
|
|
[ -d "node_modules" ] && rm -rf node_modules && echo " 🧹 Removed $project/node_modules"
|
|
[ -d "dist" ] && rm -rf dist && echo " 🧹 Removed $project/dist"
|
|
[ -d "build" ] && rm -rf build && echo " 🧹 Removed $project/build"
|
|
[ -d ".next" ] && rm -rf .next && echo " 🧹 Removed $project/.next"
|
|
[ -d "coverage" ] && rm -rf coverage && echo " 🧹 Removed $project/coverage"
|
|
[ -d ".cache" ] && rm -rf .cache && echo " 🧹 Removed $project/.cache"
|
|
[ -d "artifacts" ] && rm -rf artifacts && echo " 🧹 Removed $project/artifacts"
|
|
[ -d "cache" ] && rm -rf cache && echo " 🧹 Removed $project/cache"
|
|
|
|
((CLEANED++))
|
|
cd ..
|
|
fi
|
|
}
|
|
|
|
echo "📋 Cleaning projects..."
|
|
|
|
# Clean all projects
|
|
for dir in */; do
|
|
if [ -d "$dir" ] && [ "$dir" != ".git/" ] && [ "$dir" != "scripts/" ]; then
|
|
clean_project "$dir"
|
|
fi
|
|
done
|
|
|
|
# Clean root level
|
|
[ -d "node_modules" ] && rm -rf node_modules && echo " 🧹 Removed root node_modules"
|
|
[ -d "dist" ] && rm -rf dist && echo " 🧹 Removed root dist"
|
|
[ -d "build" ] && rm -rf build && echo " 🧹 Removed root build"
|
|
|
|
echo ""
|
|
echo "✅ Cleanup complete! Cleaned $CLEANED projects."
|
|
echo "💡 Run 'pnpm install' or 'npm install' in projects to restore dependencies."
|
|
|