Files
zclaw_openfang/scripts/quick-start.sh
iven 0d4fa96b82
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
refactor: 统一项目名称从OpenFang到ZCLAW
重构所有代码和文档中的项目名称,将OpenFang统一更新为ZCLAW。包括:
- 配置文件中的项目名称
- 代码注释和文档引用
- 环境变量和路径
- 类型定义和接口名称
- 测试用例和模拟数据

同时优化部分代码结构,移除未使用的模块,并更新相关依赖项。
2026-03-27 07:36:03 +08:00

219 lines
5.0 KiB
Bash

#!/bin/bash
#
# ZCLAW Development Quick Start Script
#
# Usage:
# ./scripts/quick-start.sh [options]
#
# Options:
# --skip-backend Skip backend startup (assume already running)
# --desktop-only Start desktop only
# --stop Stop all services
# --help Show this help message
#
set -e
PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
SKIP_BACKEND=false
DESKTOP_ONLY=false
STOP_SERVICES=false
# Parse arguments
for arg in "$@"; do
case $arg in
--skip-backend)
SKIP_BACKEND=true
shift
;;
--desktop-only)
DESKTOP_ONLY=true
shift
;;
--stop)
STOP_SERVICES=true
shift
;;
--help)
echo "ZCLAW Development Quick Start Script"
echo ""
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo " --skip-backend Skip backend startup"
echo " --desktop-only Start desktop only"
echo " --stop Stop all services"
echo " --help Show this help"
exit 0
;;
*)
echo "Unknown option: $arg"
exit 1
;;
esac
done
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Output functions
step() {
echo -e "\n${CYAN}[STEP]${NC} $1"
}
success() {
echo -e "${GREEN}[OK]${NC} $1"
}
warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Stop services
if [ "$STOP_SERVICES" = true ]; then
step "Stopping all services..."
# Kill ZCLAW processes
pkill -f "zclaw" 2>/dev/null || true
# Kill Vite processes
pkill -f "vite" 2>/dev/null || true
# Kill Tauri processes
pkill -f "tauri" 2>/dev/null || true
success "All services stopped"
exit 0
fi
echo -e "${CYAN}========================================${NC}"
echo -e "${CYAN} ZCLAW Development Quick Start${NC}"
echo -e "${CYAN}========================================${NC}"
# 1. Check Node.js
step "Checking Node.js..."
if ! command -v node &> /dev/null; then
error "Node.js not found"
echo "Please install from https://nodejs.org"
exit 1
fi
NODE_VERSION=$(node -v | sed 's/v//')
MAJOR_VERSION=$(echo "$NODE_VERSION" | cut -d. -f1)
if [ "$MAJOR_VERSION" -lt 18 ]; then
error "Node.js version too low: v$NODE_VERSION (requires 18+)"
echo "Please upgrade from https://nodejs.org"
exit 1
fi
success "Node.js $(node -v)"
# 2. Check pnpm
step "Checking pnpm..."
if ! command -v pnpm &> /dev/null; then
warn "pnpm not found, installing..."
npm install -g pnpm
if [ $? -ne 0 ]; then
error "Failed to install pnpm"
exit 1
fi
fi
success "pnpm $(pnpm -v)"
# 3. Check and install dependencies
step "Checking dependencies..."
if [ ! -d "$PROJECT_ROOT/node_modules" ]; then
echo "Installing root dependencies..."
cd "$PROJECT_ROOT"
pnpm install
fi
if [ ! -d "$PROJECT_ROOT/desktop/node_modules" ]; then
echo "Installing desktop dependencies..."
cd "$PROJECT_ROOT/desktop"
pnpm install
fi
success "Dependencies ready"
# 4. Check/Start backend
if [ "$SKIP_BACKEND" = false ] && [ "$DESKTOP_ONLY" = false ]; then
step "Checking backend service..."
BACKEND_RUNNING=false
if curl -s --connect-timeout 2 "http://127.0.0.1:50051/api/health" > /dev/null 2>&1; then
BACKEND_RUNNING=true
success "Backend service already running"
fi
if [ "$BACKEND_RUNNING" = false ]; then
echo "Starting ZCLAW backend..."
STARTED=false
# Method 1: Use zclaw CLI
if command -v zclaw &> /dev/null; then
zclaw start &
STARTED=true
fi
# Method 2: Use the project's start script
if [ "$STARTED" = false ] && [ -f "$PROJECT_ROOT/start-all.sh" ]; then
"$PROJECT_ROOT/start-all.sh" &
STARTED=true
fi
if [ "$STARTED" = false ]; then
error "Cannot start backend service"
echo "Please start ZCLAW manually:"
echo " zclaw start"
exit 1
fi
# Wait for backend
echo "Waiting for backend to start..."
RETRIES=0
MAX_RETRIES=15
while [ $RETRIES -lt $MAX_RETRIES ]; do
sleep 1
if curl -s --connect-timeout 2 "http://127.0.0.1:50051/api/health" > /dev/null 2>&1; then
success "Backend started successfully"
break
fi
RETRIES=$((RETRIES + 1))
printf "."
done
if [ $RETRIES -ge $MAX_RETRIES ]; then
error "Backend startup timeout"
echo "Please check if ZCLAW is properly installed"
exit 1
fi
fi
fi
# 5. Start development environment
step "Starting development environment..."
cd "$PROJECT_ROOT"
if [ "$DESKTOP_ONLY" = true ]; then
echo "Starting desktop only..."
pnpm desktop
else
echo "Starting full development environment..."
pnpm start:dev
fi