Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
keroxp committed Jun 17, 2024
1 parent 615de5c commit b0f33c3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35817,21 +35817,20 @@ exports.getLatestVersion = getLatestVersion;
async function downloadCage({ version, token, }) {
console.log("🥚 Installing cage...");
const gh = (0, github_1.getOctokit)(token);
const platform = node_os_1.default.platform();
const arch = node_os_1.default.arch();
const platformArch = getPlatformArch();
const list = await gh.rest.repos.listReleases({
owner: "loilo-inc",
repo: "canarycage",
});
const release = list.data.find((release) => release.tag_name === version);
if (!release)
throw new Error(`Version ${version} not found`);
const asset = release.assets.find((asset) => asset.name === `canarycage_${platform}_${arch}.zip`);
const asset = release.assets.find((asset) => asset.name === `canarycage_${platformArch}.zip`);
const checksums = release.assets.find((asset) => asset.name === `canarycage_${version}_checksums.txt`);
if (!checksums)
throw new Error(`Checksums not found for ${version}`);
if (!asset)
throw new Error(`Asset not found for ${platform}_${arch}`);
throw new Error(`Asset not found for ${platformArch}`);
console.assert(asset.url.startsWith("https://github.com/"), "asset.url is not valid: %s", asset.url);
console.assert(checksums.url.startsWith("https://github.com/"), "checksums.url is not valid: %s", checksums.url);
const checksumsContent = await tc.downloadTool(checksums.url);
Expand All @@ -35851,6 +35850,14 @@ async function downloadCage({ version, token, }) {
console.log(`🐣 cage has been installed at '${installed}/cage'`);
}
exports.downloadCage = downloadCage;
function getPlatformArch() {
const platform = node_os_1.default.platform();
let arch = node_os_1.default.arch();
if (arch === "x64") {
arch = "amd64";
}
return `${platform}_${arch}`;
}
async function parseChecksum(file) {
const buf = await promises_1.default.readFile(file, "utf-8");
const entries = buf
Expand Down

0 comments on commit b0f33c3

Please sign in to comment.