#!/usr/bin/env bash

set -ex

export CURRENT_VERSION=$1;

yarn install
rm -rf target

export NODE_ENV=production;

# Build the application
clojure -J-Xms100M -J-Xmx1000M -J-XX:+UseSerialGC -M:dev:shadow-cljs release main;

# Remove source
rm -rf target/app;

# Copy package*.json files
cp ../.yarnrc.yml target/;
cp yarn.lock target/;
cp package.json target/;

sed -i -re "s/\%version\%/$CURRENT_VERSION/g" ./target/app.js;
