/** * One-liner install commands for the native host, by platform. * Used by the onboarding card when the native host is not found. * Mirrored in Holesail (`renderer/dashboard/data/install-commands.js`). * Testable from Node (see test/install-commands.test.js). */ const INSTALL_SCRIPT_BASE_URL = 'https://git.ssh.surf/snxraven/holesail-browser/raw/branch/main/scripts/'; /** * @param {string} baseUrl - Base URL for scripts (no trailing slash; we add / before filename). * @param {'macos'|'linux'|'win32'} platform * @returns {{ label: string, command: string }} */ function getInstallCommand(baseUrl, platform) { const base = baseUrl.replace(/\/?$/, '/'); if (platform === 'win32') { return { label: 'Windows (PowerShell)', command: `irm ${base}install.ps1 | iex` }; } if (platform === 'macos' || platform === 'linux') { return { label: platform === 'macos' ? 'macOS' : 'Linux', command: `curl -fsSL ${base}web-installer.sh | bash` }; } return { label: 'macOS / Linux', command: `curl -fsSL ${base}web-installer.sh | bash` }; } /** * Detect platform from navigator (browser only). Returns 'win32' | 'macos' | 'linux'. */ function detectPlatform() { if (typeof navigator === 'undefined' || !navigator.platform) return 'linux'; const p = navigator.platform.toLowerCase(); if (p.includes('win')) return 'win32'; if (p.includes('mac')) return 'macos'; return 'linux'; } if (typeof module !== 'undefined' && module.exports) { module.exports = { getInstallCommand, detectPlatform, INSTALL_SCRIPT_BASE_URL }; }