Fail the deploy build when a module is left off the publish list
Some checks failed
CI / build-and-deploy (push) Has been cancelled

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
This commit is contained in:
Jon
2026-08-01 21:10:59 +01:00
parent 539e3cfb34
commit c293ee47d9

View File

@@ -4,14 +4,37 @@
# An allowlist rather than an .assetsignore denylist: everything that lands in # An allowlist rather than an .assetsignore denylist: everything that lands in
# dist/ becomes publicly readable, so it should be a deliberate list, not # dist/ becomes publicly readable, so it should be a deliberate list, not
# whatever happens to be sitting in the working directory. # 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 set -eu
cd "$(dirname "$0")" 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 rm -rf dist
mkdir -p dist mkdir -p dist
cp index.html _headers dist/ cp index.html _headers dist/
cp index.js index-fallback.js home.js settings.js intervalometer.js \ # shellcheck disable=SC2086
storage.js config-utils.js preview.js widget.js dist/ 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:" echo "dist/ contains:"
ls -1 dist ls -1 dist