|
| 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: "https://apps.apple.com/fr/app/<compagny_name>/idxxxxxxxxx", |
| 45 | + bundleIdentifier: bundleIdentifier, |
| 46 | + supportsTablet: true, |
| 47 | + }, |
| 48 | + name: name, |
| 49 | + newArchEnabled: true, |
| 50 | + orientation: "portrait", |
| 51 | + owner: OWNER, |
| 52 | + plugins: [], |
| 53 | + runtimeVersion: { |
| 54 | + policy: "appVersion", |
| 55 | + }, |
| 56 | + scheme: scheme, |
| 57 | + slug: PROJECT_SLUG, |
| 58 | + splash: { |
| 59 | + backgroundColor: "#ffffff", |
| 60 | + image: "./assets/splash.png", |
| 61 | + resizeMode: "contain", |
| 62 | + }, |
| 63 | + updates: { |
| 64 | + fallbackToCacheTimeout: 0, |
| 65 | + url: `https://u.expo.dev/${EAS_PROJECT_ID}`, |
| 66 | + }, |
| 67 | + userInterfaceStyle: "automatic", |
| 68 | + version, |
| 69 | + web: { |
| 70 | + bundler: "metro", |
| 71 | + favicon: "./assets/favicon.png", |
| 72 | + output: "static", |
| 73 | + }, |
| 74 | + }; |
| 75 | +}; |
| 76 | + |
| 77 | +// Dynamically configure the app based on the environment |
| 78 | +export const getDynamicAppConfig = ( |
| 79 | + environment: "development" | "preview" | "production", |
| 80 | +) => { |
| 81 | + if (environment === "production") { |
| 82 | + return { |
| 83 | + adaptiveIcon: "./assets/adaptive-icon.png", |
| 84 | + bundleIdentifier: BUNDLE_IDENTIFIER, |
| 85 | + icon: "./assets/icon.png", |
| 86 | + name: APP_NAME, |
| 87 | + packageName: PACKAGE_NAME, |
| 88 | + scheme: SCHEME, |
| 89 | + }; |
| 90 | + } |
| 91 | + |
| 92 | + if (environment === "preview") { |
| 93 | + return { |
| 94 | + adaptiveIcon: "./assets/adaptive-icon-preview.png", |
| 95 | + bundleIdentifier: `${BUNDLE_IDENTIFIER}.preview`, |
| 96 | + icon: "./assets/icon-preview.png", |
| 97 | + name: `${APP_NAME} Preview`, |
| 98 | + packageName: `${PACKAGE_NAME}.preview`, |
| 99 | + scheme: `${SCHEME}-prev`, |
| 100 | + }; |
| 101 | + } |
| 102 | + |
| 103 | + return { |
| 104 | + adaptiveIcon: "./assets/adaptive-icon-dev.png", |
| 105 | + bundleIdentifier: `${BUNDLE_IDENTIFIER}.dev`, |
| 106 | + icon: "./assets/icon-dev.png", |
| 107 | + name: `${APP_NAME} Development`, |
| 108 | + packageName: `${PACKAGE_NAME}.dev`, |
| 109 | + scheme: `${SCHEME}-dev`, |
| 110 | + }; |
| 111 | +}; |
0 commit comments