Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add provisioningProfileType #2192

Draft
wants to merge 2 commits into
base: stanley/eng-10909-flag-to-skip-credentials-validation-step-in-eas-build
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Add provisioningProfileType
  • Loading branch information
sjchmiela committed Jan 19, 2024
commit 5c710eb4789fe09922a1084752edb67f3990d2fe
4 changes: 4 additions & 0 deletions packages/eas-cli/src/credentials/credentialsJson/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ async function readCredentialsForTargetAsync(
getAbsolutePath(projectDir, targetCredentials.provisioningProfilePath),
'base64'
),
provisioningProfileType:
path.extname(targetCredentials.provisioningProfilePath) === 'provisionprofile'
? Ios.ProvisioningProfileType.PROVISIONPROFILE
: Ios.ProvisioningProfileType.MOBILEPROVISION,
distributionCertificate: {
dataBase64: await fs.readFile(
getAbsolutePath(projectDir, targetCredentials.distributionCertificate.path),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { ProfileType } from '@expo/app-store';
import { UserRole } from '@expo/apple-utils';
import { Ios } from '@expo/eas-build-job';

export interface DistributionCertificateStoreInfo {
id: string;
Expand Down Expand Up @@ -26,6 +28,30 @@ export interface ProvisioningProfile {
provisioningProfile: string;
teamId: string;
teamName?: string;
provisioningProfileType: Ios.ProvisioningProfileType;
}

export function getProvisioningProfileTypeForDistributionMethod(
distributionMethod: ProfileType
): Ios.ProvisioningProfileType {
switch (distributionMethod) {
case ProfileType.IOS_APP_DEVELOPMENT:
case ProfileType.IOS_APP_STORE:
case ProfileType.IOS_APP_ADHOC:
case ProfileType.IOS_APP_INHOUSE:
case ProfileType.TVOS_APP_DEVELOPMENT:
case ProfileType.TVOS_APP_STORE:
case ProfileType.TVOS_APP_ADHOC:
case ProfileType.TVOS_APP_INHOUSE:
return Ios.ProvisioningProfileType.MOBILEPROVISION;
case ProfileType.MAC_APP_DEVELOPMENT:
case ProfileType.MAC_APP_STORE:
case ProfileType.MAC_APP_DIRECT:
case ProfileType.MAC_CATALYST_APP_DEVELOPMENT:
case ProfileType.MAC_CATALYST_APP_STORE:
case ProfileType.MAC_CATALYST_APP_DIRECT:
return Ios.ProvisioningProfileType.PROVISIONPROFILE;
}
}

export interface ProvisioningProfileStoreInfo extends ProvisioningProfile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
DistributionCertificate,
ProvisioningProfile,
ProvisioningProfileStoreInfo,
getProvisioningProfileTypeForDistributionMethod,
} from './Credentials.types';
import { getRequestContext } from './authenticate';
import { AuthCtx } from './authenticateTypes';
Expand Down Expand Up @@ -71,8 +72,11 @@ async function transformProfileAsync(
status: cert.attributes.profileState,
expires: new Date(cert.attributes.expirationDate).getTime() / 1000,
distributionMethod: cert.attributes.profileType,
// @ts-ignore -- this can be null when the profile has expired.
provisioningProfile: cert.attributes.profileContent,
provisioningProfileType: getProvisioningProfileTypeForDistributionMethod(
cert.attributes.profileType
),
// this can be null when the profile has expired.
provisioningProfile: cert.attributes.profileContent as string,
certificates: (await cert.getCertificatesAsync()).map(transformCertificate),
teamId: authCtx.team.id,
teamName: authCtx.team.name,
Expand Down Expand Up @@ -147,17 +151,13 @@ export async function useExistingProvisioningProfileAsync(
`Provisioning profile "${profile.attributes.name}" (${profile.id}) is expired!`
);
}
const result = {
provisioningProfileId: profile.id,
provisioningProfile: content,
teamId: authCtx.team.id,
teamName: authCtx.team.name,
};
spinner.succeed(
`Updated provisioning profile (${profile.id}) with distribution certificate${certIdTag}`
);
return {
...result,
provisioningProfileId: profile.id,
provisioningProfile: content,
provisioningProfileType: provisioningProfile.provisioningProfileType,
teamId: authCtx.team.id,
teamName: authCtx.team.name,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Device, Profile, ProfileState, ProfileType, RequestContext } from '@expo/apple-utils';

import { ProvisioningProfile } from './Credentials.types';
import {
ProvisioningProfile,
getProvisioningProfileTypeForDistributionMethod,
} from './Credentials.types';
import { getRequestContext } from './authenticate';
import { AuthCtx } from './authenticateTypes';
import { getBundleIdForIdentifierAsync, getProfilesForBundleIdAsync } from './bundleId';
Expand All @@ -14,6 +17,7 @@ interface ProfileResults {
profileName?: string;
provisioningProfileId: string;
provisioningProfile: any;
provisioningProfileType: ProfileType;
}

function uniqueItems<T = any>(items: T[]): T[] {
Expand Down Expand Up @@ -177,6 +181,7 @@ async function manageAdHocProfilesAsync(
profileName: existingProfile?.attributes?.name,
provisioningProfileId: existingProfile?.id,
provisioningProfile: existingProfile?.attributes.profileContent,
provisioningProfileType: existingProfile?.attributes.profileType,
};
if (didUpdate) {
result.didUpdate = true;
Expand Down Expand Up @@ -208,6 +213,7 @@ async function manageAdHocProfilesAsync(
profileName: updatedProfile.attributes.name,
provisioningProfileId: updatedProfile.id,
provisioningProfile: updatedProfile.attributes.profileContent,
provisioningProfileType: updatedProfile.attributes.profileType,
};
}

Expand Down Expand Up @@ -239,6 +245,7 @@ async function manageAdHocProfilesAsync(
profileName: newProfile.attributes.name,
provisioningProfileId: newProfile.id,
provisioningProfile: newProfile.attributes.profileContent,
provisioningProfileType: newProfile.attributes.profileType,
};
}

Expand All @@ -252,13 +259,18 @@ export async function createOrReuseAdhocProvisioningProfileAsync(
const spinner = ora(`Handling Apple ad hoc provisioning profiles`).start();
try {
const context = getRequestContext(authCtx);
const { didUpdate, didCreate, profileName, ...adhocProvisioningProfile } =
await manageAdHocProfilesAsync(context, {
udids,
bundleId: bundleIdentifier,
certSerialNumber: distCertSerialNumber,
profileType,
});
const {
didUpdate,
didCreate,
profileName,
provisioningProfileType,
...adhocProvisioningProfile
} = await manageAdHocProfilesAsync(context, {
udids,
bundleId: bundleIdentifier,
certSerialNumber: distCertSerialNumber,
profileType,
});

if (didCreate) {
spinner.succeed(`Created new profile: ${profileName}`);
Expand All @@ -270,6 +282,8 @@ export async function createOrReuseAdhocProvisioningProfileAsync(

return {
...adhocProvisioningProfile,
provisioningProfileType:
getProvisioningProfileTypeForDistributionMethod(provisioningProfileType),
teamId: authCtx.team.id,
teamName: authCtx.team.name,
};
Expand Down
Loading