From 5fa801718f7f3fa56f1cb6c6f2cd5cd272550b1f Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Fri, 9 Oct 2020 15:43:39 -0700 Subject: [PATCH] [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 --- dev/bots/analyze.dart | 50 ------------------- packages/flutter_tools/lib/executable.dart | 4 -- .../lib/src/commands/inject_plugins.dart | 41 --------------- .../flutter_tools/lib/src/commands/train.dart | 27 ---------- .../command_output_test.dart | 2 - 5 files changed, 124 deletions(-) delete mode 100644 packages/flutter_tools/lib/src/commands/inject_plugins.dart delete mode 100644 packages/flutter_tools/lib/src/commands/train.dart diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index 2efc07a9453..3449c3ec818 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart @@ -64,9 +64,6 @@ Future run(List 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 verifyNoTestPackageImports(String workingDirectory) async { } } -Future verifyGeneratedPluginRegistrants(String flutterRoot) async { - final Directory flutterRootDir = Directory(flutterRoot); - - final Map> packageToRegistrants = >{}; - - for (final File file in flutterRootDir.listSync(recursive: true).whereType().where(_isGeneratedPluginRegistrant)) { - final String package = _getPackageFor(file, flutterRootDir); - final List registrants = packageToRegistrants.putIfAbsent(package, () => []); - registrants.add(file); - } - - final Set outOfDate = {}; - - for (final String package in packageToRegistrants.keys) { - final Map fileToContent = {}; - for (final File f in packageToRegistrants[package]) { - fileToContent[f] = f.readAsStringSync(); - } - await runCommand(flutter, ['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([ - '${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 verifyNoBadImportsInFlutter(String workingDirectory) async { final List errors = []; final String libPath = path.join(workingDirectory, 'packages', 'flutter', 'lib'); @@ -1294,15 +1253,6 @@ List _deepSearch(Map> map, T start, [ Set 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') diff --git a/packages/flutter_tools/lib/executable.dart b/packages/flutter_tools/lib/executable.dart index c625381f05a..dc8745c3fb0 100644 --- a/packages/flutter_tools/lib/executable.dart +++ b/packages/flutter_tools/lib/executable.dart @@ -28,7 +28,6 @@ import 'src/commands/format.dart'; import 'src/commands/generate.dart'; import 'src/commands/generate_localizations.dart'; import 'src/commands/ide_config.dart'; -import 'src/commands/inject_plugins.dart'; import 'src/commands/install.dart'; import 'src/commands/logs.dart'; import 'src/commands/make_host_app_editable.dart'; @@ -39,7 +38,6 @@ import 'src/commands/screenshot.dart'; import 'src/commands/shell_completion.dart'; import 'src/commands/symbolize.dart'; import 'src/commands/test.dart'; -import 'src/commands/train.dart'; import 'src/commands/update_packages.dart'; import 'src/commands/upgrade.dart'; import 'src/features.dart'; @@ -126,8 +124,6 @@ Future main(List args) async { ), // Development-only commands. These are always hidden, IdeConfigCommand(), - InjectPluginsCommand(), - TrainingCommand(), UpdatePackagesCommand(), ], verbose: verbose, muteCommandLogging: muteCommandLogging, diff --git a/packages/flutter_tools/lib/src/commands/inject_plugins.dart b/packages/flutter_tools/lib/src/commands/inject_plugins.dart deleted file mode 100644 index d3c8e09c13d..00000000000 --- a/packages/flutter_tools/lib/src/commands/inject_plugins.dart +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import '../globals.dart' as globals; -import '../plugins.dart'; -import '../project.dart'; -import '../runner/flutter_command.dart'; - -class InjectPluginsCommand extends FlutterCommand { - InjectPluginsCommand() { - requiresPubspecYaml(); - } - - @override - final String name = 'inject-plugins'; - - @override - final String description = 'Re-generates the GeneratedPluginRegistrants.'; - - @override - final bool hidden = true; - - @override - Future> get requiredArtifacts async => const {}; - - @override - Future runCommand() async { - final FlutterProject project = FlutterProject.current(); - await refreshPluginsList(project, checkProjects: true); - await injectPlugins(project, checkProjects: true); - final bool result = hasPlugins(project); - if (result) { - globals.printStatus('GeneratedPluginRegistrants successfully written.'); - } else { - globals.printStatus('This project does not use plugins, no GeneratedPluginRegistrants have been created.'); - } - - return FlutterCommandResult.success(); - } -} diff --git a/packages/flutter_tools/lib/src/commands/train.dart b/packages/flutter_tools/lib/src/commands/train.dart deleted file mode 100644 index 78f00fd9700..00000000000 --- a/packages/flutter_tools/lib/src/commands/train.dart +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import '../runner/flutter_command.dart'; - -/// This command is run when generating the app-JIT snapshot for the tool, so it cannot access the Cache -/// or any artifacts that haven't been downloaded yet. -class TrainingCommand extends FlutterCommand { - @override - String get description => 'training run for app-jit snapshot'; - - @override - String get name => 'training'; - - @override - bool get hidden => true; - - @override - bool get shouldUpdateCache => false; - - @override - Future runCommand() async { - // This command does not do anything yet :). - return FlutterCommandResult.success(); - } -} diff --git a/packages/flutter_tools/test/integration.shard/command_output_test.dart b/packages/flutter_tools/test/integration.shard/command_output_test.dart index da77ad74581..ffaa89f9cd3 100644 --- a/packages/flutter_tools/test/integration.shard/command_output_test.dart +++ b/packages/flutter_tools/test/integration.shard/command_output_test.dart @@ -22,9 +22,7 @@ void main() { ]); // Development tools. - expect(result.stdout, isNot(contains('ide-config'))); expect(result.stdout, isNot(contains('update-packages'))); - expect(result.stdout, isNot(contains('inject-plugins'))); // Deprecated. expect(result.stdout, isNot(contains('make-host-app-editable')));