Merge branch 'fix/build-output-retrieval' into fix/linux-act-setup
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "github-local-actions",
|
"name": "github-local-actions",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "github-local-actions",
|
"name": "github-local-actions",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"child_process": "^1.0.2",
|
"child_process": "^1.0.2",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
},
|
},
|
||||||
"publisher": "SanjulaGanepola",
|
"publisher": "SanjulaGanepola",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "https://github.com/SanjulaGanepola/github-local-actions"
|
"url": "https://github.com/SanjulaGanepola/github-local-actions"
|
||||||
},
|
},
|
||||||
@@ -700,6 +700,11 @@
|
|||||||
"configuration": {
|
"configuration": {
|
||||||
"title": "GitHub Local Actions",
|
"title": "GitHub Local Actions",
|
||||||
"properties": {
|
"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 should 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": {
|
"githubLocalActions.dockerDesktopPath": {
|
||||||
"type": "string",
|
"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`",
|
"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`",
|
||||||
|
|||||||
207
src/act.ts
207
src/act.ts
@@ -1,7 +1,10 @@
|
|||||||
|
import * as childProcess from "child_process";
|
||||||
|
import * as fs from "fs/promises";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import sanitize from "sanitize-filename";
|
import sanitize from "sanitize-filename";
|
||||||
import { ExtensionContext, ShellExecution, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, TaskScope, Uri, window, workspace, WorkspaceFolder } from "vscode";
|
import { CustomExecution, EventEmitter, ExtensionContext, Pseudoterminal, ShellExecution, TaskDefinition, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, TaskScope, TerminalDimensions, Uri, window, workspace, WorkspaceFolder } from "vscode";
|
||||||
import { ComponentsManager } from "./componentsManager";
|
import { ComponentsManager } from "./componentsManager";
|
||||||
|
import { ConfigurationManager, Section } from "./configurationManager";
|
||||||
import { componentsTreeDataProvider, historyTreeDataProvider } from './extension';
|
import { componentsTreeDataProvider, historyTreeDataProvider } from './extension';
|
||||||
import { HistoryManager, HistoryStatus } from './historyManager';
|
import { HistoryManager, HistoryStatus } from './historyManager';
|
||||||
import { SecretManager } from "./secretManager";
|
import { SecretManager } from "./secretManager";
|
||||||
@@ -55,7 +58,8 @@ export enum Option {
|
|||||||
VariableFile = '--var-file',
|
VariableFile = '--var-file',
|
||||||
Input = '--input',
|
Input = '--input',
|
||||||
InputFile = '--input-file',
|
InputFile = '--input-file',
|
||||||
PayloadFile = '--eventpath'
|
PayloadFile = '--eventpath',
|
||||||
|
Json = '--json'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommandArgs {
|
export interface CommandArgs {
|
||||||
@@ -66,7 +70,8 @@ export interface CommandArgs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Act {
|
export class Act {
|
||||||
private static base: string = 'act';
|
static command: string = 'act';
|
||||||
|
static githubCliCommand: string = 'gh act';
|
||||||
context: ExtensionContext;
|
context: ExtensionContext;
|
||||||
storageManager: StorageManager;
|
storageManager: StorageManager;
|
||||||
secretManager: SecretManager;
|
secretManager: SecretManager;
|
||||||
@@ -76,6 +81,8 @@ export class Act {
|
|||||||
settingsManager: SettingsManager;
|
settingsManager: SettingsManager;
|
||||||
installationCommands: { [packageManager: string]: string };
|
installationCommands: { [packageManager: string]: string };
|
||||||
prebuiltExecutables: { [architecture: string]: string };
|
prebuiltExecutables: { [architecture: string]: string };
|
||||||
|
refreshInterval: NodeJS.Timeout | undefined;
|
||||||
|
runningTaskCount: number;
|
||||||
|
|
||||||
constructor(context: ExtensionContext) {
|
constructor(context: ExtensionContext) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@@ -85,6 +92,7 @@ export class Act {
|
|||||||
this.workflowsManager = new WorkflowsManager();
|
this.workflowsManager = new WorkflowsManager();
|
||||||
this.historyManager = new HistoryManager(this.storageManager);
|
this.historyManager = new HistoryManager(this.storageManager);
|
||||||
this.settingsManager = new SettingsManager(this.storageManager, this.secretManager);
|
this.settingsManager = new SettingsManager(this.storageManager, this.secretManager);
|
||||||
|
this.runningTaskCount = 0;
|
||||||
|
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
@@ -92,7 +100,7 @@ export class Act {
|
|||||||
'Chocolatey': 'choco install act-cli',
|
'Chocolatey': 'choco install act-cli',
|
||||||
'Winget': 'winget install nektos.act',
|
'Winget': 'winget install nektos.act',
|
||||||
'Scoop': 'scoop install 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 = {
|
this.prebuiltExecutables = {
|
||||||
@@ -107,7 +115,7 @@ export class Act {
|
|||||||
'Homebrew': 'brew install act',
|
'Homebrew': 'brew install act',
|
||||||
'Nix': 'nix run nixpkgs#act',
|
'Nix': 'nix run nixpkgs#act',
|
||||||
'MacPorts': 'sudo port install 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 = {
|
this.prebuiltExecutables = {
|
||||||
@@ -122,7 +130,7 @@ export class Act {
|
|||||||
'Arch': 'pacman -Syu act',
|
'Arch': 'pacman -Syu act',
|
||||||
'AUR': 'yay -Syu act',
|
'AUR': 'yay -Syu act',
|
||||||
'COPR': 'dnf copr enable goncalossilva/act && dnf install act-cli',
|
'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 = {
|
this.prebuiltExecutables = {
|
||||||
@@ -139,80 +147,48 @@ export class Act {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup automatic history view refreshing
|
// Setup automatic history view refreshing
|
||||||
let refreshInterval: NodeJS.Timeout | undefined;
|
|
||||||
tasks.onDidStartTask(e => {
|
tasks.onDidStartTask(e => {
|
||||||
const taskDefinition = e.execution.task.definition;
|
const taskDefinition = e.execution.task.definition;
|
||||||
if (taskDefinition.type === 'GitHub Local Actions' && !refreshInterval) {
|
if (taskDefinition.type === 'GitHub Local Actions') {
|
||||||
refreshInterval = setInterval(() => {
|
this.runningTaskCount++;
|
||||||
|
|
||||||
|
if (!this.refreshInterval && this.runningTaskCount >= 0) {
|
||||||
|
this.refreshInterval = setInterval(() => {
|
||||||
historyTreeDataProvider.refresh();
|
historyTreeDataProvider.refresh();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
tasks.onDidEndTask(e => {
|
tasks.onDidEndTask(e => {
|
||||||
const taskDefinition = e.execution.task.definition;
|
const taskDefinition = e.execution.task.definition;
|
||||||
if (taskDefinition.type === 'GitHub Local Actions') {
|
if (taskDefinition.type === 'GitHub Local Actions') {
|
||||||
if (refreshInterval) {
|
this.runningTaskCount--;
|
||||||
clearInterval(refreshInterval);
|
|
||||||
refreshInterval = undefined;
|
if (this.refreshInterval && this.runningTaskCount == 0) {
|
||||||
|
clearInterval(this.refreshInterval);
|
||||||
|
this.refreshInterval = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Refresh components view after installation
|
// Refresh components view after installation
|
||||||
tasks.onDidEndTask(e => {
|
tasks.onDidEndTask(async e => {
|
||||||
const taskDefinition = e.execution.task.definition;
|
const taskDefinition = e.execution.task.definition;
|
||||||
if (taskDefinition.type === 'nektos/act installation') {
|
if (taskDefinition.type === 'nektos/act installation') {
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
componentsTreeDataProvider.refresh();
|
componentsTreeDataProvider.refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tasks.onDidStartTaskProcess(e => {
|
|
||||||
const taskDefinition = e.execution.task.definition;
|
|
||||||
if (taskDefinition.type === 'GitHub Local Actions') {
|
|
||||||
const commandArgs: CommandArgs = taskDefinition.commandArgs;
|
|
||||||
const historyIndex = taskDefinition.historyIndex;
|
|
||||||
|
|
||||||
// Add new entry to workspace history
|
|
||||||
this.historyManager.workspaceHistory[commandArgs.path].push({
|
|
||||||
index: historyIndex,
|
|
||||||
count: taskDefinition.count,
|
|
||||||
name: `${commandArgs.name}`,
|
|
||||||
status: HistoryStatus.Running,
|
|
||||||
date: {
|
|
||||||
start: taskDefinition.start.toString()
|
|
||||||
},
|
|
||||||
taskExecution: e.execution,
|
|
||||||
commandArgs: commandArgs,
|
|
||||||
logPath: taskDefinition.logPath
|
|
||||||
});
|
|
||||||
historyTreeDataProvider.refresh();
|
|
||||||
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
tasks.onDidEndTaskProcess(e => {
|
|
||||||
const taskDefinition = e.execution.task.definition;
|
|
||||||
if (taskDefinition.type === 'GitHub Local Actions') {
|
|
||||||
const commandArgs: CommandArgs = taskDefinition.commandArgs;
|
|
||||||
const historyIndex = taskDefinition.historyIndex;
|
|
||||||
|
|
||||||
// Set end status
|
|
||||||
if (this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status === HistoryStatus.Running) {
|
|
||||||
if (e.exitCode === 0) {
|
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status = HistoryStatus.Success;
|
|
||||||
} else if (!e.exitCode) {
|
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status = HistoryStatus.Cancelled;
|
|
||||||
} else {
|
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status = HistoryStatus.Failed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set end time
|
static getActCommand() {
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].date.end = new Date().toString();
|
return ConfigurationManager.get<string>(Section.actCommand) || Act.command;
|
||||||
|
|
||||||
historyTreeDataProvider.refresh();
|
|
||||||
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async runAllWorkflows(workspaceFolder: WorkspaceFolder) {
|
async runAllWorkflows(workspaceFolder: WorkspaceFolder) {
|
||||||
@@ -306,22 +282,21 @@ export class Act {
|
|||||||
} catch (error: any) { }
|
} catch (error: any) { }
|
||||||
|
|
||||||
// Build command with settings
|
// Build command with settings
|
||||||
|
const actCommand = Act.getActCommand();
|
||||||
const settings = await this.settingsManager.getSettings(workspaceFolder, true);
|
const settings = await this.settingsManager.getSettings(workspaceFolder, true);
|
||||||
const command =
|
const command =
|
||||||
`set -o pipefail; ` +
|
`${actCommand} ${commandArgs.options}` +
|
||||||
`${Act.base} ${commandArgs.options}` +
|
|
||||||
(settings.secrets.length > 0 ? ` ${Option.Secret} ${settings.secrets.map(secret => secret.key).join(` ${Option.Secret} `)}` : ``) +
|
(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.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} `)}` : ``) +
|
(settings.variables.length > 0 ? ` ${Option.Variable} ${settings.variables.map(variable => `${variable.key}=${variable.value}`).join(` ${Option.Variable} `)}` : ``) +
|
||||||
(settings.variableFiles.length > 0 ? ` ${Option.VariableFile} "${settings.variableFiles[0].path}"` : ` ${Option.VariableFile} ""`) +
|
(settings.variableFiles.length > 0 ? ` ${Option.VariableFile} "${settings.variableFiles[0].path}"` : ` ${Option.VariableFile} ""`) +
|
||||||
(settings.inputs.length > 0 ? ` ${Option.Input} ${settings.inputs.map(input => `${input.key}=${input.value}`).join(` ${Option.Input} `)}` : ``) +
|
(settings.inputs.length > 0 ? ` ${Option.Input} ${settings.inputs.map(input => `${input.key}=${input.value}`).join(` ${Option.Input} `)}` : ``) +
|
||||||
(settings.inputFiles.length > 0 ? ` ${Option.InputFile} "${settings.inputFiles[0].path}"` : ` ${Option.InputFile} ""`) +
|
(settings.inputFiles.length > 0 ? ` ${Option.InputFile} "${settings.inputFiles[0].path}"` : ` ${Option.InputFile} ""`) +
|
||||||
(settings.runners.length > 0 ? ` ${Option.Platform} ${settings.runners.map(runner => `${runner.key}=${runner.value}`).join(` ${Option.Platform} `)}` : ``) +
|
(settings.runners.length > 0 ? ` ${Option.Platform} ${settings.runners.map(runner => `${runner.key}=${runner.value}`).join(` ${Option.Platform} `)}` : ``) +
|
||||||
(settings.payloadFiles.length > 0 ? ` ${Option.PayloadFile} "${settings.payloadFiles[0].path}"` : ` ${Option.PayloadFile} ""`) +
|
(settings.payloadFiles.length > 0 ? ` ${Option.PayloadFile} "${settings.payloadFiles[0].path}"` : ` ${Option.PayloadFile} ""`);
|
||||||
` 2>&1 | tee "${logPath}"`;
|
|
||||||
|
|
||||||
// Execute task
|
// Execute task
|
||||||
await tasks.executeTask({
|
const taskExecution = await tasks.executeTask({
|
||||||
name: `${commandArgs.name} #${count}`,
|
name: `${commandArgs.name} #${count}`,
|
||||||
detail: `${commandArgs.name} #${count}`,
|
detail: `${commandArgs.name} #${count}`,
|
||||||
definition: {
|
definition: {
|
||||||
@@ -347,10 +322,52 @@ export class Act {
|
|||||||
problemMatchers: [],
|
problemMatchers: [],
|
||||||
runOptions: {},
|
runOptions: {},
|
||||||
group: TaskGroup.Build,
|
group: TaskGroup.Build,
|
||||||
execution: new ShellExecution(
|
execution: new CustomExecution(async (resolvedDefinition: TaskDefinition): Promise<Pseudoterminal> => {
|
||||||
|
// Add new entry to workspace history
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path].push({
|
||||||
|
index: historyIndex,
|
||||||
|
count: count,
|
||||||
|
name: `${commandArgs.name}`,
|
||||||
|
status: HistoryStatus.Running,
|
||||||
|
date: {
|
||||||
|
start: start.toString()
|
||||||
|
},
|
||||||
|
taskExecution: taskExecution,
|
||||||
|
commandArgs: commandArgs,
|
||||||
|
logPath: logPath
|
||||||
|
});
|
||||||
|
historyTreeDataProvider.refresh();
|
||||||
|
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
||||||
|
|
||||||
|
const writeEmitter = new EventEmitter<string>();
|
||||||
|
const closeEmitter = new EventEmitter<number>();
|
||||||
|
|
||||||
|
writeEmitter.event(async data => {
|
||||||
|
try {
|
||||||
|
// Create log file if it does not exist
|
||||||
|
try {
|
||||||
|
await fs.access(logPath);
|
||||||
|
} catch (error: any) {
|
||||||
|
await fs.writeFile(logPath, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append data to log file
|
||||||
|
await fs.appendFile(logPath, data);
|
||||||
|
} catch (error) { }
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleIO = (data: any) => {
|
||||||
|
const lines: string[] = data.toString().split('\n').filter((line: string) => line != '');
|
||||||
|
for (const line of lines) {
|
||||||
|
writeEmitter.fire(`${line.trimEnd()}\r\n`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const exec = childProcess.spawn(
|
||||||
command,
|
command,
|
||||||
{
|
{
|
||||||
cwd: commandArgs.path,
|
cwd: commandArgs.path,
|
||||||
|
shell: true,
|
||||||
env: settings.secrets
|
env: settings.secrets
|
||||||
.filter(secret => secret.value)
|
.filter(secret => secret.value)
|
||||||
.reduce((previousValue, currentValue) => {
|
.reduce((previousValue, currentValue) => {
|
||||||
@@ -358,7 +375,60 @@ export class Act {
|
|||||||
return previousValue;
|
return previousValue;
|
||||||
}, {} as Record<string, string>)
|
}, {} as Record<string, string>)
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
|
exec.stdout.on('data', handleIO);
|
||||||
|
exec.stderr.on('data', handleIO);
|
||||||
|
exec.on('exit', (code, signal) => {
|
||||||
|
// Set execution status and end time in workspace history
|
||||||
|
if (this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status === HistoryStatus.Running) {
|
||||||
|
if (code === 0) {
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status = HistoryStatus.Success;
|
||||||
|
} else if (!code) {
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status = HistoryStatus.Cancelled;
|
||||||
|
} else {
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status = HistoryStatus.Failed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].date.end = new Date().toString();
|
||||||
|
historyTreeDataProvider.refresh();
|
||||||
|
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
||||||
|
|
||||||
|
if (signal === 'SIGINT') {
|
||||||
|
writeEmitter.fire(`\r\nTask interrupted.\r\n`);
|
||||||
|
closeEmitter.fire(code || 1);
|
||||||
|
} else {
|
||||||
|
writeEmitter.fire(`\r\nTask exited with exit code ${code}.\r\n`);
|
||||||
|
closeEmitter.fire(code || 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
exec.on('close', (code) => {
|
||||||
|
closeEmitter.fire(code || 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
onDidWrite: writeEmitter.event,
|
||||||
|
onDidClose: closeEmitter.event,
|
||||||
|
open: async (initialDimensions: TerminalDimensions | undefined): Promise<void> => {
|
||||||
|
writeEmitter.fire(`${command}\r\n\r\n`);
|
||||||
|
},
|
||||||
|
handleInput: (data: string) => {
|
||||||
|
if (data === '\x03') {
|
||||||
|
exec.kill('SIGINT');
|
||||||
|
exec.stdout.destroy();
|
||||||
|
exec.stdin.destroy();
|
||||||
|
exec.stderr.destroy();
|
||||||
|
} else {
|
||||||
|
exec.stdin.write(data === '\r' ? '\r\n' : data)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
close: () => {
|
||||||
|
exec.kill('SIGINT');
|
||||||
|
exec.stdout.destroy();
|
||||||
|
exec.stdin.destroy();
|
||||||
|
exec.stderr.destroy();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
})
|
||||||
});
|
});
|
||||||
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
||||||
}
|
}
|
||||||
@@ -370,7 +440,8 @@ export class Act {
|
|||||||
name: 'nektos/act',
|
name: 'nektos/act',
|
||||||
detail: 'Install nektos/act',
|
detail: 'Install nektos/act',
|
||||||
definition: {
|
definition: {
|
||||||
type: 'nektos/act installation'
|
type: 'nektos/act installation',
|
||||||
|
ghCliInstall: command.includes('gh-act')
|
||||||
},
|
},
|
||||||
source: 'GitHub Local Actions',
|
source: 'GitHub Local Actions',
|
||||||
scope: TaskScope.Workspace,
|
scope: TaskScope.Workspace,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as childProcess from "child_process";
|
import * as childProcess from "child_process";
|
||||||
import { commands, env, extensions, QuickPickItemKind, ShellExecution, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, TaskScope, ThemeIcon, Uri, window } from "vscode";
|
import { commands, env, extensions, QuickPickItemKind, ShellExecution, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, TaskScope, ThemeIcon, Uri, window } from "vscode";
|
||||||
|
import { Act } from "./act";
|
||||||
import { ConfigurationManager, Platform, Section } from "./configurationManager";
|
import { ConfigurationManager, Platform, Section } from "./configurationManager";
|
||||||
import { act, componentsTreeDataProvider } from "./extension";
|
import { act, componentsTreeDataProvider } from "./extension";
|
||||||
import ComponentsTreeDataProvider from "./views/components/componentsTreeDataProvider";
|
import ComponentsTreeDataProvider from "./views/components/componentsTreeDataProvider";
|
||||||
@@ -38,7 +39,7 @@ export class ComponentsManager {
|
|||||||
async getComponents(): Promise<Component<CliStatus | ExtensionStatus>[]> {
|
async getComponents(): Promise<Component<CliStatus | ExtensionStatus>[]> {
|
||||||
const components: Component<CliStatus | ExtensionStatus>[] = [];
|
const components: Component<CliStatus | ExtensionStatus>[] = [];
|
||||||
|
|
||||||
const actCliInfo = await this.getCliInfo('act --version', ComponentsManager.actVersionRegExp, false, false);
|
const actCliInfo = await this.getCliInfo(`${Act.getActCommand()} --version`, ComponentsManager.actVersionRegExp, false, false);
|
||||||
components.push({
|
components.push({
|
||||||
name: 'nektos/act',
|
name: 'nektos/act',
|
||||||
icon: 'terminal',
|
icon: 'terminal',
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ConfigurationTarget, workspace } from 'vscode';
|
import { ConfigurationTarget, workspace } from 'vscode';
|
||||||
|
import { Act } from './act';
|
||||||
|
|
||||||
export enum Platform {
|
export enum Platform {
|
||||||
windows = 'win32',
|
windows = 'win32',
|
||||||
@@ -7,6 +8,7 @@ export enum Platform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum Section {
|
export enum Section {
|
||||||
|
actCommand = 'actCommand',
|
||||||
dockerDesktopPath = 'dockerDesktopPath'
|
dockerDesktopPath = 'dockerDesktopPath'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,7 +16,7 @@ export namespace ConfigurationManager {
|
|||||||
export const group: string = 'githubLocalActions';
|
export const group: string = 'githubLocalActions';
|
||||||
export const searchPrefix: string = '@ext:sanjulaganepola.github-local-actions';
|
export const searchPrefix: string = '@ext:sanjulaganepola.github-local-actions';
|
||||||
|
|
||||||
export function initialize(): void {
|
export async function initialize(): Promise<void> {
|
||||||
let dockerDesktopPath = ConfigurationManager.get<string>(Section.dockerDesktopPath);
|
let dockerDesktopPath = ConfigurationManager.get<string>(Section.dockerDesktopPath);
|
||||||
if (!dockerDesktopPath) {
|
if (!dockerDesktopPath) {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
@@ -28,7 +30,12 @@ export namespace ConfigurationManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationManager.set(Section.dockerDesktopPath, dockerDesktopPath);
|
await ConfigurationManager.set(Section.dockerDesktopPath, dockerDesktopPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
let actCommand = ConfigurationManager.get<string>(Section.actCommand);
|
||||||
|
if (!actCommand) {
|
||||||
|
await ConfigurationManager.set(Section.actCommand, Act.command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
ConfigurationManager.initialize();
|
ConfigurationManager.initialize();
|
||||||
workspace.onDidChangeConfiguration(async event => {
|
workspace.onDidChangeConfiguration(async event => {
|
||||||
if (event.affectsConfiguration(ConfigurationManager.group)) {
|
if (event.affectsConfiguration(ConfigurationManager.group)) {
|
||||||
ConfigurationManager.initialize();
|
await ConfigurationManager.initialize();
|
||||||
|
componentsTreeDataProvider.refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -59,9 +59,9 @@ export class SettingsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getSettings(workspaceFolder: WorkspaceFolder, isUserSelected: boolean): Promise<Settings> {
|
async getSettings(workspaceFolder: WorkspaceFolder, isUserSelected: boolean): Promise<Settings> {
|
||||||
const secrets = (await this.getSetting(workspaceFolder, SettingsManager.secretsRegExp, StorageKey.Secrets, true, Visibility.hide)).filter(secret => !isUserSelected || secret.selected);
|
const secrets = (await this.getSetting(workspaceFolder, SettingsManager.secretsRegExp, StorageKey.Secrets, true, Visibility.hide)).filter(secret => !isUserSelected || (secret.selected && secret.value));
|
||||||
const secretFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.SecretFiles)).filter(secretFile => !isUserSelected || secretFile.selected);
|
const secretFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.SecretFiles)).filter(secretFile => !isUserSelected || secretFile.selected);
|
||||||
const variables = (await this.getSetting(workspaceFolder, SettingsManager.variablesRegExp, StorageKey.Variables, false, Visibility.show)).filter(variable => !isUserSelected || variable.selected);
|
const variables = (await this.getSetting(workspaceFolder, SettingsManager.variablesRegExp, StorageKey.Variables, false, Visibility.show)).filter(variable => !isUserSelected || (variable.selected && variable.value));
|
||||||
const variableFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.VariableFiles)).filter(variableFile => !isUserSelected || variableFile.selected);
|
const variableFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.VariableFiles)).filter(variableFile => !isUserSelected || variableFile.selected);
|
||||||
const inputs = (await this.getSetting(workspaceFolder, SettingsManager.inputsRegExp, StorageKey.Inputs, false, Visibility.show)).filter(input => !isUserSelected || (input.selected && input.value));
|
const inputs = (await this.getSetting(workspaceFolder, SettingsManager.inputsRegExp, StorageKey.Inputs, false, Visibility.show)).filter(input => !isUserSelected || (input.selected && input.value));
|
||||||
const inputFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.InputFiles)).filter(inputFile => !isUserSelected || inputFile.selected);
|
const inputFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.InputFiles)).filter(inputFile => !isUserSelected || inputFile.selected);
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import { CancellationToken, Event, FileDecoration, FileDecorationProvider, ProviderResult, ThemeColor, Uri } from "vscode";
|
import { CancellationToken, Event, FileDecoration, FileDecorationProvider, ProviderResult, ThemeColor, Uri } from "vscode";
|
||||||
import { CliStatus, ExtensionStatus } from "../componentsManager";
|
import { CliStatus, ExtensionStatus } from "../componentsManager";
|
||||||
import ComponentTreeItem from "./components/component";
|
import ComponentTreeItem from "./components/component";
|
||||||
|
import InputsTreeItem from "./settings/inputs";
|
||||||
|
import RunnersTreeItem from "./settings/runners";
|
||||||
|
import SecretsTreeItem from "./settings/secrets";
|
||||||
|
import { SettingContextValue } from "./settings/setting";
|
||||||
|
import VariablesTreeItem from "./settings/variables";
|
||||||
import WorkflowTreeItem from "./workflows/workflow";
|
import WorkflowTreeItem from "./workflows/workflow";
|
||||||
|
|
||||||
export class DecorationProvider implements FileDecorationProvider {
|
export class DecorationProvider implements FileDecorationProvider {
|
||||||
@@ -37,14 +42,24 @@ export class DecorationProvider implements FileDecorationProvider {
|
|||||||
color: new ThemeColor('GitHubLocalActions.red')
|
color: new ThemeColor('GitHubLocalActions.red')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
} else if ([SecretsTreeItem.contextValue, VariablesTreeItem.contextValue, InputsTreeItem.contextValue, RunnersTreeItem.contextValue].includes(uri.scheme)) {
|
||||||
|
const hasAllValues = params.get('hasAllValues') === 'true';
|
||||||
|
|
||||||
// else if (uri.scheme === SecretsTreeItem.contextValue || uri.scheme === VariablesTreeItem.contextValue || uri.scheme === InputsTreeItem.contextValue || uri.scheme === RunnersTreeItem.contextValue) {
|
if (!hasAllValues) {
|
||||||
// const selected = params.get('selected');
|
return {
|
||||||
|
color: new ThemeColor('GitHubLocalActions.red')
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else if (Object.values(SettingContextValue).includes(uri.scheme as any)) {
|
||||||
|
const isSelected = params.get('isSelected') === 'true';
|
||||||
|
const hasValue = params.get('hasValue') === 'true';
|
||||||
|
|
||||||
// return {
|
if (isSelected && !hasValue) {
|
||||||
// badge: `${selected}`
|
return {
|
||||||
// };
|
badge: '?',
|
||||||
// }
|
color: new ThemeColor('GitHubLocalActions.red')
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||||
import { act } from "../../extension";
|
import { act } from "../../extension";
|
||||||
import { Setting, SettingFile } from "../../settingsManager";
|
import { Setting, SettingFile } from "../../settingsManager";
|
||||||
import { StorageKey } from "../../storageManager";
|
import { StorageKey } from "../../storageManager";
|
||||||
@@ -17,6 +17,8 @@ export default class InputsTreeItem extends TreeItem implements GithubLocalActio
|
|||||||
(selectedInputFiles.length > 0 ? ` + ${selectedInputFiles[0].name}` : ``);
|
(selectedInputFiles.length > 0 ? ` + ${selectedInputFiles[0].name}` : ``);
|
||||||
this.contextValue = InputsTreeItem.contextValue;
|
this.contextValue = InputsTreeItem.contextValue;
|
||||||
this.iconPath = new ThemeIcon('record-keys');
|
this.iconPath = new ThemeIcon('record-keys');
|
||||||
|
const hasAllValues = inputs.filter(input => input.selected && input.value === '').length === 0;
|
||||||
|
this.resourceUri = Uri.parse(`${InputsTreeItem.contextValue}:Inputs?hasAllValues=${hasAllValues}`, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||||
import { act } from "../../extension";
|
import { act } from "../../extension";
|
||||||
import { Setting } from "../../settingsManager";
|
import { Setting } from "../../settingsManager";
|
||||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
@@ -12,6 +12,8 @@ export default class RunnersTreeItem extends TreeItem implements GithubLocalActi
|
|||||||
this.description = `${runners.filter(runner => runner.selected).length}/${runners.length}`;
|
this.description = `${runners.filter(runner => runner.selected).length}/${runners.length}`;
|
||||||
this.contextValue = RunnersTreeItem.contextValue;
|
this.contextValue = RunnersTreeItem.contextValue;
|
||||||
this.iconPath = new ThemeIcon('server-environment');
|
this.iconPath = new ThemeIcon('server-environment');
|
||||||
|
const hasAllValues = runners.filter(runner => runner.selected && runner.value === '').length === 0;
|
||||||
|
this.resourceUri = Uri.parse(`${RunnersTreeItem.contextValue}:Runners?hasAllValues=${hasAllValues}`, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||||
import { act } from "../../extension";
|
import { act } from "../../extension";
|
||||||
import { Setting, SettingFile } from "../../settingsManager";
|
import { Setting, SettingFile } from "../../settingsManager";
|
||||||
import { StorageKey } from "../../storageManager";
|
import { StorageKey } from "../../storageManager";
|
||||||
@@ -17,6 +17,8 @@ export default class SecretsTreeItem extends TreeItem implements GithubLocalActi
|
|||||||
(selectedSecretFiles.length > 0 ? ` + ${selectedSecretFiles[0].name}` : ``);
|
(selectedSecretFiles.length > 0 ? ` + ${selectedSecretFiles[0].name}` : ``);
|
||||||
this.contextValue = SecretsTreeItem.contextValue;
|
this.contextValue = SecretsTreeItem.contextValue;
|
||||||
this.iconPath = new ThemeIcon('lock');
|
this.iconPath = new ThemeIcon('lock');
|
||||||
|
const hasAllValues = secrets.filter(secret => secret.selected && secret.value === '').length === 0;
|
||||||
|
this.resourceUri = Uri.parse(`${SecretsTreeItem.contextValue}:Secrets?hasAllValues=${hasAllValues}`, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
import { ThemeIcon, TreeItem, TreeItemCheckboxState, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
import { ThemeIcon, TreeItem, TreeItemCheckboxState, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||||
import { Setting, Visibility } from "../../settingsManager";
|
import { Setting, Visibility } from "../../settingsManager";
|
||||||
import { StorageKey } from "../../storageManager";
|
import { StorageKey } from "../../storageManager";
|
||||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
|
|
||||||
|
export enum SettingContextValue {
|
||||||
|
secret = 'githubLocalActions.secret',
|
||||||
|
variable = 'githubLocalActions.variable',
|
||||||
|
input = 'githubLocalActions.input',
|
||||||
|
runner = 'githubLocalActions.runner'
|
||||||
|
}
|
||||||
|
|
||||||
export default class SettingTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
export default class SettingTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||||
setting: Setting;
|
setting: Setting;
|
||||||
storageKey: StorageKey;
|
storageKey: StorageKey;
|
||||||
@@ -19,6 +26,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
|
|||||||
this.contextValue = `${treeItem.contextValue}_${setting.password ? setting.visible : ''}`;
|
this.contextValue = `${treeItem.contextValue}_${setting.password ? setting.visible : ''}`;
|
||||||
this.iconPath = treeItem.iconPath;
|
this.iconPath = treeItem.iconPath;
|
||||||
this.checkboxState = setting.selected ? TreeItemCheckboxState.Checked : TreeItemCheckboxState.Unchecked;
|
this.checkboxState = setting.selected ? TreeItemCheckboxState.Checked : TreeItemCheckboxState.Unchecked;
|
||||||
|
this.resourceUri = Uri.parse(`${treeItem.contextValue}:${setting.key}?isSelected=${setting.selected}&hasValue=${setting.value !== ''}`, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getSecretTreeItem(workspaceFolder: WorkspaceFolder, secret: Setting): SettingTreeItem {
|
static getSecretTreeItem(workspaceFolder: WorkspaceFolder, secret: Setting): SettingTreeItem {
|
||||||
@@ -27,7 +35,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
|
|||||||
secret,
|
secret,
|
||||||
StorageKey.Secrets,
|
StorageKey.Secrets,
|
||||||
{
|
{
|
||||||
contextValue: 'githubLocalActions.secret',
|
contextValue: SettingContextValue.secret,
|
||||||
iconPath: new ThemeIcon('key')
|
iconPath: new ThemeIcon('key')
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -39,7 +47,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
|
|||||||
variable,
|
variable,
|
||||||
StorageKey.Variables,
|
StorageKey.Variables,
|
||||||
{
|
{
|
||||||
contextValue: 'githubLocalActions.variable',
|
contextValue: SettingContextValue.variable,
|
||||||
iconPath: new ThemeIcon('symbol-variable')
|
iconPath: new ThemeIcon('symbol-variable')
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -51,7 +59,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
|
|||||||
input,
|
input,
|
||||||
StorageKey.Inputs,
|
StorageKey.Inputs,
|
||||||
{
|
{
|
||||||
contextValue: 'githubLocalActions.input',
|
contextValue: SettingContextValue.input,
|
||||||
iconPath: new ThemeIcon('symbol-parameter')
|
iconPath: new ThemeIcon('symbol-parameter')
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -63,7 +71,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
|
|||||||
runner,
|
runner,
|
||||||
StorageKey.Runners,
|
StorageKey.Runners,
|
||||||
{
|
{
|
||||||
contextValue: 'githubLocalActions.runner',
|
contextValue: SettingContextValue.runner,
|
||||||
iconPath: new ThemeIcon('vm-connect')
|
iconPath: new ThemeIcon('vm-connect')
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||||
import { act } from "../../extension";
|
import { act } from "../../extension";
|
||||||
import { Setting, SettingFile } from "../../settingsManager";
|
import { Setting, SettingFile } from "../../settingsManager";
|
||||||
import { StorageKey } from "../../storageManager";
|
import { StorageKey } from "../../storageManager";
|
||||||
@@ -17,6 +17,8 @@ export default class VariablesTreeItem extends TreeItem implements GithubLocalAc
|
|||||||
(selectedVariableFiles.length > 0 ? ` + ${selectedVariableFiles[0].name}` : ``);
|
(selectedVariableFiles.length > 0 ? ` + ${selectedVariableFiles[0].name}` : ``);
|
||||||
this.contextValue = VariablesTreeItem.contextValue;
|
this.contextValue = VariablesTreeItem.contextValue;
|
||||||
this.iconPath = new ThemeIcon('symbol-key');
|
this.iconPath = new ThemeIcon('symbol-key');
|
||||||
|
const hasAllValues = variables.filter(variable => variable.selected && variable.value === '').length === 0;
|
||||||
|
this.resourceUri = Uri.parse(`${VariablesTreeItem.contextValue}:Variables?hasAllValues=${hasAllValues}`, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||||
|
|||||||
Reference in New Issue
Block a user