From 9a0b891d7a36d80bbf352e43081d413b6085c45e Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Wed, 17 Feb 2021 09:24:49 -0800 Subject: [PATCH 1/4] change --- packages/webview_flutter/pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/webview_flutter/pubspec.yaml b/packages/webview_flutter/pubspec.yaml index 5d8e512b5aa5..1fa56c22200a 100644 --- a/packages/webview_flutter/pubspec.yaml +++ b/packages/webview_flutter/pubspec.yaml @@ -3,6 +3,7 @@ description: A Flutter plugin that provides a WebView widget on Android and iOS. version: 2.0.0-nullsafety.5 homepage: https://github.com/flutter/plugins/tree/master/packages/webview_flutter + environment: sdk: ">=2.12.0-0 <3.0.0" flutter: ">=1.22.0" From 93e638871d22266c565632ffa25eb2a137f1b85b Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Wed, 17 Feb 2021 10:00:37 -0800 Subject: [PATCH 2/4] ignore prerelease sdk --- packages/webview_flutter/pubspec.yaml | 1 - .../tool/lib/src/publish_check_command.dart | 36 +++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/packages/webview_flutter/pubspec.yaml b/packages/webview_flutter/pubspec.yaml index 1fa56c22200a..5d8e512b5aa5 100644 --- a/packages/webview_flutter/pubspec.yaml +++ b/packages/webview_flutter/pubspec.yaml @@ -3,7 +3,6 @@ description: A Flutter plugin that provides a WebView widget on Android and iOS. version: 2.0.0-nullsafety.5 homepage: https://github.com/flutter/plugins/tree/master/packages/webview_flutter - environment: sdk: ">=2.12.0-0 <3.0.0" flutter: ">=1.22.0" diff --git a/script/tool/lib/src/publish_check_command.dart b/script/tool/lib/src/publish_check_command.dart index 8d6f6bb9ab61..7a38548bf1a5 100644 --- a/script/tool/lib/src/publish_check_command.dart +++ b/script/tool/lib/src/publish_check_command.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:io' as io; import 'package:colorize/colorize.dart'; import 'package:file/file.dart'; @@ -63,6 +64,33 @@ class PublishCheckCommand extends PluginCommand { } } + Future hasValidPublishCheckRun(Directory package) async { + final io.Process process = await io.Process.start( + 'flutter', + ['pub', 'publish', '--', '--dry-run'], + workingDirectory: package.path, + ); + + String output = ''; + process.stdout.listen((List event) { + io.stdout.add(event); + output += String.fromCharCodes(event); + }); + + process.stderr.listen((List event) { + io.stderr.add(event); + output += String.fromCharCodes(event); + }); + + final int exitCode = await process.exitCode; + + final bool hasPreReleaseSdk = output.contains('Package has 1 warning.') && + output.contains( + 'Packages with an SDK constraint on a pre-release of the Dart SDK should themselves be published as a pre-release version.'); + + return exitCode == 0 || hasPreReleaseSdk; + } + Future passesPublishCheck(Directory package) async { final String packageName = package.basename; print('Checking that $packageName can be published.'); @@ -75,13 +103,7 @@ class PublishCheckCommand extends PluginCommand { return true; } - final int exitCode = await processRunner.runAndStream( - 'flutter', - ['pub', 'publish', '--', '--dry-run'], - workingDir: package, - ); - - if (exitCode == 0) { + if (await hasValidPublishCheckRun(package)) { print("Package $packageName is able to be published."); return true; } else { From 4fd311f3a0cd3611e520b367e3be1adba7939815 Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Wed, 17 Feb 2021 17:34:40 -0800 Subject: [PATCH 3/4] test change --- packages/webview_flutter/pubspec.yaml | 1 + .../tool/lib/src/publish_check_command.dart | 23 ++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/webview_flutter/pubspec.yaml b/packages/webview_flutter/pubspec.yaml index 5d8e512b5aa5..1fa56c22200a 100644 --- a/packages/webview_flutter/pubspec.yaml +++ b/packages/webview_flutter/pubspec.yaml @@ -3,6 +3,7 @@ description: A Flutter plugin that provides a WebView widget on Android and iOS. version: 2.0.0-nullsafety.5 homepage: https://github.com/flutter/plugins/tree/master/packages/webview_flutter + environment: sdk: ">=2.12.0-0 <3.0.0" flutter: ">=1.22.0" diff --git a/script/tool/lib/src/publish_check_command.dart b/script/tool/lib/src/publish_check_command.dart index 7a38548bf1a5..fd373a6c5df4 100644 --- a/script/tool/lib/src/publish_check_command.dart +++ b/script/tool/lib/src/publish_check_command.dart @@ -71,24 +71,21 @@ class PublishCheckCommand extends PluginCommand { workingDirectory: package.path, ); - String output = ''; - process.stdout.listen((List event) { - io.stdout.add(event); - output += String.fromCharCodes(event); - }); + io.stdout.addStream(process.stdout); + io.stderr.addStream(process.stderr); - process.stderr.listen((List event) { - io.stderr.add(event); - output += String.fromCharCodes(event); - }); + // process.stderr.listen((List event) { + // io.stderr.add(event); + // output += String.fromCharCodes(event); + // }); - final int exitCode = await process.exitCode; + if (await process.exitCode == 0) return true; - final bool hasPreReleaseSdk = output.contains('Package has 1 warning.') && + String output = await process.stdout.join(); + output += await process.stderr.join(); + return output.contains('Package has 1 warning.') && output.contains( 'Packages with an SDK constraint on a pre-release of the Dart SDK should themselves be published as a pre-release version.'); - - return exitCode == 0 || hasPreReleaseSdk; } Future passesPublishCheck(Directory package) async { From cf30a438de6386cd9cdcc4699d3767b78f5b8989 Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Wed, 17 Feb 2021 17:47:40 -0800 Subject: [PATCH 4/4] use onDone callback --- packages/webview_flutter/pubspec.yaml | 1 - .../tool/lib/src/publish_check_command.dart | 30 ++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/webview_flutter/pubspec.yaml b/packages/webview_flutter/pubspec.yaml index 1fa56c22200a..5d8e512b5aa5 100644 --- a/packages/webview_flutter/pubspec.yaml +++ b/packages/webview_flutter/pubspec.yaml @@ -3,7 +3,6 @@ description: A Flutter plugin that provides a WebView widget on Android and iOS. version: 2.0.0-nullsafety.5 homepage: https://github.com/flutter/plugins/tree/master/packages/webview_flutter - environment: sdk: ">=2.12.0-0 <3.0.0" flutter: ">=1.22.0" diff --git a/script/tool/lib/src/publish_check_command.dart b/script/tool/lib/src/publish_check_command.dart index fd373a6c5df4..af009952856e 100644 --- a/script/tool/lib/src/publish_check_command.dart +++ b/script/tool/lib/src/publish_check_command.dart @@ -71,18 +71,32 @@ class PublishCheckCommand extends PluginCommand { workingDirectory: package.path, ); - io.stdout.addStream(process.stdout); - io.stderr.addStream(process.stderr); + final StringBuffer outputBuffer = StringBuffer(); + + final Completer stdOutCompleter = Completer(); + process.stdout.listen( + (List event) { + io.stdout.add(event); + outputBuffer.write(String.fromCharCodes(event)); + }, + onDone: () => stdOutCompleter.complete(), + ); - // process.stderr.listen((List event) { - // io.stderr.add(event); - // output += String.fromCharCodes(event); - // }); + final Completer stdInCompleter = Completer(); + process.stderr.listen( + (List event) { + io.stderr.add(event); + outputBuffer.write(String.fromCharCodes(event)); + }, + onDone: () => stdInCompleter.complete(), + ); if (await process.exitCode == 0) return true; - String output = await process.stdout.join(); - output += await process.stderr.join(); + await stdOutCompleter.future; + await stdInCompleter.future; + + final String output = outputBuffer.toString(); return output.contains('Package has 1 warning.') && output.contains( 'Packages with an SDK constraint on a pre-release of the Dart SDK should themselves be published as a pre-release version.');