#!/bin/bash
python_version=$1
gitlab_user=$2
gitlab_personal_access_token=$3

# cookiecutter https://gitlab.knecon.com/knecon/research/template-python-project.git --checkout master
# latest_dir=$(ls -td -- */ | head -n 1)  # should be the dir cookiecutter just created

# cd $latest_dir

pyenv install $python_version
pyenv local $python_version
pyenv shell $python_version

pip install --upgrade pip
pip install poetry

poetry config installer.max-workers 10
# research package registry
poetry config repositories.gitlab-research https://gitlab.knecon.com/api/v4/groups/19/-/packages/pypi
poetry config http-basic.gitlab-research ${gitlab_user} ${gitlab_personal_access_token}
# redactmanager package registry
poetry config repositories.gitlab-red https://gitlab.knecon.com/api/v4/groups/12/-/packages/pypi
poetry config http-basic.gitlab-red ${gitlab_user} ${gitlab_personal_access_token}

poetry env use $(pyenv which python)
poetry install --with=dev
poetry update

source .venv/bin/activate
