Sync styleguide 2026.05.18.1
This commit is contained in:
@@ -6,8 +6,6 @@ STYLEGUIDE_REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
SOURCE_CSS="$STYLEGUIDE_REPO_ROOT/styleguide.css"
|
||||
VERSION_FILE="$STYLEGUIDE_REPO_ROOT/VERSION"
|
||||
|
||||
PORTAL_KEY="vsf"
|
||||
PORTAL_REPO_PATH=""
|
||||
PORTAL_CSS_REL="public/assets/styleguide.upstream.css"
|
||||
PORTAL_BUILT_CSS_REL="public/assets/styles.css"
|
||||
PORTAL_META_REL="public/assets/styleguide.upstream.meta.json"
|
||||
@@ -18,11 +16,9 @@ COMMIT_IN_PORTAL="false"
|
||||
usage() {
|
||||
cat <<USAGE
|
||||
Usage:
|
||||
$(basename "$0") [--portal <vsf|naurua>] [--portal-repo <path>] [--commit-portal]
|
||||
$(basename "$0") [--commit-portal]
|
||||
|
||||
Options:
|
||||
--portal <name> Portal target. Defaults to vsf.
|
||||
--portal-repo <path> Optional override for portal repository root.
|
||||
--commit-portal Create commit in portal repo after sync.
|
||||
-h, --help Show this help.
|
||||
USAGE
|
||||
@@ -30,14 +26,6 @@ USAGE
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--portal)
|
||||
PORTAL_KEY="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--portal-repo)
|
||||
PORTAL_REPO_PATH="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--commit-portal)
|
||||
COMMIT_IN_PORTAL="true"
|
||||
shift
|
||||
@@ -54,24 +42,6 @@ while [[ $# -gt 0 ]]; do
|
||||
esac
|
||||
done
|
||||
|
||||
case "$PORTAL_KEY" in
|
||||
vsf)
|
||||
if [[ -z "$PORTAL_REPO_PATH" ]]; then
|
||||
PORTAL_REPO_PATH="/Users/mathias/Documents/Dokumente Chouchou/Codebases/WebApp_Aktienberater"
|
||||
fi
|
||||
;;
|
||||
naurua)
|
||||
if [[ -z "$PORTAL_REPO_PATH" ]]; then
|
||||
PORTAL_REPO_PATH="/Users/mathias/Documents/Dokumente Chouchou/Codebases/erp_naurua"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown portal: $PORTAL_KEY" >&2
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ! -f "$SOURCE_CSS" ]]; then
|
||||
echo "Source CSS not found: $SOURCE_CSS" >&2
|
||||
exit 1
|
||||
@@ -82,20 +52,6 @@ if [[ ! -f "$VERSION_FILE" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$PORTAL_REPO_PATH/.git" ]]; then
|
||||
echo "Portal repo is not a git repository: $PORTAL_REPO_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PORTAL_CSS_PATH="$PORTAL_REPO_PATH/$PORTAL_CSS_REL"
|
||||
PORTAL_BUILT_CSS_PATH="$PORTAL_REPO_PATH/$PORTAL_BUILT_CSS_REL"
|
||||
PORTAL_META_PATH="$PORTAL_REPO_PATH/$PORTAL_META_REL"
|
||||
PORTAL_STYLEGUIDE_DOCS_PATH="$PORTAL_REPO_PATH/$PORTAL_STYLEGUIDE_DOCS_REL"
|
||||
PORTAL_BUILD_SCRIPT_PATH="$PORTAL_REPO_PATH/$PORTAL_BUILD_SCRIPT_REL"
|
||||
|
||||
mkdir -p "$(dirname "$PORTAL_CSS_PATH")"
|
||||
mkdir -p "$PORTAL_STYLEGUIDE_DOCS_PATH"
|
||||
|
||||
flatten_css() {
|
||||
local source_file="$1"
|
||||
local source_root="$2"
|
||||
@@ -118,11 +74,12 @@ flatten_css() {
|
||||
done < "$source_file"
|
||||
}
|
||||
|
||||
transform_portal_css() {
|
||||
local source_file="$1"
|
||||
local output_file="$2"
|
||||
build_portal_css() {
|
||||
local portal_key="$1"
|
||||
local source_file="$2"
|
||||
local output_file="$3"
|
||||
|
||||
case "$PORTAL_KEY" in
|
||||
case "$portal_key" in
|
||||
vsf)
|
||||
awk '
|
||||
BEGIN { skip=0 }
|
||||
@@ -140,9 +97,94 @@ transform_portal_css() {
|
||||
{ print }
|
||||
' "$source_file" > "$output_file"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown portal: $portal_key" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
sync_portal() {
|
||||
local portal_key="$1"
|
||||
local portal_repo_path="$2"
|
||||
local portal_css_path="$portal_repo_path/$PORTAL_CSS_REL"
|
||||
local portal_built_css_path="$portal_repo_path/$PORTAL_BUILT_CSS_REL"
|
||||
local portal_meta_path="$portal_repo_path/$PORTAL_META_REL"
|
||||
local portal_styleguide_docs_path="$portal_repo_path/$PORTAL_STYLEGUIDE_DOCS_REL"
|
||||
local portal_build_script_path="$portal_repo_path/$PORTAL_BUILD_SCRIPT_REL"
|
||||
local tmp_portal_css
|
||||
|
||||
if [[ ! -d "$portal_repo_path/.git" ]]; then
|
||||
echo "Portal repo is not a git repository: $portal_repo_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname "$portal_css_path")"
|
||||
mkdir -p "$portal_styleguide_docs_path"
|
||||
|
||||
tmp_portal_css="$(mktemp)"
|
||||
build_portal_css "$portal_key" "$TMP_UPSTREAM_CSS" "$tmp_portal_css"
|
||||
cp "$tmp_portal_css" "$portal_css_path"
|
||||
rm -f "$tmp_portal_css"
|
||||
|
||||
rsync -a --delete \
|
||||
--exclude ".git/" \
|
||||
--exclude ".codex/" \
|
||||
--exclude ".DS_Store" \
|
||||
--exclude "AGENTS.md" \
|
||||
"$STYLEGUIDE_REPO_ROOT/" \
|
||||
"$portal_styleguide_docs_path/"
|
||||
|
||||
STYLEGUIDE_VERSION="$(tr -d '[:space:]' < "$VERSION_FILE")"
|
||||
STYLEGUIDE_COMMIT="$(git -C "$STYLEGUIDE_REPO_ROOT" rev-parse --short HEAD)"
|
||||
SYNCED_AT="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
||||
|
||||
cat > "$portal_meta_path" <<META
|
||||
{
|
||||
"styleguideVersion": "$STYLEGUIDE_VERSION",
|
||||
"styleguideCommit": "$STYLEGUIDE_COMMIT",
|
||||
"syncedAtUtc": "$SYNCED_AT",
|
||||
"sourceRepo": "$STYLEGUIDE_REPO_ROOT",
|
||||
"mirroredDocsPath": "$PORTAL_STYLEGUIDE_DOCS_REL"
|
||||
}
|
||||
META
|
||||
|
||||
case "$portal_key" in
|
||||
vsf)
|
||||
if [[ ! -f "$portal_build_script_path" ]]; then
|
||||
echo "Portal build script not found: $portal_build_script_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
bash "$portal_build_script_path"
|
||||
;;
|
||||
naurua)
|
||||
cp "$portal_css_path" "$portal_built_css_path"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$COMMIT_IN_PORTAL" == "true" ]]; then
|
||||
git -C "$portal_repo_path" add -A \
|
||||
"$PORTAL_CSS_REL" \
|
||||
"$PORTAL_BUILT_CSS_REL" \
|
||||
"$PORTAL_META_REL" \
|
||||
"$PORTAL_STYLEGUIDE_DOCS_REL"
|
||||
if ! git -C "$portal_repo_path" diff --cached --quiet; then
|
||||
git -C "$portal_repo_path" commit -m "Sync styleguide $STYLEGUIDE_VERSION"
|
||||
git -C "$portal_repo_path" push
|
||||
echo "$portal_key portal synced and pushed."
|
||||
else
|
||||
echo "No changes to commit in $portal_key portal repo."
|
||||
fi
|
||||
else
|
||||
echo "$portal_key portal files updated locally (no commit requested)."
|
||||
fi
|
||||
|
||||
echo "Synced $SOURCE_CSS -> $portal_css_path"
|
||||
echo "Built portal stylesheet: $portal_built_css_path"
|
||||
echo "Metadata written: $portal_meta_path"
|
||||
echo "Mirrored styleguide docs: $portal_styleguide_docs_path"
|
||||
}
|
||||
|
||||
assert_no_unimported_styles() {
|
||||
local source_file="$1"
|
||||
local source_root="$2"
|
||||
@@ -174,62 +216,5 @@ TMP_UPSTREAM_CSS="$(mktemp)"
|
||||
trap 'rm -f "$TMP_UPSTREAM_CSS"' EXIT
|
||||
assert_no_unimported_styles "$SOURCE_CSS" "$STYLEGUIDE_REPO_ROOT"
|
||||
flatten_css "$SOURCE_CSS" "$STYLEGUIDE_REPO_ROOT" "$TMP_UPSTREAM_CSS"
|
||||
transform_portal_css "$TMP_UPSTREAM_CSS" "$PORTAL_CSS_PATH"
|
||||
|
||||
rsync -a --delete \
|
||||
--exclude ".git/" \
|
||||
--exclude ".codex/" \
|
||||
--exclude ".DS_Store" \
|
||||
--exclude "AGENTS.md" \
|
||||
"$STYLEGUIDE_REPO_ROOT/" \
|
||||
"$PORTAL_STYLEGUIDE_DOCS_PATH/"
|
||||
|
||||
STYLEGUIDE_VERSION="$(tr -d '[:space:]' < "$VERSION_FILE")"
|
||||
STYLEGUIDE_COMMIT="$(git -C "$STYLEGUIDE_REPO_ROOT" rev-parse --short HEAD)"
|
||||
SYNCED_AT="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
||||
|
||||
cat > "$PORTAL_META_PATH" <<META
|
||||
{
|
||||
"styleguideVersion": "$STYLEGUIDE_VERSION",
|
||||
"styleguideCommit": "$STYLEGUIDE_COMMIT",
|
||||
"syncedAtUtc": "$SYNCED_AT",
|
||||
"sourceRepo": "$STYLEGUIDE_REPO_ROOT",
|
||||
"mirroredDocsPath": "$PORTAL_STYLEGUIDE_DOCS_REL"
|
||||
}
|
||||
META
|
||||
|
||||
case "$PORTAL_KEY" in
|
||||
vsf)
|
||||
PORTAL_BUILD_SCRIPT_PATH="$PORTAL_REPO_PATH/$PORTAL_BUILD_SCRIPT_REL"
|
||||
if [[ ! -f "$PORTAL_BUILD_SCRIPT_PATH" ]]; then
|
||||
echo "Portal build script not found: $PORTAL_BUILD_SCRIPT_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
bash "$PORTAL_BUILD_SCRIPT_PATH"
|
||||
;;
|
||||
naurua)
|
||||
cp "$PORTAL_CSS_PATH" "$PORTAL_BUILT_CSS_PATH"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$COMMIT_IN_PORTAL" == "true" ]]; then
|
||||
git -C "$PORTAL_REPO_PATH" add -A \
|
||||
"$PORTAL_CSS_REL" \
|
||||
"$PORTAL_BUILT_CSS_REL" \
|
||||
"$PORTAL_META_REL" \
|
||||
"$PORTAL_STYLEGUIDE_DOCS_REL"
|
||||
if ! git -C "$PORTAL_REPO_PATH" diff --cached --quiet; then
|
||||
git -C "$PORTAL_REPO_PATH" commit -m "Sync styleguide $STYLEGUIDE_VERSION"
|
||||
git -C "$PORTAL_REPO_PATH" push
|
||||
echo "Portal repo synced and pushed."
|
||||
else
|
||||
echo "No changes to commit in portal repo."
|
||||
fi
|
||||
else
|
||||
echo "Portal files updated locally (no commit requested)."
|
||||
fi
|
||||
|
||||
echo "Synced $SOURCE_CSS -> $PORTAL_CSS_PATH"
|
||||
echo "Built portal stylesheet: $PORTAL_BUILT_CSS_PATH"
|
||||
echo "Metadata written: $PORTAL_META_PATH"
|
||||
echo "Mirrored styleguide docs: $PORTAL_STYLEGUIDE_DOCS_PATH"
|
||||
sync_portal "vsf" "/Users/mathias/Documents/Dokumente Chouchou/Codebases/WebApp_Aktienberater"
|
||||
sync_portal "naurua" "/Users/mathias/Documents/Dokumente Chouchou/Codebases/erp_naurua"
|
||||
|
||||
Reference in New Issue
Block a user