fix: surface keytool errors and add keytool preflight check

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-11 04:29:45 -04:00
parent b8a4ddf4a0
commit ec21256ca5

View File

@@ -56,6 +56,11 @@ preflight_check() {
ok=false
fi
if ! command -v keytool &>/dev/null; then
error "keytool not found. It ships with the JDK — check your JAVA_HOME/PATH."
ok=false
fi
if [[ ! -x "./gradlew" ]]; then
error "Gradle wrapper not found or not executable."
ok=false
@@ -133,6 +138,9 @@ create_keystore() {
info "Creating keystore..."
local keytool_err
keytool_err=$(mktemp)
keytool -genkeypair \
-alias "$KEY_ALIAS" \
-keyalg RSA \
@@ -142,9 +150,10 @@ create_keystore() {
-storepass "$password" \
-keypass "$password" \
-dname "$dname" \
2>/dev/null || true
2>"$keytool_err" || true
if [[ -f "$KEYSTORE_FILE" ]]; then
rm -f "$keytool_err"
echo ""
success "Keystore created at ${BOLD}$KEYSTORE_FILE${NC}"
echo ""
@@ -153,6 +162,10 @@ create_keystore() {
warn "that already have this version installed."
else
error "Keystore creation failed."
if [[ -s "$keytool_err" ]]; then
echo -e "${DIM}$(cat "$keytool_err")${NC}" >&2
fi
rm -f "$keytool_err"
return 1
fi
}