mirror of
https://github.com/flutter/packages.git
synced 2025-08-24 11:39:26 +08:00
[flutter_plugin_tools] Introduce a class for packages (#4252)
Packages are the primary conceptual object in the tool, but currently they are represented simply as Directory (or occasionally a path string). This introduces an object for packages and: - moves a number of existing utility methods into it - sweeps the code for the obvious cases of using `Directory` to represent a package, especially in method signatures and migrates them - notes a few places where we should migrate later, to avoid ballooning the size of the PR There are no doubt other cases not caught in the sweep, but this gives us a foundation both for new code, and to migrate incrementally toward as we find existing code that was missed.
This commit is contained in:
@ -9,6 +9,7 @@ import 'common/core.dart';
|
||||
import 'common/package_looping_command.dart';
|
||||
import 'common/plugin_utils.dart';
|
||||
import 'common/process_runner.dart';
|
||||
import 'common/repository_package.dart';
|
||||
import 'common/xcode.dart';
|
||||
|
||||
/// The command to run Xcode's static analyzer on plugins.
|
||||
@ -42,7 +43,7 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PackageResult> runForPackage(Directory package) async {
|
||||
Future<PackageResult> runForPackage(RepositoryPackage package) async {
|
||||
final bool testIos = getBoolArg(kPlatformIos) &&
|
||||
pluginSupportsPlatform(kPlatformIos, package,
|
||||
requiredMode: PlatformSupport.inline);
|
||||
@ -78,18 +79,18 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
|
||||
|
||||
/// Analyzes [plugin] for [platform], returning true if it passed analysis.
|
||||
Future<bool> _analyzePlugin(
|
||||
Directory plugin,
|
||||
RepositoryPackage plugin,
|
||||
String platform, {
|
||||
List<String> extraFlags = const <String>[],
|
||||
}) async {
|
||||
bool passing = true;
|
||||
for (final Directory example in getExamplesForPlugin(plugin)) {
|
||||
for (final RepositoryPackage example in plugin.getExamples()) {
|
||||
// Running tests and static analyzer.
|
||||
final String examplePath =
|
||||
getRelativePosixPath(example, from: plugin.parent);
|
||||
final String examplePath = getRelativePosixPath(example.directory,
|
||||
from: plugin.directory.parent);
|
||||
print('Running $platform tests and analyzer for $examplePath...');
|
||||
final int exitCode = await _xcode.runXcodeBuild(
|
||||
example,
|
||||
example.directory,
|
||||
actions: <String>['analyze'],
|
||||
workspace: '${platform.toLowerCase()}/Runner.xcworkspace',
|
||||
scheme: 'Runner',
|
||||
|
Reference in New Issue
Block a user