generate method
Implementation
Future<void> generate(String configFilePath, String className) async {
print(Colorize('✓ Info: starting process')..green());
if (!await Directory('./ios').exists()) {
print(Colorize('✗ Error: failed to find ios project')..red());
return;
}
if (!await Directory('./android').exists()) {
print(Colorize('✗ Error: failed to find android project')..red());
return;
}
if (!await File(configFilePath).exists()) {
print(Colorize(
'✗ Error: failed to find config file at path $configFilePath')
..red());
return;
}
final config = await _loadConfig(configFilePath);
if (config == null) {
print(Colorize('✗ Error: failed to parse $configFilePath')..red());
return;
}
final manifestXML = await _readAndroidManifestFile();
final androidPackageName = _getPackageName(manifestXML);
if (androidPackageName == null) {
print(Colorize('✗ Error: failed to find android package name')..red());
return;
}
final YamlMap? variables = config['variables'];
if (variables != null) {
await _generateCodeFiles(className, variables, androidPackageName);
} else {
print(Colorize('️⚠ Warning: variables key not found')..yellow());
}
final YamlMap? files = config['files'];
if (files != null) {
await _copyFiles(files);
} else {
print(Colorize('⚠ Warning: files key not found')..yellow());
}
}