From b0e07549a67f014c918395e5982939b950fb4ce4 Mon Sep 17 00:00:00 2001 From: Sanjula Ganepola Date: Sun, 24 Nov 2024 23:40:47 -0500 Subject: [PATCH] Fix act not found when installed as github cli extension Signed-off-by: Sanjula Ganepola --- package.json | 5 +++++ src/act.ts | 13 +++++++++++-- src/configurationManager.ts | 7 +++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c863b5..6029881 100644 --- a/package.json +++ b/package.json @@ -685,6 +685,11 @@ "configuration": { "title": "GitHub Local Actions", "properties": { + "githubLocalActions.actCommand": { + "markdownDescription": "The base `nektos/act` command to be called. By default, this will be `act` (requires the binary to be on your `PATH`). If the binary is not on your `PATH`, the command can be fully qualified. If `act` is installed as a GitHub CLI extension, this command should be set to `gh act`.", + "type": "string", + "default": "act" + }, "githubLocalActions.dockerDesktopPath": { "type": "string", "markdownDescription": "The path to your Docker Desktop executable (used for Windows and MacOS). To start Docker Engine from the `Components` view, this application will be launched. Refer to the default path based on OS:\n\n* **Windows**: `C:/Program Files/Docker/Docker/Docker Desktop.exe`\n\n* **MacOS**: `/Applications/Docker.app`", diff --git a/src/act.ts b/src/act.ts index dc84b68..9df35fe 100644 --- a/src/act.ts +++ b/src/act.ts @@ -2,6 +2,7 @@ import * as path from "path"; import sanitize from "sanitize-filename"; import { ExtensionContext, ShellExecution, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, TaskScope, Uri, window, workspace, WorkspaceFolder } from "vscode"; import { ComponentsManager } from "./componentsManager"; +import { ConfigurationManager, Section } from "./configurationManager"; import { componentsTreeDataProvider, historyTreeDataProvider } from './extension'; import { HistoryManager, HistoryStatus } from './historyManager'; import { SecretManager } from "./secretManager"; @@ -66,7 +67,8 @@ export interface CommandArgs { } export class Act { - private static base: string = 'act'; + static command: string = 'act'; + static githubCliCommand: string = 'act'; context: ExtensionContext; storageManager: StorageManager; secretManager: SecretManager; @@ -305,10 +307,11 @@ export class Act { } catch (error: any) { } // Build command with settings + const actCommand = ConfigurationManager.get(Section.actCommand) || Act.command; const settings = await this.settingsManager.getSettings(workspaceFolder, true); const command = `set -o pipefail; ` + - `${Act.base} ${commandArgs.options}` + + `${actCommand} ${commandArgs.options}` + (settings.secrets.length > 0 ? ` ${Option.Secret} ${settings.secrets.map(secret => secret.key).join(` ${Option.Secret} `)}` : ``) + (settings.secretFiles.length > 0 ? ` ${Option.SecretFile} "${settings.secretFiles[0].path}"` : ` ${Option.SecretFile} ""`) + (settings.variables.length > 0 ? ` ${Option.Variable} ${settings.variables.map(variable => (variable.value ? `${variable.key}=${variable.value}` : variable.key)).join(` ${Option.Variable} `)}` : ``) + @@ -386,6 +389,12 @@ export class Act { group: TaskGroup.Build, execution: new ShellExecution(command) }); + + if (command.includes('gh-act')) { + ConfigurationManager.set(Section.actCommand, Act.command); + } else { + ConfigurationManager.set(Section.actCommand, Act.githubCliCommand); + } } } } \ No newline at end of file diff --git a/src/configurationManager.ts b/src/configurationManager.ts index bf047bc..605d301 100644 --- a/src/configurationManager.ts +++ b/src/configurationManager.ts @@ -1,4 +1,5 @@ import { ConfigurationTarget, workspace } from 'vscode'; +import { Act } from './act'; export enum Platform { windows = 'win32', @@ -7,6 +8,7 @@ export enum Platform { } export enum Section { + actCommand = 'actCommand', dockerDesktopPath = 'dockerDesktopPath' } @@ -30,6 +32,11 @@ export namespace ConfigurationManager { ConfigurationManager.set(Section.dockerDesktopPath, dockerDesktopPath); } + + let actCommand = ConfigurationManager.get(Section.actCommand); + if (!actCommand) { + ConfigurationManager.set(Section.actCommand, Act.command); + } } export function getSearchTerm(section: Section): string {