From b7c27f6021027c62294a0c1b2cbd940a956fdc22 Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Fri, 14 Mar 2025 12:16:14 -0500 Subject: [PATCH] feat(shorebird_cli): default `--flutter-version` to `latest` (#2971) --- .../src/commands/release/release_command.dart | 21 ++++++++++--------- .../release/release_command_test.dart | 1 + 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/shorebird_cli/lib/src/commands/release/release_command.dart b/packages/shorebird_cli/lib/src/commands/release/release_command.dart index a7c9fe96..b0ffd0a8 100644 --- a/packages/shorebird_cli/lib/src/commands/release/release_command.dart +++ b/packages/shorebird_cli/lib/src/commands/release/release_command.dart @@ -90,8 +90,11 @@ class ReleaseCommand extends ShorebirdCommand { ) ..addOption( 'flutter-version', - help: - '''The Flutter version to use when building the app (e.g: 3.16.3). This option also accepts Flutter commit hashes.''', + defaultsTo: 'latest', + help: ''' +The Flutter version to use when building the app (e.g: 3.16.3). +This option also accepts Flutter commit hashes (e.g. 611a4066f1). +Defaults to "latest" which builds using the latest stable Flutter version.''', ) ..addOption( 'artifact', @@ -221,16 +224,16 @@ of the iOS app that is using this module. (aar and ios-framework only)''', String get appId => shorebirdEnv.getShorebirdYaml()!.getAppId(flavor: flavor); /// The build flavor, if provided. - late String? flavor = results.findOption('flavor', argParser: argParser); + String? get flavor => results.findOption('flavor', argParser: argParser); /// The target script, if provided. - late String? target = results.findOption('target', argParser: argParser); + String? get target => results.findOption('target', argParser: argParser); /// Whether --no-confirm was passed. bool get noConfirm => results['no-confirm'] == true; - /// The flutter version specified by the user, if any. - late String? flutterVersionArg = results['flutter-version'] as String?; + /// The flutter version specified. + String get flutterVersionArg => results['flutter-version'] as String; /// The workflow to create a new release for a Shorebird app. /// @@ -346,14 +349,12 @@ of the iOS app that is using this module. (aar and ios-framework only)''', /// [shorebirdEnv]. Will exit with [ExitCode.software] if the version /// specified by the user is not found/supported. Future resolveTargetFlutterRevision() async { - if (flutterVersionArg == null) { - return shorebirdEnv.flutterRevision; - } + if (flutterVersionArg == 'latest') return shorebirdEnv.flutterRevision; final String? revision; try { revision = await shorebirdFlutter.resolveFlutterRevision( - flutterVersionArg!, + flutterVersionArg, ); } on Exception catch (error) { logger.err(''' diff --git a/packages/shorebird_cli/test/src/commands/release/release_command_test.dart b/packages/shorebird_cli/test/src/commands/release/release_command_test.dart index 7b5cbc51..017d60e3 100644 --- a/packages/shorebird_cli/test/src/commands/release/release_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/release/release_command_test.dart @@ -102,6 +102,7 @@ void main() { when(() => argResults['dry-run']).thenReturn(false); when(() => argResults['platforms']).thenReturn(['android']); + when(() => argResults['flutter-version']).thenReturn('latest'); when(() => argResults.wasParsed(any())).thenReturn(true); when(cache.updateAll).thenAnswer((_) async => {});