execute method
Implementation
Future<void> execute(String filePath) async {
final file = File(filePath);
if (!file.existsSync()) {
_log.error('❌ Error: Config file "$filePath" not found.');
return;
}
try {
final content = await file.readAsString();
final yamlMap = loadYaml(content);
final jsonMap = YamlUtils.yamlToMap(yamlMap);
FlavorConfig config = ConfigValidator.validate(jsonMap);
if (config.flavorAppNames?.isEmpty ?? true) {
final flavorAppNames = <String, String>{};
for (final flavor in config.flavors) {
flavorAppNames[flavor] = flavor == config.productionFlavor
? config.appName
: '${config.appName}-$flavor';
}
config = config.copyWith(flavorAppNames: flavorAppNames);
}
await SetupRunner(logger: _log).run(config);
} on FormatException catch (e) {
// ConfigValidator throws FormatException with the exact error details
_log.error(e.message);
} catch (e) {
if (e is CliException && e.isLogged) return;
_log.error('❌ Error: Failed to parse "$filePath" as YAML.\n$e');
}
}