Repository navigation
Expand file tree
/
Copy pathbuild-preflight.sh
More file actions
executable file
·106 lines (90 loc) · 2.62 KB
/
Copy pathbuild-preflight.sh
File metadata and controls
executable file
·106 lines (90 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env bash
# ======================================================================
# Local Build Preflight
# ======================================================================
#
# Runs local package build steps before cluster/image workflows so plain
# TypeScript/Next.js compilation errors fail fast with a direct package
# name instead of surfacing later inside Docker builds.
#
# Usage:
# ./scripts/build-preflight.sh
# ======================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
log() { echo -e "${CYAN}[BUILD-PREFLIGHT]${NC} $*"; }
ok() { echo -e "${GREEN} OK${NC} -- $*"; }
err() { echo -e "${RED} ERROR${NC} -- $*"; }
PACKAGES=(
"packages/workflow-sdk"
"host-context-controller"
"workflow-recipes"
"mcp-host"
"mcp-proxy"
"control-api"
"codex-llm-proxy"
"grok-llm-proxy"
"external-rest-api"
"rpc-proxy"
"channel-reader"
"stdio-bridge"
"control-ui"
"profile-ui"
"mcp-servers/web-search"
"mcp-servers/doc-generator"
"tests/e2e/fixtures/mock-mcp-server"
"tests/e2e/fixtures/mock-stdio-mcp-server"
)
FAILED_PACKAGES=()
ensure_dependencies() {
local pkg=$1
local pkg_dir=$2
local needs_install=false
if [ -d "${pkg_dir}/node_modules" ]; then
if (cd "${pkg_dir}" && npm ls --depth=0 >/dev/null 2>&1); then
return
fi
log "Detected invalid dependency tree for ${pkg}; reinstalling..."
needs_install=true
else
needs_install=true
fi
if [ "${needs_install}" = true ]; then
log "Installing dependencies for ${pkg}..."
if [ -f "${pkg_dir}/package-lock.json" ]; then
(cd "${pkg_dir}" && npm ci --no-audit --no-fund)
else
(cd "${pkg_dir}" && npm install --no-audit --no-fund)
fi
fi
}
echo -e "${BOLD}=== Local Build Preflight ===${NC}"
"${PROJECT_DIR}/scripts/validate-nginx-images.sh"
"${PROJECT_DIR}/scripts/validate-workflow-backend-compat-harness.sh"
for pkg in "${PACKAGES[@]}"; do
pkg_dir="${PROJECT_DIR}/${pkg}"
if [ ! -f "${pkg_dir}/package.json" ]; then
err "Missing package.json for ${pkg}"
FAILED_PACKAGES+=("${pkg}")
continue
fi
ensure_dependencies "${pkg}" "${pkg_dir}"
log "Building ${pkg}..."
if (cd "${pkg_dir}" && npm run build --if-present); then
ok "${pkg}"
else
err "Build failed for ${pkg}"
FAILED_PACKAGES+=("${pkg}")
fi
done
if [ "${#FAILED_PACKAGES[@]}" -gt 0 ]; then
err "Build preflight failed: ${FAILED_PACKAGES[*]}"
exit 1
fi
ok "Local build preflight passed"