11import { Workflow } from '@expo/eas-build-job' ;
22import chalk from 'chalk' ;
33import getenv from 'getenv' ;
4- import resolveFrom from 'resolve-from' ;
54
65import { resolveWorkflowPerPlatformAsync } from './workflow' ;
6+ import { isExpoDevClientInstalled } from '../build/utils/devClient' ;
77import Log , { learnMore } from '../log' ;
88import type { ProfileData } from '../utils/profiles' ;
99import type { Client } from '../vcs/vcs' ;
1010
1111const suppressionEnvVarName = 'EAS_BUILD_NO_EXPO_GO_WARNING' ;
1212
13- export const discourageExpoGoForProd = (
13+ export async function discourageExpoGoForProdAsync (
1414 buildProfiles : ProfileData < 'build' > [ ] | undefined ,
1515 projectDir : string ,
1616 vcsClient : Client
17- ) : void => {
18- detectExpoGoProdBuildAsync ( buildProfiles , projectDir , vcsClient )
19- . then ( usesExpoGo => {
20- if ( usesExpoGo ) {
21- Log . newLine ( ) ;
22- Log . warn (
23- `⚠️ It appears you're trying to build an app based on Expo Go for production. Expo Go is not a suitable environment for production apps.`
24- ) ;
25- Log . warn (
26- learnMore ( 'https://docs.expo.dev/develop/development-builds/expo-go-to-dev-build/' , {
27- learnMoreMessage : 'Learn more about converting from Expo Go to a development build' ,
28- dim : false ,
29- } )
30- ) ;
31- Log . warn (
32- chalk . dim ( `To suppress this warning, set ${ chalk . bold ( `${ suppressionEnvVarName } =true` ) } .` )
33- ) ;
34- Log . newLine ( ) ;
35- }
36- } )
37- . catch ( err => {
38- Log . warn ( 'Error detecting whether Expo Go is used:' , err ) ;
39- } ) ;
40- } ;
17+ ) : Promise < void > {
18+ try {
19+ const isExpoGoProdBuild = await detectExpoGoProdBuildAsync (
20+ buildProfiles ,
21+ projectDir ,
22+ vcsClient
23+ ) ;
24+ if ( ! isExpoGoProdBuild ) {
25+ return ;
26+ }
27+ Log . newLine ( ) ;
28+ Log . warn (
29+ `⚠️ It appears you're trying to build an app based on Expo Go for production. Expo Go is not a suitable environment for production apps.`
30+ ) ;
31+ Log . warn (
32+ learnMore ( 'https://docs.expo.dev/develop/development-builds/expo-go-to-dev-build/' , {
33+ learnMoreMessage : 'Learn more about converting from Expo Go to a development build' ,
34+ dim : false ,
35+ } )
36+ ) ;
37+ Log . warn (
38+ chalk . dim ( `To suppress this warning, set ${ chalk . bold ( `${ suppressionEnvVarName } =true` ) } .` )
39+ ) ;
40+ Log . newLine ( ) ;
41+ } catch ( err ) {
42+ Log . warn ( 'Error detecting whether Expo Go is used:' , err ) ;
43+ }
44+ }
4145
4246export async function detectExpoGoProdBuildAsync (
4347 buildProfiles : ProfileData < 'build' > [ ] | undefined ,
@@ -51,7 +55,7 @@ export async function detectExpoGoProdBuildAsync(
5155 return false ;
5256 }
5357
54- const hasExpoDevClient = checkIfExpoDevClientInstalled ( projectDir ) ;
58+ const hasExpoDevClient = isExpoDevClientInstalled ( projectDir ) ;
5559 if ( hasExpoDevClient ) {
5660 return false ;
5761 }
@@ -67,7 +71,3 @@ async function checkIfManagedWorkflowAsync(
6771
6872 return workflows . android === Workflow . MANAGED && workflows . ios === Workflow . MANAGED ;
6973}
70-
71- function checkIfExpoDevClientInstalled ( projectDir : string ) : boolean {
72- return resolveFrom . silent ( projectDir , 'expo-dev-client/package.json' ) !== undefined ;
73- }
0 commit comments