Skip to content

Commit ddd995a

Browse files
committed
Add dev-update script to pull and rebuild all MCP service repos
Made-with: Cursor
1 parent ddd956e commit ddd995a

1 file changed

Lines changed: 123 additions & 0 deletions

File tree

scripts/dev-update.sh

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5+
REPO_ROOT="$SCRIPT_DIR/.."
6+
SERVICES_JSON="$REPO_ROOT/gateway/services.json"
7+
PARENT_DIR="$(cd "$REPO_ROOT/.." && pwd)"
8+
9+
# ── Colors ────────────────────────────────────────────────────────────
10+
if [ -t 1 ]; then
11+
GREEN='\033[0;32m' YELLOW='\033[0;33m' RED='\033[0;31m' CYAN='\033[0;36m' RESET='\033[0m'
12+
else
13+
GREEN='' YELLOW='' RED='' CYAN='' RESET=''
14+
fi
15+
16+
info() { printf "${CYAN} %-9s${RESET} %s\n" "$1" "$2"; }
17+
ok() { printf "${GREEN} %-9s${RESET} %s\n" "$1" "$2"; }
18+
warn() { printf "${YELLOW} %-9s${RESET} %s\n" "$1" "$2"; }
19+
fail() { printf "${RED} %-9s${RESET} %s\n" "$1" "$2"; }
20+
21+
updated=0
22+
installed=0
23+
built=0
24+
skipped=0
25+
failed=0
26+
27+
# ── Pull a git repo, reinstall deps & rebuild if anything changed ─────
28+
pull_and_refresh() {
29+
local name="$1" dir="$2"
30+
31+
if [ ! -d "$dir/.git" ]; then
32+
warn "SKIP" "$name — not a git repo"
33+
skipped=$((skipped + 1))
34+
return
35+
fi
36+
37+
local before after
38+
before=$(git -C "$dir" rev-parse HEAD 2>/dev/null)
39+
40+
if ! git -C "$dir" pull --ff-only 2>/dev/null; then
41+
warn "DIVERGED" "$name — fast-forward failed, try manual merge/rebase"
42+
failed=$((failed + 1))
43+
return
44+
fi
45+
46+
after=$(git -C "$dir" rev-parse HEAD 2>/dev/null)
47+
48+
if [ "$before" = "$after" ]; then
49+
ok "UP-TO-DATE" "$name"
50+
skipped=$((skipped + 1))
51+
return
52+
fi
53+
54+
ok "PULLED" "$name $(echo "$before" | head -c 7)$(echo "$after" | head -c 7)"
55+
updated=$((updated + 1))
56+
57+
# Reinstall deps if package-lock changed
58+
if [ -f "$dir/package.json" ]; then
59+
if git -C "$dir" diff --name-only "$before" "$after" | grep -q 'package-lock.json\|package.json'; then
60+
info "INSTALL" "$name"
61+
(cd "$dir" && npm install --silent 2>/dev/null)
62+
installed=$((installed + 1))
63+
fi
64+
65+
if node -e "const p=require('$dir/package.json'); process.exit(p.scripts && p.scripts.build ? 0 : 1)" 2>/dev/null; then
66+
info "BUILD" "$name"
67+
if (cd "$dir" && npm run build --silent 2>/dev/null); then
68+
built=$((built + 1))
69+
else
70+
fail "FAILED" "$name build"
71+
failed=$((failed + 1))
72+
fi
73+
fi
74+
fi
75+
}
76+
77+
# ── 1. Update UluOS itself ───────────────────────────────────────────
78+
echo ""
79+
echo "Updating UluOS..."
80+
echo ""
81+
pull_and_refresh "UluOS" "$REPO_ROOT"
82+
83+
# ── 2. Discover and update child MCP repos ───────────────────────────
84+
REPOS=$(node -e "
85+
const svc = require('$SERVICES_JSON');
86+
const seen = new Set();
87+
for (const s of svc.services) {
88+
const arg = (s.args || [])[0] || '';
89+
const match = arg.match(/^\\.\\.\\/([^/]+)\\//);
90+
if (match && !seen.has(match[1])) {
91+
seen.add(match[1]);
92+
console.log(match[1]);
93+
}
94+
}
95+
")
96+
97+
if [ -n "$REPOS" ]; then
98+
echo ""
99+
echo "Updating MCP services..."
100+
echo ""
101+
fi
102+
103+
for REPO_NAME in $REPOS; do
104+
REPO_PATH="$PARENT_DIR/$REPO_NAME"
105+
106+
if [ ! -d "$REPO_PATH" ]; then
107+
warn "MISSING" "$REPO_NAME — run scripts/install-services.sh to clone"
108+
failed=$((failed + 1))
109+
continue
110+
fi
111+
112+
pull_and_refresh "$REPO_NAME" "$REPO_PATH"
113+
done
114+
115+
# ── Summary ───────────────────────────────────────────────────────────
116+
echo ""
117+
echo "Done. updated=$updated installed=$installed built=$built skipped=$skipped failed=$failed"
118+
119+
if [ $failed -gt 0 ]; then
120+
echo ""
121+
warn "NOTE" "Some repos had issues — see messages above."
122+
exit 1
123+
fi

0 commit comments

Comments
 (0)