mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 21:15:57 +03:00
fix(console): pass download channels through and alias stable to latest (#60778)
This commit is contained in:
@@ -1,17 +1,7 @@
|
||||
import type { APIEvent } from "@solidjs/start/server"
|
||||
import type { DownloadPlatform } from "../types"
|
||||
|
||||
const prodAssetNames: Record<string, string> = {
|
||||
"darwin-aarch64-dmg": "opencode-desktop-mac-arm64.dmg",
|
||||
"darwin-x64-dmg": "opencode-desktop-mac-x64.dmg",
|
||||
"windows-aarch64-nsis": "opencode-desktop-win-arm64.exe",
|
||||
"windows-x64-nsis": "opencode-desktop-win-x64.exe",
|
||||
"linux-x64-deb": "opencode-desktop-linux-amd64.deb",
|
||||
"linux-x64-appimage": "opencode-desktop-linux-x86_64.AppImage",
|
||||
"linux-x64-rpm": "opencode-desktop-linux-x86_64.rpm",
|
||||
} satisfies Record<DownloadPlatform, string>
|
||||
|
||||
const betaAssetNames: Record<string, string> = {
|
||||
const assetNames: Record<string, string> = {
|
||||
"darwin-aarch64-dmg": "opencode-desktop-mac-arm64.dmg",
|
||||
"darwin-x64-dmg": "opencode-desktop-mac-x64.dmg",
|
||||
"windows-aarch64-nsis": "opencode-desktop-win-arm64.exe",
|
||||
@@ -22,11 +12,14 @@ const betaAssetNames: Record<string, string> = {
|
||||
} satisfies Record<DownloadPlatform, string>
|
||||
|
||||
export async function GET({ params: { platform, channel } }: APIEvent) {
|
||||
const assetName = channel === "stable" ? prodAssetNames[platform] : betaAssetNames[platform]
|
||||
const assetName = assetNames[platform]
|
||||
if (!assetName) return new Response(null, { status: 404 })
|
||||
|
||||
// `stable` is the old name for `latest` and what the download page linked to for months. Keep it as a permanent
|
||||
// alias: ~10% of /download/stable/* traffic (~45k requests a week, Oct 2026) comes from outside opencode.ai,
|
||||
// including bookmarks, other sites and curl/wget scripts.
|
||||
const release = await fetch(
|
||||
`https://opencode.ai/update/api/${channel === "stable" ? "latest" : "beta"}/desktop/opencode`,
|
||||
`https://opencode.ai/update/api/${channel === "stable" ? "latest" : encodeURIComponent(channel)}/desktop/opencode`,
|
||||
)
|
||||
if (!release.ok) return new Response(null, { status: release.status })
|
||||
const location = getAssetUrl(await release.json(), assetName)
|
||||
|
||||
@@ -13,8 +13,8 @@ import { useI18n } from "~/context/i18n"
|
||||
import { useLanguage } from "~/context/language"
|
||||
import type { DownloadPlatform } from "./types"
|
||||
|
||||
function getDownloadHref(platform: DownloadPlatform, channel: "stable" | "beta" = "stable") {
|
||||
return `/download/${channel}/${platform}`
|
||||
function getDownloadHref(platform: DownloadPlatform) {
|
||||
return `/download/latest/${platform}`
|
||||
}
|
||||
|
||||
function CopyStatus() {
|
||||
|
||||
Reference in New Issue
Block a user