1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
# Build the SPA from the local cache and deploy it to wisp.place.
# Credentials come from the environment; nothing is stored in this script.
set -euo pipefail
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
REPO_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
HANDLE=${ATP_HANDLE:-${NAHDIG_COM_ATPROTO_HANDLE:-}}
PASSWORD=${ATP_APP_PASSWORD:-${NAHDIG_COM_ATPROTO_PASSWORD:-}}
SITE=${WISP_SITE:-cve}
CACHE_DB=${CACHE_DB:-$REPO_DIR/.state/prod-week.db}
DIST_DIR=$SCRIPT_DIR/dist
VENDOR_DIR=$SCRIPT_DIR/vendor
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
[ -n "$HANDLE" ] || die "set ATP_HANDLE or NAHDIG_COM_ATPROTO_HANDLE"
[ -n "$PASSWORD" ] || die "set ATP_APP_PASSWORD or NAHDIG_COM_ATPROTO_PASSWORD"
command -v wispctl >/dev/null 2>&1 || die "wispctl not found; npm install -g wispctl"
for asset in d3.min.js pico.min.css highlight.min.js highlight-github.min.css; do
[ -f "$VENDOR_DIR/$asset" ] || die "missing vendored asset: $VENDOR_DIR/$asset"
done
rm -rf "$DIST_DIR"
python3 "$SCRIPT_DIR/build.py" --db "$CACHE_DB" --out "$DIST_DIR/graph.json"
mkdir -p "$DIST_DIR/vendor"
cp "$VENDOR_DIR"/* "$DIST_DIR/vendor/"
for asset in index.html main.js graph.js db.js jetstream.js config.json graph.json; do
[ -f "$DIST_DIR/$asset" ] || die "missing build output: $DIST_DIR/$asset"
done
wispctl deploy "$HANDLE" \
--path "$DIST_DIR" \
--site "$SITE" \
--spa \
--password "$PASSWORD" \
--yes
printf '\ndeployed %s to site %s\n' "$DIST_DIR" "$SITE"