Something went wrong. Try again.
Monorepo for Aesthetic.Computer aesthetic.computer
Something went wrong. Try again.
5.4 kB · 192 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193#!/usr/bin/env fish# Aesthetic Computer Electron - Mac Development Script# Usage: ./dev.fish [options]## Options:# --prod Start in production mode (aesthetic.computer)# --dev Start in dev mode (localhost:8888)# --shell Start with shell/terminal view# --inspect Enable DevTools on port 9229 (default)# --no-inspect Disable DevTools/CDP# --watch Watch for changes and auto-restart# --build Build DMG before running# --piece=NAME Start with specific piece (default: prompt)## Examples:# ./dev.fish # Run dev mode with inspector# ./dev.fish --prod # Run production mode# ./dev.fish --watch # Watch mode with auto-restart# ./dev.fish --build --prod # Build DMG then run production
set -l script_dir (dirname (status -f))cd $script_dir
# Colorsset -l cyan (set_color cyan)set -l green (set_color green)set -l yellow (set_color yellow)set -l red (set_color red)set -l magenta (set_color magenta)set -l normal (set_color normal)
echo "$magenta🎨 Aesthetic Computer Electron - Dev Environment$normal"echo ""
# Parse argumentsset -l mode "dev"set -l inspect trueset -l watch falseset -l build falseset -l piece "prompt"set -l extra_args
for arg in $argv switch $arg case "--prod" "--production" set mode "prod" case "--dev" "--development" set mode "dev" case "--shell" set extra_args $extra_args "--shell" case "--inspect" set inspect true case "--no-inspect" set inspect false case "--watch" set watch true case "--build" set build true case "--piece=*" set piece (string replace -- "--piece=" "" $arg) case "*" set extra_args $extra_args $arg endend
# Build electron argsset -l electron_args "."if test "$mode" = "dev" set electron_args $electron_args "--dev"endif test -n "$piece" set electron_args $electron_args "--piece=$piece"endset electron_args $electron_args $extra_args
# Inspector argsset -l inspect_argsif test "$inspect" = true set inspect_args "--inspect=9229" "--remote-debugging-port=9222" echo "$cyan📡 DevTools Inspector:$normal http://localhost:9229" echo "$cyan🔗 CDP (Chrome DevTools Protocol):$normal http://localhost:9222" echo ""end
# Get electron pathset -l electron_bin "./node_modules/electron/dist/Electron.app/Contents/MacOS/Electron"
if not test -f $electron_bin echo "$red✗ Electron not found. Running npm install...$normal" npm installend
# Build if requestedif test "$build" = true echo "$yellow🔨 Building macOS DMG...$normal" npm run build:mac echo ""end
# Show modeif test "$mode" = "dev" echo "$yellow🔧 Mode: DEVELOPMENT (localhost:8888)$normal"else echo "$green🚀 Mode: PRODUCTION (aesthetic.computer)$normal"endecho ""
# Function to run electronfunction run_electron echo "$cyan▶ Starting Electron...$normal" echo " $electron_bin $inspect_args $electron_args" echo "" # Run with CDP ports $electron_bin $inspect_args $electron_args return $statusend
# Watch mode using fswatchif test "$watch" = true echo "$magenta👁 Watch mode enabled - will restart on file changes$normal" echo " Watching: main.js, preload.js, webview-preload.js, renderer/" echo " Press Ctrl+C to stop" echo "" # Start electron in background set -l electron_pid function restart_electron if test -n "$electron_pid" echo "" echo "$yellow♻️ Restarting Electron...$normal" kill $electron_pid 2>/dev/null sleep 0.5 end $electron_bin $inspect_args $electron_args & set -g electron_pid $last_pid echo "$green✓ Electron started (PID: $electron_pid)$normal" end function cleanup echo "" echo "$cyan🛑 Stopping...$normal" if test -n "$electron_pid" kill $electron_pid 2>/dev/null end exit 0 end trap cleanup SIGINT SIGTERM # Initial start restart_electron # Watch for changes if command -v fswatch >/dev/null fswatch -o main.js preload.js webview-preload.js offscreen-manager.js "renderer/" | while read -l event restart_electron end else echo "$yellow⚠ fswatch not installed. Install with: brew install fswatch$normal" echo " Running without watch - press Ctrl+C and re-run to pick up changes" wait $electron_pid endelse # Normal run with restart loop set -l restart_count 0 while true if test $restart_count -gt 0 echo "" echo "$yellow♻️ Restarting Electron (restart #$restart_count)...$normal" sleep 1 end run_electron set -l exit_code $status if test $exit_code -eq 42 # Exit code 42 = intentional reboot request set restart_count (math $restart_count + 1) echo "$green✓ Reboot request received$normal" else echo "" echo "$cyan✓ Electron exited with code $exit_code$normal" break end endend
echo "$magenta👋 Goodbye!$normal"