Files
web-dslr/examples/preact/build-dist.sh
Jon c293ee47d9
Some checks failed
CI / build-and-deploy (push) Has been cancelled
Fail the deploy build when a module is left off the publish list
voice.js was missing from build-dist.sh, which would have shipped a Worker
whose index.js imports a 404 - the app wouldn't have loaded at all. That's the
failure mode of an allowlist, so check it: any top-level .js not in MODULES now
fails the build instead of silently vanishing from the deploy.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QK7PKpRVoy69Fpa32R8abb
2026-08-01 21:10:59 +01:00

41 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# Assemble exactly what gets published to Cloudflare.
#
# An allowlist rather than an .assetsignore denylist: everything that lands in
# dist/ becomes publicly readable, so it should be a deliberate list, not
# whatever happens to be sitting in the working directory.
#
# The catch with an allowlist is forgetting to add a new module, which breaks
# the deploy outright (the import 404s and nothing loads), so the check at the
# bottom fails the build if any top-level .js file was left out.
set -eu
cd "$(dirname "$0")"
MODULES="index.js index-fallback.js home.js settings.js intervalometer.js
storage.js config-utils.js preview.js voice.js widget.js"
# Collapse the line break to single spaces so the membership test below works.
# shellcheck disable=SC2116,SC2086
MODULES=$(echo $MODULES)
rm -rf dist
mkdir -p dist
cp index.html _headers dist/
# shellcheck disable=SC2086
cp $MODULES dist/
missing=""
for f in *.js; do
case " $MODULES " in
*" $f "*) ;;
*) missing="$missing $f" ;;
esac
done
if [ -n "$missing" ]; then
echo "error: top-level modules missing from the publish list:$missing" >&2
echo " add them to MODULES in $0, or delete them." >&2
exit 1
fi
echo "dist/ contains:"
ls -1 dist