From 39b34dab5ae04078042ddad7f3ad30fb0c159f13 Mon Sep 17 00:00:00 2001 From: Bryan Oltman Date: Mon, 12 Jun 2023 10:48:24 -0400 Subject: [PATCH] chore(shorebird_cli): print detected version number in patch commands (#626) --- .../src/commands/patch/patch_android_command.dart | 4 +++- .../lib/src/commands/patch/patch_ios_command.dart | 4 +++- .../commands/patch/patch_android_command_test.dart | 13 +++++++++++++ .../src/commands/patch/patch_ios_command_test.dart | 13 +++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/shorebird_cli/lib/src/commands/patch/patch_android_command.dart b/packages/shorebird_cli/lib/src/commands/patch/patch_android_command.dart index 12392cb4..4d6f7a4c 100644 --- a/packages/shorebird_cli/lib/src/commands/patch/patch_android_command.dart +++ b/packages/shorebird_cli/lib/src/commands/patch/patch_android_command.dart @@ -143,7 +143,9 @@ class PatchAndroidCommand extends ShorebirdCommand try { releaseVersion = releaseVersionArg ?? await extractReleaseVersionFromAppBundle(bundlePath); - detectReleaseVersionProgress.complete(); + detectReleaseVersionProgress.complete( + 'Detected release version $releaseVersion', + ); } catch (error) { detectReleaseVersionProgress.fail('$error'); return ExitCode.software.code; diff --git a/packages/shorebird_cli/lib/src/commands/patch/patch_ios_command.dart b/packages/shorebird_cli/lib/src/commands/patch/patch_ios_command.dart index 36e238a3..c4b15659 100644 --- a/packages/shorebird_cli/lib/src/commands/patch/patch_ios_command.dart +++ b/packages/shorebird_cli/lib/src/commands/patch/patch_ios_command.dart @@ -140,7 +140,9 @@ class PatchIosCommand extends ShorebirdCommand ), ); releaseVersion = ipa.versionNumber; - detectReleaseVersionProgress.complete(); + detectReleaseVersionProgress.complete( + 'Detected release version $releaseVersion', + ); } catch (error) { detectReleaseVersionProgress.fail( 'Failed to determine release version: $error', diff --git a/packages/shorebird_cli/test/src/commands/patch/patch_android_command_test.dart b/packages/shorebird_cli/test/src/commands/patch/patch_android_command_test.dart index e9da3f4c..63105d90 100644 --- a/packages/shorebird_cli/test/src/commands/patch/patch_android_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/patch_android_command_test.dart @@ -483,6 +483,19 @@ https://github.com/shorebirdtech/shorebird/issues/472 ).called(1); }); + test('prints release version when detected', () async { + final tempDir = setUpTempDir(); + setUpTempArtifacts(tempDir); + final exitCode = await IOOverrides.runZoned( + () => runWithOverrides(command.run), + getCurrentDirectory: () => tempDir, + ); + + expect(exitCode, equals(ExitCode.success.code)); + verify(() => progress.complete('Detected release version 1.2.3+1')) + .called(1); + }); + test('throws error when release artifact does not exist.', () async { when(() => httpClient.send(any())).thenAnswer( (_) async => http.StreamedResponse( diff --git a/packages/shorebird_cli/test/src/commands/patch/patch_ios_command_test.dart b/packages/shorebird_cli/test/src/commands/patch/patch_ios_command_test.dart index 661cdc92..3e711a8d 100644 --- a/packages/shorebird_cli/test/src/commands/patch/patch_ios_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/patch_ios_command_test.dart @@ -344,6 +344,19 @@ https://github.com/shorebirdtech/shorebird/issues/472 ).called(1); }); + test('prints release version when detected', () async { + final tempDir = setUpTempDir(); + setUpTempArtifacts(tempDir); + final exitCode = await IOOverrides.runZoned( + () => runWithOverrides(command.run), + getCurrentDirectory: () => tempDir, + ); + + expect(exitCode, equals(ExitCode.success.code)); + verify(() => progress.complete('Detected release version 1.2.3+1')) + .called(1); + }); + test('throws error when creating aot snapshot fails', () async { const error = 'oops something went wrong'; when(() => aotBuildProcessResult.exitCode).thenReturn(1);