feat(shorebird_code_push_protocol): Adding can sideload to artifacts (#2269)

This commit is contained in:
Erick
2024-06-19 15:23:32 -03:00
committed by GitHub
parent 379d050e5b
commit 6d9a5e981b
11 changed files with 26 additions and 5 deletions
@@ -140,6 +140,7 @@ void main() {
size: 4,
url: 'url',
podfileLockHash: 'podfile-lock-hash',
canSideload: true,
);
late CodePushClient codePushClient;
@@ -381,6 +381,7 @@ void main() {
size: 42,
url: 'https://example.com',
podfileLockHash: null,
canSideload: true,
);
late File releaseArtifactFile;
@@ -403,6 +403,7 @@ Looked in:
size: 42,
url: 'https://example.com',
podfileLockHash: null,
canSideload: true,
);
setUp(() {
@@ -459,6 +459,7 @@ void main() {
size: 42,
url: 'https://example.com',
podfileLockHash: null,
canSideload: true,
);
late File releaseArtifactFile;
@@ -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;
@@ -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;
@@ -1728,6 +1728,7 @@ void main() {
hash: '#',
size: 42,
podfileLockHash: null,
canSideload: true,
),
];
@@ -19,6 +19,7 @@ class ReleaseArtifact {
required this.size,
required this.url,
required this.podfileLockHash,
required this.canSideload,
});
/// Converts a Map<String, dynamic> 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();
}
@@ -14,22 +14,24 @@ ReleaseArtifact _$ReleaseArtifactFromJson(Map<String, dynamic> 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<String, dynamic> _$ReleaseArtifactToJson(ReleaseArtifact instance) =>
'size': instance.size,
'url': instance.url,
'podfile_lock_hash': instance.podfileLockHash,
'can_sideload': instance.canSideload,
};
const _$ReleasePlatformEnumMap = {
@@ -15,6 +15,7 @@ void main() {
size: 1337,
url: 'https://example.com',
podfileLockHash: 'podfile-lock-hash',
canSideload: true,
),
],
);
@@ -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}',
);
});
});