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

app.config.ts

391 lines14.1 KB

1import type { ExpoConfig } from "expo/config";
2​
3import { BRAND_ASSET_PATHS } from "../../scripts/lib/brand-assets.ts";
4import { loadRepoEnv } from "../../scripts/lib/public-config.ts";
5​
6type AppVariant = "development" | "preview" | "production";
7​
8const repoEnv = loadRepoEnv();
9Object.assign(process.env, repoEnv);
10​
11const APP_VARIANT = resolveAppVariant(repoEnv.APP_VARIANT);
12const isIosPersonalTeamBuild = repoEnv.T3CODE_IOS_PERSONAL_TEAM === "1";
13const runtimeVersionPolicy =
14 process.env.MOBILE_VERSION_POLICY ??
15 (APP_VARIANT === "development" ? "appVersion" : "fingerprint");
16​
17const personalTeamBundleIdentifier = repoEnv.T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID?.trim();
18const IOS_BUNDLE_IDENTIFIER_PATTERN = /^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/;
19​
20const fromRepoRoot = (relativePath: string) => `../../${relativePath}`;
21// Universal exports already contain their own rounded-square silhouette. Using one as an adaptive
22// foreground makes Android draw an icon shape inside the launcher's mask.
23const androidAdaptiveForeground = "./assets/android-icon-foreground.png";
24​
25if (
26 isIosPersonalTeamBuild &&
27 (!personalTeamBundleIdentifier ||
28 !IOS_BUNDLE_IDENTIFIER_PATTERN.test(personalTeamBundleIdentifier))
29) {
30 throw new Error(
31 "T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID must be a reverse-DNS identifier such as com.example.t3code when T3CODE_IOS_PERSONAL_TEAM=1.",
32 );
34​
35const DEVELOPMENT_ASSETS = {
36 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIosIconPng),
37 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIconComposerProject),
38 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIosIconPng),
39 androidAdaptiveForeground,
40 androidAdaptiveBackgroundColor: "#00639B",
41 androidMonochromeIcon: "./assets/android-icon-mark.png",
42 androidNotificationIcon: "./assets/android-notification-icon.png",
43 androidNotificationColor: "#00639B",
44} as const;
45​
46const PREVIEW_ASSETS = {
47 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
48 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIconComposerProject),
49 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
50 androidAdaptiveForeground,
51 androidAdaptiveBackgroundColor: "#111533",
52 androidMonochromeIcon: "./assets/android-icon-mark.png",
53 androidNotificationIcon: "./assets/android-notification-icon.png",
54 androidNotificationColor: "#7565C7",
55} as const;
56​
57const RELEASE_ASSETS = {
58 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
59 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIconComposerProject),
60 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
61 androidAdaptiveForeground,
62 androidAdaptiveBackgroundColor: "#000000",
63 androidMonochromeIcon: "./assets/android-icon-mark.png",
64 androidNotificationIcon: "./assets/android-notification-icon.png",
65 androidNotificationColor: "#FFFFFF",
66} as const;
67​
68const VARIANT_CONFIG = {
69 development: {
70 appName: "T3 Code Dev",
71 scheme: "t3code-dev",
72 iosBundleIdentifier: "com.t3tools.t3code.dev",
73 androidPackage: "com.t3tools.t3code.dev",
74 relyingParty: "clerk.t3.codes",
75 assets: DEVELOPMENT_ASSETS,
76 },
77 preview: {
78 appName: "T3 Code Preview",
79 scheme: "t3code-preview",
80 iosBundleIdentifier: "com.t3tools.t3code.preview",
81 androidPackage: "com.t3tools.t3code.preview",
82 relyingParty: "clerk.t3.codes",
83 assets: PREVIEW_ASSETS,
84 },
85 production: {
86 appName: "T3 Code",
87 scheme: "t3code",
88 iosBundleIdentifier: "com.t3tools.t3code",
89 androidPackage: "com.t3tools.t3code",
90 relyingParty: "clerk.t3.codes",
91 assets: RELEASE_ASSETS,
92 },
93} as const;
94​
95function resolveAppVariant(value: string | undefined): AppVariant {
96 switch (value) {
97 case "development":
98 case "preview":
99 case "production":
100 return value;
101 default:
102 return "production";
103 }
105​
106const variant = VARIANT_CONFIG[APP_VARIANT];
107const iosBundleIdentifier = isIosPersonalTeamBuild
108 ? personalTeamBundleIdentifier!
109 : variant.iosBundleIdentifier;
110​
111const dmSansFonts = {
112 regular: "@expo-google-fonts/dm-sans/400Regular/DMSans_400Regular.ttf",
113 medium: "@expo-google-fonts/dm-sans/500Medium/DMSans_500Medium.ttf",
114 bold: "@expo-google-fonts/dm-sans/700Bold/DMSans_700Bold.ttf",
115} as const;
116​
117const widgetsPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
118 "expo-widgets",
119 {
120 bundleIdentifier: `${iosBundleIdentifier}.widgets`,
121 groupIdentifier: `group.${iosBundleIdentifier}`,
122 enablePushNotifications: true,
123 // Agent activity can update many times an hour; without the
124 // frequent-updates entitlement iOS throttles the update budget sooner.
125 frequentUpdates: true,
126 widgets: [
127 {
128 name: "AgentActivity",
129 displayName: "Agent Activity",
130 description: "Shows the current state of active T3 Code agents.",
131 supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"],
132 },
133 ],
134 },
135];
136​
137const sharingPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
138 "expo-sharing",
139 {
140 ios: {
141 // Personal Teams cannot sign App Groups or extension targets. Keep the
142 // reduced-capability local build usable while release builds expose the
143 // real system share target.
144 enabled: !isIosPersonalTeamBuild,
145 extensionBundleIdentifier: `${iosBundleIdentifier}.sharing`,
146 appGroupId: `group.${iosBundleIdentifier}`,
147 activationRule: {
148 supportsText: true,
149 supportsWebUrlWithMaxCount: 1,
150 supportsImageWithMaxCount: 8,
151 supportsMovieWithMaxCount: 8,
152 supportsFileWithMaxCount: 8,
153 },
154 },
155 android: {
156 enabled: true,
157 singleShareMimeTypes: ["*/*"],
158 multipleShareMimeTypes: ["*/*"],
159 },
160 },
161];
162​
163// These aliases match the fonts' PostScript names on iOS. Register the same
164// names on Android so React Native and the native composer use one set of
165// family names without waiting for runtime font loading.
166​
167const config: ExpoConfig = {
168 name: variant.appName,
169 slug: "t3-code",
170 platforms: ["ios", "android"],
171 scheme: variant.scheme,
172 version: "1.0.4",
173 runtimeVersion: {
174 // Development manifests resolve on every launch, so avoid fingerprint's
175 // expensive native-project calculation there. Preview and production stay
176 // fingerprinted so OTAs only reach binaries with matching native projects.
177 policy: runtimeVersionPolicy,
178 },
179 orientation: "portrait",
180 icon: variant.assets.appIcon,
181 userInterfaceStyle: "automatic",
182 updates: {
183 enabled: true,
184 url: "https://u.expo.dev/d763fcb8-d37c-41ea-a773-b54a0ab4a454",
185 checkAutomatically: "ON_LOAD",
186 fallbackToCacheTimeout: 0,
187 },
188 ios: {
189 icon: variant.assets.iosIcon,
190 supportsTablet: true,
191 // Multitasking-capable iPad apps cannot rotate programmatically, so the
192 // showcase capture build requires full screen (see infoPlist below).
193 requireFullScreen: process.env.T3_SHOWCASE_CAPTURE_BUILD === "1",
194 bundleIdentifier: iosBundleIdentifier,
195 // Pin code signing to the T3 Tools team so non-interactive `expo run:ios`
196 // does not fall back to a personal team (which cannot sign app groups,
197 // Sign in with Apple, or push notification entitlements).
198 appleTeamId: "ARK85ZXQ4Z",
199 associatedDomains: [
200 `applinks:${variant.relyingParty}`,
201 `webcredentials:${variant.relyingParty}`,
202 ],
203 infoPlist: {
204 NSAppTransportSecurity: {
205 NSAllowsArbitraryLoads: true,
206 },
207 NSLocalNetworkUsageDescription:
208 "Allow T3 Code to connect to T3 Code servers on your local network or tailnet.",
209 ITSAppUsesNonExemptEncryption: false,
210 // The App Store screenshot harness rotates the iPad interface from
211 // inside the app (CI denies osascript the Accessibility access that
212 // Simulator menu scripting needs), and iPadOS ignores programmatic
213 // orientation requests for multitasking-capable apps — so the capture
214 // build opts out of multitasking and declares landscape support.
215 ...(process.env.T3_SHOWCASE_CAPTURE_BUILD === "1"
216 ? {
217 "UISupportedInterfaceOrientations~ipad": [
218 "UIInterfaceOrientationPortrait",
219 "UIInterfaceOrientationPortraitUpsideDown",
220 "UIInterfaceOrientationLandscapeLeft",
221 "UIInterfaceOrientationLandscapeRight",
222 ],
223 }
224 : {}),
225 },
226 },
227 android: {
228 icon: variant.assets.appIcon,
229 package: variant.androidPackage,
230 adaptiveIcon: {
231 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
232 foregroundImage: variant.assets.androidAdaptiveForeground,
233 monochromeImage: variant.assets.androidMonochromeIcon,
234 },
235 // Opts into OnBackInvokedCallback-based back dispatch (Android 13+).
236 // JS back handling survives it via react-native's Android 16 shim plus
237 // withAndroidPredictiveBackCompat on Android 13-15.
238 predictiveBackGestureEnabled: true,
239 },
240 web: {
241 favicon: variant.assets.appIcon,
242 },
243 plugins: [
244 "expo-asset",
245 [
246 "expo-font",
247 {
248 ios: {
249 fonts: [dmSansFonts.regular, dmSansFonts.medium, dmSansFonts.bold],
250 },
251 android: {
252 fonts: [
253 {
254 fontFamily: "DMSans-Regular",
255 fontDefinitions: [{ path: dmSansFonts.regular, weight: 400 }],
256 },
257 {
258 fontFamily: "DMSans-Medium",
259 fontDefinitions: [{ path: dmSansFonts.medium, weight: 500 }],
260 },
261 {
262 fontFamily: "DMSans-Bold",
263 fontDefinitions: [{ path: dmSansFonts.bold, weight: 700 }],
264 },
265 ],
266 },
267 },
268 ],
269 "expo-secure-store",
270 "expo-sqlite",
271 ...(isIosPersonalTeamBuild
272 ? [sharingPlugin]
273 : ["./plugins/withShareExtensionDisplayName.cjs", sharingPlugin]),
274 [
275 "expo-notifications",
276 {
277 icon: variant.assets.androidNotificationIcon,
278 color: variant.assets.androidNotificationColor,
279 mode: APP_VARIANT === "development" ? "development" : "production",
280 },
281 ],
282 // appleSignIn must be gated here: withoutIosPersonalTeamCapabilities.cjs runs before
283 // plugins earlier in this array, so it cannot strip the entitlement Clerk would add.
284 ["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
285 "expo-web-browser",
286 [
287 "expo-quick-actions",
288 {
289 // Adaptive launcher-shortcut icon; referenced by resource name from
290 // the shortcut items set in src/features/shortcuts.
291 androidIcons: {
292 shortcut_icon: {
293 foregroundImage: variant.assets.androidAdaptiveForeground,
294 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
295 },
296 },
297 },
298 ],
299 [
300 "expo-audio",
301 {
302 microphonePermission: "Allow T3 Code to use your microphone for voice input.",
303 recordAudioAndroid: false,
304 enableBackgroundPlayback: false,
305 enableBackgroundRecording: false,
306 },
307 ],
308 [
309 "expo-camera",
310 {
311 cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
312 microphonePermission: false,
313 barcodeScannerEnabled: true,
314 recordAudioAndroid: false,
315 },
316 ],
317 ["expo-image-picker", { photosPermission: false, microphonePermission: false }],
318 [
319 "expo-splash-screen",
320 {
321 image: variant.assets.splashIcon,
322 resizeMode: "contain",
323 backgroundColor: "#ffffff",
324 imageWidth: 220,
325 dark: {
326 image: variant.assets.splashIcon,
327 backgroundColor: "#0a0a0a",
328 },
329 },
330 ],
331 [
332 "expo-build-properties",
333 {
334 ios: {
335 deploymentTarget: "18.0",
336 // AppCheckCore 11.3+ includes Swift and needs module maps for these Objective-C dependencies.
337 extraPods: [
338 { name: "GoogleUtilities", modular_headers: true },
339 { name: "RecaptchaInterop", modular_headers: true },
340 ],
341 },
342 },
343 ],
344 "./plugins/withIosCocoaPodsUuidCache.cjs",
345 // Must be listed BEFORE expo-widgets: same-type mods run last-registered-
346 // first, so registering earlier makes this plugin's mods run AFTER
347 // expo-widgets' — its dangerous mod wipes ios/ExpoWidgetsTarget/ (which
348 // would delete the asset catalog) and its xcodeproj mod creates the widget
349 // target (which must exist before the compile phase can be attached).
350 ...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
351 "./plugins/withIosSceneLifecycle.cjs",
352 "./plugins/withAndroidCleartextTraffic.cjs",
353 "./plugins/withAndroidGradleHeap.cjs",
354 "./plugins/withAndroidModernPopupMenu.cjs",
355 "./plugins/withAndroidModernAlertDialog.cjs",
356 "./plugins/withAndroidPredictiveBackCompat.cjs",
357 "./plugins/withAndroidTabletOrientation.cjs",
358 ...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
359 ],
360 extra: {
361 appVariant: APP_VARIANT,
362 iosPersonalTeamBuild: isIosPersonalTeamBuild,
363 relay: {
364 url: repoEnv.T3CODE_RELAY_URL ?? null,
365 },
366 clerk: {
367 publishableKey: repoEnv.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY ?? null,
368 jwtTemplate: repoEnv.EXPO_PUBLIC_CLERK_JWT_TEMPLATE ?? null,
369 },
370 // Native Google sign-in credentials. @clerk/expo reads these from `extra`
371 // under their exact env-var names (not nested), and its config plugin reads
372 // the iOS URL scheme at prebuild to register it in Info.plist.
373 // Unset values must be omitted (not null): the public manifest serializes
374 // null to {}, which is truthy and would defeat Clerk's fallback checks.
375 EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID,
376 EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID,
377 EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID,
378 EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME,
379 observability: {
380 tracesUrl: repoEnv.EXPO_PUBLIC_OTLP_TRACES_URL ?? "https://api.axiom.co/v1/traces",
381 tracesDataset: repoEnv.EXPO_PUBLIC_OTLP_TRACES_DATASET ?? null,
382 tracesToken: repoEnv.EXPO_PUBLIC_OTLP_TRACES_TOKEN ?? null,
383 },
384 eas: {
385 projectId: "d763fcb8-d37c-41ea-a773-b54a0ab4a454",
386 },
387 },
388 owner: "pingdotgg",
389};
390​
391export default config;