#!/usr/bin/env bash set -euo pipefail # Installs the locally built Redline into /Applications and launches it with its # session window open, so the current build is what is on screen. # # ./scripts/install-local.sh # # The previously installed copy is kept at .build/Redline-.app so the change # is reversible. ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" BUILT="${ROOT}/.build/Redline.app" TARGET="/Applications/Redline.app" BUNDLE_ID="ai.flowmaster.shotdeck" if [[ ! -d "${BUILT}" ]]; then echo "No ${BUILT}. Run ./scripts/build-app.sh first." >&2 exit 1 fi if [[ -d "${TARGET}" ]]; then OLD_VERSION="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "${TARGET}/Contents/Info.plist")" BACKUP="${ROOT}/.build/Redline-${OLD_VERSION}.app" if [[ ! -d "${BACKUP}" ]]; then echo "==> Keeping the installed ${OLD_VERSION} at ${BACKUP}" ditto "${TARGET}" "${BACKUP}" fi fi echo "==> Quitting the running Redline" osascript -e 'quit app "Redline"' >/dev/null 2>&1 || true for _ in $(seq 1 40); do if ! pgrep -f "${TARGET}/Contents/MacOS/Shotdeck" >/dev/null 2>&1; then break fi sleep 0.25 done pkill -f "${TARGET}/Contents/MacOS/Shotdeck" >/dev/null 2>&1 || true sleep 0.5 echo "==> Installing ${BUILT} to ${TARGET}" ditto "${BUILT}" "${TARGET}" NEW_VERSION="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "${TARGET}/Contents/Info.plist")" echo "==> Launching Redline ${NEW_VERSION} with its window open" open -n "${TARGET}" --args --window sleep 2 if pgrep -f "${TARGET}/Contents/MacOS/Shotdeck" >/dev/null 2>&1; then echo "Redline ${NEW_VERSION} is running from ${TARGET}" else echo "Redline did not start" >&2 exit 1 fi