#!/bin/bash

source ./cappello_batch.sh

source ./.env.test.pcb

msg="*** Sincronizzazione ???  $DIRECTORY_LOCAL e $SERVERDIR_WEBSITE (Y/N) ? "

if [ "$1" = "" ]; then
  read -p "$msg" risposta
else
  risposta=$1
fi

cp .env.production .env.prod.bak
cp .env.test.pcb .env.production

sleep 1

npm run buildpwa

echo "Sincronizzazione $SERVERDIR_WEBSITE in remoto..."
rsync -e 'ssh -p 8822'  -a --exclude 'upload' dist/pwa/ pcbuser@pcb:$SERVERDIR_WEBSITE
rsync -e 'ssh -p 8822' -a dist/pwa/js/ pcbuser@pcb:$SERVERDIR_WEBSITE/js

cp .env.prod.bak .env.production

sleep 1

echo "Finito $SERVERDIR_WEBSITE"
