Skip to content

Commit ff0f978

Browse files
Dimitar TachevDimitarTachev
Dimitar Tachev
authored andcommitted
Merge branch 'master' into cli/steps
2 parents 78d4af1 + 661195e commit ff0f978

File tree

7 files changed

+205
-135
lines changed

7 files changed

+205
-135
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/*.*

.travis.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
branches:
2+
only:
3+
- master
4+
env:
5+
global:
6+
- TERM=dumb
7+
matrix:
8+
include:
9+
- os: osx
10+
env:
11+
- BuildiOS="12.1"
12+
- Xcode="10.1"
13+
osx_image: xcode10.1
14+
language: node_js
15+
node_js: "10"
16+
language: ruby
17+
rvm:
18+
- 2.3.7
19+
script:
20+
- sudo rm -rf /usr/local/Caskroom/*
21+
- sudo rm -rf /usr/local/share/android-sdk
22+
- sudo rm -rf /Library/Java/JavaVirtualMachines/*
23+
- sudo ruby native-script.rb -- --silentMode
24+
- source ~/.bash_profile
25+
- npm i -g nativescript --ignore-scripts
26+
- tns usage-reporting disable
27+
- tns error-reporting disable
28+
- tns doctor
29+
- tns create TestApp --js
30+
- tns build ios --path TestApp
31+
- tns build android --path TestApp
32+
- $ANDROID_HOME/tools/bin/avdmanager list avd -c | grep Emu

appveyor.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Test only master branch (and PRs).
2+
branches:
3+
only:
4+
- master
5+
6+
# Environment configs.
7+
environment:
8+
nodejs_version: "10"
9+
10+
# Install scripts.
11+
install:
12+
- ps: Install-Product node $env:nodejs_version
13+
14+
# Test setup scripts.
15+
test_script:
16+
# Output useful info for debugging.
17+
- node --version
18+
- npm --version
19+
# Run setup script
20+
- powershell -NoProfile -ExecutionPolicy Bypass -file "native-script.ps1" "--silentMode"
21+
- refreshenv
22+
# Install NativeScript
23+
- npm i -g nativescript --ignore-scripts
24+
- tns usage-reporting disable
25+
- tns error-reporting disable
26+
# Run doctor and build app
27+
- tns doctor
28+
- tns create TestApp --js
29+
- tns build android --path TestApp
30+
31+
# Do not build (by default it tries to build .NET projects)
32+
build: off

common-script.ps1

Lines changed: 0 additions & 54 deletions
This file was deleted.

create-avd-script.ps1

Lines changed: 0 additions & 13 deletions
This file was deleted.

native-script.ps1

Lines changed: 77 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ param(
1010
)
1111

1212
$scriptUrl = "https://www.nativescript.org/setup/win"
13-
$scriptCommonUrl = "https://www.nativescript.org/setup/win-common"
1413

1514
# Check if latest .NET framework installed is at least 4
1615
$dotNetVersions = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | Get-ItemProperty -name Version,Release -EA 0 | Where { $_.PSChildName -match '^(?!S)\p{L}'} | Select Version
@@ -37,7 +36,7 @@ $script:answer = if ($SilentMode) {"a"} else {""}
3736
function Install($programName, $message, $script, $shouldExit) {
3837
if ($script:answer -ne "a") {
3938
Write-Host -ForegroundColor Green "Allow the script to install $($programName)?"
40-
Write-Host "Tip: Note that if you type a you won't be prompted for subsequent installations"
39+
Write-Host "Tip: Note that if you type A you won't be prompted for subsequent installations"
4140
do {
4241
$script:answer = (Read-Host "(Y)es/(N)o/(A)ll").ToLower()
4342
} until ($script:answer -eq "y" -or $script:answer -eq "n" -or $script:answer -eq "a")
@@ -60,7 +59,6 @@ function Pause {
6059
[void][System.Console]::ReadKey($true)
6160
}
6261

63-
# Actually installing all other dependencies
6462
# Install Chocolatey
6563
Install "Chocolatey (It's mandatory for the rest of the script)" "Installing Chocolatey" "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
6664

@@ -70,12 +68,35 @@ if ((Get-Command "cinst" -ErrorAction SilentlyContinue) -eq $null) {
7068
exit 1
7169
}
7270

73-
# Install dependencies with Chocolatey
71+
# Refresh Environment Variables
72+
refreshenv
7473

74+
# Install dependencies with Chocolatey
7575
Install "Google Chrome" "Installing Google Chrome (required to debug NativeScript apps)" "cinst googlechrome --force --yes"
7676

77-
Install "Java Development Kit" "Installing Java Development Kit" "choco upgrade jdk8 --force"
77+
# Install OpenJDK after Android SDK, as currently installing the Android SDK also installs the Oracle Java 1.8 version.
78+
Install "Java Development Kit (OpenJDK)" "Installing Java Development Kit (OpenJDK)" "choco upgrade adoptopenjdk --version 8.192 --force --yes"
79+
80+
# For some reason refreshing the environment variables is not working with Chocolatey.
81+
# To force it, refresh the $PROFILE, as shown here: https://stackoverflow.com/a/46760714/3357767
82+
$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).path)\..\.."
83+
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
84+
refreshenv
85+
86+
if (!$env:JAVA_HOME) {
87+
$openJdkLocation = "C:\Program Files\OpenJDK";
88+
$openJdkLocationExists = Test-Path $openJdkLocation;
89+
90+
if ($openJdkLocationExists -eq $True) {
91+
# We should never come here, the installation of OpenJDK should set the variable
92+
Write-Host -ForegroundColor DarkYellow "Setting up JAVA_HOME to $openJdkLocation";
93+
[Environment]::SetEnvironmentVariable("JAVA_HOME", $openJdkLocation, "User");
94+
$env:JAVA_HOME = $openJdkLocation;
95+
refreshenv;
96+
}
97+
}
7898

99+
# Check ANDROID_HOME
79100
$androidHomePathExists = $False
80101
if($env:ANDROID_HOME){
81102
$androidHomePathExists = Test-Path $env:ANDROID_HOME
@@ -85,11 +106,10 @@ if($androidHomePathExists -eq $False){
85106
[Environment]::SetEnvironmentVariable("ANDROID_HOME",$null,"User")
86107
}
87108

109+
# Install Android SDK
88110
Install "Android SDK" "Installing Android SDK" "cinst android-sdk --force --yes"
89111

90-
refreshenv
91-
# setup environment
92-
112+
# Set ANDROID_HOME
93113
if (!$env:ANDROID_HOME) {
94114
Write-Host -ForegroundColor DarkYellow "Setting up ANDROID_HOME"
95115
# in case the user has `android` in the PATH, use it as base for setting ANDROID_HOME
@@ -107,14 +127,6 @@ if (!$env:ANDROID_HOME) {
107127
refreshenv
108128
}
109129

110-
if (!$env:JAVA_HOME) {
111-
$curVer = (Get-ItemProperty "HKLM:\SOFTWARE\JavaSoft\Java Development Kit").CurrentVersion
112-
$javaHome = (Get-ItemProperty "HKLM:\Software\JavaSoft\Java Development Kit\$curVer").JavaHome
113-
[Environment]::SetEnvironmentVariable("JAVA_HOME", $javaHome, "User")
114-
$env:JAVA_HOME = $javaHome;
115-
refreshenv
116-
}
117-
118130
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK..."
119131

120132
# Update android-sdk tools in order to have avdmanager available and create AVDs later
@@ -156,19 +168,62 @@ $androidExecutable = [io.path]::combine($env:ANDROID_HOME, "tools", "bin", "sdkm
156168

157169
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK platform-tools..."
158170
echo y | cmd /c "$androidExecutable" "platform-tools"
159-
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK build-tools;27.0.3..."
160-
echo y | cmd /c "$androidExecutable" "build-tools;27.0.3"
161-
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK platforms;android-25..."
162-
echo y | cmd /c "$androidExecutable" "platforms;android-25"
171+
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK build-tools;28.0.3..."
172+
echo y | cmd /c "$androidExecutable" "build-tools;28.0.3"
173+
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK platforms;android-28..."
174+
echo y | cmd /c "$androidExecutable" "platforms;android-28"
163175
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK extras;android;m2repository..."
164176
echo y | cmd /c "$androidExecutable" "extras;android;m2repository"
165177
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK extras;google;m2repository..."
166178
echo y | cmd /c "$androidExecutable" "extras;google;m2repository"
167179
Write-Host -ForegroundColor DarkYellow "FINISHED setting up Android SDK."
168180

169181
# Setup Default Emulator
170-
iex ((new-object net.webclient).DownloadString($scriptCommonUrl))
171-
Create-AVD
182+
$androidExecutable = [io.path]::combine($env:ANDROID_HOME, "tools", "bin", "sdkmanager")
183+
$avdManagerExecutable = [io.path]::combine($env:ANDROID_HOME, "tools", "bin", "avdmanager")
184+
185+
# Emulator will not be installed in silent mode since Intel HAXM fails to install in silent mode.
186+
$installEmulatorAnswer = if ($SilentMode) {"n"} else {
187+
Do {
188+
$installEmulatorAnswer = (Read-Host "Do you want to install Android emulator? (Y)es/(N)o").ToLower()
189+
}
190+
While ($installEmulatorAnswer -ne 'y' -and $installEmulatorAnswer -ne 'n')
191+
}
192+
193+
if ($installEmulatorAnswer -eq 'y') {
194+
Write-Host -ForegroundColor DarkYellow "Setting up Android SDK system-images;android-28;google_apis;x86..."
195+
echo y | cmd /c "$androidExecutable" "system-images;android-28;google_apis;x86"
196+
197+
echo y | cmd /c "$androidExecutable" "extras;intel;Hardware_Accelerated_Execution_Manager"
198+
$haxmSilentInstaller = [io.path]::combine($env:ANDROID_HOME, "extras", "intel", "Hardware_Accelerated_Execution_Manager", "silent_install.bat")
199+
cmd /c "$haxmSilentInstaller"
200+
201+
if ($LASTEXITCODE -ne 0) {
202+
Write-Host -ForegroundColor Yellow "WARNING: Failed to install HAXM in silent mode. Starting interactive mode."
203+
$haxmInstaller = [io.path]::combine($env:ANDROID_HOME, "extras", "intel", "Hardware_Accelerated_Execution_Manager", "intelhaxm-android.exe")
204+
cmd /c "$haxmInstaller"
205+
}
206+
207+
$cmdArgList = @(
208+
"create",
209+
"avd",
210+
"-n","Emulator-Api28-Default",
211+
"-k",'"system-images;android-28;google_apis;x86"'
212+
)
213+
214+
echo no | cmd /c $avdManagerExecutable $cmdArgList
215+
216+
if ($LASTEXITCODE -ne 0) {
217+
Write-Host -ForegroundColor Red "ERROR: An error occurred while installing Android emulator. Please, install it manually."
218+
}else{
219+
Write-Host -ForegroundColor Green "Android emulator is successfully installed."
220+
}
221+
}
222+
223+
# Refresh Environment Variables
224+
refreshenv
172225

173226
Write-Host -ForegroundColor Green "This script has modified your environment. You need to log off and log back on for the changes to take effect."
227+
if (-Not $SilentMode) {
174228
Pause
229+
}

0 commit comments

Comments
 (0)