[flutter_tools] remove train and inject-plugins command (#67766)
The train command does nothing and was originally added to provide a no-output default for generating app-jit snapshots. The inject-plugins command is only for a repo-only analysis check, which is not necessary since we regenerate during pub get. #29805
This commit is contained in:
@@ -64,9 +64,6 @@ Future<void> run(List<String> arguments) async {
|
||||
print('$clock Test package imports...');
|
||||
await verifyNoTestPackageImports(flutterRoot);
|
||||
|
||||
print('$clock Generated plugin registrants...');
|
||||
await verifyGeneratedPluginRegistrants(flutterRoot);
|
||||
|
||||
print('$clock Bad imports (framework)...');
|
||||
await verifyNoBadImportsInFlutter(flutterRoot);
|
||||
|
||||
@@ -369,44 +366,6 @@ Future<void> verifyNoTestPackageImports(String workingDirectory) async {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> verifyGeneratedPluginRegistrants(String flutterRoot) async {
|
||||
final Directory flutterRootDir = Directory(flutterRoot);
|
||||
|
||||
final Map<String, List<File>> packageToRegistrants = <String, List<File>>{};
|
||||
|
||||
for (final File file in flutterRootDir.listSync(recursive: true).whereType<File>().where(_isGeneratedPluginRegistrant)) {
|
||||
final String package = _getPackageFor(file, flutterRootDir);
|
||||
final List<File> registrants = packageToRegistrants.putIfAbsent(package, () => <File>[]);
|
||||
registrants.add(file);
|
||||
}
|
||||
|
||||
final Set<String> outOfDate = <String>{};
|
||||
|
||||
for (final String package in packageToRegistrants.keys) {
|
||||
final Map<File, String> fileToContent = <File, String>{};
|
||||
for (final File f in packageToRegistrants[package]) {
|
||||
fileToContent[f] = f.readAsStringSync();
|
||||
}
|
||||
await runCommand(flutter, <String>['inject-plugins'],
|
||||
workingDirectory: package,
|
||||
outputMode: OutputMode.discard,
|
||||
);
|
||||
for (final File registrant in fileToContent.keys) {
|
||||
if (registrant.readAsStringSync() != fileToContent[registrant]) {
|
||||
outOfDate.add(registrant.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (outOfDate.isNotEmpty) {
|
||||
exitWithError(<String>[
|
||||
'${bold}The following GeneratedPluginRegistrants are out of date:$reset',
|
||||
for (String registrant in outOfDate) ' - $registrant',
|
||||
'\nRun "flutter inject-plugins" in the package that\'s out of date.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> verifyNoBadImportsInFlutter(String workingDirectory) async {
|
||||
final List<String> errors = <String>[];
|
||||
final String libPath = path.join(workingDirectory, 'packages', 'flutter', 'lib');
|
||||
@@ -1294,15 +1253,6 @@ List<T> _deepSearch<T>(Map<T, Set<T>> map, T start, [ Set<T> seen ]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String _getPackageFor(File entity, Directory flutterRootDir) {
|
||||
for (Directory dir = entity.parent; dir != flutterRootDir; dir = dir.parent) {
|
||||
if (File(path.join(dir.path, 'pubspec.yaml')).existsSync()) {
|
||||
return dir.path;
|
||||
}
|
||||
}
|
||||
throw ArgumentError('$entity is not within a dart package.');
|
||||
}
|
||||
|
||||
bool _isGeneratedPluginRegistrant(File file) {
|
||||
final String filename = path.basename(file.path);
|
||||
return !file.path.contains('.pub-cache')
|
||||
|
||||
Reference in New Issue
Block a user