Files
bincio-wiki/scripts/dev.sh
T

34 lines
978 B
Bash
Executable File

#!/usr/bin/env bash
# Start the Astro dev server and optionally the edit sidecar.
# Usage: scripts/dev.sh [--edit]
set -e
cd "$(dirname "$0")/.."
ROOT="$(pwd)"
# Symlink wiki pages into the site's content collection
mkdir -p pages
mkdir -p site/src/content/entries
LINK="$ROOT/site/src/content/entries/_wiki"
if [ ! -L "$LINK" ]; then
ln -sf "$ROOT/pages" "$LINK"
echo "Linked pages/ → site/src/content/entries/_wiki"
fi
# Start edit sidecar if requested
if [[ "$*" == *"--edit"* ]]; then
echo "Starting edit sidecar on :8001..."
UVICORN="$ROOT/.venv/bin/uvicorn"
if [ ! -x "$UVICORN" ]; then
echo "Setting up Python venv..."
python3 -m venv "$ROOT/.venv"
"$ROOT/.venv/bin/pip" install -r "$ROOT/edit/requirements.txt" -q
fi
(cd "$ROOT" && "$UVICORN" edit.server:app --reload --port 8001) &
SIDECAR_PID=$!
trap "kill $SIDECAR_PID 2>/dev/null" EXIT
fi
# Start Astro dev server
export PUBLIC_EDIT_URL="${WIKI_EDIT_URL:-}"
cd site && npm run dev