mirror of
https://github.com/flutter/packages.git
synced 2025-06-09 05:59:45 +08:00
Switch script/tools over to the new analysis options (#3777)
Removes the legacy analysis options override and fixes all resulting issues. This is a combination of dart fix and manual changes (mostly mechanical, but some small restructuring to address warnings more cleanly, such as creating typed structs from args when they are used repeatedly to avoid repeated casting, or making things that were unnecessarily public private). One small opportunistic extra cleanup is that the handling of null-safety prerelease versions is removed, as any new plugin would be written null-safe from the start, so we no longer need to allow those versions. Part of flutter/flutter#76229
This commit is contained in:
@ -11,7 +11,9 @@ import 'package:pubspec_parse/pubspec_parse.dart';
|
||||
|
||||
import 'common.dart';
|
||||
|
||||
/// A command to check that packages are publishable via 'dart publish'.
|
||||
class PublishCheckCommand extends PluginCommand {
|
||||
/// Creates an instance of the publish command.
|
||||
PublishCheckCommand(
|
||||
Directory packagesDir,
|
||||
FileSystem fileSystem, {
|
||||
@ -26,12 +28,13 @@ class PublishCheckCommand extends PluginCommand {
|
||||
'Checks to make sure that a plugin *could* be published.';
|
||||
|
||||
@override
|
||||
Future<Null> run() async {
|
||||
checkSharding();
|
||||
Future<void> run() async {
|
||||
final List<Directory> failedPackages = <Directory>[];
|
||||
|
||||
await for (Directory plugin in getPlugins()) {
|
||||
if (!(await passesPublishCheck(plugin))) failedPackages.add(plugin);
|
||||
await for (final Directory plugin in getPlugins()) {
|
||||
if (!(await _passesPublishCheck(plugin))) {
|
||||
failedPackages.add(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
if (failedPackages.isNotEmpty) {
|
||||
@ -51,7 +54,7 @@ class PublishCheckCommand extends PluginCommand {
|
||||
print(passedMessage);
|
||||
}
|
||||
|
||||
Pubspec tryParsePubspec(Directory package) {
|
||||
Pubspec _tryParsePubspec(Directory package) {
|
||||
final File pubspecFile = package.childFile('pubspec.yaml');
|
||||
|
||||
try {
|
||||
@ -64,7 +67,7 @@ class PublishCheckCommand extends PluginCommand {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> hasValidPublishCheckRun(Directory package) async {
|
||||
Future<bool> _hasValidPublishCheckRun(Directory package) async {
|
||||
final io.Process process = await processRunner.start(
|
||||
'flutter',
|
||||
<String>['pub', 'publish', '--', '--dry-run'],
|
||||
@ -91,7 +94,9 @@ class PublishCheckCommand extends PluginCommand {
|
||||
onDone: () => stdInCompleter.complete(),
|
||||
);
|
||||
|
||||
if (await process.exitCode == 0) return true;
|
||||
if (await process.exitCode == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
await stdOutCompleter.future;
|
||||
await stdInCompleter.future;
|
||||
@ -102,11 +107,11 @@ class PublishCheckCommand extends PluginCommand {
|
||||
'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;
|
||||
print('Checking that $packageName can be published.');
|
||||
|
||||
final Pubspec pubspec = tryParsePubspec(package);
|
||||
final Pubspec pubspec = _tryParsePubspec(package);
|
||||
if (pubspec == null) {
|
||||
return false;
|
||||
} else if (pubspec.publishTo == 'none') {
|
||||
@ -114,8 +119,8 @@ class PublishCheckCommand extends PluginCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (await hasValidPublishCheckRun(package)) {
|
||||
print("Package $packageName is able to be published.");
|
||||
if (await _hasValidPublishCheckRun(package)) {
|
||||
print('Package $packageName is able to be published.');
|
||||
return true;
|
||||
} else {
|
||||
print('Unable to publish $packageName');
|
||||
|
Reference in New Issue
Block a user