#!/usr/bin/env bash
#
# Build a clean, uploadable release tarball of the platform (source + lockfiles only —
# no node_modules, no build output, no env files). Upload the result to your host and
# `tar xzf` it, then follow deploy/CPANEL-DEPLOY.md.
#
# Usage:  bash deploy/package-release.sh
# Output: jh-platform-release.tgz  (in the repo root)

set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

OUT="jh-platform-release.tgz"

echo "Packaging platform/ + deploy/ + data/ (source only) -> $OUT"

tar czf "$OUT" \
  --exclude='**/node_modules' \
  --exclude='**/.medusa' \
  --exclude='**/.next' \
  --exclude='**/dist' \
  --exclude='**/build' \
  --exclude='**/.env' \
  --exclude='**/.env.*' \
  --exclude='**/*.log' \
  platform \
  deploy \
  data

echo "Done: $OUT"
echo "Size: $(du -h "$OUT" | cut -f1)"
echo
echo "Next: upload $OUT to your host (~/apps/jh), 'tar xzf $OUT', then follow deploy/CPANEL-DEPLOY.md"
