Skip to content

Commit 7d94c7b

Browse files
committed
update config to manage multiple envs
1 parent a68c497 commit 7d94c7b

File tree

6 files changed

+148
-73
lines changed

6 files changed

+148
-73
lines changed

β€Žapp.config.tsβ€Ž

Lines changed: 134 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,142 @@
1-
import { ExpoConfig } from 'expo/config';
1+
import { ConfigContext, ExpoConfig } from 'expo/config';
22

3-
const EXPO_PROJECT_ID = 'af6ae74c-f04d-497a-9733-b2b7539f77c5';
3+
// Replace these with your EAS project ID and project slug.
4+
// You can find them at https://expo.dev/accounts/[account]/projects/[project].
5+
const EAS_PROJECT_ID = 'af6ae74c-f04d-497a-9733-b2b7539f77c5';
6+
const PROJECT_SLUG = 'start-ui-native-v9iizxkbojzedvpfkfzcq';
7+
const OWNER = 'bearstudio';
48

5-
const appPrefix =
6-
process.env.EXPO_PUBLIC_ENVIRONMENT === 'storybook' ? 'Storybook β€’ ' : '';
9+
// App production config
10+
const APP_NAME = 'Start UI [native]';
11+
const BUNDLE_IDENTIFIER = 'com.bearstudio.startuinative';
12+
const PACKAGE_NAME = 'com.bearstudio.startuinative';
13+
const ICON = './src/assets/images/icon.png';
14+
const ADAPTIVE_ICON_FOREGROUND =
15+
'./src/assets/images/android-icon-foreground.png';
16+
const ADAPTIVE_ICON_MONOCHROME =
17+
'./src/assets/images/android-icon-monochrome.png';
18+
const SCHEME = 'start-ui-native';
719

8-
export default {
9-
name: appPrefix + 'Start UI [native]',
10-
slug: 'start-ui-native-v9iizxkbojzedvpfkfzcq',
11-
scheme: 'start-ui-native',
12-
owner: 'bearstudio',
13-
version: '1.0.0',
14-
runtimeVersion: {
15-
policy: 'appVersion',
16-
},
17-
platforms: ['android', 'ios'],
18-
orientation: 'default',
19-
icon: './src/assets/images/icon.png',
20-
userInterfaceStyle: 'automatic',
21-
backgroundColor: '#FFFFFF',
22-
experiments: {
23-
typedRoutes: true,
24-
reactCompiler: true,
25-
tsconfigPaths: true,
26-
},
27-
ios: {
28-
bundleIdentifier: 'com.bearstudio.startuinative',
29-
supportsTablet: true,
30-
infoPlist: {
31-
ITSAppUsesNonExemptEncryption: false,
20+
const expoConfig = ({ config }: ConfigContext) => {
21+
const { name, bundleIdentifier, icon, adaptiveIcon, packageName, scheme } =
22+
getDynamicAppConfig(process.env.APP_ENV);
23+
24+
return {
25+
...config,
26+
name,
27+
slug: PROJECT_SLUG,
28+
owner: OWNER,
29+
30+
scheme,
31+
version: '1.0.0',
32+
runtimeVersion: {
33+
policy: 'appVersion',
3234
},
33-
// appStoreUrl: 'https://apps.apple.com/fr/app/bearstudio/startuinative',
34-
},
35-
android: {
36-
package: 'com.bearstudio.startuinative',
37-
adaptiveIcon: {
38-
backgroundColor: '#FFFFFF',
39-
foregroundImage: './src/assets/images/android-icon-foreground.png',
40-
monochromeImage: './src/assets/images/android-icon-monochrome.png',
35+
platforms: ['android', 'ios'],
36+
orientation: 'default',
37+
icon,
38+
userInterfaceStyle: 'automatic',
39+
backgroundColor: '#FFFFFF',
40+
experiments: {
41+
typedRoutes: true,
42+
reactCompiler: true,
43+
tsconfigPaths: true,
4144
},
42-
edgeToEdgeEnabled: true,
43-
// playStoreUrl:
44-
// 'https://play.google.com/store/apps/details?id=com.bearstudio.startuinative',
45-
},
46-
plugins: [
47-
'expo-router',
48-
[
49-
'expo-splash-screen',
50-
{
51-
image: './src/assets/images/splash-icon-light.png',
52-
imageWidth: 200,
53-
resizeMode: 'contain',
54-
backgroundColor: '#ffffff',
55-
dark: {
56-
image: './src/assets/images/splash-icon-dark.png',
57-
backgroundColor: '#000000',
58-
},
45+
ios: {
46+
bundleIdentifier,
47+
supportsTablet: true,
48+
infoPlist: {
49+
ITSAppUsesNonExemptEncryption: false,
50+
},
51+
// appStoreUrl: 'https://apps.apple.com/fr/app/bearstudio/startuinative',
52+
},
53+
android: {
54+
package: packageName,
55+
adaptiveIcon: {
56+
...adaptiveIcon,
57+
backgroundColor: '#FFFFFF',
5958
},
59+
edgeToEdgeEnabled: true,
60+
// playStoreUrl:
61+
// 'https://play.google.com/store/apps/details?id=com.bearstudio.startuinative',
62+
},
63+
plugins: [
64+
'expo-router',
65+
[
66+
'expo-splash-screen',
67+
{
68+
image: './src/assets/images/splash-icon-light.png',
69+
imageWidth: 200,
70+
resizeMode: 'contain',
71+
backgroundColor: '#ffffff',
72+
dark: {
73+
image: './src/assets/images/splash-icon-dark.png',
74+
backgroundColor: '#000000',
75+
},
76+
},
77+
],
78+
'expo-web-browser',
79+
'expo-secure-store',
80+
'expo-localization',
81+
'expo-font',
6082
],
61-
'expo-web-browser',
62-
'expo-secure-store',
63-
'expo-localization',
64-
'expo-font',
65-
],
66-
githubUrl: 'https://github.com/bearstudio/start-ui-native',
67-
updates: {
68-
url: `https://u.expo.dev/${EXPO_PROJECT_ID}`,
69-
},
70-
extra: {
71-
isStorybook: process.env.EXPO_PUBLIC_ENVIRONMENT === 'storybook',
72-
eas: {
73-
projectId: EXPO_PROJECT_ID,
83+
githubUrl: 'https://github.com/bearstudio/start-ui-native',
84+
updates: {
85+
url: `https://u.expo.dev/${EAS_PROJECT_ID}`,
86+
},
87+
extra: {
88+
isStorybook: process.env.EXPO_PUBLIC_ENVIRONMENT === 'storybook',
89+
eas: {
90+
projectId: EAS_PROJECT_ID,
91+
},
7492
},
75-
},
76-
} as const satisfies ExpoConfig;
93+
} as const satisfies ExpoConfig;
94+
};
95+
96+
export const getDynamicAppConfig = (
97+
environment: 'development' | 'preview' | 'production'
98+
) => {
99+
switch (environment) {
100+
case 'development':
101+
return {
102+
name: `${APP_NAME} β€’ DEV`,
103+
bundleIdentifier: `${BUNDLE_IDENTIFIER}.dev`,
104+
packageName: `${PACKAGE_NAME}.dev`,
105+
icon: ICON,
106+
adaptiveIcon: {
107+
foregroundImage: ADAPTIVE_ICON_FOREGROUND,
108+
monochromeImage: ADAPTIVE_ICON_MONOCHROME,
109+
},
110+
scheme: `${SCHEME}-dev`,
111+
};
112+
113+
case 'preview':
114+
return {
115+
name: `${APP_NAME} β€’ PREVIEW`,
116+
bundleIdentifier: `${BUNDLE_IDENTIFIER}.preview`,
117+
packageName: `${PACKAGE_NAME}.preview`,
118+
icon: ICON,
119+
adaptiveIcon: {
120+
foregroundImage: ADAPTIVE_ICON_FOREGROUND,
121+
monochromeImage: ADAPTIVE_ICON_MONOCHROME,
122+
},
123+
scheme: `${SCHEME}-preview`,
124+
};
125+
126+
case 'production':
127+
default:
128+
return {
129+
name: APP_NAME,
130+
bundleIdentifier: BUNDLE_IDENTIFIER,
131+
packageName: PACKAGE_NAME,
132+
icon: ICON,
133+
adaptiveIcon: {
134+
foregroundImage: ADAPTIVE_ICON_FOREGROUND,
135+
monochromeImage: ADAPTIVE_ICON_MONOCHROME,
136+
},
137+
scheme: SCHEME,
138+
};
139+
}
140+
};
141+
142+
export default expoConfig;

β€Žsrc/constants/config.tsβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import expoConfig from 'app.config';
2+
import Constants from 'expo-constants';
3+
4+
if (!Constants.expoConfig) {
5+
throw new Error('Expo config not found');
6+
}
7+
8+
export const appConfig = Constants.expoConfig as ReturnType<typeof expoConfig>;

β€Žsrc/features/auth/client.tsβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { expoClient } from '@better-auth/expo/client';
2-
import appConfig from 'app.config';
32
import {
43
emailOTPClient,
54
inferAdditionalFields,
65
} from 'better-auth/client/plugins';
76
import { createAuthClient } from 'better-auth/react';
87
import * as SecureStore from 'expo-secure-store';
98

9+
import { appConfig } from '@/constants/config';
10+
1011
const authBaseURL: string =
1112
process.env.EXPO_PUBLIC_AUTH_URL ??
1213
`${process.env.EXPO_PUBLIC_BASE_URL}/api/auth`;

β€Žsrc/features/auth/view-sign-in.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useMutation } from '@tanstack/react-query';
2-
import appConfig from 'app.config';
32
import { useRouter } from 'expo-router';
43
import { useTranslation } from 'react-i18next';
54
import { Center, HStack, Stack, Text } from 'react-native-ficus-ui';
@@ -12,6 +11,7 @@ import { useAppForm } from '@/lib/tanstack-form/config';
1211

1312
import { Version } from '@/components/version';
1413

14+
import { appConfig } from '@/constants/config';
1515
import { AuthHeader } from '@/features/auth/auth-header';
1616
import { authClient } from '@/features/auth/client';
1717
import { LoginEmailHint } from '@/features/devtools/login-hint';

β€Žsrc/features/home/view-home.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import appConfig from 'app.config';
21
import { Link } from 'expo-router';
32
import { useTranslation } from 'react-i18next';
43
import { Button, HStack, Stack, Text } from 'react-native-ficus-ui';
@@ -7,6 +6,7 @@ import { useShare } from '@/hooks/use-share';
76

87
import { IconShare2 } from '@/components/icons/generated';
98

9+
import { appConfig } from '@/constants/config';
1010
import { MarketingBento } from '@/features/marketing/marketing-bento';
1111
import { ViewTabContent } from '@/layout/view-tab-content';
1212

β€Žsrc/lib/ficus-ui/theme.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import appConfig from 'app.config';
2-
31
import components from '@/lib/ficus-ui/components';
42
import foundations from '@/lib/ficus-ui/foundations';
53

4+
import { appConfig } from '@/constants/config';
5+
66
export const STORAGE_KEY_THEME = `${appConfig.scheme}-theme`;
77

88
export default {

0 commit comments

Comments
Β (0)