88 lines
2.6 KiB
Bash
Executable File
88 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Phase 1: Prerequisites
|
|
# Development environment setup and validation
|
|
#
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "${SCRIPT_DIR}/config.sh"
|
|
|
|
log_info "=========================================="
|
|
log_info "Phase 1: Prerequisites"
|
|
log_info "=========================================="
|
|
|
|
# 1.1 Development Environment Setup
|
|
log_step "1.1 Checking development environment..."
|
|
|
|
check_prerequisites
|
|
|
|
# Check Node.js version
|
|
NODE_VERSION=$(node --version | cut -d'v' -f2 | cut -d'.' -f1)
|
|
if [ "${NODE_VERSION}" -lt 18 ]; then
|
|
error_exit "Node.js version 18 or higher is required. Current: $(node --version)"
|
|
fi
|
|
log_success "Node.js version: $(node --version)"
|
|
|
|
# Check pnpm version
|
|
PNPM_VERSION=$(pnpm --version | cut -d'.' -f1)
|
|
if [ "${PNPM_VERSION}" -lt 8 ]; then
|
|
error_exit "pnpm version 8 or higher is required. Current: $(pnpm --version)"
|
|
fi
|
|
log_success "pnpm version: $(pnpm --version)"
|
|
|
|
log_success "All tools verified"
|
|
|
|
# 1.2 Proxmox / Sankofa access
|
|
log_step "1.2 Verifying Sankofa Phoenix deployment access..."
|
|
|
|
check_proxmox_access
|
|
log_info "Portal CT host: ${ORDER_PORTAL_PUBLIC_HOST}"
|
|
log_info "Edge HAProxy host: ${ORDER_HAPROXY_HOST}"
|
|
log_info "Order public CT: ${ORDER_PORTAL_PUBLIC_VMID} (${ORDER_PORTAL_PUBLIC_IP}:${ORDER_PORTAL_PUBLIC_PORT})"
|
|
log_info "Order edge HAProxy: ${ORDER_HAPROXY_VMID} (${ORDER_HAPROXY_IP}:80)"
|
|
log_info "Phoenix public URL: ${SANKOFA_PHOENIX_URL}"
|
|
log_info "Portal public URL: ${SANKOFA_PORTAL_URL}"
|
|
|
|
# 1.3 Install Dependencies
|
|
log_step "1.3 Installing dependencies..."
|
|
|
|
cd "${PROJECT_ROOT}"
|
|
|
|
if [ ! -d "node_modules" ]; then
|
|
log_info "Installing dependencies with pnpm..."
|
|
pnpm install --frozen-lockfile || error_exit "Failed to install dependencies"
|
|
log_success "Dependencies installed"
|
|
else
|
|
log_info "Dependencies already installed, skipping..."
|
|
fi
|
|
|
|
# 1.4 Build Packages
|
|
log_step "1.4 Building packages..."
|
|
|
|
if [ "${SKIP_BUILD:-false}" != "true" ]; then
|
|
log_info "Building all packages..."
|
|
pnpm build || error_exit "Failed to build packages"
|
|
log_success "All packages built"
|
|
else
|
|
log_info "Skipping build (SKIP_BUILD=true)"
|
|
fi
|
|
|
|
# 1.5 Initialize Git Submodules (if any)
|
|
log_step "1.5 Initializing git submodules..."
|
|
|
|
if [ -f "${PROJECT_ROOT}/.gitmodules" ]; then
|
|
git submodule update --init --recursive || log_warning "Failed to update submodules"
|
|
log_success "Git submodules initialized"
|
|
else
|
|
log_info "No git submodules found"
|
|
fi
|
|
|
|
# Save state
|
|
save_state "phase1" "complete"
|
|
|
|
log_success "=========================================="
|
|
log_success "Phase 1: Prerequisites - COMPLETE"
|
|
log_success "=========================================="
|