Skip to content

Commit 1b40c1c

Browse files
authored
[eas-cli] Raise threshold for "big tarball" warning (#2878)
<!-- If this PR requires a changelog entry, add it by commenting the PR with the command `/changelog-entry [breaking-change|new-feature|bug-fix|chore] [message]`. --> <!-- You can skip the changelog check by labeling the PR with "no changelog". --> # Why Adding `.git` directory to the tarball makes it bigger. Users notice this warning and want it to be actionable, but currently adding `.git` to `.easignore` does nothing. # How For now, raise threshold for warning from 100 MiB to 150 MiB. In the next pull request I'm going to fix `.git` exclusion via `.easignore`. # Test Plan CI should pass.
1 parent 98344b8 commit 1b40c1c

File tree

3 files changed

+40
-28
lines changed

3 files changed

+40
-28
lines changed

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

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ import { collectMetadataAsync } from './metadata';
3535
import { printDeprecationWarnings } from './utils/printBuildInfo';
3636
import {
3737
LocalFile,
38+
assertProjectTarballSizeDoesNotExceedLimit,
3839
makeProjectMetadataFileAsync,
3940
makeProjectTarballAsync,
41+
maybeWarnAboutProjectTarballSize,
4042
reviewAndCommitChangesAsync,
4143
} from './utils/repository';
4244
import { BuildEvent } from '../analytics/AnalyticsManager';
@@ -275,19 +277,8 @@ async function uploadProjectAsync<TPlatform extends Platform>(
275277
);
276278
const projectTarball = await makeProjectTarballAsync(ctx.vcsClient);
277279

278-
if (projectTarball.size > 1024 * 1024 * 100) {
279-
Log.warn(
280-
`Your project archive is ${formatBytes(
281-
projectTarball.size
282-
)}. You can reduce its size and the time it takes to upload by excluding files that are unnecessary for the build process in ${chalk.bold(
283-
'.easignore'
284-
)} file. ${learnMore('https://expo.fyi/eas-build-archive')}`
285-
);
286-
}
287-
288-
if (projectTarball.size > 2 * 1024 * 1024 * 1024) {
289-
throw new Error('Project archive is too big. Maximum allowed size is 2GB.');
290-
}
280+
maybeWarnAboutProjectTarballSize(projectTarball.size);
281+
assertProjectTarballSizeDoesNotExceedLimit(projectTarball.size);
291282

292283
projectTarballPath = projectTarball.path;
293284
const [bucketKey, { metadataLocation }] = await Promise.all([

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import path from 'path';
44
import tar from 'tar';
55
import { v4 as uuidv4 } from 'uuid';
66

7-
import Log from '../../log';
7+
import Log, { learnMore } from '../../log';
88
import { ora } from '../../ora';
99
import { confirmAsync, promptAsync } from '../../prompts';
1010
import { formatBytes } from '../../utils/files';
@@ -169,6 +169,34 @@ export async function makeProjectTarballAsync(vcsClient: Client): Promise<LocalF
169169
return { size, path: tarPath };
170170
}
171171

172+
export function maybeWarnAboutProjectTarballSize(size: number): void {
173+
if (size <= 150 /* MiB */ * 1024 /* KiB */ * 1024 /* B */) {
174+
return;
175+
}
176+
177+
Log.warn(
178+
`Your project archive is ${formatBytes(
179+
size
180+
)}. You can reduce its size and the time it takes to upload by excluding files that are unnecessary for the build process in ${chalk.bold(
181+
'.easignore'
182+
)} file. ${learnMore('https://expo.fyi/eas-build-archive')}`
183+
);
184+
}
185+
186+
const MAX_ALLOWED_PROJECT_TARBALL_SIZE =
187+
2 /* GiB */ * 1024 /* MiB */ * 1024 /* KiB */ * 1024; /* B */
188+
export function assertProjectTarballSizeDoesNotExceedLimit(size: number): void {
189+
if (size <= MAX_ALLOWED_PROJECT_TARBALL_SIZE) {
190+
return;
191+
}
192+
193+
throw new Error(
194+
`Project archive is too big. Maximum allowed size is ${formatBytes(
195+
MAX_ALLOWED_PROJECT_TARBALL_SIZE
196+
)}.`
197+
);
198+
}
199+
172200
enum ShouldCommitChanges {
173201
Yes,
174202
ShowDiffFirst,

packages/eas-cli/src/project/uploadAccountScopedProjectSourceAsync.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import chalk from 'chalk';
22
import fs from 'node:fs';
33

4-
import { makeProjectTarballAsync } from '../build/utils/repository';
4+
import {
5+
assertProjectTarballSizeDoesNotExceedLimit,
6+
makeProjectTarballAsync,
7+
maybeWarnAboutProjectTarballSize,
8+
} from '../build/utils/repository';
59
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
610
import { AccountUploadSessionType } from '../graphql/generated';
711
import Log, { learnMore } from '../log';
@@ -36,19 +40,8 @@ export async function uploadAccountScopedProjectSourceAsync({
3640
const projectTarball = await makeProjectTarballAsync(vcsClient);
3741
projectTarballPath = projectTarball.path;
3842

39-
if (projectTarball.size > 1024 * 1024 * 100) {
40-
Log.warn(
41-
`Your project archive is ${formatBytes(
42-
projectTarball.size
43-
)}. You can reduce its size and the time it takes to upload by excluding files that are unnecessary for the build process in ${chalk.bold(
44-
'.easignore'
45-
)} file. ${learnMore('https://expo.fyi/eas-build-archive')}`
46-
);
47-
}
48-
49-
if (projectTarball.size > 2 * 1024 * 1024 * 1024) {
50-
throw new Error('Project archive is too big. Maximum allowed size is 2GB.');
51-
}
43+
maybeWarnAboutProjectTarballSize(projectTarball.size);
44+
assertProjectTarballSizeDoesNotExceedLimit(projectTarball.size);
5245

5346
const projectArchiveBucketKey = await uploadAccountScopedFileAtPathToGCSAsync(graphqlClient, {
5447
accountId,

0 commit comments

Comments
 (0)