2026-11-16 19:51:19 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
#
|
|
|
|
|
# Build a PUBLIC release of the mother theme (respondage_vanilla) only.
|
|
|
|
|
#
|
|
|
|
|
# Client data (variant definitions variants/*.json, generated client theme
|
|
|
|
|
# folders, git branches containing a client theme) must NEVER be published.
|
|
|
|
|
# This script therefore:
|
|
|
|
|
# 1. copies the theme WITHOUT .git, WITHOUT variants/*.json (only the
|
|
|
|
|
# generic build.php and export script are kept) and without old exports;
|
|
|
|
|
# 2. scans the staged copy for client-identifying strings and ABORTS if any
|
|
|
|
|
# are found;
|
|
|
|
|
# 3. creates a zip next to the folder.
|
|
|
|
|
#
|
|
|
|
|
# Usage:
|
|
|
|
|
# bash variants/export_public.sh [output-dir]
|
|
|
|
|
#
|
|
|
|
|
# Default output dir: <limesurvey-root>/dist (deliberately NOT inside
|
|
|
|
|
# upload/themes/survey/, because every folder there is scanned as a theme).
|
|
|
|
|
#
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
THEME_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
|
|
SITE_ROOT="$(cd "$THEME_DIR/../../../.." && pwd)"
|
|
|
|
|
OUT_DIR="${1:-$SITE_ROOT/dist}"
|
|
|
|
|
STAGE="$OUT_DIR/respondage_vanilla"
|
|
|
|
|
VERSION="$(sed -n 's:.*<version>\([^<]*\)</version>.*:\1:p' "$THEME_DIR/config.xml" | head -1)"
|
|
|
|
|
ZIP_NAME="respondage_vanilla-${VERSION}-public.zip"
|
|
|
|
|
|
|
|
|
|
rm -rf "$STAGE"
|
|
|
|
|
mkdir -p "$STAGE" "$OUT_DIR"
|
|
|
|
|
|
|
|
|
|
# 1. copy the theme, excluding .git, client variant definitions, the internal
|
|
|
|
|
# variants README and old exports (the generic build/export scripts are kept)
|
2026-11-16 20:41:23 +01:00
|
|
|
(cd "$THEME_DIR" && tar --exclude='./.git' --exclude='./dist' --exclude='./variants/*.json' --exclude='./variants/README.internal.md' --exclude='./variants/leak-patterns.txt' -cf - .) | (cd "$STAGE" && tar -xf -)
|
2026-11-16 19:51:19 +01:00
|
|
|
|
|
|
|
|
# 2. leak check: no client-identifying strings may remain (text files only).
|
2026-11-16 20:41:23 +01:00
|
|
|
# Client names are NOT hardcoded in this public file. Patterns are derived:
|
|
|
|
|
# - the names of sibling variant theme folders (../<name>_vanilla next to
|
|
|
|
|
# this theme, excluding this theme itself);
|
|
|
|
|
# - extra patterns (names, terms, hex colors) from variants/leak-patterns.txt,
|
|
|
|
|
# one regex per line. That file is gitignored here and lives in the PRIVATE
|
|
|
|
|
# variants repository (respondage_vanilla_variants).
|
|
|
|
|
PATTERNS=""
|
|
|
|
|
MOTHER_NAME="$(basename "$THEME_DIR")"
|
|
|
|
|
for d in "$THEME_DIR"/../*_vanilla; do
|
|
|
|
|
[ -d "$d" ] || continue
|
|
|
|
|
name="$(basename "$d")"
|
|
|
|
|
[ "$name" = "$MOTHER_NAME" ] && continue
|
|
|
|
|
PATTERNS="$PATTERNS|$name"
|
|
|
|
|
done
|
|
|
|
|
if [ -f "$THEME_DIR/variants/leak-patterns.txt" ]; then
|
|
|
|
|
while IFS= read -r line; do
|
|
|
|
|
case "$line" in ''|\#*) continue ;; esac
|
|
|
|
|
PATTERNS="$PATTERNS|$line"
|
|
|
|
|
done < "$THEME_DIR/variants/leak-patterns.txt"
|
|
|
|
|
fi
|
|
|
|
|
PATTERNS="${PATTERNS#|}"
|
|
|
|
|
if [ -n "$PATTERNS" ] && grep -rIlE "$PATTERNS" "$STAGE"; then
|
2026-11-16 19:51:19 +01:00
|
|
|
echo "ERROR: client-identifying strings found in the public export - aborting, staging removed." >&2
|
2026-11-16 20:41:23 +01:00
|
|
|
echo "(patterns came from sibling *_vanilla folders and variants/leak-patterns.txt)" >&2
|
2026-11-16 19:51:19 +01:00
|
|
|
rm -rf "$STAGE"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# 3. zip it
|
|
|
|
|
(cd "$OUT_DIR" && rm -f "$ZIP_NAME" && zip -qr "$ZIP_NAME" respondage_vanilla)
|
|
|
|
|
|
|
|
|
|
echo "Public release created:"
|
|
|
|
|
echo " folder: $STAGE"
|
|
|
|
|
echo " zip: $OUT_DIR/$ZIP_NAME"
|
|
|
|
|
echo
|
|
|
|
|
echo "Publish ONLY this artifact (or the main branch of this repo)."
|
|
|
|
|
echo "NEVER publish variants/*.json, generated client theme folders, or a git"
|
|
|
|
|
echo "branch that contains a client theme - client names, colors and logos are confidential."
|