#!/usr/bin/env bash
set -euo pipefail

# First run helper for cPanel terminal.
#
# Usage:
#   bash scripts/cpanel_first_run.sh staging
#   bash scripts/cpanel_first_run.sh production

environment="${1:-}"

if [[ "$environment" != "staging" && "$environment" != "production" ]]; then
  echo "Usage: bash scripts/cpanel_first_run.sh <staging|production>"
  exit 1
fi

php scripts/create_env.php "$environment" || true

echo
echo "Edit .env now if it still contains ISI_ or GANTI_ placeholders."
echo "Command:"
echo "  nano .env"
echo
read -r -p "Press ENTER after .env is ready..."

php scripts/post_deploy.php
php scripts/preflight.php
php scripts/deploy_ready.php "$environment"
php scripts/step7_smoke_test.php
php scripts/migrate.php status

echo
echo "First run checks finished for $environment."

