1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
# Builds dist/: modules + sessions at the atlibs.lock.json pins, one OAuth client (atlibs-agent), stage.json, the page.
# scripts/stage.sh [--origin https://host/path/]
set -eu
cd "$(dirname "$0")/.."
origin=
case ${1-} in
--origin) origin=$2 ;;
'') ;;
*) echo "usage: $0 [--origin https://host/path/]" >&2; exit 2 ;;
esac
atlibs add $(jq -r '.modules[] | select(.ref) | (.ref | split("@")[0]) + "@" + .pin' atlibs.lock.json)
rm -rf dist
if ! err=$(atlibs stage --target spa --name atlibs-agent ${origin:+--origin "$origin"} --out dist 2>&1 >/dev/null); then echo "$err" >&2; exit 1; fi
cp index.html main.js spa.js config.js dist/
[ -n "$origin" ] && echo "built dist/ for $origin" || echo "built dist/ for 127.0.0.1 (deploy: --origin https://host/path/)"