#!/usr/bin/env bash
#
# Build BrevyScribe and push it to the server.  The site is static, so a deploy
# is just "replace the files".
#
#   ./deploy/deploy.sh
#   TARGET=me@otherhost:/srv/site ./deploy/deploy.sh
#
# Override TARGET to send it somewhere else.  Nothing on the server needs Node:
# the build happens here and only dist/ travels.

set -euo pipefail

TARGET="${TARGET:-luxick@scribe.luxick.de:/var/www/brevyscribe/}"

cd "$(dirname "$0")/.."

# Don't ship a build whose transforms no longer match the Python reference.
npm test
npm run build

# --delete removes assets from previous builds; their filenames are hashed, so
# they would otherwise pile up forever.  The trailing slash on dist/ copies the
# contents rather than the directory itself.
rsync --archive --compress --delete --human-readable --progress \
	dist/ "$TARGET"

echo
echo "Deployed to $TARGET"
