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

app.config.ts

462 lines17.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// Android layers are rendered by scripts/export-android-icons.ts from the Icon Composer sources.
22// The wordmark sits inside the adaptive safe zone; the variant artwork is a full-bleed background.
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: "#347FF8",
41 androidAdaptiveBackgroundImage: "./assets/android-icon-background-dev.png",
42 androidSplashIcon: "./assets/android-splash-icon-dev.png",
43 androidMonochromeIcon: "./assets/android-icon-mark.png",
44 androidNotificationIcon: "./assets/android-notification-icon.png",
45 androidNotificationColor: "#00639B",
46} as const;
47​
48const PREVIEW_ASSETS = {
49 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
50 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIconComposerProject),
51 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
52 androidAdaptiveForeground,
53 androidAdaptiveBackgroundColor: "#111533",
54 androidAdaptiveBackgroundImage: "./assets/android-icon-background-nightly.png",
55 androidSplashIcon: "./assets/android-splash-icon-nightly.png",
56 androidMonochromeIcon: "./assets/android-icon-mark.png",
57 androidNotificationIcon: "./assets/android-notification-icon.png",
58 androidNotificationColor: "#7565C7",
59} as const;
60​
61const RELEASE_ASSETS = {
62 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
63 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIconComposerProject),
64 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
65 androidAdaptiveForeground,
66 androidAdaptiveBackgroundColor: "#000000",
67 androidAdaptiveBackgroundImage: undefined,
68 androidSplashIcon: "./assets/android-splash-icon-prod.png",
69 androidMonochromeIcon: "./assets/android-icon-mark.png",
70 androidNotificationIcon: "./assets/android-notification-icon.png",
71 androidNotificationColor: "#FFFFFF",
72} as const;
73​
74const VARIANT_CONFIG = {
75 development: {
76 appName: "T3 Code Dev",
77 scheme: "t3code-dev",
78 iosBundleIdentifier: "com.t3tools.t3code.dev",
79 androidPackage: "com.t3tools.t3code.dev",
80 relyingParty: "clerk.t3.codes",
81 assets: DEVELOPMENT_ASSETS,
82 },
83 preview: {
84 appName: "T3 Code Preview",
85 scheme: "t3code-preview",
86 iosBundleIdentifier: "com.t3tools.t3code.preview",
87 androidPackage: "com.t3tools.t3code.preview",
88 relyingParty: "clerk.t3.codes",
89 assets: PREVIEW_ASSETS,
90 },
91 production: {
92 appName: "T3 Code",
93 scheme: "t3code",
94 iosBundleIdentifier: "com.t3tools.t3code",
95 androidPackage: "com.t3tools.t3code",
96 relyingParty: "clerk.t3.codes",
97 assets: RELEASE_ASSETS,
98 },
99} as const;
100​
101function resolveAppVariant(value: string | undefined): AppVariant {
102 switch (value) {
103 case "development":
104 case "preview":
105 case "production":
106 return value;
107 default:
108 return "production";
109 }
111​
112const variant = VARIANT_CONFIG[APP_VARIANT];
113const iosBundleIdentifier = isIosPersonalTeamBuild
114 ? personalTeamBundleIdentifier!
115 : variant.iosBundleIdentifier;
116​
117const dmSansFonts = {
118 regular: "@expo-google-fonts/dm-sans/400Regular/DMSans_400Regular.ttf",
119 medium: "@expo-google-fonts/dm-sans/500Medium/DMSans_500Medium.ttf",
120 bold: "@expo-google-fonts/dm-sans/700Bold/DMSans_700Bold.ttf",
121} as const;
122​
123const widgetsPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
124 "expo-widgets",
125 {
126 bundleIdentifier: `${iosBundleIdentifier}.widgets`,
127 groupIdentifier: `group.${iosBundleIdentifier}`,
128 enablePushNotifications: true,
129 // Agent activity can update many times an hour; without the
130 // frequent-updates entitlement iOS throttles the update budget sooner.
131 frequentUpdates: true,
132 widgets: [
133 {
134 name: "SubscriptionUsage",
135 displayName: "Subscription usage",
136 description: "Subscription quotas from your connected T3 Code environments.",
137 configuration: {
138 title: "Subscription usage",
139 description:
140 "Both shows Session and Weekly when available. The Lock Screen shows the tightest selected limit.",
141 parameters: {
142 codexPeriod: {
143 title: "Codex limits",
144 type: "enum",
145 default: "auto",
146 values: [
147 { name: "Both", value: "auto" },
148 { name: "Session", value: "session" },
149 { name: "Weekly", value: "weekly" },
150 ],
151 },
152 claudePeriod: {
153 title: "Claude limits",
154 type: "enum",
155 default: "auto",
156 values: [
157 { name: "Both", value: "auto" },
158 { name: "Session", value: "session" },
159 { name: "Weekly", value: "weekly" },
160 ],
161 },
162 },
163 },
164 supportedFamilies: [
165 "systemSmall",
166 "systemMedium",
167 "systemLarge",
168 "systemExtraLarge",
169 "accessoryRectangular",
170 ],
171 },
172 {
173 name: "AgentActivity",
174 displayName: "Agent Activity",
175 description: "Shows the current state of active T3 Code agents.",
176 supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"],
177 },
178 ],
179 },
180];
181​
182const sharingPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
183 "expo-sharing",
184 {
185 ios: {
186 // Personal Teams cannot sign App Groups or extension targets. Keep the
187 // reduced-capability local build usable while release builds expose the
188 // real system share target.
189 enabled: !isIosPersonalTeamBuild,
190 extensionBundleIdentifier: `${iosBundleIdentifier}.sharing`,
191 appGroupId: `group.${iosBundleIdentifier}`,
192 activationRule: {
193 supportsText: true,
194 supportsWebUrlWithMaxCount: 1,
195 supportsImageWithMaxCount: 8,
196 supportsMovieWithMaxCount: 8,
197 supportsFileWithMaxCount: 8,
198 },
199 },
200 android: {
201 enabled: true,
202 singleShareMimeTypes: ["*/*"],
203 multipleShareMimeTypes: ["*/*"],
204 },
205 },
206];
207​
208// These aliases match the fonts' PostScript names on iOS. Register the same
209// names on Android so React Native and the native composer use one set of
210// family names without waiting for runtime font loading.
211​
212const config: ExpoConfig = {
213 name: variant.appName,
214 slug: "t3-code",
215 platforms: ["ios", "android"],
216 scheme: variant.scheme,
217 version: "1.1.1",
218 runtimeVersion: {
219 // Development manifests resolve on every launch, so avoid fingerprint's
220 // expensive native-project calculation there. Preview and production stay
221 // fingerprinted so OTAs only reach binaries with matching native projects.
222 policy: runtimeVersionPolicy,
223 },
224 orientation: "portrait",
225 icon: variant.assets.appIcon,
226 userInterfaceStyle: "automatic",
227 updates: {
228 enabled: repoEnv.T3CODE_MOBILE_UPDATES_ENABLED !== "0",
229 url: "https://u.expo.dev/d763fcb8-d37c-41ea-a773-b54a0ab4a454",
230 checkAutomatically: "ON_LOAD",
231 fallbackToCacheTimeout: 0,
232 },
233 ios: {
234 icon: variant.assets.iosIcon,
235 supportsTablet: true,
236 // Multitasking-capable iPad apps cannot rotate programmatically, so the
237 // showcase capture build requires full screen (see infoPlist below).
238 requireFullScreen: process.env.T3_SHOWCASE_CAPTURE_BUILD === "1",
239 bundleIdentifier: iosBundleIdentifier,
240 // Pin code signing to the T3 Tools team so non-interactive `expo run:ios`
241 // does not fall back to a personal team (which cannot sign app groups,
242 // Sign in with Apple, or push notification entitlements).
243 appleTeamId: "ARK85ZXQ4Z",
244 associatedDomains: [
245 `applinks:${variant.relyingParty}`,
246 `webcredentials:${variant.relyingParty}`,
247 ],
248 entitlements: {
249 "keychain-access-groups": [`$(AppIdentifierPrefix)${variant.iosBundleIdentifier}`],
250 },
251 infoPlist: {
252 NSAppTransportSecurity: {
253 NSAllowsArbitraryLoads: true,
254 },
255 NSLocalNetworkUsageDescription:
256 "Allow T3 Code to connect to T3 Code servers on your local network or tailnet.",
257 NSPhotoLibraryAddUsageDescription: "Allow T3 Code to save images to your photo library.",
258 ITSAppUsesNonExemptEncryption: false,
259 // The App Store screenshot harness rotates the iPad interface from
260 // inside the app (CI denies osascript the Accessibility access that
261 // Simulator menu scripting needs), and iPadOS ignores programmatic
262 // orientation requests for multitasking-capable apps — so the capture
263 // build opts out of multitasking and declares landscape support.
264 ...(process.env.T3_SHOWCASE_CAPTURE_BUILD === "1"
265 ? {
266 "UISupportedInterfaceOrientations~ipad": [
267 "UIInterfaceOrientationPortrait",
268 "UIInterfaceOrientationPortraitUpsideDown",
269 "UIInterfaceOrientationLandscapeLeft",
270 "UIInterfaceOrientationLandscapeRight",
271 ],
272 }
273 : {}),
274 },
275 },
276 android: {
277 icon: variant.assets.appIcon,
278 package: variant.androidPackage,
279 ...(repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE
280 ? { googleServicesFile: repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE }
281 : {}),
282 adaptiveIcon: {
283 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
284 ...(variant.assets.androidAdaptiveBackgroundImage
285 ? { backgroundImage: variant.assets.androidAdaptiveBackgroundImage }
286 : {}),
287 foregroundImage: variant.assets.androidAdaptiveForeground,
288 monochromeImage: variant.assets.androidMonochromeIcon,
289 },
290 // Opts into OnBackInvokedCallback-based back dispatch (Android 13+).
291 // JS back handling survives it via react-native's Android 16 shim plus
292 // withAndroidPredictiveBackCompat on Android 13-15.
293 predictiveBackGestureEnabled: true,
294 },
295 web: {
296 favicon: variant.assets.appIcon,
297 },
298 plugins: [
299 "expo-asset",
300 [
301 "expo-font",
302 {
303 ios: {
304 fonts: [dmSansFonts.regular, dmSansFonts.medium, dmSansFonts.bold],
305 },
306 android: {
307 fonts: [
308 {
309 fontFamily: "DMSans-Regular",
310 fontDefinitions: [{ path: dmSansFonts.regular, weight: 400 }],
311 },
312 {
313 fontFamily: "DMSans-Medium",
314 fontDefinitions: [{ path: dmSansFonts.medium, weight: 500 }],
315 },
316 {
317 fontFamily: "DMSans-Bold",
318 fontDefinitions: [{ path: dmSansFonts.bold, weight: 700 }],
319 },
320 ],
321 },
322 },
323 ],
324 "expo-secure-store",
325 "expo-sqlite",
326 ...(isIosPersonalTeamBuild
327 ? [sharingPlugin]
328 : ["./plugins/withShareExtensionDisplayName.cjs", sharingPlugin]),
329 [
330 "expo-notifications",
331 {
332 icon: variant.assets.androidNotificationIcon,
333 color: variant.assets.androidNotificationColor,
334 mode: APP_VARIANT === "development" ? "development" : "production",
335 },
336 ],
337 // appleSignIn must be gated here: withoutIosPersonalTeamCapabilities.cjs runs before
338 // plugins earlier in this array, so it cannot strip the entitlement Clerk would add.
339 ["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
340 "expo-web-browser",
341 [
342 "expo-quick-actions",
343 {
344 // Adaptive launcher-shortcut icon; referenced by resource name from
345 // the shortcut items set in src/features/shortcuts.
346 androidIcons: {
347 shortcut_icon: {
348 foregroundImage: variant.assets.androidAdaptiveForeground,
349 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
350 ...(variant.assets.androidAdaptiveBackgroundImage
351 ? { backgroundImage: variant.assets.androidAdaptiveBackgroundImage }
352 : {}),
353 },
354 },
355 },
356 ],
357 [
358 "expo-audio",
359 {
360 microphonePermission: "Allow T3 Code to use your microphone for voice input.",
361 recordAudioAndroid: false,
362 enableBackgroundPlayback: false,
363 enableBackgroundRecording: false,
364 },
365 ],
366 [
367 "expo-camera",
368 {
369 cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
370 microphonePermission: false,
371 barcodeScannerEnabled: true,
372 recordAudioAndroid: false,
373 },
374 ],
375 ["expo-image-picker", { photosPermission: false, microphonePermission: false }],
376 [
377 "expo-splash-screen",
378 {
379 image: variant.assets.splashIcon,
380 resizeMode: "contain",
381 backgroundColor: "#ffffff",
382 imageWidth: 220,
383 dark: {
384 image: variant.assets.splashIcon,
385 backgroundColor: "#0a0a0a",
386 },
387 android: {
388 // Android 12+ masks the splash icon to a circle over the central two thirds of
389 // its 288dp canvas, so the iOS export's corners get cut. A full-canvas image of
390 // the composed adaptive layers puts the wordmark in the same frame the launcher
391 // icon uses.
392 image: variant.assets.androidSplashIcon,
393 imageWidth: 288,
394 dark: { image: variant.assets.androidSplashIcon },
395 },
396 },
397 ],
398 [
399 "expo-build-properties",
400 {
401 android: {
402 // Keep the supported floor explicit and covered by native notification tests.
403 minSdkVersion: 24,
404 },
405 ios: {
406 deploymentTarget: "18.0",
407 // AppCheckCore 11.3+ includes Swift and needs module maps for these Objective-C dependencies.
408 extraPods: [
409 { name: "GoogleUtilities", modular_headers: true },
410 { name: "RecaptchaInterop", modular_headers: true },
411 ],
412 },
413 },
414 ],
415 "./plugins/withIosCocoaPodsUuidCache.cjs",
416 // Must be listed BEFORE expo-widgets: same-type mods run last-registered-
417 // first, so registering earlier makes this plugin's mods run AFTER
418 // expo-widgets' — its dangerous mod wipes ios/ExpoWidgetsTarget/ (which
419 // would delete the asset catalog) and its xcodeproj mod creates the widget
420 // target (which must exist before the compile phase can be attached).
421 ...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
422 "./plugins/withIosSceneLifecycle.cjs",
423 "./plugins/withAndroidCleartextTraffic.cjs",
424 "./plugins/withAndroidGradleHeap.cjs",
425 "./plugins/withAndroidModernPopupMenu.cjs",
426 "./plugins/withAndroidModernAlertDialog.cjs",
427 "./plugins/withAndroidPredictiveBackCompat.cjs",
428 "./plugins/withAndroidTabletOrientation.cjs",
429 ...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
430 ],
431 extra: {
432 appVariant: APP_VARIANT,
433 iosPersonalTeamBuild: isIosPersonalTeamBuild,
434 relay: {
435 url: repoEnv.T3CODE_RELAY_URL ?? null,
436 },
437 clerk: {
438 publishableKey: repoEnv.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY ?? null,
439 jwtTemplate: repoEnv.EXPO_PUBLIC_CLERK_JWT_TEMPLATE ?? null,
440 },
441 // Native Google sign-in credentials. @clerk/expo reads these from `extra`
442 // under their exact env-var names (not nested), and its config plugin reads
443 // the iOS URL scheme at prebuild to register it in Info.plist.
444 // Unset values must be omitted (not null): the public manifest serializes
445 // null to {}, which is truthy and would defeat Clerk's fallback checks.
446 EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID,
447 EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID,
448 EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID,
449 EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME,
450 observability: {
451 tracesUrl: repoEnv.EXPO_PUBLIC_OTLP_TRACES_URL ?? "https://api.axiom.co/v1/traces",
452 tracesDataset: repoEnv.EXPO_PUBLIC_OTLP_TRACES_DATASET ?? null,
453 tracesToken: repoEnv.EXPO_PUBLIC_OTLP_TRACES_TOKEN ?? null,
454 },
455 eas: {
456 projectId: "d763fcb8-d37c-41ea-a773-b54a0ab4a454",
457 },
458 },
459 owner: "pingdotgg",
460};
461​
462export default config;