verstak-desktop/scripts/build.sh

133 lines
3.4 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
echo "=== verstak-desktop build ==="
echo ""
# ── Dependency checks ──
echo "[deps]"
if ! command -v go &>/dev/null; then
echo " ❌ go: not found. Install Go 1.24+ from https://go.dev/dl/"
exit 1
fi
echo " ✅ go $(go version | grep -oP 'go\S+')"
if ! command -v node &>/dev/null; then
echo " ❌ node: not found. Install Node.js 20+"
exit 1
fi
echo " ✅ node $(node --version)"
if ! command -v npm &>/dev/null; then
echo " ❌ npm: not found"
exit 1
fi
echo " ✅ npm $(npm --version)"
# ── Frontend (build first — Go //go:embed needs frontend/dist/) ──
echo ""
echo "[frontend]"
if [ -f "$ROOT/frontend/package.json" ]; then
if [ ! -d "$ROOT/frontend/node_modules" ]; then
echo " 📦 node_modules missing — installing..."
if [ -f "$ROOT/frontend/package-lock.json" ]; then
(cd "$ROOT/frontend" && npm ci --no-audit --no-fund)
else
(cd "$ROOT/frontend" && npm install --no-audit --no-fund)
fi
fi
(cd "$ROOT/frontend" && npm run build)
echo " ✅ frontend build"
else
echo " frontend/package.json not found — skipping"
fi
# ── Go backend ──
echo ""
echo "[backend]"
echo " 📦 go mod download..."
(cd "$ROOT" && go mod download)
echo " ✅ go mod download"
echo " 🔍 go vet..."
(cd "$ROOT" && go vet ./...)
echo " ✅ go vet"
echo " 🔨 go build..."
(cd "$ROOT" && go build ./...)
echo " ✅ go build"
echo " 🧪 go test..."
(cd "$ROOT" && go test -count=1 ./...)
echo " ✅ go test"
# ── Wails ──
echo ""
echo "[wails]"
WAILS=""
if command -v wails &>/dev/null; then
WAILS="wails"
else
GOBIN="$(go env GOBIN 2>/dev/null)"
GOPATH="$(go env GOPATH 2>/dev/null)"
if [ -n "$GOBIN" ] && [ -f "$GOBIN/wails" ]; then
WAILS="$GOBIN/wails"
elif [ -f "$GOPATH/bin/wails" ]; then
WAILS="$GOPATH/bin/wails"
fi
if [ -z "$WAILS" ]; then
echo " 📦 wails not found — installing..."
go install github.com/wailsapp/wails/v2/cmd/wails@latest
if [ -n "$GOBIN" ] && [ -f "$GOBIN/wails" ]; then
WAILS="$GOBIN/wails"
elif [ -f "$GOPATH/bin/wails" ]; then
WAILS="$GOPATH/bin/wails"
fi
fi
fi
WAILS_BINARY="verstak-desktop"
WAILS_TAGS=""
if command -v pkg-config &>/dev/null; then
if pkg-config --exists webkit2gtk-4.1 2>/dev/null; then
WAILS_TAGS="-tags webkit2_41"
echo " using webkit2gtk-4.1"
elif pkg-config --exists webkit2gtk-4.0 2>/dev/null; then
echo " using webkit2gtk-4.0"
else
echo " ⚠️ no webkit2gtk found — wails requires libwebkit2gtk-4.0-dev or libwebkit2gtk-4.1-dev"
fi
else
echo " ⚠️ pkg-config not found"
fi
if [ -z "$WAILS" ]; then
echo " ❌ wails: could not find or install"
exit 1
fi
echo " 🔨 wails build..."
(cd "$ROOT" && "$WAILS" build -clean $WAILS_TAGS)
echo " ✅ wails build"
# Copy plugins/ to build/bin/ so the binary can find them at runtime
if [ -d "$ROOT/plugins" ]; then
mkdir -p "$ROOT/build/bin/plugins"
cp -r "$ROOT/plugins/"* "$ROOT/build/bin/plugins/" 2>/dev/null || true
echo " 📦 plugins copied to build/bin/plugins/"
fi
# Show where the binary ended up
if [ -f "$ROOT/build/bin/$WAILS_BINARY" ]; then
echo " 📦 binary: $ROOT/build/bin/$WAILS_BINARY"
fi
if [ -f "$ROOT/$WAILS_BINARY" ]; then
echo " 📦 binary: $ROOT/$WAILS_BINARY"
fi
echo ""
echo "✅ build passed"