Files
Anilist-App/build_app.sh
T
2026-09-18 20:55:24 +02:00

63 lines
2.1 KiB
Bash
Executable File

#!/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'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>AniList Companion</string>
<key>CFBundleDisplayName</key>
<string>AniList Companion</string>
<key>CFBundleIdentifier</key>
<string>com.anilist-tracker.companion</string>
<key>CFBundleExecutable</key>
<string>AniList Companion</string>
<key>CFBundleIconFile</key>
<string>electron.icns</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>LSMinimumSystemVersion</key>
<string>11.0</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
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"