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

29 lines
818 B
Bash

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
FRONTEND="${ROOT}/frontend-web"
OUTPUT_DIR="${1:-${ROOT}/dist}"
ARCHIVE="${OUTPUT_DIR}/frontend-offline-deps.tar.gz"
if [[ ! -d "${FRONTEND}/node_modules/.pnpm" ]]; then
echo "frontend-web/node_modules is missing or incomplete. Run 'pnpm install' in frontend-web first." >&2
exit 1
fi
mkdir -p "${OUTPUT_DIR}"
rm -f "${ARCHIVE}"
echo "Packaging frontend dependencies..."
echo " Source: ${FRONTEND}"
echo " Output: ${ARCHIVE}"
tar -czhf "${ARCHIVE}" -C "${FRONTEND}" node_modules package.json pnpm-lock.yaml
SIZE_MB=$(du -m "${ARCHIVE}" | awk '{print $1}')
echo ""
echo "Done — ${SIZE_MB} MB"
echo ""
echo "Copy to offline machine, then run:"
echo " scripts/restore-frontend-offline-deps.sh <path-to-archive>"