#!/bin/bash

# this setup script is used locally to create an .npmrc file and run yarn install.
# It relies on Docker secrets and Docker BuildKit.

# Error on subcommand error
set -e
# Echo commands
set +x
# Don't echo variable substitutions
set -v

if [ -f /run/secrets/tokens ]; then
	source /run/secrets/tokens
fi

unique_id=theorchard_jenkins

sed "s/{{GITHUB_TOKEN}}/$GITHUB_TOKEN/" .npmrc.shadow > .npmrc

yarn --frozen-lockfile && yarn build

rm -f .npmrc
