From 138e45fe0a8669feea3bef441e9098a2b828f3fd Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Tue, 2 Jun 2026 11:07:48 +0200 Subject: [PATCH] feat(dev): add 'magic' subcommand to dev.sh for RebreakMagic macOS app ./dev.sh magic - xcodegen + xcodebuild Release + relaunch ./dev.sh magic --debug - Debug-Config ./dev.sh magic --xcode - Only generate project + open Xcode ./dev.sh magic --no-build - Skip build, just relaunch ./dev.sh magic --no-launch - Build only Auto-checks for ~/.config/rebreak-magic/config.json and points to template if missing. Pre-kills any running RebreakMagic instance before launch. --- apps/rebreak-native/dev.sh | 87 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/apps/rebreak-native/dev.sh b/apps/rebreak-native/dev.sh index 9d70307..0102a6b 100755 --- a/apps/rebreak-native/dev.sh +++ b/apps/rebreak-native/dev.sh @@ -11,6 +11,7 @@ # ./dev.sh clean iOS: Nuclear clean (Pods, DerivedData, Archives) # ./dev.sh install ios Build Release + Install auf iPhone USB # ./dev.sh install android Build Debug APK + Install auf Android Device +# ./dev.sh magic Build + Launch RebreakMagic.app (macOS Wizard) # # FLAGS (ios): # --device Build auf physisches iPhone via USB (DEFAULT) @@ -33,6 +34,12 @@ # --build + iOS build am Ende # --xcode + Xcode öffnen am Ende # +# FLAGS (magic): +# --no-build Nur launchen (App muss schon gebaut sein) +# --xcode Nur Xcode-Projekt generieren + öffnen +# --debug Debug-Konfiguration statt Release +# --no-launch Build, aber App nicht öffnen +# # BEISPIELE: # # Default: iPhone USB + Native-Build: # ./dev.sh @@ -61,6 +68,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" IOS_DIR="$SCRIPT_DIR/ios" ANDROID_DIR="$SCRIPT_DIR/android" +MAGIC_DIR="$SCRIPT_DIR/../rebreak-magic-mac" # ═══════════════════════════════════════════════════════════════════════════ # Color Output @@ -421,6 +429,79 @@ cmd_install_android() { ok "Fertig" } +cmd_magic() { + local BUILD=true + local LAUNCH=true + local XCODE_ONLY=false + local CONFIGURATION="Release" + + while [[ $# -gt 0 ]]; do + case "$1" in + --no-build) BUILD=false; shift ;; + --no-launch) LAUNCH=false; shift ;; + --xcode) XCODE_ONLY=true; shift ;; + --debug) CONFIGURATION="Debug"; shift ;; + *) die "Unbekannter Flag für 'magic': $1" ;; + esac + done + + section "RebreakMagic (macOS Wizard)" + + [[ -d "$MAGIC_DIR" ]] || die "rebreak-magic-mac nicht gefunden: $MAGIC_DIR" + command -v xcodebuild >/dev/null 2>&1 || die "xcodebuild fehlt — xcode-select --install" + + cd "$MAGIC_DIR" + + # Xcode-Projekt aus project.yml generieren (idempotent) + if command -v xcodegen >/dev/null 2>&1; then + log "xcodegen generate" + xcodegen generate >/dev/null + else + warn "xcodegen nicht installiert — überspringe project-regeneration (brew install xcodegen)" + fi + + if $XCODE_ONLY; then + log "Opening Xcode..." + open -a Xcode "$MAGIC_DIR/RebreakMagic.xcodeproj" + ok "Xcode geöffnet — Cmd+R für Build & Run" + return 0 + fi + + local BUILD_DIR="$MAGIC_DIR/build" + local APP_PATH="$BUILD_DIR/Build/Products/$CONFIGURATION/RebreakMagic.app" + + if $BUILD; then + log "xcodebuild ($CONFIGURATION)" + xcodebuild \ + -project RebreakMagic.xcodeproj \ + -scheme RebreakMagic \ + -configuration "$CONFIGURATION" \ + -derivedDataPath "$BUILD_DIR" \ + build | tail -20 + [[ -d "$APP_PATH" ]] || die "Build fehlgeschlagen — $APP_PATH nicht gefunden" + ok "Build erfolgreich: $APP_PATH" + else + [[ -d "$APP_PATH" ]] || die "App nicht vorhanden ($APP_PATH) — ohne --no-build neu starten" + fi + + # Config-Check + local CONFIG_FILE="$HOME/.config/rebreak-magic/config.json" + if [[ ! -f "$CONFIG_FILE" ]]; then + warn "Config fehlt: $CONFIG_FILE" + echo " → Template kopieren: cp $MAGIC_DIR/config.example.json $CONFIG_FILE" + echo " → Dann editieren: backendBaseUrl=https://staging.rebreak.org" + fi + + if $LAUNCH; then + log "Killing running RebreakMagic instance..." + pkill -x RebreakMagic 2>/dev/null || true + sleep 0.5 + log "Launching $APP_PATH" + open "$APP_PATH" + ok "RebreakMagic gestartet" + fi +} + # ═══════════════════════════════════════════════════════════════════════════ # Main # ═══════════════════════════════════════════════════════════════════════════ @@ -459,6 +540,10 @@ case "$COMMAND" in esac ;; + magic) + cmd_magic "$@" + ;; + -h|--help) awk '/^#!/{next} /^#/{sub(/^# ?/, ""); print; next} {exit}' "$0" exit 0 @@ -474,8 +559,10 @@ case "$COMMAND" in echo " clean iOS Nuclear Clean" echo " install ios Release-Build auf iPhone installieren" echo " install android Debug-APK auf Android installieren" + echo " magic Build + Launch RebreakMagic.app (macOS)" echo "" echo "Nutze --help für Details" + exit 1 ;; esac