#!/usr/bin/env bash # Builds "AniList Companion.app" by copying the already-downloaded # Electron.app binary and rebranding it with our app code + a custom # Info.plist - avoids re-downloading Electron via electron-builder (disk # space is tight), same technique electron-packager uses internally. set -euo pipefail DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ELECTRON_APP="$DIR/node_modules/electron/dist/Electron.app" OUT_APP="/Applications/AniList Companion.app" if [ ! -d "$ELECTRON_APP" ]; then echo "Electron.app not found at $ELECTRON_APP - run 'npm install' first." >&2 exit 1 fi rm -rf "$OUT_APP" cp -R "$ELECTRON_APP" "$OUT_APP" # Rename the binary itself so it shows up correctly in Activity Monitor / # Dock, and embed our app source into Contents/Resources/app. mv "$OUT_APP/Contents/MacOS/Electron" "$OUT_APP/Contents/MacOS/AniList Companion" RESOURCES="$OUT_APP/Contents/Resources" mkdir -p "$RESOURCES/app" cp -R "$DIR/src" "$RESOURCES/app/src" cp "$DIR/package.json" "$RESOURCES/app/package.json" # Custom Info.plist: proper app name, bundle id, icon reference. cat > "$OUT_APP/Contents/Info.plist" << 'PLIST' CFBundleName AniList Companion CFBundleDisplayName AniList Companion CFBundleIdentifier com.anilist-tracker.companion CFBundleExecutable AniList Companion CFBundleIconFile electron.icns CFBundlePackageType APPL CFBundleShortVersionString 1.0.0 CFBundleVersion 1.0.0 LSMinimumSystemVersion 11.0 NSHighResolutionCapable PLIST # Re-sign ad-hoc so macOS Gatekeeper accepts the renamed/modified bundle. codesign --force --deep --sign - "$OUT_APP" 2>&1 | tail -5 echo "Built: $OUT_APP"