From d3d0f7b71e5f0b90a00a2ee6ec86dda511790a7f Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Wed, 21 Feb 2024 10:57:13 -0500 Subject: [PATCH] Implemented better checks for falvors --- .../documentation/guides/project-flavors.md | 18 +++++------------- lib/src/commands/use_command.dart | 12 +++++++++++- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/pages/documentation/guides/project-flavors.md b/docs/pages/documentation/guides/project-flavors.md index bff758f2..9c40937d 100644 --- a/docs/pages/documentation/guides/project-flavors.md +++ b/docs/pages/documentation/guides/project-flavors.md @@ -11,11 +11,11 @@ It allows you to create the following configuration for your project. ```json { - "flutterSdkVersion": "stable", + "flutter": "stable", "flavors": { - "dev": "beta", - "staging": "2.0.3", - "production": "1.22.6" + "development": "stable", + "staging": "3.16.9", + "production": "3.10.3" } } ``` @@ -35,15 +35,7 @@ This will pin `version` to `flavor_name` Will get the version configured for the flavor and set as the project version. ```bash -fvm flavor {flavor_name} +fvm use {flavor_name} ``` -## View flavors -To list all configured flavors: - -```bash -fvm flavor -``` - -[Learn more about Flutter flavors](https://flutter.dev/docs/deployment/flavors) diff --git a/lib/src/commands/use_command.dart b/lib/src/commands/use_command.dart index cccc4afe..aaf7cd43 100644 --- a/lib/src/commands/use_command.dart +++ b/lib/src/commands/use_command.dart @@ -105,11 +105,21 @@ class UseCommand extends BaseCommand { } logger.info( - 'Using Flutter SDK from "$flavorOption" which is "$flavorVersion"', + 'Using Flutter SDK from flavor: "$version" which is "$flavorVersion"', ); version = flavorVersion; } + if (flavorOption != null) { + // check if flavor option is not a channel name or semver + if (isFlutterChannel(flavorOption)) { + throw UsageException( + 'Cannot use a channel as a flavor, use a different name for flavor', + usage, + ); + } + } + final cacheVersion = await ensureCacheWorkflow(version); /// Run use workflow