From 048ec1b7ba825f9c0b062cd8f98db10b7b2e838d Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Thu, 16 Jan 2025 16:04:22 -0600 Subject: [PATCH] chore(shorebird_cli): improve error message when Flutter project does not support macOS (#2777) --- .../validators/macos_network_entitlement_validator.dart | 9 +++++++-- .../macos_network_entitlement_validator_test.dart | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/shorebird_cli/lib/src/validators/macos_network_entitlement_validator.dart b/packages/shorebird_cli/lib/src/validators/macos_network_entitlement_validator.dart index 2831fc3b6..09467a5cf 100644 --- a/packages/shorebird_cli/lib/src/validators/macos_network_entitlement_validator.dart +++ b/packages/shorebird_cli/lib/src/validators/macos_network_entitlement_validator.dart @@ -48,8 +48,13 @@ class MacosNetworkEntitlementValidator extends Validator { String get description => 'macOS app has Outgoing Connections entitlement'; @override - bool canRunInCurrentContext() => - _macosDirectory != null && _macosDirectory!.existsSync(); + bool canRunInCurrentContext() => _macosDirectory?.existsSync() ?? false; + + @override + String? get incorrectContextMessage => ''' +The ${_macosDirectory?.path ?? 'macos'} directory does not exist. + +The command you are running must be run within a Flutter app project that supports the macOS platform.'''; @override Future> validate() async { diff --git a/packages/shorebird_cli/test/src/validators/macos_network_entitlement_validator_test.dart b/packages/shorebird_cli/test/src/validators/macos_network_entitlement_validator_test.dart index 7468bec91..b4ce6f838 100644 --- a/packages/shorebird_cli/test/src/validators/macos_network_entitlement_validator_test.dart +++ b/packages/shorebird_cli/test/src/validators/macos_network_entitlement_validator_test.dart @@ -100,6 +100,12 @@ void main() { runWithOverrides(() => validator.canRunInCurrentContext()), isFalse, ); + expect( + runWithOverrides(() => validator.incorrectContextMessage), + contains( + '''The command you are running must be run within a Flutter app project that supports the macOS platform.''', + ), + ); }); }); });