Files
botsu.app/scripts/bootstrap-macos.sh

45 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
if [[ "$(uname -s)" != "Darwin" ]]; then
printf 'Ce bootstrap est prévu pour macOS. Sur Linux: nvm use && npm ci.\n' >&2
exit 1
fi
if ! xcode-select -p >/dev/null 2>&1; then
printf 'Installe les outils Apple puis relance ce script:\n xcode-select --install\n' >&2
exit 1
fi
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
if [[ -s "$NVM_DIR/nvm.sh" ]]; then
# shellcheck source=/dev/null
source "$NVM_DIR/nvm.sh"
elif command -v brew >/dev/null 2>&1 && [[ -s "$(brew --prefix nvm 2>/dev/null)/nvm.sh" ]]; then
# shellcheck source=/dev/null
source "$(brew --prefix nvm)/nvm.sh"
fi
required_node="$(tr -d '[:space:]' < .nvmrc)"
if command -v nvm >/dev/null 2>&1; then
nvm install "$required_node"
nvm use "$required_node"
elif [[ "$(node --version 2>/dev/null || true)" != "v${required_node}" ]]; then
printf 'Node %s est requis. Installe nvm, puis relance:\n' "$required_node" >&2
printf ' https://github.com/nvm-sh/nvm#installing-and-updating\n' >&2
exit 1
fi
if [[ ! -f .env.local ]]; then
cp .env.example .env.local
printf 'Créé: .env.local (configuration locale sans secret)\n'
fi
npm ci
npm test
printf '\nBOTSU est prêt. Lance: npm run dev\nPuis ouvre: http://127.0.0.1:5173\n'