Skip to content

Commit 84f6d93

Browse files
authored
fix: install extension npm dependencies during deploy (#176)
1 parent ba03e14 commit 84f6d93

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

bin/deploy.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ source "$SCRIPT_DIR/lib/paths-common.sh"
2626
source "$SCRIPT_DIR/lib/json-common.sh"
2727
# shellcheck source=bin/lib/deploy-common.sh
2828
source "$SCRIPT_DIR/lib/deploy-common.sh"
29+
# shellcheck source=bin/lib/runtime-node.sh
30+
source "$SCRIPT_DIR/lib/runtime-node.sh"
2931
bb_enable_strict_mode
3032
bb_init_paths
3133

@@ -216,6 +218,36 @@ for ext in "$EXT_SRC"/*; do
216218
fi
217219
done
218220

221+
# Install extension dependencies (extensions with package.json)
222+
if [ "$DRY_RUN" -eq 0 ]; then
223+
npm_bin=""
224+
node_bin_dir="$(bb_resolve_runtime_node_bin_dir "$BAUDBOT_HOME" 2>/dev/null || true)"
225+
if [ -n "$node_bin_dir" ] && [ -x "$node_bin_dir/npm" ]; then
226+
npm_bin="$node_bin_dir/npm"
227+
fi
228+
229+
has_ext_deps=0
230+
for ext_dir in "$EXT_DEST"/*/; do
231+
[ -d "$ext_dir" ] && [ -f "$ext_dir/package.json" ] && has_ext_deps=1 && break
232+
done
233+
234+
if [ "$has_ext_deps" -eq 1 ] && [ -z "$npm_bin" ]; then
235+
bb_log "⚠️ npm not found — cannot install extension dependencies"
236+
elif [ -n "$npm_bin" ]; then
237+
for ext_dir in "$EXT_DEST"/*/; do
238+
[ -d "$ext_dir" ] || continue
239+
[ -f "$ext_dir/package.json" ] || continue
240+
ext_name="$(basename "$ext_dir")"
241+
log "installing dependencies for $ext_name/"
242+
if as_agent bash -c "cd '$ext_dir' && '$npm_bin' install --omit=dev 2>&1"; then
243+
log "$ext_name/ dependencies installed"
244+
else
245+
bb_log "⚠️ failed to install dependencies for $ext_name/ — extension may not load"
246+
fi
247+
done
248+
fi
249+
fi
250+
219251
# ── Skills ───────────────────────────────────────────────────────────────────
220252

221253
echo "Deploying skills..."

0 commit comments

Comments
 (0)