CI / Build & Test (push) Successful in 3m19s
- Add install-command helper (getInstallCommand + platform detection) with OS-specific one-liners and configurable base URL - Show onboarding card on Overview when !hostConnected: copy button, platform switcher (macOS/Linux / Windows), and "Check again" button - "Check again" triggers refresh and shows success/disconnected toast - refresh() returns state so callers can react to hostConnected - Add unit tests for install-commands (all platforms, base URL) - Document "Native host not found" flow in README and INSTALLATION
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
/**
|
|
* One-liner install commands for the native host, by platform.
|
|
* Used by the onboarding card when the native host is not found.
|
|
* 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 };
|
|
}
|