diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d16c0a..0c2c5c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Version 0.17.1 +- Search downloaded packages in entire .pub-cache hosted directory in case path namining changes + ## Version 0.17.0 - bump dart SDK requirements to >=3.0.0 diff --git a/lib/src/analyze/package_api_analyzer.freezed.dart b/lib/src/analyze/package_api_analyzer.freezed.dart index 5393105..18de5d2 100644 --- a/lib/src/analyze/package_api_analyzer.freezed.dart +++ b/lib/src/analyze/package_api_analyzer.freezed.dart @@ -176,7 +176,7 @@ class _$_FileToAnalyzeEntryImpl implements __FileToAnalyzeEntry { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_FileToAnalyzeEntryImpl && diff --git a/lib/src/model/executable_declaration.freezed.dart b/lib/src/model/executable_declaration.freezed.dart index 4d02315..69c658c 100644 --- a/lib/src/model/executable_declaration.freezed.dart +++ b/lib/src/model/executable_declaration.freezed.dart @@ -256,7 +256,7 @@ class _$ExecutableParameterDeclarationImpl } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$ExecutableParameterDeclarationImpl && @@ -656,7 +656,7 @@ class _$ExecutableDeclarationImpl extends _ExecutableDeclaration { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$ExecutableDeclarationImpl && diff --git a/lib/src/model/field_declaration.freezed.dart b/lib/src/model/field_declaration.freezed.dart index 8439a50..34ef9e4 100644 --- a/lib/src/model/field_declaration.freezed.dart +++ b/lib/src/model/field_declaration.freezed.dart @@ -239,7 +239,7 @@ class _$FieldDeclarationImpl extends _FieldDeclaration { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$FieldDeclarationImpl && diff --git a/lib/src/model/interface_declaration.freezed.dart b/lib/src/model/interface_declaration.freezed.dart index fc841a0..07efec2 100644 --- a/lib/src/model/interface_declaration.freezed.dart +++ b/lib/src/model/interface_declaration.freezed.dart @@ -385,7 +385,7 @@ class _$InterfaceDeclarationImpl extends _InterfaceDeclaration { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$InterfaceDeclarationImpl && diff --git a/lib/src/model/package_api.freezed.dart b/lib/src/model/package_api.freezed.dart index 30cbca8..902fa79 100644 --- a/lib/src/model/package_api.freezed.dart +++ b/lib/src/model/package_api.freezed.dart @@ -464,7 +464,7 @@ class _$PackageApiImpl extends _PackageApi { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$PackageApiImpl && diff --git a/lib/src/model/package_dependency.freezed.dart b/lib/src/model/package_dependency.freezed.dart index 7805963..bbf6dea 100644 --- a/lib/src/model/package_dependency.freezed.dart +++ b/lib/src/model/package_dependency.freezed.dart @@ -123,7 +123,7 @@ class _$PackageDependencyImpl implements _PackageDependency { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$PackageDependencyImpl && diff --git a/lib/src/model/platform_constraints.freezed.dart b/lib/src/model/platform_constraints.freezed.dart index d31f4c8..c7eddd6 100644 --- a/lib/src/model/platform_constraints.freezed.dart +++ b/lib/src/model/platform_constraints.freezed.dart @@ -109,7 +109,7 @@ class _$IOSPlatformConstraintsImpl implements _IOSPlatformConstraints { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$IOSPlatformConstraintsImpl && @@ -277,7 +277,7 @@ class _$AndroidPlatformConstraintsImpl implements _AndroidPlatformConstraints { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$AndroidPlatformConstraintsImpl && diff --git a/lib/src/model/type_alias_declaration.freezed.dart b/lib/src/model/type_alias_declaration.freezed.dart index a54255e..5fce81a 100644 --- a/lib/src/model/type_alias_declaration.freezed.dart +++ b/lib/src/model/type_alias_declaration.freezed.dart @@ -220,7 +220,7 @@ class _$TypeAliasDeclarationImpl extends _TypeAliasDeclaration { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$TypeAliasDeclarationImpl && diff --git a/lib/src/model/type_hierarchy.freezed.dart b/lib/src/model/type_hierarchy.freezed.dart index 154575c..08ebc0b 100644 --- a/lib/src/model/type_hierarchy.freezed.dart +++ b/lib/src/model/type_hierarchy.freezed.dart @@ -140,7 +140,7 @@ class _$TypeIdentifierImpl extends _TypeIdentifier { final String packageRelativeLibraryPath; @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$TypeIdentifierImpl && @@ -322,7 +322,7 @@ class _$_TypeHierarchyItemImpl extends __TypeHierarchyItem { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_TypeHierarchyItemImpl && diff --git a/lib/src/storage/v3/executable_declaration_storage_v3.freezed.dart b/lib/src/storage/v3/executable_declaration_storage_v3.freezed.dart index 1c0242a..b468dde 100644 --- a/lib/src/storage/v3/executable_declaration_storage_v3.freezed.dart +++ b/lib/src/storage/v3/executable_declaration_storage_v3.freezed.dart @@ -223,7 +223,7 @@ class _$ExecutableParameterDeclarationStorageV3Impl } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$ExecutableParameterDeclarationStorageV3Impl && @@ -578,7 +578,7 @@ class _$ExecutableDeclarationStorageV3Impl } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$ExecutableDeclarationStorageV3Impl && diff --git a/lib/src/storage/v3/field_declaration_storage_v3.freezed.dart b/lib/src/storage/v3/field_declaration_storage_v3.freezed.dart index eb03e5d..98d51b2 100644 --- a/lib/src/storage/v3/field_declaration_storage_v3.freezed.dart +++ b/lib/src/storage/v3/field_declaration_storage_v3.freezed.dart @@ -223,7 +223,7 @@ class _$FieldDeclarationStorageV3Impl extends _FieldDeclarationStorageV3 { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$FieldDeclarationStorageV3Impl && diff --git a/lib/src/storage/v3/interface_declaration_storage_v3.freezed.dart b/lib/src/storage/v3/interface_declaration_storage_v3.freezed.dart index 861439f..39d40cd 100644 --- a/lib/src/storage/v3/interface_declaration_storage_v3.freezed.dart +++ b/lib/src/storage/v3/interface_declaration_storage_v3.freezed.dart @@ -325,7 +325,7 @@ class _$InterfaceDeclarationStorageV3Impl } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$InterfaceDeclarationStorageV3Impl && diff --git a/lib/src/storage/v3/package_api_storage_v3.freezed.dart b/lib/src/storage/v3/package_api_storage_v3.freezed.dart index f954b06..3b7fd69 100644 --- a/lib/src/storage/v3/package_api_storage_v3.freezed.dart +++ b/lib/src/storage/v3/package_api_storage_v3.freezed.dart @@ -400,7 +400,7 @@ class _$PackageApiStorageV3Impl extends _PackageApiStorageV3 { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$PackageApiStorageV3Impl && diff --git a/lib/src/storage/v3/package_dependency_storage_v3.freezed.dart b/lib/src/storage/v3/package_dependency_storage_v3.freezed.dart index 8676325..7a6d6e6 100644 --- a/lib/src/storage/v3/package_dependency_storage_v3.freezed.dart +++ b/lib/src/storage/v3/package_dependency_storage_v3.freezed.dart @@ -133,7 +133,7 @@ class _$PackageDependencyStorageV3Impl extends _PackageDependencyStorageV3 { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$PackageDependencyStorageV3Impl && diff --git a/lib/src/storage/v3/platform_constraints_storage_v3.freezed.dart b/lib/src/storage/v3/platform_constraints_storage_v3.freezed.dart index 765330a..5b5ce6b 100644 --- a/lib/src/storage/v3/platform_constraints_storage_v3.freezed.dart +++ b/lib/src/storage/v3/platform_constraints_storage_v3.freezed.dart @@ -121,7 +121,7 @@ class _$IOSPlatformConstraintsStorageV3Impl } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$IOSPlatformConstraintsStorageV3Impl && @@ -307,7 +307,7 @@ class _$AndroidPlatformConstraintsStorageV3Impl } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$AndroidPlatformConstraintsStorageV3Impl && diff --git a/lib/src/storage/v3/type_alias_declaration_storage_v3.freezed.dart b/lib/src/storage/v3/type_alias_declaration_storage_v3.freezed.dart index c8ca546..19404e5 100644 --- a/lib/src/storage/v3/type_alias_declaration_storage_v3.freezed.dart +++ b/lib/src/storage/v3/type_alias_declaration_storage_v3.freezed.dart @@ -211,7 +211,7 @@ class _$TypeAliasDeclarationStorageV3Impl } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && other is _$TypeAliasDeclarationStorageV3Impl && diff --git a/lib/src/tooling/pub_interaction.dart b/lib/src/tooling/pub_interaction.dart index b23fae2..4df9251 100644 --- a/lib/src/tooling/pub_interaction.dart +++ b/lib/src/tooling/pub_interaction.dart @@ -58,26 +58,54 @@ abstract class PubInteraction { /// returns the cache path of a package with the given [packageName] and [version] static String getPackagePathInCache(String packageName, String version) { - String getHostedDirectory(String cacheDir, String hostedUrl) { - return path.join(cacheDir, 'hosted', hostedUrl, '$packageName-$version'); + String? findHostedDirectory(List hostedUrls) { + for (final hostedUrl in hostedUrls) { + final packagePath = path.join(hostedUrl, '$packageName-$version'); + if (Directory(packagePath).existsSync()) { + return packagePath; + } else { + return null; + } + } + return null; } final cacheDir = pubCacheDir; + final hostedDir = path.join(cacheDir, 'hosted'); + List hostedDirs = []; + + if (Directory(hostedDir).existsSync()) { + Directory(hostedDir) + .listSync() + .map((entity) => entity.path) + .forEach((path) { + if (Directory(path).existsSync()) { + hostedDirs.add(path); + } + }); + } final envHostedUrl = Platform.environment['PUB_HOSTED_URL']; final envHosted = envHostedUrl == null ? null : Uri.parse(envHostedUrl).host; - if (envHosted == null) { + + final List hostPriorities = [ + // first check PUB_HOSTED_URL from environment variable if set + if (envHosted != null) envHosted, // Flutter 3.7 changed the name of the pub.dev directory => first test the old one, then the new one - var packageDirectory = getHostedDirectory(cacheDir, 'pub.dartlang.org'); - if (Directory(packageDirectory).existsSync()) { - return packageDirectory; + 'pub.dartlang.org', + 'pub.dev', + ]; + + for (final hostPriority in hostPriorities) { + final matchingHostedDirs = + hostedDirs.where((dir) => dir.startsWith(hostPriority)).toList(); + final foundPackagePath = findHostedDirectory(matchingHostedDirs); + if (foundPackagePath != null) { + return foundPackagePath; } - packageDirectory = getHostedDirectory(cacheDir, 'pub.dev'); - return packageDirectory; - } else { - return getHostedDirectory(cacheDir, envHosted); } + return findHostedDirectory(hostedDirs)!; } /// runs pub get in the given [packageDirectory] diff --git a/pubspec.yaml b/pubspec.yaml index b008219..ec2f5d7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: dart_apitool description: A tool to analyze the public API of a package, create a model of it and diff it against another version to check semver. repository: https://github.com/bmw-tech/dart_apitool -version: 0.17.0-dev +version: 0.17.1-dev environment: sdk: '>=3.0.0 <4.0.0'