Skip to content

Commit 4297adf

Browse files
author
Dimitar Kerezov
committed
WIP
1 parent 4709434 commit 4297adf

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

setup/native-script.ps1

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11

22
# A PowerShell script to set up Windows machine for NativeScript development
33
# NOTE: The scripts requires at least a version 4.0 .NET framework installed
4-
# To run it inside a COMMAND PROMPT against the production branch (only one supported with self-elevation) use
5-
# @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
6-
# To run it inside a WINDOWS POWERSHELL console against the production branch (only one supported with self-elevation) use
7-
# start-process -FilePath PowerShell.exe -NoNewWindow -Wait -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
4+
# To run it inside a COMMAND PROMPT against the kerezov/setup-scripts branch (only one supported with self-elevation) use
5+
# @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/kerezov/setup-scripts/setup/native-script.ps1'))"
6+
# To run it inside a WINDOWS POWERSHELL console against the kerezov/setup-scripts branch (only one supported with self-elevation) use
7+
# iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/kerezov/setup-scripts/setup/native-script.ps1'))
88

99
# Check if latest .NET framework installed is at least 4
1010
$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
1111
$latestDotNetVersion = $dotNetVersions.GetEnumerator() | Sort-Object Version | Select-Object -Last 1
1212
$latestDotNetMajorNumber = $latestDotNetVersion.Version.Split(".")[0]
1313
if ($latestDotNetMajorNumber -lt 4) {
14-
Write-Host -BackgroundColor Black -ForegroundColor Red "Running this script requires at least a version 4.0 .NET framework installed"
14+
Write-Host -ForegroundColor Red "Running this script requires at least a version 4.0 .NET framework installed"
1515
if ((Read-Host "Do you want to open Microsoft's Download Center in your default browser(y/n)") -eq 'y') {
1616
Start-Process -FilePath "https://www.microsoft.com/en-us/download/search.aspx?q=.net%20framework&p=0&r=10&t=&s=Relevancy~Descending"
1717
}
@@ -22,30 +22,30 @@ if ($latestDotNetMajorNumber -lt 4) {
2222
# Self-elevate
2323
$isElevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")
2424
if (-not $isElevated) {
25-
start-process -FilePath PowerShell.exe -Verb Runas -Wait -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
25+
start-process -FilePath PowerShell.exe -Verb Runas -Wait -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/kerezov/setup-scripts/setup/native-script.ps1'))"
2626
exit 0
2727
}
2828

2929
# Help with installing other dependencies
3030
$script:answer = ""
3131
function Install($programName, $message, $script, $shouldExit) {
32-
if ($script:answer -ne "all") {
33-
Write-Host -BackgroundColor Black -ForegroundColor Green "Allow the script to install $($programName)?"
34-
Write-Host -BackgroundColor Black "Tip: Note that if you type all you won't be prompted for subsequent installations"
32+
if ($script:answer -ne "a") {
33+
Write-Host -ForegroundColor Green "Allow the script to install $($programName)?"
34+
Write-Host "Tip: Note that if you type a you won't be prompted for subsequent installations"
3535
do {
36-
$script:answer = (Read-Host "y/n/all").ToLower()
37-
} until ($script:answer -eq "y" -or $script:answer -eq "n" -or $script:answer -eq "all")
36+
$script:answer = (Read-Host "(Y)es/(N)o/(A)ll").ToLower()
37+
} until ($script:answer -eq "y" -or $script:answer -eq "n" -or $script:answer -eq "a")
3838

3939
if ($script:answer -eq "n") {
40-
Write-Host -BackgroundColor Black -ForegroundColor Yellow "You've chosen not to install $($programName) some features of NativeScript may not work correctly if you haven't already installed it"
40+
Write-Host -ForegroundColor Yellow "You have chosen not to install $($programName). Some features of NativeScript may not work correctly if you haven't already installed it"
4141
return
4242
}
4343
}
4444

45-
Write-Host -BackgroundColor Black $message
45+
Write-Host $message
4646
Invoke-Expression($script)
4747
if ($LASTEXITCODE -ne 0) {
48-
Write-Host -BackgroundColor Black -ForegroundColor Yellow "WARNING: $($programName) not installed"
48+
Write-Host -ForegroundColor Yellow "WARNING: $($programName) not installed"
4949
}
5050
}
5151

@@ -59,7 +59,7 @@ function Pause {
5959
Install "Chocolately(It's mandatory for the rest of the script)" "Installing Chocolately" "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
6060

6161
if ((Get-Command "cinst" -ErrorAction SilentlyContinue) -eq $null) {
62-
Write-Host -BackgroundColor Black -ForegroundColor Red "Chocolatey is not installed or not configured properly. Download it from https://chocolatey.org/, install, set it up and run this script again."
62+
Write-Host -ForegroundColor Red "Chocolatey is not installed or not configured properly. Download it from https://chocolatey.org/, install, set it up and run this script again."
6363
Pause
6464
exit 1
6565
}
@@ -90,5 +90,5 @@ if (!$env:JAVA_HOME) {
9090
$env:JAVA_HOME = $javaHome;
9191
}
9292

93-
Write-Host -BackgroundColor Black -ForegroundColor Green "This script has modified your environment. You need to log off and log back on for the changes to take effect."
93+
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."
9494
Pause

setup/native-script.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Only the user can manually download and install Xcode from App Store
88
unless Process.uid == 0
9-
# Self-elevate
9+
# Execute as root
1010
puts "This scripts needs sudo permissions"
1111
exec('sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.rb)"')
1212
end
@@ -50,21 +50,21 @@ def execute(script, warning_message, run_as_root = false)
5050
end
5151

5252
def install(program_name, message, script, run_as_root = false, show_all_option = true)
53-
if $answer != "all"
53+
if $answer != "a"
5454
puts "Allow the script to install " + program_name + "?"
5555
if show_all_option
5656
puts "Note that if you type all you won't be prompted for subsequent installations"
5757
end
5858

5959
loop do
60-
puts show_all_option ? "y/n/all" : "y/n"
60+
puts show_all_option ? "(Y)es/(N)o/(A)ll" : "(Y)es/(N)o"
6161
$answer = gets.chomp.downcase
6262
is_answer_yn = $answer == "y" || $answer == "n"
63-
break if show_all_option ? is_answer_yn || $answer == "all" : is_answer_yn
63+
break if show_all_option ? is_answer_yn || $answer == "a" : is_answer_yn
6464
end
6565

6666
if $answer == "n"
67-
puts "You've chosen not to install " + program_name + " some features of NativeScript may not work correctly if you haven't already installed it"
67+
puts "You have chosen not to install " + program_name + ". Some features of NativeScript may not work correctly if you haven't already installed it"
6868
end
6969
end
7070

@@ -80,7 +80,7 @@ def install(program_name, message, script, run_as_root = false, show_all_option
8080
exit
8181
end
8282

83-
install("Java SE Development Kit", "Installing the Java SE Development Kit... This might take some time, please, be patient.(You will be prompted for your password)", 'brew cask install java', false, false)
83+
install("Java SE Development Kit", "Installing the Java SE Development Kit... This might take some time, please, be patient. (You will be prompted for your password)", 'brew cask install java', false, false)
8484
execute('echo "export JAVA_HOME=$(/usr/libexec/java_home)" >> ~/.profile', "Unable to set JAVA_HOME")
8585

8686
install("Android SDK", "Installing Android SDK", 'brew install android-sdk')

0 commit comments

Comments
 (0)