2024-10-23 00:07:49 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
2024-10-23 00:16:25 +00:00
|
|
|
temp_env=$(declare -p -x)
|
2024-10-23 00:13:36 +00:00
|
|
|
|
2025-05-12 15:27:07 +00:00
|
|
|
if [ -f .env.template ]; then
|
|
|
|
|
source .env.template
|
2024-10-23 00:07:49 +00:00
|
|
|
fi
|
2026-03-03 19:52:22 +00:00
|
|
|
if [ -f .env ]; then
|
|
|
|
|
source .env
|
|
|
|
|
fi
|
2024-10-23 00:07:49 +00:00
|
|
|
|
2024-10-23 00:13:36 +00:00
|
|
|
# Avoid overwriting env vars provided directly
|
|
|
|
|
# https://stackoverflow.com/a/69127685/1467342
|
|
|
|
|
eval "$temp_env"
|
|
|
|
|
|
2025-01-28 22:51:33 +00:00
|
|
|
if [[ -z $VITE_BUILD_HASH ]]; then
|
|
|
|
|
export VITE_BUILD_HASH=$(git rev-parse --short HEAD)
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-03 19:52:22 +00:00
|
|
|
if [[ $VITE_PLATFORM_LOGO =~ ^https:// ]]; then
|
|
|
|
|
curl -fSL "$VITE_PLATFORM_LOGO" -o static/logo.png
|
2024-10-23 00:07:49 +00:00
|
|
|
export VITE_PLATFORM_LOGO=static/logo.png
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-03 19:52:22 +00:00
|
|
|
# Ensure generator uses local path (dotenv may have loaded URL from .env)
|
|
|
|
|
VITE_PLATFORM_LOGO="${VITE_PLATFORM_LOGO}" npx pwa-assets-generator
|
2024-10-23 00:07:49 +00:00
|
|
|
npx vite build
|
2024-10-23 15:55:40 +00:00
|
|
|
|
|
|
|
|
# Replace index.html variables with stuff from our env
|
|
|
|
|
perl -i -pe"s|{DESCRIPTION}|$VITE_PLATFORM_DESCRIPTION|g" build/index.html
|
|
|
|
|
perl -i -pe"s|{ACCENT}|$VITE_PLATFORM_ACCENT|g" build/index.html
|
|
|
|
|
perl -i -pe"s|{NAME}|$VITE_PLATFORM_NAME|g" build/index.html
|
|
|
|
|
perl -i -pe"s|{URL}|$VITE_PLATFORM_URL|g" build/index.html
|
2025-01-17 16:43:56 +00:00
|
|
|
|
|
|
|
|
npx cap sync
|
|
|
|
|
npx @capacitor/assets generate \
|
|
|
|
|
--iconBackgroundColor '#eeeeee' \
|
|
|
|
|
--iconBackgroundColorDark '#222222' \
|
|
|
|
|
--splashBackgroundColor '#ffffff' \
|
|
|
|
|
--splashBackgroundColorDark '#191E24'
|