Skip to content

Commit

Permalink
fix: Enable git->ignore_secure_file
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Jan 15, 2023
1 parent ed09e70 commit afd6669
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 95 deletions.
60 changes: 36 additions & 24 deletions packages/katana_cli/lib/action/app/csr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,42 @@ class AppCsrCliAction extends CliCommand with CliActionMixin {
return;
}
final gitignores = await gitignore.readAsLines();
if (!gitignores.any((e) => e.startsWith("**/*.p12"))) {
gitignores.add("**/*.p12");
}
if (!gitignores.any((e) => e.startsWith("**/*.p8"))) {
gitignores.add("**/*.p8");
}
if (!gitignores.any((e) => e.startsWith("**/*.mobileprovision"))) {
gitignores.add("**/*.mobileprovision");
}
if (!gitignores.any((e) => e.startsWith("**/*.pem"))) {
gitignores.add("**/*.pem");
}
if (!gitignores.any((e) => e.startsWith("**/*.cer"))) {
gitignores.add("**/*.cer");
}
if (!gitignores.any((e) => e.startsWith("**/*.certSigningRequest"))) {
gitignores.add("**/*.certSigningRequest");
}
if (!gitignores
.any((e) => e.startsWith("**/ios_certificate_password.key"))) {
gitignores.add("**/ios_certificate_password.key");
}
if (!gitignores.any((e) => e.startsWith("**/ios_enterprise.key"))) {
gitignores.add("**/ios_enterprise.key");
if (context.yaml.getAsMap("git").get("ignore_secure_file", true)) {
if (!gitignores.any((e) => e.startsWith("**/*.p12"))) {
gitignores.add("**/*.p12");
}
if (!gitignores.any((e) => e.startsWith("**/*.p8"))) {
gitignores.add("**/*.p8");
}
if (!gitignores.any((e) => e.startsWith("**/*.mobileprovision"))) {
gitignores.add("**/*.mobileprovision");
}
if (!gitignores.any((e) => e.startsWith("**/*.pem"))) {
gitignores.add("**/*.pem");
}
if (!gitignores.any((e) => e.startsWith("**/*.cer"))) {
gitignores.add("**/*.cer");
}
if (!gitignores.any((e) => e.startsWith("**/*.certSigningRequest"))) {
gitignores.add("**/*.certSigningRequest");
}
if (!gitignores
.any((e) => e.startsWith("**/ios_certificate_password.key"))) {
gitignores.add("**/ios_certificate_password.key");
}
if (!gitignores.any((e) => e.startsWith("**/ios_enterprise.key"))) {
gitignores.add("**/ios_enterprise.key");
}
} else {
gitignores.removeWhere((e) => e.startsWith("**/*.p12"));
gitignores.removeWhere((e) => e.startsWith("**/*.p8"));
gitignores.removeWhere((e) => e.startsWith("**/*.mobileprovision"));
gitignores.removeWhere((e) => e.startsWith("**/*.pem"));
gitignores.removeWhere((e) => e.startsWith("**/*.cer"));
gitignores.removeWhere((e) => e.startsWith("**/*.certSigningRequest"));
gitignores
.removeWhere((e) => e.startsWith("**/ios_certificate_password.key"));
gitignores.removeWhere((e) => e.startsWith("**/ios_enterprise.key"));
}
await gitignore.writeAsString(gitignores.join("\n"));
}
Expand Down
41 changes: 30 additions & 11 deletions packages/katana_cli/lib/action/app/keystore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,36 @@ class AppKeystoreCliAction extends CliCommand with CliActionMixin {
return;
}
final gitignores = await gitignore.readAsLines();
if (!gitignores.any((e) => e.startsWith("**/*.p12"))) {
gitignores.add("**/*.p12");
}
if (!gitignores.any((e) => e.startsWith("*.json"))) {
gitignores.add("*.json");
}
if (!gitignores.any((e) => e.startsWith("**/appkey_fingerprint.txt"))) {
gitignores.add("**/appkey_fingerprint.txt");
}
if (!gitignores.any((e) => e.startsWith("**/appkey_password.key"))) {
gitignores.add("**/appkey_password.key");
if (context.yaml.getAsMap("git").get("ignore_secure_file", true)) {
if (!gitignores.any((e) => e.startsWith("key.properties"))) {
gitignores.add("key.properties");
}
if (!gitignores.any((e) => e.startsWith("**/*.keystore"))) {
gitignores.add("**/*.keystore");
}
if (!gitignores.any((e) => e.startsWith("**/*.jks"))) {
gitignores.add("**/*.jks");
}
if (!gitignores.any((e) => e.startsWith("**/*.p12"))) {
gitignores.add("**/*.p12");
}
if (!gitignores.any((e) => e.startsWith("*.json"))) {
gitignores.add("*.json");
}
if (!gitignores.any((e) => e.startsWith("**/appkey_fingerprint.txt"))) {
gitignores.add("**/appkey_fingerprint.txt");
}
if (!gitignores.any((e) => e.startsWith("**/appkey_password.key"))) {
gitignores.add("**/appkey_password.key");
}
} else {
gitignores.removeWhere((e) => e.startsWith("**/*.p12"));
gitignores.removeWhere((e) => e.startsWith("*.json"));
gitignores.removeWhere((e) => e.startsWith("**/appkey_fingerprint.txt"));
gitignores.removeWhere((e) => e.startsWith("**/appkey_password.key"));
gitignores.removeWhere((e) => e.startsWith("key.properties"));
gitignores.removeWhere((e) => e.startsWith("**/*.keystore"));
gitignores.removeWhere((e) => e.startsWith("**/*.jks"));
}
await gitignore.writeAsString(gitignores.join("\n"));
}
Expand Down
60 changes: 36 additions & 24 deletions packages/katana_cli/lib/action/app/p12.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,42 @@ class AppP12CliAction extends CliCommand with CliActionMixin {
return;
}
final gitignores = await gitignore.readAsLines();
if (!gitignores.any((e) => e.startsWith("**/*.p12"))) {
gitignores.add("**/*.p12");
}
if (!gitignores.any((e) => e.startsWith("**/*.p8"))) {
gitignores.add("**/*.p8");
}
if (!gitignores.any((e) => e.startsWith("**/*.mobileprovision"))) {
gitignores.add("**/*.mobileprovision");
}
if (!gitignores.any((e) => e.startsWith("**/*.pem"))) {
gitignores.add("**/*.pem");
}
if (!gitignores.any((e) => e.startsWith("**/*.cer"))) {
gitignores.add("**/*.cer");
}
if (!gitignores.any((e) => e.startsWith("**/*.certSigningRequest"))) {
gitignores.add("**/*.certSigningRequest");
}
if (!gitignores
.any((e) => e.startsWith("**/ios_certificate_password.key"))) {
gitignores.add("**/ios_certificate_password.key");
}
if (!gitignores.any((e) => e.startsWith("**/ios_enterprise.key"))) {
gitignores.add("**/ios_enterprise.key");
if (context.yaml.getAsMap("git").get("ignore_secure_file", true)) {
if (!gitignores.any((e) => e.startsWith("**/*.p12"))) {
gitignores.add("**/*.p12");
}
if (!gitignores.any((e) => e.startsWith("**/*.p8"))) {
gitignores.add("**/*.p8");
}
if (!gitignores.any((e) => e.startsWith("**/*.mobileprovision"))) {
gitignores.add("**/*.mobileprovision");
}
if (!gitignores.any((e) => e.startsWith("**/*.pem"))) {
gitignores.add("**/*.pem");
}
if (!gitignores.any((e) => e.startsWith("**/*.cer"))) {
gitignores.add("**/*.cer");
}
if (!gitignores.any((e) => e.startsWith("**/*.certSigningRequest"))) {
gitignores.add("**/*.certSigningRequest");
}
if (!gitignores
.any((e) => e.startsWith("**/ios_certificate_password.key"))) {
gitignores.add("**/ios_certificate_password.key");
}
if (!gitignores.any((e) => e.startsWith("**/ios_enterprise.key"))) {
gitignores.add("**/ios_enterprise.key");
}
} else {
gitignores.removeWhere((e) => e.startsWith("**/*.p12"));
gitignores.removeWhere((e) => e.startsWith("**/*.p8"));
gitignores.removeWhere((e) => e.startsWith("**/*.mobileprovision"));
gitignores.removeWhere((e) => e.startsWith("**/*.pem"));
gitignores.removeWhere((e) => e.startsWith("**/*.cer"));
gitignores.removeWhere((e) => e.startsWith("**/*.certSigningRequest"));
gitignores
.removeWhere((e) => e.startsWith("**/ios_certificate_password.key"));
gitignores.removeWhere((e) => e.startsWith("**/ios_enterprise.key"));
}
await gitignore.writeAsString(gitignores.join("\n"));
}
Expand Down
41 changes: 30 additions & 11 deletions packages/katana_cli/lib/action/git/platform/android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,36 @@ Future<void> buildAndroid(
return;
}
final gitignores = await gitignore.readAsLines();
if (!gitignores.any((e) => e.startsWith("**/*.p12"))) {
gitignores.add("**/*.p12");
}
if (!gitignores.any((e) => e.startsWith("*.json"))) {
gitignores.add("*.json");
}
if (!gitignores.any((e) => e.startsWith("**/appkey_fingerprint.txt"))) {
gitignores.add("**/appkey_fingerprint.txt");
}
if (!gitignores.any((e) => e.startsWith("**/appkey_password.key"))) {
gitignores.add("**/appkey_password.key");
if (context.yaml.getAsMap("git").get("ignore_secure_file", true)) {
if (!gitignores.any((e) => e.startsWith("key.properties"))) {
gitignores.add("key.properties");
}
if (!gitignores.any((e) => e.startsWith("**/*.keystore"))) {
gitignores.add("**/*.keystore");
}
if (!gitignores.any((e) => e.startsWith("**/*.jks"))) {
gitignores.add("**/*.jks");
}
if (!gitignores.any((e) => e.startsWith("**/*.p12"))) {
gitignores.add("**/*.p12");
}
if (!gitignores.any((e) => e.startsWith("*.json"))) {
gitignores.add("*.json");
}
if (!gitignores.any((e) => e.startsWith("**/appkey_fingerprint.txt"))) {
gitignores.add("**/appkey_fingerprint.txt");
}
if (!gitignores.any((e) => e.startsWith("**/appkey_password.key"))) {
gitignores.add("**/appkey_password.key");
}
} else {
gitignores.removeWhere((e) => e.startsWith("**/*.p12"));
gitignores.removeWhere((e) => e.startsWith("*.json"));
gitignores.removeWhere((e) => e.startsWith("**/appkey_fingerprint.txt"));
gitignores.removeWhere((e) => e.startsWith("**/appkey_password.key"));
gitignores.removeWhere((e) => e.startsWith("key.properties"));
gitignores.removeWhere((e) => e.startsWith("**/*.keystore"));
gitignores.removeWhere((e) => e.startsWith("**/*.jks"));
}
await gitignore.writeAsString(gitignores.join("\n"));
}
Expand Down
60 changes: 37 additions & 23 deletions packages/katana_cli/lib/action/git/platform/ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,30 +195,44 @@ Future<void> buildIOS(
return;
}
final gitignores = await gitignore.readAsLines();
if (!gitignores.any((e) => e.startsWith("**/*.p12"))) {
gitignores.add("**/*.p12");
}
if (!gitignores.any((e) => e.startsWith("**/*.p8"))) {
gitignores.add("**/*.p8");
}
if (!gitignores.any((e) => e.startsWith("**/*.mobileprovision"))) {
gitignores.add("**/*.mobileprovision");
}
if (!gitignores.any((e) => e.startsWith("**/*.pem"))) {
gitignores.add("**/*.pem");
}
if (!gitignores.any((e) => e.startsWith("**/*.cer"))) {
gitignores.add("**/*.cer");
}
if (!gitignores.any((e) => e.startsWith("**/*.certSigningRequest"))) {
gitignores.add("**/*.certSigningRequest");
}
if (!gitignores.any((e) => e.startsWith("**/ios_certificate_password.key"))) {
gitignores.add("**/ios_certificate_password.key");
}
if (!gitignores.any((e) => e.startsWith("**/ios_enterprise.key"))) {
gitignores.add("**/ios_enterprise.key");
if (context.yaml.getAsMap("git").get("ignore_secure_file", true)) {
if (!gitignores.any((e) => e.startsWith("**/*.p12"))) {
gitignores.add("**/*.p12");
}
if (!gitignores.any((e) => e.startsWith("**/*.p8"))) {
gitignores.add("**/*.p8");
}
if (!gitignores.any((e) => e.startsWith("**/*.mobileprovision"))) {
gitignores.add("**/*.mobileprovision");
}
if (!gitignores.any((e) => e.startsWith("**/*.pem"))) {
gitignores.add("**/*.pem");
}
if (!gitignores.any((e) => e.startsWith("**/*.cer"))) {
gitignores.add("**/*.cer");
}
if (!gitignores.any((e) => e.startsWith("**/*.certSigningRequest"))) {
gitignores.add("**/*.certSigningRequest");
}
if (!gitignores
.any((e) => e.startsWith("**/ios_certificate_password.key"))) {
gitignores.add("**/ios_certificate_password.key");
}
if (!gitignores.any((e) => e.startsWith("**/ios_enterprise.key"))) {
gitignores.add("**/ios_enterprise.key");
}
} else {
gitignores.removeWhere((e) => e.startsWith("**/*.p12"));
gitignores.removeWhere((e) => e.startsWith("**/*.p8"));
gitignores.removeWhere((e) => e.startsWith("**/*.mobileprovision"));
gitignores.removeWhere((e) => e.startsWith("**/*.pem"));
gitignores.removeWhere((e) => e.startsWith("**/*.cer"));
gitignores.removeWhere((e) => e.startsWith("**/*.certSigningRequest"));
gitignores
.removeWhere((e) => e.startsWith("**/ios_certificate_password.key"));
gitignores.removeWhere((e) => e.startsWith("**/ios_enterprise.key"));
}
await gitignore.writeAsString(gitignores.join("\n"));
}

/// Contents of buiod.yaml for IOS in Github Actions.
Expand Down
16 changes: 14 additions & 2 deletions packages/katana_cli/lib/command/create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ class CreateCliCommand extends CliCommand {
if (!gitignores.any((e) => e.startsWith("pubspec_overrides.yaml"))) {
gitignores.add("pubspec_overrides.yaml");
}
if (!gitignores.any((e) => e.startsWith("katana_secrets.yaml"))) {
gitignores.add("katana_secrets.yaml");
if (context.yaml.getAsMap("git").get("ignore_secure_file", true)) {
if (!gitignores.any((e) => e.startsWith("katana_secrets.yaml"))) {
gitignores.add("katana_secrets.yaml");
}
} else {
gitignores.removeWhere((e) => e.startsWith("katana_secrets.yaml"));
}
await gitignore.writeAsString(gitignores.join("\n"));
await command(
Expand Down Expand Up @@ -279,6 +283,14 @@ firebase:
# This section contains information related to Git.
# Git関連の情報を記載します。
git:
# Add secure files to .gitignore.
# If `false`, password files, etc. will be uploaded to Git.
# Please limit your use to private repositories only.
# セキュアなファイルを.gitignoreに追加します。
# `false`にした場合、パスワードファイルなどがGitにアップロードされることになります。
# プライベートレポジトリのみでの利用に限定してください。
ignore_secure_file: true
# Ensure that the dart code is modified and verified before committing.
# lefthand installation is required.
# コミット前にdartコードの修正や確認を行うようにします。
Expand Down

0 comments on commit afd6669

Please sign in to comment.