-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.config.ts
More file actions
193 lines (174 loc) · 7.09 KB
/
app.config.ts
File metadata and controls
193 lines (174 loc) · 7.09 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import { ExpoConfig, ConfigContext } from '@expo/config'
import * as dotenv from 'dotenv'
dotenv.config()
// https://patorjk.com/software/taag/#p=display&h=0&v=0&c=c&f=ANSI%20Regular&t=CONFIG
/***
* ██████ ██████ ███ ██ ███████ ██ ██████
* ██ ██ ██ ████ ██ ██ ██ ██
* ██ ██ ██ ██ ██ ██ █████ ██ ██ ███
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██████ ██████ ██ ████ ██ ██ ██████
*
*/
// CONFIG: You can change the values below to adjust app
// You can also run `yarn bootstrap` script to make this steps more safety
// APP_CONFIG_START
export const APP_CONFIG = {
androidPackageName: 'com.binarapps.baca', // CONFIG: Add your android package name here
appName: 'BACA', // CONFIG: Add your app name here
easProjectId: 'ac562c27-4a4e-4532-869f-fe6f9447bee6', // CONFIG: Add your eas project ID here
iosBundleIdentifier: 'com.binarapps.baca', // CONFIG: Add your ios bundle identifier here
scheme: 'baca', // CONFIG: Add your url scheme to link to your app
adaptiveIconBackgroundColor: '#2E7AF0CC', // CONFIG: Add your android adaptive icon background color here
} as const
// APP_CONFIG_END
const universalLinks = ['https://baca-six.vercel.app', 'https://baca.binar.app']
/***
* ██████ ██ ██ ███ ██ █████ ███ ███ ██ ██████
* ██ ██ ██ ██ ████ ██ ██ ██ ████ ████ ██ ██
* ██ ██ ████ ██ ██ ██ ███████ ██ ████ ██ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██████ ██ ██ ████ ██ ██ ██ ██ ██ ██████
*
*
* ██████ ██████ ███ ██ ███████ ██ ██████
* ██ ██ ██ ████ ██ ██ ██ ██
* ██ ██ ██ ██ ██ ██ █████ ██ ██ ███
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██████ ██████ ██ ████ ██ ██ ██████
*
*/
// Please make sure you know what are you doing when you make some changes on the bottom
const environments = {
prod: 'production',
stg: 'staging',
qa: 'qa',
} as const
export const envValues = Object.values(environments)
export type Environments = (typeof envValues)[number]
const adaptiveIconPath = './assets/icons/android/adaptive-icon-'
const appIconPath = './assets/icons/ios/icon-'
const faviconPath = './assets/icons/web/favicon-'
const IS_DEV = process.env.IS_DEV === '1'
const runtimeVersion = { policy: IS_DEV ? 'sdkVersion' : 'appVersion' } as const
type Setup = { [key in Environments]: string }
export const EAS_ENV_CONFIG: { [key: string]: Setup } = {
adaptiveIconBackgroundColor: {
production: APP_CONFIG.adaptiveIconBackgroundColor,
staging: '#0064FF', // TODO: Randomize APP_CONFIG.adaptiveIconBackgroundColor
qa: '#041939', // TODO: Randomize APP_CONFIG.adaptiveIconBackgroundColor
},
adaptiveIcon: {
production: `${adaptiveIconPath}production.png`,
staging: `${adaptiveIconPath}staging.png`,
qa: `${adaptiveIconPath}qa.png`,
},
androidPackageName: {
production: `${APP_CONFIG.androidPackageName}`,
staging: `${APP_CONFIG.androidPackageName}.staging`,
qa: `${APP_CONFIG.androidPackageName}.qa`,
},
appIcon: {
production: `${appIconPath}production.png`,
staging: `${appIconPath}staging.png`,
qa: `${appIconPath}qa.png`,
},
appName: {
production: `${APP_CONFIG.appName}`,
staging: `${APP_CONFIG.appName} (staging)`,
qa: `${APP_CONFIG.appName} (qa)`,
},
favicon: {
production: `${faviconPath}production.png`,
staging: `${faviconPath}staging.png`,
qa: `${faviconPath}qa.png`,
},
iosBundleIdentifier: {
production: `${APP_CONFIG.iosBundleIdentifier}`,
staging: `${APP_CONFIG.iosBundleIdentifier}.staging`,
qa: `${APP_CONFIG.iosBundleIdentifier}.qa`,
},
scheme: {
production: `${APP_CONFIG.scheme}`,
staging: `${APP_CONFIG.scheme}-stg`,
qa: `${APP_CONFIG.scheme}-qa`,
},
} as const
const associatedDomains = universalLinks.map((link) => link.replace('https://', 'applinks:')) || []
const intentFilters =
universalLinks.map((link) => ({
action: 'VIEW',
autoVerify: true,
data: [''].map(() => ({
scheme: 'https',
host: link.replace('https://', ''),
})),
category: ['BROWSABLE', 'DEFAULT'],
})) || []
export default ({ config }: ConfigContext): Partial<ExpoConfig> => {
const ENVIRONMENT_NAME = (process.env.ENVIRONMENT_NAME || 'qa') as Environments
if (!envValues.includes(ENVIRONMENT_NAME)) {
throw Error(`${ENVIRONMENT_NAME} setup missing`)
}
const {
KEYSTORE_KEY_ALIAS = '',
KEYSTORE_KEY_PASSWORD = '',
KEYSTORE_STORE_PASSWORD = '',
...environmentVariables
} = process.env || {}
// This is used to make usable keystore file in debug
// It's usefull because thanks to that you can test in prebuilded app native functionalities like:
// - push notifications
// - maps
// - google / facebook sign in
// - deeplinks
const shouldAddKeystorePlugin =
IS_DEV && KEYSTORE_STORE_PASSWORD && KEYSTORE_KEY_ALIAS && KEYSTORE_KEY_PASSWORD
const keystorePlugin: Partial<ExpoConfig>['plugins'] = shouldAddKeystorePlugin
? [
[
'./plugins/withDebugKeystore',
{
storePassword: KEYSTORE_STORE_PASSWORD,
keyAlias: KEYSTORE_KEY_ALIAS,
keyPassword: KEYSTORE_KEY_PASSWORD,
},
],
]
: []
const plugins = [...(config?.plugins ?? []), ...keystorePlugin]
return {
...config,
android: {
...config.android,
adaptiveIcon: {
backgroundColor: EAS_ENV_CONFIG.adaptiveIconBackgroundColor[ENVIRONMENT_NAME],
foregroundImage: EAS_ENV_CONFIG.adaptiveIcon[ENVIRONMENT_NAME],
},
package: EAS_ENV_CONFIG.androidPackageName[ENVIRONMENT_NAME],
intentFilters,
},
extra: {
eas: { projectId: APP_CONFIG.easProjectId },
ENVIRONMENT_NAME,
universalLinks,
...(environmentVariables || {}),
},
icon: EAS_ENV_CONFIG.appIcon[ENVIRONMENT_NAME],
ios: {
...config.ios,
associatedDomains,
bundleIdentifier: EAS_ENV_CONFIG.iosBundleIdentifier[ENVIRONMENT_NAME],
},
name: EAS_ENV_CONFIG.appName[ENVIRONMENT_NAME],
owner: config.owner || 'binarapps',
runtimeVersion,
plugins,
scheme: EAS_ENV_CONFIG.scheme[ENVIRONMENT_NAME],
updates: { url: `https://u.expo.dev/${APP_CONFIG.easProjectId}` },
web: {
...config.web,
favicon: EAS_ENV_CONFIG.favicon[ENVIRONMENT_NAME],
},
}
}