deerflow-code/scripts/restore-frontend-offline-deps.sh
2026-09-07 18:24:55 +08:00

39 lines
951 B
Bash

#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <path-to-frontend-offline-deps.tar.gz>" >&2
exit 1
fi
ARCHIVE="$1"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
FRONTEND="${ROOT}/frontend-web"
if [[ ! -f "${ARCHIVE}" ]]; then
echo "Archive not found: ${ARCHIVE}" >&2
exit 1
fi
echo "Restoring frontend dependencies to ${FRONTEND} ..."
if [[ -d "${FRONTEND}/node_modules" ]]; then
rm -rf "${FRONTEND}/node_modules.bak"
mv "${FRONTEND}/node_modules" "${FRONTEND}/node_modules.bak"
echo " Existing node_modules backed up to node_modules.bak"
fi
tar -xzf "${ARCHIVE}" -C "${FRONTEND}"
for rel in node_modules/.pnpm node_modules/react/package.json node_modules/vite/package.json; do
if [[ ! -e "${FRONTEND}/${rel}" ]]; then
echo "Restore incomplete — missing ${rel}" >&2
exit 1
fi
done
echo ""
echo "Restore complete. You can now run:"
echo " cd frontend-web"
echo " pnpm dev"