Jesús Pérez 9095ea6d8e
Some checks failed
Nickel Type Check / Nickel Type Checking (push) Has been cancelled
Rust CI / Security Audit (push) Has been cancelled
Rust CI / Check + Test + Lint (nightly) (push) Has been cancelled
Rust CI / Check + Test + Lint (stable) (push) Has been cancelled
feat: add stratum-orchestrator with graph, state, NATS, and Nickel action nodes
New crates: stratum-orchestrator (Cedar authz, Vault secrets, Nu/agent executors,
  saga runner), stratum-graph (petgraph DAG + SurrealDB repo), stratum-state
  (SurrealDB tracker), platform-nats (NKey auth client), ncl-import-resolver.

  Updates: stratum-embeddings (SurrealDB store + persistent cache), stratum-llm
  circuit breaker. Adds Nickel action-nodes, schemas, config, Nushell scripts,
  docker-compose dev stack, and ADR-003.
2026-02-22 21:33:26 +00:00

98 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# Minify HTML files from src/ to production versions
# Usage: ./minify.sh
# Processes: stratumiops-arch, stratumiops-pipeline, stratumiops-orchestrator
set -e
SCRIPT_DIR="$(dirname "$0")"
FILES=("stratumiops-arch" "stratumiops-pipeline" "stratumiops-orchestrator")
minify_file() {
local basename=$1
local src_file="${SCRIPT_DIR}/src/${basename}.html"
local out_file="${SCRIPT_DIR}/${basename}.html"
local temp_file="${out_file}.tmp"
if [ ! -f "$src_file" ]; then
echo "⚠️ Skipping $basename: source file not found: $src_file"
return 0
fi
echo "🔨 Minifying $basename.html..."
echo " Input: $src_file"
echo " Output: $out_file"
perl -e "
use strict;
use warnings;
open(my \$fh, '<', '$src_file') or die \$!;
my \$content = do { local \$/; <\$fh> };
close(\$fh);
# Remove HTML comments
\$content =~ s/<!--.*?-->//gs;
# Compress CSS (remove spaces and comments)
\$content =~ s/(<style[^>]*>)(.*?)(<\/style>)/
my \$before = \$1;
my \$style = \$2;
my \$after = \$3;
\$style =~ s{\/\*.*?\*\/}{}gs;
\$style =~ s{\s+}{ }gs;
\$style =~ s{\s*([{}:;,>+~])\s*}{\$1}gs;
\$before . \$style . \$after;
/gies;
# Compress JavaScript (remove comments and extra spaces)
\$content =~ s/(<script[^>]*>)(.*?)(<\/script>)/
my \$before = \$1;
my \$script = \$2;
my \$after = \$3;
\$script =~ s{\/\/.*\$}{}gm;
\$script =~ s{\s+}{ }gs;
\$script =~ s{\s*([{}();,])\s*}{\$1}gs;
\$before . \$script . \$after;
/gies;
# Remove whitespace between tags
\$content =~ s/>\s+</></gs;
# Compress general whitespace
\$content =~ s/\s+/ /gs;
# Trim
\$content =~ s/^\s+|\s+\$//g;
open(my \$out, '>', '$temp_file') or die \$!;
print \$out \$content;
close(\$out);
" || {
echo "❌ Minification failed for $basename"
rm -f "$temp_file"
return 1
}
mv "$temp_file" "$out_file"
# Show statistics
original=$(wc -c < "$src_file")
minified=$(wc -c < "$out_file")
saved=$((original - minified))
percent=$((saved * 100 / original))
echo "$basename.html minified"
printf " Original: %6d bytes | Minified: %6d bytes | Saved: %d%% (%d bytes)\n" "$original" "$minified" "$percent" "$saved"
echo ""
}
echo "🔨 Minifying HTML files..."
echo ""
for file in "${FILES[@]}"; do
minify_file "$file" || exit 1
done
echo "✅ All HTML files minified and ready for production"