mirror of
https://github.com/hanzoai/base.git
synced 2026-08-07 13:05:50 +00:00
Source moves to ~/work/hanzo/gui/apps/admin-base. scripts/sync-admin-ui.sh copies dist/ here for go:embed. apis/serve.go now imports ui-react instead of legacy Svelte ui. README + embed.go docstrings updated. .gitignore exception flipped from ui/dist to ui-react/dist so go build is hermetic.
55 lines
2.1 KiB
Bash
Executable File
55 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# sync-admin-ui.sh — sync the admin-base @hanzo/gui v7 bundle into ui-react/dist.
|
|
#
|
|
# The Base admin SPA is built externally in the @hanzo/gui workspace at
|
|
# ~/work/hanzo/gui/apps/admin-base (Vite + @hanzo/gui v7). This script
|
|
# copies the built bundle into ui-react/dist/ where //go:embed picks it up
|
|
# at compile time. Reproducible, idempotent, CI-friendly.
|
|
#
|
|
# Usage:
|
|
# scripts/sync-admin-ui.sh # uses ../gui/apps/admin-base
|
|
# ADMIN_BASE_DIR=/path scripts/sync-admin-ui.sh
|
|
#
|
|
# Exits non-zero if the source dist/ is missing or empty so CI fails
|
|
# loud instead of shipping a binary with a stale or empty SPA.
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
DEFAULT_SRC="$(cd "${REPO_ROOT}/../gui/apps/admin-base" 2>/dev/null && pwd || echo "")"
|
|
SRC="${ADMIN_BASE_DIR:-${DEFAULT_SRC}}"
|
|
DST="${REPO_ROOT}/ui-react/dist"
|
|
|
|
if [[ -z "${SRC}" || ! -d "${SRC}/dist" ]]; then
|
|
echo "error: admin-base dist not found." >&2
|
|
echo " expected: ${SRC:-<unset>}/dist" >&2
|
|
echo " build it first: cd \"${SRC:-../gui/apps/admin-base}\" && bun run build" >&2
|
|
echo " or set ADMIN_BASE_DIR=/abs/path/to/admin-base" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! ls "${SRC}/dist"/index.html "${SRC}/dist"/assets/*.js >/dev/null 2>&1; then
|
|
echo "error: ${SRC}/dist is missing index.html or assets/*.js" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "${DST}"
|
|
rsync -a --delete "${SRC}/dist/" "${DST}/"
|
|
|
|
# Stamp the sync so binaries can be traced back to a build.
|
|
{
|
|
echo "# auto-generated by scripts/sync-admin-ui.sh — do not edit"
|
|
echo "source=${SRC}"
|
|
echo "synced_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
if command -v git >/dev/null 2>&1 && git -C "${SRC}" rev-parse --short HEAD >/dev/null 2>&1; then
|
|
echo "source_commit=$(git -C "${SRC}" rev-parse --short HEAD)"
|
|
fi
|
|
if command -v git >/dev/null 2>&1 && git -C "${SRC}" status --porcelain >/dev/null 2>&1; then
|
|
if [[ -n "$(git -C "${SRC}" status --porcelain || true)" ]]; then
|
|
echo "source_dirty=true"
|
|
fi
|
|
fi
|
|
} > "${DST}/.sync-stamp"
|
|
|
|
echo "synced ${SRC}/dist -> ${DST}"
|
|
ls -lh "${DST}/index.html" "${DST}"/assets/*.js "${DST}"/assets/*.css 2>/dev/null
|