From eb8f748c657557aeb7e51ba2317c6e6d3cd9c9a8 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 17 Nov 2023 17:44:04 +0100 Subject: [PATCH 1/3] [eas-cli] Always refresh provisioning profile There are other cases when the provisioning profile needs to be refreshed before use and which cannot be easily validated at runtime without bigger changes in the code. It is simpler (at least for the time being) to just refresh existing profile each time See: https://exponent-internal.slack.com/archives/C9PRD479V/p1700236895524379 https://exponent-internal.slack.com/archives/C9PRD479V/p1700229660146479 --- .../actions/SetUpAdhocProvisioningProfile.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/eas-cli/src/credentials/ios/actions/SetUpAdhocProvisioningProfile.ts b/packages/eas-cli/src/credentials/ios/actions/SetUpAdhocProvisioningProfile.ts index f6ef7ca2c9..37e975489b 100644 --- a/packages/eas-cli/src/credentials/ios/actions/SetUpAdhocProvisioningProfile.ts +++ b/packages/eas-cli/src/credentials/ios/actions/SetUpAdhocProvisioningProfile.ts @@ -6,7 +6,6 @@ import nullthrows from 'nullthrows'; import DeviceCreateAction, { RegistrationMethod } from '../../../devices/actions/create/action'; import { AppleAppIdentifierFragment, - AppleDevice, AppleDeviceFragment, AppleDistributionCertificateFragment, AppleProvisioningProfileFragment, @@ -147,15 +146,14 @@ export class SetUpAdhocProvisioningProfile { app, appleTeam ); - let appleProvisioningProfile: AppleProvisioningProfileFragment | null = null; + let appleProvisioningProfile: AppleProvisioningProfileFragment | null; if (currentBuildCredentials?.provisioningProfile) { appleProvisioningProfile = await this.reuseCurrentProvisioningProfileAsync( currentBuildCredentials.provisioningProfile, provisioningProfileStoreInfo, ctx, app, - appleAppIdentifier, - chosenDevices + appleAppIdentifier ); } else { appleProvisioningProfile = await ctx.ios.createProvisioningProfileAsync( @@ -202,8 +200,7 @@ export class SetUpAdhocProvisioningProfile { provisioningProfileStoreInfo: ProvisioningProfile, ctx: CredentialsContext, app: AppLookupParams, - appleAppIdentifier: AppleAppIdentifierFragment, - chosenDevices: AppleDevice[] + appleAppIdentifier: AppleAppIdentifierFragment ): Promise { if ( currentProvisioningProfile.developerPortalIdentifier !== @@ -222,10 +219,8 @@ export class SetUpAdhocProvisioningProfile { developerPortalIdentifier: provisioningProfileStoreInfo.provisioningProfileId, } ); - } else if ( - differenceBy(chosenDevices, currentProvisioningProfile.appleDevices, 'identifier').length > 0 - ) { - // If IDs match, but the devices lists don't, the profile needs to be updated first + } else { + // If not, the profile needs to be updated first return await ctx.ios.updateProvisioningProfileAsync( ctx.graphqlClient, currentProvisioningProfile.id, @@ -234,9 +229,6 @@ export class SetUpAdhocProvisioningProfile { developerPortalIdentifier: provisioningProfileStoreInfo.provisioningProfileId, } ); - } else { - // Otherwise the current profile can be reused - return currentProvisioningProfile; } } From 476ba177fcf3f054f9a75630dd491d2a0f1eaedf Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 17 Nov 2023 17:45:56 +0100 Subject: [PATCH 2/3] [eas-cli] Fix test Added missing mock See: https://exponent-internal.slack.com/archives/C9PRD479V/p1700236895524379 https://exponent-internal.slack.com/archives/C9PRD479V/p1700229660146479 --- .../actions/__tests__/SetUpAdhocProvisioningProfile-test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/eas-cli/src/credentials/ios/actions/__tests__/SetUpAdhocProvisioningProfile-test.ts b/packages/eas-cli/src/credentials/ios/actions/__tests__/SetUpAdhocProvisioningProfile-test.ts index 40f623385c..bbdf4e32cb 100644 --- a/packages/eas-cli/src/credentials/ios/actions/__tests__/SetUpAdhocProvisioningProfile-test.ts +++ b/packages/eas-cli/src/credentials/ios/actions/__tests__/SetUpAdhocProvisioningProfile-test.ts @@ -126,6 +126,11 @@ describe('runWithDistributionCertificateAsync', () => { developerPortalIdentifier: 'provisioningProfileId', }, } as IosAppBuildCredentialsFragment); + ctx.ios.updateProvisioningProfileAsync = jest.fn().mockResolvedValue({ + appleTeam: {}, + appleDevices: [{ identifier: 'id1' }, { identifier: 'id2' }, { identifier: 'id3' }], + developerPortalIdentifier: 'provisioningProfileId', + }); const LogWarnSpy = jest.spyOn(Log, 'warn'); const LogLogSpy = jest.spyOn(Log, 'log'); const result = await setUpAdhocProvisioningProfile.runWithDistributionCertificateAsync( From 8b80b3afdb03ad70caac98713ceb214dc6be7da1 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 17 Nov 2023 16:54:59 +0000 Subject: [PATCH 3/3] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42c5826b33..8251bd1ea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This is the log of notable changes to EAS CLI and related packages. ### ๐Ÿ› Bug fixes - Don't ask a user to install the dev client if running in non-interactive mode. ([#2124](https://github.com/expo/eas-cli/pull/2124) by [@szdziedzic](https://github.com/szdziedzic)) +- Always refresh existing provisioning profile before use. ([#2125](https://github.com/expo/eas-cli/pull/2125) by [@radoslawkrzemien](https://github.com/radoslawkrzemien)) ### ๐Ÿงน Chores