const DEV_ICON_PROFILES = new Set(['development', 'simulator']); /** * Which app identity a build assumes. See docs/release/environments.md. * * development — dev-client builds; production identity + dev icon * sandbox — "Glide Beta", com.henrynelsonfirth.glide, personal accounts * production — "Glide", com.h14h.glide, LLC accounts * * GLIDE_APP_VARIANT must be set consistently in the matching EAS environment * (preview → sandbox, production → production) so that workflow fingerprint * jobs compute the same hash the build does. */ const PROFILE_VARIANTS = { simulator: 'development', development: 'development', sandbox: 'sandbox', production: 'production', }; const SANDBOX_BUNDLE_ID = 'com.henrynelsonfirth.glide'; module.exports = ({ config }) => { const profile = process.env.EAS_BUILD_PROFILE; const variant = process.env.GLIDE_APP_VARIANT ?? PROFILE_VARIANTS[profile] ?? 'production'; if (profile === 'production') validateProductionEnvironment(); if (variant === 'sandbox') return sandboxConfig(config); const useDevIcon = DEV_ICON_PROFILES.has(profile) || process.env.GLIDE_DEV_ICON === '1'; return useDevIcon ? withDevIcon(config) : config; }; /** * The sandbox app is a separate app with its own permanent identity, published * from the personal developer accounts. Its bundle/package IDs are as permanent * as production's: testers' local-first data lives in the container keyed to them. */ function sandboxConfig(config) { const base = withDevIcon(config); return { ...base, name: 'Glide Beta', ios: { ...base.ios, bundleIdentifier: SANDBOX_BUNDLE_ID, }, android: { ...base.android, package: SANDBOX_BUNDLE_ID, }, plugins: (base.plugins ?? []).map((plugin) => { if (!Array.isArray(plugin) || plugin[0] !== 'expo-widgets') return plugin; return [ 'expo-widgets', { ...plugin[1], bundleIdentifier: `${SANDBOX_BUNDLE_ID}.widgets`, groupIdentifier: `group.${SANDBOX_BUNDLE_ID}`, }, ]; }), }; } function withDevIcon(config) { return { ...config, icon: './assets/images/icon-dev.png', ios: { ...config.ios, icon: './assets/images/icon-dev.png', }, android: { ...config.android, icon: './assets/images/icon-dev.png', adaptiveIcon: { ...config.android?.adaptiveIcon, foregroundImage: './assets/images/android-icon-foreground-dev.png', monochromeImage: './assets/images/android-icon-monochrome-dev.png', }, }, }; } function validateProductionEnvironment() { const required = [ 'EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY', 'EXPO_PUBLIC_CONVEX_URL', 'EXPO_PUBLIC_CONVEX_SITE_URL', 'EXPO_PUBLIC_REVENUECAT_KEY', ]; const missing = required.filter((name) => !process.env[name]); if (missing.length > 0) { throw new Error(`Production build is missing: ${missing.join(', ')}`); } if (!process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY.startsWith('pk_live_')) { throw new Error('Production builds require a live Clerk publishable key (pk_live_…).'); } if (process.env.EXPO_PUBLIC_FREE_SYNC === '1') { throw new Error('EXPO_PUBLIC_FREE_SYNC is sandbox-only and must not be set in production builds.'); } const revenueCatKey = process.env.EXPO_PUBLIC_REVENUECAT_KEY; const platform = process.env.EAS_BUILD_PLATFORM; const validRevenueCatKey = platform === 'android' ? revenueCatKey.startsWith('goog_') : platform === 'ios' ? revenueCatKey.startsWith('appl_') : revenueCatKey.startsWith('appl_') || revenueCatKey.startsWith('goog_'); if (!validRevenueCatKey) { throw new Error( platform === 'android' ? 'Android production builds require a RevenueCat Google Play key (goog_…).' : 'iOS production builds require a RevenueCat App Store key (appl_…).' ); } }