2018-11-27 03:42:04 +03:00
|
|
|
#! /bin/bash
|
2019-10-01 21:35:32 +03:00
|
|
|
# Copyright 2018-2019 the .Net Foundation
|
2018-11-28 00:21:49 +03:00
|
|
|
# Licensed under the MIT License
|
2018-11-27 03:42:04 +03:00
|
|
|
|
2019-10-01 21:38:47 +03:00
|
|
|
top="$(dirname "$0")"
|
|
|
|
|
2018-11-27 03:42:04 +03:00
|
|
|
function vagrant_up () {
|
|
|
|
if vagrant status |grep ^default |grep -q running ; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
echo "Starting the Vagrant VM ..."
|
|
|
|
vagrant up
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function run_command () {
|
|
|
|
# $1 - capitalized gerund verb to use in user output (e.g. "Building")
|
|
|
|
# $2 - the name of the log file (e.g. "wwt-web-client/build.log")
|
|
|
|
# $3 - basename of PowerShell script to run (e.g. "build_web.ps1")
|
|
|
|
# $4... - extra args to pass to the PowerShell script. Escaping of
|
|
|
|
# arguments could get gnarly.
|
|
|
|
|
|
|
|
gerund="$1"
|
|
|
|
logfile="$2"
|
|
|
|
script_base="$3"
|
|
|
|
shift 3
|
|
|
|
|
|
|
|
vagrant_up
|
|
|
|
echo "$gerund; logs also captured to \"$logfile\" ..."
|
2019-10-01 21:35:32 +03:00
|
|
|
vagrant winrm -c "powershell -NoProfile -NoLogo -InputFormat None -ExecutionPolicy Bypass \
|
|
|
|
-File c:\\\\vagrant\\\\$script_base $*" |& tee "$logfile"
|
2018-11-27 03:42:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-29 23:56:17 +03:00
|
|
|
function just_run_command () {
|
|
|
|
# $1 - basename of PowerShell script to run (e.g. "build_web.ps1")
|
|
|
|
# $2... - extra args to pass to the PowerShell script. Escaping of
|
|
|
|
# arguments could get gnarly.
|
|
|
|
|
|
|
|
script_base="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
vagrant_up
|
2019-10-01 21:35:32 +03:00
|
|
|
vagrant winrm -c "powershell -NoProfile -NoLogo -ExecutionPolicy Bypass \
|
|
|
|
-File c:\\\\vagrant\\\\$script_base $*"
|
2018-11-29 23:56:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-27 03:42:04 +03:00
|
|
|
function cmd_build_web () {
|
2019-10-01 21:38:47 +03:00
|
|
|
run_command "Building" "$top/wwt-web-client/build.log" "build_web.ps1"
|
2018-11-27 03:42:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function cmd_clean_web () {
|
2019-10-01 21:38:47 +03:00
|
|
|
run_command "Cleaning" "$top/wwt-web-client/clean.log" "build_web.ps1" "/t:clean"
|
2018-11-27 03:42:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-29 23:56:17 +03:00
|
|
|
function cmd_grunt () {
|
2019-10-01 21:35:32 +03:00
|
|
|
just_run_command "clientcmd.ps1" "grunt $@"
|
2018-11-29 23:56:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function cmd_npm () {
|
2019-10-01 21:35:32 +03:00
|
|
|
just_run_command "clientcmd.ps1" "npm $@"
|
2018-11-29 23:56:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-01 21:44:31 +03:00
|
|
|
function cmd_nuget () {
|
|
|
|
just_run_command "clientcmd.ps1" "nuget $@"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-29 03:02:48 +03:00
|
|
|
function cmd_serve_web () {
|
2019-10-01 21:38:47 +03:00
|
|
|
run_command "Serving" "$top/wwt-web-client/serve.log" "serve_web.ps1"
|
2018-11-29 03:02:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-27 03:42:04 +03:00
|
|
|
function usage () {
|
|
|
|
echo "Usage: $0 COMMAND [arguments...] where COMMAND is one of:"
|
|
|
|
echo ""
|
|
|
|
echo " build-web Build the web client"
|
2018-11-28 00:21:49 +03:00
|
|
|
echo " clean-web Clean files in the web client"
|
2018-11-29 23:56:17 +03:00
|
|
|
echo " grunt Run a grunt task in the webclient"
|
|
|
|
echo " npm Run an npm task in the webclient"
|
2019-10-01 21:44:31 +03:00
|
|
|
echo " nuget Run a nuget task in the webclient"
|
2018-11-29 03:02:48 +03:00
|
|
|
echo " serve-web Serve the current web pack on http://MSEDGEWIN10:26993/"
|
2018-11-27 03:42:04 +03:00
|
|
|
echo ""
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Dispatcher.
|
|
|
|
|
|
|
|
command="$1"
|
|
|
|
|
|
|
|
if [ -z "$command" ] ; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
shift
|
|
|
|
|
|
|
|
case "$command" in
|
|
|
|
build-web)
|
|
|
|
cmd_build_web "$@" ;;
|
|
|
|
clean-web)
|
|
|
|
cmd_clean_web "$@" ;;
|
2018-11-29 23:56:17 +03:00
|
|
|
grunt)
|
|
|
|
cmd_grunt "$@" ;;
|
|
|
|
npm)
|
|
|
|
cmd_npm "$@" ;;
|
2019-10-01 21:44:31 +03:00
|
|
|
nuget)
|
|
|
|
cmd_nuget "$@" ;;
|
2018-11-29 03:02:48 +03:00
|
|
|
serve-web)
|
|
|
|
cmd_serve_web "$@" ;;
|
2018-11-27 03:42:04 +03:00
|
|
|
*)
|
|
|
|
echo >&2 "error: unrecognized COMMAND \"$command\""
|
|
|
|
usage ;;
|
|
|
|
esac
|