#!/bin/sh
#/ Usage: bootstrap https://base.url.com/from/libchromiumcontent/script/upload
#/ Bootstrap this project.

set -e

usage() {
  grep '^#/' <"$0"| cut -c4-
}

BASE_URL="${1}"

if [ -z "${BASE_URL}" ]; then
  usage
  exit 1
fi

cd "$(dirname "$0")/.."
SOURCE_ROOT=$(pwd -P)
VENDOR_DIR="${SOURCE_ROOT}/vendor"
BRIGHTRAY_DIR="${VENDOR_DIR}/brightray"

git submodule sync --quiet
git submodule update --init --recursive

npm install npm --silent
./node_modules/.bin/npm install --silent

"${BRIGHTRAY_DIR}/script/bootstrap" "${BASE_URL}"

"${SOURCE_ROOT}/script/update"