Create a GUI installer for the CLI dependencies.
Steps (credits to @dtopuzov):
- Initial steps
Welcome screen, explain what installer will do:
Setup {N} and all {N} dependencies.
Installer will reuse current dependencies if available.
Installer should prompt for dependencies root folder.
It should be he folder where not existing dependencies will be installed by default.
Default location of this folder should be short because later we may hit 255 symbols limitations in Windows.
For example: c:NativeScriptTools or c:DevTools or c:Tools or c:NativeScriptTools
We can use structure like this:
c:NativeScript -> root
c:NativeScriptdependencies -> dependencies
c:NativeScriptdemos -> here installer can close some repos like hello-world
c:NativeScriptdocs -> stand alone version of docs or other resources
c:NativeScriptcomponents -> RichUI components (pro version). Valid only for RichUI installer.
c:NativeScripttns.bat
-> We can place a shortcut to tns (just to have something in the root folder).
-> We may also place "The {N} shell" there (for sandboxed installations).
Next version options:
Checkbox "Install in sandboxed environment".
- There is an idea for a separate shell.
- In this case all dependencies will be force installed in specified dependencies folder.
- Installer will not try to detect existing version and prompt if you want to reuse them.
- JDK
Check if JAVA_HOME exist
Yes -> Check if version is 1.8+
Yes -> Use it
No -> Install JDK 1.8+
No -> Check if Java exists
Yes -> Just set JAVA_HOME
No -> Install JDK 1.8+
- NodeJS
Minimal NodeJS: 4
Recommended NodeJS: 6
Check node and npm versions:
< 4.0 -> Error "{N} is not compatible with this NodeJS vesrions." Install NodeJS 6.
4._, 5_, 6* -> Do nothing
7+ -> Warning "{N} is not verified agains this version of NodeJS. Proceed on your own risk!" and suggest installing Node6 (but Node6 should not be mandatory if you already have 7)
- Android
Check if ANDROID_HOME exist
Yes ->
prompt "Android SDK already exists. {N} will reuse it."
ask "Do you want {N} to add Android SDK features it needs."
Yes -> Go to step 4
No -> Warning "Proceed on your onw risk!"
No -> Download and extract SDK zip.
- Setup Android
Just run some commands (see details in draft).
- Create Emulators
Ask for HAXM (if possible detect if CPU is compatible with HAXM in future releases):
Yes -> Install HAXM and x86 Android 6.0 Emulator
No -> Install arm Android 6.0 Emulator
- Install tns
Check if current version is available:
Yes -> Check if latest on npm is newer:
Yes -> Suggest installing latest
No -> Do nothing
No -> Install latest
- Final steps
Open nativescript docs.
Draft, notes, more info:
- Java
if JAVA_HOME exists:
# c:>"%JAVA_HOME%binjava" -version
# java version "1.8.0_91"
# Java(TM) SE Runtime Environment (build 1.8.0_91-b15)
# Java HotSpot(TM) 64-Bit Server VM (build 25.91-b15, mixed mode)
if (""%JAVA_HOME%binjava -version" is 1.8+):
pass
# Installer can prompt -> Java detected, will reuse it.
else:
Install Java 1.8+
# http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html#jdk-silent-installation
# http://stackoverflow.com/questions/15292464/how-to-silently-install-java-jdk-into-a-specific-directory-on-windows
else:
# c:>where javac
# C:ToolsJavajdk1.8.0_20binjavac.exe
# c:>where javac
# C:ToolsJavajdk1.8.0_20binjavac.exe
# C:ToolsJavajdk1.8.0_20binjavac.exe -version
# javac 1.8.0_20
if (java exists, and it is 1.8+, but JAVA_HOME is not set):
set JAVA_HOME (no need to install it)
# Installer can prompt "Java 1.8+ detected on this location, do you want to set it in JAVA_HOME"
# If cancel setting java home then we can fallback to new JDK installation.
else:
Install Java 1.8+
# http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html#jdk-silent-installation
# http://stackoverflow.com/questions/15292464/how-to-silently-install-java-jdk-into-a-specific-directory-on-windows
Notes:
Download JDK might be a bit challenging, see https://gist.github.com/P7h/9741922
- NodeJS
if (npm and node are available):
# c:Gitnativescript-cli-tests>npm -v
#2.15.8
# c:Gitnativescript-cli-tests>node -v
# v4.4.7
# both should return some versions
# Possible checks:
# If version is < 4.0:
# Show warning that we recommend latest LTS release of NodeJS.
# May be even prompt "Do you want latest LTS" and install it.
# If version is 4._:
# pass (this is the best case)
# If version is 5._:
# Prompt "Your version is not LTS, do you want to install latest LTS release?"
# If version is 6._:
# pass
# Now LTS is 4, but after 4 next LTS will be 6. We work on 6 (but to be honest we do not use it on CI).
# So if node is 6._ => Do nothing and hope it work (most likely it will).
pass
else:
Install latest LTS from here: https://nodejs.org/en/
Notes:
Not sure how we can get link that always get latest msi, but is is not a big problem to hardcode some LTS version.
- Install Android SDK
if (%ANDROID_HOME%Toolsandroid exists):
prompt "Android SDK already exists. {N} will reuse it."
ask "Do you want {N} to add Android SDK features it needs."
if yes:
go to step 4
else:
do nothing (hope this user knows what to do)
else:
Download and extract SDK zip.
- Configure Android SDK
Run:
%ANDROID_HOME%Toolsandroid update sdk --filter "platform-tools" --all --no-ui
%ANDROID_HOME%Toolsandroid update sdk --filter "tools" --all --no-ui
%ANDROID_HOME%Toolsandroid update sdk --filter "android-23" --all --no-ui
%ANDROID_HOME%Toolsandroid update sdk --filter "build-tools-24.0.1" --all --no-ui
%ANDROID_HOME%Toolsandroid update sdk --filter "extra-android-m2repository" --all --no-ui
%ANDROID_HOME%Toolsandroid update sdk --filter "extra-google-m2repository" --all --no-ui
Reference:
https://github.com/NativeScript/nativescript-cli/blob/master/setup/native-script.ps1
- Create emulators:
I think there is no need to prompt here, just run it.
Even if user has some emulators, it will add one more.
if ((Read-Host "Do you want to install HAXM (Hardware accelerated Android emulator)?") -eq 'y') {
echo y | $ANDROID_HOME/tools/android update sdk --filter extra-intel-Hardware_Accelerated_Execution_Manager --all --no-ui
$haxmSilentInstaller = [io.path]::combine($env:ANDROID_HOME, "extras", "intel", "Hardware_Accelerated_Execution_Manager", "silent_install.bat")
cmd /c "$haxmSilentInstaller"
echo y | $ANDROID_HOME/tools/android update sdk --filter sys-img-x86-android-23 --all --no-ui
echo no | $ANDROID_HOME/tools/android create avd -n NativeScript-Emulator-Api23 -t android-23 --abi default/x86 -c 32M -f
} else {
echo y | $ANDROID_HOME/tools/android update sdk --filter sys-img-armeabi-v7a-android-23 --all --no-ui
echo no | $ANDROID_HOME/tools/android create avd -n NativeScript-Emulator-Api23 -t android-23 --abi default/armeabi-v7a -c 32M -f
}
Ides for next versions:
- Detect if CPU support HAXM.
If CPU suport HAXM and HAXM is not install it -> install it.
Crete x86 emulators
- If CPU does not support HAXM -> prompt with some message like
"Your CPU does not support hardware accelerated emulators. Please be patient..."
Create arm emulators.
- Nativescript
if nativescript exists:
# c:>tns --version (check local version)
#2.2.0
# c:>npm view nativescript version (check latest on npm)
#2.2.1
if (latest version on npm > available version):
prompt "There is newer version of nativescript. Do you want to update?"
if yes:
"npm install -g nativescript -f" (force isntall latest)
else:
"npm install -g nativescript"
- Final steps (Optional): Open {N} documentation - http://docs.nativescript.org/angular/start/introduction.html.
Notes:
If getting JDK and SDK from internet is hard then we may install them with chocolaty.
This approach is used in setup scripts and it works:
https://github.com/NativeScript/nativescript-cli/blob/master/setup/native-script.ps1
Most helpful comment
The algorithm looks good to me generally. Some suggestions: