diff --git a/scripts/install-extension.ps1 b/scripts/install-extension.ps1 deleted file mode 100644 index 55c8d41..0000000 --- a/scripts/install-extension.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -# Install only the extension (copy path, open browser). For full install use scripts/install.ps1. -$ErrorActionPreference = "Stop" -$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path -$RepoRoot = (Resolve-Path (Join-Path $ScriptDir "..")).Path -$ExtDir = (Resolve-Path (Join-Path $RepoRoot "extension")).Path -if (-not (Test-Path (Join-Path $ExtDir "manifest.json"))) { Write-Error "extension/manifest.json not found."; exit 1 } -Set-Clipboard -Value $ExtDir -$p = "${env:ProgramFiles}\Google\Chrome\Application\chrome.exe","${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe","${env:LocalAppData}\Google\Chrome\Application\chrome.exe" | Where-Object { Test-Path $_ } | Select-Object -First 1 -if ($p) { Start-Process $p -ArgumentList "chrome://extensions" } -Write-Host "Extension path (clipboard): $ExtDir" -Write-Host "Open the extension page, click 'Load unpacked', paste the path." diff --git a/scripts/install-extension.sh b/scripts/install-extension.sh deleted file mode 100755 index 484825a..0000000 --- a/scripts/install-extension.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -# Install only the extension (copy path, open browser). For full install use scripts/install.sh. -set -e -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" -EXT_DIR="$REPO_ROOT/extension" -[[ ! -f "$EXT_DIR/manifest.json" ]] && echo "Error: extension/manifest.json not found." && exit 1 - -command -v pbcopy >/dev/null 2>&1 && echo "$EXT_DIR" | pbcopy -command -v xclip >/dev/null 2>&1 && echo -n "$EXT_DIR" | xclip -selection clipboard 2>/dev/null || true -command -v xsel >/dev/null 2>&1 && echo -n "$EXT_DIR" | xsel --clipboard 2>/dev/null || true - -open_page() { local u="$1" a="$2"; [[ "$OSTYPE" == "darwin"* ]] && open -a "$a" "$u" 2>/dev/null && return 0; command -v xdg-open >/dev/null 2>&1 && xdg-open "$u" 2>/dev/null; } -open_page "chrome://extensions" "Google Chrome" || open_page "chrome://extensions" "Chromium" || open_page "chrome://extensions" "Microsoft Edge" || true -echo "Extension path (clipboard): $EXT_DIR" -echo "Open the extension page, click 'Load unpacked', paste the path." diff --git a/scripts/install-host.ps1 b/scripts/install-host.ps1 deleted file mode 100644 index d0c9c03..0000000 --- a/scripts/install-host.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -# 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 -$barePath = (Get-Command bare -ErrorAction SilentlyContinue).Source -if (-not $nodePath) { $nodePath = "node" } -if (-not $barePath) { $barePath = "bare" } - -$batContent = "@echo off`r`nset `"DIR=%~dp0`"`r`n`"$nodePath`" `"$barePath`" `"%DIR%index.mjs`" %*" -Set-Content (Join-Path $HostDir "holesail-browser-host.bat") -Value $batContent -Encoding ASCII -$HostPath = Join-Path $HostDir "holesail-browser-host.bat" - -$manifest = Get-Content (Join-Path $RepoRoot "com.holesail.browser.json") -Raw | ConvertFrom-Json -$manifest.path = $HostPath -$manifestFile = Join-Path $env:LOCALAPPDATA "holesail-browser\com.holesail.browser.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.holesail.browser" -Force | Out-Null -Set-ItemProperty -Path "HKCU:\Software\Google\Chrome\NativeMessagingHosts\com.holesail.browser" -Name "(Default)" -Value $manifestFile -New-Item -Path "HKCU:\Software\Mozilla\NativeMessagingHosts\com.holesail.browser" -Force | Out-Null -Set-ItemProperty -Path "HKCU:\Software\Mozilla\NativeMessagingHosts\com.holesail.browser" -Name "(Default)" -Value $manifestFile -Write-Host "Done. Manifest: $manifestFile" diff --git a/scripts/install-host.sh b/scripts/install-host.sh deleted file mode 100755 index fc001d1..0000000 --- a/scripts/install-host.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash -# Install only the native messaging host (macOS/Linux). For full install use scripts/install.sh. -# -# If a standalone distributable binary exists in releases/ it is used directly -# (no bare runtime required). Otherwise falls back to a bare launcher script. -set -e -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" -HOST_DIR="$REPO_ROOT/native-host" - -# Detect current platform/arch for distributable lookup -PLATFORM="$(uname -s | tr '[:upper:]' '[:lower:]')" -ARCH="$(uname -m)" -[[ "$ARCH" == "x86_64" ]] && ARCH="x64" -[[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]] && ARCH="arm64" -[[ "$PLATFORM" == "darwin" ]] && HOST_TRIPLE="darwin-$ARCH" -[[ "$PLATFORM" == "linux" ]] && HOST_TRIPLE="linux-$ARCH" - -# Check for a pre-built standalone binary in releases/ -DIST_BINARY="$REPO_ROOT/releases/holesail-browser-host" -if [[ -x "$DIST_BINARY" ]]; then - echo "Using standalone distributable binary: $DIST_BINARY" - HOST_PATH="$DIST_BINARY" -else - echo "No distributable binary found, building bare launcher..." - cd "$HOST_DIR" - - echo "Installing native-host dependencies..." - if [[ ! -d "$HOST_DIR/node_modules" ]]; then - npm install --no-fund --no-audit 2>/dev/null || npm install - else - echo " node_modules exists, skipping npm install" - fi - - BARE_PATH="$(which bare 2>/dev/null)" || true - [[ -z "$BARE_PATH" ]] && for c in /opt/homebrew/bin/bare /usr/local/bin/bare; do [[ -x "$c" ]] && BARE_PATH="$c" && break; done - NODE_PATH="" - if [[ -n "$BARE_PATH" ]]; then - BARE_DIR="${BARE_PATH%/*}" - for c in "$BARE_DIR/node" "$(which node 2>/dev/null)" /opt/homebrew/bin/node /usr/local/bin/node; do - [[ -x "$c" ]] && NODE_PATH="$c" && break - done - fi - [[ -z "$NODE_PATH" ]] && NODE_PATH="node" - [[ -z "$BARE_PATH" ]] && BARE_PATH="bare" - - cat > "$HOST_DIR/holesail-browser-host" << EOF -#!/usr/bin/env bash -DIR="\$(cd "\$(dirname "\$0")" && pwd)" -exec "$NODE_PATH" "$BARE_PATH" "\$DIR/index.mjs" "\$@" -EOF - chmod +x "$HOST_DIR/holesail-browser-host" - HOST_PATH="$HOST_DIR/holesail-browser-host" - echo "Done. Wrapper: $NODE_PATH $BARE_PATH" -fi - -CHROME_DIR="$HOME/.config/google-chrome/NativeMessagingHosts" -CHROMIUM_DIR="$HOME/.config/chromium/NativeMessagingHosts" -FIREFOX_DIR="$HOME/.mozilla/native-messaging-hosts" -[[ "$OSTYPE" == "darwin"* ]] && CHROME_DIR="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" && CHROMIUM_DIR="$HOME/Library/Application Support/Chromium/NativeMessagingHosts" && FIREFOX_DIR="$HOME/Library/Application Support/Mozilla/NativeMessagingHosts" - -MANIFEST_NAME="com.holesail.browser" -MANIFEST_CONTENT=$(sed "s|ABSOLUTE_PATH_TO_NATIVE_HOST|$HOST_PATH|g" "$REPO_ROOT/com.holesail.browser.json") -for dir in "$CHROME_DIR" "$CHROMIUM_DIR" "$FIREFOX_DIR"; do - mkdir -p "$dir" 2>/dev/null && echo "$MANIFEST_CONTENT" > "$dir/${MANIFEST_NAME}.json" && echo "Wrote $dir/${MANIFEST_NAME}.json" -done -echo "Done. Wrapper: $NODE_PATH $BARE_PATH" diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 20025f0..73edb25 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -1,87 +1,92 @@ -# Unified installer for Holesail Browser (extension + native host). -# Run from anywhere: .\scripts\install.ps1 or cd holesail-browser; .\scripts\install.ps1 +# Holesail Browser Installer (Windows) +# Downloads the native host binary and extension from the latest release. +# +# Usage (run in PowerShell as your normal user): +# irm https://git.ssh.surf/snxraven/holesail-browser/raw/branch/main/scripts/install.ps1 | iex $ErrorActionPreference = "Stop" -$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path -$RepoRoot = (Resolve-Path (Join-Path $ScriptDir "..")).Path -Write-Host "Holesail Browser – Install" -ForegroundColor Cyan -Write-Host "=============================" +$ReleaseBase = "https://git.ssh.surf/snxraven/holesail-browser/releases/download/latest-main" +$InstallDir = "$env:LOCALAPPDATA\holesail-browser" +$Downloads = "$env:USERPROFILE\Downloads" +$ManifestName = "com.holesail.browser" -# Require Node.js -if (-not (Get-Command node -ErrorAction SilentlyContinue)) { - Write-Host "Error: Node.js is required. Install from https://nodejs.org and run this script again." -ForegroundColor Red - exit 1 -} +$HostZip = "holesail-browser-host-win32-x64.zip" +$ExtZip = "Holesail-Browser-1.0.0.zip" -# Ensure bare is available -if (-not (Get-Command bare -ErrorAction SilentlyContinue)) { - Write-Host "Installing Bare runtime (required for native host)..." - npm install -g bare 2>$null - if (-not (Get-Command bare -ErrorAction SilentlyContinue)) { - Write-Host "Warning: Could not install bare. Run: npm install -g bare" -ForegroundColor Yellow - } -} - -# 1. Native host Write-Host "" -Write-Host "1. Installing native host..." -$HostDir = Join-Path $RepoRoot "native-host" -Set-Location $HostDir -npm install --no-fund --no-audit 2>$null -if ($LASTEXITCODE -ne 0) { npm install } - -# Windows: use .bat that runs bare; Chrome may have limited PATH so use full path if we can find it -$bareCmd = Get-Command bare -ErrorAction SilentlyContinue -$nodeCmd = Get-Command node -ErrorAction SilentlyContinue -$nodePath = if ($nodeCmd) { $nodeCmd.Source } else { "node" } -$barePath = if ($bareCmd) { $bareCmd.Source } else { "bare" } - -$batContent = "@echo off`r`nset `"DIR=%~dp0`"`r`n`"$nodePath`" `"$barePath`" `"%DIR%index.mjs`" %*" -$batContent | Set-Content (Join-Path $HostDir "holesail-browser-host.bat") -Encoding ASCII -$HostPath = Join-Path $HostDir "holesail-browser-host.bat" - -$manifestPath = Join-Path $RepoRoot "com.holesail.browser.json" -$manifest = Get-Content $manifestPath -Raw | ConvertFrom-Json -$manifest.path = $HostPath - -$manifestFile = Join-Path $env:LOCALAPPDATA "holesail-browser\com.holesail.browser.json" -$manifestDir = Split-Path $manifestFile -if (-not (Test-Path $manifestDir)) { New-Item -ItemType Directory -Path $manifestDir -Force | Out-Null } -$manifest | ConvertTo-Json -Depth 4 | Set-Content $manifestFile -Encoding UTF8 - -$chromeKey = "HKCU:\Software\Google\Chrome\NativeMessagingHosts\com.holesail.browser" -New-Item -Path $chromeKey -Force | Out-Null -Set-ItemProperty -Path $chromeKey -Name "(Default)" -Value $manifestFile -$ffKey = "HKCU:\Software\Mozilla\NativeMessagingHosts\com.holesail.browser" -New-Item -Path $ffKey -Force | Out-Null -Set-ItemProperty -Path $ffKey -Name "(Default)" -Value $manifestFile -Write-Host " Native host manifest: $manifestFile" - -# 2. Extension +Write-Host "Holesail Browser Installer" -ForegroundColor Cyan +Write-Host "==========================" -ForegroundColor Cyan +Write-Host "Install : $InstallDir" Write-Host "" -Write-Host "2. Preparing extension..." -$ExtDir = (Resolve-Path (Join-Path $RepoRoot "extension")).Path -if (-not (Test-Path (Join-Path $ExtDir "manifest.json"))) { - Write-Host "Error: extension/manifest.json not found." -ForegroundColor Red - exit 1 -} -Set-Clipboard -Value $ExtDir -$chromePaths = @( - "${env:ProgramFiles}\Google\Chrome\Application\chrome.exe", - "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe", - "${env:LocalAppData}\Google\Chrome\Application\chrome.exe" +# ── Uninstall any previous install ──────────────────────────────────────────── +Write-Host "Removing any previous installation..." +Get-Process | Where-Object { $_.Path -like "*holesail-browser-host*" } | Stop-Process -Force -ErrorAction SilentlyContinue +if (Test-Path $InstallDir) { Remove-Item $InstallDir -Recurse -Force } + +# Remove old registry entries +$RegPaths = @( + "HKCU:\Software\Google\Chrome\NativeMessagingHosts\$ManifestName", + "HKCU:\Software\Chromium\NativeMessagingHosts\$ManifestName", + "HKCU:\Software\Mozilla\NativeMessagingHosts\$ManifestName" ) -foreach ($p in $chromePaths) { - if (Test-Path $p) { - Start-Process $p -ArgumentList "chrome://extensions" - break - } +foreach ($p in $RegPaths) { + if (Test-Path $p) { Remove-Item $p -Force -ErrorAction SilentlyContinue } } +# ── Download ─────────────────────────────────────────────────────────────────── +New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null +New-Item -ItemType Directory -Path $Downloads -Force | Out-Null + +Write-Host "Downloading native host..." +$TmpZip = "$env:TEMP\$HostZip" +Invoke-WebRequest "$ReleaseBase/$HostZip" -OutFile $TmpZip +Expand-Archive -Path $TmpZip -DestinationPath $InstallDir -Force +Remove-Item $TmpZip + +# Find the binary +$HostBin = Get-ChildItem -Path $InstallDir -Recurse -Filter "holesail-browser-host.exe" | Select-Object -First 1 -ExpandProperty FullName +if (-not $HostBin) { + Write-Host "Error: binary not found in $HostZip" -ForegroundColor Red; exit 1 +} +Write-Host " Binary: $HostBin" + +Write-Host "Downloading extension..." +Invoke-WebRequest "$ReleaseBase/$ExtZip" -OutFile "$Downloads\$ExtZip" +Write-Host " Saved: $Downloads\$ExtZip" + +# ── Native messaging manifest ────────────────────────────────────────────────── +Write-Host "Installing native messaging manifest..." + +$ManifestFile = "$InstallDir\$ManifestName.json" +$Manifest = @{ + name = "com.holesail.browser" + description = "Holesail Browser native host" + path = $HostBin + type = "stdio" + allowed_origins = @("chrome-extension://fmcenppcipeikpnpopolicnllljclmmi/") + allowed_extensions = @("holesail-browser-58514e5bbfe0d5e3@example.org") +} | ConvertTo-Json -Depth 4 +Set-Content $ManifestFile -Value $Manifest -Encoding UTF8 + +foreach ($p in $RegPaths) { + New-Item -Path $p -Force | Out-Null + Set-ItemProperty -Path $p -Name "(Default)" -Value $ManifestFile + Write-Host " Registry: $p" +} + +# ── Done ─────────────────────────────────────────────────────────────────────── Write-Host "" -Write-Host "Done." -ForegroundColor Green +Write-Host "==========================" -ForegroundColor Green +Write-Host "Installation complete!" -ForegroundColor Green +Write-Host "" +Write-Host "Next steps:" +Write-Host "" +Write-Host " Chrome / Edge:" +Write-Host " 1. Open chrome://extensions" +Write-Host " 2. Enable Developer mode" +Write-Host " 3. Drag & drop $Downloads\$ExtZip onto the page" +Write-Host " (or click 'Load unpacked' after extracting)" +Write-Host "" +Write-Host " Then restart your browser." Write-Host "" -Write-Host "Next step: In the browser tab that opened, click 'Load unpacked' and paste this path:" -Write-Host " $ExtDir" -Write-Host "(Path is in your clipboard.) Then restart the browser." diff --git a/scripts/install.sh b/scripts/install.sh index 73e9806..c82dbe3 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,96 +1,131 @@ #!/usr/bin/env bash -# Unified installer for Holesail Browser (extension + native host). -# Run from anywhere: ./scripts/install.sh or cd holesail-browser && ./scripts/install.sh -set -e -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" -cd "$REPO_ROOT" - -echo "Holesail Browser – Install" -echo "=============================" - -# Require Node.js -if ! command -v node >/dev/null 2>&1; then - echo "Error: Node.js is required. Install from https://nodejs.org and run this script again." - exit 1 -fi - -# Ensure bare is available (required for native host) -if ! command -v bare >/dev/null 2>&1; then - echo "Installing Bare runtime (required for native host)..." - if npm install -g bare 2>/dev/null; then - echo "Bare installed." - else - echo "Warning: Could not install bare. Run: npm install -g bare" - echo "Continuing; native host may not work until bare is installed." - fi -fi - -# 1. Native host -echo "" -echo "1. Installing native host..." -HOST_DIR="$REPO_ROOT/native-host" -cd "$HOST_DIR" -npm install --no-fund --no-audit 2>/dev/null || npm install - - -# Build native host binary -echo "" -echo "1b. Building native host..." -cd "$REPO_ROOT" -npm install --no-fund --no-audit 2>/dev/null || npm install -npm run build:host -cd "$HOST_DIR" - -HOST_PATH="$HOST_DIR/holesail-browser-host" - -CHROME_DIR="$HOME/.config/google-chrome/NativeMessagingHosts" -CHROMIUM_DIR="$HOME/.config/chromium/NativeMessagingHosts" -FIREFOX_DIR="$HOME/.mozilla/native-messaging-hosts" -if [[ "$OSTYPE" == "darwin"* ]]; then - CHROME_DIR="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" - CHROMIUM_DIR="$HOME/Library/Application Support/Chromium/NativeMessagingHosts" - FIREFOX_DIR="$HOME/Library/Application Support/Mozilla/NativeMessagingHosts" -fi +# Holesail Browser Installer (macOS / Linux) +# Downloads the native host binary and extension from the latest release. +# +# Usage: +# curl -fsSL https://git.ssh.surf/snxraven/holesail-browser/raw/branch/main/scripts/install.sh | bash +set -euo pipefail +RELEASE_BASE="https://git.ssh.surf/snxraven/holesail-browser/releases/download/latest-main" +INSTALL_DIR="$HOME/.holesail-browser" MANIFEST_NAME="com.holesail.browser" -MANIFEST_CONTENT=$(sed "s|ABSOLUTE_PATH_TO_NATIVE_HOST|$HOST_PATH|g" "$REPO_ROOT/com.holesail.browser.json") -for dir in "$CHROME_DIR" "$CHROMIUM_DIR" "$FIREFOX_DIR"; do - mkdir -p "$dir" 2>/dev/null && echo "$MANIFEST_CONTENT" > "$dir/${MANIFEST_NAME}.json" && echo " Native host manifest: $dir" +DOWNLOADS="$HOME/Downloads" + +# ── Detect platform ──────────────────────────────────────────────────────────── +OS="$(uname -s | tr '[:upper:]' '[:lower:]')" +ARCH="$(uname -m)" +[[ "$ARCH" == "x86_64" ]] && ARCH="x64" +[[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]] && ARCH="arm64" +[[ "$OS" == "darwin" ]] && PLATFORM="darwin" +[[ "$OS" == "linux" ]] && PLATFORM="linux" + +if [[ -z "${PLATFORM:-}" ]]; then + echo "Unsupported OS: $OS" >&2; exit 1 +fi + +HOST_ZIP="holesail-browser-host-${PLATFORM}-${ARCH}.zip" +EXT_ZIP="Holesail-Browser-1.0.0.zip" +EXT_XPI="Holesail-Browser-1.0.0.xpi" + +echo "" +echo "Holesail Browser Installer" +echo "==========================" +echo "Platform : ${PLATFORM}-${ARCH}" +echo "Install : ${INSTALL_DIR}" +echo "" + +# ── Uninstall any previous local/source install ──────────────────────────────── +echo "Removing any previous installation..." +pkill -f "holesail-browser/native-host/index.mjs" 2>/dev/null || true +pkill -f "holesail-browser-host" 2>/dev/null || true +rm -rf "$INSTALL_DIR" + +# Remove old native messaging manifests +for dir in \ + "$HOME/.config/google-chrome/NativeMessagingHosts" \ + "$HOME/.config/chromium/NativeMessagingHosts" \ + "$HOME/.mozilla/native-messaging-hosts" \ + "$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" \ + "$HOME/Library/Application Support/Chromium/NativeMessagingHosts" \ + "$HOME/Library/Application Support/Mozilla/NativeMessagingHosts"; do + rm -f "${dir}/${MANIFEST_NAME}.json" 2>/dev/null || true done -# 2. Extension -echo "" -echo "2. Preparing extension..." -EXT_DIR="$REPO_ROOT/extension" -if [[ ! -f "$EXT_DIR/manifest.json" ]]; then - echo "Error: extension/manifest.json not found." - exit 1 -fi +# ── Download ─────────────────────────────────────────────────────────────────── +mkdir -p "$INSTALL_DIR" +mkdir -p "$DOWNLOADS" -if command -v pbcopy >/dev/null 2>&1; then - echo "$EXT_DIR" | pbcopy -elif command -v xclip >/dev/null 2>&1; then - echo -n "$EXT_DIR" | xclip -selection clipboard 2>/dev/null || true -elif command -v xsel >/dev/null 2>&1; then - echo -n "$EXT_DIR" | xsel --clipboard 2>/dev/null || true -fi +echo "Downloading native host..." +curl -fsSL "${RELEASE_BASE}/${HOST_ZIP}" -o "/tmp/${HOST_ZIP}" +unzip -q -o "/tmp/${HOST_ZIP}" -d "$INSTALL_DIR" +rm "/tmp/${HOST_ZIP}" -open_page() { - local url="$1" app="$2" - if [[ "$OSTYPE" == "darwin"* ]]; then - open -a "$app" "$url" 2>/dev/null && return 0 - fi - command -v xdg-open >/dev/null 2>&1 && xdg-open "$url" 2>/dev/null && return 0 - return 1 +# Find the binary (may be in a subdir inside the zip) +HOST_BIN="$(find "$INSTALL_DIR" -type f -name "holesail-browser-host" | head -1)" +if [[ -z "$HOST_BIN" ]]; then + echo "Error: binary not found in ${HOST_ZIP}" >&2; exit 1 +fi +chmod +x "$HOST_BIN" +echo " Binary: $HOST_BIN" + +echo "Downloading extension..." +curl -fsSL "${RELEASE_BASE}/${EXT_ZIP}" -o "${DOWNLOADS}/${EXT_ZIP}" +echo " Saved: ${DOWNLOADS}/${EXT_ZIP}" +# Also grab the .xpi for Firefox +curl -fsSL "${RELEASE_BASE}/${EXT_XPI}" -o "${DOWNLOADS}/${EXT_XPI}" 2>/dev/null || true + +# ── Native messaging manifest ────────────────────────────────────────────────── +echo "Installing native messaging manifest..." + +MANIFEST=$(cat < "${dir}/${MANIFEST_NAME}.json" + echo " Wrote: ${dir}/${MANIFEST_NAME}.json" +done + +# ── Done ─────────────────────────────────────────────────────────────────────── echo "" -echo "Done." +echo "==========================" +echo "Installation complete!" +echo "" +echo "Next steps:" +echo "" +echo " Chrome / Edge:" +echo " 1. Open chrome://extensions" +echo " 2. Enable Developer mode" +echo " 3. Drag & drop ${DOWNLOADS}/${EXT_ZIP} onto the page" +echo " (or click 'Load unpacked' after extracting)" +echo "" +echo " Firefox:" +echo " 1. Open about:addons" +echo " 2. Gear icon → Install Add-on From File" +echo " 3. Select ${DOWNLOADS}/${EXT_XPI}" +echo "" +echo " Then restart your browser." echo "" -echo "Next step: In the browser tab that opened, click 'Load unpacked' and paste this path:" -echo " $EXT_DIR" -echo "(Path is in your clipboard.) Then restart the browser." diff --git a/scripts/web-installer.sh b/scripts/web-installer.sh index b6bd4d4..08bff76 100644 --- a/scripts/web-installer.sh +++ b/scripts/web-installer.sh @@ -1,193 +1,7 @@ #!/usr/bin/env bash +# Holesail Browser — Web Installer (macOS / Linux) +# Downloads the native host binary and extension from the latest release. # # Usage: -# curl -fsSL https://ssh.surf/bridgeswarm/install.sh -o install.sh && bash install.sh -# - -set -euo pipefail - -echo "" -echo "╔══════════════════════════════════════════════════════════════════╗" -echo "║ 🌉 BridgeSwarm Installer ║" -echo "╚══════════════════════════════════════════════════════════════════╝" -echo "" - -cat << 'EOF' -This installer will set up BridgeSwarm on your computer: - - • Native Messaging Host → Enables browser ↔ network communication - • Browser Extension → Packaged to ~/Downloads for manual install - • Fixed Extension ID → No random IDs, stable across updates - -What's installed where: - • Software: ~/.bridgeswarm/ - • Extension: ~/Downloads/BridgeSwarm-*.zip (Chrome) / *.xpi (Firefox) - • Browser manifests: ~/.config/.../NativeMessagingHosts/ (Linux) - ~/Library/Application Support/.../NativeMessagingHosts/ (macOS) - %LOCALAPPDATA%/bridge-swarm/ (Windows) - -EOF - -echo "" - -if [ -t 1 ]; then - echo -n "Continue with installation? [y/N]: " - read -r answer - if [[ "${answer,,}" != "y" && "${answer,,}" != "yes" ]]; then - echo "Installation cancelled." - exit 0 - fi -fi - -echo "" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "" - -# 1. Install Node.js if missing -if ! command -v node >/dev/null 2>&1 || ! command -v npm >/dev/null 2>&1; then - echo "📦 Installing Node.js..." - if [[ "$OSTYPE" == "darwin"* ]]; then - command -v brew >/dev/null 2>&1 || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - brew install node - elif grep -qiE 'debian|ubuntu' /etc/os-release 2>/dev/null; then - curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - - sudo apt-get update && sudo apt-get install -y nodejs - elif grep -qi fedora /etc/os-release 2>/dev/null || command -v dnf >/dev/null; then - sudo dnf install -y nodejs - else - echo "⚠️ Please install Node.js manually from https://nodejs.org" - exit 1 - fi -fi - -# 2. git -if ! command -v git >/dev/null 2>&1; then - echo "📦 Installing git..." - [[ "$OSTYPE" == "darwin"* ]] && brew install git || sudo apt install -y git || sudo dnf install -y git || true -fi - -# 3. Clone / update to persistent location -INSTALL_DIR="$HOME/.bridgeswarm" -mkdir -p "$INSTALL_DIR" -cd "$INSTALL_DIR" || exit 1 - -if [ -d ".git" ]; then - echo "📥 Updating existing installation..." - git pull --ff-only origin main || { cd ..; rm -rf "$INSTALL_DIR"; git clone https://git.ssh.surf/snxraven/BridgeSwarm.git "$INSTALL_DIR"; cd "$INSTALL_DIR"; } -else - echo "📥 Cloning BridgeSwarm..." - git clone https://git.ssh.surf/snxraven/BridgeSwarm.git . -fi - -# 4. Build -echo "🔨 Building bundles and codegen..." -npm ci --no-audit --prefer-offline --no-fund -cd native-host && npm ci --no-audit --prefer-offline --no-fund || npm install --no-audit --no-fund -cd .. -npm run build - -# 5. Package the extension -echo "📦 Packaging extension..." -npm run pack - -# 6. Copy to ~/Downloads -DOWNLOADS_DIR="$HOME/Downloads" -mkdir -p "$DOWNLOADS_DIR" -ZIP_FILE=$(ls releases/BridgeSwarm-*.zip 2>/dev/null | head -1) -XPI_FILE=$(ls releases/BridgeSwarm-*.xpi 2>/dev/null | head -1) - -if [ -n "$ZIP_FILE" ]; then - cp "$ZIP_FILE" "$DOWNLOADS_DIR/" - echo "✅ Extension saved to ~/Downloads/$(basename "$ZIP_FILE")" -fi -if [ -n "$XPI_FILE" ]; then - cp "$XPI_FILE" "$DOWNLOADS_DIR/" - echo "✅ Firefox extension saved to ~/Downloads/$(basename "$XPI_FILE")" -fi - -# 7. Install native host + manifest -echo "🔧 Installing native messaging host..." - -HOST_WRAPPER="$INSTALL_DIR/native-host/bridge-swarm-host" -chmod +x "$HOST_WRAPPER" 2>/dev/null || true - -MANIFEST_NAME="com.bridgeswarm" -MANIFEST_TEMPLATE="$INSTALL_DIR/com.bridgeswarm.json" -MANIFEST_CONTENT=$(sed "s|ABSOLUTE_PATH_TO_NATIVE_HOST|$HOST_WRAPPER|g" "$MANIFEST_TEMPLATE") - -CHROME_DIRS=( - "$HOME/.config/google-chrome/NativeMessagingHosts" - "$HOME/.config/chromium/NativeMessagingHosts" - "$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" - "$HOME/Library/Application Support/Chromium/NativeMessagingHosts" -) -FIREFOX_DIR="$HOME/.mozilla/native-messaging-hosts" - -for dir in "${CHROME_DIRS[@]}" "$FIREFOX_DIR"; do - mkdir -p "$dir" 2>/dev/null - echo "$MANIFEST_CONTENT" > "$dir/$MANIFEST_NAME.json" - echo " ✅ Installed: $dir/$MANIFEST_NAME.json" -done - -# 8. Try open browser -echo "" -echo "🌐 Opening browser extension page..." - -open_page() { - local url="$1" app="$2" - if [[ "$OSTYPE" == "darwin"* ]]; then - open -a "$app" "$url" 2>/dev/null && return 0 - fi - command -v xdg-open >/dev/null 2>&1 && xdg-open "$url" 2>/dev/null && return 0 - return 1 -} - -open_page "chrome://extensions" "Google Chrome" || \ - open_page "chrome://extensions" "Chromium" || \ - open_page "chrome://extensions" "Microsoft Edge" || { - echo "⚠️ Could not auto-open browser. Please open manually:" - echo " Chrome/Edge: chrome://extensions/" - echo " Firefox: about:addons" - } - -echo "" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo " ✅ Installation Complete!" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "" - -cat << INSTALL_EOF - -📋 NEXT STEPS - Install the Extension - -Chrome / Edge: - 1. In the browser that opened, enable "Developer mode" (top right) - 2. Click "Unpack extension" - 3. Extract ~/Downloads/BridgeSwarm-1.0.0.zip to a folder - 4. Click "Load unpacked" and select the extracted folder - 5. Your extension ID should be: fmcenppcipeikpnpopolicnllljclmmi - -Firefox: - 1. Go to about:addons - 2. Click the gear icon → "Install Add-on From File" - 3. Select ~/Downloads/BridgeSwarm-1.0.0.xpi - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -🧪 Test it: - • Open: $INSTALL_DIR/examples/chat/index.html - • In browser console: BridgeSwarm → should show the constructor - -📁 Files: - • Extension: ~/Downloads/BridgeSwarm-1.0.0.zip - • Software: ~/.bridgeswarm/ - -🔄 To update later: run the same install command again - -INSTALL_EOF - -echo "" -echo "📍 Extension file path copied to clipboard!" -echo "$DOWNLOADS_DIR/BridgeSwarm-1.0.0.zip" | pbcopy 2>/dev/null || \ - echo "$DOWNLOADS_DIR/BridgeSwarm-1.0.0.zip" | xclip -sel clip 2>/dev/null || \ - echo "$DOWNLOADS_DIR/BridgeSwarm-1.0.0.zip" | xsel -ib 2>/dev/null || true +# curl -fsSL https://git.ssh.surf/snxraven/holesail-browser/raw/branch/main/scripts/web-installer.sh | bash +exec bash <(curl -fsSL https://git.ssh.surf/snxraven/holesail-browser/raw/branch/main/scripts/install.sh)