#!/usr/bin/env bash
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 CERN.
# Copyright (C) 2019 Northwestern University.
#
# Invenio App RDM is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

set -e


script_path=$(dirname "$0")
pipfile_lock_path="$script_path/../Pipfile.lock"

if [ ! -f $pipfile_lock_path ]; then
    echo "'Pipfile.lock' not found. Generating via 'pipenv lock --dev'..."
    pipenv lock --dev
fi

# Installs all packages specified in Pipfile.lock
pipenv sync --dev
# Install application code and entrypoints from 'setup.py'
pipenv run pip install -e $script_path/..
# Build assets
pipenv run invenio collect -v
pipenv run invenio webpack buildall


