Skip to content
Open
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
42 changes: 42 additions & 0 deletions apps/code/scripts/download-binaries.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
existsSync,
mkdirSync,
realpathSync,
renameSync,
rmSync,
} from "node:fs";
import { dirname, join } from "node:path";
Expand Down Expand Up @@ -47,6 +48,40 @@ const BINARIES = [
return target;
},
},
{
name: "codex",
version: "0.140.0",
getUrl: (version, target) => {
if (target.includes("windows")) {
return `https://github.com/openai/codex/releases/download/rust-v${version}/codex-${target}.exe.zip`;
}
return `https://github.com/openai/codex/releases/download/rust-v${version}/codex-${target}.tar.gz`;
},
getTarget: () => {
const { platform, arch } = process;
const targets = {
darwin: { arm64: "aarch64-apple-darwin", x64: "x86_64-apple-darwin" },
linux: {
arm64: "aarch64-unknown-linux-musl",
x64: "x86_64-unknown-linux-musl",
},
win32: {
arm64: "aarch64-pc-windows-msvc",
x64: "x86_64-pc-windows-msvc",
},
};
const platformTargets = targets[platform];
if (!platformTargets)
throw new Error(`Unsupported platform: ${platform}`);
const target = platformTargets[arch];
if (!target) throw new Error(`Unsupported arch: ${arch}`);
return target;
},
// The codex release archive contains a target-suffixed binary
// (e.g. `codex-aarch64-apple-darwin`); rename it to `codex` after extract.
archiveBinaryName: (target) =>
process.platform === "win32" ? `codex-${target}.exe` : `codex-${target}`,
},
{
name: "rg",
version: "15.0.0",
Expand Down Expand Up @@ -159,6 +194,13 @@ async function downloadBinary(binary) {
await extractArchive(archivePath, DEST_DIR);
rmSync(archivePath);

if (binary.archiveBinaryName) {
const extractedPath = join(DEST_DIR, binary.archiveBinaryName(target));
if (extractedPath !== binaryPath && existsSync(extractedPath)) {
renameSync(extractedPath, binaryPath);
}
}

if (!existsSync(binaryPath)) {
throw new Error(`Binary not found after extraction: ${binaryPath}`);
}
Expand Down
Loading
Loading