Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[expo-cli] Allow manually provided credentials when keytool is missing #2662

Merged
merged 1 commit into from
Sep 18, 2020

Conversation

wkozyra95
Copy link
Contributor

Why

When keytool was missing update process was stopped before the user had a chance to select the option to manually provide credentials.

How

Move keytool check to later stage

Test plan

Remove keytool and run expo build:android -c

@wkozyra95 wkozyra95 requested a review from quinlanj September 17, 2020 08:26
@wkozyra95 wkozyra95 force-pushed the @wkozyra95/fix-prompt-when-keytool-is-missing branch 2 times, most recently from eb24854 to c203d03 Compare September 17, 2020 08:31
@wkozyra95 wkozyra95 changed the title [expo-cli] Allow manully provided credentials when keytool is missing [expo-cli] Allow manually provided credentials when keytool is missing Sep 17, 2020
Copy link
Member

@quinlanj quinlanj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, we are passing in additional options into the UpdateKeystore constructor because we expect different behaviours in credentials:manager vs build:android.

In the event the user doesn't have the keytool binary, we want:

  • credentials:manager to throw, because the user is specifically asking for client side generation of Keystore
  • build:android to return null, because we will generate a Keystore for the user on the Expo servers.

const providedKeystore = await askForUserProvided(keystoreSchema);
if (providedKeystore) {
return providedKeystore;
} else if (this.options.optionalKeystoreGeneration && !(await keytoolCommandExists())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (this.options.optionalKeystoreGeneration && !(await keytoolCommandExists())) {
}
const userHasKeytoolCommand = await keytoolCommandExists();
if (!userHasKeytoolCommand) {
if (this.options.bestEffortKeystoreGeneration) {
// we tried our best to generate the keystore on the client side
return null;
}
throw new Error('The keytool binary is not installed. A Keystore will be generated on the Expo servers during your next build.');
}

@@ -13,24 +14,48 @@ import { askForUserProvided } from '../actions/promptForCredentials';
import { Context, IView } from '../context';
import { Keystore, keystoreSchema } from '../credentials';

interface UpdateKeystoreOptions {
optionalKeystoreGeneration: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
optionalKeystoreGeneration: boolean;
bestEffortKeystoreGeneration: boolean; // don't error if user doesn't have the binaries to generate a Keystore

@wkozyra95
Copy link
Contributor Author

@quinlanj

In the event the user doesn't have the keytool binary, we want:
credentials:manager to throw, because the user is specifically asking for client side generation of Keystore
build:android to return null, because we will generate a Keystore for the user on the Expo servers.

If I did not miss anything this code has the same exact behaviour as with your changes. The only difference is that I'm throwing an error when cli attempts to generate Keystore and with your changes, it's happening based on userHasKeytoolCommand value.

bestEffortKeystoreGeneration is a better name, so I'll update that

@wkozyra95 wkozyra95 force-pushed the @wkozyra95/fix-prompt-when-keytool-is-missing branch from c203d03 to ec9726b Compare September 18, 2020 11:35
@wkozyra95 wkozyra95 merged commit 50f98f6 into master Sep 18, 2020
@wkozyra95 wkozyra95 deleted the @wkozyra95/fix-prompt-when-keytool-is-missing branch September 18, 2020 14:26
@quinlanj
Copy link
Member

@wkozyra95 ok sounds good to me, just wanted to make sure we were not missing anything!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants