-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_flutter
More file actions
158 lines (131 loc) · 3.66 KB
/
setup_flutter
File metadata and controls
158 lines (131 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
check_and_install_homebrew() {
if ! command -v brew &>/dev/null; then
echo "Installing Homebrew..."
install_homebrew
if [ "$(uname)" == "Darwin" ]; then
setup_macos_path
if ! command brew -v &>/dev/null; then
echo "Homebrew not found. Please check the Homebrew installation and PATH setup."
exit 1
fi
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
setup_linux_path
if ! command -v snap &>/dev/null; then
install_snap
fi
fi
else
echo "✅ Homebrew Installed."
fi
}
install_homebrew() {
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
}
setup_macos_path() {
if [ ! -f ~/.zshrc ]; then
touch ~/.zshrc
fi
if ! grep -q 'eval "$(/opt/homebrew/bin/brew shellenv)"' ~/.zprofile; then
(
echo
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"'
) >>~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
}
setup_linux_path() {
if ! grep -q 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' ~/.bashrc && ! grep -q 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' ~/.zshrc; then
if [ -n "$ZSH_VERSION" ]; then
echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' >>~/.zshrc
elif [ -n "$BASH_VERSION" ]; then
echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' >>~/.bashrc
fi
fi
}
install_snap() {
sudo apt-get update
sudo apt-get install -y snapd
}
install_android_studio() {
if [ "$(uname)" == "Darwin" ]; then
if [ ! -d "/Applications/Android Studio.app" ]; then
brew list --cask android-studio || brew install --cask android-studio
else
echo "✅ Android Studio is already installed."
return 0
fi
else
if [ ! -d "/snap/bin/android-studio" ]; then
sudo snap install android-studio --classic
else
echo "✅ Android Studio is already installed."
return 0
fi
fi
echo "✅ Android Studio Installed."
}
install_vs_code() {
if [ "$(uname)" == "Darwin" ]; then
if [ ! -d "/Applications/Visual Studio Code.app" ]; then
brew list --cask visual-studio-code || brew install --cask visual-studio-code
else
echo "✅ Visual studio code is already installed."
return 0
fi
else
if [ ! -d "/snap/bin/code" ]; then
sudo snap install --classic code
else
echo "✅ Visual studio code is already installed."
return 0
fi
fi
echo "✅ Visual studio code installed."
}
install_fvm() {
install_fvm_if_not_installed
configure_shell
source $SHELL_CONFIG
fvm list | grep 'stable' || fvm install stable
fvm global stable
export PATH="$HOME/fvm/default/bin:$PATH"
flutter doctor
}
install_fvm_if_not_installed() {
if ! brew list fvm &>/dev/null; then
brew tap leoafarias/fvm
brew install fvm
echo "✅ FVM Installed."
else
echo "✅ FVM already Installed."
fi
}
configure_shell() {
if [ "$(uname)" == "Darwin" ]; then
SHELL_CONFIG=~/.zshrc
else
SHELL_CONFIG=~/.bashrc
fi
if ! grep -q 'export PATH="$PATH":"$HOME/.pub-cache/bin"' $SHELL_CONFIG; then
echo 'export PATH="$PATH":"$HOME/.pub-cache/bin"' >>$SHELL_CONFIG
echo "✅ Added flutter executables to path."
fi
if ! grep -q 'export PATH="$PATH":"$HOME/fvm/default/bin"' $SHELL_CONFIG; then
echo 'export PATH="$PATH":"$HOME/fvm/default/bin"' >> $SHELL_CONFIG
echo "✅ Added flutter to path."
fi
}
reload_shell() {
if [ -n "$ZSH_VERSION" ]; then
source ~/.zshrc
elif [ -n "$BASH_VERSION" ]; then
source ~/.bashrc
fi
echo "✅ Shell reloaded."
}
check_and_install_homebrew
reload_shell
install_android_studio
install_vs_code
install_fvm