#!/bin/bash
# Run this on Mac or Linux to rebuild the native binary locally.
set -e
cd "$(dirname "$0")"

echo "=== JG Music Tools — Mac/Linux native build ==="

if [ ! -f package.json ]; then
  echo "ERROR: package.json not found"
  exit 1
fi

npm ci

OS=$(uname -s)
if [ "$OS" = "Darwin" ]; then
  echo "Building Mac binary..."
  npm run build:mac
else
  echo "Building Linux AppImage..."
  npm run build:linux
fi

echo
echo "=== Build complete ==="
ls -la dist/*.{dmg,AppImage} 2>/dev/null || true
echo
echo "Upload to /apps/ via your _deploy.php endpoint."
