Skip to content

Commit

Permalink
Fix expiration date check for build list source (#2406)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjchmiela authored Jun 4, 2024
1 parent a0606ad commit 3093691
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This is the log of notable changes to EAS CLI and related packages.
### 🐛 Bug fixes

- Use the correct app config for no GitHub flow in `init:onboarding`. ([#2397](https://github.com/expo/eas-cli/pull/2397) by [@szdziedzic](https://github.com/szdziedzic))
- Disallow picking expired builds as submit archive source. ([#2406](https://github.com/expo/eas-cli/pull/2406) by [@sjchmiela](https://github.com/sjchmiela))

### 🧹 Chores

Expand Down
10 changes: 4 additions & 6 deletions packages/eas-cli/src/submit/ArchiveSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ async function handleBuildListSourceAsync(
): Promise<ResolvedArchiveSource> {
try {
const appPlatform = toAppPlatform(ctx.platform);
const expiryDate = new Date(); // artifacts expire after 30 days
expiryDate.setDate(expiryDate.getDate() - 30);

const recentBuilds = await getRecentBuildsForSubmissionAsync(
ctx.graphqlClient,
Expand All @@ -294,7 +292,7 @@ async function handleBuildListSourceAsync(
});
}

if (recentBuilds.every(it => new Date(it.updatedAt) < expiryDate)) {
if (recentBuilds.every(it => new Date(it.expirationDate) <= new Date())) {
Log.error(
chalk.bold(
'It looks like all of your build artifacts have expired. ' +
Expand All @@ -306,7 +304,7 @@ async function handleBuildListSourceAsync(
});
}

const choices = recentBuilds.map(build => formatBuildChoice(build, expiryDate));
const choices = recentBuilds.map(build => formatBuildChoice(build));
choices.push({
title: 'None of the above (select another option)',
value: null,
Expand Down Expand Up @@ -336,7 +334,7 @@ async function handleBuildListSourceAsync(
}
}

function formatBuildChoice(build: BuildFragment, expiryDate: Date): prompts.Choice {
function formatBuildChoice(build: BuildFragment): prompts.Choice {
const {
id,
updatedAt,
Expand Down Expand Up @@ -380,7 +378,7 @@ function formatBuildChoice(build: BuildFragment, expiryDate: Date): prompts.Choi
title,
description: filteredDescriptionArray.length > 0 ? filteredDescriptionArray.join('\n') : '',
value: build,
disabled: buildDate < expiryDate,
disabled: new Date(build.expirationDate) < new Date(),
};
}

Expand Down
4 changes: 3 additions & 1 deletion packages/eas-cli/src/submit/__tests__/ArchiveSource-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ describe(getArchiveAsync, () => {
jest.mocked(getRecentBuildsForSubmissionAsync).mockResolvedValueOnce([
{
...MOCK_BUILD_FRAGMENT,
updatedAt: new Date(Date.now() - 31 * 24 * 3600 * 1000),
// We're setting expirationDate to be in the past,
// because we want to build to appear expired.
expirationDate: new Date(Date.now() - 31 * 24 * 3600 * 1000),
} as BuildFragment,
]);
jest
Expand Down

0 comments on commit 3093691

Please sign in to comment.