mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-04 03:46:59 +01:00
* chore: pnpm — the fleet has one package manager - packageManager pnpm@11.25.0; lockfile via pnpm import, package-lock.json gone - npm overrides moved to pnpm-workspace.yaml overrides (pnpm ignores package.json overrides); allowBuilds for @parcel/watcher, @sentry/cli, @swc/core, esbuild, puppeteer, unrs-resolver, and the ai-forms git dep (pnpm requires the exact resolved URL for git-dep prepare builds) - @tiptap/core added as a direct dependency: RichTextEditor.tsx augments 'module @tiptap/core' and tiptap-markdown's Storage augmentation rides on it — a phantom dependency npm's hoisting hid and pnpm's isolation exposed - all workflows: pnpm/action-setup@v6 before setup-node, cache: pnpm, store-dir pinned, pnpm install --frozen-lockfile; Next cache key now hashes pnpm-lock.yaml - scripts/ci/dependency-audit.sh: pnpm audit --prod (parses both npm-v2 'vulnerabilities' and pnpm's v1 'advisories' shapes) - selfhost-deploy-evig.sh, ship.sh, start-all.sh, e2e-inventory-prod.sh, husky pre-commit, Dockerfile.prod (node 24 + corepack) converted - engines: node >=22.13 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn * fix(deps): declare espree — eslint.config.mjs imports it directly npm's hoisting provided it as a phantom; pnpm's isolated node_modules exposed ERR_MODULE_NOT_FOUND in CI. Verified in a true clean room (parent node_modules masked): full verify green, 7783 tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn * fix(deps): declare tsx — npx fetched it on demand, pnpm exec does not e2e:seed (and the hirn:*/setup-admins scripts) ran 'npx tsx', which silently downloaded tsx because it was never in devDependencies. pnpm exec only resolves installed bins, so CI's Seed E2E step died with 'Command tsx not found'. Declare it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn * fix(ci): drop '--' separators — pnpm run forwards them verbatim npm strips the first '--' before handing args to the script; pnpm 11 passes it through, so 'pnpm run start -- -p 3001' executed 'next start -- -p 3001' and next read '-p' as a project directory. pnpm forwards everything after the script name anyway, so the separator is dead weight: remove it in ci.yml (start, e2e journeys, e2e guards) and ship.sh. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn --------- Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
196 lines
6.1 KiB
Bash
Executable File
196 lines
6.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# =============================================================================
|
|
# RevampIT - Unified Startup Script
|
|
# =============================================================================
|
|
# Starts all services in the correct order with health checks
|
|
# Usage: ./scripts/start-all.sh [--stop]
|
|
# =============================================================================
|
|
|
|
set -e
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Configuration
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
NEXTJS_PORT="${NEXTJS_PORT:-3000}"
|
|
DB_PORT="${DB_PORT:-5433}"
|
|
|
|
# Parse arguments
|
|
STOP_ALL=false
|
|
for arg in "$@"; do
|
|
case $arg in
|
|
--stop)
|
|
STOP_ALL=true
|
|
shift
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Function to print status
|
|
print_status() {
|
|
echo -e "${BLUE}[RevampIT]${NC} $1"
|
|
}
|
|
|
|
print_success() {
|
|
echo -e "${GREEN}✓${NC} $1"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}⚠${NC} $1"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}✗${NC} $1"
|
|
}
|
|
|
|
# Function to check if a port is in use
|
|
port_in_use() {
|
|
lsof -i :"$1" >/dev/null 2>&1
|
|
}
|
|
|
|
# Function to wait for a service to be ready
|
|
wait_for_service() {
|
|
local name="$1"
|
|
local host="$2"
|
|
local port="$3"
|
|
local max_attempts="${4:-30}"
|
|
local attempt=1
|
|
|
|
print_status "Waiting for $name on port $port..."
|
|
|
|
while [ $attempt -le $max_attempts ]; do
|
|
if nc -z "$host" "$port" 2>/dev/null; then
|
|
print_success "$name is ready"
|
|
return 0
|
|
fi
|
|
sleep 1
|
|
attempt=$((attempt + 1))
|
|
done
|
|
|
|
print_error "$name failed to start within ${max_attempts}s"
|
|
return 1
|
|
}
|
|
|
|
# Function to stop all services
|
|
stop_all_services() {
|
|
print_status "Stopping all services..."
|
|
|
|
# Kill Next.js
|
|
pkill -f "next dev" 2>/dev/null || true
|
|
|
|
# Stop Docker containers
|
|
cd "$PROJECT_DIR"
|
|
docker compose down 2>/dev/null || true
|
|
|
|
print_success "All services stopped"
|
|
}
|
|
|
|
# Handle stop command
|
|
if [ "$STOP_ALL" = true ]; then
|
|
stop_all_services
|
|
exit 0
|
|
fi
|
|
|
|
# =============================================================================
|
|
# MAIN STARTUP SEQUENCE
|
|
# =============================================================================
|
|
|
|
cd "$PROJECT_DIR"
|
|
|
|
echo ""
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${BLUE} RevampIT Startup ${NC}"
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Step 1: Start Docker Infrastructure
|
|
# -----------------------------------------------------------------------------
|
|
print_status "Step 1: Starting Docker infrastructure..."
|
|
|
|
# Check if Docker is running
|
|
if ! docker info >/dev/null 2>&1; then
|
|
print_error "Docker is not running. Please start Docker first."
|
|
exit 1
|
|
fi
|
|
|
|
# Start all required containers
|
|
docker compose up -d db meilisearch listmonk
|
|
|
|
# Wait for services to be healthy
|
|
wait_for_service "PostgreSQL" "localhost" "$DB_PORT" 30
|
|
wait_for_service "Meilisearch" "localhost" 7700 15
|
|
|
|
print_success "Docker infrastructure is ready"
|
|
echo ""
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Step 2: Start Transcription Service (optional)
|
|
# -----------------------------------------------------------------------------
|
|
TRANSCRIPTION_PORT="${TRANSCRIPTION_PORT:-5111}"
|
|
|
|
if port_in_use "$TRANSCRIPTION_PORT"; then
|
|
print_warning "Transcription service already running on port $TRANSCRIPTION_PORT"
|
|
elif [ -d "$PROJECT_DIR/services/transcription/.venv" ]; then
|
|
print_status "Step 2: Starting transcription service..."
|
|
"$PROJECT_DIR/services/transcription/start.sh" &
|
|
TRANSCRIPTION_PID=$!
|
|
echo $TRANSCRIPTION_PID > "$PROJECT_DIR/.transcription.pid"
|
|
wait_for_service "Transcription" "localhost" "$TRANSCRIPTION_PORT" 30
|
|
else
|
|
print_warning "Transcription service not set up (run: npm run transcription:setup)"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Step 3: Start Next.js Frontend
|
|
# -----------------------------------------------------------------------------
|
|
print_status "Step 3: Starting Next.js frontend..."
|
|
|
|
cd "$PROJECT_DIR"
|
|
|
|
if port_in_use "$NEXTJS_PORT"; then
|
|
print_warning "Next.js already running on port $NEXTJS_PORT"
|
|
else
|
|
# Create logs directory if it doesn't exist
|
|
mkdir -p "$PROJECT_DIR/logs"
|
|
|
|
# Start Next.js
|
|
print_status "Starting Next.js on port $NEXTJS_PORT..."
|
|
WATCHPACK_POLLING=1 pnpm run dev &
|
|
NEXTJS_PID=$!
|
|
echo $NEXTJS_PID > "$PROJECT_DIR/.nextjs.pid"
|
|
|
|
# Wait for Next.js to be ready
|
|
wait_for_service "Next.js" "localhost" "$NEXTJS_PORT" 30
|
|
fi
|
|
|
|
# =============================================================================
|
|
# STARTUP COMPLETE
|
|
# =============================================================================
|
|
|
|
echo ""
|
|
echo -e "${GREEN}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${GREEN} All Services Running! ${NC}"
|
|
echo -e "${GREEN}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
echo -e " ${BLUE}Frontend:${NC} http://localhost:${NEXTJS_PORT}"
|
|
echo -e " ${BLUE}Admin:${NC} http://localhost:${NEXTJS_PORT}/admin"
|
|
echo -e " ${BLUE}Meilisearch:${NC} http://localhost:7700"
|
|
echo ""
|
|
echo -e " ${YELLOW}To stop all services:${NC} npm run stop:all"
|
|
echo ""
|
|
|
|
# Keep the script running to show Next.js output
|
|
wait
|