From 445dbc443db4eb5ce284f76749f60e81208b8783 Mon Sep 17 00:00:00 2001 From: Andrew Kolos Date: Wed, 11 Jan 2023 12:49:47 -0800 Subject: [PATCH] replace enum with simpler boolean --- .../lib/src/commands/create.dart | 2 +- .../lib/src/commands/update_packages.dart | 4 +-- packages/flutter_tools/lib/src/dart/pub.dart | 28 +++++++++---------- .../hermetic/create_usage_test.dart | 2 +- .../commands.shard/hermetic/drive_test.dart | 2 +- .../commands.shard/hermetic/pub_get_test.dart | 2 +- .../hermetic/update_packages_test.dart | 2 +- .../flutter_tools/test/src/throwing_pub.dart | 4 +-- 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index 5c46a766430db..326c031c74b7c 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -414,7 +414,7 @@ class CreateCommand extends CreateBase { context: pubContext, project: project, offline: boolArgDeprecated('offline'), - outputMode: PubOutputMode.summaryOnly, + printProgress: false, ); await project.ensureReadyForPlatformSpecificTooling( androidPlatform: includeAndroid, diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index cd30ef022393d..553d158bfdf84 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -444,7 +444,7 @@ class UpdatePackagesCommand extends FlutterCommand { upgrade: doUpgrade, offline: boolArgDeprecated('offline'), flutterRootOverride: temporaryFlutterSdk?.path, - outputMode: PubOutputMode.none, + printProgress: false, ); if (doUpgrade) { @@ -538,7 +538,7 @@ class UpdatePackagesCommand extends FlutterCommand { // All dependencies should already have been downloaded by the fake // package, so the concurrent checks can all happen offline. offline: true, - outputMode: PubOutputMode.none, + printProgress: false, ); stopwatch.stop(); final double seconds = stopwatch.elapsedMilliseconds / 1000.0; diff --git a/packages/flutter_tools/lib/src/dart/pub.dart b/packages/flutter_tools/lib/src/dart/pub.dart index 3535d102c2d49..bc736112e5bfe 100644 --- a/packages/flutter_tools/lib/src/dart/pub.dart +++ b/packages/flutter_tools/lib/src/dart/pub.dart @@ -140,12 +140,6 @@ class PubContext { } } -enum PubOutputMode { - none, - standard, - summaryOnly, -} - /// A handle for interacting with the pub tool. abstract class Pub { /// Create a default [Pub] instance. @@ -178,6 +172,10 @@ abstract class Pub { /// If [shouldSkipThirdPartyGenerator] is true, the overall pub get will be /// skipped if the package config file has a "generator" other than "pub". /// Defaults to true. + /// + /// If [printProgress] is true, `pub get` will inherit stdio from the current process. + /// Defaults to true. + /// /// Will also resolve dependencies in the example folder if present. Future get({ required PubContext context, @@ -187,7 +185,7 @@ abstract class Pub { String? flutterRootOverride, bool checkUpToDate = false, bool shouldSkipThirdPartyGenerator = true, - PubOutputMode outputMode = PubOutputMode.standard + bool printProgress = true, }); /// Runs pub in 'batch' mode. @@ -227,7 +225,7 @@ abstract class Pub { required String command, bool touchesPackageConfig = false, bool generateSyntheticPackage = false, - PubOutputMode outputMode = PubOutputMode.standard + bool printProgress = true, }); } @@ -292,7 +290,7 @@ class _DefaultPub implements Pub { String? flutterRootOverride, bool checkUpToDate = false, bool shouldSkipThirdPartyGenerator = true, - PubOutputMode outputMode = PubOutputMode.standard + bool printProgress = true, }) async { final String directory = project.directory.path; final File packageConfigFile = project.packageConfigFile; @@ -364,7 +362,7 @@ class _DefaultPub implements Pub { directory: directory, failureMessage: 'pub $command failed', flutterRootOverride: flutterRootOverride, - outputMode: outputMode, + printProgress: printProgress, ); await _updateVersionAndPackageConfig(project); } @@ -381,19 +379,19 @@ class _DefaultPub implements Pub { Future _runWithStdioInherited( List arguments, { required String command, - required PubOutputMode outputMode, required PubContext context, required String directory, String failureMessage = 'pub failed', String? flutterRootOverride, + bool printProgress = true }) async { int exitCode; final List pubCommand = _pubCommand(arguments); - final Map pubEnvironment = await _createPubEnvironment(context: context, flutterRootOverride: flutterRootOverride, summaryOnly: outputMode == PubOutputMode.summaryOnly); + final Map pubEnvironment = await _createPubEnvironment(context: context, flutterRootOverride: flutterRootOverride, summaryOnly: printProgress); try { - if (outputMode != PubOutputMode.none) { + if (printProgress) { final io.Stdio? stdio = _stdio; if (stdio == null) { // Let pub inherit stdio and output directly to the tool's stdout and @@ -564,14 +562,14 @@ class _DefaultPub implements Pub { required String command, bool touchesPackageConfig = false, bool generateSyntheticPackage = false, - PubOutputMode outputMode = PubOutputMode.standard + bool printProgress = true, }) async { await _runWithStdioInherited( arguments, command: command, directory: _fileSystem.currentDirectory.path, context: context, - outputMode: outputMode, + printProgress: printProgress, ); if (touchesPackageConfig && project != null) { await _updateVersionAndPackageConfig(project); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart index 62a2a1a30bf85..4a617ff70e126 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart @@ -36,7 +36,7 @@ class FakePub extends Fake implements Pub { String? flutterRootOverride, bool checkUpToDate = false, bool shouldSkipThirdPartyGenerator = true, - PubOutputMode outputMode = PubOutputMode.standard, + bool printProgress = true, }) async { project.directory.childFile('.packages').createSync(); if (offline == true) { diff --git a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart index dc230748cc01e..a7445131369d8 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart @@ -486,7 +486,7 @@ class FakePub extends Fake implements Pub { String? flutterRootOverride, bool checkUpToDate = false, bool shouldSkipThirdPartyGenerator = true, - PubOutputMode outputMode = PubOutputMode.standard, + bool printProgress = true, }) async { } } diff --git a/packages/flutter_tools/test/commands.shard/hermetic/pub_get_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/pub_get_test.dart index 05b11e1050292..4ab290199c6d4 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/pub_get_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/pub_get_test.dart @@ -190,7 +190,7 @@ class FakePub extends Fake implements Pub { required String command, bool touchesPackageConfig = false, bool generateSyntheticPackage = false, - PubOutputMode outputMode = PubOutputMode.standard, + bool printProgress = true, }) async { if (project != null) { fileSystem.directory(project.directory) diff --git a/packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart index 2167e702daf48..56b9fa0d7a120 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart @@ -282,7 +282,7 @@ class FakePub extends Fake implements Pub { String? flutterRootOverride, bool checkUpToDate = false, bool shouldSkipThirdPartyGenerator = true, - PubOutputMode outputMode = PubOutputMode.standard, + bool printProgress = true, }) async { pubGetDirectories.add(project.directory.path); project.directory.childFile('pubspec.lock') diff --git a/packages/flutter_tools/test/src/throwing_pub.dart b/packages/flutter_tools/test/src/throwing_pub.dart index 8d12746d2eb97..a96d13375ab00 100644 --- a/packages/flutter_tools/test/src/throwing_pub.dart +++ b/packages/flutter_tools/test/src/throwing_pub.dart @@ -29,7 +29,7 @@ class ThrowingPub implements Pub { String? flutterRootOverride, bool checkUpToDate = false, bool shouldSkipThirdPartyGenerator = true, - PubOutputMode outputMode = PubOutputMode.standard, + bool printProgress = true, }) { throw UnsupportedError('Attempted to invoke pub during test.'); } @@ -42,7 +42,7 @@ class ThrowingPub implements Pub { required String command, bool touchesPackageConfig = false, bool generateSyntheticPackage = false, - PubOutputMode outputMode = PubOutputMode.standard, + bool printProgress = true, }) { throw UnsupportedError('Attempted to invoke pub during test.'); }