From c835c4b02e64f661e5a7c5c23f4e23a6b25f5281 Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Fri, 12 May 2023 09:40:59 -0700 Subject: [PATCH] feat(shorebird_cli): expose `flutter_revision` on `release` (#475) --- .../test/src/commands/patch_command_test.dart | 1 + .../src/commands/release_command_test.dart | 1 + .../releases/delete_releases_command_test.dart | 4 ++++ .../releases/list_releases_command_test.dart | 5 +++++ .../test/src/code_push_client_test.dart | 18 ++++++++++++++++-- .../lib/src/models/release.dart | 4 ++++ .../lib/src/models/release.g.dart | 9 ++++++++- .../test/src/models/release_test.dart | 1 + 8 files changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/shorebird_cli/test/src/commands/patch_command_test.dart b/packages/shorebird_cli/test/src/commands/patch_command_test.dart index 37a14e39..df711bf7 100644 --- a/packages/shorebird_cli/test/src/commands/patch_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch_command_test.dart @@ -70,6 +70,7 @@ void main() { id: 0, appId: appId, version: version, + flutterRevision: '83305b5088e6fe327fb3334a73ff190828d85713', displayName: '1.2.3+1', ); const patch = Patch(id: 0, number: 1); diff --git a/packages/shorebird_cli/test/src/commands/release_command_test.dart b/packages/shorebird_cli/test/src/commands/release_command_test.dart index 52e7321e..eee6eb12 100644 --- a/packages/shorebird_cli/test/src/commands/release_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/release_command_test.dart @@ -52,6 +52,7 @@ void main() { id: 0, appId: appId, version: version, + flutterRevision: '83305b5088e6fe327fb3334a73ff190828d85713', displayName: '1.2.3+1', ); const releaseArtifact = ReleaseArtifact( diff --git a/packages/shorebird_cli/test/src/commands/releases/delete_releases_command_test.dart b/packages/shorebird_cli/test/src/commands/releases/delete_releases_command_test.dart index e0112111..a99929f7 100644 --- a/packages/shorebird_cli/test/src/commands/releases/delete_releases_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/releases/delete_releases_command_test.dart @@ -25,6 +25,7 @@ class _MockProgress extends Mock implements Progress {} void main() { group(DeleteReleasesCommand, () { const appId = 'test-app-id'; + const flutterRevision = '83305b5088e6fe327fb3334a73ff190828d85713'; const releaseId = 3; const versionNumber = '1.0.0'; @@ -87,18 +88,21 @@ flutter: id: 1, appId: appId, version: '0.1.0', + flutterRevision: flutterRevision, displayName: null, ), const Release( id: 2, appId: appId, version: '0.1.1', + flutterRevision: flutterRevision, displayName: null, ), const Release( id: releaseId, appId: appId, version: versionNumber, + flutterRevision: flutterRevision, displayName: null, ), ], diff --git a/packages/shorebird_cli/test/src/commands/releases/list_releases_command_test.dart b/packages/shorebird_cli/test/src/commands/releases/list_releases_command_test.dart index 77c8c767..ea085cb3 100644 --- a/packages/shorebird_cli/test/src/commands/releases/list_releases_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/releases/list_releases_command_test.dart @@ -23,6 +23,8 @@ class _MockLogger extends Mock implements Logger {} void main() { group(ListReleasesCommand, () { const appId = 'test-app-id'; + const flutterRevision = '83305b5088e6fe327fb3334a73ff190828d85713'; + late ArgResults argResults; late Auth auth; late http.Client httpClient; @@ -139,6 +141,7 @@ flavors: id: 1, appId: appId, version: '1.0.0', + flutterRevision: flutterRevision, displayName: 'v1.0.0 (dev)', ), ], @@ -170,12 +173,14 @@ flavors: id: 1, appId: appId, version: '1.0.1', + flutterRevision: flutterRevision, displayName: 'First', ), const Release( id: 1, appId: appId, version: '1.0.2', + flutterRevision: flutterRevision, displayName: null, ), ], diff --git a/packages/shorebird_code_push_client/test/src/code_push_client_test.dart b/packages/shorebird_code_push_client/test/src/code_push_client_test.dart index 3b1ffaf2..1b1e2b37 100644 --- a/packages/shorebird_code_push_client/test/src/code_push_client_test.dart +++ b/packages/shorebird_code_push_client/test/src/code_push_client_test.dart @@ -15,6 +15,7 @@ class _FakeBaseRequest extends Fake implements http.BaseRequest {} void main() { group('CodePushClient', () { const appId = 'app-id'; + const flutterRevision = '83305b5088e6fe327fb3334a73ff190828d85713'; const displayName = 'shorebird-example'; const errorResponse = ErrorResponse( code: 'test_code', @@ -738,6 +739,7 @@ void main() { id: releaseId, appId: appId, version: version, + flutterRevision: flutterRevision, displayName: displayName, ), ), @@ -1205,8 +1207,20 @@ void main() { test('completes when request succeeds (populated)', () async { final expected = [ - Release(id: 0, appId: '1', version: '1.0.0', displayName: 'v1.0.0'), - Release(id: 1, appId: '2', version: '1.0.1', displayName: 'v1.0.1'), + Release( + id: 0, + appId: '1', + version: '1.0.0', + flutterRevision: flutterRevision, + displayName: 'v1.0.0', + ), + Release( + id: 1, + appId: '2', + version: '1.0.1', + flutterRevision: flutterRevision, + displayName: 'v1.0.1', + ), ]; when( diff --git a/packages/shorebird_code_push_protocol/lib/src/models/release.dart b/packages/shorebird_code_push_protocol/lib/src/models/release.dart index e8afc4ed..77400737 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/release.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/release.dart @@ -13,6 +13,7 @@ class Release { required this.id, required this.appId, required this.version, + required this.flutterRevision, required this.displayName, }); @@ -32,6 +33,9 @@ class Release { /// The version of the release. final String version; + /// The Flutter revision used to create the release. + final String flutterRevision; + /// The display name for the release final String? displayName; } diff --git a/packages/shorebird_code_push_protocol/lib/src/models/release.g.dart b/packages/shorebird_code_push_protocol/lib/src/models/release.g.dart index 418a0ad1..f44651bd 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/release.g.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/release.g.dart @@ -16,16 +16,23 @@ Release _$ReleaseFromJson(Map json) => $checkedCreate( id: $checkedConvert('id', (v) => v as int), appId: $checkedConvert('app_id', (v) => v as String), version: $checkedConvert('version', (v) => v as String), + flutterRevision: + $checkedConvert('flutter_revision', (v) => v as String), displayName: $checkedConvert('display_name', (v) => v as String?), ); return val; }, - fieldKeyMap: const {'appId': 'app_id', 'displayName': 'display_name'}, + fieldKeyMap: const { + 'appId': 'app_id', + 'flutterRevision': 'flutter_revision', + 'displayName': 'display_name' + }, ); Map _$ReleaseToJson(Release instance) => { 'id': instance.id, 'app_id': instance.appId, 'version': instance.version, + 'flutter_revision': instance.flutterRevision, 'display_name': instance.displayName, }; diff --git a/packages/shorebird_code_push_protocol/test/src/models/release_test.dart b/packages/shorebird_code_push_protocol/test/src/models/release_test.dart index 3bcb6ce7..7a623cd5 100644 --- a/packages/shorebird_code_push_protocol/test/src/models/release_test.dart +++ b/packages/shorebird_code_push_protocol/test/src/models/release_test.dart @@ -8,6 +8,7 @@ void main() { id: 1, appId: 'app-id', version: '1.0.0', + flutterRevision: '83305b5088e6fe327fb3334a73ff190828d85713', displayName: 'v1.0.0', ); expect(