#!/bin/sh # Builds dist/: the composition and its modules at the atlibs.lock.json pins, one OAuth client (app) with every # instance's session, the page, the tile, and dl/atirc-x86_64 when ATIRC_BIN names it (sha256 checked). # 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) >/dev/null 2>&1 node compose.ts | cmp -s - composition.json || { echo "composition.json is stale: node compose.ts > composition.json" >&2; exit 1; } rm -rf dist if ! err=$(atlibs stage --target spa --name app ${origin:+--origin "$origin"} --out dist composition.json 2>&1 >/dev/null); then echo "$err" >&2; exit 1; fi atlibs compose check dist/composition.json >/dev/null cp -R index.html main.js app.js vendor tiles.js theme.css app.css atlibs.lock.json tile dist/ if [ -n "${ATIRC_BIN-}" ]; then want=$(jq -r '.parameters[] | select(.key == "atirc_sha256") | .values.default' composition.json) echo "$want $ATIRC_BIN" | shasum -a 256 -c - >/dev/null mkdir -p dist/dl && cp "$ATIRC_BIN" dist/dl/atirc-x86_64 fi [ -n "$origin" ] && echo "built dist/ for $origin" || echo "built dist/ for 127.0.0.1 (deploy: --origin https://host/path/)"