Every plain `sh tool/build.sh` invocation now reasserts a relative symlink website/releases/<tool>_alpha.html → ../../<tool>/dist/<tool>.html so the alpha hyperlinks always serve whatever dist currently holds. Idempotent — git sees no churn on rebuild. `--release alpha` still wins by overwriting the symlink with a real "alpha · <date> · <sha>" file; the next plain build re-symlinks it. Five existing alpha files become typechanges (regular file → symlink) — the one-time migration cost. The reassertion survives deployment because the website is served directly from the working tree. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
88 lines
2.1 KiB
Bash
88 lines
2.1 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
root_dir=$(cd "$(dirname "$0")" && pwd)
|
|
. "$root_dir/../shared/build-lib.sh"
|
|
|
|
src_html="$root_dir/template.html"
|
|
output_dir="$root_dir/dist"
|
|
output_html="$output_dir/classifier.html"
|
|
|
|
mkdir -p "$output_dir"
|
|
ensure_exists "$src_html"
|
|
|
|
css_temp=$(mktemp)
|
|
js_raw=$(mktemp)
|
|
js_temp=$(mktemp)
|
|
cleanup() { rm -f "$css_temp" "$js_raw" "$js_temp"; }
|
|
trap cleanup EXIT
|
|
|
|
# CSS files to concatenate in order
|
|
concat_files \
|
|
"../shared/base.css" \
|
|
"css/base.css" \
|
|
"css/layout.css" \
|
|
"css/spreadsheet.css" \
|
|
> "$css_temp"
|
|
|
|
# JavaScript files to concatenate in order
|
|
concat_files \
|
|
"../shared/zddc.js" \
|
|
"../shared/hash.js" \
|
|
"../shared/theme.js" \
|
|
"js/app.js" \
|
|
"js/utils.js" \
|
|
"../shared/zddc-filter.js" \
|
|
"js/store.js" \
|
|
"js/validator.js" \
|
|
"js/scanner.js" \
|
|
"js/tree.js" \
|
|
"js/spreadsheet.js" \
|
|
"js/selection.js" \
|
|
"js/preview.js" \
|
|
"js/resize.js" \
|
|
"js/filter.js" \
|
|
"js/sort.js" \
|
|
"js/excel.js" \
|
|
"../shared/help.js" \
|
|
> "$js_raw"
|
|
|
|
# Escape '</' in inlined JS so the HTML parser cannot mistake string contents
|
|
# for a closing </script> tag. Required for any tool with template literals.
|
|
escape_js_close_tags "$js_raw" "$js_temp"
|
|
|
|
compute_build_label "classifier" "${1:-}" "${2:-}"
|
|
|
|
# Process template: inject CSS/JS, substitute build label, strip CDN refs.
|
|
awk -v css_file="$css_temp" -v js_file="$js_temp" -v build_label="$build_label" -v is_red="$is_red" '
|
|
/\{\{CSS_PLACEHOLDER\}\}/ {
|
|
while ((getline line < css_file) > 0) print line
|
|
close(css_file)
|
|
next
|
|
}
|
|
/\{\{JS_PLACEHOLDER\}\}/ {
|
|
while ((getline line < js_file) > 0) print line
|
|
close(js_file)
|
|
next
|
|
}
|
|
/\{\{BUILD_LABEL\}\}/ {
|
|
if (is_red == "1") {
|
|
gsub(/\{\{BUILD_LABEL\}\}/, "<span style=\"color:red;font-weight:bold\">" build_label "</span>")
|
|
} else {
|
|
gsub(/\{\{BUILD_LABEL\}\}/, build_label)
|
|
}
|
|
print
|
|
next
|
|
}
|
|
/<script src="https?:\/\// { next }
|
|
/<link rel="stylesheet" href="https?:\/\// { next }
|
|
{ print }
|
|
' "$src_html" > "$output_html"
|
|
|
|
echo "Wrote $output_html"
|
|
|
|
if [ "$is_release" = "1" ]; then
|
|
promote_release "classifier"
|
|
else
|
|
update_alpha "classifier"
|
|
fi
|