exec method

  1. @override
Future<void> exec(
  1. ExecContext context
)
override

Run command.

The contents of katana.yaml and the arguments of the command are passed to context.

コマンドを実行します。

contextkatana.yamlの内容やコマンドの引数が渡されます。

Implementation

@override
Future<void> exec(ExecContext context) async {
  final apply = context.args.contains("--apply");
  if (apply && context.args.contains("--dry-run")) {
    throw ArgumentError("--apply and --dry-run cannot be used together.");
  }
  final plan = KatanaEnvironmentFixPlan.inspect();
  // ignore: avoid_print
  print(plan.describe());
  if (!apply) {
    // ignore: avoid_print
    print("Diagnostic only. Run `katana fix --apply` to migrate.");
    return;
  }
  await plan.apply(
    flavor: context.flavorContext?.flavor.name ?? "prod",
    firebaseProjectId:
        context.yaml.getAsMap("firebase").get("project_id", ""),
  );
  // ignore: avoid_print
  print("Katana environment migration completed.");
}