|
| 1 | +import { ExpoConfig } from "@expo/config-types"; |
| 2 | + |
| 3 | +import { version } from "./package.json"; |
| 4 | + |
| 5 | +// Project constants |
| 6 | +const EAS_PROJECT_ID = "012accc3-4ce5-4bae-9f4d-2f842489f07a"; |
| 7 | +const PROJECT_SLUG = "spacecraft"; |
| 8 | +const OWNER = "weshipit"; |
| 9 | + |
| 10 | +// App production config |
| 11 | +const APP_NAME = "Spacecraft"; |
| 12 | +const BUNDLE_IDENTIFIER = "weshipit.today.spacecraft"; |
| 13 | +const PACKAGE_NAME = "weshipit.today.spacecraft"; |
| 14 | +const SCHEME = "spacecraft"; |
| 15 | + |
| 16 | +export default ({ config }: { config: ExpoConfig }): ExpoConfig => { |
| 17 | + const environment = process.env.APP_ENV || "development"; |
| 18 | + console.log("⚙️ Building app for environment:", environment); |
| 19 | + |
| 20 | + const { adaptiveIcon, bundleIdentifier, icon, name, packageName, scheme } = |
| 21 | + getDynamicAppConfig( |
| 22 | + environment as "development" | "preview" | "production", |
| 23 | + ); |
| 24 | + |
| 25 | + return { |
| 26 | + ...config, |
| 27 | + android: { |
| 28 | + adaptiveIcon: { |
| 29 | + backgroundColor: "#ffffff", |
| 30 | + foregroundImage: adaptiveIcon, |
| 31 | + }, |
| 32 | + package: packageName, |
| 33 | + playStoreUrl: |
| 34 | + "https://play.google.com/store/apps/details?id=weshipit.today.spacecraft", |
| 35 | + }, |
| 36 | + extra: { |
| 37 | + eas: { |
| 38 | + projectId: EAS_PROJECT_ID, |
| 39 | + }, |
| 40 | + storybookEnabled: process.env.STORYBOOK_ENABLED, |
| 41 | + }, |
| 42 | + icon: icon, |
| 43 | + ios: { |
| 44 | + appStoreUrl: |
| 45 | + "https://apps.apple.com/fr/app/retail-shake-scanner/id1234567890", |
| 46 | + bundleIdentifier: bundleIdentifier, |
| 47 | + supportsTablet: true, |
| 48 | + }, |
| 49 | + name: name, |
| 50 | + newArchEnabled: true, |
| 51 | + orientation: "portrait", |
| 52 | + owner: OWNER, |
| 53 | + plugins: [ |
| 54 | + [ |
| 55 | + "app-icon-badge", |
| 56 | + { |
| 57 | + badges: [ |
| 58 | + { |
| 59 | + background: "#FF0000", |
| 60 | + color: "white", |
| 61 | + text: environment, |
| 62 | + type: "banner", |
| 63 | + }, |
| 64 | + { |
| 65 | + text: version, |
| 66 | + type: "ribbon", |
| 67 | + }, |
| 68 | + ], |
| 69 | + enabled: environment !== "production", |
| 70 | + }, |
| 71 | + ], |
| 72 | + ], |
| 73 | + runtimeVersion: { |
| 74 | + policy: "appVersion", |
| 75 | + }, |
| 76 | + scheme: scheme, |
| 77 | + slug: PROJECT_SLUG, |
| 78 | + splash: { |
| 79 | + backgroundColor: "#ffffff", |
| 80 | + image: "./assets/splash.png", |
| 81 | + resizeMode: "contain", |
| 82 | + }, |
| 83 | + updates: { |
| 84 | + fallbackToCacheTimeout: 0, |
| 85 | + url: `https://u.expo.dev/${EAS_PROJECT_ID}`, |
| 86 | + }, |
| 87 | + userInterfaceStyle: "automatic", |
| 88 | + version, |
| 89 | + web: { |
| 90 | + bundler: "metro", |
| 91 | + favicon: "./assets/favicon.png", |
| 92 | + output: "static", |
| 93 | + }, |
| 94 | + }; |
| 95 | +}; |
| 96 | + |
| 97 | +// Dynamically configure the app based on the environment |
| 98 | +export const getDynamicAppConfig = ( |
| 99 | + environment: "development" | "preview" | "production", |
| 100 | +) => { |
| 101 | + if (environment === "production") { |
| 102 | + return { |
| 103 | + adaptiveIcon: "./assets/adaptive-icon.png", |
| 104 | + bundleIdentifier: BUNDLE_IDENTIFIER, |
| 105 | + icon: "./assets/icon.png", |
| 106 | + name: APP_NAME, |
| 107 | + packageName: PACKAGE_NAME, |
| 108 | + scheme: SCHEME, |
| 109 | + }; |
| 110 | + } |
| 111 | + |
| 112 | + if (environment === "preview") { |
| 113 | + return { |
| 114 | + adaptiveIcon: "./assets/adaptive-icon-preview.png", |
| 115 | + bundleIdentifier: `${BUNDLE_IDENTIFIER}.preview`, |
| 116 | + icon: "./assets/icon-preview.png", |
| 117 | + name: `${APP_NAME} Preview`, |
| 118 | + packageName: `${PACKAGE_NAME}.preview`, |
| 119 | + scheme: `${SCHEME}-prev`, |
| 120 | + }; |
| 121 | + } |
| 122 | + |
| 123 | + return { |
| 124 | + adaptiveIcon: "./assets/adaptive-icon-dev.png", |
| 125 | + bundleIdentifier: `${BUNDLE_IDENTIFIER}.dev`, |
| 126 | + icon: "./assets/icon-dev.png", |
| 127 | + name: `${APP_NAME} Development`, |
| 128 | + packageName: `${PACKAGE_NAME}.dev`, |
| 129 | + scheme: `${SCHEME}-dev`, |
| 130 | + }; |
| 131 | +}; |
0 commit comments