chore(shorebird_cli): don't use FlutterVersionValidator for all commands (#378)
This commit is contained in:
@@ -27,7 +27,6 @@ typedef StartProcess = Future<Process> Function(
|
||||
});
|
||||
|
||||
List<Validator> _defaultValidators() => [
|
||||
ShorebirdFlutterValidator(),
|
||||
AndroidInternetPermissionValidator(),
|
||||
];
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:shorebird_cli/src/shorebird_environment.dart';
|
||||
import 'package:shorebird_cli/src/shorebird_process.dart';
|
||||
import 'package:shorebird_cli/src/validators/validators.dart';
|
||||
import 'package:version/version.dart';
|
||||
|
||||
class FlutterValidationException implements Exception {
|
||||
const FlutterValidationException(this.message);
|
||||
@@ -58,9 +59,9 @@ class ShorebirdFlutterValidator extends Validator {
|
||||
);
|
||||
}
|
||||
|
||||
String? shorebirdFlutterVersion;
|
||||
String? shorebirdFlutterVersionString;
|
||||
try {
|
||||
shorebirdFlutterVersion = await _shorebirdFlutterVersion(process);
|
||||
shorebirdFlutterVersionString = await _shorebirdFlutterVersion(process);
|
||||
} catch (error) {
|
||||
issues.add(
|
||||
ValidationIssue(
|
||||
@@ -70,9 +71,9 @@ class ShorebirdFlutterValidator extends Validator {
|
||||
);
|
||||
}
|
||||
|
||||
String? pathFlutterVersion;
|
||||
String? pathFlutterVersionString;
|
||||
try {
|
||||
pathFlutterVersion = await _pathFlutterVersion(process);
|
||||
pathFlutterVersionString = await _pathFlutterVersion(process);
|
||||
} catch (error) {
|
||||
issues.add(
|
||||
ValidationIssue(
|
||||
@@ -82,21 +83,26 @@ class ShorebirdFlutterValidator extends Validator {
|
||||
);
|
||||
}
|
||||
|
||||
if (shorebirdFlutterVersion != null &&
|
||||
pathFlutterVersion != null &&
|
||||
shorebirdFlutterVersion != pathFlutterVersion) {
|
||||
final message = '''
|
||||
if (shorebirdFlutterVersionString != null &&
|
||||
pathFlutterVersionString != null) {
|
||||
final shorebirdFlutterVersion =
|
||||
Version.parse(shorebirdFlutterVersionString);
|
||||
final pathFlutterVersion = Version.parse(pathFlutterVersionString);
|
||||
if (shorebirdFlutterVersion.major != pathFlutterVersion.major ||
|
||||
shorebirdFlutterVersion.minor != pathFlutterVersion.minor) {
|
||||
final message = '''
|
||||
The version of Flutter that Shorebird includes and the Flutter on your path are different.
|
||||
\tShorebird Flutter: $shorebirdFlutterVersion
|
||||
\tSystem Flutter: $pathFlutterVersion
|
||||
\tShorebird Flutter: $shorebirdFlutterVersionString
|
||||
\tSystem Flutter: $pathFlutterVersionString
|
||||
This can cause unexpected behavior if you are switching between the tools and the version gap is wide. If you have any trouble, please let us know on Shorebird discord.''';
|
||||
|
||||
issues.add(
|
||||
ValidationIssue(
|
||||
severity: ValidationIssueSeverity.warning,
|
||||
message: message,
|
||||
),
|
||||
);
|
||||
issues.add(
|
||||
ValidationIssue(
|
||||
severity: ValidationIssueSeverity.warning,
|
||||
message: message,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final flutterStorageEnvironmentValue =
|
||||
|
||||
@@ -28,6 +28,7 @@ dependencies:
|
||||
pubspec_parse: ^1.2.2
|
||||
shorebird_code_push_client:
|
||||
path: ../shorebird_code_push_client
|
||||
version: ^3.0.2
|
||||
xml: ^6.2.2
|
||||
yaml: ^3.1.1
|
||||
yaml_edit: ^2.1.0
|
||||
|
||||
@@ -160,8 +160,8 @@ Tools • Dart 2.19.6 • DevTools 2.20.1
|
||||
});
|
||||
|
||||
test(
|
||||
'warns when path flutter version does not match shorebird flutter'
|
||||
' version',
|
||||
'does not warn if flutter version and shorebird flutter version have same'
|
||||
' major and minor but different patch versions',
|
||||
() async {
|
||||
when(() => pathFlutterVersionProcessResult.stdout).thenReturn(
|
||||
pathFlutterVersionMessage.replaceAll('3.7.9', '3.7.10'),
|
||||
@@ -169,6 +169,20 @@ Tools • Dart 2.19.6 • DevTools 2.20.1
|
||||
|
||||
final results = await validator.validate(shorebirdProcess);
|
||||
|
||||
expect(results, isEmpty);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'warns when path flutter version has different major or minor version '
|
||||
'than shorebird flutter',
|
||||
() async {
|
||||
when(() => pathFlutterVersionProcessResult.stdout).thenReturn(
|
||||
pathFlutterVersionMessage.replaceAll('3.7.9', '3.8.9'),
|
||||
);
|
||||
|
||||
final results = await validator.validate(shorebirdProcess);
|
||||
|
||||
expect(results, hasLength(1));
|
||||
expect(results.first.severity, ValidationIssueSeverity.warning);
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user