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

app.config.ts

392 lines14.2 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 NSPhotoLibraryAddUsageDescription: "Allow T3 Code to save images to your photo library.",
210 ITSAppUsesNonExemptEncryption: false,
211 // The App Store screenshot harness rotates the iPad interface from
212 // inside the app (CI denies osascript the Accessibility access that
213 // Simulator menu scripting needs), and iPadOS ignores programmatic
214 // orientation requests for multitasking-capable apps — so the capture
215 // build opts out of multitasking and declares landscape support.
216 ...(process.env.T3_SHOWCASE_CAPTURE_BUILD === "1"
217 ? {
218 "UISupportedInterfaceOrientations~ipad": [
219 "UIInterfaceOrientationPortrait",
220 "UIInterfaceOrientationPortraitUpsideDown",
221 "UIInterfaceOrientationLandscapeLeft",
222 "UIInterfaceOrientationLandscapeRight",
223 ],
224 }
225 : {}),
226 },
227 },
228 android: {
229 icon: variant.assets.appIcon,
230 package: variant.androidPackage,
231 adaptiveIcon: {
232 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
233 foregroundImage: variant.assets.androidAdaptiveForeground,
234 monochromeImage: variant.assets.androidMonochromeIcon,
235 },
236 // Opts into OnBackInvokedCallback-based back dispatch (Android 13+).
237 // JS back handling survives it via react-native's Android 16 shim plus
238 // withAndroidPredictiveBackCompat on Android 13-15.
239 predictiveBackGestureEnabled: true,
240 },
241 web: {
242 favicon: variant.assets.appIcon,
243 },
244 plugins: [
245 "expo-asset",
246 [
247 "expo-font",
248 {
249 ios: {
250 fonts: [dmSansFonts.regular, dmSansFonts.medium, dmSansFonts.bold],
251 },
252 android: {
253 fonts: [
254 {
255 fontFamily: "DMSans-Regular",
256 fontDefinitions: [{ path: dmSansFonts.regular, weight: 400 }],
257 },
258 {
259 fontFamily: "DMSans-Medium",
260 fontDefinitions: [{ path: dmSansFonts.medium, weight: 500 }],
261 },
262 {
263 fontFamily: "DMSans-Bold",
264 fontDefinitions: [{ path: dmSansFonts.bold, weight: 700 }],
265 },
266 ],
267 },
268 },
269 ],
270 "expo-secure-store",
271 "expo-sqlite",
272 ...(isIosPersonalTeamBuild
273 ? [sharingPlugin]
274 : ["./plugins/withShareExtensionDisplayName.cjs", sharingPlugin]),
275 [
276 "expo-notifications",
277 {
278 icon: variant.assets.androidNotificationIcon,
279 color: variant.assets.androidNotificationColor,
280 mode: APP_VARIANT === "development" ? "development" : "production",
281 },
282 ],
283 // appleSignIn must be gated here: withoutIosPersonalTeamCapabilities.cjs runs before
284 // plugins earlier in this array, so it cannot strip the entitlement Clerk would add.
285 ["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
286 "expo-web-browser",
287 [
288 "expo-quick-actions",
289 {
290 // Adaptive launcher-shortcut icon; referenced by resource name from
291 // the shortcut items set in src/features/shortcuts.
292 androidIcons: {
293 shortcut_icon: {
294 foregroundImage: variant.assets.androidAdaptiveForeground,
295 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
296 },
297 },
298 },
299 ],
300 [
301 "expo-audio",
302 {
303 microphonePermission: "Allow T3 Code to use your microphone for voice input.",
304 recordAudioAndroid: false,
305 enableBackgroundPlayback: false,
306 enableBackgroundRecording: false,
307 },
308 ],
309 [
310 "expo-camera",
311 {
312 cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
313 microphonePermission: false,
314 barcodeScannerEnabled: true,
315 recordAudioAndroid: false,
316 },
317 ],
318 ["expo-image-picker", { photosPermission: false, microphonePermission: false }],
319 [
320 "expo-splash-screen",
321 {
322 image: variant.assets.splashIcon,
323 resizeMode: "contain",
324 backgroundColor: "#ffffff",
325 imageWidth: 220,
326 dark: {
327 image: variant.assets.splashIcon,
328 backgroundColor: "#0a0a0a",
329 },
330 },
331 ],
332 [
333 "expo-build-properties",
334 {
335 ios: {
336 deploymentTarget: "18.0",
337 // AppCheckCore 11.3+ includes Swift and needs module maps for these Objective-C dependencies.
338 extraPods: [
339 { name: "GoogleUtilities", modular_headers: true },
340 { name: "RecaptchaInterop", modular_headers: true },
341 ],
342 },
343 },
344 ],
345 "./plugins/withIosCocoaPodsUuidCache.cjs",
346 // Must be listed BEFORE expo-widgets: same-type mods run last-registered-
347 // first, so registering earlier makes this plugin's mods run AFTER
348 // expo-widgets' — its dangerous mod wipes ios/ExpoWidgetsTarget/ (which
349 // would delete the asset catalog) and its xcodeproj mod creates the widget
350 // target (which must exist before the compile phase can be attached).
351 ...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
352 "./plugins/withIosSceneLifecycle.cjs",
353 "./plugins/withAndroidCleartextTraffic.cjs",
354 "./plugins/withAndroidGradleHeap.cjs",
355 "./plugins/withAndroidModernPopupMenu.cjs",
356 "./plugins/withAndroidModernAlertDialog.cjs",
357 "./plugins/withAndroidPredictiveBackCompat.cjs",
358 "./plugins/withAndroidTabletOrientation.cjs",
359 ...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
360 ],
361 extra: {
362 appVariant: APP_VARIANT,
363 iosPersonalTeamBuild: isIosPersonalTeamBuild,
364 relay: {
365 url: repoEnv.T3CODE_RELAY_URL ?? null,
366 },
367 clerk: {
368 publishableKey: repoEnv.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY ?? null,
369 jwtTemplate: repoEnv.EXPO_PUBLIC_CLERK_JWT_TEMPLATE ?? null,
370 },
371 // Native Google sign-in credentials. @clerk/expo reads these from `extra`
372 // under their exact env-var names (not nested), and its config plugin reads
373 // the iOS URL scheme at prebuild to register it in Info.plist.
374 // Unset values must be omitted (not null): the public manifest serializes
375 // null to {}, which is truthy and would defeat Clerk's fallback checks.
376 EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID,
377 EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID,
378 EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID,
379 EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME,
380 observability: {
381 tracesUrl: repoEnv.EXPO_PUBLIC_OTLP_TRACES_URL ?? "https://api.axiom.co/v1/traces",
382 tracesDataset: repoEnv.EXPO_PUBLIC_OTLP_TRACES_DATASET ?? null,
383 tracesToken: repoEnv.EXPO_PUBLIC_OTLP_TRACES_TOKEN ?? null,
384 },
385 eas: {
386 projectId: "d763fcb8-d37c-41ea-a773-b54a0ab4a454",
387 },
388 },
389 owner: "pingdotgg",
390};
391​
392export default config;