Skip to content

Commit

Permalink
fix: Command acceleration.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Mar 21, 2024
1 parent 05f5b9d commit ea270c9
Show file tree
Hide file tree
Showing 29 changed files with 357 additions and 331 deletions.
36 changes: 20 additions & 16 deletions packages/katana_cli/bin/katana.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ Future<void> main(List<String> args) async {
if (tmp.key != command) {
continue;
}
await tmp.value.exec(
ExecContext(
yaml: {},
secrets: katanaSecrets.existsSync()
? loadYaml(await katanaSecrets.readAsString())
: {},
args: args,
),
final context = ExecContext(
yaml: {},
secrets: katanaSecrets.existsSync()
? loadYaml(await katanaSecrets.readAsString())
: {},
args: args,
);
await tmp.value.exec(context);
for (final action in context.postActions) {
await action.exec(context);
}
return;
}
} else {
Expand All @@ -70,15 +72,17 @@ Future<void> main(List<String> args) async {
if (tmp.key != command) {
continue;
}
await tmp.value.exec(
ExecContext(
yaml: yaml,
secrets: katanaSecrets.existsSync()
? modifize(loadYaml(await katanaSecrets.readAsString()))
: {},
args: args,
),
final context = ExecContext(
yaml: yaml,
secrets: katanaSecrets.existsSync()
? modifize(loadYaml(await katanaSecrets.readAsString()))
: {},
args: args,
);
await tmp.value.exec(context);
for (final action in context.postActions) {
await action.exec(context);
}
return;
}
}
Expand Down
8 changes: 1 addition & 7 deletions packages/katana_cli/lib/action/ads/ads.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class AdsCliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
final ads = context.yaml.getAsMap("ads");
final androidAppId = ads.get("android_app_id", "");
final iosAppId = ads.get("ios_app_id", "");
Expand All @@ -47,12 +45,8 @@ class AdsCliAction extends CliCommand with CliActionMixin {
"Specify the app ID for Android or iOS in [ads]->[android_app_id] or [ads]->[ios_app_id].",
);
}
await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_ads_google",
],
);
Expand Down
31 changes: 13 additions & 18 deletions packages/katana_cli/lib/action/agora/agora.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import 'dart:io';

// Project imports:
import 'package:katana_cli/action/post/firebase_deploy_post_action.dart';
import 'package:katana_cli/katana_cli.dart';
import 'package:katana_cli/src/android_manifest.dart';

Expand Down Expand Up @@ -30,9 +31,6 @@ class AgoraCliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
final firebaseCommand = bin.get("firebase", "firebase");
final agora = context.yaml.getAsMap("agora");
final appId = agora.get("app_id", "");
final appCertificate = agora.get("app_certificate", "");
Expand Down Expand Up @@ -78,12 +76,8 @@ class AgoraCliAction extends CliCommand with CliActionMixin {
);
return;
}
await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_agora",
"katana_functions_firebase",
],
Expand Down Expand Up @@ -131,15 +125,16 @@ class AgoraCliAction extends CliCommand with CliActionMixin {
env["AGORA_APP_ID"] = appId;
env["AGORA_APP_CERTIFICATE"] = appCertificate;
await env.save();
await command(
"Deploy firebase functions.",
[
firebaseCommand,
"deploy",
"--only",
"functions",
],
workingDirectory: "firebase",
);
context.requestFirebaseDeploy(FirebaseDeployPostActionType.functions);
// await command(
// "Deploy firebase functions.",
// [
// firebaseCommand,
// "deploy",
// "--only",
// "functions",
// ],
// workingDirectory: "firebase",
// );
}
}
8 changes: 1 addition & 7 deletions packages/katana_cli/lib/action/app/calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ class AppCalendarCliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_calendar",
],
);
Expand Down
8 changes: 1 addition & 7 deletions packages/katana_cli/lib/action/app/deeplink.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class AppDeeplinkCliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
final deeplink = context.yaml.getAsMap("app").getAsMap("deeplink");
final host = deeplink.get("host", "");
final server = deeplink.getAsMap("server");
Expand Down Expand Up @@ -63,12 +61,8 @@ class AppDeeplinkCliAction extends CliCommand with CliActionMixin {
}
}

await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_deeplink",
],
);
Expand Down
31 changes: 13 additions & 18 deletions packages/katana_cli/lib/action/app/geocoding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import 'dart:io';

// Project imports:
import 'package:katana_cli/action/post/firebase_deploy_post_action.dart';
import 'package:katana_cli/katana_cli.dart';

/// Add a module to use GeocodingAPI.
Expand Down Expand Up @@ -29,9 +30,6 @@ class AppGeocodingCliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
final firebaseCommand = bin.get("firebase", "firebase");
final location = context.yaml.getAsMap("location");
final geocoding = location.getAsMap("geocoding");
final firebase = context.yaml.getAsMap("firebase");
Expand Down Expand Up @@ -63,12 +61,8 @@ class AppGeocodingCliAction extends CliCommand with CliActionMixin {
);
return;
}
await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_location_geocoding",
"katana_functions_firebase",
],
Expand All @@ -85,15 +79,16 @@ class AppGeocodingCliAction extends CliCommand with CliActionMixin {
await env.load();
env["MAP_GEOCODING_APIKEY"] = geocodingApiKey;
await env.save();
await command(
"Deploy firebase functions.",
[
firebaseCommand,
"deploy",
"--only",
"functions",
],
workingDirectory: "firebase",
);
context.requestFirebaseDeploy(FirebaseDeployPostActionType.functions);
// await command(
// "Deploy firebase functions.",
// [
// firebaseCommand,
// "deploy",
// "--only",
// "functions",
// ],
// workingDirectory: "firebase",
// );
}
}
8 changes: 1 addition & 7 deletions packages/katana_cli/lib/action/app/introduction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ class AppIntroductionCliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_introduction",
],
);
Expand Down
8 changes: 1 addition & 7 deletions packages/katana_cli/lib/action/app/location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class AppLocationCliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
final location = context.yaml.getAsMap("location");
final enableBackground = location.get("enable_background", false);
final googleMap = location.getAsMap("google_map");
Expand Down Expand Up @@ -275,12 +273,8 @@ class AppLocationCliAction extends CliCommand with CliActionMixin {
.where((key, value) => value.isNotEmpty),
);
await PodfilePermissionType.locationUsage.enablePermissionToPodfile();
await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_location",
],
);
Expand Down
8 changes: 1 addition & 7 deletions packages/katana_cli/lib/action/app/openai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ class AppOpenAICliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_ai_openai",
],
);
Expand Down
8 changes: 1 addition & 7 deletions packages/katana_cli/lib/action/app/picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class AppPickerCliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
final app = context.yaml.getAsMap("app");
if (app.isEmpty) {
error("The item [app] is missing. Please add an item.");
Expand All @@ -52,12 +50,8 @@ class AppPickerCliAction extends CliCommand with CliActionMixin {
.where((key, value) => value.isNotEmpty),
);
await PodfilePermissionType.photoLibraryUsage.enablePermissionToPodfile();
await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_picker",
],
);
Expand Down
8 changes: 1 addition & 7 deletions packages/katana_cli/lib/action/app/speech_to_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class AppSpeechToTextCliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
final stt = context.yaml.getAsMap("app").getAsMap("speech_to_text");
final permission = stt.getAsMap("permission");
if (permission.isEmpty) {
Expand All @@ -39,12 +37,8 @@ class AppSpeechToTextCliAction extends CliCommand with CliActionMixin {
);
return;
}
await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_speech_to_text",
],
);
Expand Down
8 changes: 1 addition & 7 deletions packages/katana_cli/lib/action/app/text_to_speech.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,8 @@ class AppTextToSpeechCliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_text_to_speech",
],
);
Expand Down
8 changes: 1 addition & 7 deletions packages/katana_cli/lib/action/ecosystem/ecosystem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class EcosystemCliAction extends CliCommand with CliActionMixin {

@override
Future<void> exec(ExecContext context) async {
final bin = context.yaml.getAsMap("bin");
final flutter = bin.get("flutter", "flutter");
final ecosystem = context.yaml.getAsMap("ecosystem");
final type = ecosystem.get("type", "");
switch (type) {
Expand Down Expand Up @@ -138,12 +136,8 @@ class EcosystemCliAction extends CliCommand with CliActionMixin {
"Specify the app ID for Android or iOS in [ads]->[android_app_id] or [ads]->[ios_app_id].",
);
}
await command(
"Import packages.",
await addFlutterImport(
[
flutter,
"pub",
"add",
"masamune_point_ecosystem",
],
);
Expand Down

0 comments on commit ea270c9

Please sign in to comment.