Support toml spec 1.0.0 (#245)

iarna/toml is unmaintained.
Replaced by smol-toml which is maintained and has the same api

Fixes: #242
This commit is contained in:
Kevin Stillhammer 2025-01-16 16:38:18 +01:00 committed by GitHub
parent 4e3dbecc19
commit b5f58b2abc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 1350 additions and 2777 deletions

116
dist/update-known-checksums/index.js generated vendored
View file

@ -34751,39 +34751,28 @@ var __importStar = (this && this.__importStar) || (function () {
return result;
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.updateChecksums = updateChecksums;
const node_fs_1 = __nccwpck_require__(3024);
const tc = __importStar(__nccwpck_require__(3472));
const known_checksums_1 = __nccwpck_require__(2764);
function updateChecksums(filePath, downloadUrls) {
return __awaiter(this, void 0, void 0, function* () {
yield node_fs_1.promises.rm(filePath);
yield node_fs_1.promises.appendFile(filePath, "// AUTOGENERATED_DO_NOT_EDIT\nexport const KNOWN_CHECKSUMS: { [key: string]: string } = {\n");
let firstLine = true;
for (const downloadUrl of downloadUrls) {
const key = getKey(downloadUrl);
if (key === undefined) {
continue;
}
const checksum = yield getOrDownloadChecksum(key, downloadUrl);
if (!firstLine) {
yield node_fs_1.promises.appendFile(filePath, ",\n");
}
yield node_fs_1.promises.appendFile(filePath, ` "${key}":\n "${checksum}"`);
firstLine = false;
async function updateChecksums(filePath, downloadUrls) {
await node_fs_1.promises.rm(filePath);
await node_fs_1.promises.appendFile(filePath, "// AUTOGENERATED_DO_NOT_EDIT\nexport const KNOWN_CHECKSUMS: { [key: string]: string } = {\n");
let firstLine = true;
for (const downloadUrl of downloadUrls) {
const key = getKey(downloadUrl);
if (key === undefined) {
continue;
}
yield node_fs_1.promises.appendFile(filePath, ",\n};\n");
});
const checksum = await getOrDownloadChecksum(key, downloadUrl);
if (!firstLine) {
await node_fs_1.promises.appendFile(filePath, ",\n");
}
await node_fs_1.promises.appendFile(filePath, ` "${key}":\n "${checksum}"`);
firstLine = false;
}
await node_fs_1.promises.appendFile(filePath, ",\n};\n");
}
function getKey(downloadUrl) {
// https://github.com/astral-sh/uv/releases/download/0.3.2/uv-aarch64-apple-darwin.tar.gz.sha256
@ -34796,25 +34785,21 @@ function getKey(downloadUrl) {
const version = parts[parts.length - 2];
return `${name}-${version}`;
}
function getOrDownloadChecksum(key, downloadUrl) {
return __awaiter(this, void 0, void 0, function* () {
let checksum = "";
if (key in known_checksums_1.KNOWN_CHECKSUMS) {
checksum = known_checksums_1.KNOWN_CHECKSUMS[key];
}
else {
const content = yield downloadAssetContent(downloadUrl);
checksum = content.split(" ")[0].trim();
}
return checksum;
});
async function getOrDownloadChecksum(key, downloadUrl) {
let checksum = "";
if (key in known_checksums_1.KNOWN_CHECKSUMS) {
checksum = known_checksums_1.KNOWN_CHECKSUMS[key];
}
else {
const content = await downloadAssetContent(downloadUrl);
checksum = content.split(" ")[0].trim();
}
return checksum;
}
function downloadAssetContent(downloadUrl) {
return __awaiter(this, void 0, void 0, function* () {
const downloadPath = yield tc.downloadTool(downloadUrl);
const content = yield node_fs_1.promises.readFile(downloadPath, "utf8");
return content;
});
async function downloadAssetContent(downloadUrl) {
const downloadPath = await tc.downloadTool(downloadUrl);
const content = await node_fs_1.promises.readFile(downloadPath, "utf8");
return content;
}
@ -34858,39 +34843,28 @@ var __importStar = (this && this.__importStar) || (function () {
return result;
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const github = __importStar(__nccwpck_require__(3228));
const core = __importStar(__nccwpck_require__(7484));
const constants_1 = __nccwpck_require__(6156);
const semver = __importStar(__nccwpck_require__(9318));
const update_known_checksums_1 = __nccwpck_require__(6182);
function run() {
return __awaiter(this, void 0, void 0, function* () {
const checksumFilePath = process.argv.slice(2)[0];
const github_token = process.argv.slice(2)[1];
const octokit = github.getOctokit(github_token, { baseUrl: constants_1.GITHUB_COM_API });
const response = yield octokit.paginate(octokit.rest.repos.listReleases, {
owner: constants_1.OWNER,
repo: constants_1.REPO,
});
const downloadUrls = response.flatMap((release) => release.assets
.filter((asset) => asset.name.endsWith(".sha256"))
.map((asset) => asset.browser_download_url));
yield (0, update_known_checksums_1.updateChecksums)(checksumFilePath, downloadUrls);
const latestVersion = response
.map((release) => release.tag_name)
.sort(semver.rcompare)[0];
core.setOutput("latest-version", latestVersion);
async function run() {
const checksumFilePath = process.argv.slice(2)[0];
const github_token = process.argv.slice(2)[1];
const octokit = github.getOctokit(github_token, { baseUrl: constants_1.GITHUB_COM_API });
const response = await octokit.paginate(octokit.rest.repos.listReleases, {
owner: constants_1.OWNER,
repo: constants_1.REPO,
});
const downloadUrls = response.flatMap((release) => release.assets
.filter((asset) => asset.name.endsWith(".sha256"))
.map((asset) => asset.browser_download_url));
await (0, update_known_checksums_1.updateChecksums)(checksumFilePath, downloadUrls);
const latestVersion = response
.map((release) => release.tag_name)
.sort(semver.rcompare)[0];
core.setOutput("latest-version", latestVersion);
}
run();