Skip to content

Commit

Permalink
[eas-cli] Always refresh provisioning profile (#2125)
Browse files Browse the repository at this point in the history
* [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

* [eas-cli] Fix test

Added missing mock

See: https://exponent-internal.slack.com/archives/C9PRD479V/p1700236895524379
https://exponent-internal.slack.com/archives/C9PRD479V/p1700229660146479

* update CHANGELOG.md
  • Loading branch information
radoslawkrzemien authored Nov 20, 2023
1 parent 50d78b0 commit 1db76a1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 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

- 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import nullthrows from 'nullthrows';
import DeviceCreateAction, { RegistrationMethod } from '../../../devices/actions/create/action';
import {
AppleAppIdentifierFragment,
AppleDevice,
AppleDeviceFragment,
AppleDistributionCertificateFragment,
AppleProvisioningProfileFragment,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -202,8 +200,7 @@ export class SetUpAdhocProvisioningProfile {
provisioningProfileStoreInfo: ProvisioningProfile,
ctx: CredentialsContext,
app: AppLookupParams,
appleAppIdentifier: AppleAppIdentifierFragment,
chosenDevices: AppleDevice[]
appleAppIdentifier: AppleAppIdentifierFragment
): Promise<AppleProvisioningProfileFragment> {
if (
currentProvisioningProfile.developerPortalIdentifier !==
Expand All @@ -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,
Expand All @@ -234,9 +229,6 @@ export class SetUpAdhocProvisioningProfile {
developerPortalIdentifier: provisioningProfileStoreInfo.provisioningProfileId,
}
);
} else {
// Otherwise the current profile can be reused
return currentProvisioningProfile;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 1db76a1

Please sign in to comment.