#!/bin/bash

npm run pack

fname="flo-flex-builder"
zipname="flo-flex-builder.zip"

#get the name of the current script directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 
scp "${DIR}/${zipname}" flo@demo.stage.flosites.com:/var/www/demo.stage.flosites.com/releases/1/web/app/plugins
#rm "${zipname}"
# connect via ssh
ssh -t -t flo@demo.stage.flosites.com << EOF
  ## remove the current plugin if exists
  sudo rm -r -f "demo.stage.flosites.com/releases/1/web/app/plugins/${fname}"
  #unzip the uploaded file
  cd demo.stage.flosites.com/releases/1/web/app/plugins/
  unzip -o "${zipname}"
  sudo chown -R www-data ./flo-flex-builder
exit
EOF
exit