diff --git a/packages/shorebird_cli/lib/src/shorebird_validator.dart b/packages/shorebird_cli/lib/src/shorebird_validator.dart index dc7e8216..8f738611 100644 --- a/packages/shorebird_cli/lib/src/shorebird_validator.dart +++ b/packages/shorebird_cli/lib/src/shorebird_validator.dart @@ -175,6 +175,12 @@ To fix, update your pubspec.yaml to include the following: throw ValidationFailedException(); } + + if (validationIssuesContainsWarning(issues)) { + for (final issue in issues) { + logger.warn(issue.message); + } + } } /// Whether any [ValidationIssue]s have a severity of @@ -182,6 +188,11 @@ To fix, update your pubspec.yaml to include the following: bool validationIssuesContainsError(List issues) => issues.any((issue) => issue.severity == ValidationIssueSeverity.error); + /// Whether any [ValidationIssue]s have a severity of + /// [ValidationIssueSeverity.warning]. + bool validationIssuesContainsWarning(List issues) => + issues.any((issue) => issue.severity == ValidationIssueSeverity.warning); + /// Logs a message indicating that validation failed. If any of the issues /// can be automatically fixed, this also prompts the user to run /// `shorebird doctor --fix`. diff --git a/packages/shorebird_cli/lib/src/validators/flavor_validator.dart b/packages/shorebird_cli/lib/src/validators/flavor_validator.dart index 943b7f02..50f618c8 100644 --- a/packages/shorebird_cli/lib/src/validators/flavor_validator.dart +++ b/packages/shorebird_cli/lib/src/validators/flavor_validator.dart @@ -23,7 +23,8 @@ class FlavorValidator extends Validator { @override Future> validate() async { - final projectFlavors = shorebirdEnv.getShorebirdYaml()!.flavors; + final shorebirdYaml = shorebirdEnv.getShorebirdYaml()!; + final projectFlavors = shorebirdYaml.flavors; if (projectFlavors == null && flavorArg != null) { return [ ValidationIssue.error( @@ -35,9 +36,11 @@ class FlavorValidator extends Validator { if (projectFlavors != null && flavorArg == null) { return [ - ValidationIssue.error( + ValidationIssue.warning( message: - '''The project has flavors ${projectFlavors.keys}, but no --flavor argument was provided''', + ''' +The project has flavors ${projectFlavors.keys}, but no --flavor argument was provided. +The default app id ${shorebirdYaml.appId} will be used.''', ), ]; } diff --git a/packages/shorebird_cli/test/src/shorebird_validator_test.dart b/packages/shorebird_cli/test/src/shorebird_validator_test.dart index 322d3425..856a1556 100644 --- a/packages/shorebird_cli/test/src/shorebird_validator_test.dart +++ b/packages/shorebird_cli/test/src/shorebird_validator_test.dart @@ -283,7 +283,7 @@ To fix, update your pubspec.yaml to include the following: group('when platform supports flavors', () { group('when no flavor is specified', () { - test('fails validation', () async { + test('logs warning and fails validation', () async { await expectLater( runWithOverrides( () => shorebirdValidator.validateFlavors( @@ -291,8 +291,15 @@ To fix, update your pubspec.yaml to include the following: releasePlatform: ReleasePlatform.android, ), ), - throwsA(isA()), + completes, ); + verify( + () => logger.warn( + ''' +The project has flavors (flavorA), but no --flavor argument was provided. +The default app id test will be used.''', + ), + ).called(1); }); }); diff --git a/packages/shorebird_cli/test/src/validators/flavor_validator_test.dart b/packages/shorebird_cli/test/src/validators/flavor_validator_test.dart index f23c70c5..f42a2a80 100644 --- a/packages/shorebird_cli/test/src/validators/flavor_validator_test.dart +++ b/packages/shorebird_cli/test/src/validators/flavor_validator_test.dart @@ -119,14 +119,15 @@ void main() { validator = FlavorValidator(flavorArg: null); }); - test('returns validation error', () async { + test('returns validation warning', () async { final issues = await runWithOverrides(validator.validate); expect( issues, equals([ - ValidationIssue.error( - message: - '''The project has flavors (flavorA, flavorB), but no --flavor argument was provided''', + ValidationIssue.warning( + message: ''' +The project has flavors (flavorA, flavorB), but no --flavor argument was provided. +The default app id $appId will be used.''', ), ]), );