add development and build scripts

This commit is contained in:
2026-07-18 22:03:48 +08:00
parent 7800b07d42
commit f7cd69c70f
5 changed files with 77 additions and 0 deletions

11
scripts/build-all.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
"$ROOT_DIR/scripts/build-backend.sh"
"$ROOT_DIR/scripts/build-web.sh"
"$ROOT_DIR/scripts/build-desktop.sh"
echo "All builds completed."

14
scripts/build-backend.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
OUT_DIR="$ROOT_DIR/backend/bin"
mkdir -p "$OUT_DIR"
cd "$ROOT_DIR/backend"
go test ./...
go build -o "$OUT_DIR/senlin-agent-api" ./cmd/api
echo "Backend binary: $OUT_DIR/senlin-agent-api"

10
scripts/build-desktop.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR/apps/desktop"
npm run build
echo "Desktop build completed."

10
scripts/build-web.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR/apps/web"
npm run build
echo "Web build output: $ROOT_DIR/apps/web/dist"

32
scripts/dev-all.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cleanup() {
if [[ -n "${BACKEND_PID:-}" ]]; then
kill "$BACKEND_PID" 2>/dev/null || true
fi
if [[ -n "${WEB_PID:-}" ]]; then
kill "$WEB_PID" 2>/dev/null || true
fi
}
trap cleanup EXIT INT TERM
echo "Starting backend API..."
(
cd "$ROOT_DIR/backend"
go run ./cmd/api
) &
BACKEND_PID=$!
echo "Starting Svelte web client..."
(
cd "$ROOT_DIR/apps/web"
npm run dev
) &
WEB_PID=$!
wait -n "$BACKEND_PID" "$WEB_PID"