forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_mobile_build_config.sh
More file actions
executable file
·73 lines (65 loc) · 1.62 KB
/
Copy pathvalidate_mobile_build_config.sh
File metadata and controls
executable file
·73 lines (65 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
set -euo pipefail
usage() {
echo "usage: $0 --flavor <dev|prod> [--profile <profile>] [--env-file <path>]" >&2
}
flavor=''
profile=''
env_file=''
while (($#)); do
case "$1" in
--flavor)
[[ $# -ge 2 ]] || { usage; exit 2; }
flavor="$2"
shift 2
;;
--profile)
[[ $# -ge 2 ]] || { usage; exit 2; }
profile="$2"
shift 2
;;
--env-file)
[[ $# -ge 2 ]] || { usage; exit 2; }
env_file="$2"
shift 2
;;
*)
usage
exit 2
;;
esac
done
case "$flavor" in
dev)
expected_profile='local_dev'
default_env_file='.dev.env'
;;
prod)
expected_profile='mobile_beta'
default_env_file='.env'
;;
*)
echo "ERROR: unsupported mobile flavor '${flavor:-<missing>}' (expected dev or prod)." >&2
exit 1
;;
esac
if [[ -n "$profile" && "$profile" != "$expected_profile" ]]; then
echo "ERROR: mobile flavor '$flavor' requires OMI_APP_PROFILE=$expected_profile, got '$profile'." >&2
exit 1
fi
env_file="${env_file:-$default_env_file}"
if [[ ! -f "$env_file" ]]; then
echo "ERROR: missing $env_file; run setup_app_env $expected_profile before building." >&2
exit 1
fi
read_setting() {
local key="$1"
awk -F= -v key="$key" '$1 == key { value = $2 } END { print value }' "$env_file"
}
for key in USE_WEB_AUTH USE_AUTH_CUSTOM_TOKEN; do
if [[ "$(read_setting "$key")" != 'true' ]]; then
echo "ERROR: $env_file must contain $key=true for the supported $flavor/$expected_profile mobile build." >&2
exit 1
fi
done
echo "mobile build config valid: flavor=$flavor profile=$expected_profile env=$env_file"