From 284b337e6874f849758be4e149314ab1613a8a0b Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Fri, 7 Jul 2023 12:17:12 -0400 Subject: [PATCH] [tool] Update Dart SDK version Since the tool only needs to support back to Flutter 3.3 (the oldest version we still run CI with), this updates the tool to the corresponding minimum Dart version. This allows the use of `super` parameters, so `dart fix --apply` was run to convert them all (and remove all the includes that were only needed for setting default values). Also opportunistically cleans up a bunch of unnecessry very old `dart:async` includes. --- script/tool/lib/src/analyze_command.dart | 12 ++++------- .../tool/lib/src/build_examples_command.dart | 12 ++++------- .../src/common/package_looping_command.dart | 14 +++++-------- script/tool/lib/src/custom_test_command.dart | 10 ++++----- script/tool/lib/src/dart_test_command.dart | 10 ++++----- .../lib/src/dependabot_check_command.dart | 6 +----- .../tool/lib/src/drive_examples_command.dart | 11 ++++------ .../src/federation_safety_check_command.dart | 18 +++++----------- .../lib/src/firebase_test_lab_command.dart | 11 ++++------ script/tool/lib/src/fix_command.dart | 14 ++++--------- script/tool/lib/src/format_command.dart | 10 ++++----- script/tool/lib/src/gradle_check_command.dart | 2 +- .../tool/lib/src/license_check_command.dart | 6 +----- script/tool/lib/src/lint_android_command.dart | 12 ++++------- script/tool/lib/src/list_command.dart | 7 +++---- .../lib/src/make_deps_path_based_command.dart | 7 +++---- script/tool/lib/src/native_test_command.dart | 11 ++++------ .../tool/lib/src/podspec_check_command.dart | 10 ++++----- .../tool/lib/src/publish_check_command.dart | 14 +++++-------- script/tool/lib/src/publish_command.dart | 13 +++++------- .../tool/lib/src/pubspec_check_command.dart | 18 +++++----------- script/tool/lib/src/readme_check_command.dart | 18 +++++----------- .../src/remove_dev_dependencies_command.dart | 3 +-- .../lib/src/update_dependency_command.dart | 10 ++++----- .../tool/lib/src/update_excerpts_command.dart | 18 +++++----------- .../tool/lib/src/update_min_sdk_command.dart | 3 +-- .../lib/src/update_release_info_command.dart | 7 +++---- .../tool/lib/src/version_check_command.dart | 21 ++++++------------- .../tool/lib/src/xcode_analyze_command.dart | 13 ++++-------- script/tool/pubspec.yaml | 2 +- .../test/common/package_command_test.dart | 13 +++++------- .../common/package_looping_command_test.dart | 14 +++++-------- .../tool/test/common/plugin_utils_test.dart | 9 +++++--- 33 files changed, 124 insertions(+), 235 deletions(-) diff --git a/script/tool/lib/src/analyze_command.dart b/script/tool/lib/src/analyze_command.dart index c7a953c50ca..c8b576587d0 100644 --- a/script/tool/lib/src/analyze_command.dart +++ b/script/tool/lib/src/analyze_command.dart @@ -2,25 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; - import 'package:file/file.dart'; -import 'package:platform/platform.dart'; import 'package:yaml/yaml.dart'; import 'common/core.dart'; import 'common/package_looping_command.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; /// A command to run Dart analysis on packages. class AnalyzeCommand extends PackageLoopingCommand { /// Creates a analysis command instance. AnalyzeCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : super(packagesDir, processRunner: processRunner, platform: platform) { + super.packagesDir, { + super.processRunner, + super.platform, + }) { argParser.addMultiOption(_customAnalysisFlag, help: 'Directories (comma separated) that are allowed to have their own ' diff --git a/script/tool/lib/src/build_examples_command.dart b/script/tool/lib/src/build_examples_command.dart index 29af2e69ebd..5b5866ec03b 100644 --- a/script/tool/lib/src/build_examples_command.dart +++ b/script/tool/lib/src/build_examples_command.dart @@ -2,16 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; - import 'package:file/file.dart'; -import 'package:platform/platform.dart'; import 'package:yaml/yaml.dart'; import 'common/core.dart'; import 'common/package_looping_command.dart'; import 'common/plugin_utils.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; /// Key for APK. @@ -45,10 +41,10 @@ const String _flutterBuildTypeAndroidAlias = 'android'; class BuildExamplesCommand extends PackageLoopingCommand { /// Creates an instance of the build command. BuildExamplesCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : super(packagesDir, processRunner: processRunner, platform: platform) { + super.packagesDir, { + super.processRunner, + super.platform, + }) { argParser.addFlag(platformLinux); argParser.addFlag(platformMacOS); argParser.addFlag(platformWeb); diff --git a/script/tool/lib/src/common/package_looping_command.dart b/script/tool/lib/src/common/package_looping_command.dart index 5462f5378c7..f014fb21ace 100644 --- a/script/tool/lib/src/common/package_looping_command.dart +++ b/script/tool/lib/src/common/package_looping_command.dart @@ -6,14 +6,11 @@ import 'dart:async'; import 'package:colorize/colorize.dart'; import 'package:file/file.dart'; -import 'package:git/git.dart'; import 'package:path/path.dart' as p; -import 'package:platform/platform.dart'; import 'package:pub_semver/pub_semver.dart'; import 'core.dart'; import 'package_command.dart'; -import 'process_runner.dart'; import 'repository_package.dart'; /// Enumeration options for package looping commands. @@ -85,12 +82,11 @@ class PackageResult { abstract class PackageLoopingCommand extends PackageCommand { /// Creates a command to operate on [packagesDir] with the given environment. PackageLoopingCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - GitDir? gitDir, - }) : super(packagesDir, - processRunner: processRunner, platform: platform, gitDir: gitDir) { + super.packagesDir, { + super.processRunner, + super.platform, + super.gitDir, + }) { argParser.addOption( _skipByFlutterVersionArg, help: 'Skip any packages that require a Flutter version newer than ' diff --git a/script/tool/lib/src/custom_test_command.dart b/script/tool/lib/src/custom_test_command.dart index aac8fa8122c..9c8f36e38a3 100644 --- a/script/tool/lib/src/custom_test_command.dart +++ b/script/tool/lib/src/custom_test_command.dart @@ -3,10 +3,8 @@ // found in the LICENSE file. import 'package:file/file.dart'; -import 'package:platform/platform.dart'; import 'common/package_looping_command.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; const String _scriptName = 'run_tests.dart'; @@ -20,10 +18,10 @@ const String _legacyScriptName = 'run_tests.sh'; class CustomTestCommand extends PackageLoopingCommand { /// Creates a custom test command instance. CustomTestCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : super(packagesDir, processRunner: processRunner, platform: platform); + super.packagesDir, { + super.processRunner, + super.platform, + }); @override final String name = 'custom-test'; diff --git a/script/tool/lib/src/dart_test_command.dart b/script/tool/lib/src/dart_test_command.dart index cd564a84060..c4b2fb85953 100644 --- a/script/tool/lib/src/dart_test_command.dart +++ b/script/tool/lib/src/dart_test_command.dart @@ -3,22 +3,20 @@ // found in the LICENSE file. import 'package:file/file.dart'; -import 'package:platform/platform.dart'; import 'common/core.dart'; import 'common/package_looping_command.dart'; import 'common/plugin_utils.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; /// A command to run Dart unit tests for packages. class DartTestCommand extends PackageLoopingCommand { /// Creates an instance of the test command. DartTestCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : super(packagesDir, processRunner: processRunner, platform: platform) { + super.packagesDir, { + super.processRunner, + super.platform, + }) { argParser.addOption( kEnableExperiment, defaultsTo: '', diff --git a/script/tool/lib/src/dependabot_check_command.dart b/script/tool/lib/src/dependabot_check_command.dart index d16fb33e92f..032ea32fca4 100644 --- a/script/tool/lib/src/dependabot_check_command.dart +++ b/script/tool/lib/src/dependabot_check_command.dart @@ -2,10 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; - import 'package:file/file.dart'; -import 'package:git/git.dart'; import 'package:yaml/yaml.dart'; import 'common/core.dart'; @@ -15,8 +12,7 @@ import 'common/repository_package.dart'; /// A command to verify Dependabot configuration coverage of packages. class DependabotCheckCommand extends PackageLoopingCommand { /// Creates Dependabot check command instance. - DependabotCheckCommand(Directory packagesDir, {GitDir? gitDir}) - : super(packagesDir, gitDir: gitDir) { + DependabotCheckCommand(super.packagesDir, {super.gitDir}) { argParser.addOption(_configPathFlag, help: 'Path to the Dependabot configuration file', defaultsTo: '.github/dependabot.yml'); diff --git a/script/tool/lib/src/drive_examples_command.dart b/script/tool/lib/src/drive_examples_command.dart index 18354d83777..24acb9b43e9 100644 --- a/script/tool/lib/src/drive_examples_command.dart +++ b/script/tool/lib/src/drive_examples_command.dart @@ -2,17 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'package:file/file.dart'; -import 'package:platform/platform.dart'; import 'common/core.dart'; import 'common/package_looping_command.dart'; import 'common/plugin_utils.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; const int _exitNoPlatformFlags = 2; @@ -25,10 +22,10 @@ const int _chromeDriverPort = 4444; class DriveExamplesCommand extends PackageLoopingCommand { /// Creates an instance of the drive command. DriveExamplesCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : super(packagesDir, processRunner: processRunner, platform: platform) { + super.packagesDir, { + super.processRunner, + super.platform, + }) { argParser.addFlag(platformAndroid, help: 'Runs the Android implementation of the examples', aliases: const [platformAndroidAlias]); diff --git a/script/tool/lib/src/federation_safety_check_command.dart b/script/tool/lib/src/federation_safety_check_command.dart index 837193b1ccc..ec4b98879d7 100644 --- a/script/tool/lib/src/federation_safety_check_command.dart +++ b/script/tool/lib/src/federation_safety_check_command.dart @@ -3,9 +3,7 @@ // found in the LICENSE file. import 'package:file/file.dart'; -import 'package:git/git.dart'; import 'package:path/path.dart' as p; -import 'package:platform/platform.dart'; import 'package:pub_semver/pub_semver.dart'; import 'common/core.dart'; @@ -13,7 +11,6 @@ import 'common/file_utils.dart'; import 'common/git_version_finder.dart'; import 'common/package_looping_command.dart'; import 'common/plugin_utils.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; /// A command to check that PRs don't violate repository best practices that @@ -22,16 +19,11 @@ import 'common/repository_package.dart'; class FederationSafetyCheckCommand extends PackageLoopingCommand { /// Creates an instance of the safety check command. FederationSafetyCheckCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - GitDir? gitDir, - }) : super( - packagesDir, - processRunner: processRunner, - platform: platform, - gitDir: gitDir, - ); + super.packagesDir, { + super.processRunner, + super.platform, + super.gitDir, + }); // A map of package name (as defined by the directory name of the package) // to a list of changed Dart files in that package, as Posix paths relative to diff --git a/script/tool/lib/src/firebase_test_lab_command.dart b/script/tool/lib/src/firebase_test_lab_command.dart index b679c1a27c5..07335959a2b 100644 --- a/script/tool/lib/src/firebase_test_lab_command.dart +++ b/script/tool/lib/src/firebase_test_lab_command.dart @@ -2,18 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; import 'dart:io' as io; import 'package:file/file.dart'; -import 'package:platform/platform.dart'; import 'package:uuid/uuid.dart'; import 'common/core.dart'; import 'common/gradle.dart'; import 'common/package_looping_command.dart'; import 'common/plugin_utils.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; const int _exitGcloudAuthFailed = 2; @@ -22,10 +19,10 @@ const int _exitGcloudAuthFailed = 2; class FirebaseTestLabCommand extends PackageLoopingCommand { /// Creates an instance of the test runner command. FirebaseTestLabCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : super(packagesDir, processRunner: processRunner, platform: platform) { + super.packagesDir, { + super.processRunner, + super.platform, + }) { argParser.addOption( 'project', defaultsTo: 'flutter-cirrus', diff --git a/script/tool/lib/src/fix_command.dart b/script/tool/lib/src/fix_command.dart index 2819609eabb..a35508bcf8e 100644 --- a/script/tool/lib/src/fix_command.dart +++ b/script/tool/lib/src/fix_command.dart @@ -2,24 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; - -import 'package:file/file.dart'; -import 'package:platform/platform.dart'; - import 'common/core.dart'; import 'common/package_looping_command.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; /// A command to run Dart's "fix" command on packages. class FixCommand extends PackageLoopingCommand { /// Creates a fix command instance. FixCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : super(packagesDir, processRunner: processRunner, platform: platform); + super.packagesDir, { + super.processRunner, + super.platform, + }); @override final String name = 'fix'; diff --git a/script/tool/lib/src/format_command.dart b/script/tool/lib/src/format_command.dart index 30a5565f232..b7f1745f5e9 100644 --- a/script/tool/lib/src/format_command.dart +++ b/script/tool/lib/src/format_command.dart @@ -8,11 +8,9 @@ import 'dart:io' as io; import 'package:file/file.dart'; import 'package:http/http.dart' as http; import 'package:meta/meta.dart'; -import 'package:platform/platform.dart'; import 'common/core.dart'; import 'common/package_command.dart'; -import 'common/process_runner.dart'; /// In theory this should be 8191, but in practice that was still resulting in /// "The input line is too long" errors. This was chosen as a value that worked @@ -40,10 +38,10 @@ final Uri _googleFormatterUrl = Uri.https('github.com', class FormatCommand extends PackageCommand { /// Creates an instance of the format command. FormatCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : super(packagesDir, processRunner: processRunner, platform: platform) { + super.packagesDir, { + super.processRunner, + super.platform, + }) { argParser.addFlag('fail-on-change', hide: true); argParser.addOption('clang-format', defaultsTo: 'clang-format', help: 'Path to "clang-format" executable.'); diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index cbce766b376..6eaaa0308f0 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -18,7 +18,7 @@ final Version minKotlinVersion = Version(1, 7, 10); /// A command to enforce gradle file conventions and best practices. class GradleCheckCommand extends PackageLoopingCommand { /// Creates an instance of the gradle check command. - GradleCheckCommand(Directory packagesDir) : super(packagesDir); + GradleCheckCommand(super.packagesDir); @override final String name = 'gradle-check'; diff --git a/script/tool/lib/src/license_check_command.dart b/script/tool/lib/src/license_check_command.dart index a8d4a7be5f6..dcc8c2711ce 100644 --- a/script/tool/lib/src/license_check_command.dart +++ b/script/tool/lib/src/license_check_command.dart @@ -3,9 +3,7 @@ // found in the LICENSE file. import 'package:file/file.dart'; -import 'package:git/git.dart'; import 'package:path/path.dart' as p; -import 'package:platform/platform.dart'; import 'common/core.dart'; import 'common/package_command.dart'; @@ -107,9 +105,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /// Validates that code files have copyright and license blocks. class LicenseCheckCommand extends PackageCommand { /// Creates a new license check command for [packagesDir]. - LicenseCheckCommand(Directory packagesDir, - {Platform platform = const LocalPlatform(), GitDir? gitDir}) - : super(packagesDir, platform: platform, gitDir: gitDir); + LicenseCheckCommand(super.packagesDir, {super.platform, super.gitDir}); @override final String name = 'license-check'; diff --git a/script/tool/lib/src/lint_android_command.dart b/script/tool/lib/src/lint_android_command.dart index 9b875e78560..8d82baf7152 100644 --- a/script/tool/lib/src/lint_android_command.dart +++ b/script/tool/lib/src/lint_android_command.dart @@ -2,14 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:file/file.dart'; -import 'package:platform/platform.dart'; - import 'common/core.dart'; import 'common/gradle.dart'; import 'common/package_looping_command.dart'; import 'common/plugin_utils.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; /// Run 'gradlew lint'. @@ -18,10 +14,10 @@ import 'common/repository_package.dart'; class LintAndroidCommand extends PackageLoopingCommand { /// Creates an instance of the linter command. LintAndroidCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : super(packagesDir, processRunner: processRunner, platform: platform); + super.packagesDir, { + super.processRunner, + super.platform, + }); @override final String name = 'lint-android'; diff --git a/script/tool/lib/src/list_command.dart b/script/tool/lib/src/list_command.dart index b47657e47ef..f4becce078a 100644 --- a/script/tool/lib/src/list_command.dart +++ b/script/tool/lib/src/list_command.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:file/file.dart'; -import 'package:platform/platform.dart'; import 'common/package_command.dart'; import 'common/repository_package.dart'; @@ -13,9 +12,9 @@ class ListCommand extends PackageCommand { /// Creates an instance of the list command, whose behavior depends on the /// 'type' argument it provides. ListCommand( - Directory packagesDir, { - Platform platform = const LocalPlatform(), - }) : super(packagesDir, platform: platform) { + super.packagesDir, { + super.platform, + }) { argParser.addOption( _type, defaultsTo: _package, diff --git a/script/tool/lib/src/make_deps_path_based_command.dart b/script/tool/lib/src/make_deps_path_based_command.dart index 8884a3deddc..9561dbb45ea 100644 --- a/script/tool/lib/src/make_deps_path_based_command.dart +++ b/script/tool/lib/src/make_deps_path_based_command.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:file/file.dart'; -import 'package:git/git.dart'; import 'package:path/path.dart' as p; import 'package:pub_semver/pub_semver.dart'; import 'package:pubspec_parse/pubspec_parse.dart'; @@ -28,9 +27,9 @@ class MakeDepsPathBasedCommand extends PackageCommand { /// Creates an instance of the command to convert selected dependencies to /// path-based. MakeDepsPathBasedCommand( - Directory packagesDir, { - GitDir? gitDir, - }) : super(packagesDir, gitDir: gitDir) { + super.packagesDir, { + super.gitDir, + }) { argParser.addMultiOption(_targetDependenciesArg, help: 'The names of the packages to convert to path-based dependencies.\n' diff --git a/script/tool/lib/src/native_test_command.dart b/script/tool/lib/src/native_test_command.dart index 978c41bdf8c..7d7bc0405e8 100644 --- a/script/tool/lib/src/native_test_command.dart +++ b/script/tool/lib/src/native_test_command.dart @@ -4,14 +4,12 @@ import 'package:file/file.dart'; import 'package:meta/meta.dart'; -import 'package:platform/platform.dart'; import 'common/cmake.dart'; import 'common/core.dart'; import 'common/gradle.dart'; import 'common/package_looping_command.dart'; import 'common/plugin_utils.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; import 'common/xcode.dart'; @@ -39,11 +37,10 @@ const String misconfiguredJavaIntegrationTestErrorExplanation = class NativeTestCommand extends PackageLoopingCommand { /// Creates an instance of the test command. NativeTestCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : _xcode = Xcode(processRunner: processRunner, log: true), - super(packagesDir, processRunner: processRunner, platform: platform) { + super.packagesDir, { + super.processRunner, + super.platform, + }) : _xcode = Xcode(processRunner: processRunner, log: true) { argParser.addOption( _iOSDestinationFlag, help: 'Specify the destination when running iOS tests.\n' diff --git a/script/tool/lib/src/podspec_check_command.dart b/script/tool/lib/src/podspec_check_command.dart index 9fcaa469955..31773122cd9 100644 --- a/script/tool/lib/src/podspec_check_command.dart +++ b/script/tool/lib/src/podspec_check_command.dart @@ -6,11 +6,9 @@ import 'dart:convert'; import 'dart:io'; import 'package:file/file.dart'; -import 'package:platform/platform.dart'; import 'common/core.dart'; import 'common/package_looping_command.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; const int _exitUnsupportedPlatform = 2; @@ -22,10 +20,10 @@ const int _exitPodNotInstalled = 3; class PodspecCheckCommand extends PackageLoopingCommand { /// Creates an instance of the linter command. PodspecCheckCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : super(packagesDir, processRunner: processRunner, platform: platform); + super.packagesDir, { + super.processRunner, + super.platform, + }); @override final String name = 'podspec-check'; diff --git a/script/tool/lib/src/publish_check_command.dart b/script/tool/lib/src/publish_check_command.dart index 0ac01535b44..1187de5b756 100644 --- a/script/tool/lib/src/publish_check_command.dart +++ b/script/tool/lib/src/publish_check_command.dart @@ -6,14 +6,11 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io' as io; -import 'package:file/file.dart'; import 'package:http/http.dart' as http; -import 'package:platform/platform.dart'; import 'package:pub_semver/pub_semver.dart'; import 'common/core.dart'; import 'common/package_looping_command.dart'; -import 'common/process_runner.dart'; import 'common/pub_version_finder.dart'; import 'common/repository_package.dart'; @@ -21,13 +18,12 @@ import 'common/repository_package.dart'; class PublishCheckCommand extends PackageLoopingCommand { /// Creates an instance of the publish command. PublishCheckCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), + super.packagesDir, { + super.processRunner, + super.platform, http.Client? httpClient, - }) : _pubVersionFinder = - PubVersionFinder(httpClient: httpClient ?? http.Client()), - super(packagesDir, processRunner: processRunner, platform: platform) { + }) : _pubVersionFinder = + PubVersionFinder(httpClient: httpClient ?? http.Client()) { argParser.addFlag( _allowPrereleaseFlag, help: 'Allows the pre-release SDK warning to pass.\n' diff --git a/script/tool/lib/src/publish_command.dart b/script/tool/lib/src/publish_command.dart index fb197ccd3ab..e8eadb7982e 100644 --- a/script/tool/lib/src/publish_command.dart +++ b/script/tool/lib/src/publish_command.dart @@ -20,7 +20,6 @@ import 'common/file_utils.dart'; import 'common/git_version_finder.dart'; import 'common/package_command.dart'; import 'common/package_looping_command.dart'; -import 'common/process_runner.dart'; import 'common/pub_version_finder.dart'; import 'common/repository_package.dart'; @@ -49,17 +48,15 @@ class _RemoteInfo { class PublishCommand extends PackageLoopingCommand { /// Creates an instance of the publish command. PublishCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), + super.packagesDir, { + super.processRunner, + super.platform, io.Stdin? stdinput, - GitDir? gitDir, + super.gitDir, http.Client? httpClient, }) : _pubVersionFinder = PubVersionFinder(httpClient: httpClient ?? http.Client()), - _stdin = stdinput ?? io.stdin, - super(packagesDir, - platform: platform, processRunner: processRunner, gitDir: gitDir) { + _stdin = stdinput ?? io.stdin { argParser.addMultiOption(_pubFlagsOption, help: 'A list of options that will be forwarded on to pub. Separate multiple flags with commas.'); diff --git a/script/tool/lib/src/pubspec_check_command.dart b/script/tool/lib/src/pubspec_check_command.dart index 838aac0541b..976e6b70678 100644 --- a/script/tool/lib/src/pubspec_check_command.dart +++ b/script/tool/lib/src/pubspec_check_command.dart @@ -3,16 +3,13 @@ // found in the LICENSE file. import 'package:file/file.dart'; -import 'package:git/git.dart'; import 'package:path/path.dart' as p; -import 'package:platform/platform.dart'; import 'package:pub_semver/pub_semver.dart'; import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:yaml/yaml.dart'; import 'common/core.dart'; import 'common/package_looping_command.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; /// A command to enforce pubspec conventions across the repository. @@ -23,16 +20,11 @@ import 'common/repository_package.dart'; class PubspecCheckCommand extends PackageLoopingCommand { /// Creates an instance of the version check command. PubspecCheckCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - GitDir? gitDir, - }) : super( - packagesDir, - processRunner: processRunner, - platform: platform, - gitDir: gitDir, - ) { + super.packagesDir, { + super.processRunner, + super.platform, + super.gitDir, + }) { argParser.addOption( _minMinFlutterVersionFlag, help: diff --git a/script/tool/lib/src/readme_check_command.dart b/script/tool/lib/src/readme_check_command.dart index 7e28979c956..81f401510f1 100644 --- a/script/tool/lib/src/readme_check_command.dart +++ b/script/tool/lib/src/readme_check_command.dart @@ -3,13 +3,10 @@ // found in the LICENSE file. import 'package:file/file.dart'; -import 'package:git/git.dart'; -import 'package:platform/platform.dart'; import 'package:yaml/yaml.dart'; import 'common/core.dart'; import 'common/package_looping_command.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; const String _instructionWikiUrl = @@ -19,16 +16,11 @@ const String _instructionWikiUrl = class ReadmeCheckCommand extends PackageLoopingCommand { /// Creates an instance of the README check command. ReadmeCheckCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - GitDir? gitDir, - }) : super( - packagesDir, - processRunner: processRunner, - platform: platform, - gitDir: gitDir, - ) { + super.packagesDir, { + super.processRunner, + super.platform, + super.gitDir, + }) { argParser.addFlag(_requireExcerptsArg, help: 'Require that Dart code blocks be managed by code-excerpt.'); } diff --git a/script/tool/lib/src/remove_dev_dependencies_command.dart b/script/tool/lib/src/remove_dev_dependencies_command.dart index 3085e0df85e..0b74e79f00d 100644 --- a/script/tool/lib/src/remove_dev_dependencies_command.dart +++ b/script/tool/lib/src/remove_dev_dependencies_command.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:file/file.dart'; import 'package:yaml/yaml.dart'; import 'package:yaml_edit/yaml_edit.dart'; @@ -16,7 +15,7 @@ import 'common/repository_package.dart'; /// clients of the library, but not for development of the library. class RemoveDevDependenciesCommand extends PackageLoopingCommand { /// Creates a publish metadata updater command instance. - RemoveDevDependenciesCommand(Directory packagesDir) : super(packagesDir); + RemoveDevDependenciesCommand(super.packagesDir); @override final String name = 'remove-dev-dependencies'; diff --git a/script/tool/lib/src/update_dependency_command.dart b/script/tool/lib/src/update_dependency_command.dart index d3914ca73bf..902bfdf6bef 100644 --- a/script/tool/lib/src/update_dependency_command.dart +++ b/script/tool/lib/src/update_dependency_command.dart @@ -12,7 +12,6 @@ import 'package:yaml_edit/yaml_edit.dart'; import 'common/core.dart'; import 'common/package_looping_command.dart'; -import 'common/process_runner.dart'; import 'common/pub_version_finder.dart'; import 'common/repository_package.dart'; @@ -28,12 +27,11 @@ const int _exitNoTargetVersion = 4; class UpdateDependencyCommand extends PackageLoopingCommand { /// Creates an instance of the version check command. UpdateDependencyCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), + super.packagesDir, { + super.processRunner, http.Client? httpClient, - }) : _pubVersionFinder = - PubVersionFinder(httpClient: httpClient ?? http.Client()), - super(packagesDir, processRunner: processRunner) { + }) : _pubVersionFinder = + PubVersionFinder(httpClient: httpClient ?? http.Client()) { argParser.addOption( _pubPackageFlag, help: 'A pub package to update.', diff --git a/script/tool/lib/src/update_excerpts_command.dart b/script/tool/lib/src/update_excerpts_command.dart index ecd05428dd2..c9846b8ad20 100644 --- a/script/tool/lib/src/update_excerpts_command.dart +++ b/script/tool/lib/src/update_excerpts_command.dart @@ -5,31 +5,23 @@ import 'dart:io' as io; import 'package:file/file.dart'; -import 'package:git/git.dart'; import 'package:meta/meta.dart'; -import 'package:platform/platform.dart'; import 'package:yaml/yaml.dart'; import 'package:yaml_edit/yaml_edit.dart'; import 'common/core.dart'; import 'common/package_looping_command.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; /// A command to update .md code excerpts from code files. class UpdateExcerptsCommand extends PackageLoopingCommand { /// Creates a excerpt updater command instance. UpdateExcerptsCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - GitDir? gitDir, - }) : super( - packagesDir, - processRunner: processRunner, - platform: platform, - gitDir: gitDir, - ) { + super.packagesDir, { + super.processRunner, + super.platform, + super.gitDir, + }) { argParser.addFlag(_failOnChangeFlag, hide: true); argParser.addFlag(_noCleanupFlag, help: 'Skips the step of cleaning up the excerpt extraction output. ' diff --git a/script/tool/lib/src/update_min_sdk_command.dart b/script/tool/lib/src/update_min_sdk_command.dart index e75b4fe0543..fd4a344b683 100644 --- a/script/tool/lib/src/update_min_sdk_command.dart +++ b/script/tool/lib/src/update_min_sdk_command.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:file/file.dart'; import 'package:pub_semver/pub_semver.dart'; import 'package:yaml_edit/yaml_edit.dart'; @@ -15,7 +14,7 @@ const int _exitUnknownVersion = 3; /// A command to update the minimum Flutter and Dart SDKs of packages. class UpdateMinSdkCommand extends PackageLoopingCommand { /// Creates a publish metadata updater command instance. - UpdateMinSdkCommand(Directory packagesDir) : super(packagesDir) { + UpdateMinSdkCommand(super.packagesDir) { argParser.addOption(_flutterMinFlag, mandatory: true, help: 'The minimum version of Flutter to set SDK constraints to.'); diff --git a/script/tool/lib/src/update_release_info_command.dart b/script/tool/lib/src/update_release_info_command.dart index 240ae72eed7..92d11082344 100644 --- a/script/tool/lib/src/update_release_info_command.dart +++ b/script/tool/lib/src/update_release_info_command.dart @@ -4,7 +4,6 @@ import 'package:args/command_runner.dart'; import 'package:file/file.dart'; -import 'package:git/git.dart'; import 'package:pub_semver/pub_semver.dart'; import 'package:yaml_edit/yaml_edit.dart'; @@ -36,9 +35,9 @@ enum _ChangelogUpdateState { class UpdateReleaseInfoCommand extends PackageLoopingCommand { /// Creates a publish metadata updater command instance. UpdateReleaseInfoCommand( - Directory packagesDir, { - GitDir? gitDir, - }) : super(packagesDir, gitDir: gitDir) { + super.packagesDir, { + super.gitDir, + }) { argParser.addOption(_changelogFlag, mandatory: true, help: 'The changelog entry to add. ' diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index a2ea016c331..acaf510b7b8 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -3,18 +3,15 @@ // found in the LICENSE file. import 'package:file/file.dart'; -import 'package:git/git.dart'; import 'package:http/http.dart' as http; import 'package:meta/meta.dart'; import 'package:path/path.dart' as p; -import 'package:platform/platform.dart'; import 'package:pub_semver/pub_semver.dart'; import 'common/core.dart'; import 'common/git_version_finder.dart'; import 'common/package_looping_command.dart'; import 'common/package_state_utils.dart'; -import 'common/process_runner.dart'; import 'common/pub_version_finder.dart'; import 'common/repository_package.dart'; @@ -98,19 +95,13 @@ Map getAllowedNextVersions( class VersionCheckCommand extends PackageLoopingCommand { /// Creates an instance of the version check command. VersionCheckCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - GitDir? gitDir, + super.packagesDir, { + super.processRunner, + super.platform, + super.gitDir, http.Client? httpClient, - }) : _pubVersionFinder = - PubVersionFinder(httpClient: httpClient ?? http.Client()), - super( - packagesDir, - processRunner: processRunner, - platform: platform, - gitDir: gitDir, - ) { + }) : _pubVersionFinder = + PubVersionFinder(httpClient: httpClient ?? http.Client()) { argParser.addFlag( _againstPubFlag, help: 'Whether the version check should run against the version on pub.\n' diff --git a/script/tool/lib/src/xcode_analyze_command.dart b/script/tool/lib/src/xcode_analyze_command.dart index 7a9a5953f52..f953bf879e3 100644 --- a/script/tool/lib/src/xcode_analyze_command.dart +++ b/script/tool/lib/src/xcode_analyze_command.dart @@ -2,13 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:file/file.dart'; -import 'package:platform/platform.dart'; - import 'common/core.dart'; import 'common/package_looping_command.dart'; import 'common/plugin_utils.dart'; -import 'common/process_runner.dart'; import 'common/repository_package.dart'; import 'common/xcode.dart'; @@ -16,11 +12,10 @@ import 'common/xcode.dart'; class XcodeAnalyzeCommand extends PackageLoopingCommand { /// Creates an instance of the test command. XcodeAnalyzeCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - }) : _xcode = Xcode(processRunner: processRunner, log: true), - super(packagesDir, processRunner: processRunner, platform: platform) { + super.packagesDir, { + super.processRunner, + super.platform, + }) : _xcode = Xcode(processRunner: processRunner, log: true) { argParser.addFlag(platformIOS, help: 'Analyze iOS'); argParser.addFlag(platformMacOS, help: 'Analyze macOS'); argParser.addOption(_minIOSVersionArg, diff --git a/script/tool/pubspec.yaml b/script/tool/pubspec.yaml index 925d4b60697..cfc95ba4db5 100644 --- a/script/tool/pubspec.yaml +++ b/script/tool/pubspec.yaml @@ -31,4 +31,4 @@ dev_dependencies: mockito: '>=5.3.2 <=5.4.0' environment: - sdk: '>=2.14.0 <4.0.0' + sdk: '>=2.18.0 <4.0.0' diff --git a/script/tool/test/common/package_command_test.dart b/script/tool/test/common/package_command_test.dart index 2ef9b9e8438..dad4e3b9e96 100644 --- a/script/tool/test/common/package_command_test.dart +++ b/script/tool/test/common/package_command_test.dart @@ -7,11 +7,9 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_plugin_tools/src/common/core.dart'; import 'package:flutter_plugin_tools/src/common/package_command.dart'; -import 'package:flutter_plugin_tools/src/common/process_runner.dart'; import 'package:git/git.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:platform/platform.dart'; import 'package:test/test.dart'; import '../mocks.dart'; @@ -1255,13 +1253,12 @@ packages/b_package/lib/src/foo.dart class SamplePackageCommand extends PackageCommand { SamplePackageCommand( - Directory packagesDir, { - ProcessRunner processRunner = const ProcessRunner(), - Platform platform = const LocalPlatform(), - GitDir? gitDir, + super.packagesDir, { + super.processRunner, + super.platform, + super.gitDir, this.includeSubpackages = false, - }) : super(packagesDir, - processRunner: processRunner, platform: platform, gitDir: gitDir); + }); final List plugins = []; diff --git a/script/tool/test/common/package_looping_command_test.dart b/script/tool/test/common/package_looping_command_test.dart index 043fa0a77ce..32d18376a5d 100644 --- a/script/tool/test/common/package_looping_command_test.dart +++ b/script/tool/test/common/package_looping_command_test.dart @@ -10,10 +10,7 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_plugin_tools/src/common/core.dart'; import 'package:flutter_plugin_tools/src/common/package_looping_command.dart'; -import 'package:flutter_plugin_tools/src/common/process_runner.dart'; -import 'package:git/git.dart'; import 'package:mockito/mockito.dart'; -import 'package:platform/platform.dart'; import 'package:test/test.dart'; import '../mocks.dart'; @@ -852,8 +849,8 @@ void main() { class TestPackageLoopingCommand extends PackageLoopingCommand { TestPackageLoopingCommand( - Directory packagesDir, { - required Platform platform, + super.packagesDir, { + required super.platform, this.hasLongOutput = true, this.packageLoopingType = PackageLoopingType.topLevelOnly, this.customFailureListHeader, @@ -862,10 +859,9 @@ class TestPackageLoopingCommand extends PackageLoopingCommand { this.warnsDuringInit = false, this.warnsDuringCleanup = false, this.captureOutput = false, - ProcessRunner processRunner = const ProcessRunner(), - GitDir? gitDir, - }) : super(packagesDir, - processRunner: processRunner, platform: platform, gitDir: gitDir); + super.processRunner, + super.gitDir, + }); final List checkedPackages = []; final List capturedOutput = []; diff --git a/script/tool/test/common/plugin_utils_test.dart b/script/tool/test/common/plugin_utils_test.dart index 415b1db8932..ff2ff6a3953 100644 --- a/script/tool/test/common/plugin_utils_test.dart +++ b/script/tool/test/common/plugin_utils_test.dart @@ -223,9 +223,12 @@ void main() { 'plugin', packagesDir, platformSupport: { - platformLinux: const PlatformDetails(PlatformSupport.inline, hasDartCode: true), - platformMacOS: const PlatformDetails(PlatformSupport.inline, hasDartCode: true), - platformWindows: const PlatformDetails(PlatformSupport.inline, hasDartCode: true), + platformLinux: + const PlatformDetails(PlatformSupport.inline, hasDartCode: true), + platformMacOS: + const PlatformDetails(PlatformSupport.inline, hasDartCode: true), + platformWindows: + const PlatformDetails(PlatformSupport.inline, hasDartCode: true), }, );