5eac194b63b7dfa5601a0bd48990d9a5ac9832bf
[webi-installers/.git] / _webi / bootstrap.ps1
1 #!/usr/bin/env pwsh
2
3 # If a command returns an error, halt the script.
4 $ErrorActionPreference = 'Stop'
5
6 # Ignore progress events from cmdlets so Invoke-WebRequest is not painfully slow
7 $ProgressPreference = 'SilentlyContinue'
8
9 # Switch to userprofile
10 pushd $Env:USERPROFILE
11
12 # Make paths if needed
13 if (!(Test-Path -Path .local\bin))
14 {
15     New-Item -Path .local\bin -ItemType Directory
16 }
17
18 # {{ baseurl }}
19 # {{ version }}
20
21 # Enter path
22 pushd .local\bin
23
24 # TODO SetStrictMode
25 # TODO Test-Path variable:global:Env:WEBI_HOST ???
26 IF(!$Env:WEBI_HOST)
27 {
28     $Env:WEBI_HOST = "https://webinstall.dev"
29 }
30
31 # Fetch webi.bat
32 Invoke-WebRequest "$Env:WEBI_HOST/packages/_webi/webi.ps1.bat" -OutFile webi.bat
33 Invoke-WebRequest "$Env:WEBI_HOST/packages/_webi/webi.ps1" -OutFile webi.ps1
34
35 popd
36
37 # Run webi.ps1
38 #TODO Set-ExecutionPolicy -ExecutionPolicy Bypass
39 Invoke-Expression "powershell -ExecutionPolicy Bypass .\.local\bin\webi.ps1 {{ exename }}"
40
41 # Run pathman to set up the folder
42 #& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\.bin"
43 & "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\.bin
44
45 # Done
46 popd