#!/usr/bin/env bash
# Orchestrator — runs every numbered setup script in order with a confirmation prompt.
# Each script is also runnable individually:
#   ./docs/setup/scripts/40-node.sh
# See docs/setup/01-dev-debian-vm-setup.md for the step-by-step doc.

set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
# shellcheck source=./lib.sh
source "$HERE/lib.sh"

require_debian
require_not_root

SCRIPTS=(
  10-base-packages.sh
  20-zsh.sh
  30-cli-tools.sh
  40-node.sh
  50-docker.sh
  60-tuning.sh
  70-hardening.sh
  80-dotfiles.sh
)

log "Bootstrap will run, in order:"
for s in "${SCRIPTS[@]}"; do
  printf '  - %s\n' "$s"
done
echo

if ! confirm "Continue?"; then
  log "Aborted before any change."
  exit 0
fi

for s in "${SCRIPTS[@]}"; do
  echo
  log "═══ $s ═══"
  if confirm "Run $s now?"; then
    "$HERE/$s"
    ok "$s done"
  else
    skip "$s"
  fi
done

echo
ok "Bootstrap complete."
log "Next steps:"
printf '  - exec zsh -l            # reload shell to pick up zsh + PATH\n'
printf '  - p10k configure         # only if you skipped during 20-zsh.sh\n'
printf '  - cp infra/local/.env.example infra/local/.env && $EDITOR infra/local/.env\n'
printf '  - ./infra/local/dev.sh up\n'
printf '  - pnpm install\n'
