Skip to content

Commit

Permalink
scripts: Add ui.sh
Browse files Browse the repository at this point in the history
This script runs your local checkout of the UI.
  • Loading branch information
danobi authored and kuba-moo committed May 6, 2024
1 parent 4a4085e commit 79c4001
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions scripts/ui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
#
# This script opens your local checkout of the UI in your browser.
#
# Note you need to have run `scripts/ui_assets.sh download` at least
# once prior to running this script.
#
# Usage example:
#
# ./scripts/ui.sh

set -eu

# Change dir to project root
cd "$(git rev-parse --show-toplevel)"

# Quick sanity check
if [[ ! -d ./ui/static ]]; then
echo >&2 "Error: you haven't run scripts/ui_assets.sh yet"
exit 1
fi

# Need to run a local webserver to avoid CORS violations
python -m http.server -d ./ui -b localhost 8080 &> /dev/null &
pid=$!
trap 'kill ${pid}' EXIT

# Best effort in case someone is on OSX or SSH forwarding
if ! xdg-open http://localhost:8080/status.html &> /dev/null; then
echo "UI is available at http://localhost:8080/status.html"
fi

echo "Press Enter to stop serving and exit..."
read -r -p ""

0 comments on commit 79c4001

Please sign in to comment.