Add status check and login for github cli extension

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2024-11-25 00:11:48 -05:00
parent b6a12f35a8
commit 6292da3f72
3 changed files with 16 additions and 15 deletions

View File

@@ -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);
}
}
}
}