Skip to content

Commit 0bd94bb

Browse files
committed
address review
1 parent 9107eb9 commit 0bd94bb

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed
Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
import { Workflow } from '@expo/eas-build-job';
22
import chalk from 'chalk';
33
import getenv from 'getenv';
4-
import resolveFrom from 'resolve-from';
54

65
import { resolveWorkflowPerPlatformAsync } from './workflow';
6+
import { isExpoDevClientInstalled } from '../build/utils/devClient';
77
import Log, { learnMore } from '../log';
88
import type { ProfileData } from '../utils/profiles';
99
import type { Client } from '../vcs/vcs';
1010

1111
const 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 usesExpoGo = await detectExpoGoProdBuildAsync(buildProfiles, projectDir, vcsClient);
20+
if (!usesExpoGo) {
21+
return;
22+
}
23+
Log.newLine();
24+
Log.warn(
25+
`⚠️ 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.`
26+
);
27+
Log.warn(
28+
learnMore('https://docs.expo.dev/develop/development-builds/expo-go-to-dev-build/', {
29+
learnMoreMessage: 'Learn more about converting from Expo Go to a development build',
30+
dim: false,
31+
})
32+
);
33+
Log.warn(
34+
chalk.dim(`To suppress this warning, set ${chalk.bold(`${suppressionEnvVarName}=true`)}.`)
35+
);
36+
Log.newLine();
37+
} catch (err) {
38+
Log.warn('Error detecting whether Expo Go is used:', err);
39+
}
40+
}
4141

4242
export async function detectExpoGoProdBuildAsync(
4343
buildProfiles: ProfileData<'build'>[] | undefined,
@@ -51,7 +51,7 @@ export async function detectExpoGoProdBuildAsync(
5151
return false;
5252
}
5353

54-
const hasExpoDevClient = checkIfExpoDevClientInstalled(projectDir);
54+
const hasExpoDevClient = isExpoDevClientInstalled(projectDir);
5555
if (hasExpoDevClient) {
5656
return false;
5757
}
@@ -67,7 +67,3 @@ async function checkIfManagedWorkflowAsync(
6767

6868
return workflows.android === Workflow.MANAGED && workflows.ios === Workflow.MANAGED;
6969
}
70-
71-
function checkIfExpoDevClientInstalled(projectDir: string): boolean {
72-
return resolveFrom.silent(projectDir, 'expo-dev-client/package.json') !== undefined;
73-
}

0 commit comments

Comments
 (0)