#!/bin/sh
path=$(realpath "$(dirname "$0")") || exit 1
resourceDir="$path/../../resources/0f31fa2d-43ca-410f-8148-239b298112b3"
rm -rf "$resourceDir" || exit 1
rm -rf "$path/../../services/eternity-web.fgs" || exit 1
cd "$path" || exit 1
go build -o "$path/../../services/eternity-web.fgs" --buildmode=plugin -ldflags "-s -w" || exit 1
cd "$path/resources/wasm/oauth" || exit 1
GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/oauth.wasm" -ldflags "-s -w" || exit 1
cp -r "$path/resources/static" "$resourceDir/" || exit 1
cp -r "$path/resources/templates" "$resourceDir/" || exit 1