-
Notifications
You must be signed in to change notification settings - Fork 1
/
initChocoScript.ps1
153 lines (117 loc) · 4.78 KB
/
initChocoScript.ps1
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
-NoLogo -NoProfile
Write-Host "This script will install chocolatey, git, github-cli, as well as non Choco essentials." -ForegroundColor Green
#function to update system path after installation
function Update-Environment-Path
{
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") `
+ ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
}
$ifChocoInstalled = powershell -NoLogo -NoProfile choco -v
#Choco installation
if(-not($ifChocoInstalled)){
Write-host "Chocolatey is not installed, installation begin now " -ForegroundColor Green
Set-ExecutionPolicy Bypass -Scope Process -Force;
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Update-Environment-Path
}
else{
Write-host "Chocolatey $ifChocoInstalled is already installed" -ForegroundColor Green
}
#GIT Installation
$ifGITInstalled = powershell -NoLogo -NoProfile git --version
if(-not($ifGITInstalled)){
Write-host "GIT is not installed, installation begin now " -ForegroundColor Green
Set-ExecutionPolicy Bypass -Scope Process -Force;
choco install git --yes
Update-Environment-Path
}
else{
Write-host "$ifGITInstalled is already installed" -ForegroundColor Green
}
$ifghInstalled = powershell -NoLogo -NoProfile gh --version
if(-not($ifghInstalled)){
Write-host "gh is not installed, installation begin now " -ForegroundColor Green
Set-ExecutionPolicy Bypass -Scope Process -Force;
choco install gh --yes
Update-Environment-Path
}
else{
Write-host "$ifghInstalled is already installed" -ForegroundColor Green
}
$ifbobInstalled = powershell -NoLogo -NoProfile where bob
#bob installation
if(-not($ifbobInstalled)){
Write-host "bob is not installed, installation begin now " -ForegroundColor Green
Set-ExecutionPolicy Bypass -Scope Process -Force;
curl.exe -L ('https://github.com/MordechaiHadad/bob/releases/latest/download/bob-windows-x86_64.zip') -o c:\bob.zip
7z x c:/temp/bob.zip -oc:/bob
[System.Environment]::SetEnvironmentVariable("Path","Env:Path + c:/bob", "User")
Remove-Item -path c:/temp/bob.zip
Update-Environment-Path
}
else{
Write-host "bob $ifbobInstalled is already installed" -ForegroundColor Green
}
$ifnvimInstalled = powershell -NoLogo -NoProfile where.exe nvim
if ($ifnvimInstalled -and $ifnvimInstalled[0] -ne "bob\nvim-bin\nvim.exe") {
# Uninstall existing Neovim installation from regular Windows installation
# $regularUninstallCommand = '<Uninstall Command for Regular Windows Installation>'
# if ($regularUninstallCommand) {
# Write-Host "Uninstalling existing Neovim installation (Regular Windows Installation)" -ForegroundColor Yellow
# Invoke-Expression $regularUninstallCommand
# }
# Uninstall existing Neovim installation from Chocolatey
$chocoListOutput = powershell -NoLogo -NoProfile choco list nvim
$chocoInstalled = $chocoListOutput -ne ""
if ($chocoInstalled) {
Write-Host "Uninstalling existing Neovim installation (Chocolatey)" -ForegroundColor Yellow
powershell -NoLogo -NoProfile choco uninstall nvim -y
Write-Host "Refreshing environment variables" -ForegroundColor Yellow
powershell -NoLogo -NoProfile refreshenv
}
# Run the command to install Neovim through Bob
Write-Host "Installing Neovim through Bob" -ForegroundColor Yellow
powershell -NoLogo -NoProfile -Command "bob use stable"
Write-Host "Installed Neovim through Bob successfully" -ForegroundColor Green
} elseif ($ifnvimInstalled -eq $null) {
Write-Host "Neovim is not installed, something obviously went wrong" -ForegroundColor Red
} else {
Write-Host "Neovim is already installed through Bob" -ForegroundColor Green
}
# $ifbobInstalled = powershell -NoLogo -NoProfile where.exe bob
# $uninstallPath = Get-Command nvim | Select-Object -ExpandProperty Source & $uninstallPath --uninstall
# if(($ifbobInstalled)){
# if(($ifnvimInstalled)){
# $Installer = New-Object -ComObject WindowsInstaller.Installer
# $nvim =
# ( $Installer.ProductsEx("", "", 7)
# |Where-Object{$_.InstallProperty("ProductName ") -like "Neovim"})
# | Select-Object -First 1
# $msiProductCode = $nvim.ProductCode()
# if($msiProductCode) {
# Write-host "Uninstall neovim installed in any other way other than through Bob. " -ForegroundColor Red
# }
# }
# }
# else {
#
# Write-host "bob is not installed, Something obviously went wrong" -ForegroundColor Red
#
# }
#
#
# if(($ifbobInstalled)){
#
# Write-host "bob $ifbobInstalled is already installed" -ForegroundColor Green
#
# }
# else {
#
# Write-host "bob is not installed, Something obviously went wrong" -ForegroundColor Red
#
# }
#
#
#
#
Update-Environment-Path