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.

コマンドを実行します。

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

Implementation

@override
Future<void> exec(ExecContext context) async {
  final firebase = context.yaml.getAsMap("firebase");
  final projectId = firebase.get("project_id", "");
  final firestore = firebase.getAsMap("firestore");
  final database = firestore.getAsList<String>("database");
  if (projectId.isEmpty) {
    error(
      "The item [firebase]->[project_id] is missing. Please provide the Firebase project ID for the configuration.",
    );
    return;
  }
  label("Set firebase firestore config.");
  final file = File("firebase/firebase.json");
  final json = jsonDecodeAsMap(await file.readAsString());
  json["firestore"] = synchronizeFirestoreConfig(json["firestore"], database);
  await file.writeAsString(jsonEncode(json));
}