execute method

  1. @override
Future<void> execute(
  1. ArgResults results
)
override

Executes the command using the parsed results.

Implementation

@override
Future<void> execute(ArgResults results) async {
  if (results.rest.isEmpty) {
    LoggerService.error('Usage: $usage');
    return;
  }

  final flavor = results.rest.first;

  final platform = results['platform'] as String;

  final config = await ConfigService.load();

  final notes = results['notes'] as String? ?? 'Automated build upload via FKIT';

  final testerGroup = results['group'] as String? ?? config.testerGroup;

  final flavorConfig = config.flavors[flavor];

  if (flavorConfig == null) {
    LoggerService.error('Flavor "$flavor" not found.');
    return;
  }

  if (!PlatformUtils.isEnabled(config, platform)) {
    LoggerService.error('$platform is disabled in fkit.yaml.');
    return;
  }

  final appId = PlatformUtils.firebaseAppId(flavorConfig, platform);

  if (appId.isEmpty) {
    LoggerService.error('$platform Firebase App ID is not configured.');
    return;
  }

  final buildResult = await BuildService().build(platform: PlatformUtils.buildPlatform(platform), flavor: flavor);

  await FirebaseService().upload(appId: appId, artifactPath: buildResult.artifactPath, testerGroup: testerGroup, notes: notes);

  LoggerService.blank();
  LoggerService.success('Firebase upload completed successfully.');
  LoggerService.blank();
}