fix(scripts): use powershell instead of pwsh and add DesktopOnly mode
- Replace pwsh with powershell for Windows compatibility - Add -DesktopOnly flag to skip all external services - Add automatic port 1420 cleanup before starting - Improve stop command to kill all related processes - Update package.json scripts for easier access Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,11 +11,10 @@
|
||||
"gateway:start": "openfang gateway start",
|
||||
"gateway:status": "openfang gateway status",
|
||||
"gateway:doctor": "openfang doctor",
|
||||
"start": "pwsh -File ./start-all.ps1",
|
||||
"start:dev": "pwsh -File ./start-all.ps1 -Dev",
|
||||
"start:no-browser": "pwsh -File ./start-all.ps1 -NoBrowser",
|
||||
"start:no-gateway": "pwsh -File ./start-all.ps1 -NoGateway",
|
||||
"start:stop": "pwsh -File ./start-all.ps1 -Stop",
|
||||
"start": "powershell -ExecutionPolicy Bypass -File ./start-all.ps1",
|
||||
"start:dev": "powershell -ExecutionPolicy Bypass -File ./start-all.ps1 -Dev",
|
||||
"start:desktop": "powershell -ExecutionPolicy Bypass -File ./start-all.ps1 -DesktopOnly",
|
||||
"start:stop": "powershell -ExecutionPolicy Bypass -File ./start-all.ps1 -Stop",
|
||||
"desktop": "cd desktop && pnpm tauri dev",
|
||||
"desktop:build": "cd desktop && pnpm tauri build",
|
||||
"chromedriver": "chromedriver --port=4444"
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
# ZCLAW Full Stack Start Script
|
||||
# Starts: ChromeDriver -> OpenFang Gateway -> Tauri Desktop
|
||||
# Starts: ChromeDriver (optional) -> OpenFang Gateway (optional) -> Tauri Desktop
|
||||
|
||||
param(
|
||||
[switch]$NoBrowser,
|
||||
[switch]$NoGateway,
|
||||
[switch]$Dev,
|
||||
[switch]$Help,
|
||||
[switch]$Stop
|
||||
[switch]$Stop,
|
||||
[switch]$DesktopOnly
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Continue"
|
||||
@@ -27,6 +28,7 @@ ZCLAW Full Stack Start Script
|
||||
Usage: .\start-all.ps1 [options]
|
||||
|
||||
Options:
|
||||
-DesktopOnly Start desktop only (skip all external services)
|
||||
-NoBrowser Skip ChromeDriver
|
||||
-NoGateway Skip OpenFang Gateway
|
||||
-Dev Development mode (hot reload)
|
||||
@@ -35,9 +37,7 @@ Options:
|
||||
|
||||
Quick Commands:
|
||||
pnpm start # Start all services
|
||||
pnpm start:dev # Start in dev mode
|
||||
pnpm desktop # Start desktop only
|
||||
pnpm chromedriver # Start ChromeDriver only
|
||||
|
||||
"@
|
||||
exit 0
|
||||
@@ -59,16 +59,27 @@ if ($Stop) {
|
||||
|
||||
# Stop Tauri/ZClaw
|
||||
Get-Process -Name "ZClaw" -ErrorAction SilentlyContinue | Stop-Process -Force
|
||||
Get-Process -Name "desktop" -ErrorAction SilentlyContinue | Stop-Process -Force
|
||||
ok "ZCLAW Desktop stopped"
|
||||
|
||||
# Kill any process on port 1420
|
||||
$port1420 = netstat -ano | Select-String ":1420.*LISTENING"
|
||||
if ($port1420) {
|
||||
$pid1420 = ($port1420 -split '\s+')[-1]
|
||||
if ($pid1420 -match '^\d+$') {
|
||||
Stop-Process -Id $pid1420 -Force -ErrorAction SilentlyContinue
|
||||
ok "Killed process on port 1420 (PID: $pid1420)"
|
||||
}
|
||||
}
|
||||
|
||||
ok "All services stopped"
|
||||
exit 0
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "═══════════════════════════════════════════════════════════" -ForegroundColor Magenta
|
||||
Write-Host " 🦞 ZCLAW - OpenFang Desktop Client" -ForegroundColor Magenta
|
||||
Write-Host "═══════════════════════════════════════════════════════════" -ForegroundColor Magenta
|
||||
Write-Host "===============================================" -ForegroundColor Magenta
|
||||
Write-Host " ZCLAW - OpenFang Desktop Client" -ForegroundColor Magenta
|
||||
Write-Host "===============================================" -ForegroundColor Magenta
|
||||
Write-Host ""
|
||||
|
||||
# Track processes for cleanup
|
||||
@@ -87,7 +98,13 @@ function Cleanup {
|
||||
trap { Cleanup; break }
|
||||
Register-EngineEvent -SourceIdentifier PowerShell.Exiting -Action { Cleanup } | Out-Null
|
||||
|
||||
# 1. ChromeDriver
|
||||
# Skip external services if DesktopOnly
|
||||
if ($DesktopOnly) {
|
||||
$NoBrowser = $true
|
||||
$NoGateway = $true
|
||||
}
|
||||
|
||||
# 1. ChromeDriver (optional)
|
||||
if (-not $NoBrowser) {
|
||||
info "Checking ChromeDriver..."
|
||||
|
||||
@@ -114,11 +131,13 @@ if (-not $NoBrowser) {
|
||||
info "Download: https://chromedriver.chromium.org/downloads"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
info "Skipping ChromeDriver"
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
# 2. OpenFang Gateway
|
||||
# 2. OpenFang Gateway (optional)
|
||||
if (-not $NoGateway) {
|
||||
info "Checking OpenFang Gateway..."
|
||||
|
||||
@@ -156,10 +175,12 @@ if (-not $NoGateway) {
|
||||
warn "Gateway did not respond within 30s"
|
||||
}
|
||||
} else {
|
||||
warn "OpenFang CLI not found"
|
||||
info "Install: https://github.com/openfang/openfang"
|
||||
warn "OpenFang CLI not found. Gateway not started."
|
||||
info "The app will run in standalone mode."
|
||||
}
|
||||
}
|
||||
} else {
|
||||
info "Skipping OpenFang Gateway"
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
@@ -168,6 +189,17 @@ Write-Host ""
|
||||
info "Starting ZCLAW Desktop..."
|
||||
Set-Location "$ScriptDir/desktop"
|
||||
|
||||
# Check if port 1420 is in use
|
||||
$port1420 = netstat -ano | Select-String ":1420.*LISTENING"
|
||||
if ($port1420) {
|
||||
$pid1420 = ($port1420 -split '\s+')[-1]
|
||||
if ($pid1420 -match '^\d+$') {
|
||||
warn "Port 1420 is in use by PID $pid1420. Killing..."
|
||||
Stop-Process -Id $pid1420 -Force -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 1
|
||||
}
|
||||
}
|
||||
|
||||
if ($Dev) {
|
||||
info "Development mode enabled"
|
||||
pnpm tauri dev
|
||||
|
||||
Reference in New Issue
Block a user