#! /bin/bash
# To be run from app directory
nvm use
export NODE_OPTIONS="--max-old-space-size=8192"

npm run build:vite:app-landing

mkdir to_upload
mv dist/app/* to_upload/
cp -r .well-known/ to_upload/
mkdir -p to_upload/assets/fonts

cp ../public/css/index-tailwind-output.css to_upload/assets/
cp ../public/assets/fonts/source-sans-pro.regular.ttf to_upload/assets/fonts/

cp dist/assets/*.js to_upload/assets/
rm -rf dist

ssh hetzner "rm -rf /root/app/"
scp -rp to_upload/ hetzner:/root/app/
scp -rp to_upload/.well-known/ hetzner:/root/app/
ssh hetzner "cp ~/public/apk/mapcomplete-latest.apk ~/app/"
rm -rf to_upload
