74 lines
2.7 KiB
Bash
74 lines
2.7 KiB
Bash
#!/bin/bash
|
|
# Package the CocotteAI macOS cockpit into a double-clickable .app bundle.
|
|
# Builds release, assembles Contents/{MacOS,Resources,Info.plist}, generates the
|
|
# ✦ rose icon. Run on plum (macOS, Swift). Output: ./build/CocotteAI.app
|
|
#
|
|
# ./scripts/package-app.sh [output-dir]
|
|
#
|
|
# Live data: the app reads ~/Library/Application Support/CocotteAI/config.json
|
|
# (apiBase/userId/token/orgId). No config → mock dataset. See main.swift.
|
|
set -euo pipefail
|
|
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
OUT="${1:-$HERE/build}"
|
|
APP="$OUT/CocotteAI.app"
|
|
BUNDLE_ID="tech.cocotte.cockpit.macos"
|
|
EXEC="CocotteCockpit"
|
|
|
|
cd "$HERE"
|
|
echo "→ swift build -c release"
|
|
swift build -c release
|
|
BIN="$(swift build -c release --show-bin-path)/$EXEC"
|
|
[ -x "$BIN" ] || { echo "build produced no $EXEC at $BIN" >&2; exit 1; }
|
|
|
|
echo "→ assembling $APP"
|
|
rm -rf "$APP"
|
|
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
|
|
cp "$BIN" "$APP/Contents/MacOS/$EXEC"
|
|
|
|
echo "→ generating icon"
|
|
ICONSET="$OUT/AppIcon.iconset"
|
|
rm -rf "$ICONSET"
|
|
swift "$HERE/scripts/make-icon.swift" "$ICONSET"
|
|
iconutil -c icns "$ICONSET" -o "$APP/Contents/Resources/AppIcon.icns"
|
|
rm -rf "$ICONSET"
|
|
|
|
cat > "$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>CocotteAI</string>
|
|
<key>CFBundleDisplayName</key><string>CocotteAI</string>
|
|
<key>CFBundleExecutable</key><string>$EXEC</string>
|
|
<key>CFBundleIdentifier</key><string>$BUNDLE_ID</string>
|
|
<key>CFBundleIconFile</key><string>AppIcon</string>
|
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
<key>CFBundleShortVersionString</key><string>0.1.0</string>
|
|
<key>CFBundleVersion</key><string>1</string>
|
|
<key>LSMinimumSystemVersion</key><string>14.0</string>
|
|
<key>NSHighResolutionCapable</key><true/>
|
|
<!-- LAN dev: platform.api is cleartext http://black.lan:3060 (per INFRA.md).
|
|
Unbundled CLI binaries skip ATS, but a bundled .app enforces it — without
|
|
this exception URLSession silently fails and the cockpit shows "offline".
|
|
Prod (HTTPS via Caddy) needs no exception; tighten/remove before shipping. -->
|
|
<key>NSAppTransportSecurity</key>
|
|
<dict>
|
|
<key>NSExceptionDomains</key>
|
|
<dict>
|
|
<key>black.lan</key>
|
|
<dict>
|
|
<key>NSExceptionAllowsInsecureHTTPLoads</key><true/>
|
|
<key>NSIncludesSubdomains</key><true/>
|
|
</dict>
|
|
</dict>
|
|
</dict>
|
|
<key>NSHumanReadableCopyright</key><string>cocotte.tech</string>
|
|
</dict>
|
|
</plist>
|
|
PLIST
|
|
|
|
# Ad-hoc codesign so Gatekeeper/launchd accept the local bundle.
|
|
codesign --force --deep --sign - "$APP" >/dev/null 2>&1 || echo " (codesign skipped)"
|
|
|
|
echo "✓ built $APP"
|