Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

app.config.ts

310 lines10.9 KB

1import type { ExpoConfig } from "expo/config";
2​
3import { loadRepoEnv } from "../../scripts/lib/public-config.ts";
4​
5type AppVariant = "development" | "preview" | "production";
6​
7const repoEnv = loadRepoEnv();
8Object.assign(process.env, repoEnv);
9​
10const APP_VARIANT = resolveAppVariant(repoEnv.APP_VARIANT);
11const isIosPersonalTeamBuild = repoEnv.T3CODE_IOS_PERSONAL_TEAM === "1";
12​
13const personalTeamBundleIdentifier = repoEnv.T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID?.trim();
14const IOS_BUNDLE_IDENTIFIER_PATTERN = /^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/;
15​
16if (
17 isIosPersonalTeamBuild &&
18 (!personalTeamBundleIdentifier ||
19 !IOS_BUNDLE_IDENTIFIER_PATTERN.test(personalTeamBundleIdentifier))
20) {
21 throw new Error(
22 "T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID must be a reverse-DNS identifier such as com.example.t3code when T3CODE_IOS_PERSONAL_TEAM=1.",
23 );
25​
26const DEVELOPMENT_ASSETS = {
27 appIcon: "./assets/splash-icon-dev.png",
28 iosIcon: "./assets/icon-composer-dev.icon",
29 splashIcon: "./assets/splash-icon-dev.png",
30 androidAdaptiveForeground: "./assets/android-icon-dev-foreground.png",
31 androidAdaptiveBackgroundColor: "#00639B",
32 androidMonochromeIcon: "./assets/android-icon-mark.png",
33 androidNotificationIcon: "./assets/android-notification-icon.png",
34 androidNotificationColor: "#00639B",
35} as const;
36​
37const RELEASE_ASSETS = {
38 appIcon: "./assets/splash-icon-prod.png",
39 iosIcon: "./assets/icon-composer-prod.icon",
40 splashIcon: "./assets/splash-icon-prod.png",
41 androidAdaptiveForeground: "./assets/android-icon-mark.png",
42 androidAdaptiveBackgroundColor: "#000000",
43 androidMonochromeIcon: "./assets/android-icon-mark.png",
44 androidNotificationIcon: "./assets/android-notification-icon.png",
45 androidNotificationColor: "#FFFFFF",
46} as const;
47​
48const VARIANT_CONFIG = {
49 development: {
50 appName: "T3 Code Dev",
51 scheme: "t3code-dev",
52 iosBundleIdentifier: "com.t3tools.t3code.dev",
53 androidPackage: "com.t3tools.t3code.dev",
54 relyingParty: "clerk.t3.codes",
55 assets: DEVELOPMENT_ASSETS,
56 },
57 preview: {
58 appName: "T3 Code Preview",
59 scheme: "t3code-preview",
60 iosBundleIdentifier: "com.t3tools.t3code.preview",
61 androidPackage: "com.t3tools.t3code.preview",
62 relyingParty: "clerk.t3.codes",
63 assets: RELEASE_ASSETS,
64 },
65 production: {
66 appName: "T3 Code",
67 scheme: "t3code",
68 iosBundleIdentifier: "com.t3tools.t3code",
69 androidPackage: "com.t3tools.t3code",
70 relyingParty: "clerk.t3.codes",
71 assets: RELEASE_ASSETS,
72 },
73} as const;
74​
75function resolveAppVariant(value: string | undefined): AppVariant {
76 switch (value) {
77 case "development":
78 case "preview":
79 case "production":
80 return value;
81 default:
82 return "production";
83 }
85​
86const variant = VARIANT_CONFIG[APP_VARIANT];
87​
88const dmSansFonts = {
89 regular: "@expo-google-fonts/dm-sans/400Regular/DMSans_400Regular.ttf",
90 medium: "@expo-google-fonts/dm-sans/500Medium/DMSans_500Medium.ttf",
91 bold: "@expo-google-fonts/dm-sans/700Bold/DMSans_700Bold.ttf",
92} as const;
93​
94const widgetsPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
95 "expo-widgets",
96 {
97 bundleIdentifier: `${variant.iosBundleIdentifier}.widgets`,
98 groupIdentifier: `group.${variant.iosBundleIdentifier}`,
99 enablePushNotifications: true,
100 // Agent activity can update many times an hour; without the
101 // frequent-updates entitlement iOS throttles the update budget sooner.
102 frequentUpdates: true,
103 widgets: [
104 {
105 name: "AgentActivity",
106 displayName: "Agent Activity",
107 description: "Shows the current state of active T3 Code agents.",
108 supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"],
109 },
110 ],
111 },
112];
113​
114// These aliases match the fonts' PostScript names on iOS. Register the same
115// names on Android so React Native and the native composer use one set of
116// family names without waiting for runtime font loading.
117​
118const config: ExpoConfig = {
119 name: variant.appName,
120 slug: "t3-code",
121 platforms: ["ios", "android"],
122 scheme: variant.scheme,
123 version: "0.1.0",
124 runtimeVersion: {
125 // Fingerprint (not appVersion) so an OTA only reaches binaries whose native
126 // project — native deps, config plugins, AND patches/ — matches the update.
127 // With appVersion, every 0.1.0 build shares a runtime version, so a JS update
128 // could land on a binary missing the native changes it needs and crash.
129 policy: process.env.MOBILE_VERSION_POLICY ?? "fingerprint",
130 },
131 orientation: "portrait",
132 icon: variant.assets.appIcon,
133 userInterfaceStyle: "automatic",
134 updates: {
135 enabled: true,
136 url: "https://u.expo.dev/d763fcb8-d37c-41ea-a773-b54a0ab4a454",
137 checkAutomatically: "ON_LOAD",
138 fallbackToCacheTimeout: 0,
139 },
140 ios: {
141 icon: variant.assets.iosIcon,
142 supportsTablet: true,
143 bundleIdentifier: variant.iosBundleIdentifier,
144 // Pin code signing to the T3 Tools team so non-interactive `expo run:ios`
145 // does not fall back to a personal team (which cannot sign app groups,
146 // Sign in with Apple, or push notification entitlements).
147 appleTeamId: "ARK85ZXQ4Z",
148 associatedDomains: [
149 `applinks:${variant.relyingParty}`,
150 `webcredentials:${variant.relyingParty}`,
151 ],
152 infoPlist: {
153 NSAppTransportSecurity: {
154 NSAllowsArbitraryLoads: true,
155 },
156 NSLocalNetworkUsageDescription:
157 "Allow T3 Code to connect to T3 Code servers on your local network or tailnet.",
158 ITSAppUsesNonExemptEncryption: false,
159 },
160 },
161 android: {
162 icon: variant.assets.appIcon,
163 package: variant.androidPackage,
164 adaptiveIcon: {
165 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
166 foregroundImage: variant.assets.androidAdaptiveForeground,
167 monochromeImage: variant.assets.androidMonochromeIcon,
168 },
169 // Opts into OnBackInvokedCallback-based back dispatch (Android 13+).
170 // JS back handling survives it via react-native's Android 16 shim plus
171 // withAndroidPredictiveBackCompat on Android 13-15.
172 predictiveBackGestureEnabled: true,
173 },
174 web: {
175 favicon: variant.assets.appIcon,
176 },
177 plugins: [
178 "expo-asset",
179 [
180 "expo-font",
181 {
182 ios: {
183 fonts: [dmSansFonts.regular, dmSansFonts.medium, dmSansFonts.bold],
184 },
185 android: {
186 fonts: [
187 {
188 fontFamily: "DMSans-Regular",
189 fontDefinitions: [{ path: dmSansFonts.regular, weight: 400 }],
190 },
191 {
192 fontFamily: "DMSans-Medium",
193 fontDefinitions: [{ path: dmSansFonts.medium, weight: 500 }],
194 },
195 {
196 fontFamily: "DMSans-Bold",
197 fontDefinitions: [{ path: dmSansFonts.bold, weight: 700 }],
198 },
199 ],
200 },
201 },
202 ],
203 "expo-secure-store",
204 "expo-sqlite",
205 [
206 "expo-notifications",
207 {
208 icon: variant.assets.androidNotificationIcon,
209 color: variant.assets.androidNotificationColor,
210 mode: APP_VARIANT === "development" ? "development" : "production",
211 },
212 ],
213 // appleSignIn must be gated here: withoutIosPersonalTeamCapabilities.cjs runs before
214 // plugins earlier in this array, so it cannot strip the entitlement Clerk would add.
215 ["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
216 "expo-web-browser",
217 [
218 "expo-quick-actions",
219 {
220 // Adaptive launcher-shortcut icon; referenced by resource name from
221 // the shortcut items set in src/features/shortcuts.
222 androidIcons: {
223 shortcut_icon: {
224 foregroundImage: variant.assets.androidAdaptiveForeground,
225 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
226 },
227 },
228 },
229 ],
230 [
231 "expo-camera",
232 {
233 cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
234 barcodeScannerEnabled: true,
235 recordAudioAndroid: false,
236 },
237 ],
238 [
239 "expo-splash-screen",
240 {
241 image: variant.assets.splashIcon,
242 resizeMode: "contain",
243 backgroundColor: "#ffffff",
244 imageWidth: 220,
245 dark: {
246 image: variant.assets.splashIcon,
247 backgroundColor: "#0a0a0a",
248 },
249 },
250 ],
251 [
252 "expo-build-properties",
253 {
254 ios: {
255 deploymentTarget: "18.0",
256 // AppCheckCore 11.3+ includes Swift and needs module maps for these Objective-C dependencies.
257 extraPods: [
258 { name: "GoogleUtilities", modular_headers: true },
259 { name: "RecaptchaInterop", modular_headers: true },
260 ],
261 },
262 },
263 ],
264 "./plugins/withIosCocoaPodsUuidCache.cjs",
265 // Must be listed BEFORE expo-widgets: same-type mods run last-registered-
266 // first, so registering earlier makes this plugin's mods run AFTER
267 // expo-widgets' — its dangerous mod wipes ios/ExpoWidgetsTarget/ (which
268 // would delete the asset catalog) and its xcodeproj mod creates the widget
269 // target (which must exist before the compile phase can be attached).
270 ...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
271 "./plugins/withIosSceneLifecycle.cjs",
272 "./plugins/withAndroidCleartextTraffic.cjs",
273 "./plugins/withAndroidGradleHeap.cjs",
274 "./plugins/withAndroidModernPopupMenu.cjs",
275 "./plugins/withAndroidModernAlertDialog.cjs",
276 "./plugins/withAndroidPredictiveBackCompat.cjs",
277 ...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
278 ],
279 extra: {
280 appVariant: APP_VARIANT,
281 iosPersonalTeamBuild: isIosPersonalTeamBuild,
282 relay: {
283 url: repoEnv.T3CODE_RELAY_URL ?? null,
284 },
285 clerk: {
286 publishableKey: repoEnv.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY ?? null,
287 jwtTemplate: repoEnv.EXPO_PUBLIC_CLERK_JWT_TEMPLATE ?? null,
288 },
289 // Native Google sign-in credentials. @clerk/expo reads these from `extra`
290 // under their exact env-var names (not nested), and its config plugin reads
291 // the iOS URL scheme at prebuild to register it in Info.plist.
292 // Unset values must be omitted (not null): the public manifest serializes
293 // null to {}, which is truthy and would defeat Clerk's fallback checks.
294 EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID,
295 EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID,
296 EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID,
297 EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME,
298 observability: {
299 tracesUrl: repoEnv.EXPO_PUBLIC_OTLP_TRACES_URL ?? "https://api.axiom.co/v1/traces",
300 tracesDataset: repoEnv.EXPO_PUBLIC_OTLP_TRACES_DATASET ?? null,
301 tracesToken: repoEnv.EXPO_PUBLIC_OTLP_TRACES_TOKEN ?? null,
302 },
303 eas: {
304 projectId: "d763fcb8-d37c-41ea-a773-b54a0ab4a454",
305 },
306 },
307 owner: "pingdotgg",
308};
309​
310export default config;