diff --git a/src/act.ts b/src/act.ts index 0959854..f604325 100644 --- a/src/act.ts +++ b/src/act.ts @@ -94,7 +94,7 @@ export class Act { 'Chocolatey': 'choco install act-cli', 'Winget': 'winget install nektos.act', 'Scoop': 'scoop install act', - 'GitHub CLI': 'gh extension install https://github.com/nektos/gh-act' + 'GitHub CLI': 'gh auth status || gh auth login && gh extension install https://github.com/nektos/gh-act' }; this.prebuiltExecutables = { @@ -109,7 +109,7 @@ export class Act { 'Homebrew': 'brew install act', 'Nix': 'nix run nixpkgs#act', 'MacPorts': 'sudo port install act', - 'GitHub CLI': 'gh extension install https://github.com/nektos/gh-act' + 'GitHub CLI': 'gh auth status || gh auth login && gh extension install https://github.com/nektos/gh-act' }; this.prebuiltExecutables = { @@ -123,7 +123,7 @@ export class Act { 'Nix': 'nix run nixpkgs#act', 'AUR': 'yay -Syu act', 'COPR': 'dnf copr enable goncalossilva/act && dnf install act-cli', - 'GitHub CLI': 'gh extension install https://github.com/nektos/gh-act' + 'GitHub CLI': 'gh auth status || gh auth login && gh extension install https://github.com/nektos/gh-act' }; this.prebuiltExecutables = { @@ -160,9 +160,15 @@ export class Act { }); // Refresh components view after installation - tasks.onDidEndTask(e => { + tasks.onDidEndTask(async e => { const taskDefinition = e.execution.task.definition; if (taskDefinition.type === 'nektos/act installation') { + if (taskDefinition.ghCliInstall) { + await ConfigurationManager.set(Section.actCommand, Act.githubCliCommand); + } else { + await ConfigurationManager.set(Section.actCommand, Act.command); + } + componentsTreeDataProvider.refresh(); } }); @@ -375,7 +381,7 @@ export class Act { await tasks.executeTask({ name: 'nektos/act', detail: 'Install nektos/act', - definition: { type: 'nektos/act installation' }, + definition: { type: 'nektos/act installation', ghCliInstall: command.includes('gh-act') }, source: 'GitHub Local Actions', scope: TaskScope.Workspace, isBackground: true, @@ -393,12 +399,6 @@ export class Act { group: TaskGroup.Build, execution: new ShellExecution(command) }); - - if (command.includes('gh-act')) { - ConfigurationManager.set(Section.actCommand, Act.githubCliCommand); - } else { - ConfigurationManager.set(Section.actCommand, Act.command); - } } } } \ No newline at end of file diff --git a/src/configurationManager.ts b/src/configurationManager.ts index 605d301..e6c8c84 100644 --- a/src/configurationManager.ts +++ b/src/configurationManager.ts @@ -16,7 +16,7 @@ export namespace ConfigurationManager { export const group: string = 'githubLocalActions'; export const searchPrefix: string = '@ext:sanjulaganepola.github-local-actions'; - export function initialize(): void { + export async function initialize(): Promise { let dockerDesktopPath = ConfigurationManager.get(Section.dockerDesktopPath); if (!dockerDesktopPath) { switch (process.platform) { @@ -30,12 +30,12 @@ export namespace ConfigurationManager { return; } - ConfigurationManager.set(Section.dockerDesktopPath, dockerDesktopPath); + await ConfigurationManager.set(Section.dockerDesktopPath, dockerDesktopPath); } let actCommand = ConfigurationManager.get(Section.actCommand); if (!actCommand) { - ConfigurationManager.set(Section.actCommand, Act.command); + await ConfigurationManager.set(Section.actCommand, Act.command); } } diff --git a/src/extension.ts b/src/extension.ts index c39afb8..7aa315c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -54,7 +54,8 @@ export function activate(context: vscode.ExtensionContext) { ConfigurationManager.initialize(); workspace.onDidChangeConfiguration(async event => { if (event.affectsConfiguration(ConfigurationManager.group)) { - ConfigurationManager.initialize(); + await ConfigurationManager.initialize(); + componentsTreeDataProvider.refresh(); } });