mirror of
https://github.com/flutter/packages.git
synced 2025-06-12 15:49:05 +08:00
[flutter_plugin_tools] Fix subpackage analysis (#5027)
This commit is contained in:
@ -102,16 +102,25 @@ class AnalyzeCommand extends PackageLoopingCommand {
|
||||
|
||||
@override
|
||||
Future<PackageResult> runForPackage(RepositoryPackage package) async {
|
||||
// For non-example packages, fetch dependencies. 'flutter packages get'
|
||||
// automatically runs 'pub get' in examples as part of handling the parent
|
||||
// directory, which is guaranteed to come first in the package enumeration.
|
||||
if (package.directory.basename != 'example' ||
|
||||
!RepositoryPackage(package.directory.parent).pubspecFile.existsSync()) {
|
||||
final int exitCode = await processRunner.runAndStream(
|
||||
flutterCommand, <String>['packages', 'get'],
|
||||
workingDir: package.directory);
|
||||
if (exitCode != 0) {
|
||||
return PackageResult.fail(<String>['Unable to get dependencies']);
|
||||
// Analysis runs over the package and all subpackages, so all of them need
|
||||
// `flutter packages get` run before analyzing. `example` packages can be
|
||||
// skipped since 'flutter packages get' automatically runs `pub get` in
|
||||
// examples as part of handling the parent directory.
|
||||
final List<RepositoryPackage> packagesToGet = <RepositoryPackage>[
|
||||
package,
|
||||
...await getSubpackages(package).toList(),
|
||||
];
|
||||
for (final RepositoryPackage packageToGet in packagesToGet) {
|
||||
if (packageToGet.directory.basename != 'example' ||
|
||||
!RepositoryPackage(packageToGet.directory.parent)
|
||||
.pubspecFile
|
||||
.existsSync()) {
|
||||
final int exitCode = await processRunner.runAndStream(
|
||||
flutterCommand, <String>['packages', 'get'],
|
||||
workingDir: packageToGet.directory);
|
||||
if (exitCode != 0) {
|
||||
return PackageResult.fail(<String>['Unable to get dependencies']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,16 +417,22 @@ abstract class PluginCommand extends Command<void> {
|
||||
await for (final PackageEnumerationEntry plugin
|
||||
in getTargetPackages(filterExcluded: filterExcluded)) {
|
||||
yield plugin;
|
||||
yield* plugin.package.directory
|
||||
.list(recursive: true, followLinks: false)
|
||||
.where(_isDartPackage)
|
||||
.map((FileSystemEntity directory) => PackageEnumerationEntry(
|
||||
// _isDartPackage guarantees that this cast is valid.
|
||||
RepositoryPackage(directory as Directory),
|
||||
excluded: plugin.excluded));
|
||||
yield* getSubpackages(plugin.package).map((RepositoryPackage package) =>
|
||||
PackageEnumerationEntry(package, excluded: plugin.excluded));
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns all Dart package folders (e.g., examples) under the given package.
|
||||
Stream<RepositoryPackage> getSubpackages(RepositoryPackage package,
|
||||
{bool filterExcluded = true}) async* {
|
||||
yield* package.directory
|
||||
.list(recursive: true, followLinks: false)
|
||||
.where(_isDartPackage)
|
||||
.map((FileSystemEntity directory) =>
|
||||
// _isDartPackage guarantees that this cast is valid.
|
||||
RepositoryPackage(directory as Directory));
|
||||
}
|
||||
|
||||
/// Returns the files contained, recursively, within the packages
|
||||
/// involved in this command execution.
|
||||
Stream<File> getFiles() {
|
||||
|
@ -207,6 +207,10 @@ dependency_overrides:
|
||||
allComponents.contains('example')) {
|
||||
continue;
|
||||
}
|
||||
if (!allComponents.contains(packagesDir.basename)) {
|
||||
print(' Skipping $changedPath; not in packages directory.');
|
||||
continue;
|
||||
}
|
||||
final RepositoryPackage package =
|
||||
RepositoryPackage(packagesDir.fileSystem.file(changedPath).parent);
|
||||
// Ignored deleted packages, as they won't be published.
|
||||
|
Reference in New Issue
Block a user