#!/usr/bin/env bash

set -ex

export CURRENT_VERSION=$1;
export NODE_ENV=production;

rm -rf target;

corepack enable;
corepack install;

pnpm install;
pnpm run build;

cp pnpm-lock.yaml target/;
cp pnpm-workspace.yaml target/;
cp package.json target/;

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