From 76e26819e4ea5976d56977eafee4b182bbdbb169 Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Wed, 4 Oct 2023 17:54:37 -0500 Subject: [PATCH] refactor(shorebird_cli): make `shorebird patch` default to production (#1363) --- .../src/commands/patch/patch_android_command.dart | 14 +++++++------- .../lib/src/commands/patch/patch_ios_command.dart | 14 +++++++------- .../commands/patch/patch_android_command_test.dart | 4 ++-- .../src/commands/patch/patch_ios_command_test.dart | 4 ++-- 4 files changed, 18 insertions(+), 18 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 8b017ecc..bfabae27 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 @@ -63,9 +63,9 @@ class PatchAndroidCommand extends ShorebirdCommand help: 'Validate but do not upload the patch.', ) ..addFlag( - 'prod', + 'staging', negatable: false, - help: 'Whether to publish the patch to production', + help: 'Whether to publish the patch to the staging environment.', ); } @@ -94,7 +94,7 @@ class PatchAndroidCommand extends ShorebirdCommand final force = results['force'] == true; final dryRun = results['dry-run'] == true; - final isProd = results['prod'] == true; + final isStaging = results['staging'] == true; if (force && dryRun) { logger.err('Cannot use both --force and --dry-run.'); @@ -287,10 +287,10 @@ Current Flutter Revision: $originalFlutterRevision if (flavor != null) '🍧 Flavor: ${lightCyan.wrap(flavor)}', 'đŸ“Ļ Release Version: ${lightCyan.wrap(releaseVersion)}', '''đŸ•šī¸ Platform: ${lightCyan.wrap(platform.name)} ${lightCyan.wrap('[${archMetadata.join(', ')}]')}''', - if (isProd) - 'đŸŸĸ Track: ${lightCyan.wrap('Production')}' + if (isStaging) + '🟠 Track: ${lightCyan.wrap('Staging')}' else - '🟠 Track: ${lightCyan.wrap('Staging')}', + 'đŸŸĸ Track: ${lightCyan.wrap('Production')}', ]; logger.info( @@ -316,7 +316,7 @@ ${summary.join('\n')} appId: appId, releaseId: release.id, platform: platform, - track: isProd ? DeploymentTrack.production : DeploymentTrack.staging, + track: isStaging ? DeploymentTrack.staging : DeploymentTrack.production, patchArtifactBundles: patchArtifactBundles, ); 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 db10af00..9a6a74cf 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 @@ -61,9 +61,9 @@ class PatchIosCommand extends ShorebirdCommand help: 'Validate but do not upload the patch.', ) ..addFlag( - 'prod', + 'staging', negatable: false, - help: 'Whether to publish the patch to production', + help: 'Whether to publish the patch to the staging environment.', ); } @@ -94,7 +94,7 @@ class PatchIosCommand extends ShorebirdCommand final force = results['force'] == true; final dryRun = results['dry-run'] == true; - final isProd = results['prod'] == true; + final isStaging = results['staging'] == true; if (force && dryRun) { logger.err('Cannot use both --force and --dry-run.'); @@ -219,10 +219,10 @@ Current Flutter Revision: $originalFlutterRevision if (flavor != null) '🍧 Flavor: ${lightCyan.wrap(flavor)}', 'đŸ“Ļ Release Version: ${lightCyan.wrap(releaseVersion)}', '''đŸ•šī¸ Platform: ${lightCyan.wrap(releasePlatform.name)} ${lightCyan.wrap('[$arch (${formatBytes(aotFileSize)})]')}''', - if (isProd) - 'đŸŸĸ Track: ${lightCyan.wrap('Production')}' + if (isStaging) + '🟠 Track: ${lightCyan.wrap('Staging')}' else - '🟠 Track: ${lightCyan.wrap('Staging')}', + 'đŸŸĸ Track: ${lightCyan.wrap('Production')}', ]; logger.info( @@ -248,7 +248,7 @@ ${summary.join('\n')} appId: appId, releaseId: release.id, platform: releasePlatform, - track: isProd ? DeploymentTrack.production : DeploymentTrack.staging, + track: isStaging ? DeploymentTrack.staging : DeploymentTrack.production, patchArtifactBundles: { Arch.arm64: PatchArtifactBundle( arch: arch, 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 0385b1e2..fb673ce9 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 @@ -267,7 +267,7 @@ flutter: ).thenReturn(false); when(() => argResults.rest).thenReturn([]); when(() => argResults['arch']).thenReturn(arch); - when(() => argResults['prod']).thenReturn(true); + when(() => argResults['staging']).thenReturn(false); when(() => argResults['dry-run']).thenReturn(false); when(() => argResults['force']).thenReturn(false); when(() => argResults['release-version']).thenReturn(release.version); @@ -827,7 +827,7 @@ Please re-run the release command for this version or create a new release.'''), }); test('succeeds when patch is successful (staging)', () async { - when(() => argResults['prod']).thenReturn(false); + when(() => argResults['staging']).thenReturn(true); final tempDir = setUpTempDir(); setUpTempArtifacts(tempDir); final exitCode = await IOOverrides.runZoned( 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 44f4ecdb..d5268fba 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 @@ -256,7 +256,7 @@ flutter: when(() => argResults['force']).thenReturn(false); when(() => argResults['release-version']).thenReturn(release.version); when(() => argResults['codesign']).thenReturn(true); - when(() => argResults['prod']).thenReturn(true); + when(() => argResults['staging']).thenReturn(false); when(() => argResults.rest).thenReturn([]); when(() => auth.isAuthenticated).thenReturn(true); when(() => auth.client).thenReturn(httpClient); @@ -890,7 +890,7 @@ Please re-run the release command for this version or create a new release.'''), }); test('succeeds when patch is successful (staging)', () async { - when(() => argResults['prod']).thenReturn(false); + when(() => argResults['staging']).thenReturn(true); final tempDir = setUpTempDir(); setUpTempArtifacts(tempDir); final exitCode = await IOOverrides.runZoned(