Skip to content

Commit

Permalink
feat: Consolidate commands such as APP into APPLY.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Jan 14, 2023
1 parent ff5027c commit da3e54c
Show file tree
Hide file tree
Showing 19 changed files with 369 additions and 202 deletions.
4 changes: 2 additions & 2 deletions packages/katana_cli/bin/katana.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ library katana_cli;

import 'dart:io';

import 'package:katana_cli/command/apply.dart';
import 'package:katana_cli/katana_cli.dart';
import 'package:yaml/yaml.dart';

/// Defines a list of commands.
///
/// コマンドの一覧を定義します。
const commands = <String, CliCommand>{
"app": AppCliCommand(),
"pub": PubCliCommand(),
"code": CodeCliCommand(),
"git": GitCliCommand(),
"firebase": FirebaseCliCommand(),
"apply": ApplyCliCommand(),
"create": CreateCliCommand(),
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
part of katana_cli.app;
import 'dart:convert';
import 'dart:io';

import 'package:katana_cli/katana_cli.dart';

/// Automatically outputs `CertificateSigningRequest.certSigningRequest`.
///
/// `CertificateSigningRequest.certSigningRequest`を自動出力します。
class AppCsrCliCommand extends CliCommand {
class AppCsrCliAction extends CliCommand with CliActionMixin {
/// Automatically outputs `CertificateSigningRequest.certSigningRequest`.
///
/// `CertificateSigningRequest.certSigningRequest`を自動出力します。
const AppCsrCliCommand();
const AppCsrCliAction();

@override
String get description =>
"Automatically outputs `CertificateSigningRequest.certSigningRequest` for authentication at AppStore. The key is stored in `ios/ios_enterprise.key` and the CertificateSigningRequest is output to `ios/CertificateSigningRequest.certSigningRequest`. AppStoreでの認証を行うための`CertificateSigningRequest.certSigningRequest`を自動出力します。`ios/ios_enterprise.key`にキーが保存され、`ios/CertificateSigningRequest.certSigningRequest`にCertificateSigningRequestが出力されます。";

@override
bool checkEnabled(ExecContext context) {
final value = context.yaml.getAsMap("app").getAsMap("csr");
final enabled = value.get("enable", false);
if (!enabled) {
return false;
}
return true;
}

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
part of katana_cli.app;
import 'dart:io';

import 'package:katana_cli/katana_cli.dart';

/// Generate a keystore for Android and use it only for release builds.
///
/// Android用のkeystoreを生成しリリースビルド時のみ利用するようにします。
class AppKeystoreCliCommand extends CliCommand {
class AppKeystoreCliAction extends CliCommand with CliActionMixin {
/// Generate a keystore for Android and use it only for release builds.
///
/// Android用のkeystoreを生成しリリースビルド時のみ利用するようにします。
const AppKeystoreCliCommand();
const AppKeystoreCliAction();

@override
String get description =>
"Generate a keystore for Android and use it only at release build time. Save the password for keystore generation in `android/app/appkey_password.key`. Store the keystore in `android/app/appkey.keystore` and `android/app/appkey.p12`. Save the keystore information in `android/key.properties` so that it can be read by build.gradle. Save fingerprint information in `android/app/appkey_fingerprint.txt`. Android用のkeystoreを生成しリリースビルド時のみ利用するようにします。`android/app/appkey_password.key`にkeystoreの生成時のパスワードを保存します。`android/app/appkey.keystore`と`android/app/appkey.p12`にキーストアが保存されます。`android/key.properties`にキーストアの情報を保存し、build.gradleで読み込めるようにします。`android/app/appkey_fingerprint.txt`にフィンガープリント情報を保存します。";

@override
bool checkEnabled(ExecContext context) {
final value = context.yaml.getAsMap("app").getAsMap("keystore");
final enabled = value.get("enable", false);
if (!enabled) {
return false;
}
return true;
}

@override
Future<void> exec(ExecContext context) async {
final com = context.args.get(2, "");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
part of katana_cli.app;
import 'dart:io';

import 'package:katana_cli/katana_cli.dart';

/// Convert the cer file created by Certificate in AppleDeveloperProgram from `CertificateSigningRequest.certSigningRequest` to a p12 file.
///
/// `CertificateSigningRequest.certSigningRequest`からAppleDeveloperProgramのCertificateにて作成されたcerファイルをp12ファイルに変換します。
class AppP12CliCommand extends CliCommand {
class AppP12CliAction extends CliCommand with CliActionMixin {
/// Convert the cer file created by Certificate in AppleDeveloperProgram from `CertificateSigningRequest.certSigningRequest` to a p12 file.
///
/// `CertificateSigningRequest.certSigningRequest`からAppleDeveloperProgramのCertificateにて作成されたcerファイルをp12ファイルに変換します。
const AppP12CliCommand();
const AppP12CliAction();

@override
String get description =>
"Convert the cer file created by Certificate in AppleDeveloperProgram from `CertificateSigningRequest.certSigningRequest` to a p12 file. First create a `CertificateSigningRequest.certSigningRequest` from `katana app csr`, then go to https://mathru.notion.site/AppStoreConnect-ID-f516ff1a767146 f69acd6780fbcf20fe to download the cer file. `CertificateSigningRequest.certSigningRequest`からAppleDeveloperProgramのCertificateにて作成されたcerファイルをp12ファイルに変換します。最初に`katana app csr`から`CertificateSigningRequest.certSigningRequest`を作成し、https://mathru.notion.site/AppStoreConnect-ID-f516ff1a767146f69acd6780fbcf20fe を参考にcerファイルをダウンロードしてください。";

@override
bool checkEnabled(ExecContext context) {
final value = context.yaml.getAsMap("app").getAsMap("p12");
final enabled = value.get("enable", false);
if (!enabled) {
return false;
}
return true;
}

@override
Future<void> exec(ExecContext context) async {
final regExp = RegExp(r".cer$");
Expand Down Expand Up @@ -43,37 +55,39 @@ class AppP12CliCommand extends CliCommand {
print("Password is missing in `ios/ios_certificate_password.key`.");
return;
}
await command(
"Converts a cer file to a pem file.",
[
openssl,
"x509",
"-in",
cer.path,
"-inform",
"DER",
"-out",
cer.path.replaceAll(regExp, ".pem"),
"-outform",
"PEM"
],
);
await command(
"Converts a pem file to a p12 file.",
[
openssl,
"pkcs12",
"-export",
"-in",
cer.path.replaceAll(regExp, ".pem"),
"-out",
cer.path.replaceAll(regExp, ".p12"),
"-inkey",
"ios/ios_enterprise.key",
"-password",
"pass:$password",
],
);
if (!File(cer.path.replaceAll(regExp, ".p12")).existsSync()) {
await command(
"Converts a cer file to a pem file.",
[
openssl,
"x509",
"-in",
cer.path,
"-inform",
"DER",
"-out",
cer.path.replaceAll(regExp, ".pem"),
"-outform",
"PEM"
],
);
await command(
"Converts a pem file to a p12 file.",
[
openssl,
"pkcs12",
"-export",
"-in",
cer.path.replaceAll(regExp, ".pem"),
"-out",
cer.path.replaceAll(regExp, ".p12"),
"-inkey",
"ios/ios_enterprise.key",
"-password",
"pass:$password",
],
);
}
label("Rewrite `.gitignore`.");
final gitignore = File("ios/.gitignore");
if (!gitignore.existsSync()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
part of katana_cli.app;
import 'package:katana_cli/katana_cli.dart';

/// Add a module to pick up images.
///
/// 画像のピックアップを行うためのモジュールを追加します。
class AppPickerCliCommand extends CliCommand {
class AppPickerCliAction extends CliCommand with CliActionMixin {
/// Add a module to pick up images.
///
/// 画像のピックアップを行うためのモジュールを追加します。
const AppPickerCliCommand();
const AppPickerCliAction();

@override
String get description =>
"Add a module to pick up images. 画像のピックアップを行うためのモジュールを追加します。";

@override
bool checkEnabled(ExecContext context) {
final value = context.yaml.getAsMap("app").getAsMap("picker");
final enabled = value.get("enable", false);
if (!enabled) {
return false;
}
return true;
}

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
part of katana_cli.app;
import 'dart:convert';
import 'dart:io';

import 'package:csv/csv.dart';
import 'package:katana_cli/katana_cli.dart';
import 'package:xml/xml.dart';

final _mapping = [
"timestamp",
Expand All @@ -22,19 +27,29 @@ final _mapping = [
"screenshot_tablet",
];

/// Set the application information.
/// Set the application information from the spreadsheet.
///
/// アプリケーションの情報を設定します
class AppInfoCliCommand extends CliCommand {
/// Set the application information.
/// スプレッドシートからのアプリケーションの情報を設定します
class AppSpreadSheetCliAction extends CliCommand with CliActionMixin {
/// Set the application information from the spreadsheet.
///
/// アプリケーションの情報を設定します
const AppInfoCliCommand();
/// スプレッドシートからのアプリケーションの情報を設定します
const AppSpreadSheetCliAction();

@override
String get description =>
"Set the application title, icon, and other information based on the information in `katana.yaml`. `katana.yaml`の情報を元にアプリケーションのタイトルやアイコンなどの情報を設定します。";

@override
bool checkEnabled(ExecContext context) {
final value = context.yaml.getAsMap("app").getAsMap("spread_sheet");
final enabled = value.get("enable", false);
if (!enabled) {
return false;
}
return true;
}

@override
Future<void> exec(ExecContext context) async {
final app = context.yaml.getAsMap("app");
Expand Down

0 comments on commit da3e54c

Please sign in to comment.