Something went wrong. Try again.
experiments in a post-browser web
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115#!/bin/bash# Dev setup script: starts servers and opens Xcode with config info
set -e
# Get script directorySCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"SERVER_DIR="$SCRIPT_DIR/../server"
# Reset server data for fresh startrm -rf "$SERVER_DIR/data"
# Get local IP addressIP=$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || echo "localhost")PORT=$((RANDOM % 10000 + 10000)) # Random port between 10000-19999API_KEY="dev-test-key-$(date +%s)"
echo "=========================================="echo " Peek Dev Setup"echo "=========================================="echo ""echo "Local IP: $IP"echo "Server URL: http://$IP:$PORT"echo "API Key: $API_KEY"echo ""
# Start backend server in backgroundecho "Starting backend server..."cd "$SERVER_DIR"API_KEY="$API_KEY" PORT="$PORT" node index.js &BACKEND_PID=$!echo "Backend server started (PID: $BACKEND_PID)"
# Start frontend dev server in backgroundecho "Starting frontend dev server..."cd "$SCRIPT_DIR"npx vite --port 1420 &FRONTEND_PID=$!echo "Frontend server started (PID: $FRONTEND_PID)"
# Wait for servers to be readysleep 3
# Configure iOS simulator with server settingsecho "Configuring iOS simulator..."APP_GROUP=$(xcrun simctl get_app_container booted com.dietrich.peek-mobile groups 2>/dev/null | grep "group.com.dietrich.peek-mobile" | awk '{print $2}')
if [ -n "$APP_GROUP" ]; then DB_PATH="$APP_GROUP/peek.db" if [ -f "$DB_PATH" ]; then sqlite3 "$DB_PATH" "INSERT OR REPLACE INTO settings (key, value) VALUES ('webhook_url', 'http://$IP:$PORT');" sqlite3 "$DB_PATH" "INSERT OR REPLACE INTO settings (key, value) VALUES ('webhook_api_key', '$API_KEY');" echo " Pre-configured server URL and API key in simulator" else echo " Database not found yet - settings will need manual config on first run" fielse echo " App not installed yet - settings will need manual config on first run"fi
# Build and copy librariesecho ""echo "Building Rust libraries..."if [ ! -f src-tauri/target/aarch64-apple-ios-sim/debug/libpeek_save_lib.a ]; then echo " Building debug library (simulator)..." ./build-ios.shelse echo " Debug library exists (use ./build-ios.sh --force to rebuild)"fiif [ ! -f src-tauri/target/aarch64-apple-ios/release/libpeek_save_lib.a ]; then echo " Building release library (device)..." ./build-release.shelse echo " Release library exists (use ./build-release.sh --force to rebuild)"fi
echo "Opening Xcode..."open src-tauri/gen/apple/peek-save.xcodeproj
# Seed test dataecho ""echo "Seeding test data..."SERVER_URL="http://$IP:$PORT" API_KEY="$API_KEY" "$SCRIPT_DIR/seed-test-data.sh"
echo ""echo "=========================================="echo " Ready to test!"echo "=========================================="echo ""echo " Server URL: http://$IP:$PORT"echo " API Key: $API_KEY"echo ""echo "=========================================="echo ""echo "Servers running:"echo " - Frontend: http://localhost:1420 (PID: $FRONTEND_PID)"echo " - Backend: http://$IP:$PORT (PID: $BACKEND_PID)"echo ""echo "Press Ctrl+C to stop all servers."echo ""
# Cleanup functioncleanup() { echo "" echo "Stopping servers..." kill $FRONTEND_PID 2>/dev/null kill $BACKEND_PID 2>/dev/null exit 0}
trap cleanup SIGINT SIGTERM
# Keep script runningwait