#!/usr/bin/env bash
set -e

GITEA_INSTANCE_URL="https://git.ourworld.tf"
GITEA_USERNAME="threefold_coop"

mkdir -p ~/.vmodules/freeflowuniverse
mkdir -p ~/code/gitea/$GITEA_USERNAME

pushd ~/code/gitea/$GITEA_USERNAME

# Clone crystallib repository from Gitea
git clone $GITEA_INSTANCE_URL/$GITEA_USERNAME/crystallib.git
pushd crystallib
git checkout development_db
popd

# Create symbolic link to crystallib in ~/.vmodules/freeflowuniverse
ln -s ~/code/gitea/$GITEA_USERNAME/crystallib/crystallib ~/.vmodules/freeflowuniverse/crystallib

# Clone webcomponents repository from Gitea
git clone $GITEA_INSTANCE_URL/$GITEA_USERNAME/webcomponents.git

# Create symbolic link to webcomponents in ~/.vmodules/freeflowuniverse
ln -s ~/code/gitea/$GITEA_USERNAME/webcomponents/webcomponents ~/.vmodules/freeflowuniverse/webcomponents

popd

echo "INSTALL OK"
