Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/components/CliDownloads.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down
17 changes: 15 additions & 2 deletions src/lib/cli-releases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ const PLATFORMS = [
{ platform: 'Windows', arch: 'ARM64', key: 'windows-arm64' },
] as const;

async function fetchLatestVersion(): Promise<string> {
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';
Expand All @@ -38,8 +52,7 @@ function buildBinaries(version: string): CliBinary[] {
}

export async function getLatestRcRelease(): Promise<CliRelease> {
const response = await fetch(`${BINARIES_BASE_URL}/client/rc.txt`);
const version = await response.text();
const version = await fetchLatestVersion();

return {
version,
Expand Down
Loading