From 6d9a5e981bfbe1108a772d7e3b188a58cb1639a2 Mon Sep 17 00:00:00 2001 From: Erick Date: Wed, 19 Jun 2024 15:23:32 -0300 Subject: [PATCH] feat(shorebird_code_push_protocol): Adding can sideload to artifacts (#2269) --- .../test/src/code_push_client_wrapper_test.dart | 1 + .../test/src/commands/patch/aar_patcher_test.dart | 1 + .../test/src/commands/patch/android_patcher_test.dart | 1 + .../commands/patch/ios_framework_patcher_test.dart | 1 + .../test/src/commands/patch/ios_patcher_test.dart | 3 +++ .../test/src/commands/patch/patch_command_test.dart | 2 ++ .../test/src/code_push_client_test.dart | 1 + .../lib/src/models/release_artifact.dart | 5 +++++ .../lib/src/models/release_artifact.g.dart | 11 +++++++---- .../get_release_artifacts_response_test.dart | 1 + .../test/src/models/release_artifact_test.dart | 4 +++- 11 files changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart b/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart index bf9f7fb0..3bc557d4 100644 --- a/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart +++ b/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart @@ -140,6 +140,7 @@ void main() { size: 4, url: 'url', podfileLockHash: 'podfile-lock-hash', + canSideload: true, ); late CodePushClient codePushClient; diff --git a/packages/shorebird_cli/test/src/commands/patch/aar_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch/aar_patcher_test.dart index da66184c..56608915 100644 --- a/packages/shorebird_cli/test/src/commands/patch/aar_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/aar_patcher_test.dart @@ -381,6 +381,7 @@ void main() { size: 42, url: 'https://example.com', podfileLockHash: null, + canSideload: true, ); late File releaseArtifactFile; diff --git a/packages/shorebird_cli/test/src/commands/patch/android_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch/android_patcher_test.dart index 52990755..55b52001 100644 --- a/packages/shorebird_cli/test/src/commands/patch/android_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/android_patcher_test.dart @@ -403,6 +403,7 @@ Looked in: size: 42, url: 'https://example.com', podfileLockHash: null, + canSideload: true, ); setUp(() { diff --git a/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart index 4dcc0687..a61a76fd 100644 --- a/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart @@ -459,6 +459,7 @@ void main() { size: 42, url: 'https://example.com', podfileLockHash: null, + canSideload: true, ); late File releaseArtifactFile; diff --git a/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart index 7f00e745..690895c8 100644 --- a/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart @@ -349,6 +349,7 @@ void main() { size: 42, url: 'https://example.com', podfileLockHash: podfileLockHash, + canSideload: true, ); test('does not warn of native changes', () async { @@ -378,6 +379,7 @@ void main() { size: 42, url: 'https://example.com', podfileLockHash: 'podfile-lock-hash', + canSideload: true, ); group('when native diffs are allowed', () { @@ -766,6 +768,7 @@ For more information see: $supportedVersionsLink''', size: 42, url: 'https://example.com', podfileLockHash: 'podfile-lock-hash', + canSideload: true, ); late File releaseArtifactFile; diff --git a/packages/shorebird_cli/test/src/commands/patch/patch_command_test.dart b/packages/shorebird_cli/test/src/commands/patch/patch_command_test.dart index b75deea0..c4bde68c 100644 --- a/packages/shorebird_cli/test/src/commands/patch/patch_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/patch_command_test.dart @@ -75,6 +75,7 @@ void main() { size: 42, url: 'https://example.com', podfileLockHash: null, + canSideload: true, ); const aabArtifact = ReleaseArtifact( id: 0, @@ -85,6 +86,7 @@ void main() { size: 42, url: 'https://example.com/release.aab', podfileLockHash: null, + canSideload: true, ); late AotTools aotTools; 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 28fbe254..29c6a1f3 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 @@ -1728,6 +1728,7 @@ void main() { hash: '#', size: 42, podfileLockHash: null, + canSideload: true, ), ]; diff --git a/packages/shorebird_code_push_protocol/lib/src/models/release_artifact.dart b/packages/shorebird_code_push_protocol/lib/src/models/release_artifact.dart index 770e4256..2f0f5fa3 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/release_artifact.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/release_artifact.dart @@ -19,6 +19,7 @@ class ReleaseArtifact { required this.size, required this.url, required this.podfileLockHash, + required this.canSideload, }); /// Converts a Map to a [ReleaseArtifact] @@ -52,6 +53,10 @@ class ReleaseArtifact { /// The hash of the Podfile.lock file used to create the artifact (iOS only). final String? podfileLockHash; + /// Whether the artifact can be sideloaded onto a device or not + /// (e.g. non signed iOS artifacts cannot be sideloaded). + final bool canSideload; + @override String toString() => toJson().toString(); } diff --git a/packages/shorebird_code_push_protocol/lib/src/models/release_artifact.g.dart b/packages/shorebird_code_push_protocol/lib/src/models/release_artifact.g.dart index 6afef45b..f2b34e0d 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/release_artifact.g.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/release_artifact.g.dart @@ -14,22 +14,24 @@ ReleaseArtifact _$ReleaseArtifactFromJson(Map json) => json, ($checkedConvert) { final val = ReleaseArtifact( - id: $checkedConvert('id', (v) => v as int), - releaseId: $checkedConvert('release_id', (v) => v as int), + id: $checkedConvert('id', (v) => (v as num).toInt()), + releaseId: $checkedConvert('release_id', (v) => (v as num).toInt()), arch: $checkedConvert('arch', (v) => v as String), platform: $checkedConvert( 'platform', (v) => $enumDecode(_$ReleasePlatformEnumMap, v)), hash: $checkedConvert('hash', (v) => v as String), - size: $checkedConvert('size', (v) => v as int), + size: $checkedConvert('size', (v) => (v as num).toInt()), url: $checkedConvert('url', (v) => v as String), podfileLockHash: $checkedConvert('podfile_lock_hash', (v) => v as String?), + canSideload: $checkedConvert('can_sideload', (v) => v as bool), ); return val; }, fieldKeyMap: const { 'releaseId': 'release_id', - 'podfileLockHash': 'podfile_lock_hash' + 'podfileLockHash': 'podfile_lock_hash', + 'canSideload': 'can_sideload' }, ); @@ -43,6 +45,7 @@ Map _$ReleaseArtifactToJson(ReleaseArtifact instance) => 'size': instance.size, 'url': instance.url, 'podfile_lock_hash': instance.podfileLockHash, + 'can_sideload': instance.canSideload, }; const _$ReleasePlatformEnumMap = { diff --git a/packages/shorebird_code_push_protocol/test/src/messages/get_release_artifacts/get_release_artifacts_response_test.dart b/packages/shorebird_code_push_protocol/test/src/messages/get_release_artifacts/get_release_artifacts_response_test.dart index 73cb9a2b..7c83d911 100644 --- a/packages/shorebird_code_push_protocol/test/src/messages/get_release_artifacts/get_release_artifacts_response_test.dart +++ b/packages/shorebird_code_push_protocol/test/src/messages/get_release_artifacts/get_release_artifacts_response_test.dart @@ -15,6 +15,7 @@ void main() { size: 1337, url: 'https://example.com', podfileLockHash: 'podfile-lock-hash', + canSideload: true, ), ], ); diff --git a/packages/shorebird_code_push_protocol/test/src/models/release_artifact_test.dart b/packages/shorebird_code_push_protocol/test/src/models/release_artifact_test.dart index 32eb8e1f..7bcb55ef 100644 --- a/packages/shorebird_code_push_protocol/test/src/models/release_artifact_test.dart +++ b/packages/shorebird_code_push_protocol/test/src/models/release_artifact_test.dart @@ -13,6 +13,7 @@ void main() { size: 42, hash: 'sha256:1234567890', podfileLockHash: 'podfile-lock-hash', + canSideload: true, ); expect( ReleaseArtifact.fromJson(artifact.toJson()).toJson(), @@ -30,11 +31,12 @@ void main() { size: 42, hash: 'sha256:1234567890', podfileLockHash: 'podfile-lock-hash', + canSideload: true, ); final artifactString = artifact.toString(); expect( artifactString, - '{id: 1, release_id: 1, arch: aarch64, platform: android, hash: sha256:1234567890, size: 42, url: https://example.com, podfile_lock_hash: podfile-lock-hash}', + '{id: 1, release_id: 1, arch: aarch64, platform: android, hash: sha256:1234567890, size: 42, url: https://example.com, podfile_lock_hash: podfile-lock-hash, can_sideload: true}', ); }); });