#!/usr/bin/env bash

# Copyright (c) 2023 ipyforcegraph contributors.
# Distributed under the terms of the Modified BSD License.

set -eux

export IN_BINDER=1

source activate ${NB_PYTHON_PREFIX}

doit list
doit -n4 binder || doit list
doit binder

# work around default start command
cp ${NB_PYTHON_PREFIX}/bin/jupyter-lab ${NB_PYTHON_PREFIX}/bin/jupyter-notebook

# clean up some settings
mkdir -p ${NB_PYTHON_PREFIX}/share/jupyter/lab/settings
cp .binder/overrides.json ${NB_PYTHON_PREFIX}/share/jupyter/lab/settings/

mkdir -p .jupyter/
cp .binder/jupyter_config.json .jupyter/

# disable some extensions
jupyter labextension disable jupyter-offlinenotebook
jupyter labextension disable @jupyterlab/apputils-extension:notification
jupyter labextension disable @jupyterlab/extensionmanager-extension

# clean up assets un-needed for demo
rm -rf ~/.cache ./build/.yarn-packages node_modules /tmp/yarn*
