Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudflared supports arm64 now #24

Merged
merged 2 commits into from
Aug 6, 2024
Merged
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
16 changes: 13 additions & 3 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const LINUX_URL: Partial<Record<typeof process.arch, string>> = {
};

const MACOS_URL: Partial<Record<typeof process.arch, string>> = {
arm64: "cloudflared-darwin-amd64.tgz",
arm64: "cloudflared-darwin-arm64.tgz",
x64: "cloudflared-darwin-amd64.tgz",
};

Expand Down Expand Up @@ -60,10 +60,15 @@ export async function install_linux(to: string, version = CLOUDFLARED_VERSION):
}

export async function install_macos(to: string, version = CLOUDFLARED_VERSION): Promise<string> {
const file = MACOS_URL[process.arch];
let arch = process.arch;
if (version !== "latest" && version_number(version) < 20240802) {
// arm64 is only supported starting from 2024.8.2
arch = "x64";
}
const file = MACOS_URL[arch];

if (file === undefined) {
throw new UnsupportedError("Unsupported architecture: " + process.arch);
throw new UnsupportedError("Unsupported architecture: " + arch);
}

await download(resolve_base(version) + file, `${to}.tgz`);
Expand Down Expand Up @@ -130,3 +135,8 @@ function download(url: string, to: string, redirect = 0): Promise<string> {
request.end();
});
}

function version_number(semver: string): number {
const [major, minor, patch] = semver.split(".").map(Number);
return major * 10000 + minor * 100 + patch;
}
Loading