Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/capability-sync-keeps-linked-identifiers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eas-cli': patch
---

Keep already linked App Groups, Merchant IDs and iCloud containers when capability sync links another identifier.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,35 @@ describe(syncCapabilityIdentifiersForEntitlementsAsync, () => {
expect(bundleId.updateBundleIdCapabilityAsync).toHaveBeenCalledTimes(1);
});

it(`keeps already linked capability identifiers when linking another one`, async () => {
const Apple = require('@expo/apple-utils');
mockCapabilities(Apple);
const bundleId = {
context: {},
updateBundleIdCapabilityAsync: jest.fn(),
id: 'XXX',
} as any;

const result = await syncCapabilityIdentifiersForEntitlementsAsync(bundleId, {
'com.apple.security.application-groups': ['group.expo', 'group.bacon'],
});

expect(result).toStrictEqual({
created: ['group.bacon'],
linked: ['group.bacon'],
});
expect(bundleId.updateBundleIdCapabilityAsync).toHaveBeenCalledTimes(1);
expect(bundleId.updateBundleIdCapabilityAsync).toHaveBeenLastCalledWith([
{
capabilityType: 'APP_GROUPS',
option: 'ON',
relationships: {
appGroups: ['XXX-group-1', 'XXX-group-2'],
},
},
]);
});

it(`doesn't perform duplicate CapabilityModel.getAsync calls`, async () => {
const Apple = require('@expo/apple-utils');
mockCapabilities(Apple);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export async function syncCapabilityIdentifiersForEntitlementsAsync(
(remoteLinkedIds?.[CapabilityModel.type] ?? []).map(model => model.id)
);

// A list of server IDs for linking.
// A list of server IDs for linking. The update replaces the linked identifiers,
// so this includes the ones that are already linked.
const capabilityIdOpaqueIds: string[] = [];

// Iterate through all the local IDs and see if they exist on the server.
Expand All @@ -106,8 +107,8 @@ export async function syncCapabilityIdentifiersForEntitlementsAsync(
if (!alreadyLinkedOpaqueIds.has(remoteIdModel.id)) {
// Link the existing identifier to this bundle.
linkedIds.push(remoteIdModel.attributes.identifier);
capabilityIdOpaqueIds.push(remoteIdModel.id);
}
capabilityIdOpaqueIds.push(remoteIdModel.id);
continue;
}

Expand All @@ -133,7 +134,7 @@ export async function syncCapabilityIdentifiersForEntitlementsAsync(
capabilityIdOpaqueIds.push(remoteIdModel.id);
}

if (capabilityIdOpaqueIds.length) {
if (capabilityIdOpaqueIds.some(id => !alreadyLinkedOpaqueIds.has(id))) {
updateRequest.push({
capabilityType: classifier.capability,
option: CapabilityTypeOption.ON,
Expand Down
Loading