#!/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/browse.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: shared base first, then browse-specific. concat_files \ "../shared/base.css" \ "css/base.css" \ "css/tree.css" \ > "$css_temp" # JS files: shared canonical helpers, then browse modules. # init.js must come first so window.app exists when later modules # attach to it. concat_files \ "../shared/zddc.js" \ "../shared/theme.js" \ "js/init.js" \ "js/loader.js" \ "js/tree.js" \ "js/events.js" \ "js/app.js" \ > "$js_raw" # Escape any literal ` block doesn't get terminated prematurely. escape_js_close_tags "$js_raw" "$js_temp" tool=browse compute_build_label "$tool" "$@" # Replace template placeholders with concatenated CSS/JS + label. awk -v css_file="$css_temp" -v js_file="$js_temp" \ -v build_label="$build_label" -v favicon="$favicon_data_uri" ' /\{\{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 } { gsub(/\{\{BUILD_LABEL\}\}/, build_label) gsub(/\{\{FAVICON\}\}/, favicon) print } ' "$src_html" > "$output_html" echo "Wrote $output_html" # Promote AFTER the dist file exists so promote_release can copy from # $output_html. (The order matters — _promote_stable does cp $output_html ...) promote_release "$tool"