diff --git a/packages/shorebird_cli/lib/src/config/shorebird_yaml.dart b/packages/shorebird_cli/lib/src/config/shorebird_yaml.dart index 2e8244da..2b3e7e7b 100644 --- a/packages/shorebird_cli/lib/src/config/shorebird_yaml.dart +++ b/packages/shorebird_cli/lib/src/config/shorebird_yaml.dart @@ -12,7 +12,12 @@ part 'shorebird_yaml.g.dart'; ) class ShorebirdYaml { /// {@macro shorebird_yaml} - const ShorebirdYaml({required this.appId, this.flavors, this.baseUrl}); + const ShorebirdYaml({ + required this.appId, + this.flavors, + this.baseUrl, + this.autoUpdate, + }); factory ShorebirdYaml.fromJson(Map json) => _$ShorebirdYamlFromJson(json); @@ -38,6 +43,9 @@ class ShorebirdYaml { /// The base url used to check for updates. final String? baseUrl; + + /// Whether or not to automatically update the app. + final bool? autoUpdate; } extension AppIdExtension on ShorebirdYaml { diff --git a/packages/shorebird_cli/lib/src/config/shorebird_yaml.g.dart b/packages/shorebird_cli/lib/src/config/shorebird_yaml.g.dart index 74aa5a5e..73d00d07 100644 --- a/packages/shorebird_cli/lib/src/config/shorebird_yaml.g.dart +++ b/packages/shorebird_cli/lib/src/config/shorebird_yaml.g.dart @@ -14,7 +14,7 @@ ShorebirdYaml _$ShorebirdYamlFromJson(Map json) => $checkedCreate( ($checkedConvert) { $checkKeys( json, - allowedKeys: const ['app_id', 'flavors', 'base_url'], + allowedKeys: const ['app_id', 'flavors', 'base_url', 'auto_update'], ); final val = ShorebirdYaml( appId: $checkedConvert('app_id', (v) => v as String), @@ -24,8 +24,13 @@ ShorebirdYaml _$ShorebirdYamlFromJson(Map json) => $checkedCreate( (k, e) => MapEntry(k as String, e as String), )), baseUrl: $checkedConvert('base_url', (v) => v as String?), + autoUpdate: $checkedConvert('auto_update', (v) => v as bool?), ); return val; }, - fieldKeyMap: const {'appId': 'app_id', 'baseUrl': 'base_url'}, + fieldKeyMap: const { + 'appId': 'app_id', + 'baseUrl': 'base_url', + 'autoUpdate': 'auto_update' + }, ); diff --git a/packages/shorebird_cli/test/src/config/shorebird_yaml_test.dart b/packages/shorebird_cli/test/src/config/shorebird_yaml_test.dart index cd1f7922..75bec973 100644 --- a/packages/shorebird_cli/test/src/config/shorebird_yaml_test.dart +++ b/packages/shorebird_cli/test/src/config/shorebird_yaml_test.dart @@ -37,5 +37,34 @@ base_url: https://example.com }); expect(shorebirdYaml.baseUrl, 'https://example.com'); }); + + test('can be deserialized without auto-update', () { + const yaml = ''' +app_id: test_app_id +'''; + final shorebirdYaml = checkedYamlDecode( + yaml, + (m) => ShorebirdYaml.fromJson(m!), + ); + expect(shorebirdYaml.appId, 'test_app_id'); + expect(shorebirdYaml.flavors, isNull); + expect(shorebirdYaml.baseUrl, isNull); + expect(shorebirdYaml.autoUpdate, isNull); + }); + + test('can be deserialized with auto-update', () { + const yaml = ''' +app_id: test_app_id +auto_update: true +'''; + final shorebirdYaml = checkedYamlDecode( + yaml, + (m) => ShorebirdYaml.fromJson(m!), + ); + expect(shorebirdYaml.appId, 'test_app_id'); + expect(shorebirdYaml.flavors, isNull); + expect(shorebirdYaml.baseUrl, isNull); + expect(shorebirdYaml.autoUpdate, isTrue); + }); }); }