diff --git a/src/lib/server/install-script.test.ts b/src/lib/server/install-script.test.ts index 42d10eb..480b636 100644 --- a/src/lib/server/install-script.test.ts +++ b/src/lib/server/install-script.test.ts @@ -136,7 +136,7 @@ describe('generateInstallScript', () => { expect(script).toContain('#!/bin/bash'); expect(script).toContain('OpenBoot Installer'); expect(script).toContain('Config: @testuser/my-config'); - expect(script).toContain('brew install ${TAP_NAME}/openboot'); + expect(script).toContain('api.github.com/repos/${OPENBOOT_REPO}/releases/latest'); expect(script).toContain('--user "testuser/my-config"'); }); @@ -182,13 +182,13 @@ describe('generateInstallScript', () => { expect(script).not.toContain('my config!'); }); - it('should install openboot via Homebrew tap', () => { + it('should install openboot via GitHub releases', () => { const script = generateInstallScript('testuser', 'my-config'); - expect(script).toContain('TAP_NAME="openbootdotdev/tap"'); - expect(script).toContain('brew install ${TAP_NAME}/openboot'); - expect(script).toContain('brew list openboot'); - expect(script).toContain('Reinstall? (y/N)'); + expect(script).toContain('OPENBOOT_REPO="openbootdotdev/openboot"'); + expect(script).toContain('api.github.com/repos/${OPENBOOT_REPO}/releases/latest'); + expect(script).toContain('install_openboot()'); + expect(script).toContain('github.com/${OPENBOOT_REPO}/releases/download/${latest_version}/openboot-'); }); it('should pass through additional arguments to openboot', () => { diff --git a/src/lib/server/install-script.ts b/src/lib/server/install-script.ts index fa5b6be..f07f1b2 100644 --- a/src/lib/server/install-script.ts +++ b/src/lib/server/install-script.ts @@ -105,7 +105,7 @@ export function generateInstallScript( return `#!/bin/bash set -euo pipefail -TAP_NAME="openbootdotdev/tap" +OPENBOOT_REPO="openbootdotdev/openboot" main() { # When run via "curl | bash", stdin is the script content, not the terminal. @@ -205,39 +205,48 @@ install_homebrew() { echo "" } -local os arch -os=\$(detect_os) -arch=\$(detect_arch) +install_openboot() { + local os_name="\$1" + local arch_name="\$2" -echo "Detected: \${os}/\${arch}" -echo "" + echo "Fetching latest OpenBoot version..." + local latest_version + latest_version=\$(curl -fsSL "https://api.github.com/repos/\${OPENBOOT_REPO}/releases/latest" \\ + | grep '"tag_name"' | grep -o 'v[0-9][0-9.]*') -install_xcode_clt -install_homebrew + if [[ -z "\$latest_version" ]]; then + echo "Error: Could not fetch latest OpenBoot version" >&2 + exit 1 + fi + + local binary_url="https://github.com/\${OPENBOOT_REPO}/releases/download/\${latest_version}/openboot-\${os_name}-\${arch_name}" -if brew list openboot &>/dev/null 2>&1; then - echo "OpenBoot is already installed via Homebrew." + echo "Installing OpenBoot \${latest_version}..." echo "" - read -p "Reinstall? (y/N) " -n 1 -r - echo - - if [[ \$REPLY =~ ^[Yy]\$ ]]; then - echo "Reinstalling OpenBoot..." - brew reinstall \${TAP_NAME}/openboot - echo "" - echo "OpenBoot reinstalled!" + + curl -fsSL "\$binary_url" -o /tmp/openboot-install + chmod +x /tmp/openboot-install + + if [[ -w "/usr/local/bin" ]]; then + mv /tmp/openboot-install /usr/local/bin/openboot else - echo "Using existing installation." + sudo mv /tmp/openboot-install /usr/local/bin/openboot fi -else - echo "Installing OpenBoot via Homebrew..." + echo "" + echo "OpenBoot \${latest_version} installed!" +} - brew install \${TAP_NAME}/openboot +local os arch +os=\$(detect_os) +arch=\$(detect_arch) - echo "" - echo "OpenBoot installed!" -fi +echo "Detected: \${os}/\${arch}" +echo "" + +install_xcode_clt +install_homebrew +install_openboot "\$os" "\$arch" echo "" echo "Starting OpenBoot setup with config: @${safeUsername}/${safeSlug}"