whiskers.git / web / tools / preview-hash
preview-hash18 lines · 1.0 KB · raw
1#!/usr/bin/env bash
2# Prints one hash of everything the link preview is drawn from: the sources of the cat, the site,
3# the generator and the shared look (`jev-ui`), the generator's and this script's own settings, and
4# the default mascot (asked of the generator, so it is what the card really draws).
5# `tools/preview` writes it beside the files it builds; `tools/build` and `tools/check-preview`
6# compare. Content, not modification times: a checkout touches every file, and a stale card has
7# shipped once under mtimes.
8#
9#     nix develop ~/whiskers#web -c web/tools/preview-hash
10set -euo pipefail
11cd "$(dirname "$0")/.."
12{
13  find cat site previewgen ../crates/whiskers-pet ../crates/whiskers-art ../third-party/jevcrates/jev-ui \
14    -type f -not -path '*/target/*' \( -name '*.rs' -o -name 'Cargo.toml' -o -name '*.css' -o -name '*.js' -o -name '*.woff2' \) -print0 \
15    | LC_ALL=C sort -z | xargs -0 sha256sum
16  sha256sum tools/preview Cargo.lock
17  echo "default mascot: $(cargo run -q -p previewgen -- mascot)"
18} | sha256sum | cut -d' ' -f1