-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use direnv and flutter to enforce and validate a pinned version of flutter. This approach uses `direnv` and `fvm` to setup the environment with the pinned version of the repo. When setup correctly, `direnv` will turn on `fvm`'s pinned flutter version whenever entering the zulip-flutter repository (directory). The `.envrc` does the following: - Use fvm's flutter version if it's available. - Check that whether the flutter binary version matches what was pinned for the repo. - Let users know if there's a mismatch of version so that the user can take action. Other notes: - Power users can: - use their checked out flutter sdk (either their own custom path, configured in .envrc, or the system default) - disable the check if they know what they're doing and want to use a custom flutter installation
- Loading branch information
Showing
6 changed files
with
88 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This file is used by direnv to setup the environment when entering to use fvm's flutter. | ||
|
||
# Comment out the next line if you want to use your system flutter. | ||
PATH_add .fvm/flutter_sdk/bin | ||
|
||
# Check flutter version matches what's in .fvmrc | ||
check_flutter_version() { | ||
local fvm_flutter_version_string=$(cat .fvmrc) | ||
# Fetch string from format `"flutter": "18340ea16c"`` | ||
local fvm_flutter_version=$(echo "$fvm_flutter_version_string" | grep -o '"flutter": "[a-z0-9]*"' | cut -d '"' -f 4) | ||
|
||
local flutter_version_string=$(flutter --version) | ||
# Fetch string from format `Framework • revision 11c034f037` | ||
local flutter_version=$(echo $flutter_version_string | grep -o 'Framework • revision [a-z0-9]*' | cut -d ' ' -f 4) | ||
|
||
if [ "$fvm_flutter_version" != "$flutter_version" ]; then | ||
echo "Flutter version mismatch: $fvm_flutter_version != $flutter_version" | ||
echo "Expected Flutter version: $fvm_flutter_version" | ||
echo "Actual Flutter version: $flutter_version" | ||
echo "Run 'fvm install' to fix this or see README on Setup." | ||
return 1 | ||
fi | ||
} | ||
|
||
# Check flutter version when entering directory | ||
# Comment this out at your own risk if you want to use a custom flutter version. | ||
check_flutter_version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"flutter": "18340ea16c", | ||
"updateVscodeSettings": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,6 @@ app.*.map.json | |
|
||
# Old scaffolding hack | ||
lib/credential_fixture.dart | ||
|
||
# FVM Version Cache | ||
.fvm/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters