mirror of
https://github.com/avatao-content/test-tutorial-framework
synced 2024-11-14 22:07:17 +00:00
59 lines
1.7 KiB
Bash
Executable File
59 lines
1.7 KiB
Bash
Executable File
#!/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
|