exec method
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 app = context.yaml.getAsMap("app");
if (app.isEmpty) {
error("The item [app] is missing. Please add an item.");
return;
}
final picker = app.getAsMap("picker");
if (picker.isEmpty) {
error("The item [app]->[picker] is missing. Please add an item.");
return;
}
final permission = picker.getAsMap("permission");
if (permission.isEmpty) {
error(
"The item [app]->[picker]->[permission] is missing. Please include the language code and the message when authorization is granted here.",
);
return;
}
final camera = picker.getAsMap("camera");
final cameraEnabled = camera.get("enable", false);
final cameraPermission = camera.getAsMap("permission");
if (cameraEnabled && cameraPermission.isEmpty) {
error(
"The item [app]->[picker]->[camera]->[permission] is missing. Please include the language code and the message when authorization is granted here.",
);
return;
}
label("Addition of permission messages.");
await XCodePermissionType.photoLibraryUsage.setMessageToXCode(
permission
.map((key, value) => MapEntry(key, value.toString()))
.where((key, value) => value.isNotEmpty),
);
await PodfilePermissionType.photoLibraryUsage.enablePermissionToPodfile();
if (cameraEnabled) {
await XCodePermissionType.cameraUsage.setMessageToXCode(
permission
.map((key, value) => MapEntry(key, value.toString()))
.where((key, value) => value.isNotEmpty),
);
await PodfilePermissionType.cameraUsage.enablePermissionToPodfile();
}
await addFlutterImport(
[
"masamune_picker",
],
);
label("Edit PrivacyInfo.xcprivacy.");
await XCodePrivacyManifests.fileTimestamp.setPrivacyManifestToXCode(
XCodePrivacyManifests.fileTimestamp.reasons.first,
);
}