cleanOutdatedUniApiFiles function
Future<void>
cleanOutdatedUniApiFiles(
- UniAPIOptions options,
- String tempDirPath,
- ParseResults results
Implementation
Future<void> cleanOutdatedUniApiFiles(
UniAPIOptions options, String tempDirPath, ParseResults results) async {
final androidPath = options.javaOutputPath;
final flutterPath = options.dartOutput;
final iosPath = options.objcOutput;
final androidOutdatedFiles = <InputFile>[];
final flutterOutdatedFiles = <InputFile>[];
final iosOutdatedFiles = <InputFile>[];
if (androidPath.isNotEmpty) {
final androidFiles = await parseInputFiles(androidPath, tempDirPath);
androidOutdatedFiles.addAll(_findOutdatedFiles(androidFiles, results));
}
if (flutterPath.isNotEmpty) {
final flutterFiles = await parseInputFiles(flutterPath, tempDirPath);
flutterOutdatedFiles.addAll(_findOutdatedFiles(flutterFiles, results));
}
if (iosPath.isNotEmpty) {
final iosFiles = await parseInputFiles(iosPath, tempDirPath);
iosOutdatedFiles
.addAll(_findOutdatedFiles(iosFiles, results, options: options));
}
final outdatedFiles = [
...flutterOutdatedFiles,
...androidOutdatedFiles,
...iosOutdatedFiles
];
if (outdatedFiles.isEmpty) {
return;
}
printf('发现过时的接口生成代码:');
_showOutdatedFileInfo('Flutter', flutterOutdatedFiles);
_showOutdatedFileInfo('Android', androidOutdatedFiles);
_showOutdatedFileInfo('iOS', iosOutdatedFiles);
printf('\n 是否删除?(Y/N)');
final answer = stdin.readLineSync();
if (answer != 'Y' && answer != 'y') {
return;
}
for (final file in outdatedFiles) {
printf('delete ${file.absolutePath}');
File(file.absolutePath).deleteSync();
}
// After deleting the outdated interface, delete the empty directory again
await _cleanDir(androidPath);
await _cleanDir(iosPath);
await _cleanDir(flutterPath);
}