release(v3.2.1): fix asset stamper to stamp src/ templates + APP_QVER placeholders

This commit is contained in:
Ryan
2026-01-28 02:32:54 -05:00
committed by GitHub
parent b7bcaa8cd3
commit 21eb77d900
2 changed files with 27 additions and 7 deletions
+6 -1
View File
@@ -1,6 +1,11 @@
# Changelog
## Changes 01/28/2026 (v3.2.0)
## Changes 01/28/2026 (v3.2.0 & v3.2.1)
`release(v3.2.1): fix asset stamper to stamp src/ templates + APP_QVER placeholders`
- stamp-assets: include src/ alongside public/ for stamping
- stamp-assets: replace {{APP_QVER}} in HTML/CSS/PHP templates and validate no placeholders remain
`release(v3.2.0): share pages revamp + portals browse/download-all + Pro branding upgrades`
+21 -6
View File
@@ -11,19 +11,34 @@ echo "VER=${VER} QVER=${QVER}"
cd "$TARGET"
# Directories to stamp (public assets + server-rendered PHP templates)
STAMP_DIRS=()
if [[ -d "public" ]]; then
STAMP_DIRS+=("public")
fi
if [[ -d "src" ]]; then
STAMP_DIRS+=("src")
fi
if [[ ${#STAMP_DIRS[@]} -eq 0 ]]; then
echo "No stampable directories found."
exit 0
fi
# Normalize CRLF to LF (if any files were edited on Windows)
# We only touch web assets.
find public \( -name '*.html' -o -name '*.php' -o -name '*.css' -o -name '*.js' \) -type f -print0 \
find "${STAMP_DIRS[@]}" \( -name '*.html' -o -name '*.php' -o -name '*.css' -o -name '*.js' \) -type f -print0 \
| xargs -0 -r sed -i 's/\r$//'
# --- HTML/CSS/PHP: stamp ?v=... and {{APP_VER}} ---
# --- HTML/CSS/PHP: stamp ?v=... and {{APP_VER}}/{{APP_QVER}} ---
# (?v=...) -> ?v=<QVER>
HTML_CSS_COUNT=0
while IFS= read -r -d '' f; do
sed -E -i "s/(\?v=)[^\"'&<>\s]*/\1${QVER}/g" "$f"
sed -E -i "s/\{\{APP_VER\}\}/${VER}/g" "$f"
sed -E -i "s/\{\{APP_QVER\}\}/${QVER}/g" "$f"
HTML_CSS_COUNT=$((HTML_CSS_COUNT+1))
done < <(find public -type f \( -name '*.html' -o -name '*.php' -o -name '*.css' \) -print0)
done < <(find "${STAMP_DIRS[@]}" -type f \( -name '*.html' -o -name '*.php' -o -name '*.css' \) -print0)
# --- JS: stamp placeholders and normalize any pre-existing ?v=... ---
JS_COUNT=0
@@ -35,7 +50,7 @@ while IFS= read -r -d '' f; do
# This keeps any ".js" or ".mjs" then forces ?v=<QVER>
perl -0777 -i -pe "s@(\.m?js)\?v=[^\"')]+@\1?v=${QVER}@g" "$f"
JS_COUNT=$((JS_COUNT+1))
done < <(find public -type f -name '*.js' -print0)
done < <(find "${STAMP_DIRS[@]}" -type f -name '*.js' -print0)
# Force-write version.js (source of truth in stamped output)
if [[ -f public/js/version.js ]]; then
@@ -45,10 +60,10 @@ fi
echo "Touched files: HTML/CSS/PHP=${HTML_CSS_COUNT}, JS=${JS_COUNT}"
# Final self-check: fail if anything is left
if grep -R -n -E "{{APP_QVER}}|{{APP_VER}}" public \
if grep -R -n -E "{{APP_QVER}}|{{APP_VER}}" "${STAMP_DIRS[@]}" \
--include='*.html' --include='*.php' --include='*.css' --include='*.js' 2>/dev/null; then
echo "ERROR: Placeholders remain after stamping." >&2
exit 2
fi
echo "✅ Stamped to ${VER} (${QVER})"
echo "✅ Stamped to ${VER} (${QVER})"