#!/usr/bin/env bash set -eu set -o pipefail set -o errtrace shopt -s expand_aliases [ "$(uname)" == "Darwin" ] && alias readlink="greadlink" && alias grep="ggrep" || : SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" TFW_PATH="${TFW_PATH:-$SCRIPT_DIR/../..}" BASEIMAGE_REPO="${BASEIMAGE_REPO:-baseimage-tutorial-framework}" CHALLENGE_REPO="${CHALLENGE_REPO:-"$(basename "$(realpath "${SCRIPT_DIR}/..")")"}" FRONTEND_REPO="${FRONTEND_REPO:-frontend-tutorial-framework}" BASEIMAGE_PATH="${TFW_PATH}/${BASEIMAGE_REPO}" CHALLENGE_PATH="${TFW_PATH}/${CHALLENGE_REPO}" FRONTEND_PATH="${TFW_PATH}/${FRONTEND_REPO}" source "${SCRIPT_DIR}/libhack/baseimage.sh" source "${SCRIPT_DIR}/libhack/challenge.sh" case ${1:-} in start) baseimage::build_if_exists challenge::build challenge::run ${@:2} ;; run) challenge:run ${@:2} ;; buildtfw) baseimage::build_if_exists ;; build) baseimage::build_if_exists challenge::build_no_cache ;; releasetfw) if [[ -d "$BASEIMAGE_PATH" ]]; then baseimage::release fi ;; builddocs) if [[ -d "$BASEIMAGE_PATH" ]]; then baseimage::builddocs fi ;; *) echo "Usage: tfw.sh [COMMAND]" echo " |--- start: build & run TFW challenge" echo " |--- run: run TFW challenge" echo " |--- buildtfw: build TFW baseimage" echo " |--- build: build TFW baseimage and challenge" echo " |--- releasetfw: tag TFW baseimage and push to upstream" echo " |--- builddocs: build baseimage documentation (in docs/build/html)" ;; esac