1#!/usr/bin/env bash 2# What `wrangler dev` and `wrangler deploy` run before they serve or upload (web/wrangler.toml, 3# [build]): the link preview's card, then the Worker. So a Worker cannot go out whose own tags 4# point at a picture that was never made. 5# 6# tools/build-web.sh (mise run web:build) 7# 8# The card is drawn by the site's own code (web/src/bin/card.rs prints an SVG) and made a PNG by 9# resvg, because the apps that show link previews do not draw SVG. 10set -euo pipefail 11cd "$(dirname "$0")/.." 12for tool in cargo resvg worker-build; do 13 command -v "$tool" >/dev/null || { echo "build-web: $tool is not installed (mise install)" >&2; exit 1; } 14done 15 16out=web/public/preview 17mkdir -p "$out" 18cargo run --quiet --manifest-path web/Cargo.toml --bin card > "$out/card.svg" 19resvg "$out/card.svg" "$out/card.png" 20rm "$out/card.svg" 21[ -s "$out/card.png" ] || { echo "build-web: the card was not drawn" >&2; exit 1; } 22 23cd web 24exec worker-build --release