Skip to content

Commit

Permalink
fix: Output keyhash for Facebook.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Sep 7, 2023
1 parent ae2ff78 commit b7f4d90
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
39 changes: 39 additions & 0 deletions packages/katana_cli/lib/action/app/keystore.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Dart imports:
import 'dart:convert';
import 'dart:io';

// Project imports:
Expand Down Expand Up @@ -50,6 +51,7 @@ class AppKeystoreCliAction extends CliCommand with CliActionMixin {
}
final bin = context.yaml.getAsMap("bin");
final keytool = bin.get("keytool", "keytool");
final openssl = bin.get("openssl", "openssl");
final app = context.yaml.getAsMap("app");
if (app.isEmpty) {
error("The item [app] is missing. Please add an item.");
Expand Down Expand Up @@ -197,6 +199,12 @@ class AppKeystoreCliAction extends CliCommand with CliActionMixin {
storeFile: "file(keyProperties['storeFile'])",
storePassword: "keyProperties['storePassword']",
),
debug: GradleAndroidSigningConfig(
keyAlias: "keyProperties['keyAlias']",
keyPassword: "keyProperties['keyPassword']",
storeFile: "file(keyProperties['storeFile'])",
storePassword: "keyProperties['storePassword']",
),
);
await gradle.save();
label("Save the fingerprint information.");
Expand All @@ -220,6 +228,37 @@ class AppKeystoreCliAction extends CliCommand with CliActionMixin {
);
await fingerPrintFile.writeAsString(fingerPrint);
}
label("Save the keyhash information.");
final keyHashFile = File("android/app/appkey_keyhash.txt");
if (!keyHashFile.existsSync()) {
// ignore: avoid_print
print("\r\n#### Create appkey_keyhash.txt");
var keyHash = "";
final keytoolResult = await Process.start(keytool, [
"-exportcert",
"-v",
"-keystore",
"android/app/appkey.keystore",
"-alias",
alias,
"-storepass",
password,
]);
final openSslSha1Restul = await Process.start(openssl, [
"sha1",
"-binary",
]);
keytoolResult.stdout.pipe(openSslSha1Restul.stdin);
final openSslBase64Result = await Process.start(openssl, ["base64"]);
openSslSha1Restul.stdout.pipe(openSslBase64Result.stdin);
openSslBase64Result.stdout.transform(utf8.decoder).forEach((e) {
keyHash += e;
// ignore: avoid_print
print(e);
});
await openSslBase64Result.exitCode;
await keyHashFile.writeAsString(keyHash);
}
label("Rewrite `.gitignore`.");
final gitignore = File("android/.gitignore");
if (!gitignore.existsSync()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ class FirebaseAuthenticationCliAction extends CliCommand with CliActionMixin {
),
XmlAttribute(
XmlName("android:value"),
facebookAppId,
"fb$facebookAppId",
),
],
[],
Expand Down
2 changes: 1 addition & 1 deletion packages/katana_cli/lib/src/framework.dart
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ extension CliDirectoryExtensions on Directory {
/// Extended methods to make [Process] easier to use.
///
/// [Process]を使いやすくするための拡張メソッド。
extension _ProcessExtensions on Future<Process> {
extension ProcessExtensions on Future<Process> {
/// Prints the contents of the command to standard output.
///
/// コマンドの内容を標準出力にプリントします。
Expand Down
8 changes: 4 additions & 4 deletions packages/katana_cli/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ packages:
dependency: "direct main"
description:
name: archive
sha256: "0c8368c9b3f0abbc193b9d6133649a614204b528982bebc7026372d61677ce3a"
sha256: "49b1fad315e57ab0bbc15bcbb874e83116a1d78f77ebd500a4af6c9407d6b28e"
url: "https://pub.dev"
source: hosted
version: "3.3.7"
version: "3.3.8"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -172,10 +172,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
path:
dependency: transitive
description:
Expand Down

0 comments on commit b7f4d90

Please sign in to comment.