A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: d98c82ed1bcaf19183257694ad8683d9f672e86f (4227 bytes)[doc][blame][raw]
1
#!/bin/bash3
declare -A config4
config=(5
["--mode"]="dev"6
["--tw-local"]=false7
["--tw-watch"]=false8
)10
while read argument; do11
key=$(echo "$argument" | awk '{split($0, a, "="); print a[1]}')12
if [ -z "$key" ]; then13
continue14
fi15
value=$(echo "$argument" | awk '{st = index($0, "="); print substr($0, st + 1)}')16
if [[ "$value" == "$key" ]]; then17
value="true"18
fi19
config["$key"]=$value20
done <<< $(echo "$@" | tr " " "\n")22
print() {23
printf "%-8s %s\n" $1 $224
}26
section() {27
echo ""28
printf "%2s%-48s" "" $1 | tr ' ' '-'29
printf "\n"30
}32
MODE="${config["--mode"]}"34
if [[ "$MODE" != "dev" ]] && [[ "$MODE" != "prod" ]]; then35
echo "[ERROR] invalid mode '$MODE'!"36
exit 137
fi39
section "INFO"40
print "mode" $MODE42
if [[ -z "$VERSION" ]]; then43
VERSION=$(git log --format="%h" -n 1)44
fi46
print "version" $VERSION48
DIST_DIR="dist"49
MEDIA_DIR="media"51
if [[ -d "$DIST_DIR" ]]; then52
section "CLEAN"53
rm -rf "$DIST_DIR"54
print "remove" "$DIST_DIR/"55
fi57
section "MEDIA"58
mkdir -p "$MEDIA_DIR"59
print "create" "$MEDIA_DIR/"61
if [[ "$MODE" == "dev" ]]; then62
section "LINK"63
print "create" "$DIST_DIR/"64
mkdir -p "$DIST_DIR"65
print "link" "$DIST_DIR/app/"66
ln -sf "../app" "$DIST_DIR/app"67
print "link" "$DIST_DIR/www/"68
ln -sf "../www" "$DIST_DIR/www"69
fi70
if [[ "$MODE" == "prod" ]]; then71
section "COPY"72
print "create" "$DIST_DIR/"73
mkdir -p "$DIST_DIR"74
print "copy" "$DIST_DIR/app/"75
cp -rf app "$DIST_DIR/app"76
print "copy" "$DIST_DIR/www/"77
cp -rf www "$DIST_DIR/www"78
fi80
if [[ "$MODE" == "prod" ]]; then81
section "INJECT"83
sed -i -e "s/{{version}}/$VERSION/g" "$DIST_DIR/www/worker.js"84
print "inject" "$DIST_DIR/www/worker.js"85
sed -i -e "s/{{version}}/$VERSION/g" "$DIST_DIR/app/main.js"86
print "inject" "$DIST_DIR/app/main.js"87
fi89
LIB_DIR="$DIST_DIR/www/asset/lib"90
FONT_DIR="$DIST_DIR/www/asset/font"92
section "DEPS"94
print "create" "$LIB_DIR/"95
mkdir -p "$LIB_DIR"96
print "create" "$FONT_DIR/"97
mkdir -p "$FONT_DIR"99
TW_LOCAL="${config["--tw-local"]}"101
# tailwindcss102
if [[ "$TW_LOCAL" == "false" ]]; then103
print "download" "tailwindcss"104
curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 -o "$DIST_DIR/tailwindcss"105
chmod +x "$DIST_DIR/tailwindcss"106
fi108
# vue109
print "download" "vue"110
curl -sL https://cdn.jsdelivr.net/npm/vue@2/dist/vue.esm.browser.min.js -o "$LIB_DIR/vue.min.js"111
# curl -L https://unpkg.com/vue@latest/dist/vue.esm-browser.prod.js -o ./www/asset/lib/vue.min.js -s113
# tabler-icons114
print "download" "tabler-icons"115
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/tabler-icons.min.css -o "$LIB_DIR/tabler-icons.min.css"116
sed -i -e "s/fonts\/tabler-icons/..\/font\/tabler-icons/g" "$LIB_DIR/tabler-icons.min.css"117
print "download" "tabler-icons-font"118
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.eot -o "$FONT_DIR/tabler-icons.eot"119
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.ttf -o "$FONT_DIR/tabler-icons.ttf"120
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.woff -o "$FONT_DIR/tabler-icons.woff"121
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.woff2 -o "$FONT_DIR/tabler-icons.woff2"123
# inter124
print "download" "inter-font"125
curl -sL https://fonts.google.com/download?family=Inter -o "$FONT_DIR/inter.zip"126
unzip -qq "$FONT_DIR/inter.zip" -d "$FONT_DIR/inter"127
mv "$FONT_DIR/inter/static/Inter-Regular.ttf" "$FONT_DIR/"128
mv "$FONT_DIR/inter/static/Inter-Medium.ttf" "$FONT_DIR/"129
mv "$FONT_DIR/inter/static/Inter-SemiBold.ttf" "$FONT_DIR/"130
rm -rf "$FONT_DIR/inter"131
rm -rf "$FONT_DIR/inter.zip"133
section "BUILD"135
TW_BIN="$DIST_DIR/tailwindcss"136
TW_WATCH="${config["--tw-watch"]}"138
if [[ "$TW_LOCAL" == "true" ]]; then139
TW_BIN="tailwindcss"140
fi142
if [[ "$TW_WATCH" == "true" ]]; then143
print "watch" "tailwindcss"144
WATCH_FLAG="--watch"145
else146
print "build" "tailwindcss"147
fi149
"$TW_BIN" -c tailwind.config.js -i "$DIST_DIR/www/asset/css/input.css" -o "$DIST_DIR/www/asset/css/output.css" --minify "$WATCH_FLAG"151
STATUS="$?"153
section155
if [[ "$STATUS" != "0" ]]; then156
print "status" "failed"157
echo ""158
exit 1159
fi161
print "status" "success"162
echo ""