Files
BridgeSwarm/scripts/install-host.ps1
T
Raven Scott 914bc7e404
CI / Build & Test (push) Successful in 3m5s
Modernize
2026-07-26 21:58:45 -04:00

36 lines
2.0 KiB
PowerShell

# Install only the native messaging host (Windows). For full install use scripts/install.ps1.
$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepoRoot = (Resolve-Path (Join-Path $ScriptDir "..")).Path
$HostDir = Join-Path $RepoRoot "native-host"
Set-Location $HostDir
Write-Host "Installing native-host dependencies..."
if (-not (Test-Path (Join-Path $HostDir "node_modules"))) {
npm install --no-fund --no-audit 2>$null
if ($LASTEXITCODE -ne 0) { npm install }
} else {
Write-Host " node_modules exists, skipping npm install"
}
$nodePath = (Get-Command node -ErrorAction SilentlyContinue).Source
$localBare = Join-Path $HostDir "node_modules\bare\bin\bare"
$bareCmd = Get-Command bare -ErrorAction SilentlyContinue
if (-not $nodePath) { $nodePath = "node" }
$barePath = if (Test-Path $localBare) { $localBare } elseif ($bareCmd) { $bareCmd.Source } else { "bare" }
$batContent = "@echo off`r`nset `"DIR=%~dp0`"`r`n`"$nodePath`" `"$barePath`" `"%DIR%index.mjs`" %*"
Set-Content (Join-Path $HostDir "bridge-swarm-host.bat") -Value $batContent -Encoding ASCII
$HostPath = Join-Path $HostDir "bridge-swarm-host.bat"
$manifest = Get-Content (Join-Path $RepoRoot "com.bridgeswarm.json") -Raw | ConvertFrom-Json
$manifest.path = $HostPath
$manifestFile = Join-Path $env:LOCALAPPDATA "bridge-swarm\com.bridgeswarm.json"
New-Item -ItemType Directory -Path (Split-Path $manifestFile) -Force | Out-Null
$manifest | ConvertTo-Json -Depth 4 | Set-Content $manifestFile -Encoding UTF8
New-Item -Path "HKCU:\Software\Google\Chrome\NativeMessagingHosts\com.bridgeswarm" -Force | Out-Null
Set-ItemProperty -Path "HKCU:\Software\Google\Chrome\NativeMessagingHosts\com.bridgeswarm" -Name "(Default)" -Value $manifestFile
New-Item -Path "HKCU:\Software\Mozilla\NativeMessagingHosts\com.bridgeswarm" -Force | Out-Null
Set-ItemProperty -Path "HKCU:\Software\Mozilla\NativeMessagingHosts\com.bridgeswarm" -Name "(Default)" -Value $manifestFile
Write-Host "Done. Manifest: $manifestFile"