13
13
14
14
$silentMode = false
15
15
$answer = ""
16
- ARGV . each do |a |
16
+ ARGV . each do |a |
17
17
if a == "--silentMode"
18
18
$silentMode = true
19
19
$answer = "a"
40
40
system ( 'xcodebuild -license' )
41
41
end
42
42
43
- $tasks = [ "Homebrew" , "Google Chrome" , " Open JDK 8", "Android SDK" , "Android emulator system image" , "HAXM (Hardware accelerated Android emulator)" , "Android emulator" , "CocoaPods" , "CocoaPods setup" , "pip" , "six" , "xcodeproj" ]
43
+ $tasks = [ "Homebrew" , "Open JDK 8" , "Android SDK" , "Android emulator system image" , "HAXM (Hardware accelerated Android emulator)" , "Android emulator" , "CocoaPods" , "CocoaPods setup" , "pip" , "six" , "xcodeproj" ]
44
44
$count = 1
45
45
puts "This setup script will request to install the following on your machine:"
46
46
$tasks. each_with_index do |st , index |
47
- puts "#{ index + 1 } . #{ st } "
47
+ puts "#{ index + 1 } . #{ st } "
48
48
end
49
49
50
50
# Help with installing other dependencies
@@ -72,7 +72,7 @@ def execute(script, warning_message, run_as_root = false)
72
72
def install ( program_name , message , script , run_as_root = false , show_all_option = true )
73
73
puts "Step #{ $count} of #{ $tasks. length } :"
74
74
$count += 1
75
-
75
+
76
76
if $answer != "a"
77
77
puts "Allow the script to install " + program_name + "?"
78
78
if show_all_option
@@ -107,33 +107,37 @@ def install_environment_variable(name, value)
107
107
end
108
108
109
109
# Actually installing all other dependencies
110
- if $silentMode
111
- install ( "Homebrew" , "Installing Homebrew..." , 'ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" > /dev/null 2>&1 </dev/null' , false , false )
112
- else
113
- install ( "Homebrew" , "Installing Homebrew..." , 'ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"</dev/null' , false , false )
110
+ if !( execute ( "which brew > /dev/null" , "Homebrew is not installed or not configured properly, trying to install now." ) )
111
+ if $silentMode
112
+ install ( "Homebrew" , "Installing Homebrew..." , '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" > /dev/null 2>&1 </dev/null' , false , false )
113
+ else
114
+ install ( "Homebrew" , "Installing Homebrew..." , '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" </dev/null' , false , false )
115
+ end
114
116
end
115
117
116
118
if !( execute ( "brew --version" , "Homebrew is not installed or not configured properly. Download it from http://brew.sh/, install, set it up and run this script again." ) )
117
119
exit
118
120
end
119
121
120
122
# Allow brew to lookup versions
121
- execute ( "brew tap caskroom/versions" , "" , false )
123
+ execute ( "brew tap homebrew/cask-versions" , "" , false )
124
+ execute ( "brew tap homebrew/cask" , "" , false )
122
125
123
126
# Install Google Chrome
124
- install ( "Google Chrome" , "Installing Google Chrome (required to debug NativeScript apps)" , "brew cask install google-chrome" , false , false ) ;
127
+ # install("Google Chrome", "Installing Google Chrome (required to debug NativeScript apps)", "brew install --cask google-chrome", false, false);
125
128
126
129
# Install Open JDK 8
127
- install ( "Open JDK 8" , "Installing Open JDK 8 ... This might take some time, please, be patient." , 'brew cask install adoptopenjdk8' , false , false )
130
+ install ( "Open JDK 8" , "Installing Open JDK 8 ... This might take some time, please, be patient." , 'brew install --cask adoptopenjdk8' , false , false )
128
131
unless ENV [ "JAVA_HOME" ]
129
132
java_home = "$(/usr/libexec/java_home -v 1.8)"
130
133
puts "Set JAVA_HOME=#{ java_home } "
131
134
install_environment_variable ( "JAVA_HOME" , java_home )
132
135
end
133
136
134
137
# Install Android SDK
135
- install ( "Android SDK" , "Installing Android SDK" , 'brew tap caskroom/cask; brew cask install android-sdk' , false )
136
- unless ENV [ "ANDROID_HOME" ]
138
+ install ( "Android SDK" , "Installing Android SDK" , 'brew install --cask android-sdk' , false )
139
+ puts ENV [ 'ANDROID_HOME' ]
140
+ unless ENV [ 'ANDROID_HOME' ]
137
141
android_home = "/usr/local/share/android-sdk"
138
142
puts "Set ANDROID_HOME=#{ android_home } "
139
143
install_environment_variable ( "ANDROID_HOME" , android_home )
@@ -154,13 +158,33 @@ def install_android_package(name)
154
158
end
155
159
end
156
160
161
+ def install_android_packages ( )
162
+ if $answer != "a"
163
+ puts "Allow the script to install Android packages?"
164
+
165
+ loop do
166
+ puts "(Y)es/(N)o"
167
+ $answer = gets . chomp . downcase
168
+ is_answer_yn = $answer == "y" || $answer == "n"
169
+ break if is_answer_yn
170
+ end
171
+
172
+ if $answer == "n"
173
+ puts "You have chosen not to install Android packages. Some features of NativeScript may not work correctly if you haven't already installed it"
174
+ return
175
+ end
176
+ end
177
+
178
+ install_android_package ( "tools" )
179
+ install_android_package ( "build-tools;30.0.3" )
180
+ install_android_package ( "platform-tools" )
181
+ install_android_package ( "platforms;android-30" )
182
+ install_android_package ( "extras;android;m2repository" )
183
+ install_android_package ( "extras;google;m2repository" )
184
+ end
185
+
157
186
sdk_manager = File . join ( ENV [ "ANDROID_HOME" ] , "tools" , "bin" , "sdkmanager" )
158
- install_android_package ( "tools" )
159
- install_android_package ( "build-tools;28.0.3" )
160
- install_android_package ( "platform-tools" )
161
- install_android_package ( "platforms;android-28" )
162
- install_android_package ( "extras;android;m2repository" )
163
- install_android_package ( "extras;google;m2repository" )
187
+ install_android_packages ( )
164
188
165
189
puts "Step #{ $count} of #{ $tasks. length } :"
166
190
$count += 1
@@ -173,7 +197,7 @@ def install_android_package(name)
173
197
execute ( "echo y | #{ sdk_manager } \" extras;intel;Hardware_Accelerated_Execution_Manager\" | grep -v = || true" , "Failed to download Intel HAXM." )
174
198
haxm_silent_installer = File . join ( ENV [ "ANDROID_HOME" ] , "extras" , "intel" , "Hardware_Accelerated_Execution_Manager" , "silent_install.sh" )
175
199
execute ( "sudo #{ haxm_silent_installer } " , "Failed to install Intel HAXM." )
176
- execute ( "echo y | #{ sdk_manager } \" system-images;android-28 ;google_apis;x86\" | grep -v = || true" , "Failed to download Android emulator system image." )
200
+ execute ( "echo y | #{ sdk_manager } \" system-images;android-30 ;google_apis;x86\" | grep -v = || true" , "Failed to download Android emulator system image." )
177
201
end
178
202
end
179
203
@@ -184,7 +208,7 @@ def install_android_package(name)
184
208
error_msg = "Failed to create Android emulator."
185
209
avd_manager = File . join ( ENV [ "ANDROID_HOME" ] , "tools" , "bin" , "avdmanager" )
186
210
# Create command ask for custom config, we pass "no" because we want defaults
187
- execute ( "echo no | #{ avd_manager } create avd -n Emulator-Api28 -Google -k \" system-images;android-28 ;google_apis;x86\" -b google_apis/x86 -c 265M -f" , error_msg )
211
+ execute ( "echo no | #{ avd_manager } create avd -n Emulator-Api30 -Google -k \" system-images;android-30 ;google_apis;x86\" -b google_apis/x86 -c 265M -f" , error_msg )
188
212
end
189
213
190
214
# the -p flag is set in order to ensure zero status code even if the directory exists
0 commit comments