Repository navigation
Expand file tree
/
Copy pathinstall.ps1
More file actions
48 lines (45 loc) · 2.29 KB
/
Copy pathinstall.ps1
File metadata and controls
48 lines (45 loc) · 2.29 KB
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
# opensips-lsp one-command installer for Windows (PowerShell).
#
# irm https://raw.githubusercontent.com/NormB/opensips-lsp/main/install.ps1 | iex
#
# Downloads the latest release for this machine, installs the server
# to %LOCALAPPDATA%\opensips-lsp, and installs the VS Code extension
# into every editor CLI found (code, code-insiders, codium).
$ErrorActionPreference = 'Stop'
$repo = 'NormB/opensips-lsp'
$arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'aarch64' } else { 'x86_64' }
$tag = (Invoke-RestMethod "https://api.github.com/repos/$repo/releases/latest").tag_name
Write-Host "Installing opensips-lsp $tag for $arch ..."
$dest = Join-Path $env:LOCALAPPDATA 'opensips-lsp'
New-Item -ItemType Directory -Force -Path $dest | Out-Null
$zip = Join-Path $env:TEMP 'opensips-lsp.zip'
Invoke-WebRequest "https://github.com/$repo/releases/download/$tag/opensips-lsp-$tag-$arch-windows.zip" -OutFile $zip
Expand-Archive -Path $zip -DestinationPath $dest -Force
Remove-Item $zip
Write-Host "Server installed: $dest\opensips-lsp.exe"
Write-Host "NOTE: add $dest to your PATH if editors other than VS Code need it."
$vsix = Join-Path $env:TEMP 'opensips-lsp-ext.vsix'
$installed = $false
foreach ($editor in 'code', 'code-insiders', 'codium') {
if (Get-Command $editor -ErrorAction SilentlyContinue) {
if (-not (Test-Path $vsix)) {
Invoke-WebRequest "https://github.com/$repo/releases/download/$tag/opensips-lsp-ext-$tag.vsix" -OutFile $vsix
}
& $editor --install-extension $vsix --force | Out-Null
Write-Host "Extension installed into $editor."
$installed = $true
}
}
if ($installed) {
Write-Host ""
Write-Host "NOTE: installing from a file means your editor will NOT offer"
Write-Host " updates for this extension - a sideloaded VSIX carries no"
Write-Host " marketplace metadata. To get updates, either re-run this"
Write-Host " script, or install it from the Extensions view instead."
}
if (-not $installed) {
Write-Host "No editor CLI found. Install the extension by hand:"
Write-Host " 1. Download: https://github.com/$repo/releases/download/$tag/opensips-lsp-ext-$tag.vsix"
Write-Host " 2. In VS Code press Ctrl+Shift+X, click the '...' menu,"
Write-Host " choose 'Install from VSIX...' and pick the file."
}