This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 477
[cli] better build errors #1928
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ import { | |
getProvisioningProfileFromParams, | ||
useProvisioningProfileFromParams, | ||
} from '../../../credentials/views/IosProvisioningProfile'; | ||
import { IosAppCredentials, IosDistCredentials } from '../../../credentials/credentials'; | ||
|
||
class IOSBuilder extends BaseBuilder { | ||
appleCtx?: apple.AppleCtx; | ||
|
@@ -144,21 +145,102 @@ See https://docs.expo.io/versions/latest/distribution/building-standalone-apps/# | |
ErrorCodes.NON_INTERACTIVE, | ||
'Unable to proceed, see the above error message.' | ||
); | ||
} | ||
|
||
log( | ||
chalk.bold.red( | ||
'Failed to prepare all credentials. \nThe next time you build, we will automatically use the following configuration:' | ||
) | ||
); | ||
throw e; | ||
} finally { | ||
const credentials = await context.ios.getAllCredentials(); | ||
displayProjectCredentials(experienceName, bundleIdentifier, credentials); | ||
} | ||
} | ||
|
||
async _setupDistCert( | ||
ctx: Context, | ||
experienceName: string, | ||
bundleIdentifier: string, | ||
appCredentials: IosAppCredentials | ||
): Promise<void> { | ||
try { | ||
const nonInteractive = this.options.parent && this.options.parent.nonInteractive; | ||
const distCertFromParams = await getDistCertFromParams(this.options); | ||
if (distCertFromParams) { | ||
await useDistCertFromParams(ctx, appCredentials, distCertFromParams); | ||
} else { | ||
log( | ||
chalk.bold.red( | ||
'Failed to prepare all credentials. \nThe next time you build, we will automatically use the following configuration:' | ||
) | ||
await runCredentialsManager( | ||
ctx, | ||
new SetupIosDist({ experienceName, bundleIdentifier, nonInteractive }) | ||
); | ||
} | ||
} catch (e) { | ||
log.error('Failed to set up Distribution Certificate'); | ||
throw e; | ||
} | ||
} | ||
|
||
const credentials = await context.ios.getAllCredentials(); | ||
displayProjectCredentials(experienceName, bundleIdentifier, credentials); | ||
async _setupPushCert( | ||
ctx: Context, | ||
experienceName: string, | ||
bundleIdentifier: string, | ||
appCredentials: IosAppCredentials | ||
): Promise<void> { | ||
try { | ||
const nonInteractive = this.options.parent && this.options.parent.nonInteractive; | ||
const pushKeyFromParams = await getPushKeyFromParams(this.options); | ||
if (pushKeyFromParams) { | ||
await usePushKeyFromParams(ctx, appCredentials, pushKeyFromParams); | ||
} else { | ||
await runCredentialsManager( | ||
ctx, | ||
new SetupIosPush({ experienceName, bundleIdentifier, nonInteractive }) | ||
); | ||
} | ||
} catch (e) { | ||
log.error('Failed to set up Push Key'); | ||
throw e; | ||
} | ||
} | ||
|
||
async _setupProvisioningProfile( | ||
ctx: Context, | ||
experienceName: string, | ||
bundleIdentifier: string, | ||
appCredentials: IosAppCredentials, | ||
distributionCert: IosDistCredentials | ||
) { | ||
try { | ||
const nonInteractive = this.options.parent && this.options.parent.nonInteractive; | ||
const provisioningProfileFromParams = await getProvisioningProfileFromParams(this.options); | ||
if (provisioningProfileFromParams) { | ||
await useProvisioningProfileFromParams( | ||
ctx, | ||
appCredentials, | ||
this.options.teamId!, | ||
provisioningProfileFromParams, | ||
distributionCert | ||
); | ||
} else { | ||
await runCredentialsManager( | ||
ctx, | ||
new SetupIosProvisioningProfile({ | ||
experienceName, | ||
bundleIdentifier, | ||
distCert: distributionCert, | ||
nonInteractive, | ||
}) | ||
); | ||
} | ||
} catch (e) { | ||
log.error('Failed to set up Provisioning Profile'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar to above, is there any more context we can provide here? maybe a expo.fyi link that explains why this can happen, for example There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above comment :) |
||
throw e; | ||
} | ||
} | ||
|
||
async produceCredentials(ctx: Context, experienceName: string, bundleIdentifier: string) { | ||
const nonInteractive = this.options.parent && this.options.parent.nonInteractive; | ||
const appCredentials = await ctx.ios.getAppCredentials(experienceName, bundleIdentifier); | ||
|
||
if (ctx.hasAppleCtx()) { | ||
|
@@ -168,16 +250,7 @@ See https://docs.expo.io/versions/latest/distribution/building-standalone-apps/# | |
{ enablePushNotifications: true } | ||
); | ||
} | ||
|
||
const distCertFromParams = await getDistCertFromParams(this.options); | ||
if (distCertFromParams) { | ||
await useDistCertFromParams(ctx, appCredentials, distCertFromParams); | ||
} else { | ||
await runCredentialsManager( | ||
ctx, | ||
new SetupIosDist({ experienceName, bundleIdentifier, nonInteractive }) | ||
); | ||
} | ||
await this._setupDistCert(ctx, experienceName, bundleIdentifier, appCredentials); | ||
|
||
const distributionCert = await ctx.ios.getDistCert(experienceName, bundleIdentifier); | ||
if (!distributionCert) { | ||
|
@@ -187,36 +260,15 @@ See https://docs.expo.io/versions/latest/distribution/building-standalone-apps/# | |
); | ||
} | ||
|
||
const pushKeyFromParams = await getPushKeyFromParams(this.options); | ||
if (pushKeyFromParams) { | ||
await usePushKeyFromParams(ctx, appCredentials, pushKeyFromParams); | ||
} else { | ||
await runCredentialsManager( | ||
ctx, | ||
new SetupIosPush({ experienceName, bundleIdentifier, nonInteractive }) | ||
); | ||
} | ||
await this._setupPushCert(ctx, experienceName, bundleIdentifier, appCredentials); | ||
|
||
const provisioningProfileFromParams = await getProvisioningProfileFromParams(this.options); | ||
if (provisioningProfileFromParams) { | ||
await useProvisioningProfileFromParams( | ||
ctx, | ||
appCredentials, | ||
this.options.teamId!, | ||
provisioningProfileFromParams, | ||
distributionCert | ||
); | ||
} else { | ||
await runCredentialsManager( | ||
ctx, | ||
new SetupIosProvisioningProfile({ | ||
experienceName, | ||
bundleIdentifier, | ||
distCert: distributionCert, | ||
nonInteractive, | ||
}) | ||
); | ||
} | ||
await this._setupProvisioningProfile( | ||
ctx, | ||
experienceName, | ||
bundleIdentifier, | ||
appCredentials, | ||
distributionCert | ||
); | ||
} | ||
|
||
async clearAndRevokeCredentialsIfRequested(ctx: Context, projectMetadata: any): Promise<void> { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is there any more context that we can provide in this error?
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.
The more context-specific error with the
expo.fyi
link is caught and rethrown (which will then print to stderr). I catch it at this point and print outFailed to set up Push Key
so we know which part of the credential process we failed at. The error logging would look something like this: