Files
zeekay e05ad497c1 fix(brand): select-brand lists the brands it can actually select
It enumerated asset directories, so it offered brands with no env file
and stopped after the first one under set -e. It reads the env files it
needs instead.
2026-08-13 13:25:42 -07:00

47 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# select-brand.sh — switch the active brand for a local build.
#
# Usage: scripts/select-brand.sh <slug> (any apps/web/.env.<slug>)
#
# Copies apps/web/.env.<slug> -> apps/web/.env.local (overridden each run).
#
# Nothing else is baked in: name, logo, icons and manifest are served from
# apps/web/public/brand/<slug>/ and picked by request host at runtime.
#
# After this runs, `yarn workspace @safe-global/web build` produces the branded build.
set -euo pipefail
slug="${1:-}"
if [[ -z "$slug" ]]; then
echo "usage: scripts/select-brand.sh <slug>"
echo "available brands:"
for f in apps/web/.env.*; do
name="${f##*/.env.}"
if [[ "$name" != "example" && "$name" != "local" ]]; then
echo " - $name"
fi
done
exit 1
fi
repo_root="$(cd "$(dirname "$0")/.." && pwd)"
env_file="$repo_root/apps/web/.env.$slug"
brand_dir="$repo_root/apps/web/public/brand/$slug"
if [[ ! -f "$env_file" ]]; then
echo "error: $env_file not found"
exit 2
fi
if [[ ! -d "$brand_dir" ]]; then
echo "error: $brand_dir not found"
exit 2
fi
cp "$env_file" "$repo_root/apps/web/.env.local"
echo "brand '$slug' selected"
echo " env -> apps/web/.env.local"
echo " assets -> apps/web/public/brand/$slug/ (served as-is, resolved by host)"