Skip to content

Commit 0e195e9

Browse files
authored
Revert "Show output from pub get in flutter pub get (flutter#106300)" (flutter#110478)
This reverts commit 3802eb6.
1 parent 5848306 commit 0e195e9

27 files changed

+252
-559
lines changed

dev/bots/analyze_snippet_code.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -980,13 +980,6 @@ class _SnippetChecker {
980980
/// Invokes the analyzer on the given [directory] and returns the stdout (with some lines filtered).
981981
List<String> _runAnalyzer() {
982982
_createConfigurationFiles();
983-
// Run pub get to avoid output from getting dependencies in the analyzer
984-
// output.
985-
Process.runSync(
986-
_flutter,
987-
<String>['pub', 'get'],
988-
workingDirectory: _tempDirectory.absolute.path,
989-
);
990983
final ProcessResult result = Process.runSync(
991984
_flutter,
992985
<String>['--no-wrap', 'analyze', '--no-preamble', '--no-congratulate', '.'],
@@ -1013,7 +1006,7 @@ class _SnippetChecker {
10131006
if (stdout.isNotEmpty && stdout.first == 'Building flutter tool...') {
10141007
stdout.removeAt(0);
10151008
}
1016-
if (stdout.isNotEmpty && stdout.first.isEmpty) {
1009+
if (stdout.isNotEmpty && stdout.first.startsWith('Running "flutter pub get" in ')) {
10171010
stdout.removeAt(0);
10181011
}
10191012
return stdout;

packages/flutter_tools/lib/src/commands/create.dart

Lines changed: 42 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class CreateCommand extends CreateBase {
192192
}
193193

194194
validateOutputDirectoryArg();
195+
195196
String? sampleCode;
196197
final String? sampleArgument = stringArg('sample');
197198
if (sampleArgument != null) {
@@ -254,29 +255,7 @@ class CreateCommand extends CreateBase {
254255
}
255256

256257
final String dartSdk = globals.cache.dartSdkBuild;
257-
final bool includeIos;
258-
final bool includeAndroid;
259-
final bool includeWeb;
260-
final bool includeLinux;
261-
final bool includeMacos;
262-
final bool includeWindows;
263-
if (template == FlutterProjectType.module) {
264-
// The module template only supports iOS and Android.
265-
includeIos = true;
266-
includeAndroid = true;
267-
includeWeb = false;
268-
includeLinux = false;
269-
includeMacos = false;
270-
includeWindows = false;
271-
} else {
272-
includeIos = featureFlags.isIOSEnabled && platforms.contains('ios');
273-
includeAndroid = featureFlags.isAndroidEnabled && platforms.contains('android');
274-
includeWeb = featureFlags.isWebEnabled && platforms.contains('web');
275-
includeLinux = featureFlags.isLinuxEnabled && platforms.contains('linux');
276-
includeMacos = featureFlags.isMacOSEnabled && platforms.contains('macos');
277-
includeWindows = featureFlags.isWindowsEnabled && platforms.contains('windows');
278-
}
279-
258+
final bool includeIos = featureFlags.isIOSEnabled && platforms.contains('ios');
280259
String? developmentTeam;
281260
if (includeIos) {
282261
developmentTeam = await getCodeSigningIdentityDevelopmentTeam(
@@ -303,11 +282,11 @@ class CreateCommand extends CreateBase {
303282
iosLanguage: stringArgDeprecated('ios-language'),
304283
iosDevelopmentTeam: developmentTeam,
305284
ios: includeIos,
306-
android: includeAndroid,
307-
web: includeWeb,
308-
linux: includeLinux,
309-
macos: includeMacos,
310-
windows: includeWindows,
285+
android: featureFlags.isAndroidEnabled && platforms.contains('android'),
286+
web: featureFlags.isWebEnabled && platforms.contains('web'),
287+
linux: featureFlags.isLinuxEnabled && platforms.contains('linux'),
288+
macos: featureFlags.isMacOSEnabled && platforms.contains('macos'),
289+
windows: featureFlags.isWindowsEnabled && platforms.contains('windows'),
311290
// Enable null safety everywhere.
312291
dartSdkVersionBounds: "'>=$dartSdk <3.0.0'",
313292
implementationTests: boolArgDeprecated('implementation-tests'),
@@ -330,7 +309,6 @@ class CreateCommand extends CreateBase {
330309

331310
final Directory relativeDir = globals.fs.directory(projectDirPath);
332311
int generatedFileCount = 0;
333-
final PubContext pubContext;
334312
switch (template) {
335313
case FlutterProjectType.app:
336314
generatedFileCount += await generateApp(
@@ -341,7 +319,6 @@ class CreateCommand extends CreateBase {
341319
printStatusWhenWriting: !creatingNewProject,
342320
projectType: template,
343321
);
344-
pubContext = PubContext.create;
345322
break;
346323
case FlutterProjectType.skeleton:
347324
generatedFileCount += await generateApp(
@@ -352,7 +329,6 @@ class CreateCommand extends CreateBase {
352329
printStatusWhenWriting: !creatingNewProject,
353330
generateMetadata: false,
354331
);
355-
pubContext = PubContext.create;
356332
break;
357333
case FlutterProjectType.module:
358334
generatedFileCount += await _generateModule(
@@ -361,7 +337,6 @@ class CreateCommand extends CreateBase {
361337
overwrite: overwrite,
362338
printStatusWhenWriting: !creatingNewProject,
363339
);
364-
pubContext = PubContext.create;
365340
break;
366341
case FlutterProjectType.package:
367342
generatedFileCount += await _generatePackage(
@@ -370,7 +345,6 @@ class CreateCommand extends CreateBase {
370345
overwrite: overwrite,
371346
printStatusWhenWriting: !creatingNewProject,
372347
);
373-
pubContext = PubContext.createPackage;
374348
break;
375349
case FlutterProjectType.plugin:
376350
generatedFileCount += await _generateMethodChannelPlugin(
@@ -380,7 +354,6 @@ class CreateCommand extends CreateBase {
380354
printStatusWhenWriting: !creatingNewProject,
381355
projectType: template,
382356
);
383-
pubContext = PubContext.createPlugin;
384357
break;
385358
case FlutterProjectType.ffiPlugin:
386359
generatedFileCount += await _generateFfiPlugin(
@@ -390,26 +363,8 @@ class CreateCommand extends CreateBase {
390363
printStatusWhenWriting: !creatingNewProject,
391364
projectType: template,
392365
);
393-
pubContext = PubContext.createPlugin;
394366
break;
395367
}
396-
397-
if (boolArgDeprecated('pub')) {
398-
final FlutterProject project = FlutterProject.fromDirectory(relativeDir);
399-
await pub.get(
400-
context: pubContext,
401-
project: project,
402-
offline: boolArgDeprecated('offline'),
403-
);
404-
await project.ensureReadyForPlatformSpecificTooling(
405-
androidPlatform: includeAndroid,
406-
iosPlatform: includeIos,
407-
linuxPlatform: includeLinux,
408-
macOSPlatform: includeMacos,
409-
windowsPlatform: includeWindows,
410-
webPlatform: includeWeb,
411-
);
412-
}
413368
if (sampleCode != null) {
414369
generatedFileCount += _applySample(relativeDir, sampleCode);
415370
}
@@ -492,6 +447,18 @@ Your $application code is in $relativeAppMain.
492447
overwrite: overwrite,
493448
printStatusWhenWriting: printStatusWhenWriting,
494449
);
450+
if (boolArgDeprecated('pub')) {
451+
await pub.get(
452+
context: PubContext.create,
453+
directory: directory.path,
454+
offline: boolArgDeprecated('offline'),
455+
);
456+
final FlutterProject project = FlutterProject.fromDirectory(directory);
457+
await project.ensureReadyForPlatformSpecificTooling(
458+
androidPlatform: true,
459+
iosPlatform: true,
460+
);
461+
}
495462
return generatedCount;
496463
}
497464

@@ -513,6 +480,13 @@ Your $application code is in $relativeAppMain.
513480
overwrite: overwrite,
514481
printStatusWhenWriting: printStatusWhenWriting,
515482
);
483+
if (boolArgDeprecated('pub')) {
484+
await pub.get(
485+
context: PubContext.createPackage,
486+
directory: directory.path,
487+
offline: boolArgDeprecated('offline'),
488+
);
489+
}
516490
return generatedCount;
517491
}
518492

@@ -552,6 +526,14 @@ Your $application code is in $relativeAppMain.
552526
printStatusWhenWriting: printStatusWhenWriting,
553527
);
554528

529+
if (boolArgDeprecated('pub')) {
530+
await pub.get(
531+
context: PubContext.createPlugin,
532+
directory: directory.path,
533+
offline: boolArgDeprecated('offline'),
534+
);
535+
}
536+
555537
final FlutterProject project = FlutterProject.fromDirectory(directory);
556538
final bool generateAndroid = templateContext['android'] == true;
557539
if (generateAndroid) {
@@ -622,6 +604,14 @@ Your $application code is in $relativeAppMain.
622604
printStatusWhenWriting: printStatusWhenWriting,
623605
);
624606

607+
if (boolArgDeprecated('pub')) {
608+
await pub.get(
609+
context: PubContext.createPlugin,
610+
directory: directory.path,
611+
offline: boolArgDeprecated('offline'),
612+
);
613+
}
614+
625615
final FlutterProject project = FlutterProject.fromDirectory(directory);
626616
final bool generateAndroid = templateContext['android'] == true;
627617
if (generateAndroid) {

packages/flutter_tools/lib/src/commands/create_base.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import '../build_system/build_system.dart';
1717
import '../cache.dart';
1818
import '../convert.dart';
1919
import '../dart/generate_synthetic_packages.dart';
20+
import '../dart/pub.dart';
2021
import '../flutter_project_metadata.dart';
2122
import '../globals.dart' as globals;
2223
import '../project.dart';
@@ -548,6 +549,24 @@ abstract class CreateBase extends FlutterCommand {
548549
environment: environment,
549550
buildSystem: globals.buildSystem,
550551
);
552+
553+
await pub.get(
554+
context: PubContext.create,
555+
directory: directory.path,
556+
offline: boolArgDeprecated('offline'),
557+
// For templates that use the l10n localization tooling, make sure
558+
// importing the generated package works right after `flutter create`.
559+
generateSyntheticPackage: true,
560+
);
561+
562+
await project.ensureReadyForPlatformSpecificTooling(
563+
androidPlatform: androidPlatform,
564+
iosPlatform: iosPlatform,
565+
linuxPlatform: linuxPlatform,
566+
macOSPlatform: macOSPlatform,
567+
windowsPlatform: windowsPlatform,
568+
webPlatform: webPlatform,
569+
);
551570
}
552571
final List<SupportedPlatform> platformsForMigrateConfig = <SupportedPlatform>[SupportedPlatform.root];
553572
if (androidPlatform) {

packages/flutter_tools/lib/src/commands/daemon.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ class AppRunLogger extends DelegatingLogger {
15411541
}
15421542

15431543
@override
1544-
bool get supportsColor => false;
1544+
bool get supportsColor => throw UnimplementedError();
15451545

15461546
@override
15471547
bool get hasTerminal => false;

packages/flutter_tools/lib/src/commands/packages.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,11 @@ class PackagesGetCommand extends FlutterCommand {
139139
try {
140140
await pub.get(
141141
context: PubContext.pubGet,
142-
project: flutterProject,
142+
directory: directory,
143143
upgrade: upgrade,
144144
shouldSkipThirdPartyGenerator: false,
145145
offline: boolArgDeprecated('offline'),
146+
generateSyntheticPackage: flutterProject.manifest.generateSyntheticPackage,
146147
);
147148
pubGetTimer.stop();
148149
globals.flutterUsage.sendTiming('pub', 'get', pubGetTimer.elapsed, label: 'success');
@@ -171,14 +172,13 @@ class PackagesGetCommand extends FlutterCommand {
171172
}
172173
final FlutterProject rootProject = FlutterProject.fromDirectory(globals.fs.directory(target));
173174

174-
// This will also resolve dependencies for the example folder,
175175
await _runPubGet(target, rootProject);
176-
177-
// We need to regenerate the platform specific tooling for both the project
178-
// itself and example (if present).
179176
await rootProject.regeneratePlatformSpecificTooling();
177+
178+
// Get/upgrade packages in example app as well
180179
if (rootProject.hasExampleApp && rootProject.example.pubspecFile.existsSync()) {
181180
final FlutterProject exampleProject = rootProject.example;
181+
await _runPubGet(exampleProject.directory.path, exampleProject);
182182
await exampleProject.regeneratePlatformSpecificTooling();
183183
}
184184

@@ -211,7 +211,7 @@ class PackagesTestCommand extends FlutterCommand {
211211

212212
@override
213213
Future<FlutterCommandResult> runCommand() async {
214-
await pub.batch(<String>['run', 'test', ...argResults!.rest], context: PubContext.runTest);
214+
await pub.batch(<String>['run', 'test', ...argResults!.rest], context: PubContext.runTest, retry: false);
215215
return FlutterCommandResult.success();
216216
}
217217
}

packages/flutter_tools/lib/src/commands/update_packages.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import '../base/task_queue.dart';
1616
import '../cache.dart';
1717
import '../dart/pub.dart';
1818
import '../globals.dart' as globals;
19-
import '../project.dart';
2019
import '../runner/flutter_command.dart';
2120

2221
/// Map from package name to package version, used to artificially pin a pub
@@ -400,7 +399,7 @@ class UpdatePackagesCommand extends FlutterCommand {
400399
// needed packages to the pub cache, upgrading if requested.
401400
await pub.get(
402401
context: PubContext.updatePackages,
403-
project: FlutterProject.fromDirectory(tempDir),
402+
directory: tempDir.path,
404403
upgrade: doUpgrade,
405404
offline: boolArgDeprecated('offline'),
406405
flutterRootOverride: temporaryFlutterSdk?.path,
@@ -423,6 +422,7 @@ class UpdatePackagesCommand extends FlutterCommand {
423422
context: PubContext.updatePackages,
424423
directory: tempDir.path,
425424
filter: tree.fill,
425+
retry: false, // errors here are usually fatal since we're not hitting the network
426426
);
427427
}
428428
} finally {
@@ -502,7 +502,7 @@ class UpdatePackagesCommand extends FlutterCommand {
502502
stopwatch.start();
503503
await pub.get(
504504
context: PubContext.updatePackages,
505-
project: FlutterProject.fromDirectory(dir),
505+
directory: dir.path,
506506
// All dependencies should already have been downloaded by the fake
507507
// package, so the concurrent checks can all happen offline.
508508
offline: true,

packages/flutter_tools/lib/src/commands/upgrade.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import '../cache.dart';
1212
import '../dart/pub.dart';
1313
import '../globals.dart' as globals;
1414
import '../persistent_tool_state.dart';
15-
import '../project.dart';
1615
import '../runner/flutter_command.dart';
1716
import '../version.dart';
1817
import 'channel.dart';
@@ -331,7 +330,7 @@ class UpgradeCommandRunner {
331330
globals.printStatus('');
332331
await pub.get(
333332
context: PubContext.pubUpgrade,
334-
project: FlutterProject.fromDirectory(globals.fs.directory(projectRoot)),
333+
directory: projectRoot,
335334
upgrade: true,
336335
);
337336
}

packages/flutter_tools/lib/src/context_runner.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ Future<T> runInContext<T>(
152152
logger: globals.logger,
153153
platform: globals.platform,
154154
osUtils: globals.os,
155-
projectFactory: globals.projectFactory,
156155
),
157156
CocoaPods: () => CocoaPods(
158157
fileSystem: globals.fs,
@@ -313,7 +312,6 @@ Future<T> runInContext<T>(
313312
botDetector: globals.botDetector,
314313
platform: globals.platform,
315314
usage: globals.flutterUsage,
316-
stdio: globals.stdio,
317315
),
318316
ShutdownHooks: () => ShutdownHooks(logger: globals.logger),
319317
Stdio: () => Stdio(),

0 commit comments

Comments
 (0)