#!/bin/bash # Environment Validation Script # Checks if all prerequisites are installed and configured correctly set -e # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' print_header() { echo -e "\n${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo -e "${BLUE}$1${NC}" echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}\n" } print_check() { if [ $1 -eq 0 ]; then echo -e "${GREEN}✓${NC} $2" return 0 else echo -e "${RED}✗${NC} $2" return 1 fi } print_warning() { echo -e "${YELLOW}⚠${NC} $1" } print_info() { echo -e "${BLUE}ℹ${NC} $1" } # Track overall status ALL_CHECKS_PASSED=0 print_header "🔍 Validating Copilot SDK Development Environment" # Check GitHub CLI print_header "GitHub CLI" if command -v gh &> /dev/null; then VERSION=$(gh --version | head -n1) print_check 0 "GitHub CLI installed: $VERSION" # Check authentication if gh auth status &> /dev/null; then print_check 0 "GitHub CLI is authenticated" else print_check 1 "GitHub CLI is not authenticated" print_info "Run: gh auth login" ALL_CHECKS_PASSED=1 fi else print_check 1 "GitHub CLI not found" print_info "Install from: https://cli.github.com/" ALL_CHECKS_PASSED=1 fi # Check Copilot CLI print_header "Copilot CLI" if command -v copilot &> /dev/null; then print_check 0 "Copilot CLI is installed" # Try to get version if copilot --version &> /dev/null; then VERSION=$(copilot --version 2>&1 | head -n1 || echo "version check failed") print_info "Version: $VERSION" fi else print_check 1 "Copilot CLI not found" print_info "Install: gh extension install github/gh-copilot" ALL_CHECKS_PASSED=1 fi # Check Node.js print_header "Node.js / TypeScript SDK" if command -v node &> /dev/null; then NODE_VERSION=$(node -v) print_check 0 "Node.js installed: $NODE_VERSION" # Check version is 18+ NODE_MAJOR=$(echo $NODE_VERSION | cut -d'v' -f2 | cut -d'.' -f1) if [ "$NODE_MAJOR" -ge 18 ]; then print_check 0 "Node.js version is 18+" else print_warning "Node.js version should be 18 or higher" fi if command -v npm &> /dev/null; then NPM_VERSION=$(npm -v) print_check 0 "npm installed: $NPM_VERSION" else print_check 1 "npm not found" fi else print_warning "Node.js not installed (optional)" print_info "Install from: https://nodejs.org/" fi # Check Python print_header "Python SDK" if command -v python3 &> /dev/null; then PYTHON_VERSION=$(python3 --version) print_check 0 "Python installed: $PYTHON_VERSION" if command -v pip3 &> /dev/null; then PIP_VERSION=$(pip3 --version) print_check 0 "pip installed: $PIP_VERSION" else print_check 1 "pip not found" fi # Check for uv (recommended) if command -v uv &> /dev/null; then UV_VERSION=$(uv --version) print_check 0 "uv installed: $UV_VERSION (recommended)" else print_warning "uv not installed (recommended for faster package management)" print_info "Install: curl -LsSf https://astral.sh/uv/install.sh | sh" fi else print_warning "Python not installed (optional)" print_info "Install from: https://www.python.org/" fi # Check Go print_header "Go SDK" if command -v go &> /dev/null; then GO_VERSION=$(go version) print_check 0 "Go installed: $GO_VERSION" else print_warning "Go not installed (optional)" print_info "Install from: https://go.dev/doc/install" fi # Check .NET print_header ".NET SDK" if command -v dotnet &> /dev/null; then DOTNET_VERSION=$(dotnet --version) print_check 0 ".NET installed: $DOTNET_VERSION" else print_warning ".NET not installed (optional)" print_info "Install from: https://dotnet.microsoft.com/download" fi # Check additional tools print_header "Additional Tools" if command -v git &> /dev/null; then GIT_VERSION=$(git --version) print_check 0 "Git installed: $GIT_VERSION" else print_check 1 "Git not found (required)" ALL_CHECKS_PASSED=1 fi if command -v code &> /dev/null; then print_check 0 "VS Code installed" else print_warning "VS Code not installed (recommended)" print_info "Install from: https://code.visualstudio.com/" fi if command -v just &> /dev/null; then JUST_VERSION=$(just --version) print_check 0 "just command runner installed: $JUST_VERSION" else print_warning "just not installed (optional, useful for running tasks)" print_info "Install from: https://github.com/casey/just" fi # Summary print_header "Summary" if [ $ALL_CHECKS_PASSED -eq 0 ]; then echo -e "${GREEN}✓ All required checks passed!${NC}" echo "" echo "Your environment is ready for Copilot SDK development!" echo "" echo "Next steps:" echo "1. Choose a template from: templates/" echo "2. Copy the template to start your project" echo "3. Follow the template's README for setup" echo "" echo "Quick start:" echo " cd templates/typescript-quickstart # or python-quickstart" echo " npm install # or pip install -r requirements.txt" echo " cp ../../.env.example .env" echo " npm start # or python src/main.py" exit 0 else echo -e "${YELLOW}⚠ Some checks failed${NC}" echo "" echo "Please install the missing required components before continuing." echo "See the messages above for installation instructions." echo "" echo "Required:" echo " - GitHub CLI (gh)" echo " - Copilot CLI extension" echo " - Git" echo "" echo "Optional (at least one SDK):" echo " - Node.js (for TypeScript SDK)" echo " - Python (for Python SDK)" echo " - Go (for Go SDK)" echo " - .NET (for .NET SDK)" exit 1 fi