A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 18bc0b0c27e393fdc04b3a3d129d5ac0d837aa04 (4141 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"50
if [[ -d "$DIST_DIR" ]]; then51
section "CLEAN"52
rm -rf "$DIST_DIR"53
print "remove" "$DIST_DIR/"54
fi56
if [[ "$MODE" == "dev" ]]; then57
section "LINK"58
print "create" "$DIST_DIR/"59
mkdir -p "$DIST_DIR"60
print "link" "$DIST_DIR/app/"61
ln -sf "../app" "$DIST_DIR/app"62
print "link" "$DIST_DIR/www/"63
ln -sf "../www" "$DIST_DIR/www"64
fi65
if [[ "$MODE" == "prod" ]]; then66
section "COPY"67
print "create" "$DIST_DIR/"68
mkdir -p "$DIST_DIR"69
print "copy" "$DIST_DIR/app/"70
cp -rf app "$DIST_DIR/app"71
print "copy" "$DIST_DIR/www/"72
cp -rf www "$DIST_DIR/www"73
fi75
if [[ "$MODE" == "prod" ]]; then76
section "INJECT"78
sed -i -e "s/{{version}}/$VERSION/g" "$DIST_DIR/www/worker.js"79
print "inject" "$DIST_DIR/www/worker.js"80
sed -i -e "s/{{version}}/$VERSION/g" "$DIST_DIR/app/main.js"81
print "inject" "$DIST_DIR/app/main.js"82
fi84
LIB_DIR="$DIST_DIR/www/asset/lib"85
FONT_DIR="$DIST_DIR/www/asset/font"87
section "DEPS"89
print "create" "$LIB_DIR/"90
mkdir -p "$LIB_DIR"91
print "create" "$FONT_DIR/"92
mkdir -p "$FONT_DIR"94
TW_LOCAL="${config["--tw-local"]}"96
# tailwindcss97
if [[ "$TW_LOCAL" == "false" ]]; then98
print "download" "tailwindcss"99
curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 -o "$DIST_DIR/tailwindcss"100
chmod +x "$DIST_DIR/tailwindcss"101
fi103
# vue104
print "download" "vue"105
curl -sL https://cdn.jsdelivr.net/npm/vue@2/dist/vue.esm.browser.min.js -o "$LIB_DIR/vue.min.js"106
# curl -L https://unpkg.com/vue@latest/dist/vue.esm-browser.prod.js -o ./www/asset/lib/vue.min.js -s108
# tabler-icons109
print "download" "tabler-icons"110
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/tabler-icons.min.css -o "$LIB_DIR/tabler-icons.min.css"111
sed -i -e "s/fonts\/tabler-icons/..\/font\/tabler-icons/g" "$LIB_DIR/tabler-icons.min.css"112
print "download" "tabler-icons-font"113
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.eot -o "$FONT_DIR/tabler-icons.eot"114
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.ttf -o "$FONT_DIR/tabler-icons.ttf"115
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.woff -o "$FONT_DIR/tabler-icons.woff"116
curl -sL https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/fonts/tabler-icons.woff2 -o "$FONT_DIR/tabler-icons.woff2"118
# inter119
print "download" "inter-font"120
curl -sL https://fonts.google.com/download?family=Inter -o "$FONT_DIR/inter.zip"121
unzip -qq "$FONT_DIR/inter.zip" -d "$FONT_DIR/inter"122
mv "$FONT_DIR/inter/static/Inter-Regular.ttf" "$FONT_DIR/"123
mv "$FONT_DIR/inter/static/Inter-Medium.ttf" "$FONT_DIR/"124
mv "$FONT_DIR/inter/static/Inter-SemiBold.ttf" "$FONT_DIR/"125
rm -rf "$FONT_DIR/inter"126
rm -rf "$FONT_DIR/inter.zip"128
section "BUILD"130
TW_BIN="$DIST_DIR/tailwindcss"131
TW_WATCH="${config["--tw-watch"]}"133
if [[ "$TW_LOCAL" == "true" ]]; then134
TW_BIN="tailwindcss"135
fi137
if [[ "$TW_WATCH" == "true" ]]; then138
print "watch" "tailwindcss"139
WATCH_FLAG="--watch"140
else141
print "build" "tailwindcss"142
fi144
"$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"146
STATUS="$?"148
section150
if [[ "$STATUS" != "0" ]]; then151
print "status" "failed"152
echo ""153
exit 1154
fi156
print "status" "success"157
echo ""