#! /usr/bin/env bash
cd "$( dirname "${BASH_SOURCE[0]}" )"

echo "Building Server Plugin"
server/build-server.sh $1

echo "Building Client Plugin"
( cd webapp && npx webpack --mode=production; )

echo "Generating plugin.json"
( . plugin_values_${1:-default} ; envsubst < plugin_template.json > plugin.json )


echo "Archiving"
tar -czvf bathroom.tar.gz plugin.json -C server bathroom-linux-amd64 -C ../webapp/dist main.js -C ../../images/ $(cd images && ls *.png)
