Support Naurua styleguide export
This commit is contained in:
@@ -6,7 +6,8 @@ STYLEGUIDE_REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|||||||
SOURCE_CSS="$STYLEGUIDE_REPO_ROOT/styleguide.css"
|
SOURCE_CSS="$STYLEGUIDE_REPO_ROOT/styleguide.css"
|
||||||
VERSION_FILE="$STYLEGUIDE_REPO_ROOT/VERSION"
|
VERSION_FILE="$STYLEGUIDE_REPO_ROOT/VERSION"
|
||||||
|
|
||||||
PORTAL_REPO_PATH="/Users/mathias/Documents/Dokumente Chouchou/Codebases/WebApp_Aktienberater"
|
PORTAL_KEY="vsf"
|
||||||
|
PORTAL_REPO_PATH=""
|
||||||
PORTAL_CSS_REL="public/assets/styleguide.upstream.css"
|
PORTAL_CSS_REL="public/assets/styleguide.upstream.css"
|
||||||
PORTAL_BUILT_CSS_REL="public/assets/styles.css"
|
PORTAL_BUILT_CSS_REL="public/assets/styles.css"
|
||||||
PORTAL_META_REL="public/assets/styleguide.upstream.meta.json"
|
PORTAL_META_REL="public/assets/styleguide.upstream.meta.json"
|
||||||
@@ -17,9 +18,10 @@ COMMIT_IN_PORTAL="false"
|
|||||||
usage() {
|
usage() {
|
||||||
cat <<USAGE
|
cat <<USAGE
|
||||||
Usage:
|
Usage:
|
||||||
$(basename "$0") [--portal-repo <path>] [--commit-portal]
|
$(basename "$0") [--portal <vsf|naurua>] [--portal-repo <path>] [--commit-portal]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
--portal <name> Portal target. Defaults to vsf.
|
||||||
--portal-repo <path> Optional override for portal repository root.
|
--portal-repo <path> Optional override for portal repository root.
|
||||||
--commit-portal Create commit in portal repo after sync.
|
--commit-portal Create commit in portal repo after sync.
|
||||||
-h, --help Show this help.
|
-h, --help Show this help.
|
||||||
@@ -28,6 +30,10 @@ USAGE
|
|||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
--portal)
|
||||||
|
PORTAL_KEY="${2:-}"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
--portal-repo)
|
--portal-repo)
|
||||||
PORTAL_REPO_PATH="${2:-}"
|
PORTAL_REPO_PATH="${2:-}"
|
||||||
shift 2
|
shift 2
|
||||||
@@ -48,6 +54,24 @@ while [[ $# -gt 0 ]]; do
|
|||||||
esac
|
esac
|
||||||
done
|
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
|
if [[ ! -f "$SOURCE_CSS" ]]; then
|
||||||
echo "Source CSS not found: $SOURCE_CSS" >&2
|
echo "Source CSS not found: $SOURCE_CSS" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -94,6 +118,31 @@ flatten_css() {
|
|||||||
done < "$source_file"
|
done < "$source_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transform_portal_css() {
|
||||||
|
local source_file="$1"
|
||||||
|
local output_file="$2"
|
||||||
|
|
||||||
|
case "$PORTAL_KEY" in
|
||||||
|
vsf)
|
||||||
|
awk '
|
||||||
|
BEGIN { skip=0 }
|
||||||
|
/^:root\[data-portal="naurua"\] \{/ { skip=1; next }
|
||||||
|
skip && /^}/ { skip=0; next }
|
||||||
|
skip { next }
|
||||||
|
{ print }
|
||||||
|
' "$source_file" > "$output_file"
|
||||||
|
;;
|
||||||
|
naurua)
|
||||||
|
awk '
|
||||||
|
BEGIN { in_override=0 }
|
||||||
|
/^:root\[data-portal="naurua"\] \{/ { print ":root {"; in_override=1; next }
|
||||||
|
in_override && /^}/ { print "}"; in_override=0; next }
|
||||||
|
{ print }
|
||||||
|
' "$source_file" > "$output_file"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
assert_no_unimported_styles() {
|
assert_no_unimported_styles() {
|
||||||
local source_file="$1"
|
local source_file="$1"
|
||||||
local source_root="$2"
|
local source_root="$2"
|
||||||
@@ -125,7 +174,7 @@ TMP_UPSTREAM_CSS="$(mktemp)"
|
|||||||
trap 'rm -f "$TMP_UPSTREAM_CSS"' EXIT
|
trap 'rm -f "$TMP_UPSTREAM_CSS"' EXIT
|
||||||
assert_no_unimported_styles "$SOURCE_CSS" "$STYLEGUIDE_REPO_ROOT"
|
assert_no_unimported_styles "$SOURCE_CSS" "$STYLEGUIDE_REPO_ROOT"
|
||||||
flatten_css "$SOURCE_CSS" "$STYLEGUIDE_REPO_ROOT" "$TMP_UPSTREAM_CSS"
|
flatten_css "$SOURCE_CSS" "$STYLEGUIDE_REPO_ROOT" "$TMP_UPSTREAM_CSS"
|
||||||
cp "$TMP_UPSTREAM_CSS" "$PORTAL_CSS_PATH"
|
transform_portal_css "$TMP_UPSTREAM_CSS" "$PORTAL_CSS_PATH"
|
||||||
|
|
||||||
rsync -a --delete \
|
rsync -a --delete \
|
||||||
--exclude ".git/" \
|
--exclude ".git/" \
|
||||||
@@ -149,12 +198,19 @@ cat > "$PORTAL_META_PATH" <<META
|
|||||||
}
|
}
|
||||||
META
|
META
|
||||||
|
|
||||||
if [[ ! -f "$PORTAL_BUILD_SCRIPT_PATH" ]]; then
|
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
|
echo "Portal build script not found: $PORTAL_BUILD_SCRIPT_PATH" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
bash "$PORTAL_BUILD_SCRIPT_PATH"
|
||||||
bash "$PORTAL_BUILD_SCRIPT_PATH"
|
;;
|
||||||
|
naurua)
|
||||||
|
cp "$PORTAL_CSS_PATH" "$PORTAL_BUILT_CSS_PATH"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if [[ "$COMMIT_IN_PORTAL" == "true" ]]; then
|
if [[ "$COMMIT_IN_PORTAL" == "true" ]]; then
|
||||||
git -C "$PORTAL_REPO_PATH" add -A \
|
git -C "$PORTAL_REPO_PATH" add -A \
|
||||||
|
|||||||
Reference in New Issue
Block a user