-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·61 lines (42 loc) · 1.51 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
set -e
if [ $# -ne 1 ] ; then
echo "Please specify the theme vendor as the first and only argument!" >&2
exit 5
fi
crit () {
echo "$1" >&2
exit "${2:-1}"
}
STATIC_DIR="./pub/static/frontend"
THEME_VENDOR="$1"
THEME_DIR="${STATIC_DIR}/${THEME_VENDOR}"
BUILD_FILE="./build.js"
MAGEPACK="magepack"
echo "[INFO] Using theme vendor '$THEME_VENDOR'"
which "$MAGEPACK" 2>&1 > /dev/null || crit "[CRITICAL] No magepack binary '$MAGEPACK' found" 10
[ ! -f "$BUILD_FILE" ] && crit "[CRITICAL] No '$BUILD_FILE' file found in current directory" 20
[ ! -d "$STATIC_DIR" ] && crit "[CRITICAL] No base magento frontend assets dir '$STATIC_DIR' found - did you already build the themes?" 21
[ ! -d "$THEME_DIR" ] && crit "[CRITICAL] No vendor frontend assets dir '$THEME_DIR' found - did you already build the themes?" 22
pack_theme_lang () {
THEME="$1"
LANG="$2"
TARGET_DIR="$THEME_DIR/$THEME/$LANG"
echo -e "\n[INFO] Packing theme '$THEME' language '$LANG' in '$TARGET_DIR'..."
magepack --bundle --config "$BUILD_FILE" --dir "$TARGET_DIR"
}
list_themes () {
(cd "$THEME_DIR"; ls -1da *)
}
list_theme_langs () {
THEME_NAME="$1"
(cd "${THEME_DIR}/${THEME_NAME}"; ls -1da *)
}
list_themes | while read THEME_NAME ; do
echo " * Theme '$THEME_NAME'"
list_theme_langs "$THEME_NAME" | while read THEME_LANG ; do
echo -e " - Language '$THEME_LANG'"
pack_theme_lang "$THEME_NAME" "$THEME_LANG"
done
done
echo "All themes have been processed successfully"