fix: reorder build — frontend before Go (//go:embed deps), auto-install node_modules/go mod
This commit is contained in:
parent
aefb9e9a9c
commit
e3b0bf5f4b
|
|
@ -13,23 +13,76 @@ report() {
|
|||
fi
|
||||
}
|
||||
|
||||
ensure_npm_deps() {
|
||||
local dir="$1"
|
||||
if [ ! -f "$dir/package.json" ]; then
|
||||
return 1
|
||||
fi
|
||||
if [ ! -d "$dir/node_modules" ]; then
|
||||
echo " 📦 node_modules missing — installing..."
|
||||
if [ -f "$dir/package-lock.json" ]; then
|
||||
(cd "$dir" && npm ci --no-audit --no-fund)
|
||||
else
|
||||
(cd "$dir" && npm install --no-audit --no-fund)
|
||||
fi
|
||||
report "npm install in $(basename "$dir")" $?
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
echo "=== verstak-desktop build ==="
|
||||
|
||||
# ── Dependency checks ──
|
||||
echo "[deps]"
|
||||
if ! command -v go &>/dev/null; then
|
||||
echo " ❌ go: not found. Install Go 1.24+ from https://go.dev/dl/"
|
||||
FAILED=1
|
||||
else
|
||||
echo " ✅ go $(go version | grep -oP 'go\S+')"
|
||||
fi
|
||||
if ! command -v node &>/dev/null; then
|
||||
echo " ❌ node: not found. Install Node.js 20+"
|
||||
FAILED=1
|
||||
else
|
||||
echo " ✅ node $(node --version)"
|
||||
fi
|
||||
if ! command -v npm &>/dev/null; then
|
||||
echo " ❌ npm: not found"
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
if [ "$FAILED" -ne 0 ]; then
|
||||
echo ""
|
||||
echo "❌ build failed — missing core dependencies"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ── Frontend (build first — Go //go:embed needs frontend/dist/) ──
|
||||
echo "[frontend]"
|
||||
if [ -f "$ROOT/frontend/package.json" ]; then
|
||||
ensure_npm_deps "$ROOT/frontend"
|
||||
(cd "$ROOT/frontend" && npm run build)
|
||||
report "frontend build" $?
|
||||
else
|
||||
echo " ℹ️ frontend/package.json not found — skipping"
|
||||
fi
|
||||
|
||||
# ── Go backend ──
|
||||
echo "[backend]"
|
||||
|
||||
# Ensure Go module deps are downloaded
|
||||
(cd "$ROOT" && go mod download)
|
||||
report "go mod download" $?
|
||||
|
||||
(cd "$ROOT" && go vet ./...)
|
||||
report "go vet" $?
|
||||
|
||||
(cd "$ROOT" && go build ./...)
|
||||
report "go build" $?
|
||||
|
||||
if command -v go-test-summary &>/dev/null || go test -list . ./... &>/dev/null 2>&1; then
|
||||
(cd "$ROOT" && go test -count=1 ./... 2>&1 || true)
|
||||
report "go test" $?
|
||||
else
|
||||
echo " ℹ️ go test: no tests to run"
|
||||
fi
|
||||
# Go test (best-effort — some packages may have no tests)
|
||||
(cd "$ROOT" && go test -count=1 ./... 2>&1 || true)
|
||||
report "go test" $?
|
||||
|
||||
# ── Wails ──
|
||||
echo "[wails]"
|
||||
|
|
@ -41,17 +94,6 @@ else
|
|||
FAILED=1
|
||||
fi
|
||||
|
||||
# ── Frontend ──
|
||||
echo "[frontend]"
|
||||
if [ -f "$ROOT/frontend/package.json" ]; then
|
||||
(cd "$ROOT/frontend" && npm ci --no-audit --no-fund)
|
||||
report "npm ci" $?
|
||||
(cd "$ROOT/frontend" && npm run build)
|
||||
report "frontend build" $?
|
||||
else
|
||||
echo " ℹ️ frontend/package.json not found — skipping"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
if [ "$FAILED" -eq 0 ]; then
|
||||
echo "✅ build passed"
|
||||
|
|
|
|||
|
|
@ -13,13 +13,34 @@ report() {
|
|||
fi
|
||||
}
|
||||
|
||||
ensure_npm_deps() {
|
||||
local dir="$1"
|
||||
if [ ! -f "$dir/package.json" ]; then
|
||||
return 1
|
||||
fi
|
||||
if [ ! -d "$dir/node_modules" ]; then
|
||||
echo " 📦 node_modules missing — installing..."
|
||||
if [ -f "$dir/package-lock.json" ]; then
|
||||
(cd "$dir" && npm ci --no-audit --no-fund)
|
||||
else
|
||||
(cd "$dir" && npm install --no-audit --no-fund)
|
||||
fi
|
||||
report "npm install in $(basename "$dir")" $?
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
echo "=== verstak-desktop check ==="
|
||||
|
||||
# Go vet
|
||||
# ── Go deps ──
|
||||
(cd "$ROOT" && go mod download)
|
||||
report "go mod download" $?
|
||||
|
||||
# ── Go vet ──
|
||||
(cd "$ROOT" && go vet ./...)
|
||||
report "go vet" $?
|
||||
|
||||
# Go fmt (non-destructive — only report unformatted files)
|
||||
# ── Go fmt (non-destructive — only report unformatted files) ──
|
||||
UNFORMATTED=$(cd "$ROOT" && gofmt -l . 2>/dev/null || go fmt -n ./... 2>&1 || true)
|
||||
if [ -z "$UNFORMATTED" ]; then
|
||||
echo " ✅ gofmt: all files formatted"
|
||||
|
|
@ -29,22 +50,26 @@ else
|
|||
FAILED=1
|
||||
fi
|
||||
|
||||
# Go mod tidy check (non-destructive — report only)
|
||||
# ── Go mod tidy check (non-destructive) ──
|
||||
(cd "$ROOT" && go mod tidy -diff 2>&1 || echo " ⚠️ go mod tidy check skipped")
|
||||
report "go mod tidy" $?
|
||||
|
||||
# Frontend lint
|
||||
if [ -f "$ROOT/frontend/package.json" ]; then
|
||||
# Check if npm ci is needed (node_modules missing)
|
||||
if [ ! -d "$ROOT/frontend/node_modules" ]; then
|
||||
echo " ℹ️ frontend/node_modules missing — run build.sh first"
|
||||
fi
|
||||
# ── Frontend checks ──
|
||||
echo "[frontend]"
|
||||
if ensure_npm_deps "$ROOT/frontend"; then
|
||||
if grep -q '"lint"' "$ROOT/frontend/package.json" 2>/dev/null; then
|
||||
(cd "$ROOT/frontend" && npx tsc --noEmit 2>&1 || true)
|
||||
report "frontend tsc --noEmit" $?
|
||||
(cd "$ROOT/frontend" && npm run lint 2>&1 || true)
|
||||
report "frontend lint" $?
|
||||
else
|
||||
echo " ℹ️ no lint script in frontend/package.json"
|
||||
fi
|
||||
# Always run tsc --noEmit if typescript is available
|
||||
if [ -f "$ROOT/frontend/node_modules/.bin/tsc" ]; then
|
||||
(cd "$ROOT/frontend" && npx tsc --noEmit 2>&1 || true)
|
||||
report "frontend tsc --noEmit" $?
|
||||
fi
|
||||
else
|
||||
echo " ℹ️ no frontend/package.json"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
|
|
|||
|
|
@ -13,15 +13,34 @@ report() {
|
|||
fi
|
||||
}
|
||||
|
||||
ensure_npm_deps() {
|
||||
local dir="$1"
|
||||
if [ ! -f "$dir/package.json" ]; then
|
||||
return 1
|
||||
fi
|
||||
if [ ! -d "$dir/node_modules" ]; then
|
||||
echo " 📦 node_modules missing — installing..."
|
||||
if [ -f "$dir/package-lock.json" ]; then
|
||||
(cd "$dir" && npm ci --no-audit --no-fund)
|
||||
else
|
||||
(cd "$dir" && npm install --no-audit --no-fund)
|
||||
fi
|
||||
report "npm install in $(basename "$dir")" $?
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
echo "=== verstak-desktop test ==="
|
||||
|
||||
# Go tests
|
||||
(cd "$ROOT" && go test -count=1 -v ./... 2>&1 || true)
|
||||
# ── Go tests ──
|
||||
(cd "$ROOT" && go mod download)
|
||||
OUTPUT=$(cd "$ROOT" && go test -count=1 -v ./... 2>&1) || true
|
||||
echo "$OUTPUT" | grep -E '(FAIL|PASS|---)' || true
|
||||
report "go test" $?
|
||||
|
||||
# Frontend tests
|
||||
if [ -f "$ROOT/frontend/package.json" ]; then
|
||||
# Only run if vitest or jest is in the config
|
||||
# ── Frontend tests ──
|
||||
echo "[frontend]"
|
||||
if ensure_npm_deps "$ROOT/frontend"; then
|
||||
if grep -q '"test"' "$ROOT/frontend/package.json" 2>/dev/null; then
|
||||
(cd "$ROOT/frontend" && npm test 2>&1 || true)
|
||||
report "frontend test" $?
|
||||
|
|
|
|||
Loading…
Reference in New Issue