#!/usr/bin/env bash set -e # Get absolute path of this script's directory SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" ROOT_DIR="$SCRIPT_DIR/.." # Load config source "$ROOT_DIR/scripts/config.sh" git push origin main # SSH to target: pull, build, sync apps, restart ssh "$SSH_HOST" bash <<'SCRIPT' set -e DEST="${DEST:-$HOME/toes}" APPS_DIR="${APPS_DIR:-$HOME/apps}" cd "$DEST" && git checkout -- bun.lock && git pull origin main && bun install && rm -rf dist && bun run build echo "=> Migrating apps to flat structure..." bun run scripts/migrate.ts echo "=> Syncing default apps..." for app_dir in "$DEST"/apps/*/; do app=$(basename "$app_dir") [ -f "$app_dir/package.json" ] || continue target="$APPS_DIR/$app" mkdir -p "$target" cp -a "$app_dir"/. "$target"/ echo " $app" (cd "$target" && bun install --frozen-lockfile 2>/dev/null || bun install) done sudo systemctl restart toes.service SCRIPT echo "=> Deployed to $SSH_HOST" echo "=> Visit $URL"