Skip to content

Commit

Permalink
Download correct OSS binary based on OS (#29074)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 747565cb17ddb179175faae1269ee6abf7466d63
  • Loading branch information
sshader authored and Convex, Inc. committed Aug 21, 2024
1 parent a8d77b7 commit 4371ebd
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions npm-packages/convex/src/cli/lib/localDeployment/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,16 @@ async function checkForExistingDownload(
}

async function downloadBinary(ctx: Context, version: string): Promise<string> {
// TODO(ENG-7077) download the file depending on the platform
const downloadPath = getDownloadPath();
if (downloadPath === null) {
return await ctx.crash({
exitCode: 1,
errorType: "fatal",
printedMessage: `Unsupported platform ${process.platform} and architecture ${process.arch} for local deployment.`,
});
}
const response = await fetch(
`https://github.com/get-convex/convex-backend/releases/download/${version}/convex-local-backend-aarch64-apple-darwin.zip`,
`https://github.com/get-convex/convex-backend/releases/download/${version}/${downloadPath}`,
);
logMessage(ctx, "Downloading convex backend");
if (!ctx.fs.exists(binariesDir())) {
Expand Down Expand Up @@ -242,3 +249,25 @@ export async function ensureBackendStopped(
export function localDeploymentUrl(cloudPort: number): string {
return `http://127.0.0.1:${cloudPort}`;
}

function getDownloadPath() {
switch (process.platform) {
case "darwin":
if (process.arch === "arm64") {
return "convex-local-backend-aarch64-apple-darwin.zip";
} else if (process.arch === "x64") {
return "convex-local-backend-x86_64-apple-darwin.zip";
}
break;
case "linux":
if (process.arch === "arm64") {
return "convex-local-backend-aarch64-unknown-linux-gnu.zip";
} else if (process.arch === "x64") {
return "convex-local-backend-x86_64-unknown-linux-gnu.zip";
}
break;
case "win32":
return "convex-local-backend-x86_64-pc-windows-msvc.zip";
}
return null;
}

0 comments on commit 4371ebd

Please sign in to comment.