diff --git a/cmd/upgrade.ts b/cmd/upgrade.ts index 64c1497e..c71d1a99 100644 --- a/cmd/upgrade.ts +++ b/cmd/upgrade.ts @@ -1,21 +1,13 @@ import { dirname } from "@std/path"; -export function upgradeCommand() { - // TODO: Update this before a proper release - console.log("Not implemented yet"); -} - -export async function upgradeEdgeCommand() { - console.log("Now going to attempt an edge upgrade..."); - +async function upgrade(urlPrefix: string) { const installDir = dirname(Deno.execPath()); console.log("Install dir:", installDir); const tmpDir = Deno.makeTempDirSync(); - // const zipUrl = "https://github.com/silverbulletmd/silverbullet/releases/download/test-release/silverbullet-server-apple-aarch64.zip"; - const zipUrl = - `https://github.com/silverbulletmd/silverbullet/releases/download/edge/silverbullet-server-${Deno.build.os}-${Deno.build.arch}.zip`; + const zipUrl = urlPrefix + + `/silverbullet-server-${Deno.build.os}-${Deno.build.arch}.zip`; const zipPath = `${tmpDir}/silverbullet.zip`; console.log("Downloading from", zipUrl); const command = new Deno.Command("curl", { @@ -59,3 +51,17 @@ export async function upgradeEdgeCommand() { await Deno.remove(zipPath); console.log("And done! Restart your server to get the latest and greatest!"); } + +export async function upgradeCommand() { + console.log("Now going to attempt an upgrade..."); + await upgrade( + "https://github.com/silverbulletmd/silverbullet/releases/latest/download", + ); +} + +export async function upgradeEdgeCommand() { + console.log("Now going to attempt an edge upgrade..."); + await upgrade( + "https://github.com/silverbulletmd/silverbullet/releases/download/edge", + ); +}