Skip to content

Commit 888dbf5

Browse files
authored
fix: auto-build dashboard SPA in session-start hook (#508)
The dashboard SPA dist/ is gitignored and was never built during plugin installation, causing the interactive dashboard to always fall back to static HTML. Add Step 1.5 to session-start.sh that builds the dashboard when dist/index.html is missing or stale relative to package.json. Closes #500
1 parent 9a1b04e commit 888dbf5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

hooks/session-start.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if [ -d "${MARKETPLACE_DIR}/.git" ]; then
1717
(cd "${MARKETPLACE_DIR}" && git pull --ff-only) >/dev/null 2>&1 || true
1818
fi
1919

20-
# --- Step 1: Rebuild stale bundle (if needed) ---
20+
# --- Step 1: Rebuild stale CLI bundle (if needed) ---
2121
if [ -f "${PLUGIN_ROOT}/packages/core/dist/cli.bundle.cjs" ] && [ "${PLUGIN_ROOT}/packages/core/package.json" -nt "${PLUGIN_ROOT}/packages/core/dist/cli.bundle.cjs" ]; then
2222
if (cd "${PLUGIN_ROOT}/packages/core" && npm install --silent 2>/dev/null && npm run bundle --silent 2>/dev/null); then
2323
messages="CLI bundle rebuilt after plugin update."
@@ -26,6 +26,17 @@ if [ -f "${PLUGIN_ROOT}/packages/core/dist/cli.bundle.cjs" ] && [ "${PLUGIN_ROOT
2626
fi
2727
fi
2828

29+
# --- Step 1.5: Build dashboard SPA if missing or stale ---
30+
DASHBOARD_INDEX="${PLUGIN_ROOT}/packages/dashboard/dist/index.html"
31+
DASHBOARD_PKG="${PLUGIN_ROOT}/packages/dashboard/package.json"
32+
if [ -f "${DASHBOARD_PKG}" ] && { [ ! -f "${DASHBOARD_INDEX}" ] || [ "${DASHBOARD_PKG}" -nt "${DASHBOARD_INDEX}" ]; }; then
33+
if (cd "${PLUGIN_ROOT}/packages/dashboard" && npm install --silent 2>/dev/null && npm run build --silent 2>/dev/null); then
34+
messages="${messages:+${messages}\n}Dashboard SPA built successfully."
35+
else
36+
messages="${messages:+${messages}\n}Warning: Dashboard SPA build failed. The static HTML fallback will be used. To fix: cd ${PLUGIN_ROOT}/packages/dashboard && npm install && npm run build"
37+
fi
38+
fi
39+
2940
# --- Step 2: Check for updates (once per day) ---
3041
LAST_CHECK="${HOME}/.oss-autopilot/.last-update-check"
3142
CURRENT=$(node -e "console.log(require('${PLUGIN_ROOT}/packages/core/package.json').version)" 2>/dev/null || echo "")

0 commit comments

Comments
 (0)