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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 5536 additions and 5497 deletions

View file

@ -1,51 +1,59 @@
import * as core from '@actions/core'
import * as path from 'path'
import {downloadVersion, tryGetFromToolCache} from './download/download-version'
import {restoreCache} from './cache/restore-cache'
import * as core from "@actions/core";
import * as path from "path";
import {
downloadVersion,
tryGetFromToolCache,
} from "./download/download-version";
import { restoreCache } from "./cache/restore-cache";
import {downloadLatest} from './download/download-latest'
import {Architecture, getArch, getPlatform, Platform} from './utils/platforms'
import { downloadLatest } from "./download/download-latest";
import {
Architecture,
getArch,
getPlatform,
Platform,
} from "./utils/platforms";
import {
cacheLocalPath,
checkSum,
enableCache,
githubToken,
version
} from './utils/inputs'
version,
} from "./utils/inputs";
async function run(): Promise<void> {
const platform = getPlatform()
const arch = getArch()
const platform = getPlatform();
const arch = getArch();
try {
if (platform === undefined) {
throw new Error(`Unsupported platform: ${process.platform}`)
throw new Error(`Unsupported platform: ${process.platform}`);
}
if (arch === undefined) {
throw new Error(`Unsupported architecture: ${process.arch}`)
throw new Error(`Unsupported architecture: ${process.arch}`);
}
const setupResult = await setupUv(
platform,
arch,
version,
checkSum,
githubToken
)
githubToken,
);
addUvToPath(setupResult.uvDir)
core.setOutput('uv-version', version)
core.info(`Successfully installed uv version ${version}`)
addUvToPath(setupResult.uvDir);
core.setOutput("uv-version", version);
core.info(`Successfully installed uv version ${version}`);
addMatchers()
setCacheDir(cacheLocalPath)
addMatchers();
setCacheDir(cacheLocalPath);
if (enableCache) {
await restoreCache(setupResult.version)
await restoreCache(setupResult.version);
}
} catch (err) {
core.setFailed((err as Error).message)
core.setFailed((err as Error).message);
}
process.exit(0)
process.exit(0);
}
async function setupUv(
@ -53,47 +61,47 @@ async function setupUv(
arch: Architecture,
versionInput: string,
checkSum: string | undefined,
githubToken: string | undefined
): Promise<{uvDir: string; version: string}> {
let installedPath: string | undefined
let cachedToolDir: string
let version: string
if (versionInput === 'latest') {
const result = await downloadLatest(platform, arch, checkSum, githubToken)
version = result.version
cachedToolDir = result.cachedToolDir
githubToken: string | undefined,
): Promise<{ uvDir: string; version: string }> {
let installedPath: string | undefined;
let cachedToolDir: string;
let version: string;
if (versionInput === "latest") {
const result = await downloadLatest(platform, arch, checkSum, githubToken);
version = result.version;
cachedToolDir = result.cachedToolDir;
} else {
version = versionInput
installedPath = tryGetFromToolCache(arch, versionInput)
version = versionInput;
installedPath = tryGetFromToolCache(arch, versionInput);
if (installedPath) {
core.info(`Found uv in tool-cache for ${versionInput}`)
return {uvDir: installedPath, version}
core.info(`Found uv in tool-cache for ${versionInput}`);
return { uvDir: installedPath, version };
}
cachedToolDir = await downloadVersion(
platform,
arch,
versionInput,
checkSum,
githubToken
)
githubToken,
);
}
return {uvDir: cachedToolDir, version}
return { uvDir: cachedToolDir, version };
}
function addUvToPath(cachedPath: string): void {
core.addPath(cachedPath)
core.info(`Added ${cachedPath} to the path`)
core.addPath(cachedPath);
core.info(`Added ${cachedPath} to the path`);
}
function setCacheDir(cacheLocalPath: string): void {
core.exportVariable('UV_CACHE_DIR', cacheLocalPath)
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`)
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
}
function addMatchers(): void {
const matchersPath = path.join(__dirname, `..${path.sep}..`, '.github')
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`)
const matchersPath = path.join(__dirname, `..${path.sep}..`, ".github");
core.info(`##[add-matcher]${path.join(matchersPath, "python.json")}`);
}
run()
run();