From e1435f2b0c9cb309361623f1dc45c54cbd58e2f8 Mon Sep 17 00:00:00 2001 From: Sanjula Ganepola Date: Wed, 27 Nov 2024 00:17:30 -0500 Subject: [PATCH] Add message to update act command Signed-off-by: Sanjula Ganepola --- src/act.ts | 31 ++++++++++++++++++++----------- src/componentsManager.ts | 6 +++++- src/configurationManager.ts | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/act.ts b/src/act.ts index ef9445a..c4b9139 100644 --- a/src/act.ts +++ b/src/act.ts @@ -2,7 +2,7 @@ import * as childProcess from "child_process"; import * as fs from "fs/promises"; import * as path from "path"; import sanitize from "sanitize-filename"; -import { CustomExecution, env, EventEmitter, ExtensionContext, Pseudoterminal, ShellExecution, TaskDefinition, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, TaskScope, TerminalDimensions, Uri, window, workspace, WorkspaceFolder } from "vscode"; +import { commands, CustomExecution, env, EventEmitter, ExtensionContext, Pseudoterminal, ShellExecution, TaskDefinition, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, TaskScope, TerminalDimensions, Uri, window, workspace, WorkspaceFolder } from "vscode"; import { ComponentsManager } from "./componentsManager"; import { ConfigurationManager, Platform, Section } from "./configurationManager"; import { componentsTreeDataProvider, historyTreeDataProvider } from './extension'; @@ -70,8 +70,8 @@ export interface CommandArgs { } export class Act { - static command: string = 'act'; - static githubCliCommand: string = 'gh act'; + static defaultActCommand: string = 'act'; + static githubCliActCommand: string = 'gh act'; context: ExtensionContext; storageManager: StorageManager; secretManager: SecretManager; @@ -175,20 +175,29 @@ export class Act { tasks.onDidEndTaskProcess(async e => { const taskDefinition = e.execution.task.definition; if (taskDefinition.type === 'nektos/act installation' && e.exitCode === 0) { - // Update base act command based on installation method - if (taskDefinition.ghCliInstall) { - await ConfigurationManager.set(Section.actCommand, Act.githubCliCommand); - } else { - await ConfigurationManager.set(Section.actCommand, Act.command); - } - + this.updateActCommand(taskDefinition.ghCliInstall ? Act.githubCliActCommand : Act.defaultActCommand); componentsTreeDataProvider.refresh(); } }); } static getActCommand() { - return ConfigurationManager.get(Section.actCommand) || Act.command; + return ConfigurationManager.get(Section.actCommand) || Act.defaultActCommand; + } + + updateActCommand(newActCommand: string) { + const actCommand = ConfigurationManager.get(Section.actCommand); + + if (newActCommand !== actCommand) { + window.showInformationMessage(`The act command is currently set to "${actCommand}". Once the installation is complete, it is recommended to update this to "${newActCommand}" for this selected installation method.`, 'Proceed', 'Manually Edit').then(async value => { + if (value === 'Proceed') { + await ConfigurationManager.set(Section.actCommand, newActCommand); + componentsTreeDataProvider.refresh(); + } else if (value === 'Manually Edit') { + await commands.executeCommand('workbench.action.openSettings', ConfigurationManager.getSearchTerm(Section.actCommand)); + } + }); + } } async runAllWorkflows(workspaceFolder: WorkspaceFolder) { diff --git a/src/componentsManager.ts b/src/componentsManager.ts index bbdaaf9..1ace6dd 100644 --- a/src/componentsManager.ts +++ b/src/componentsManager.ts @@ -115,6 +115,8 @@ export class ComponentsManager { } }); } + + act.updateActCommand(Act.defaultActCommand); } else if (selectedInstallationMethod.link) { await env.openExternal(Uri.parse(selectedInstallationMethod.link)); window.showInformationMessage('Once nektos/act is successfully installed, add it to your shell\'s PATH and then refresh the components view.', 'Refresh').then(async value => { @@ -122,6 +124,8 @@ export class ComponentsManager { componentsTreeDataProvider.refresh(); } }); + + act.updateActCommand(Act.defaultActCommand); } else { await act.install(selectedInstallationMethod.label); } @@ -232,7 +236,7 @@ export class ComponentsManager { problemMatchers: [], runOptions: {}, group: TaskGroup.Build, - execution: new ShellExecution('sudo groupadd docker; sudo usermod -aG docker $USER; newgrp docker') + execution: new ShellExecution('sudo groupadd docker; sudo usermod -aG docker $USER') }); window.withProgress({ location: { viewId: ComponentsTreeDataProvider.VIEW_ID } }, async () => { diff --git a/src/configurationManager.ts b/src/configurationManager.ts index e6c8c84..4d38acd 100644 --- a/src/configurationManager.ts +++ b/src/configurationManager.ts @@ -35,7 +35,7 @@ export namespace ConfigurationManager { let actCommand = ConfigurationManager.get(Section.actCommand); if (!actCommand) { - await ConfigurationManager.set(Section.actCommand, Act.command); + await ConfigurationManager.set(Section.actCommand, Act.defaultActCommand); } }