@@ -6,29 +6,98 @@ echo "=== Flutter Structurizr Development Environment Setup ==="
66
77# 1. Check for Flutter installation
88if ! command -v flutter & > /dev/null; then
9- echo " Flutter is not installed. Please install Flutter SDK 3.10.0+ and ensure it's in your PATH."
9+ echo " Flutter is not installed. Let's help you install it."
10+ echo " "
11+ echo " Choose your operating system:"
12+ echo " 1. Linux (Ubuntu/Debian)"
13+ echo " 2. macOS"
14+ echo " 3. Other"
15+ read -p " Enter your choice (1-3): " os_choice
16+
17+ case $os_choice in
18+ 1)
19+ echo " Installing Flutter on Linux..."
20+ echo " "
21+ echo " Option 1: Using snap (recommended):"
22+ echo " sudo snap install flutter --classic"
23+ echo " "
24+ echo " Option 2: Manual installation:"
25+ echo " 1. Download Flutter SDK from: https://flutter.dev/docs/get-started/install/linux"
26+ echo " 2. Extract to a directory (e.g., ~/development/flutter)"
27+ echo " 3. Add Flutter to your PATH:"
28+ echo " export PATH=\"\$ PATH:~/development/flutter/bin\" "
29+ echo " 4. Add the above line to your ~/.bashrc or ~/.zshrc"
30+ echo " "
31+ echo " After installation, run 'flutter doctor' to verify setup."
32+ ;;
33+ 2)
34+ echo " Installing Flutter on macOS..."
35+ echo " "
36+ echo " Option 1: Using Homebrew:"
37+ echo " brew install flutter"
38+ echo " "
39+ echo " Option 2: Manual installation:"
40+ echo " 1. Download Flutter SDK from: https://flutter.dev/docs/get-started/install/macos"
41+ echo " 2. Extract to a directory (e.g., ~/development/flutter)"
42+ echo " 3. Add Flutter to your PATH:"
43+ echo " export PATH=\"\$ PATH:~/development/flutter/bin\" "
44+ echo " 4. Add the above line to your ~/.zshrc or ~/.bash_profile"
45+ echo " "
46+ echo " After installation, run 'flutter doctor' to verify setup."
47+ ;;
48+ 3)
49+ echo " For other operating systems, please visit:"
50+ echo " https://flutter.dev/docs/get-started/install"
51+ ;;
52+ esac
53+
54+ echo " "
55+ echo " Please install Flutter and then run this script again."
1056 exit 1
1157fi
1258
13- # 2. Check for Dart installation (should be included with Flutter)
59+ # 2. Check Flutter version
60+ FLUTTER_VERSION=$( flutter --version | grep -o ' Flutter [0-9]\+\.[0-9]\+\.[0-9]\+' | awk ' {print $2}' )
61+ MIN_VERSION=" 3.10.0"
62+
63+ version_gt () {
64+ test " $( printf ' %s\n' " $@ " | sort -V | head -n 1) " ! = " $1 " ;
65+ }
66+
67+ if version_gt " $MIN_VERSION " " $FLUTTER_VERSION " ; then
68+ echo " Flutter version $FLUTTER_VERSION is installed, but version $MIN_VERSION or higher is required."
69+ echo " Please upgrade Flutter using: flutter upgrade"
70+ exit 1
71+ fi
72+
73+ echo " Flutter $FLUTTER_VERSION is installed ✓"
74+
75+ # 3. Run flutter doctor to check for issues
76+ echo " Checking Flutter environment..."
77+ flutter doctor
78+
79+ # 4. Check for Dart installation (should be included with Flutter)
1480if ! command -v dart & > /dev/null; then
15- echo " Dart is not installed. Please install Dart SDK (comes with Flutter) and ensure it's in your PATH."
81+ echo " Dart is not installed. It should come with Flutter."
82+ echo " Please ensure Flutter is properly installed and in your PATH."
1683 exit 1
1784fi
1885
19- # 3. Install Flutter dependencies
20- echo " Running flutter pub get..."
86+ echo " Dart $( dart --version) is installed ✓"
87+
88+ # 5. Install Flutter dependencies
89+ echo " Installing Flutter dependencies..."
2190flutter pub get
2291
23- # 4 . Install dependencies for demo_app, example, and test_app if present
92+ # 6 . Install dependencies for demo_app, example, and test_app if present
2493for dir in demo_app example test_app; do
2594 if [ -d " $dir " ]; then
26- echo " Running flutter pub get in $dir /..."
95+ echo " Installing dependencies in $dir /..."
2796 (cd " $dir " && flutter pub get)
2897 fi
2998done
3099
31- # 5 . Install any additional tools (e.g., lcov for coverage reports)
100+ # 7 . Install any additional tools (e.g., lcov for coverage reports)
32101if ! command -v lcov & > /dev/null; then
33102 echo " lcov not found. Installing lcov (for coverage reports)..."
34103 if [[ " $OSTYPE " == " linux-gnu" * ]]; then
@@ -40,16 +109,24 @@ if ! command -v lcov &> /dev/null; then
40109 fi
41110fi
42111
43- # 6 . Run code generation (build_runner)
112+ # 8 . Run code generation (build_runner)
44113echo " Running code generation (build_runner)..."
45114flutter pub run build_runner build --delete-conflicting-outputs
46115
47- # 7. (Optional) Run analyzer and tests to verify setup
116+ # 9. Run analyzer and tests to verify setup
48117echo " Running flutter analyze..."
49118flutter analyze
50119
51120echo " Running flutter test (smoke test)..."
52121flutter test
53122
123+ echo " "
54124echo " === Setup complete! ==="
55- echo " You can now start developing or running the application."
125+ echo " Your Flutter Structurizr development environment is ready."
126+ echo " You can now start developing or running the application."
127+ echo " "
128+ echo " Quick start commands:"
129+ echo " flutter run # Run the application"
130+ echo " flutter test # Run all tests"
131+ echo " flutter analyze # Analyze code"
132+ echo " flutter build # Build the application"
0 commit comments