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 github = context.yaml.getAsMap("github");
final action = github.getAsMap("action");
final platforms = action.get("platform", "").trimString(" ").split(" ");
if (platforms.isEmpty) {
error(
"Platform is not specified. Please pass the platform you want to support as a parameter. Supported platforms are `android`, `ios`, `web`, `windows`, `macos`, and `linux`.",
);
return;
}
final incrementNumber = action.get("increment_number", 0);
final pubspecFile = File("pubspec.yaml");
final yaml = modifize(loadYaml(await pubspecFile.readAsString())) as Map;
final bin = context.yaml.getAsMap("bin");
final gh = bin.get("gh", "gh");
final name = yaml.get("name", "");
for (final platform in platforms) {
label("Create build.yaml for $platform");
switch (platform) {
case "android":
await buildAndroid(
context,
gh: gh,
appName: name,
defaultIncrementNumber: incrementNumber,
);
break;
case "ios":
await buildIOS(
context,
gh: gh,
appName: name,
defaultIncrementNumber: incrementNumber,
);
break;
case "web":
await buildWeb(
context,
gh: gh,
appName: name,
defaultIncrementNumber: incrementNumber,
);
break;
}
}
}