From e9c433bcf07de9b13b4a1d56e20e6eb55980451b Mon Sep 17 00:00:00 2001 From: Jack Hughes Date: Mon, 20 May 2024 19:56:08 -0600 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20a=20button=20to=20reset=20the?= =?UTF-8?q?=20PROS=20conductor=20file=20(#224)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * pros c reset button Works * fix prettier warning automated CI run of prettier is bugged * run prettier on new file please pass ci check * Allow conductor reset regardless of vscode context Co-authored-by: BennyBot <48661356+BennyBot@users.noreply.github.com> * Add package.json entry for resetConductor --------- Co-authored-by: BennyBot <48661356+BennyBot@users.noreply.github.com> --- package.json | 4 ++++ src/commands/index.ts | 1 + src/commands/reset-conductor.ts | 21 +++++++++++++++++++++ src/extension.ts | 2 ++ src/views/tree-view.ts | 1 + 5 files changed, 29 insertions(+) create mode 100644 src/commands/reset-conductor.ts diff --git a/package.json b/package.json index bcc0f10..55e97dc 100644 --- a/package.json +++ b/package.json @@ -165,6 +165,10 @@ "command": "pros.infoProject", "title": "PROS: Project Information" }, + { + "command": "pros.resetConductor", + "title": "PROS: Reset Conductor" + }, { "command": "pros.welcome", "title": "PROS: Welcome" diff --git a/src/commands/index.ts b/src/commands/index.ts index 0d40187..d746718 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -16,3 +16,4 @@ export * from "./set-team-number"; export * from "./set-robot-name"; export * from "./runvision"; export * from "./info-project"; +export * from "./reset-conductor"; diff --git a/src/commands/reset-conductor.ts b/src/commands/reset-conductor.ts new file mode 100644 index 0000000..ad000b7 --- /dev/null +++ b/src/commands/reset-conductor.ts @@ -0,0 +1,21 @@ +import * as vscode from "vscode"; +import { BaseCommand, BaseCommandOptions } from "./base-command"; + +export const resetConductor = async () => { + const resetConductorCommandOptions: BaseCommandOptions = { + command: "pros", + args: ["c", "reset"], //--force not needed: Ben's base-commands class auto-handles warning + confirmation. + message: "Resetting Conductor", + requiresProsProject: false, + successMessage: + "Conductor Reset Successfully. Any templates and/or depots previously cached will need to be re-fetched.", + }; + const resetConductorCommand: BaseCommand = new BaseCommand( + resetConductorCommandOptions + ); + try { + await resetConductorCommand.runCommand(); + } catch (err: any) { + await vscode.window.showErrorMessage(err.message); + } +}; diff --git a/src/extension.ts b/src/extension.ts index e919114..d28e2dd 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -30,6 +30,7 @@ import { setRobotName, runVision, getCurrentKernelOkapiVersion, + resetConductor, } from "./commands"; import { ProsProjectEditorProvider } from "./views/editor"; import { Analytics } from "./ga"; @@ -229,6 +230,7 @@ export async function activate(context: vscode.ExtensionContext) { setupCommandBlocker("pros.upgrade", upgradeProject); setupCommandBlocker("pros.new", createNewProject); setupCommandBlocker("pros.infoProject", infoProject); + setupCommandBlocker("pros.resetConductor", resetConductor); // Beta commands (notice the fourth argument is set to true for these) setupCommandBlocker("pros.installVision", installVision, context, true); diff --git a/src/views/tree-view.ts b/src/views/tree-view.ts index e0fd47a..47774a6 100644 --- a/src/views/tree-view.ts +++ b/src/views/tree-view.ts @@ -36,6 +36,7 @@ export class TreeDataProvider implements vscode.TreeDataProvider { new TreeItem("Upgrade Project", undefined, "pros.upgrade"), new TreeItem("Create Project", undefined, "pros.new"), new TreeItem("Project/Template Info", undefined, "pros.infoProject"), + new TreeItem("Reset Conductor", undefined, "pros.resetConductor"), // open branchline will go here in the future ]), new TreeItem("Manage Installations", [