diff --git a/analysis_options.yaml b/analysis_options.yaml index c2f4cbb..9df80aa 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1 +1 @@ -include: package:very_good_analysis/analysis_options.7.0.0.yaml +include: package:very_good_analysis/analysis_options.yaml diff --git a/lib/src/models/package_info.g.dart b/lib/src/models/package_info.g.dart index b262ee8..bee2359 100644 --- a/lib/src/models/package_info.g.dart +++ b/lib/src/models/package_info.g.dart @@ -9,16 +9,17 @@ part of 'package_info.dart'; // ************************************************************************** PackageInfo _$PackageInfoFromJson(Map json) => $checkedCreate( - 'PackageInfo', - json, - ($checkedConvert) { - final val = PackageInfo( - name: $checkedConvert('name', (v) => v as String), - latest: $checkedConvert( - 'latest', - (v) => const LatestVersionConverter() - .fromJson(v as Map)), - ); - return val; - }, + 'PackageInfo', + json, + ($checkedConvert) { + final val = PackageInfo( + name: $checkedConvert('name', (v) => v as String), + latest: $checkedConvert( + 'latest', + (v) => + const LatestVersionConverter().fromJson(v as Map), + ), ); + return val; + }, +); diff --git a/lib/src/pub_updater.dart b/lib/src/pub_updater.dart index 7cd5115..9cc214b 100644 --- a/lib/src/pub_updater.dart +++ b/lib/src/pub_updater.dart @@ -24,8 +24,8 @@ const _pubPackagesPath = '/api/packages/'; class PubUpdater { /// {@macro pub_update} PubUpdater([http.Client? client, String baseUrl = _defaultBaseUrl]) - : _client = client, - _baseUrl = baseUrl; + : _client = client, + _baseUrl = baseUrl; final http.Client? _client; final String _baseUrl; diff --git a/pubspec.yaml b/pubspec.yaml index 3d5f9a2..befca86 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ issue_tracker: https://github.com/VeryGoodOpenSource/pub_updater/issues topics: [cli, pub, version] environment: - sdk: ^3.5.0 + sdk: ^3.8.1 dependencies: http: ^1.2.2 @@ -19,4 +19,4 @@ dev_dependencies: json_serializable: ^6.8.0 mocktail: ^1.0.4 test: ^1.25.8 - very_good_analysis: ^7.0.0 + very_good_analysis: ^9.0.0 diff --git a/test/fixtures/pre_release_package_info_response.dart b/test/fixtures/pre_release_package_info_response.dart index 2a6098e..8eccc75 100644 --- a/test/fixtures/pre_release_package_info_response.dart +++ b/test/fixtures/pre_release_package_info_response.dart @@ -4,11 +4,11 @@ import 'dart:convert'; -final preReleasePackageInfoResponseBody = json.encode( +final String preReleasePackageInfoResponseBody = json.encode( preReleasePackageInfoResponse, ); -const preReleasePackageInfoResponse = { +const Map preReleasePackageInfoResponse = { "name": "mason", "latest": { "version": "0.1.0-dev.48", @@ -424,6 +424,6 @@ const preReleasePackageInfoResponse = { "archive_sha256": "d122e582f4c332b33d95289aafdea475ff5446e9939338b4b6330e2e488ed4e1", "published": "2023-03-24T04:15:07.809166Z", - } + }, ], }; diff --git a/test/fixtures/valid_package_info_response.dart b/test/fixtures/valid_package_info_response.dart index 3f2e001..9281743 100644 --- a/test/fixtures/valid_package_info_response.dart +++ b/test/fixtures/valid_package_info_response.dart @@ -4,9 +4,11 @@ import 'dart:convert'; -final validPackageInfoResponseBody = json.encode(validPackageInfoResponse); +final String validPackageInfoResponseBody = json.encode( + validPackageInfoResponse, +); -const validPackageInfoResponse = { +const Map validPackageInfoResponse = { "name": "very_good_cli", "latest": { "version": "0.4.6", @@ -876,6 +878,6 @@ const validPackageInfoResponse = { "archive_url": "https://pub.dartlang.org/packages/very_good_cli/versions/0.4.6.tar.gz", "published": "2021-10-07T21:23:42.789542Z", - } + }, ], }; diff --git a/test/pub_update_test.dart b/test/pub_update_test.dart index e5b5eb8..16275fc 100644 --- a/test/pub_update_test.dart +++ b/test/pub_update_test.dart @@ -25,7 +25,7 @@ const command = [ 'activate', 'very_good_cli', ]; -const commandWithCustomBaseUrl = [ +const List commandWithCustomBaseUrl = [ 'dart', 'pub', 'global', @@ -44,7 +44,7 @@ const commandWithConstraint = [ 'very_good_cli', '>=0.4.0', ]; -const commandWithConstraintAndCustomBaseUrl = [ +const List commandWithConstraintAndCustomBaseUrl = [ 'dart', 'pub', 'global', @@ -80,8 +80,9 @@ void main() { when(() => response.statusCode).thenReturn(HttpStatus.ok); when(() => response.body).thenReturn(validPackageInfoResponseBody); - when(() => processManager.run(any())) - .thenAnswer((_) => Future.value(ProcessResult(42, 0, '', ''))); + when( + () => processManager.run(any()), + ).thenAnswer((_) => Future.value(ProcessResult(42, 0, '', ''))); }); test('can be instantiated without an explicit http client', () { @@ -173,11 +174,13 @@ void main() { when(() => client.get(any())).thenAnswer((_) async => response); when(() => response.statusCode).thenReturn(HttpStatus.ok); - when(() => response.body) - .thenReturn(preReleasePackageInfoResponseBody); + when( + () => response.body, + ).thenReturn(preReleasePackageInfoResponseBody); - when(() => processManager.run(any())) - .thenAnswer((_) => Future.value(ProcessResult(42, 0, '', ''))); + when( + () => processManager.run(any()), + ).thenAnswer((_) => Future.value(ProcessResult(42, 0, '', ''))); }); test('returns false when currentVersion < latestVersion', () async { @@ -212,17 +215,19 @@ void main() { ); }); - test('throws PackageInfoNotFoundFailure when response body is empty', - () async { - when(() => response.body).thenReturn(emptyResponseBody); - await expectLater( - pubUpdater.isUpToDate( - packageName: 'very_good_cli', - currentVersion: '3.0.0', - ), - throwsA(isA()), - ); - }); + test( + 'throws PackageInfoNotFoundFailure when response body is empty', + () async { + when(() => response.body).thenReturn(emptyResponseBody); + await expectLater( + pubUpdater.isUpToDate( + packageName: 'very_good_cli', + currentVersion: '3.0.0', + ), + throwsA(isA()), + ); + }, + ); }); group('getLatestVersion', () { @@ -274,14 +279,16 @@ void main() { ); }); - test('throws PackageInfoNotFoundFailure when response body is empty', - () async { - when(() => response.body).thenReturn(emptyResponseBody); - await expectLater( - pubUpdater.getLatestVersion('very_good_cli'), - throwsA(isA()), - ); - }); + test( + 'throws PackageInfoNotFoundFailure when response body is empty', + () async { + when(() => response.body).thenReturn(emptyResponseBody); + await expectLater( + pubUpdater.getLatestVersion('very_good_cli'), + throwsA(isA()), + ); + }, + ); }); group('update', () { @@ -301,27 +308,32 @@ void main() { verify(() => processManager.run(commandWithCustomBaseUrl)).called(1); }); - test('makes correct call to process.run with version constraint', - () async { - await pubUpdater.update( - packageName: 'very_good_cli', - processManager: processManager, - versionConstraint: '>=0.4.0', - ); - verify(() => processManager.run(commandWithConstraint)).called(1); - }); + test( + 'makes correct call to process.run with version constraint', + () async { + await pubUpdater.update( + packageName: 'very_good_cli', + processManager: processManager, + versionConstraint: '>=0.4.0', + ); + verify(() => processManager.run(commandWithConstraint)).called(1); + }, + ); - test('makes correct call to process.run with version constraint', - () async { - pubUpdater = PubUpdater(client, customBaseUrl); - await pubUpdater.update( - packageName: 'very_good_cli', - processManager: processManager, - versionConstraint: '>=0.4.0', - ); - verify(() => processManager.run(commandWithConstraintAndCustomBaseUrl)) - .called(1); - }); + test( + 'makes correct call to process.run with version constraint', + () async { + pubUpdater = PubUpdater(client, customBaseUrl); + await pubUpdater.update( + packageName: 'very_good_cli', + processManager: processManager, + versionConstraint: '>=0.4.0', + ); + verify( + () => processManager.run(commandWithConstraintAndCustomBaseUrl), + ).called(1); + }, + ); }); }); }