Skip to content

fix: temporarially pin to specific binary version #116

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

Merged
merged 2 commits into from
Jan 23, 2025
Merged
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
45 changes: 27 additions & 18 deletions src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,37 @@ export async function getDenoDownloadUrl(
}

const name = FILENAMES[key];

const url = canary ? DENO_CANARY_INFO_URL : DENO_RELEASE_INFO_URL;
const res = await fetch(url);
if (!res.ok) {
await res.body?.cancel();
throw new Error(
`${res.status}: Unable to retrieve ${
canary ? "canary" : "release"
} version information from ${url}.`,
);
}
const version = (await res.text()).trim();

const filename = name + ".zip";

return {
canary,
url: canary
? `https://dl.deno.land/canary/${decodeURI(version)}/${filename}`
: `https://dl.deno.land/release/${decodeURI(version)}/${filename}`,
canary: false,
url:
`https://dl.deno.land/canary/c38dbe500b0a5815f4b07d4a6b696c5fdf622dc0/${filename}`,
filename,
version: version,
version: "c38dbe500b0a5815f4b07d4a6b696c5fdf622dc0",
};

// TEMPORARIALLY FORCE USE OF VERSION c38dbe500b0a5815f4b07d4a6b696c5fdf622dc0
// const url = canary ? DENO_CANARY_INFO_URL : DENO_RELEASE_INFO_URL;
// const res = await fetch(url);
// if (!res.ok) {
// await res.body?.cancel();
// throw new Error(
// `${res.status}: Unable to retrieve ${
// canary ? "canary" : "release"
// } version information from ${url}.`,
// );
// }
// const version = (await res.text()).trim();

// return {
// canary,
// url: canary
// ? `https://dl.deno.land/canary/${decodeURI(version)}/${filename}`
// : `https://dl.deno.land/release/${decodeURI(version)}/${filename}`,
// filename,
// version: version,
// };
}

export async function downloadDeno(
Expand Down
8 changes: 7 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ export async function findProjectDir(
// prefer bun.lockb over yarn.lock
// In some cases, both bun.lockb and yarn.lock can exist in the same project.
// https://bun.sh/docs/install/lockfile
const bunLockfile = path.join(dir, "bun.lockb");
const bunbLockfile = path.join(dir, "bun.lockb");
if (await fileExists(bunbLockfile)) {
logDebug(`Detected bun from lockfile ${bunbLockfile}`);
result.pkgManagerName = "bun";
return result;
}
const bunLockfile = path.join(dir, "bun.lock");
if (await fileExists(bunLockfile)) {
logDebug(`Detected bun from lockfile ${bunLockfile}`);
result.pkgManagerName = "bun";
Expand Down
8 changes: 4 additions & 4 deletions test/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ describe("install", () => {
["i", "--bun", "--save-dev", "@std/[email protected]"],
async (dir) => {
assert.ok(
await isFile(path.join(dir, "bun.lockb")),
await isFile(path.join(dir, "bun.lock")),
"bun lockfile not created",
);
const pkgJson = await readJson<PkgJson>(
Expand Down Expand Up @@ -333,7 +333,7 @@ describe("install", () => {
["i", "--bun", "--save-optional", "@std/[email protected]"],
async (dir) => {
assert.ok(
await isFile(path.join(dir, "bun.lockb")),
await isFile(path.join(dir, "bun.lock")),
"bun lockfile not created",
);
const pkgJson = await readJson<PkgJson>(
Expand Down Expand Up @@ -440,7 +440,7 @@ describe("install", () => {
["i", "--bun", "@std/[email protected]"],
async (dir) => {
assert.ok(
await isFile(path.join(dir, "bun.lockb")),
await isFile(path.join(dir, "bun.lock")),
"bun lockfile not created",
);

Expand Down Expand Up @@ -584,7 +584,7 @@ describe("install", () => {
["i", "@std/[email protected]"],
async (dir) => {
assert.ok(
await isFile(path.join(dir, "bun.lockb")),
await isFile(path.join(dir, "bun.lock")),
"bun lockfile not created",
);
},
Expand Down
8 changes: 8 additions & 0 deletions test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ describe("findProjectDir", () => {
});
});

it("should return bun if bun.lock is found", async () => {
await runInTempDir(async (tempDir) => {
await writeTextFile(path.join(tempDir, "bun.lock"), "");
const result = await findProjectDir(tempDir);
assert.strictEqual(result.pkgManagerName, "bun");
});
});

it("should return bun if bun.lockb and yarn.lock are found", async () => {
// bun allow to save bun.lockb and yarn.lock
// https://bun.sh/docs/install/lockfile
Expand Down
Loading