Some checks failed
CI / Lint (bash) (push) Has been cancelled
CI / Lint (markdown) (push) Has been cancelled
CI / Lint (nickel) (push) Has been cancelled
CI / Lint (nushell) (push) Has been cancelled
CI / Lint (rust) (push) Has been cancelled
CI / Benchmark (push) Has been cancelled
CI / Security Audit (push) Has been cancelled
CI / License Compliance (push) Has been cancelled
CI / Code Coverage (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (macos-latest) (push) Has been cancelled
CI / Build (ubuntu-latest) (push) Has been cancelled
CI / Build (windows-latest) (push) Has been cancelled
Replace all TOML form definitions in examples/ and config/ with type-checked Nickel equivalents. Update cli_loader to prefer .ncl (via nickel export) over .toml in config search order. TOML support retained as fallback — no breaking change. - El loader usa nickel export --format json + serde_json como puente — evita reimplementar un parser Nickel en Rust y aprovecha el binario ya existente. - El orden de búsqueda .ncl > .toml permite migración incremental: cualquier config vieja sigue funcionando sin tocarla. - Los contratos Nickel (| default, | String) en los configs sustituyen la validación que antes era implícita en el parsing TOML — el error llega antes (en nickel export) con mensajes más descriptivos.
102 lines
2.2 KiB
Bash
Executable File
102 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# Minify HTML files from src/ to production versions
|
|
# Usage: ./minify.sh
|
|
|
|
set -e
|
|
|
|
BASE_DIR="$(dirname "$0")"
|
|
FILES=("index.html" "architecture-diagram.html")
|
|
|
|
minify_file() {
|
|
local filename="$1"
|
|
local SRC_FILE="${BASE_DIR}/src/${filename}"
|
|
local OUT_FILE="${BASE_DIR}/${filename}"
|
|
local TEMP_FILE="${OUT_FILE}.tmp"
|
|
|
|
if [ ! -f "$SRC_FILE" ]; then
|
|
echo " Source file not found: $SRC_FILE (skipping)"
|
|
return 0
|
|
fi
|
|
|
|
echo ""
|
|
echo " Minifying ${filename}..."
|
|
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"
|
|
rm -f "$TEMP_FILE"
|
|
exit 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 ""
|
|
echo " Compression statistics:"
|
|
printf " Original: %6d bytes\n" "$original"
|
|
printf " Minified: %6d bytes\n" "$minified"
|
|
printf " Saved: %6d bytes (%d%%)\n" "$saved" "$percent"
|
|
echo " ${filename} ready for production"
|
|
}
|
|
|
|
echo "Starting HTML minification..."
|
|
|
|
for file in "${FILES[@]}"; do
|
|
minify_file "$file"
|
|
done
|
|
|
|
echo ""
|
|
echo "All files minified."
|
|
echo ""
|