100 lines
2.7 KiB
Bash
Executable File
100 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Development Restart Script
|
|
# Usage: ./dev-restart.sh [cache|config|routes|all|container]
|
|
|
|
set -e
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
ACTION=${1:-cache}
|
|
|
|
print_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
print_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
case $ACTION in
|
|
cache)
|
|
print_info "Clearing Laravel cache..."
|
|
docker-compose exec app php artisan cache:clear
|
|
print_success "Cache cleared!"
|
|
;;
|
|
|
|
config)
|
|
print_info "Clearing configuration cache..."
|
|
docker-compose exec app php artisan config:clear
|
|
print_success "Config cache cleared!"
|
|
;;
|
|
|
|
routes)
|
|
print_info "Clearing route cache..."
|
|
docker-compose exec app php artisan route:clear
|
|
print_success "Route cache cleared!"
|
|
;;
|
|
|
|
all)
|
|
print_info "Clearing all Laravel caches..."
|
|
docker-compose exec app php artisan optimize:clear
|
|
print_success "All caches cleared!"
|
|
;;
|
|
|
|
container)
|
|
print_info "Restarting app container..."
|
|
docker-compose restart app
|
|
print_success "Container restarted!"
|
|
;;
|
|
|
|
build)
|
|
print_info "Rebuilding app container..."
|
|
docker-compose up -d --build app
|
|
print_success "Container rebuilt!"
|
|
;;
|
|
|
|
migrate)
|
|
print_info "Running database migrations..."
|
|
docker-compose exec app php artisan migrate
|
|
print_success "Migrations completed!"
|
|
;;
|
|
|
|
composer)
|
|
print_info "Installing/updating composer dependencies..."
|
|
docker-compose exec app composer install --optimize-autoloader
|
|
print_success "Composer dependencies updated!"
|
|
;;
|
|
|
|
npm)
|
|
print_info "Installing npm dependencies and building assets..."
|
|
docker-compose exec app npm install
|
|
docker-compose exec app npm run dev
|
|
print_success "Frontend assets built!"
|
|
;;
|
|
|
|
*)
|
|
echo "Development Restart Script"
|
|
echo "Usage: $0 [cache|config|routes|all|container|build|migrate|composer|npm]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " cache - Clear application cache only"
|
|
echo " config - Clear configuration cache"
|
|
echo " routes - Clear route cache"
|
|
echo " all - Clear all Laravel caches"
|
|
echo " container - Restart app container"
|
|
echo " build - Rebuild app container"
|
|
echo " migrate - Run database migrations"
|
|
echo " composer - Update composer dependencies"
|
|
echo " npm - Update npm and build assets"
|
|
exit 1
|
|
;;
|
|
esac |