From 1d09b6f480e388c7096ff42c9b2837f1d5982c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Gla=CC=88ser?= Date: Mon, 25 May 2026 08:33:38 +0200 Subject: [PATCH] Resolve styleguide imports before syncing upstream CSS --- ...sync_styleguide_to_webapp_aktienberater.sh | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/scripts/sync_styleguide_to_webapp_aktienberater.sh b/scripts/sync_styleguide_to_webapp_aktienberater.sh index c77404e..d870326 100755 --- a/scripts/sync_styleguide_to_webapp_aktienberater.sh +++ b/scripts/sync_styleguide_to_webapp_aktienberater.sh @@ -68,7 +68,32 @@ PORTAL_STYLEGUIDE_DOCS_PATH="$PORTAL_REPO_PATH/$PORTAL_STYLEGUIDE_DOCS_REL" mkdir -p "$(dirname "$PORTAL_CSS_PATH")" mkdir -p "$PORTAL_STYLEGUIDE_DOCS_PATH" -cp "$SOURCE_CSS" "$PORTAL_CSS_PATH" +flatten_css() { + local source_file="$1" + local source_root="$2" + local output_file="$3" + + : > "$output_file" + while IFS= read -r line; do + if [[ "$line" =~ ^[[:space:]]*@import[[:space:]]+\"([^\"]+)\"[[:space:]]*\;[[:space:]]*$ ]]; then + local import_path="${BASH_REMATCH[1]}" + local import_abs="$source_root/$import_path" + if [[ ! -f "$import_abs" ]]; then + echo "Imported CSS not found: $import_abs" >&2 + exit 1 + fi + cat "$import_abs" >> "$output_file" + printf "\n" >> "$output_file" + else + printf "%s\n" "$line" >> "$output_file" + fi + done < "$source_file" +} + +TMP_UPSTREAM_CSS="$(mktemp)" +trap 'rm -f "$TMP_UPSTREAM_CSS"' EXIT +flatten_css "$SOURCE_CSS" "$STYLEGUIDE_REPO_ROOT" "$TMP_UPSTREAM_CSS" +cp "$TMP_UPSTREAM_CSS" "$PORTAL_CSS_PATH" rsync -a --delete \ --exclude ".git/" \