-
Notifications
You must be signed in to change notification settings - Fork 91
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
[ENG-1271] make iOS credentials manager work with multi-target projects #441
Conversation
104f046
to
7076162
Compare
Size Change: +2 kB (0%) Total Size: 37.5 MB
|
ca992ea
to
818b23d
Compare
ENG-1271 eas credentials downloads to ios/certs, which conflicts with workflow detection
If you have a managed project and run |
2d2dd5b
to
a7edaeb
Compare
a7edaeb
to
a296bc0
Compare
if (notConfiguredTargets.length > 0) { | ||
throw new Error( | ||
`Credentials for target${ | ||
notConfiguredTargets.length === 1 ? '' : 's' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there is only one target error message should state sth less specific e.g. credentials are not configured or sth like this, without talking about targets
const provisioningProfilePath: string = | ||
currentRawTargetCredentialsObject?.provisioningProfilePath ?? | ||
`credentials/ios/${target.targetName}-profile.mobileprovision`; | ||
const distCertPath: string = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if existing paths pointed to the same file on the disk, when updating you will replace it for all of them
exp: ctx.exp, | ||
}, | ||
{ | ||
workflow: buildProfile.workflow, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe pass buildProfile here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
targets: Target[] | ||
): void { | ||
const projectFullName = `@${app.account.name}/${app.projectName}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore this suggestion if theres an edge case (ie) targets
is a subset of the appCredentials
keys
targets: Target[] | |
): void { | |
const projectFullName = `@${app.account.name}/${app.projectName}`; | |
): void { | |
const targets = Object.keys(appCredentials); | |
const projectFullName = `@${app.account.name}/${app.projectName}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use the Target[]
type here because it contains bundle identifiers of the targets. If the build credentials for a target in appCredentials
don't exist, then I couldn't determine the bundle id. See line 79.
export function displayIosAppCredentials(credentials: CommonIosAppCredentialsFragment): void { | ||
export function displayIosCredentials( | ||
app: App, | ||
appCredentials: IosAppCredentialsMap, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
appCredentials: IosAppCredentialsMap, | |
appCredentialsMap: IosAppCredentialsMap, |
app = { account, projectName: ctx.exp.slug }; | ||
const easJsonReader = new EasJsonReader(ctx.projectDir, 'ios'); | ||
const easConfig = await new SelectBuildProfileFromEasJson(easJsonReader).runAsync(ctx); | ||
buildProfile = nullthrows(easConfig.builds.ios, 'iOS build profile must be defined'); | ||
const xcodeBuildContext = await resolveXcodeBuildContextAsync( | ||
{ | ||
projectDir: ctx.projectDir, | ||
nonInteractive: ctx.nonInteractive, | ||
exp: ctx.exp, | ||
}, | ||
{ | ||
workflow: buildProfile.workflow, | ||
...(buildProfile.workflow === Workflow.GENERIC && { | ||
buildConfiguration: buildProfile.schemeBuildConfiguration, | ||
buildScheme: buildProfile.scheme, | ||
}), | ||
} | ||
); | ||
if (!iosAppCredentials) { | ||
displayEmptyIosCredentials(appLookupParams); | ||
} else { | ||
displayIosAppCredentials(iosAppCredentials); | ||
targets = await resolveTargetsAsync( | ||
{ exp: ctx.exp, projectDir: ctx.projectDir }, | ||
xcodeBuildContext | ||
); | ||
const iosAppCredentialsMap: IosAppCredentialsMap = {}; | ||
for (const target of targets) { | ||
const appLookupParams = getAppLookupParamsFromContext(ctx, target); | ||
iosAppCredentialsMap[ | ||
target.targetName | ||
] = await ctx.ios.getIosAppCredentialsWithCommonFieldsAsync(appLookupParams); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be cleaner to refactor this into a separate method that returns {isProjectContext: true, app: App, targets: Target[], buildProfile: BuildProfile} | {isProjectContext: false, app: null, targets: null, buildProfile: null}
and populate it on line 83-86 (moving line 87-96 out of the while loop so you can use account
)
3982742
to
b03c1c9
Compare
b03c1c9
to
fe314e7
Compare
Checklist
[EAS BUILD API]
if it's a part of a breaking change to EAS Build API (only possible when updating@expo/eas-build-job
package).Why
How
I know this is quite big PR but I didn't know how to divide work into smaller pieces.
Notable changes:
SetupBuildCredentials
prints the summary after all targets are set up.UseExistingDistributionCertificate
,CreateDistributionCertificate
andRemoveProvisioningProfile
) they are asked which target to use.ios/certs
->credentials/ios
android/keystores
->credentials/android
Test Plan
I tested credentials manager manually (by executing all available commands) for 3 different projects: