feature(windows): make it more clear that the user needs to update their PATH
[webi-installers/.git] / _webi / template.ps1
1 #!/usr/bin/env pwsh
2
3 # this allows us to call ps1 files, which allows us to have spaces in filenames
4 # ('powershell "$Env:USERPROFILE\test.ps1" foo' will fail if it has a space in
5 # the path but '& "$Env:USERPROFILE\test.ps1" foo' will work even with a space)
6 Set-ExecutionPolicy -Scope Process Bypass
7
8 # If a command returns an error, halt the script.
9 $ErrorActionPreference = 'Stop'
10
11 # Ignore progress events from cmdlets so Invoke-WebRequest is not painfully slow
12 $ProgressPreference = 'SilentlyContinue'
13
14 $Env:WEBI_HOST = 'https://webinstall.dev'
15 #$Env:WEBI_PKG = 'node@lts'
16 #$Env:PKG_NAME = node
17 #$Env:WEBI_VERSION = v12.16.2
18 #$Env:WEBI_PKG_URL = "https://.../node-....zip"
19 #$Env:WEBI_PKG_FILE = "node-v12.16.2-win-x64.zip"
20
21 # Switch to userprofile
22 pushd $Env:USERPROFILE
23
24 # Make paths
25 New-Item -Path Downloads -ItemType Directory -Force | out-null
26 New-Item -Path .local\bin -ItemType Directory -Force | out-null
27 New-Item -Path .local\opt -ItemType Directory -Force | out-null
28
29 # {{ baseurl }}
30 # {{ version }}
31
32 function webi_add_path
33 {
34     Write-Host ''
35     Write-Host '*****************************' -ForegroundColor red -BackgroundColor white
36     Write-Host '*    IMPORTANT - READ ME    *' -ForegroundColor red -BackgroundColor white
37     Write-Host '*****************************' -ForegroundColor red -BackgroundColor white
38     Write-Host ''
39     & "$Env:USERPROFILE\.local\bin\pathman.exe" add "$args[0]"
40     # Note: not all of these work as expected, so we use the unix-style, which is most consistent
41     #& "$Env:USERPROFILE\.local\bin\pathman.exe" add ~/.local/bin
42     #& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\bin"
43     #& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\bin
44 }
45
46 # Run pathman to set up the folder
47 & "$Env:USERPROFILE\.local\bin\pathman.exe" add ~/.local/bin
48
49 {{ installer }}
50
51 # Done
52 popd