#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
set -e
. $DIR/environment.sh
. $DIR/keys.sh

if [[ ! -e $PWD/node_modules  ]]; then
  echo "[Documentation] installing dependencies"
  npm install
fi

if [[ "$DECLINATION_ID" = cli  ]]; then
  echo "[Documentation] generating CLI documentation"
  npx @yeutech/rollup-documentation-cli cli-help
fi

if [[ -e $PWD/styleguide/prepare.sh ]]; then
  echo "[Documentation] running prepare"
  chmod +x $PWD/styleguide/prepare.sh
  $PWD/styleguide/prepare.sh
fi
if [[ ! -e $PWD/public ]]; then
  echo "[Documentation] build documentation"
  npm run styleguide:build
fi

. $DIR/unset.sh
