xref: /expo/home/utils/Environment.ts (revision dfd15ebd)
1import Constants from 'expo-constants';
2import { Platform } from 'react-native';
3import semver from 'semver';
4
5import * as Kernel from '../kernel/Kernel';
6
7const PRODUCTION_EXPONENT_HOME_PROJECT_ID = '6b6c6660-df76-11e6-b9b4-59d1587e6774';
8
9const isProductionClassicManifest =
10  (Constants.manifest?.originalFullName === '@exponent/home' ||
11    Constants.manifest?.id === '@exponent/home' ||
12    Constants.manifest?.projectId === PRODUCTION_EXPONENT_HOME_PROJECT_ID) &&
13  Constants.manifest?.publishedTime;
14
15const isProductionManifest =
16  Constants.manifest2?.extra?.eas?.projectId === PRODUCTION_EXPONENT_HOME_PROJECT_ID &&
17  !Constants.manifest2.extra.expoGo;
18
19const isProduction = isProductionClassicManifest || isProductionManifest;
20
21const IOSClientReleaseType = Kernel.iosClientReleaseType;
22
23const IsIOSRestrictedBuild =
24  Platform.OS === 'ios' &&
25  Kernel.iosClientReleaseType === Kernel.ExpoClientReleaseType.APPLE_APP_STORE;
26
27const SupportedExpoSdks = Constants.supportedExpoSdks || [];
28
29// Constants.supportedExpoSdks is not guaranteed to be sorted!
30const sortedSupportedExpoSdks = SupportedExpoSdks.sort();
31
32let lowestSupportedSdkVersion: number = -1;
33
34if (SupportedExpoSdks.length > 0) {
35  lowestSupportedSdkVersion = semver.major(sortedSupportedExpoSdks[0]);
36}
37
38const supportedSdksString = `SDK${
39  SupportedExpoSdks.length === 1 ? ':' : 's:'
40} ${sortedSupportedExpoSdks.map((sdk) => semver.major(sdk)).join(', ')}`;
41
42export default {
43  isProduction,
44  IOSClientReleaseType,
45  IsIOSRestrictedBuild,
46  lowestSupportedSdkVersion,
47  supportedSdksString,
48};
49