@@ -140,6 +140,17 @@ class PubContext {
140
140
}
141
141
}
142
142
143
+ /// Describes the amount of output that should get printed from a `pub` command.
144
+ /// [PubOutputMode.all] indicates that the complete output is printed. This is
145
+ /// typically the default.
146
+ /// [PubOutputMode.none] indicates that no output should be printed.
147
+ /// [PubOutputMode.summaryOnly] indicates that only summary information should be printed.
148
+ enum PubOutputMode {
149
+ none,
150
+ all,
151
+ summaryOnly,
152
+ }
153
+
143
154
/// A handle for interacting with the pub tool.
144
155
abstract class Pub {
145
156
/// Create a default [Pub] instance.
@@ -172,6 +183,14 @@ abstract class Pub {
172
183
/// If [shouldSkipThirdPartyGenerator] is true, the overall pub get will be
173
184
/// skipped if the package config file has a "generator" other than "pub".
174
185
/// Defaults to true.
186
+ ///
187
+ /// [outputMode] determines how verbose the output from `pub get` will be.
188
+ /// If [PubOutputMode.all] is used, `pub get` will print its typical output
189
+ /// which includes information about all changed dependencies. If
190
+ /// [PubOutputMode.summaryOnly] is used, only summary information will be printed.
191
+ /// This is useful for cases where the user is typically not interested in
192
+ /// what dependencies were changed, such as when running `flutter create` .
193
+ ///
175
194
/// Will also resolve dependencies in the example folder if present.
176
195
Future <void > get ({
177
196
required PubContext context,
@@ -181,7 +200,7 @@ abstract class Pub {
181
200
String ? flutterRootOverride,
182
201
bool checkUpToDate = false ,
183
202
bool shouldSkipThirdPartyGenerator = true ,
184
- bool printProgress = true ,
203
+ PubOutputMode outputMode = PubOutputMode .all
185
204
});
186
205
187
206
/// Runs pub in 'batch' mode.
@@ -221,7 +240,7 @@ abstract class Pub {
221
240
required String command,
222
241
bool touchesPackageConfig = false ,
223
242
bool generateSyntheticPackage = false ,
224
- bool printProgress = true ,
243
+ PubOutputMode outputMode = PubOutputMode .all
225
244
});
226
245
}
227
246
@@ -286,7 +305,7 @@ class _DefaultPub implements Pub {
286
305
String ? flutterRootOverride,
287
306
bool checkUpToDate = false ,
288
307
bool shouldSkipThirdPartyGenerator = true ,
289
- bool printProgress = true ,
308
+ PubOutputMode outputMode = PubOutputMode .all
290
309
}) async {
291
310
final String directory = project.directory.path;
292
311
final File packageConfigFile = project.packageConfigFile;
@@ -358,7 +377,7 @@ class _DefaultPub implements Pub {
358
377
directory: directory,
359
378
failureMessage: 'pub $command failed' ,
360
379
flutterRootOverride: flutterRootOverride,
361
- printProgress : printProgress
380
+ outputMode : outputMode,
362
381
);
363
382
await _updateVersionAndPackageConfig (project);
364
383
}
@@ -375,7 +394,7 @@ class _DefaultPub implements Pub {
375
394
Future <void > _runWithStdioInherited (
376
395
List <String > arguments, {
377
396
required String command,
378
- required bool printProgress ,
397
+ required PubOutputMode outputMode ,
379
398
required PubContext context,
380
399
required String directory,
381
400
String failureMessage = 'pub failed' ,
@@ -384,10 +403,10 @@ class _DefaultPub implements Pub {
384
403
int exitCode;
385
404
386
405
final List <String > pubCommand = _pubCommand (arguments);
387
- final Map <String , String > pubEnvironment = await _createPubEnvironment (context, flutterRootOverride);
406
+ final Map <String , String > pubEnvironment = await _createPubEnvironment (context: context , flutterRootOverride: flutterRootOverride, summaryOnly : outputMode == PubOutputMode .summaryOnly );
388
407
389
408
try {
390
- if (printProgress ) {
409
+ if (outputMode != PubOutputMode .none ) {
391
410
final io.Stdio ? stdio = _stdio;
392
411
if (stdio == null ) {
393
412
// Let pub inherit stdio and output directly to the tool's stdout and
@@ -450,8 +469,7 @@ class _DefaultPub implements Pub {
450
469
? 'exists'
451
470
: 'does not exist' ;
452
471
buffer.writeln ('Working directory: "$directory " ($directoryExistsMessage )' );
453
- final Map <String , String > env = await _createPubEnvironment (context, flutterRootOverride);
454
- buffer.write (_stringifyPubEnv (env));
472
+ buffer.write (_stringifyPubEnv (pubEnvironment));
455
473
throw io.ProcessException (
456
474
exception.executable,
457
475
exception.arguments,
@@ -517,7 +535,7 @@ class _DefaultPub implements Pub {
517
535
if (showTraceForErrors) {
518
536
arguments.insert (0 , '--trace' );
519
537
}
520
- final Map <String , String > pubEnvironment = await _createPubEnvironment (context, flutterRootOverride);
538
+ final Map <String , String > pubEnvironment = await _createPubEnvironment (context: context, flutterRootOverride : flutterRootOverride);
521
539
final List <String > pubCommand = _pubCommand (arguments);
522
540
final int code = await _processUtils.stream (
523
541
pubCommand,
@@ -557,14 +575,14 @@ class _DefaultPub implements Pub {
557
575
required String command,
558
576
bool touchesPackageConfig = false ,
559
577
bool generateSyntheticPackage = false ,
560
- bool printProgress = true ,
578
+ PubOutputMode outputMode = PubOutputMode .all
561
579
}) async {
562
580
await _runWithStdioInherited (
563
581
arguments,
564
582
command: command,
565
583
directory: _fileSystem.currentDirectory.path,
566
584
context: context,
567
- printProgress : printProgress ,
585
+ outputMode : outputMode ,
568
586
);
569
587
if (touchesPackageConfig && project != null ) {
570
588
await _updateVersionAndPackageConfig (project);
@@ -697,10 +715,15 @@ class _DefaultPub implements Pub {
697
715
///
698
716
/// [context] provides extra information to package server requests to
699
717
/// understand usage.
700
- Future <Map <String , String >> _createPubEnvironment (PubContext context, [ String ? flutterRootOverride ]) async {
718
+ Future <Map <String , String >> _createPubEnvironment ({
719
+ required PubContext context,
720
+ String ? flutterRootOverride,
721
+ bool ? summaryOnly = false ,
722
+ }) async {
701
723
final Map <String , String > environment = < String , String > {
702
724
'FLUTTER_ROOT' : flutterRootOverride ?? Cache .flutterRoot! ,
703
725
_kPubEnvironmentKey: await _getPubEnvironmentValue (context),
726
+ if (summaryOnly ?? false ) 'PUB_SUMMARY_ONLY' : '1' ,
704
727
};
705
728
final String ? pubCache = _getPubCacheIfAvailable ();
706
729
if (pubCache != null ) {
0 commit comments