Skip to content

Commit

Permalink
chore(shorebird_cli): remove deprecated force flag from release and p…
Browse files Browse the repository at this point in the history
…atch commands
  • Loading branch information
bryanoltman committed Apr 4, 2024
1 parent 6120941 commit 7659245
Show file tree
Hide file tree
Showing 18 changed files with 0 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ The version of the associated release (e.g. "1.0.0"). This should be the version
of the Android app that is using this module.''',
mandatory: true,
)
..addFlag(
'force',
abbr: 'f',
help: PatchCommand.forceHelpText,
negatable: false,
)
..addFlag(
'allow-native-diffs',
help: PatchCommand.allowNativeDiffsHelpText,
Expand Down Expand Up @@ -100,14 +94,6 @@ of the Android app that is using this module.''',
return e.exitCode.code;
}

final force = results['force'] == true;
if (force) {
logger
..err(PatchCommand.forceDeprecationErrorMessage)
..info(PatchCommand.forceDeprecationExplanation);
return ExitCode.usage.code;
}

final dryRun = results['dry-run'] == true;
final allowAssetDiffs = results['allow-asset-diffs'] == true;
final allowNativeDiffs = results['allow-native-diffs'] == true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ The version of the release being patched (e.g. "1.0.0+1").
If this option is not provided, the version number will be determined from the patch artifact.''',
)
..addFlag(
'force',
abbr: 'f',
help: PatchCommand.forceHelpText,
negatable: false,
)
..addFlag(
'allow-native-diffs',
help: PatchCommand.allowNativeDiffsHelpText,
Expand Down Expand Up @@ -108,14 +102,6 @@ If this option is not provided, the version number will be determined from the p
return e.exitCode.code;
}

final force = results['force'] == true;
if (force) {
logger
..err(PatchCommand.forceDeprecationErrorMessage)
..info(PatchCommand.forceDeprecationExplanation);
return ExitCode.usage.code;
}

final allowAssetDiffs = results['allow-asset-diffs'] == true;
final allowNativeDiffs = results['allow-native-diffs'] == true;
final dryRun = results['dry-run'] == true;
Expand Down
12 changes: 0 additions & 12 deletions packages/shorebird_cli/lib/src/commands/patch/patch_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ NOTE: this is ${styleBold.wrap('not')} recommended. Native code changes cannot b
Patch even if asset diffs are detected.
NOTE: this is ${styleBold.wrap('not')} recommended. Asset changes cannot be included in a patch can cause your app to behave unexpectedly.''';

static const forceDeprecationErrorMessage =
'The --force flag has been deprecated';

static final forceDeprecationExplanation =
'If your app has known safe native code or asset changes, you can use '
'the ${cyan.wrap('--allow-native-diffs')} or '
'${cyan.wrap('--allow-asset-diffs')} '
'flags. We do not recommend using these flags unless you are '
'${styleBold.wrap('absolutely sure')} that the changes are safe. '
'Note: the ${cyan.wrap('--force flag')} is not required for use in CI '
'environments.';

@override
String get description =>
'Manage patches for a specific release in Shorebird.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ If this option is not provided, the version number will be determined from the p
help:
'''Export an IPA with these options. See "xcodebuild -h" for available exportOptionsPlist keys.''',
)
..addFlag(
'force',
abbr: 'f',
help: PatchCommand.forceHelpText,
negatable: false,
)
..addFlag(
'allow-native-diffs',
help: PatchCommand.allowNativeDiffsHelpText,
Expand Down Expand Up @@ -135,14 +129,6 @@ https://docs.shorebird.dev/status#link-percentage-ios
return error.exitCode.code;
}

final force = results['force'] == true;
if (force) {
logger
..err(PatchCommand.forceDeprecationErrorMessage)
..info(PatchCommand.forceDeprecationExplanation);
return ExitCode.usage.code;
}

final allowAssetDiffs = results['allow-asset-diffs'] == true;
final allowNativeDiffs = results['allow-native-diffs'] == true;
final dryRun = results['dry-run'] == true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ class PatchIosFrameworkCommand extends ShorebirdCommand
The version of the associated release (e.g. "1.0.0"). This should be the version
of the iOS app that is using this module.''',
)
..addFlag(
'force',
abbr: 'f',
help: PatchCommand.forceHelpText,
negatable: false,
)
..addFlag(
'allow-native-diffs',
help: PatchCommand.allowNativeDiffsHelpText,
Expand Down Expand Up @@ -102,14 +96,6 @@ of the iOS app that is using this module.''',
return e.exitCode.code;
}

final force = results['force'] == true;
if (force) {
logger
..err(PatchCommand.forceDeprecationErrorMessage)
..info(PatchCommand.forceDeprecationExplanation);
return ExitCode.usage.code;
}

final allowAssetDiffs = results['allow-asset-diffs'] == true;
final allowNativeDiffs = results['allow-native-diffs'] == true;
final dryRun = results['dry-run'] == true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:path/path.dart' as p;
import 'package:scoped/scoped.dart';
import 'package:shorebird_cli/src/code_push_client_wrapper.dart';
import 'package:shorebird_cli/src/command.dart';
import 'package:shorebird_cli/src/commands/release/release.dart';
import 'package:shorebird_cli/src/config/config.dart';
import 'package:shorebird_cli/src/logger.dart';
import 'package:shorebird_cli/src/platform.dart';
Expand Down Expand Up @@ -49,12 +48,6 @@ of the Android app that is using this module.''',
help: 'The build number of the aar',
defaultsTo: '1.0',
)
..addFlag(
'force',
abbr: 'f',
help: ReleaseCommand.forceHelpText,
negatable: false,
)
..addOption(
'flutter-version',
help: 'The Flutter version to use when building the app (e.g: 3.16.3).',
Expand Down Expand Up @@ -84,14 +77,6 @@ make smaller updates to your app.
return e.exitCode.code;
}

final force = results['force'] == true;
if (force) {
logger
..err(ReleaseCommand.forceDeprecationErrorMessage)
..info(ReleaseCommand.forceDeprecationExplanation);
return ExitCode.usage.code;
}

if (shorebirdEnv.androidPackageName == null) {
logger.err('Could not find androidPackage in pubspec.yaml.');
return ExitCode.config.code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:path/path.dart' as p;
import 'package:scoped/scoped.dart';
import 'package:shorebird_cli/src/code_push_client_wrapper.dart';
import 'package:shorebird_cli/src/command.dart';
import 'package:shorebird_cli/src/commands/commands.dart';
import 'package:shorebird_cli/src/config/shorebird_yaml.dart';
import 'package:shorebird_cli/src/doctor.dart';
import 'package:shorebird_cli/src/extensions/arg_results.dart';
Expand Down Expand Up @@ -57,12 +56,6 @@ class ReleaseAndroidCommand extends ShorebirdCommand
'To learn more, see: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split',
hide: true,
negatable: false,
)
..addFlag(
'force',
abbr: 'f',
help: ReleaseCommand.forceHelpText,
negatable: false,
);
}

Expand All @@ -88,14 +81,6 @@ make smaller updates to your app.
return e.exitCode.code;
}

final force = results['force'] == true;
if (force) {
logger
..err(ReleaseCommand.forceDeprecationErrorMessage)
..info(ReleaseCommand.forceDeprecationExplanation);
return ExitCode.usage.code;
}

const releasePlatform = ReleasePlatform.android;
final flavor = results.findOption('flavor', argParser: argParser);
final target = results.findOption('target', argParser: argParser);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:mason_logger/mason_logger.dart';
import 'package:shorebird_cli/src/command.dart';
import 'package:shorebird_cli/src/commands/commands.dart';

Expand All @@ -20,14 +19,4 @@ class ReleaseCommand extends ShorebirdCommand {

@override
String get name => 'release';

static const forceHelpText = 'The force flag has been deprecated';

static const forceDeprecationErrorMessage =
'The --force flag has been deprecated';

static final forceDeprecationExplanation = '''
If you believe you have a valid reason to use the --force flag, please reach out to the Shorebird team by filing an issue at ${link(uri: Uri.parse('https://github.com/shorebirdtech/shorebird/issues/new'))}
Note: the --force flag is not required for use in CI environments.''';
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:scoped/scoped.dart';
import 'package:shorebird_cli/src/archive_analysis/archive_analysis.dart';
import 'package:shorebird_cli/src/code_push_client_wrapper.dart';
import 'package:shorebird_cli/src/command.dart';
import 'package:shorebird_cli/src/commands/commands.dart';
import 'package:shorebird_cli/src/config/config.dart';
import 'package:shorebird_cli/src/doctor.dart';
import 'package:shorebird_cli/src/executables/xcodebuild.dart';
Expand Down Expand Up @@ -65,12 +64,6 @@ class ReleaseIosCommand extends ShorebirdCommand
'codesign',
help: 'Codesign the application bundle.',
defaultsTo: true,
)
..addFlag(
'force',
abbr: 'f',
help: ReleaseCommand.forceHelpText,
negatable: false,
);
}

Expand Down Expand Up @@ -100,14 +93,6 @@ make smaller updates to your app.
return e.exitCode.code;
}

final force = results['force'] == true;
if (force) {
logger
..err(ReleaseCommand.forceDeprecationErrorMessage)
..info(ReleaseCommand.forceDeprecationExplanation);
return ExitCode.usage.code;
}

if (results.rest.contains('--obfuscate')) {
// Obfuscated releases break patching, so we don't support them.
// See https://github.com/shorebirdtech/shorebird/issues/1619
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:pub_semver/pub_semver.dart';
import 'package:scoped/scoped.dart';
import 'package:shorebird_cli/src/code_push_client_wrapper.dart';
import 'package:shorebird_cli/src/command.dart';
import 'package:shorebird_cli/src/commands/commands.dart';
import 'package:shorebird_cli/src/config/config.dart';
import 'package:shorebird_cli/src/doctor.dart';
import 'package:shorebird_cli/src/executables/xcodebuild.dart';
Expand Down Expand Up @@ -37,12 +36,6 @@ of the iOS app that is using this module.''',
..addOption(
'flutter-version',
help: 'The Flutter version to use when building the app (e.g: 3.16.3).',
)
..addFlag(
'force',
abbr: 'f',
help: ReleaseCommand.forceHelpText,
negatable: false,
);
}

Expand All @@ -69,14 +62,6 @@ of the iOS app that is using this module.''',
return e.exitCode.code;
}

final force = results['force'] == true;
if (force) {
logger
..err(ReleaseCommand.forceDeprecationErrorMessage)
..info(ReleaseCommand.forceDeprecationExplanation);
return ExitCode.usage.code;
}

const releasePlatform = ReleasePlatform.ios;
final releaseVersion = results['release-version'] as String;
final flutterVersion = results['flutter-version'] as String?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,20 +386,6 @@ void main() {
expect(exitCode, ExitCode.config.code);
});

test('exits with explanation if force flag is used', () async {
when(() => argResults['force']).thenReturn(true);

await expectLater(
runWithOverrides(command.run),
completion(equals(ExitCode.usage.code)),
);

verify(() => logger.err(PatchCommand.forceDeprecationErrorMessage))
.called(1);
verify(() => logger.info(PatchCommand.forceDeprecationExplanation))
.called(1);
});

test('prompts for release when release-version is not specified', () async {
when(() => argResults['release-version']).thenReturn(null);
when(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,20 +418,6 @@ flutter:
).called(1);
});

test('exits with explanation if force flag is used', () async {
when(() => argResults['force']).thenReturn(true);

await expectLater(
runWithOverrides(command.run),
completion(equals(ExitCode.usage.code)),
);

verify(() => logger.err(PatchCommand.forceDeprecationErrorMessage))
.called(1);
verify(() => logger.info(PatchCommand.forceDeprecationExplanation))
.called(1);
});

test('exits with code 70 when building fails', () async {
when(() => flutterBuildProcessResult.exitCode).thenReturn(1);
when(() => flutterBuildProcessResult.stderr).thenReturn('oops');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,20 +557,6 @@ flutter:
).called(1);
});

test('exits with explanation if force flag is used', () async {
when(() => argResults['force']).thenReturn(true);

await expectLater(
runWithOverrides(command.run),
completion(equals(ExitCode.usage.code)),
);

verify(() => logger.err(PatchCommand.forceDeprecationErrorMessage))
.called(1);
verify(() => logger.info(PatchCommand.forceDeprecationExplanation))
.called(1);
});

group('when exportOptionsPlistFromArgs throws exception', () {
setUp(() {
when(() => ios.exportOptionsPlistFromArgs(argResults))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,20 +453,6 @@ flutter:
).called(1);
});

test('exits with explanation if force flag is used', () async {
when(() => argResults['force']).thenReturn(true);

await expectLater(
runWithOverrides(command.run),
completion(equals(ExitCode.usage.code)),
);

verify(() => logger.err(PatchCommand.forceDeprecationErrorMessage))
.called(1);
verify(() => logger.info(PatchCommand.forceDeprecationExplanation))
.called(1);
});

test('prompts for release when release-version is not specified', () async {
when(() => argResults['release-version']).thenReturn(null);
when(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,6 @@ void main() {
).called(1);
});

test('exits with explanation if force flag is used', () async {
when(() => argResults['force']).thenReturn(true);

await expectLater(
runWithOverrides(command.run),
completion(equals(ExitCode.usage.code)),
);

verify(() => logger.err(ReleaseCommand.forceDeprecationErrorMessage))
.called(1);
verify(() => logger.info(ReleaseCommand.forceDeprecationExplanation))
.called(1);
});

test('exits with 78 if no module entry exists in pubspec.yaml', () async {
when(() => shorebirdEnv.androidPackageName).thenReturn(null);

Expand Down
Loading

0 comments on commit 7659245

Please sign in to comment.