Skip to content

Commit

Permalink
🐛 Use tag versions to select CLI version on welcome screen (#225)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Lu <[email protected]>
  • Loading branch information
BennyBot and AndrewLuGit authored May 21, 2024
1 parent e9c433b commit c29e5eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 44 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { promisify } from "util";
import { TreeDataProvider } from "./views/tree-view";
import {
getWebviewContent,
fetchCliVersion,
fetchKernelVersionNonCLIDependent,
} from "./views/welcome-view";
import {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
40 changes: 0 additions & 40 deletions src/views/welcome-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,6 @@ var fetch = require("node-fetch");
*
* @returns The kernel library versions
*/
export const fetchKernelVersion = async (): Promise<string> => {
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<string> => {
const response = await fetch(
"https://api.github.com/repos/purduesigbots/pros/releases/latest"
Expand All @@ -59,12 +25,6 @@ export const fetchKernelVersionNonCLIDependent = async (): Promise<string> => {
var v = (await response.json()).tag_name;
return v;
};
export const fetchCliVersion = async (): Promise<string> => {
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,
Expand Down

0 comments on commit c29e5eb

Please sign in to comment.