- New variants/build_all.sh: rebuilds ALL variants from their json definitions in one go (loops over <definitions-dir>/*.json, calls build.php per variant, aggregates failures, exits non-zero on any failure) and prints the owner follow-up actions (reset each variant theme in the LS admin, flushassets, Ctrl+F5). Generic tooling — no client names — so it ships in the public repo. - README.md: the variants workflow is now split into a 'Build process' (defining a NEW variant: json + assets in the private definitions repo, build.php, deploy + theme reset + flushassets) and a 'Rebuild process' (build_all.sh after a mother config.xml change or a definitions change). The preview section now documents the standing rules: variant preview must differ from the mother's, preview.svg is committed + synced publicly, added only at first creation and never overwritten. - AGENTS.md propagation rule now points at build_all.sh. Verified: bash -n clean; PHP_BIN=/usr/bin/php bash variants/build_all.sh variants -> '2 built, 0 failed', rc=0, both variants' preview.svg untouched (md5 before = after); export_public.sh exit 0 with build_all.sh in the zip. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
75 lines
3 KiB
Shell
75 lines
3 KiB
Shell
#!/usr/bin/env bash
|
|
# ---------------------------------------------------------------------------
|
|
# REBUILD process: rebuild ALL variants of this theme from their json
|
|
# definitions in one go (see README.md, "Client variants (house styles)").
|
|
#
|
|
# Usage:
|
|
# bash variants/build_all.sh [definitions-dir]
|
|
#
|
|
# definitions-dir defaults to the variants/ folder next to this script, or to
|
|
# $RESPONDAGE_VARIANTS_DIR (the private variants repository, which holds the
|
|
# confidential <client>.json files and <client>/ asset folders). Every
|
|
# <name>.json in that dir is built with variants/build.php <name> <dir>.
|
|
#
|
|
# Environment:
|
|
# PHP_BIN php binary to use (default: "php"; e.g. PHP_BIN=/usr/bin/php)
|
|
#
|
|
# Per-variant rules enforced by build.php itself:
|
|
# - unknown option keys fail the build loudly (drift check);
|
|
# - files/preview.svg is added only at FIRST creation and never overwritten
|
|
# (row 235) — edit it in the variant, not here;
|
|
# - a WARNING is printed when the variant's preview.png is identical to the
|
|
# mother's (standing rule: each variant has its own preview).
|
|
#
|
|
# After a successful run, the OWNER actions in the LimeSurvey admin UI are:
|
|
# 1. reset every rebuilt variant theme (Theme options -> <variant> -> Reset),
|
|
# so the new config.xml is imported into lime_template_configuration;
|
|
# 2. flush the asset cache: php application/commands/console.php flushassets
|
|
# (or the button in the admin UI);
|
|
# 3. hard-refresh the browser (Ctrl+F5).
|
|
# ---------------------------------------------------------------------------
|
|
set -u
|
|
|
|
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
DEFS="${1:-${RESPONDAGE_VARIANTS_DIR:-$HERE}}"
|
|
PHP_BIN="${PHP_BIN:-php}"
|
|
|
|
if [ ! -d "$DEFS" ]; then
|
|
echo "ERROR: definitions dir not found: $DEFS" >&2
|
|
echo "Usage: bash variants/build_all.sh [definitions-dir]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
shopt -s nullglob
|
|
jsons=("$DEFS"/*.json)
|
|
if [ ${#jsons[@]} -eq 0 ]; then
|
|
echo "ERROR: no *.json variant definitions found in $DEFS" >&2
|
|
exit 1
|
|
fi
|
|
|
|
built=0
|
|
failed=0
|
|
for json in "${jsons[@]}"; do
|
|
name="$(basename "$json" .json)"
|
|
echo "=================================================================="
|
|
echo "=== building variant: $name (from $json)"
|
|
echo "=================================================================="
|
|
if "$PHP_BIN" "$HERE/build.php" "$name" "$DEFS"; then
|
|
built=$((built + 1))
|
|
else
|
|
failed=$((failed + 1))
|
|
echo "!!! BUILD FAILED: $name (see output above)" >&2
|
|
fi
|
|
done
|
|
|
|
echo "=================================================================="
|
|
echo "Rebuild summary: $built built, $failed failed (definitions dir: $DEFS)"
|
|
if [ "$failed" -gt 0 ]; then
|
|
echo "Fix the failing definitions and re-run this script." >&2
|
|
exit 1
|
|
fi
|
|
echo
|
|
echo "Next — owner actions in the LimeSurvey admin UI:"
|
|
echo " 1. reset every rebuilt variant theme (Theme options -> <variant> -> Reset)"
|
|
echo " 2. flush the asset cache (php application/commands/console.php flushassets)"
|
|
echo " 3. hard-refresh the browser (Ctrl+F5)"
|