Skip to content

Commit

Permalink
Indicate when using the latest version of a Pub package
Browse files Browse the repository at this point in the history
  • Loading branch information
greglittlefield-wf committed Aug 6, 2024
1 parent eda7140 commit 50b6fc7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/src/dart3_suggestors/required_props/collect/package/pub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import 'spec.dart';
import 'version_manager.dart';

PackageSpec packageSpecFromPackageVersion(
PackageVersion version, PackageVersionManager versionManager) {
PackageVersion version, PackageVersionManager versionManager,
{String? sourceDescription}) {
sourceDescription ??= version.toString();
return PackageSpec(
packageName: version.packageName,
versionId: version.version,
sourceDescription: version.toString(),
sourceDescription: sourceDescription,
getDirectory: () => versionManager.getExtractedFolder(version),
);
}
Expand All @@ -42,11 +44,16 @@ Future<PackageSpec> pubPackageSpec({
required PackageVersionManager versionManager,
required String host,
}) async {
version ??= await getLatestVersionOfPackage(packageName, host: host);
final useLatest = version == null;

final packageVersion = PackageVersion(
hostUrl: host,
packageName: packageName,
version: version,
version: useLatest
? await getLatestVersionOfPackage(packageName, host: host)
: version,
);
return packageSpecFromPackageVersion(packageVersion, versionManager);
return packageSpecFromPackageVersion(packageVersion, versionManager,
sourceDescription:
useLatest ? '$packageVersion (latest version)' : '$packageVersion');
}

0 comments on commit 50b6fc7

Please sign in to comment.