A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: e8cee5acf5283f324b26050ce6525e31493e4e3d (4157 bytes)[doc][blame][raw]
1
#!/bin/bash3
declare -A config4
config=(5
["mode"]="dev"6
["twc-local"]=false7
["twc-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
config["$key"]=$value17
done <<< $(echo "$@" | tr " " "\n")19
print() {20
printf "%-8s %s\n" $1 $221
}23
section() {24
echo ""25
printf "%2s%-48s" "" $1 | tr ' ' '-'26
printf "\n"27
}29
MODE="${config["mode"]}"31
if [[ "$MODE" != "dev" ]] && [[ "$MODE" != "prod" ]]; then32
echo "[ERROR] invalid mode '$MODE'!"33
exit 134
fi36
section "INFO"37
print "mode" $MODE39
if [[ -z "$VERSION" ]]; then40
VERSION=$(git log --format="%h" -n 1)41
fi43
print "version" $VERSION45
DIST_DIR="dist"47
if [[ -d "$DIST_DIR" ]]; then48
section "CLEAN"49
rm -rf "$DIST_DIR"50
print "remove" "$DIST_DIR/"51
fi53
if [[ "$MODE" == "dev" ]]; then54
section "LINK"55
print "create" "$DIST_DIR/"56
mkdir -p "$DIST_DIR"57
print "link" "$DIST_DIR/app/"58
ln -sf "../app" "$DIST_DIR/app"59
print "link" "$DIST_DIR/www/"60
ln -sf "../www" "$DIST_DIR/www"61
fi62
if [[ "$MODE" == "prod" ]]; then63
section "COPY"64
print "create" "$DIST_DIR/"65
mkdir -p "$DIST_DIR"66
print "copy" "$DIST_DIR/app/"67
cp -rf app "$DIST_DIR/app"68
print "copy" "$DIST_DIR/www/"69
cp -rf www "$DIST_DIR/www"70
fi72
if [[ "$MODE" == "prod" ]]; then73
section "INJECT"75
sed -i -e "s/{{version}}/$VERSION/g" "$DIST_DIR/www/worker.js"76
print "inject" "$DIST_DIR/www/worker.js"77
sed -i -e "s/{{version}}/$VERSION/g" "$DIST_DIR/app/main.js"78
print "inject" "$DIST_DIR/app/main.js"79
fi81
LIB_DIR="$DIST_DIR/www/asset/lib"82
FONT_DIR="$DIST_DIR/www/asset/font"84
section "DEPS"86
print "create" "$LIB_DIR/"87
mkdir -p "$LIB_DIR"88
print "create" "$FONT_DIR/"89
mkdir -p "$FONT_DIR"91
TWC_LOCAL="${config["twc-local"]}"93
# tailwindcss94
if [[ "$TWC_LOCAL" == "false" ]]; then95
print "download" "tailwindcss"96
curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 -o "$DIST_DIR/tailwindcss"97
chmod +x "$DIST_DIR/tailwindcss"98
fi100
# vue101
print "download" "vue"102
curl -sL https://cdn.jsdelivr.net/npm/vue@2/dist/vue.esm.browser.min.js -o "$LIB_DIR/vue.min.js"103
# curl -L https://unpkg.com/vue@latest/dist/vue.esm-browser.prod.js -o ./www/asset/lib/vue.min.js -s105
# tabler-icons106
print "download" "tabler-icons"107
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/tabler-icons.min.css -o "$LIB_DIR/tabler-icons.min.css"108
sed -i -e "s/fonts\/tabler-icons/..\/font\/tabler-icons/g" "$LIB_DIR/tabler-icons.min.css"109
print "download" "tabler-icons-font"110
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.eot -o "$FONT_DIR/tabler-icons.eot"111
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.ttf -o "$FONT_DIR/tabler-icons.ttf"112
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.woff -o "$FONT_DIR/tabler-icons.woff"113
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.woff2 -o "$FONT_DIR/tabler-icons.woff2"115
# inter116
print "download" "inter-font"117
curl -sL https://fonts.google.com/download?family=Inter -o "$FONT_DIR/inter.zip"118
unzip -qq "$FONT_DIR/inter.zip" -d "$FONT_DIR/inter"119
mv "$FONT_DIR/inter/static/Inter-Regular.ttf" "$FONT_DIR/"120
mv "$FONT_DIR/inter/static/Inter-Medium.ttf" "$FONT_DIR/"121
mv "$FONT_DIR/inter/static/Inter-SemiBold.ttf" "$FONT_DIR/"122
rm -rf "$FONT_DIR/inter"123
rm -rf "$FONT_DIR/inter.zip"125
section "BUILD"127
TWC_BIN="$DIST_DIR/tailwindcss"128
TWC_WATCH="${config["twc-watch"]}"130
if [[ "$TWC_LOCAL" == "true" ]] || [[ "$TWC_LOCAL" == "twc-local" ]]; then131
TWC_BIN="tailwindcss"132
fi134
if [[ "$TWC_WATCH" == "true" ]] || [[ "$TWC_WATCH" == "twc-watch" ]]; then135
print "watch" "tailwindcss"136
WATCH_FLAG="--watch"137
else138
print "build" "tailwindcss"139
fi141
"$TWC_BIN" -c tailwind.config.js -i "$DIST_DIR/www/asset/css/input.css" -o "$DIST_DIR/www/asset/css/output.css" --minify "$WATCH_FLAG"143
STATUS="$?"145
section147
if [[ "$STATUS" != "0" ]]; then148
print "status" "failed"149
echo ""150
exit 1151
fi153
print "status" "success"154
echo ""