1
0
mirror of https://github.com/avatao-content/test-tutorial-framework synced 2024-11-15 10:17:17 +00:00
test-tutorial-framework/hack/tfw.sh

59 lines
1.7 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2018-04-16 18:45:46 +00:00
set -eu
2018-04-15 19:50:43 +00:00
set -o pipefail
set -o errtrace
shopt -s expand_aliases
2018-09-17 09:49:10 +00:00
[ "$(uname)" == "Darwin" ] && alias readlink="greadlink" && alias grep="ggrep" || :
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
2018-06-15 13:18:46 +00:00
TFW_PATH="${TFW_PATH:-$SCRIPT_DIR/../..}"
BASEIMAGE_REPO="${BASEIMAGE_REPO:-baseimage-tutorial-framework}"
2018-06-15 13:18:46 +00:00
CHALLENGE_REPO="${CHALLENGE_REPO:-"$(basename "$(realpath "${SCRIPT_DIR}/..")")"}"
FRONTEND_REPO="${FRONTEND_REPO:-frontend-tutorial-framework}"
2018-06-15 13:18:46 +00:00
BASEIMAGE_PATH="${TFW_PATH}/${BASEIMAGE_REPO}"
CHALLENGE_PATH="${TFW_PATH}/${CHALLENGE_REPO}"
FRONTEND_PATH="${TFW_PATH}/${FRONTEND_REPO}"
2018-06-15 13:18:46 +00:00
source "${SCRIPT_DIR}/libhack/baseimage.sh"
source "${SCRIPT_DIR}/libhack/challenge.sh"
2018-04-19 15:01:59 +00:00
case ${1:-} in
start)
2018-06-15 13:18:46 +00:00
baseimage::build_if_exists
challenge::build
challenge::run ${@:2}
;;
run)
challenge:run ${@:2}
;;
buildtfw)
2018-06-15 13:18:46 +00:00
baseimage::build_if_exists
;;
build)
2018-06-15 13:18:46 +00:00
baseimage::build_if_exists
challenge::build_no_cache
;;
releasetfw)
2018-06-18 12:53:10 +00:00
if [[ -d "$BASEIMAGE_PATH" ]]; then
baseimage::release
fi
;;
builddocs)
2018-06-18 12:53:10 +00:00
if [[ -d "$BASEIMAGE_PATH" ]]; then
baseimage::builddocs
fi
;;
*)
2018-06-15 13:18:46 +00:00
echo "Usage: tfw.sh [COMMAND]"
echo " |--- start: build & run TFW challenge"
echo " |--- run: run TFW challenge"
echo " |--- buildtfw: build TFW baseimage"
2018-06-15 13:18:46 +00:00
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