From e3e4385b916ce4e9247123a123643ce5e3f6ad34 Mon Sep 17 00:00:00 2001 From: mirivlad Date: Tue, 16 Jun 2026 12:32:34 +0800 Subject: [PATCH] fix: add dep checks, npm install fallback, go mod download in build.sh --- plugins/platform-test/backend/platform-test | Bin 2763647 -> 2763647 bytes scripts/build.sh | 53 ++++++++++++++++---- scripts/check.sh | 16 +++--- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/plugins/platform-test/backend/platform-test b/plugins/platform-test/backend/platform-test index 09c3b739e23ee2cce41236dd67b1710ade7d8cc4..6e10ab367d40b4d8d377ec624ef011f099e482b8 100755 GIT binary patch delta 455 zcmb`=yH3Jj0EXcr;0cvhIVd6(k1!C*Uka2>W1s<4q5{#FkOFPQcnlb2R;-%?1GnJd zfD@w$yN*syF6zh?;5T{!4A1f|Z|~zt*MruB*?X3|NX4?(>(XgOIWMJT`9QkzCobdV zll@9smMXD~z}=*MNBPE!*(N5$%}lMfv$wWg-OZ8IvAUraDFa1O7SKa{D?{afpAUOk zgJ!*#-fE_n-TC!dYPfyuElX=Gt%Cv3g8_^%2tzOoBQOdk7=v+`05i~SmS!HSOn`8L zkLNkLR16Z8kZ|+$j`{ZdFCtfnh#^G~`GTTw;SjHqNSF_CB2fa(_d4S;21t|>v~Hb& zNtgl)SiuH%n1-2lx9<3f_Ho+8)UPEw4wwZe%z+D7mW!^U{7(W_H1 z2~*&LX>h{~%)(r!SNHtH{&CvIG~7sZJunXo-~}Jhun2xwf@N5NRak>{2y_zNAb<7? DGhmgY diff --git a/scripts/build.sh b/scripts/build.sh index 597414a..1139317 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -3,6 +3,9 @@ set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" FAILED=0 +BUILT=0 +SKIPPED=0 +FAILED_PLUGINS="" report() { if [ "$2" -eq 0 ]; then @@ -13,11 +16,33 @@ report() { fi } +ensure_npm_deps() { + local dir="$1" + if [ ! -f "$dir/package.json" ]; then + return 1 + fi + if [ ! -d "$dir/node_modules" ]; then + 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-official-plugins build ===" -BUILT=0 -SKIPPED=0 -FAILED_PLUGINS="" +# ── Dependency checks ── +echo "[deps]" +HAS_DEPS=1 +if ! command -v node &>/dev/null; then echo " ❌ node: not found"; HAS_DEPS=0; else echo " ✅ node $(node --version)"; fi +if ! command -v npm &>/dev/null; then echo " ❌ npm: not found"; HAS_DEPS=0; fi +if ! command -v go &>/dev/null; then echo " ❌ go: not found"; HAS_DEPS=0; else echo " ✅ go $(go version | grep -oP 'go\S+')"; fi +if [ "$HAS_DEPS" -eq 0 ]; then + echo " ⚠️ some deps missing — will skip matching plugin parts" +fi for plugin_dir in "$ROOT"/plugins/*/; do [ -d "$plugin_dir" ] || continue @@ -47,23 +72,29 @@ for plugin_dir in "$ROOT"/plugins/*/; do # Frontend build if [ -f "$plugin_dir/frontend/package.json" ]; then - echo " → frontend: npm ci + build" - (cd "$plugin_dir/frontend" && npm ci --no-audit --no-fund) - report "npm ci" $? - (cd "$plugin_dir/frontend" && npm run build) - report "frontend build" $? - BUILT=1 + echo " → frontend" + if command -v npm &>/dev/null; then + ensure_npm_deps "$plugin_dir/frontend" + (cd "$plugin_dir/frontend" && npm run build) + report "frontend build" $? + BUILT=1 + else + echo " ⚠️ npm not available — skipping frontend" + fi else echo " ℹ️ no frontend/package.json — skipping frontend" fi # Backend build (Go) if [ -f "$plugin_dir/backend/go.mod" ] || [ -f "$plugin_dir/backend/main.go" ]; then - echo " → backend: go build" - if [ -d "$plugin_dir/backend" ]; then + echo " → backend" + if command -v go &>/dev/null; then + (cd "$plugin_dir/backend" && go mod download 2>/dev/null || true) (cd "$plugin_dir/backend" && go build ./...) report "backend go build" $? BUILT=1 + else + echo " ⚠️ go not available — skipping backend" fi else echo " ℹ️ no backend/ — skipping backend" diff --git a/scripts/check.sh b/scripts/check.sh index d4ca7dd..8118565 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -15,8 +15,12 @@ report() { echo "=== verstak-official-plugins check ===" +# ── Dependency checks ── +HAS_PYTHON=0 +if command -v python3 &>/dev/null; then HAS_PYTHON=1; fi + # Validate all plugin manifests against the SDK schema -if command -v python3 &>/dev/null; then +if [ "$HAS_PYTHON" -eq 1 ]; then echo "[manifest validation]" SDK_SCHEMA="$ROOT/../verstak-sdk/schemas/manifest.json" if [ -f "$SDK_SCHEMA" ]; then @@ -35,7 +39,7 @@ for plugin_dir in glob.glob('$ROOT/plugins/*/'): skipped.append(plugin_dir.split('/')[-2]) continue except json.JSONDecodeError as e: - problems.append(f'{plugin_dir.split(\"/\")[-2]}: invalid JSON — {e}') + problems.append(plugin_dir.split('/')[-2] + ': invalid JSON — ' + str(e)) continue checks = { @@ -47,15 +51,15 @@ for plugin_dir in glob.glob('$ROOT/plugins/*/'): } for check, ok in checks.items(): if not ok: - problems.append(f'{manifest.get(\"id\", plugin_dir.split(\"/\")[-2])}: missing/empty \"{check}\"') + problems.append(manifest.get('id', plugin_dir.split('/')[-2]) + ': missing/empty \"' + check + '\"') if skipped: - print(f' ⚠️ skipped (no plugin.json): {\", \".join(skipped)}') + print(' \u26a0\ufe0f skipped (no plugin.json): ' + ', '.join(skipped)) if problems: for p in problems: - print(f' ❌ {p}') + print(' \u274c ' + p) else: - print(' ✅ all manifests valid') + print(' \u2705 all manifests valid') " report "manifests valid" $? else