diff --git a/src/components/CliDownloads.astro b/src/components/CliDownloads.astro index 2de3c74..4f253c8 100644 --- a/src/components/CliDownloads.astro +++ b/src/components/CliDownloads.astro @@ -16,12 +16,11 @@ const instructions = [ steps: [ { label: 'Download the binary', - code: `curl -LO ${darwinArm64.url}`, + code: `curl -LO \\\n ${darwinArm64.url}`, }, { label: 'Verify checksum (recommended)', - code: `curl -LO ${darwinArm64.checksumUrl} -shasum -a 256 -c ${darwinArm64.filename}.sha256`, + code: `curl -sL ${darwinArm64.checksumUrl} \\\n | awk '{print $1 " ${darwinArm64.filename}"}' | shasum -a 256 -c`, }, { label: 'Extract and install', @@ -36,12 +35,11 @@ sudo mv sprite /usr/local/bin/`, steps: [ { label: 'Download the binary', - code: `curl -LO ${linuxAmd64.url}`, + code: `curl -LO \\\n ${linuxAmd64.url}`, }, { label: 'Verify checksum (recommended)', - code: `curl -LO ${linuxAmd64.checksumUrl} -sha256sum -c ${linuxAmd64.filename}.sha256`, + code: `curl -sL ${linuxAmd64.checksumUrl} \\\n | awk '{print $1 " ${linuxAmd64.filename}"}' | sha256sum -c`, }, { label: 'Extract and install', @@ -56,7 +54,7 @@ sudo mv sprite /usr/local/bin/`, steps: [ { label: 'Download the binary', - code: `Invoke-WebRequest -Uri "${windowsAmd64.url}" -OutFile "${windowsAmd64.filename}"`, + code: `Invoke-WebRequest \`\n -Uri "${windowsAmd64.url}" \`\n -OutFile "${windowsAmd64.filename}"`, }, { label: 'Extract to your bin directory', diff --git a/src/lib/cli-releases.ts b/src/lib/cli-releases.ts index 07a1d8f..2978b8f 100644 --- a/src/lib/cli-releases.ts +++ b/src/lib/cli-releases.ts @@ -22,6 +22,20 @@ const PLATFORMS = [ { platform: 'Windows', arch: 'ARM64', key: 'windows-arm64' }, ] as const; +async function fetchLatestVersion(): Promise { + const response = await fetch(`${BINARIES_BASE_URL}/client/rc.txt`); + if (!response.ok) { + throw new Error( + `Failed to fetch latest RC version: ${response.statusText}`, + ); + } + const version = (await response.text()).trim(); + if (!version) { + throw new Error('Empty version string from rc.txt'); + } + return version; +} + function buildBinaries(version: string): CliBinary[] { return PLATFORMS.map(({ platform, arch, key }) => { const ext = key.startsWith('windows') ? 'zip' : 'tar.gz'; @@ -38,8 +52,7 @@ function buildBinaries(version: string): CliBinary[] { } export async function getLatestRcRelease(): Promise { - const response = await fetch(`${BINARIES_BASE_URL}/client/rc.txt`); - const version = await response.text(); + const version = await fetchLatestVersion(); return { version,