Change Prettier settings (#36)

## Summary

I know this is a little tedious but I'd prefer to use the same settings
as in Ruff.
This commit is contained in:
Charlie Marsh
2024-09-05 08:06:45 -04:00
committed by GitHub
parent 1785c7bde0
commit 182c9c7e92
32 changed files with 5536 additions and 5497 deletions

View File

@ -1,39 +1,39 @@
import {promises as fs} from 'fs'
import * as tc from '@actions/tool-cache'
import { promises as fs } from "fs";
import * as tc from "@actions/tool-cache";
export async function updateChecksums(
filePath: string,
downloadUrls: string[]
downloadUrls: string[],
): Promise<void> {
await fs.rm(filePath)
await fs.rm(filePath);
await fs.appendFile(
filePath,
'// AUTOGENERATED_DO_NOT_EDIT\nexport const KNOWN_CHECKSUMS: {[key: string]: string} = {\n'
)
let firstLine = true
"// AUTOGENERATED_DO_NOT_EDIT\nexport const KNOWN_CHECKSUMS: {[key: string]: string} = {\n",
);
let firstLine = true;
for (const downloadUrl of downloadUrls) {
const content = await downloadAssetContent(downloadUrl)
const checksum = content.split(' ')[0].trim()
const key = getKey(downloadUrl)
const content = await downloadAssetContent(downloadUrl);
const checksum = content.split(" ")[0].trim();
const key = getKey(downloadUrl);
if (!firstLine) {
await fs.appendFile(filePath, ',\n')
await fs.appendFile(filePath, ",\n");
}
await fs.appendFile(filePath, ` '${key}':\n '${checksum}'`)
firstLine = false
await fs.appendFile(filePath, ` '${key}':\n '${checksum}'`);
firstLine = false;
}
await fs.appendFile(filePath, '}\n')
await fs.appendFile(filePath, "}\n");
}
function getKey(downloadUrl: string): string {
// https://github.com/astral-sh/uv/releases/download/0.3.2/uv-aarch64-apple-darwin.tar.gz.sha256
const parts = downloadUrl.split('/')
const fileName = parts[parts.length - 1]
const name = fileName.split('.')[0].split('uv-')[1]
const version = parts[parts.length - 2]
return `${name}-${version}`
const parts = downloadUrl.split("/");
const fileName = parts[parts.length - 1];
const name = fileName.split(".")[0].split("uv-")[1];
const version = parts[parts.length - 2];
return `${name}-${version}`;
}
async function downloadAssetContent(downloadUrl: string): Promise<string> {
const downloadPath = await tc.downloadTool(downloadUrl)
const content = await fs.readFile(downloadPath, 'utf8')
return content
const downloadPath = await tc.downloadTool(downloadUrl);
const content = await fs.readFile(downloadPath, "utf8");
return content;
}