#!/usr/bin/env bash
# Install Argus frontend dependencies
set -euo pipefail

echo "Setting up Argus"
SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE="$SCRIPT_ROOT/../.."

NVM_FILE=~/.nvm/nvm.sh
if ! [ -f "$NVM_FILE" ]; then
  echo 'nvm not found. Installing nvm...'
  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
fi

# Prevent nvm error from causing script to exit
set +e
source "$NVM_FILE"
set -e

pushd "$WORKSPACE/argus/frontend"
echo "Installing node, yarn"
nvm install
npm install -g yarn
popd
