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

app.config.ts

380 lines13.8 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 },
152 },
153 android: {
154 enabled: true,
155 singleShareMimeTypes: ["text/plain", "image/*"],
156 multipleShareMimeTypes: ["image/*"],
157 },
158 },
159];
160​
161// These aliases match the fonts' PostScript names on iOS. Register the same
162// names on Android so React Native and the native composer use one set of
163// family names without waiting for runtime font loading.
164​
165const config: ExpoConfig = {
166 name: variant.appName,
167 slug: "t3-code",
168 platforms: ["ios", "android"],
169 scheme: variant.scheme,
170 version: "1.0.4",
171 runtimeVersion: {
172 // Development manifests resolve on every launch, so avoid fingerprint's
173 // expensive native-project calculation there. Preview and production stay
174 // fingerprinted so OTAs only reach binaries with matching native projects.
175 policy: runtimeVersionPolicy,
176 },
177 orientation: "portrait",
178 icon: variant.assets.appIcon,
179 userInterfaceStyle: "automatic",
180 updates: {
181 enabled: true,
182 url: "https://u.expo.dev/d763fcb8-d37c-41ea-a773-b54a0ab4a454",
183 checkAutomatically: "ON_LOAD",
184 fallbackToCacheTimeout: 0,
185 },
186 ios: {
187 icon: variant.assets.iosIcon,
188 supportsTablet: true,
189 // Multitasking-capable iPad apps cannot rotate programmatically, so the
190 // showcase capture build requires full screen (see infoPlist below).
191 requireFullScreen: process.env.T3_SHOWCASE_CAPTURE_BUILD === "1",
192 bundleIdentifier: iosBundleIdentifier,
193 // Pin code signing to the T3 Tools team so non-interactive `expo run:ios`
194 // does not fall back to a personal team (which cannot sign app groups,
195 // Sign in with Apple, or push notification entitlements).
196 appleTeamId: "ARK85ZXQ4Z",
197 associatedDomains: [
198 `applinks:${variant.relyingParty}`,
199 `webcredentials:${variant.relyingParty}`,
200 ],
201 infoPlist: {
202 NSAppTransportSecurity: {
203 NSAllowsArbitraryLoads: true,
204 },
205 NSLocalNetworkUsageDescription:
206 "Allow T3 Code to connect to T3 Code servers on your local network or tailnet.",
207 ITSAppUsesNonExemptEncryption: false,
208 // The App Store screenshot harness rotates the iPad interface from
209 // inside the app (CI denies osascript the Accessibility access that
210 // Simulator menu scripting needs), and iPadOS ignores programmatic
211 // orientation requests for multitasking-capable apps — so the capture
212 // build opts out of multitasking and declares landscape support.
213 ...(process.env.T3_SHOWCASE_CAPTURE_BUILD === "1"
214 ? {
215 "UISupportedInterfaceOrientations~ipad": [
216 "UIInterfaceOrientationPortrait",
217 "UIInterfaceOrientationPortraitUpsideDown",
218 "UIInterfaceOrientationLandscapeLeft",
219 "UIInterfaceOrientationLandscapeRight",
220 ],
221 }
222 : {}),
223 },
224 },
225 android: {
226 icon: variant.assets.appIcon,
227 package: variant.androidPackage,
228 adaptiveIcon: {
229 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
230 foregroundImage: variant.assets.androidAdaptiveForeground,
231 monochromeImage: variant.assets.androidMonochromeIcon,
232 },
233 // Opts into OnBackInvokedCallback-based back dispatch (Android 13+).
234 // JS back handling survives it via react-native's Android 16 shim plus
235 // withAndroidPredictiveBackCompat on Android 13-15.
236 predictiveBackGestureEnabled: true,
237 },
238 web: {
239 favicon: variant.assets.appIcon,
240 },
241 plugins: [
242 "expo-asset",
243 [
244 "expo-font",
245 {
246 ios: {
247 fonts: [dmSansFonts.regular, dmSansFonts.medium, dmSansFonts.bold],
248 },
249 android: {
250 fonts: [
251 {
252 fontFamily: "DMSans-Regular",
253 fontDefinitions: [{ path: dmSansFonts.regular, weight: 400 }],
254 },
255 {
256 fontFamily: "DMSans-Medium",
257 fontDefinitions: [{ path: dmSansFonts.medium, weight: 500 }],
258 },
259 {
260 fontFamily: "DMSans-Bold",
261 fontDefinitions: [{ path: dmSansFonts.bold, weight: 700 }],
262 },
263 ],
264 },
265 },
266 ],
267 "expo-secure-store",
268 "expo-sqlite",
269 ...(isIosPersonalTeamBuild
270 ? [sharingPlugin]
271 : ["./plugins/withShareExtensionDisplayName.cjs", sharingPlugin]),
272 [
273 "expo-notifications",
274 {
275 icon: variant.assets.androidNotificationIcon,
276 color: variant.assets.androidNotificationColor,
277 mode: APP_VARIANT === "development" ? "development" : "production",
278 },
279 ],
280 // appleSignIn must be gated here: withoutIosPersonalTeamCapabilities.cjs runs before
281 // plugins earlier in this array, so it cannot strip the entitlement Clerk would add.
282 ["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
283 "expo-web-browser",
284 [
285 "expo-quick-actions",
286 {
287 // Adaptive launcher-shortcut icon; referenced by resource name from
288 // the shortcut items set in src/features/shortcuts.
289 androidIcons: {
290 shortcut_icon: {
291 foregroundImage: variant.assets.androidAdaptiveForeground,
292 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
293 },
294 },
295 },
296 ],
297 [
298 "expo-camera",
299 {
300 cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
301 microphonePermission: false,
302 barcodeScannerEnabled: true,
303 recordAudioAndroid: false,
304 },
305 ],
306 ["expo-image-picker", { photosPermission: false, microphonePermission: false }],
307 [
308 "expo-splash-screen",
309 {
310 image: variant.assets.splashIcon,
311 resizeMode: "contain",
312 backgroundColor: "#ffffff",
313 imageWidth: 220,
314 dark: {
315 image: variant.assets.splashIcon,
316 backgroundColor: "#0a0a0a",
317 },
318 },
319 ],
320 [
321 "expo-build-properties",
322 {
323 ios: {
324 deploymentTarget: "18.0",
325 // AppCheckCore 11.3+ includes Swift and needs module maps for these Objective-C dependencies.
326 extraPods: [
327 { name: "GoogleUtilities", modular_headers: true },
328 { name: "RecaptchaInterop", modular_headers: true },
329 ],
330 },
331 },
332 ],
333 "./plugins/withIosCocoaPodsUuidCache.cjs",
334 // Must be listed BEFORE expo-widgets: same-type mods run last-registered-
335 // first, so registering earlier makes this plugin's mods run AFTER
336 // expo-widgets' — its dangerous mod wipes ios/ExpoWidgetsTarget/ (which
337 // would delete the asset catalog) and its xcodeproj mod creates the widget
338 // target (which must exist before the compile phase can be attached).
339 ...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
340 "./plugins/withIosSceneLifecycle.cjs",
341 "./plugins/withAndroidCleartextTraffic.cjs",
342 "./plugins/withAndroidGradleHeap.cjs",
343 "./plugins/withAndroidModernPopupMenu.cjs",
344 "./plugins/withAndroidModernAlertDialog.cjs",
345 "./plugins/withAndroidPredictiveBackCompat.cjs",
346 "./plugins/withAndroidTabletOrientation.cjs",
347 ...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
348 ],
349 extra: {
350 appVariant: APP_VARIANT,
351 iosPersonalTeamBuild: isIosPersonalTeamBuild,
352 relay: {
353 url: repoEnv.T3CODE_RELAY_URL ?? null,
354 },
355 clerk: {
356 publishableKey: repoEnv.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY ?? null,
357 jwtTemplate: repoEnv.EXPO_PUBLIC_CLERK_JWT_TEMPLATE ?? null,
358 },
359 // Native Google sign-in credentials. @clerk/expo reads these from `extra`
360 // under their exact env-var names (not nested), and its config plugin reads
361 // the iOS URL scheme at prebuild to register it in Info.plist.
362 // Unset values must be omitted (not null): the public manifest serializes
363 // null to {}, which is truthy and would defeat Clerk's fallback checks.
364 EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID,
365 EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID,
366 EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID,
367 EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME,
368 observability: {
369 tracesUrl: repoEnv.EXPO_PUBLIC_OTLP_TRACES_URL ?? "https://api.axiom.co/v1/traces",
370 tracesDataset: repoEnv.EXPO_PUBLIC_OTLP_TRACES_DATASET ?? null,
371 tracesToken: repoEnv.EXPO_PUBLIC_OTLP_TRACES_TOKEN ?? null,
372 },
373 eas: {
374 projectId: "d763fcb8-d37c-41ea-a773-b54a0ab4a454",
375 },
376 },
377 owner: "pingdotgg",
378};
379​
380export default config;