From c29e5eb5f6e8dd2258b3a40bbffae31ac7d7c0d9 Mon Sep 17 00:00:00 2001 From: BennyBot <48661356+BennyBot@users.noreply.github.com> Date: Mon, 20 May 2024 21:56:34 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Use=20tag=20versions=20to=20sele?= =?UTF-8?q?ct=20CLI=20version=20on=20welcome=20screen=20(#225)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Andrew Lu --- package-lock.json | 4 ++-- src/extension.ts | 6 ++++-- src/views/welcome-view.ts | 40 --------------------------------------- 3 files changed, 6 insertions(+), 44 deletions(-) diff --git a/package-lock.json b/package-lock.json index b95b452..5317363 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pros", - "version": "0.7.0", + "version": "0.7.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pros", - "version": "0.7.0", + "version": "0.7.1", "license": "SEE LICENSE IN LICENSE.txt", "dependencies": { "@purduesigbots/pros-cli-middleware": "^2.5.2", diff --git a/src/extension.ts b/src/extension.ts index d28e2dd..894b223 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -9,7 +9,6 @@ import { promisify } from "util"; import { TreeDataProvider } from "./views/tree-view"; import { getWebviewContent, - fetchCliVersion, fetchKernelVersionNonCLIDependent, } from "./views/welcome-view"; import { @@ -56,6 +55,7 @@ import { import { startPortMonitoring } from "./device"; import { BrainViewProvider } from "./views/brain-view"; import { populateDocsJSON, debugDocsJson } from "./views/docs-webscrape"; +import { getCurrentReleaseVersion } from "./one-click/installed"; /** * COMMAND BLOCKER SECTION @@ -379,7 +379,9 @@ export async function activate(context: vscode.ExtensionContext) { // This gets the kernel version so we can display it on the welcome page const newKernel = await fetchKernelVersionNonCLIDependent(); // This gets the CLI version so we can display it on the welcome page - const newCli = await fetchCliVersion(); + const newCli = await getCurrentReleaseVersion( + "https://api.github.com/repos/purduesigbots/pros-cli/releases/latest" + ); // Setup google analytics preference and welcome page display preference const useGoogleAnalytics = diff --git a/src/views/welcome-view.ts b/src/views/welcome-view.ts index 3364d42..bf3f18f 100644 --- a/src/views/welcome-view.ts +++ b/src/views/welcome-view.ts @@ -14,40 +14,6 @@ var fetch = require("node-fetch"); * * @returns The kernel library versions */ -export const fetchKernelVersion = async (): Promise => { - try { - const { stdout, stderr } = await promisify(child_process.exec)( - `pros c q --target v5 --machine-output`, - { - env: { - ...process.env, - // eslint-disable-next-line @typescript-eslint/naming-convention - PATH: getChildProcessPath(), - }, - } - ); - - let newKernel = "0.0.0"; - - for (let e of stdout.split(/\r?\n/)) { - if (e.startsWith(PREFIX)) { - let jdata = JSON.parse(e.substr(PREFIX.length)); - if (jdata.type === "finalize") { - for (let ver of jdata.data) { - if (ver.name === "kernel" && gt(ver.version, newKernel)) { - newKernel = ver.version; - } - } - } - } - } - - return newKernel; - } catch (error) { - return "0.0.0"; - } -}; - export const fetchKernelVersionNonCLIDependent = async (): Promise => { const response = await fetch( "https://api.github.com/repos/purduesigbots/pros/releases/latest" @@ -59,12 +25,6 @@ export const fetchKernelVersionNonCLIDependent = async (): Promise => { var v = (await response.json()).tag_name; return v; }; -export const fetchCliVersion = async (): Promise => { - const response = await axios.get( - "https://purduesigbots.github.io/pros-mainline/stable/UpgradeManifestV1.json" - ); - return `${response.data.version.major}.${response.data.version.minor}.${response.data.version.patch}`; -}; export function getWebviewContent( styleUri: vscode.Uri,