From c7d93229e2c8bc14727229ce9b8266664b30ef8c Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Mon, 14 Oct 2024 18:59:15 -0400 Subject: [PATCH] run prettier :) --- src/one-click/download.ts | 32 +++++++++++--------- src/one-click/install.ts | 60 +++++++++++++++++++++++++++----------- src/one-click/installed.ts | 27 +++++++++-------- 3 files changed, 76 insertions(+), 43 deletions(-) diff --git a/src/one-click/download.ts b/src/one-click/download.ts index e32d1f5..b9a0fb9 100644 --- a/src/one-click/download.ts +++ b/src/one-click/download.ts @@ -24,12 +24,13 @@ async function download( await prosLogger.log("OneClick", `Storage Path: ${storagePath}`); downloadName = - "Downloading: " + (downloadName ?? - (storagePath.includes("cli") - ? "PROS CLI" - : storagePath.includes("toolchain") - ? "PROS Toolchain" - : "VEX Vexcom")); + "Downloading: " + + (downloadName ?? + (storagePath.includes("cli") + ? "PROS CLI" + : storagePath.includes("toolchain") + ? "PROS Toolchain" + : "VEX Vexcom")); await window.withProgress( { @@ -84,12 +85,13 @@ export async function extract( ) { await prosLogger.log("OneClick", `Extracting ${storagePath}`); extractName = - "Installing: " + (extractName ?? - (storagePath.includes("cli") - ? "PROS CLI" - : storagePath.includes("toolchain") - ? "PROS Toolchain" - : "VEX Vexcom")); + "Installing: " + + (extractName ?? + (storagePath.includes("cli") + ? "PROS CLI" + : storagePath.includes("toolchain") + ? "PROS Toolchain" + : "VEX Vexcom")); await window.withProgress( { location: ProgressLocation.Notification, @@ -110,14 +112,16 @@ export async function extract( await new Promise(function (resolve, reject) { // Create our read stream prosLogger.log("OneClick", `Creating read stream for ${storagePath}`); - const stats = fs.statSync(path.join(globalPath, "download", storagePath)); + const stats = fs.statSync( + path.join(globalPath, "download", storagePath) + ); const totalSize = stats.size; read = fs.createReadStream( path.join(globalPath, "download", storagePath) ); var decompress = new lzma.createDecompressor(); decompress.on("data", (chunk: Buffer | string | any) => { - _progress.report({ increment: (chunk.length * 100) / totalSize}); + _progress.report({ increment: (chunk.length * 100) / totalSize }); }); // Remove tar from the filename storagePath = storagePath.replace(".tar.xz", ""); diff --git a/src/one-click/install.ts b/src/one-click/install.ts index de9aee1..43fd5f3 100644 --- a/src/one-click/install.ts +++ b/src/one-click/install.ts @@ -3,7 +3,11 @@ import * as vscode from "vscode"; import * as path from "path"; import * as os from "os"; import { downloadextract, chmod } from "./download"; -import { getCurrentVersion, getCurrentReleaseVersion, getToolchainVersion } from "./installed"; +import { + getCurrentVersion, + getCurrentReleaseVersion, + getToolchainVersion, +} from "./installed"; import * as fs from "fs"; import { promisify } from "util"; import * as child_process from "child_process"; @@ -141,7 +145,7 @@ async function getUrls( await prosLogger.log("OneClick", `MacOS detected, using MacOS URLS`); // Set system, path seperator, and downloads to windows version cliArch = "macos-64bit"; - toolchainArch = (os.arch() === "x64") ? "darwin-x86_64" : "darwin-arm64"; + toolchainArch = os.arch() === "x64" ? "darwin-x86_64" : "darwin-arm64"; vexcomArch = "osx"; } else { await prosLogger.log("OneClick", `Linux detected, using Linux URLS`); @@ -151,7 +155,7 @@ async function getUrls( if (operatingSystem === "windows") { var downloadToolchain = `https://github.com/purduesigbots/toolchain/releases/download/${toolchainVersion}/pros-toolchain-windows-formatted.zip`; } else { - let toolchainSemver = semver.parse(toolchainVersion, {loose: true}); + let toolchainSemver = semver.parse(toolchainVersion, { loose: true }); toolchainVersion = `${toolchainSemver?.major}.${toolchainSemver?.minor}.rel${toolchainSemver?.patch}`; var downloadToolchain = `https://developer.arm.com/-/media/Files/downloads/gnu/${toolchainVersion}/binrel/arm-gnu-toolchain-${toolchainVersion}-${toolchainArch}-arm-none-eabi.tar.xz`; } @@ -281,13 +285,14 @@ export async function install(context: vscode.ExtensionContext) { "pros" ) ); - let [currentToolchainVersion, isToolchainOneClickInstall] = await getToolchainVersion( - path.join( - `${addQuotes ? `"` : ""}${toolchainExecPath}${addQuotes ? `"` : ""}`, - "bin", - "arm-none-eabi-g++" - ) - ); + let [currentToolchainVersion, isToolchainOneClickInstall] = + await getToolchainVersion( + path.join( + `${addQuotes ? `"` : ""}${toolchainExecPath}${addQuotes ? `"` : ""}`, + "bin", + "arm-none-eabi-g++" + ) + ); const cliWorking = currentCliVersion !== "0.0.0"; const toolchainWorking = currentToolchainVersion !== "0.0.0"; const vexcomWorking = await verifyVexcom(); @@ -326,8 +331,12 @@ export async function install(context: vscode.ExtensionContext) { console.log("Vexcom Working: " + vexcomWorking); // Does the user's CLI have an update or does the user need to install/update - const cliUpToDate = cliWorking ? semver.gte(currentCliVersion, cliVersion) : false; - const toolchainUpToDate = toolchainWorking ? semver.gte(currentToolchainVersion, toolchainVersion, {loose: true}) : false; + const cliUpToDate = cliWorking + ? semver.gte(currentCliVersion, cliVersion) + : false; + const toolchainUpToDate = toolchainWorking + ? semver.gte(currentToolchainVersion, toolchainVersion, { loose: true }) + : false; await prosLogger.log( "OneClick", `${cliUpToDate ? "CLI is up to date" : "CLI is not up to date"}`, @@ -344,7 +353,11 @@ export async function install(context: vscode.ExtensionContext) { ); await prosLogger.log( "OneClick", - `${toolchainUpToDate ? "Toolchain is up to date" : "To0lchain is not up to date"}`, + `${ + toolchainUpToDate + ? "Toolchain is up to date" + : "To0lchain is not up to date" + }`, toolchainUpToDate ? "INFO" : "WARNING" ); await prosLogger.log( @@ -375,7 +388,13 @@ export async function install(context: vscode.ExtensionContext) { await preparingInstall.stop(); //if everything works and cli is up to date, do nothing - if (cliWorking && toolchainWorking && cliUpToDate && toolchainUpToDate && vexcomWorking) { + if ( + cliWorking && + toolchainWorking && + cliUpToDate && + toolchainUpToDate && + vexcomWorking + ) { return; } @@ -475,7 +494,13 @@ async function promptInstall( toolchainUpToDate: boolean, vexcomWorking: boolean ) { - if (cliWorking && cliUpToDate && toolchainWorking && toolchainUpToDate && vexcomWorking) { + if ( + cliWorking && + cliUpToDate && + toolchainWorking && + toolchainUpToDate && + vexcomWorking + ) { vscode.window.showInformationMessage( "Everything is currently working and up to date." ); @@ -627,8 +652,9 @@ export async function configurePaths( "pros" ) ); - process.env["PROS_VSCODE_FLAGS"] = - semver.gte(version, "3.2.4") ? "--no-sentry --no-analytics" : ""; + process.env["PROS_VSCODE_FLAGS"] = semver.gte(version, "3.2.4") + ? "--no-sentry --no-analytics" + : ""; await prosLogger.log( "OneClick", `CLI is installed through ${ diff --git a/src/one-click/installed.ts b/src/one-click/installed.ts index 1693391..5fbc31a 100644 --- a/src/one-click/installed.ts +++ b/src/one-click/installed.ts @@ -41,8 +41,7 @@ export async function getCurrentVersion( }, } ); - const version = stdout - .replace("pros, version ", ""); + const version = stdout.replace("pros, version ", ""); return [version, true]; } catch { try { @@ -53,8 +52,7 @@ export async function getCurrentVersion( PATH: getChildProcessPath(), }, }); - const version = stdout - .replace("pros, version ", ""); + const version = stdout.replace("pros, version ", ""); return [version, false]; } catch (err) { console.log(`Error fetching PROS CLI version: ${err}`); @@ -68,7 +66,9 @@ export async function getCurrentVersion( } } -export async function getToolchainVersion(oneClickPath: string): Promise<[string, boolean]> { +export async function getToolchainVersion( + oneClickPath: string +): Promise<[string, boolean]> { try { console.log(oneClickPath); prosLogger.log( @@ -88,13 +88,16 @@ export async function getToolchainVersion(oneClickPath: string): Promise<[string return [stdout, true]; } catch { try { - const { stdout } = await promisify(child_process.exec)(`arm-none-eabi-g++ --version`, { - env: { - ...process.env, - // eslint-disable-next-line @typescript-eslint/naming-convention - PATH: getChildProcessPath(), - }, - }); + const { stdout } = await promisify(child_process.exec)( + `arm-none-eabi-g++ --version`, + { + env: { + ...process.env, + // eslint-disable-next-line @typescript-eslint/naming-convention + PATH: getChildProcessPath(), + }, + } + ); return [stdout, false]; } catch (err) { console.log(`Error fetching PROS toolchain version: ${err}`);