Skip to content

Commit

Permalink
[eas-cli] skip creation of testflight group when there are already ex…
Browse files Browse the repository at this point in the history
…isitng testflight groups + allow to opt out of the behavior by setting env var (#2856)

* [eas-cli] skip creation of testflight group when there are already exisitng testflight groups + allow to opt out of the behavior by setting env var

* rename env var

* add changelog
  • Loading branch information
szdziedzic authored Feb 21, 2025
1 parent 6c7bae2 commit a1d4f26
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This is the log of notable changes to EAS CLI and related packages.

- Narrow amount of data queried for basic update channel operations. ([#2901](https://github.com/expo/eas-cli/pull/2901) by [@wschurman](https://github.com/wschurman))
- Fix `eas fingerprint:compare` description. ([#2908](https://github.com/expo/eas-cli/pull/2908) by [@quinlanj](https://github.com/quinlanj))
- Skip auto-creation of TestFlight group when there are already exisitng TestFlight groups and allow to opt out of the behavior by setting `EAS_NO_AUTO_TESTFLIGHT_SETUP` env var. ([#2856](https://github.com/expo/eas-cli/pull/2856) by [@szdziedzic](https://github.com/szdziedzic))

## [15.0.10](https://github.com/expo/eas-cli/releases/tag/v15.0.10) - 2025-02-11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,40 @@ const AUTO_GROUP_NAME = 'Team (Expo)';
* This allows users to instantly access their builds from TestFlight after it finishes processing.
*/
export async function ensureTestFlightGroupExistsAsync(app: App): Promise<void> {
const group = await ensureInternalGroupAsync(app);
const users = await User.getAsync(app.context);
const admins = users.filter(user => user.attributes.roles?.includes(UserRole.ADMIN));

await addAllUsersToInternalGroupAsync(group, admins);
}
if (process.env.EAS_NO_AUTO_TESTFLIGHT_SETUP) {
Log.debug('EAS_NO_AUTO_TESTFLIGHT_SETUP is set, skipping TestFlight setup');
return;
}

async function ensureInternalGroupAsync(app: App): Promise<BetaGroup> {
const groups = await app.getBetaGroupsAsync({
query: {
includes: ['betaTesters'],
},
});

if (groups.length > 0) {
Log.debug(`Found ${groups.length} TestFlight groups`);
Log.debug('Skipping creating a new TestFlight group');
return;
}

const group = await ensureInternalGroupAsync({
app,
groups,
});
const users = await User.getAsync(app.context);
const admins = users.filter(user => user.attributes.roles?.includes(UserRole.ADMIN));

await addAllUsersToInternalGroupAsync(group, admins);
}

async function ensureInternalGroupAsync({
groups,
app,
}: {
groups: BetaGroup[];
app: App;
}): Promise<BetaGroup> {
let betaGroup = groups.find(group => group.attributes.name === AUTO_GROUP_NAME);
if (!betaGroup) {
const spinner = ora().start('Creating TestFlight group...');
Expand Down Expand Up @@ -74,7 +94,14 @@ async function ensureInternalGroupAsync(app: App): Promise<BetaGroup> {
})
) {
await BetaGroup.deleteAsync(app.context, { id: betaGroup.id });
return await ensureInternalGroupAsync(app);
return await ensureInternalGroupAsync({
app,
groups: await app.getBetaGroupsAsync({
query: {
includes: ['betaTesters'],
},
}),
});
}
}

Expand Down

0 comments on commit a1d4f26

Please sign in to comment.