Merge pull request #65 from SanjulaGanepola/feature/payload-file
Add payload support
This commit is contained in:
50
package.json
50
package.json
@@ -276,6 +276,12 @@
|
|||||||
"title": "Locate Variable Files",
|
"title": "Locate Variable Files",
|
||||||
"icon": "$(search)"
|
"icon": "$(search)"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"category": "GitHub Local Actions",
|
||||||
|
"command": "githubLocalActions.importFromGithub",
|
||||||
|
"title": "Import from GitHub",
|
||||||
|
"icon": "$(github)"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"category": "GitHub Local Actions",
|
"category": "GitHub Local Actions",
|
||||||
"command": "githubLocalActions.createInputFile",
|
"command": "githubLocalActions.createInputFile",
|
||||||
@@ -290,9 +296,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "GitHub Local Actions",
|
"category": "GitHub Local Actions",
|
||||||
"command": "githubLocalActions.importFromGithub",
|
"command": "githubLocalActions.createPayloadFile",
|
||||||
"title": "Import from GitHub",
|
"title": "Create Payload File",
|
||||||
"icon": "$(github)"
|
"icon": "$(add)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"category": "GitHub Local Actions",
|
||||||
|
"command": "githubLocalActions.locatePayloadFiles",
|
||||||
|
"title": "Locate Payload Files",
|
||||||
|
"icon": "$(search)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "GitHub Local Actions",
|
"category": "GitHub Local Actions",
|
||||||
@@ -430,6 +442,10 @@
|
|||||||
"command": "githubLocalActions.locateVariableFiles",
|
"command": "githubLocalActions.locateVariableFiles",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.importFromGithub",
|
||||||
|
"when": "never"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.createInputFile",
|
"command": "githubLocalActions.createInputFile",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
@@ -439,7 +455,11 @@
|
|||||||
"when": "never"
|
"when": "never"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.importFromGithub",
|
"command": "githubLocalActions.createPayloadFile",
|
||||||
|
"when": "never"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.locatePayloadFiles",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -615,6 +635,11 @@
|
|||||||
"when": "view == settings && viewItem =~ /^githubLocalActions.variables.*/",
|
"when": "view == settings && viewItem =~ /^githubLocalActions.variables.*/",
|
||||||
"group": "inline@1"
|
"group": "inline@1"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.importFromGithub",
|
||||||
|
"when": "view == settings && viewItem =~ /^githubLocalActions.variables.*/",
|
||||||
|
"group": "inline@2"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.createInputFile",
|
"command": "githubLocalActions.createInputFile",
|
||||||
"when": "view == settings && viewItem =~ /^githubLocalActions.inputs.*/",
|
"when": "view == settings && viewItem =~ /^githubLocalActions.inputs.*/",
|
||||||
@@ -626,23 +651,28 @@
|
|||||||
"group": "inline@1"
|
"group": "inline@1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.importFromGithub",
|
"command": "githubLocalActions.createPayloadFile",
|
||||||
"when": "view == settings && viewItem =~ /^githubLocalActions.variables.*/",
|
"when": "view == settings && viewItem =~ /^githubLocalActions.payloads.*/",
|
||||||
"group": "inline@2"
|
"group": "inline@0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.locatePayloadFiles",
|
||||||
|
"when": "view == settings && viewItem =~ /^githubLocalActions.payloads.*/",
|
||||||
|
"group": "inline@1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.openSettingFile",
|
"command": "githubLocalActions.openSettingFile",
|
||||||
"when": "view == settings && viewItem =~ /^githubLocalActions.(secret|variable|input)File.*/",
|
"when": "view == settings && viewItem =~ /^githubLocalActions.(secret|variable|input|payload)File.*/",
|
||||||
"group": "inline@0"
|
"group": "inline@0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.removeSettingFile",
|
"command": "githubLocalActions.removeSettingFile",
|
||||||
"when": "view == settings && viewItem =~ /^githubLocalActions.(secret|variable|input)File.*/",
|
"when": "view == settings && viewItem =~ /^githubLocalActions.(secret|variable|input|payload)File.*/",
|
||||||
"group": "inline@1"
|
"group": "inline@1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.deleteSettingFile",
|
"command": "githubLocalActions.deleteSettingFile",
|
||||||
"when": "view == settings && viewItem =~ /^githubLocalActions.(secret|variable|input)File.*/",
|
"when": "view == settings && viewItem =~ /^githubLocalActions.(secret|variable|input|payload)File.*/",
|
||||||
"group": "inline@2"
|
"group": "inline@2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
10
src/act.ts
10
src/act.ts
@@ -46,15 +46,16 @@ export enum Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum Option {
|
export enum Option {
|
||||||
Workflows = '-W',
|
Workflows = '--workflows',
|
||||||
Job = '-j',
|
Job = '--job',
|
||||||
Platform = '-P',
|
Platform = '--platform',
|
||||||
Secret = '--secret',
|
Secret = '--secret',
|
||||||
SecretFile = '--secret-file',
|
SecretFile = '--secret-file',
|
||||||
Variable = '--var',
|
Variable = '--var',
|
||||||
VariableFile = '--var-file',
|
VariableFile = '--var-file',
|
||||||
Input = '--input',
|
Input = '--input',
|
||||||
InputFile = '--input-file'
|
InputFile = '--input-file',
|
||||||
|
PayloadFile = '--eventpath'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommandArgs {
|
export interface CommandArgs {
|
||||||
@@ -315,6 +316,7 @@ export class Act {
|
|||||||
(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} ""`) +
|
||||||
` 2>&1 | tee "${logPath}"`;
|
` 2>&1 | tee "${logPath}"`;
|
||||||
|
|
||||||
// Execute task
|
// Execute task
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export interface Settings {
|
|||||||
inputs: Setting[];
|
inputs: Setting[];
|
||||||
inputFiles: SettingFile[];
|
inputFiles: SettingFile[];
|
||||||
runners: Setting[];
|
runners: Setting[];
|
||||||
|
payloadFiles: SettingFile[];
|
||||||
environments: Setting[];
|
environments: Setting[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +39,8 @@ export enum Visibility {
|
|||||||
export enum SettingFileName {
|
export enum SettingFileName {
|
||||||
secretFile = '.secrets',
|
secretFile = '.secrets',
|
||||||
variableFile = '.env',
|
variableFile = '.env',
|
||||||
inputFile = '.input'
|
inputFile = '.input',
|
||||||
|
payloadFile = 'payload.json'
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SettingsManager {
|
export class SettingsManager {
|
||||||
@@ -64,6 +66,7 @@ export class SettingsManager {
|
|||||||
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);
|
||||||
const runners = (await this.getSetting(workspaceFolder, SettingsManager.runnersRegExp, StorageKey.Runners, false, Visibility.show)).filter(runner => !isUserSelected || (runner.selected && runner.value));
|
const runners = (await this.getSetting(workspaceFolder, SettingsManager.runnersRegExp, StorageKey.Runners, false, Visibility.show)).filter(runner => !isUserSelected || (runner.selected && runner.value));
|
||||||
|
const payloadFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.PayloadFiles)).filter(payloadFile => !isUserSelected || payloadFile.selected);
|
||||||
const environments = await this.getEnvironments(workspaceFolder);
|
const environments = await this.getEnvironments(workspaceFolder);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -74,6 +77,7 @@ export class SettingsManager {
|
|||||||
inputs: inputs,
|
inputs: inputs,
|
||||||
inputFiles: inputFiles,
|
inputFiles: inputFiles,
|
||||||
runners: runners,
|
runners: runners,
|
||||||
|
payloadFiles: payloadFiles,
|
||||||
environments: environments
|
environments: environments
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export enum StorageKey {
|
|||||||
VariableFiles = 'variableFiles',
|
VariableFiles = 'variableFiles',
|
||||||
Inputs = 'inputs',
|
Inputs = 'inputs',
|
||||||
InputFiles = 'inputFiles',
|
InputFiles = 'inputFiles',
|
||||||
|
PayloadFiles = 'PayloadFiles',
|
||||||
Runners = 'runners'
|
Runners = 'runners'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
33
src/views/settings/payloads.ts
Normal file
33
src/views/settings/payloads.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||||
|
import { act } from "../../extension";
|
||||||
|
import { SettingFile } from "../../settingsManager";
|
||||||
|
import { StorageKey } from "../../storageManager";
|
||||||
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
|
import SettingFileTreeItem from "./settingFile";
|
||||||
|
|
||||||
|
export default class PayloadsTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||||
|
static contextValue = 'githubLocalActions.payloads';
|
||||||
|
storageKey = StorageKey.PayloadFiles;
|
||||||
|
|
||||||
|
constructor(public workspaceFolder: WorkspaceFolder, payloadFiles: SettingFile[]) {
|
||||||
|
super('Payloads', TreeItemCollapsibleState.Collapsed);
|
||||||
|
const selectedPayloadFiles = payloadFiles.filter(payloadFile => payloadFile.selected);
|
||||||
|
this.description = selectedPayloadFiles.length > 0 ? `${selectedPayloadFiles[0].name}` : ``;
|
||||||
|
this.contextValue = PayloadsTreeItem.contextValue;
|
||||||
|
this.iconPath = new ThemeIcon('json');
|
||||||
|
}
|
||||||
|
|
||||||
|
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||||
|
const items: GithubLocalActionsTreeItem[] = [];
|
||||||
|
|
||||||
|
const settings = await act.settingsManager.getSettings(this.workspaceFolder, false);
|
||||||
|
|
||||||
|
const payloadFileTreeItems: GithubLocalActionsTreeItem[] = [];
|
||||||
|
for (const payloadFile of settings.payloadFiles) {
|
||||||
|
payloadFileTreeItems.push(SettingFileTreeItem.getPayloadTreeItem(this.workspaceFolder, payloadFile));
|
||||||
|
}
|
||||||
|
items.push(...payloadFileTreeItems.sort((a, b) => a.label!.toString().localeCompare(b.label!.toString())));
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,6 +55,18 @@ export default class SettingFileTreeItem extends TreeItem implements GithubLocal
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getPayloadTreeItem(workspaceFolder: WorkspaceFolder, payloadFile: SettingFile): SettingFileTreeItem {
|
||||||
|
return new SettingFileTreeItem(
|
||||||
|
workspaceFolder,
|
||||||
|
payloadFile,
|
||||||
|
StorageKey.PayloadFiles,
|
||||||
|
{
|
||||||
|
contextValue: 'githubLocalActions.payloadFile',
|
||||||
|
iconPath: new ThemeIcon('file')
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { SettingFileName, Visibility } from "../../settingsManager";
|
|||||||
import { StorageKey } from "../../storageManager";
|
import { StorageKey } from "../../storageManager";
|
||||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
import InputsTreeItem from "./inputs";
|
import InputsTreeItem from "./inputs";
|
||||||
|
import PayloadsTreeItem from "./payloads";
|
||||||
import SecretsTreeItem from "./secrets";
|
import SecretsTreeItem from "./secrets";
|
||||||
import SettingTreeItem from "./setting";
|
import SettingTreeItem from "./setting";
|
||||||
import SettingFileTreeItem from "./settingFile";
|
import SettingFileTreeItem from "./settingFile";
|
||||||
@@ -98,6 +99,32 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
commands.registerCommand('githubLocalActions.createPayloadFile', async (payloadsTreeItem: PayloadsTreeItem) => {
|
||||||
|
const payloadFileName = await window.showInputBox({
|
||||||
|
prompt: `Enter the name for the payload file`,
|
||||||
|
placeHolder: `Payload File Name`,
|
||||||
|
value: SettingFileName.payloadFile
|
||||||
|
});
|
||||||
|
|
||||||
|
if (payloadFileName) {
|
||||||
|
await act.settingsManager.createSettingFile(payloadsTreeItem.workspaceFolder, payloadsTreeItem.storageKey, payloadFileName);
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
commands.registerCommand('githubLocalActions.locatePayloadFiles', async (payloadsTreeItem: PayloadsTreeItem) => {
|
||||||
|
const payloadFilesUris = await window.showOpenDialog({
|
||||||
|
title: 'Locate Payload Files',
|
||||||
|
canSelectFiles: true,
|
||||||
|
canSelectFolders: false,
|
||||||
|
canSelectMany: true,
|
||||||
|
defaultUri: payloadsTreeItem.workspaceFolder.uri
|
||||||
|
});
|
||||||
|
|
||||||
|
if (payloadFilesUris) {
|
||||||
|
await act.settingsManager.locateSettingFile(payloadsTreeItem.workspaceFolder, payloadsTreeItem.storageKey, payloadFilesUris);
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
}),
|
||||||
commands.registerCommand('githubLocalActions.openSettingFile', async (settingFileTreeItem: SettingFileTreeItem) => {
|
commands.registerCommand('githubLocalActions.openSettingFile', async (settingFileTreeItem: SettingFileTreeItem) => {
|
||||||
const document = await workspace.openTextDocument(settingFileTreeItem.settingFile.path);
|
const document = await workspace.openTextDocument(settingFileTreeItem.settingFile.path);
|
||||||
await window.showTextDocument(document);
|
await window.showTextDocument(document);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "
|
|||||||
import { act } from "../../extension";
|
import { act } from "../../extension";
|
||||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
import InputsTreeItem from "./inputs";
|
import InputsTreeItem from "./inputs";
|
||||||
|
import PayloadsTreeItem from "./payloads";
|
||||||
import RunnersTreeItem from "./runners";
|
import RunnersTreeItem from "./runners";
|
||||||
import SecretsTreeItem from "./secrets";
|
import SecretsTreeItem from "./secrets";
|
||||||
import VariablesTreeItem from "./variables";
|
import VariablesTreeItem from "./variables";
|
||||||
@@ -23,7 +24,8 @@ export default class WorkspaceFolderSettingsTreeItem extends TreeItem implements
|
|||||||
new SecretsTreeItem(this.workspaceFolder, settings.secrets, settings.secretFiles),
|
new SecretsTreeItem(this.workspaceFolder, settings.secrets, settings.secretFiles),
|
||||||
new VariablesTreeItem(this.workspaceFolder, settings.variables, settings.variableFiles),
|
new VariablesTreeItem(this.workspaceFolder, settings.variables, settings.variableFiles),
|
||||||
new InputsTreeItem(this.workspaceFolder, settings.inputs, settings.inputFiles),
|
new InputsTreeItem(this.workspaceFolder, settings.inputs, settings.inputFiles),
|
||||||
new RunnersTreeItem(this.workspaceFolder, settings.runners)
|
new RunnersTreeItem(this.workspaceFolder, settings.runners),
|
||||||
|
new PayloadsTreeItem(this.workspaceFolder, settings.payloadFiles)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
|
|||||||
Reference in New Issue
Block a user