mirror of
https://github.com/flutter/packages.git
synced 2025-06-17 20:19:14 +08:00
Publish check ignores prerelease sdk (#3560)
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:io' as io;
|
||||||
|
|
||||||
import 'package:colorize/colorize.dart';
|
import 'package:colorize/colorize.dart';
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
@ -63,6 +64,44 @@ class PublishCheckCommand extends PluginCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> hasValidPublishCheckRun(Directory package) async {
|
||||||
|
final io.Process process = await io.Process.start(
|
||||||
|
'flutter',
|
||||||
|
<String>['pub', 'publish', '--', '--dry-run'],
|
||||||
|
workingDirectory: package.path,
|
||||||
|
);
|
||||||
|
|
||||||
|
final StringBuffer outputBuffer = StringBuffer();
|
||||||
|
|
||||||
|
final Completer<void> stdOutCompleter = Completer<void>();
|
||||||
|
process.stdout.listen(
|
||||||
|
(List<int> event) {
|
||||||
|
io.stdout.add(event);
|
||||||
|
outputBuffer.write(String.fromCharCodes(event));
|
||||||
|
},
|
||||||
|
onDone: () => stdOutCompleter.complete(),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Completer<void> stdInCompleter = Completer<void>();
|
||||||
|
process.stderr.listen(
|
||||||
|
(List<int> event) {
|
||||||
|
io.stderr.add(event);
|
||||||
|
outputBuffer.write(String.fromCharCodes(event));
|
||||||
|
},
|
||||||
|
onDone: () => stdInCompleter.complete(),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (await process.exitCode == 0) return true;
|
||||||
|
|
||||||
|
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.');
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> passesPublishCheck(Directory package) async {
|
Future<bool> passesPublishCheck(Directory package) async {
|
||||||
final String packageName = package.basename;
|
final String packageName = package.basename;
|
||||||
print('Checking that $packageName can be published.');
|
print('Checking that $packageName can be published.');
|
||||||
@ -75,13 +114,7 @@ class PublishCheckCommand extends PluginCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int exitCode = await processRunner.runAndStream(
|
if (await hasValidPublishCheckRun(package)) {
|
||||||
'flutter',
|
|
||||||
<String>['pub', 'publish', '--', '--dry-run'],
|
|
||||||
workingDir: package,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (exitCode == 0) {
|
|
||||||
print("Package $packageName is able to be published.");
|
print("Package $packageName is able to be published.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user