Skip to content

Commit 6b3940a

Browse files
committed
address review
1 parent 9107eb9 commit 6b3940a

File tree

4 files changed

+41
-38
lines changed

4 files changed

+41
-38
lines changed

packages/eas-cli/src/build/runBuildAndSubmit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import {
4949
CustomBuildConfigMetadata,
5050
validateCustomBuildConfigAsync,
5151
} from '../project/customBuildConfig';
52-
import { discourageExpoGoForProd } from '../project/discourageExpoGoForProd';
52+
import { discourageExpoGoForProdAsync } from '../project/discourageExpoGoForProd';
5353
import { checkExpoSdkIsSupportedAsync } from '../project/expoSdk';
5454
import { validateMetroConfigForManagedWorkflowAsync } from '../project/metroConfig';
5555
import {
@@ -147,7 +147,7 @@ export async function runBuildAndSubmitAsync({
147147
projectDir,
148148
});
149149

150-
discourageExpoGoForProd(buildProfiles, projectDir, vcsClient);
150+
await discourageExpoGoForProdAsync(buildProfiles, projectDir, vcsClient);
151151

152152
for (const buildProfile of buildProfiles) {
153153
if (buildProfile.profile.image && ['default', 'stable'].includes(buildProfile.profile.image)) {

packages/eas-cli/src/build/utils/devClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export async function ensureExpoDevClientInstalledForDevClientBuildsAsync({
2424
nonInteractive?: boolean;
2525
buildProfiles?: ProfileData<'build'>[];
2626
}): Promise<void> {
27-
if (await isExpoDevClientInstalledAsync(projectDir)) {
27+
if (isExpoDevClientInstalled(projectDir)) {
2828
return;
2929
}
3030

@@ -103,7 +103,7 @@ export async function ensureExpoDevClientInstalledForDevClientBuildsAsync({
103103
}
104104
}
105105

106-
async function isExpoDevClientInstalledAsync(projectDir: string): Promise<boolean> {
106+
export function isExpoDevClientInstalled(projectDir: string): boolean {
107107
try {
108108
resolveFrom(projectDir, 'expo-dev-client/package.json');
109109
return true;

packages/eas-cli/src/project/__tests__/discourageExpoGoForProd-test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import resolveFrom from 'resolve-from';
44

55
import type { ProfileData } from '../../utils/profiles';
66
import { resolveVcsClient } from '../../vcs';
7-
import { detectExpoGoProdBuildAsync } from '../discourageExpoGoForProd';
7+
import { detectExpoGoProdBuildAsync } from '../discourageExpoGoForProdAsync';
88

99
jest.mock('getenv');
1010
jest.mock('resolve-from');
@@ -29,7 +29,10 @@ describe(detectExpoGoProdBuildAsync, () => {
2929
beforeEach(() => {
3030
jest.clearAllMocks();
3131
jest.mocked(getenv.boolish).mockReturnValue(false);
32-
jest.mocked(resolveFrom.silent).mockReturnValue(undefined); // expo-dev-client is not installed
32+
jest.mocked(resolveFrom).mockImplementation(() => {
33+
// expo-dev-client is not installed
34+
throw new Error('Module not found');
35+
});
3336
});
3437

3538
describe('should return false', () => {
@@ -45,7 +48,7 @@ describe(detectExpoGoProdBuildAsync, () => {
4548
});
4649

4750
it('when expo-dev-client is installed - that signals a development build', async () => {
48-
jest.mocked(resolveFrom.silent).mockReturnValue('/path/to/expo-dev-client/package.json');
51+
jest.mocked(resolveFrom).mockReturnValue('/path/to/expo-dev-client/package.json');
4952
const buildProfiles = [createMockBuildProfile('production')];
5053

5154
const result = await detectExpoGoProdBuildAsync(buildProfiles, projectDir, vcsClient);
Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,47 @@
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 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

4246
export 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

Comments
 (0)