#!/bin/bash
set -e

echo "=== Building frontend ==="
npm run build

echo "=== Copying dist to server/ ==="
rm -rf server/dist
cp -r dist server/dist

echo "=== Building Go binary ==="
cd server
go mod init protoc-frontend-server 2>/dev/null || true
GOOS=windows GOARCH=amd64 go build -o ../protoc-frontend.exe .

echo ""
echo "=== Done! ==="
echo "Binary: protoc-frontend.exe"
echo "Usage:  protoc-frontend.exe [-port 1111] [-api http://localhost:8000]"
