Add all extension settings
Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
187
package.json
187
package.json
@@ -312,6 +312,18 @@
|
|||||||
"title": "Locate Payload Files",
|
"title": "Locate Payload Files",
|
||||||
"icon": "$(search)"
|
"icon": "$(search)"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"category": "GitHub Local Actions",
|
||||||
|
"command": "githubLocalActions.addOption",
|
||||||
|
"title": "Add Option",
|
||||||
|
"icon": "$(add)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"category": "GitHub Local Actions",
|
||||||
|
"command": "githubLocalActions.editOption",
|
||||||
|
"title": "Edit",
|
||||||
|
"icon": "$(edit)"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"category": "GitHub Local Actions",
|
"category": "GitHub Local Actions",
|
||||||
"command": "githubLocalActions.openSettingFile",
|
"command": "githubLocalActions.openSettingFile",
|
||||||
@@ -320,7 +332,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "GitHub Local Actions",
|
"category": "GitHub Local Actions",
|
||||||
"command": "githubLocalActions.removeSettingFile",
|
"command": "githubLocalActions.removeCustomSetting",
|
||||||
"title": "Remove",
|
"title": "Remove",
|
||||||
"icon": "$(close)"
|
"icon": "$(close)"
|
||||||
},
|
},
|
||||||
@@ -472,12 +484,20 @@
|
|||||||
"command": "githubLocalActions.locatePayloadFiles",
|
"command": "githubLocalActions.locatePayloadFiles",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.addOption",
|
||||||
|
"when": "never"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.editOption",
|
||||||
|
"when": "never"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.openSettingFile",
|
"command": "githubLocalActions.openSettingFile",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.removeSettingFile",
|
"command": "githubLocalActions.removeCustomSetting",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -675,14 +695,24 @@
|
|||||||
"when": "view == settings && viewItem =~ /^githubLocalActions.payloads.*/",
|
"when": "view == settings && viewItem =~ /^githubLocalActions.payloads.*/",
|
||||||
"group": "inline@1"
|
"group": "inline@1"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.addOption",
|
||||||
|
"when": "view == settings && viewItem =~ /^githubLocalActions.options.*/",
|
||||||
|
"group": "inline@0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.editOption",
|
||||||
|
"when": "view == settings && viewItem =~ /^githubLocalActions.option(?!s)_editable.*/",
|
||||||
|
"group": "inline@0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.openSettingFile",
|
"command": "githubLocalActions.openSettingFile",
|
||||||
"when": "view == settings && viewItem =~ /^githubLocalActions.(secret|variable|input|payload)File.*/",
|
"when": "view == settings && viewItem =~ /^githubLocalActions.(secret|variable|input|payload)File.*/",
|
||||||
"group": "inline@0"
|
"group": "inline@0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.removeSettingFile",
|
"command": "githubLocalActions.removeCustomSetting",
|
||||||
"when": "view == settings && viewItem =~ /^githubLocalActions.(secret|variable|input|payload)File.*/",
|
"when": "view == settings && viewItem =~ /^githubLocalActions.((secret|variable|input|payload|)File|option(?!s)).*/",
|
||||||
"group": "inline@1"
|
"group": "inline@1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -709,155 +739,6 @@
|
|||||||
"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`",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": ""
|
"default": ""
|
||||||
},
|
|
||||||
"githubLocalActions.act.actionCachePath": {
|
|
||||||
"description": "Defines the path where the actions get cached and host workspaces are created.",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.actionOfflineMode": {
|
|
||||||
"description": "If action contents exists, it will not be fetch and pull again. If turn on this, will turn off force pull.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.actor": {
|
|
||||||
"description": "User that triggered the event.",
|
|
||||||
"type": "string",
|
|
||||||
"default": "nektos/act"
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.artifactServerAddr": {
|
|
||||||
"markdownDescription": "Defines the address to which the artifact server binds. If not set, `nektos/act` will use the outbound IP address of this machine. This means that it will try to access the internet and return the local IP address of the connection. If the machine cannot access the internet, it returns a preferred IP address from network interfaces. If no IP address is found, this will not be set.",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.artifactServerPath": {
|
|
||||||
"description": "Defines the path where the artifact server stores uploads and retrieves downloads from. If not specified, the artifact server will not start.",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.artifactServerPort": {
|
|
||||||
"description": "Defines the port where the artifact server listens.",
|
|
||||||
"type": "number",
|
|
||||||
"default": 34567
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.bind": {
|
|
||||||
"description": "Bind working directory to container, rather than copy.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.cacheServerAddr": {
|
|
||||||
"markdownDescription": "Defines the address to which the cache server binds. If not set, `nektos/act` will use the outbound IP address of this machine. This means that it will try to access the internet and return the local IP address of the connection. If the machine cannot access the internet, it returns a preferred IP address from network interfaces. If no IP address is found, this will not be set.",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.cacheServerPath": {
|
|
||||||
"description": "Defines the path where the cache server stores caches.",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.cacheServerPort": {
|
|
||||||
"markdownDescription": "Defines the port where the artifact server listens. `0` means a randomly available port.",
|
|
||||||
"type": "number",
|
|
||||||
"default": 0
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.containerArchitecture": {
|
|
||||||
"markdownDescription": "The architecture which should be used to run containers (e.g.: `linux/amd64`). If not specified, the host default architecture will be used. This requires Docker server API Version 1.41+ (ignored on earlier Docker server platforms).",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.containerCapAdd": {
|
|
||||||
"markdownDescription": "Kernel capabilities to add to the workflow containers (e.g. `SYS_PTRACE`).",
|
|
||||||
"type": "array",
|
|
||||||
"default": [],
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.containerCapDrop": {
|
|
||||||
"markdownDescription": "Kernel capabilities to remove from the workflow containers (e.g. `SYS_PTRACE`).",
|
|
||||||
"type": "array",
|
|
||||||
"default": [],
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.containerDaemonSocket": {
|
|
||||||
"markdownDescription": "URI to Docker Engine socket (e.g.: `unix://~/.docker/run/docker.sock` or `-` to disable bind mounting the socket).",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.containerOptions": {
|
|
||||||
"description": "Custom docker container options for the job container without an options property in the job definition.",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.defaultBranch": {
|
|
||||||
"description": "The name of the main branch.",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.detectEvent": {
|
|
||||||
"description": "Use first event type from workflow as event that triggered the workflow.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.directory": {
|
|
||||||
"markdownDescription": "The working directory used when running a `nektos/act` command.",
|
|
||||||
"type": "string",
|
|
||||||
"default": "."
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.githubInstance": {
|
|
||||||
"description": "The GitHub instance to use. Only use this when using GitHub Enterprise Server.",
|
|
||||||
"type": "string",
|
|
||||||
"default": "github.com"
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.insecureSecrets": {
|
|
||||||
"markdownDescription": "Show secrets while printing logs (**NOT RECOMMENDED!**).",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.json": {
|
|
||||||
"description": "Output logs in json format.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.localRepository": {
|
|
||||||
"markdownDescription": "Replaces the specified repository and ref with a local folder (e.g. `https://github.com/test/test@v0=/home/act/test` or `test/test@v0=/home/act/test`, the latter matches any hosts or protocols).",
|
|
||||||
"type": "array",
|
|
||||||
"default": [],
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.logPrefixJobId": {
|
|
||||||
"description": "Output the job id within non-json logs instead of the entire name.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.network": {
|
|
||||||
"description": "Sets a docker network name.",
|
|
||||||
"type": "string",
|
|
||||||
"default": "host"
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.noCacheServer": {
|
|
||||||
"description": "Disable cache server.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.noRecurse": {
|
|
||||||
"markdownDescription": "Flag to disable running workflows from subdirectories of specified path in `--workflows`/`-W` flag.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.noSkipCheckout": {
|
|
||||||
"description": "Do not skip actions/checkout.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"githubLocalActions.act.privileged": {
|
|
||||||
"description": "Use privileged mode.",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
82
src/act.ts
82
src/act.ts
@@ -49,20 +49,67 @@ export enum Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum Option {
|
export enum Option {
|
||||||
Workflows = '--workflows',
|
ActionCachePath = "--action-cache-path",
|
||||||
Job = '--job',
|
ActionOfflineMode = "--action-offline-mode",
|
||||||
Platform = '--platform',
|
Actor = "--actor",
|
||||||
Secret = '--secret',
|
ArtifactServerAddr = "--artifact-server-addr",
|
||||||
SecretFile = '--secret-file',
|
ArtifactServerPath = "--artifact-server-path",
|
||||||
Variable = '--var',
|
ArtifactServerPort = "--artifact-server-port",
|
||||||
VariableFile = '--var-file',
|
Bind = "--bind",
|
||||||
Input = '--input',
|
BugReport = "--bug-report",
|
||||||
InputFile = '--input-file',
|
CacheServerAddr = "--cache-server-addr",
|
||||||
PayloadFile = '--eventpath',
|
CacheServerPath = "--cache-server-path",
|
||||||
|
CacheServerPort = "--cache-server-port",
|
||||||
|
ContainerArchitecture = "--container-architecture",
|
||||||
ActionCachePath = '--action-cache-path',
|
ContainerCapAdd = "--container-cap-add",
|
||||||
ActionOfflineMode = '--action-offline-mode'
|
ContainerCapDrop = "--container-cap-drop",
|
||||||
|
ContainerDaemonSocket = "--container-daemon-socket",
|
||||||
|
ContainerOptions = "--container-options",
|
||||||
|
DefaultBranch = "--defaultbranch",
|
||||||
|
DetectEvent = "--detect-event",
|
||||||
|
Directory = "--directory",
|
||||||
|
DryRun = "--dryrun",
|
||||||
|
Env = "--env",
|
||||||
|
EnvFile = "--env-file",
|
||||||
|
EventPath = "--eventpath",
|
||||||
|
GithubInstance = "--github-instance",
|
||||||
|
Graph = "--graph",
|
||||||
|
Help = "--help",
|
||||||
|
Input = "--input",
|
||||||
|
InputFile = "--input-file",
|
||||||
|
InsecureSecrets = "--insecure-secrets",
|
||||||
|
Job = "--job",
|
||||||
|
Json = "--json",
|
||||||
|
List = "--list",
|
||||||
|
LocalRepository = "--local-repository",
|
||||||
|
LogPrefixJobId = "--log-prefix-job-id",
|
||||||
|
ManPage = "--man-page",
|
||||||
|
Matrix = "--matrix",
|
||||||
|
Network = "--network",
|
||||||
|
NoCacheServer = "--no-cache-server",
|
||||||
|
NoRecurse = "--no-recurse",
|
||||||
|
NoSkipCheckout = "--no-skip-checkout",
|
||||||
|
Platform = "--platform",
|
||||||
|
Privileged = "--privileged",
|
||||||
|
Pull = "--pull",
|
||||||
|
Quiet = "--quiet",
|
||||||
|
Rebuild = "--rebuild",
|
||||||
|
RemoteName = "--remote-name",
|
||||||
|
ReplaceGheActionTokenWithGithubCom = "--replace-ghe-action-token-with-github-com",
|
||||||
|
ReplaceGheActionWithGithubCom = "--replace-ghe-action-with-github-com",
|
||||||
|
Reuse = "--reuse",
|
||||||
|
Rm = "--rm",
|
||||||
|
Secret = "--secret",
|
||||||
|
SecretFile = "--secret-file",
|
||||||
|
UseGitignore = "--use-gitignore",
|
||||||
|
UseNewActionCache = "--use-new-action-cache",
|
||||||
|
Userns = "--userns",
|
||||||
|
Var = "--var",
|
||||||
|
VarFile = "--var-file",
|
||||||
|
Verbose = "--verbose",
|
||||||
|
Version = "--version",
|
||||||
|
Watch = "--watch",
|
||||||
|
Workflows = "--workflows",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommandArgs {
|
export interface CommandArgs {
|
||||||
@@ -300,12 +347,13 @@ export class Act {
|
|||||||
`${actCommand} ${commandArgs.options}` +
|
`${actCommand} ${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.key}=${variable.value}`).join(` ${Option.Variable} `)}` : ``) +
|
(settings.variables.length > 0 ? ` ${Option.Var} ${settings.variables.map(variable => `${variable.key}=${variable.value}`).join(` ${Option.Var} `)}` : ``) +
|
||||||
(settings.variableFiles.length > 0 ? ` ${Option.VariableFile} "${settings.variableFiles[0].path}"` : ` ${Option.VariableFile} ""`) +
|
(settings.variableFiles.length > 0 ? ` ${Option.VarFile} "${settings.variableFiles[0].path}"` : ` ${Option.VarFile} ""`) +
|
||||||
(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.EventPath} "${settings.payloadFiles[0].path}"` : ` ${Option.EventPath} ""`) +
|
||||||
|
(settings.options.map(option => option.path ? ` --${option.name} ${option.path}` : ` --${option.name}`).join(''));
|
||||||
|
|
||||||
// Execute task
|
// Execute task
|
||||||
const taskExecution = await tasks.executeTask({
|
const taskExecution = await tasks.executeTask({
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import * as os from "os";
|
|
||||||
import * as path from "path";
|
|
||||||
import { ConfigurationTarget, workspace } from 'vscode';
|
import { ConfigurationTarget, workspace } from 'vscode';
|
||||||
import { Act } from './act';
|
import { Act } from './act';
|
||||||
|
|
||||||
@@ -11,8 +9,7 @@ export enum Platform {
|
|||||||
|
|
||||||
export enum Section {
|
export enum Section {
|
||||||
actCommand = 'actCommand',
|
actCommand = 'actCommand',
|
||||||
dockerDesktopPath = 'dockerDesktopPath',
|
dockerDesktopPath = 'dockerDesktopPath'
|
||||||
actionCachePath = 'actionCachePath'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace ConfigurationManager {
|
export namespace ConfigurationManager {
|
||||||
@@ -40,13 +37,6 @@ export namespace ConfigurationManager {
|
|||||||
if (!actCommand) {
|
if (!actCommand) {
|
||||||
await ConfigurationManager.set(Section.actCommand, Act.defaultActCommand);
|
await ConfigurationManager.set(Section.actCommand, Act.defaultActCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
let actionCachePath = ConfigurationManager.get<string>(Section.actionCachePath);
|
|
||||||
if (!actionCachePath) {
|
|
||||||
actionCachePath = getCacheDirectory(['act']);
|
|
||||||
|
|
||||||
ConfigurationManager.set(Section.actionCachePath, actionCachePath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSearchTerm(section: Section): string {
|
export function getSearchTerm(section: Section): string {
|
||||||
@@ -60,10 +50,4 @@ export namespace ConfigurationManager {
|
|||||||
export async function set(section: Section, value: any): Promise<void> {
|
export async function set(section: Section, value: any): Promise<void> {
|
||||||
return await workspace.getConfiguration(ConfigurationManager.group).update(section, value, ConfigurationTarget.Global);
|
return await workspace.getConfiguration(ConfigurationManager.group).update(section, value, ConfigurationTarget.Global);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCacheDirectory(paths: string[]) {
|
|
||||||
const userHomeDir = os.homedir();
|
|
||||||
const cacheHomeDir = process.env.XDG_CACHE_HOME || path.join(userHomeDir, '.cache');
|
|
||||||
return path.join(cacheHomeDir, ...paths);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -7,13 +7,14 @@ import { StorageKey, StorageManager } from "./storageManager";
|
|||||||
|
|
||||||
export interface Settings {
|
export interface Settings {
|
||||||
secrets: Setting[];
|
secrets: Setting[];
|
||||||
secretFiles: SettingFile[];
|
secretFiles: CustomSetting[];
|
||||||
variables: Setting[];
|
variables: Setting[];
|
||||||
variableFiles: SettingFile[];
|
variableFiles: CustomSetting[];
|
||||||
inputs: Setting[];
|
inputs: Setting[];
|
||||||
inputFiles: SettingFile[];
|
inputFiles: CustomSetting[];
|
||||||
runners: Setting[];
|
runners: Setting[];
|
||||||
payloadFiles: SettingFile[];
|
payloadFiles: CustomSetting[];
|
||||||
|
options: CustomSetting[];
|
||||||
environments: Setting[];
|
environments: Setting[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,10 +26,14 @@ export interface Setting {
|
|||||||
visible: Visibility
|
visible: Visibility
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SettingFile {
|
// This is either a secret/variable/input/payload file or an option
|
||||||
|
export interface CustomSetting {
|
||||||
name: string,
|
name: string,
|
||||||
path: string,
|
path: string,
|
||||||
selected: boolean
|
selected: boolean,
|
||||||
|
notEditable?: boolean,
|
||||||
|
default?: string,
|
||||||
|
description?: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Visibility {
|
export enum Visibility {
|
||||||
@@ -61,13 +66,14 @@ 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 && secret.value));
|
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.getCustomSettings(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 && variable.value));
|
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.getCustomSettings(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.getCustomSettings(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 payloadFiles = (await this.getCustomSettings(workspaceFolder, StorageKey.PayloadFiles)).filter(payloadFile => !isUserSelected || payloadFile.selected);
|
||||||
|
const options = (await this.getCustomSettings(workspaceFolder, StorageKey.Options)).filter(option => !isUserSelected || (option.selected && (option.path || option.notEditable)));
|
||||||
const environments = await this.getEnvironments(workspaceFolder);
|
const environments = await this.getEnvironments(workspaceFolder);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -79,6 +85,7 @@ export class SettingsManager {
|
|||||||
inputFiles: inputFiles,
|
inputFiles: inputFiles,
|
||||||
runners: runners,
|
runners: runners,
|
||||||
payloadFiles: payloadFiles,
|
payloadFiles: payloadFiles,
|
||||||
|
options: options,
|
||||||
environments: environments
|
environments: environments
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -129,9 +136,9 @@ export class SettingsManager {
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSettingFiles(workspaceFolder: WorkspaceFolder, storageKey: StorageKey): Promise<SettingFile[]> {
|
async getCustomSettings(workspaceFolder: WorkspaceFolder, storageKey: StorageKey): Promise<CustomSetting[]> {
|
||||||
const existingSettingFiles = this.storageManager.get<{ [path: string]: SettingFile[] }>(storageKey) || {};
|
const existingCustomSettings = this.storageManager.get<{ [path: string]: CustomSetting[] }>(storageKey) || {};
|
||||||
return existingSettingFiles[workspaceFolder.uri.fsPath] || [];
|
return existingCustomSettings[workspaceFolder.uri.fsPath] || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
async getEnvironments(workspaceFolder: WorkspaceFolder): Promise<Setting[]> {
|
async getEnvironments(workspaceFolder: WorkspaceFolder): Promise<Setting[]> {
|
||||||
@@ -184,7 +191,7 @@ export class SettingsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async locateSettingFile(workspaceFolder: WorkspaceFolder, storageKey: StorageKey, settingFilesUris: Uri[]) {
|
async locateSettingFile(workspaceFolder: WorkspaceFolder, storageKey: StorageKey, settingFilesUris: Uri[]) {
|
||||||
const settingFilesPaths = (await act.settingsManager.getSettingFiles(workspaceFolder, storageKey)).map(settingFile => settingFile.path);
|
const settingFilesPaths = (await act.settingsManager.getCustomSettings(workspaceFolder, storageKey)).map(settingFile => settingFile.path);
|
||||||
const existingSettingFileNames: string[] = [];
|
const existingSettingFileNames: string[] = [];
|
||||||
|
|
||||||
for await (const uri of settingFilesUris) {
|
for await (const uri of settingFilesUris) {
|
||||||
@@ -193,12 +200,12 @@ export class SettingsManager {
|
|||||||
if (settingFilesPaths.includes(uri.fsPath)) {
|
if (settingFilesPaths.includes(uri.fsPath)) {
|
||||||
existingSettingFileNames.push(settingFileName);
|
existingSettingFileNames.push(settingFileName);
|
||||||
} else {
|
} else {
|
||||||
const newSettingFile: SettingFile = {
|
const newSettingFile: CustomSetting = {
|
||||||
name: path.parse(uri.fsPath).base,
|
name: path.parse(uri.fsPath).base,
|
||||||
path: uri.fsPath,
|
path: uri.fsPath,
|
||||||
selected: false
|
selected: false
|
||||||
};
|
};
|
||||||
await act.settingsManager.editSettingFile(workspaceFolder, newSettingFile, storageKey);
|
await act.settingsManager.editCustomSetting(workspaceFolder, newSettingFile, storageKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,35 +214,44 @@ export class SettingsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async editSettingFile(workspaceFolder: WorkspaceFolder, newSettingFile: SettingFile, storageKey: StorageKey) {
|
async editCustomSetting(workspaceFolder: WorkspaceFolder, newCustomSetting: CustomSetting, storageKey: StorageKey) {
|
||||||
const existingSettingFiles = this.storageManager.get<{ [path: string]: SettingFile[] }>(storageKey) || {};
|
const existingCustomSettings = this.storageManager.get<{ [path: string]: CustomSetting[] }>(storageKey) || {};
|
||||||
if (existingSettingFiles[workspaceFolder.uri.fsPath]) {
|
if (existingCustomSettings[workspaceFolder.uri.fsPath]) {
|
||||||
const index = existingSettingFiles[workspaceFolder.uri.fsPath].findIndex(settingFile => settingFile.path === newSettingFile.path);
|
const index = existingCustomSettings[workspaceFolder.uri.fsPath]
|
||||||
|
.findIndex(customSetting =>
|
||||||
|
storageKey === StorageKey.Options ?
|
||||||
|
customSetting.name === newCustomSetting.name :
|
||||||
|
customSetting.path === newCustomSetting.path
|
||||||
|
);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
existingSettingFiles[workspaceFolder.uri.fsPath][index] = newSettingFile;
|
existingCustomSettings[workspaceFolder.uri.fsPath][index] = newCustomSetting;
|
||||||
} else {
|
} else {
|
||||||
existingSettingFiles[workspaceFolder.uri.fsPath].push(newSettingFile);
|
existingCustomSettings[workspaceFolder.uri.fsPath].push(newCustomSetting);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
existingSettingFiles[workspaceFolder.uri.fsPath] = [newSettingFile];
|
existingCustomSettings[workspaceFolder.uri.fsPath] = [newCustomSetting];
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.storageManager.update(storageKey, existingSettingFiles);
|
await this.storageManager.update(storageKey, existingCustomSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeSettingFile(workspaceFolder: WorkspaceFolder, settingFile: SettingFile, storageKey: StorageKey) {
|
async removeCustomSetting(workspaceFolder: WorkspaceFolder, existingCustomSetting: CustomSetting, storageKey: StorageKey) {
|
||||||
const existingSettingFiles = this.storageManager.get<{ [path: string]: SettingFile[] }>(storageKey) || {};
|
const existingCustomSettings = this.storageManager.get<{ [path: string]: CustomSetting[] }>(storageKey) || {};
|
||||||
if (existingSettingFiles[workspaceFolder.uri.fsPath]) {
|
if (existingCustomSettings[workspaceFolder.uri.fsPath]) {
|
||||||
const settingFileIndex = existingSettingFiles[workspaceFolder.uri.fsPath].findIndex(settingFile => settingFile.path === settingFile.path);
|
const index = existingCustomSettings[workspaceFolder.uri.fsPath].findIndex(customSetting =>
|
||||||
if (settingFileIndex > -1) {
|
storageKey === StorageKey.Options ?
|
||||||
existingSettingFiles[workspaceFolder.uri.fsPath].splice(settingFileIndex, 1);
|
customSetting.name === existingCustomSetting.name :
|
||||||
|
customSetting.path === existingCustomSetting.path
|
||||||
|
);
|
||||||
|
if (index > -1) {
|
||||||
|
existingCustomSettings[workspaceFolder.uri.fsPath].splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.storageManager.update(storageKey, existingSettingFiles);
|
await this.storageManager.update(storageKey, existingCustomSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteSettingFile(workspaceFolder: WorkspaceFolder, settingFile: SettingFile, storageKey: StorageKey) {
|
async deleteSettingFile(workspaceFolder: WorkspaceFolder, settingFile: CustomSetting, storageKey: StorageKey) {
|
||||||
try {
|
try {
|
||||||
await workspace.fs.delete(Uri.file(settingFile.path));
|
await workspace.fs.delete(Uri.file(settingFile.path));
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@@ -246,7 +262,7 @@ export class SettingsManager {
|
|||||||
} catch (error: any) { }
|
} catch (error: any) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.removeSettingFile(workspaceFolder, settingFile, storageKey);
|
await this.removeCustomSetting(workspaceFolder, settingFile, storageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
async editSetting(workspaceFolder: WorkspaceFolder, newSetting: Setting, storageKey: StorageKey) {
|
async editSetting(workspaceFolder: WorkspaceFolder, newSetting: Setting, storageKey: StorageKey) {
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ export enum StorageKey {
|
|||||||
VariableFiles = 'variableFiles',
|
VariableFiles = 'variableFiles',
|
||||||
Inputs = 'inputs',
|
Inputs = 'inputs',
|
||||||
InputFiles = 'inputFiles',
|
InputFiles = 'inputFiles',
|
||||||
|
Runners = 'runners',
|
||||||
PayloadFiles = 'PayloadFiles',
|
PayloadFiles = 'PayloadFiles',
|
||||||
Runners = 'runners'
|
Options = 'options'
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StorageManager {
|
export class StorageManager {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { CancellationToken, Event, FileDecoration, FileDecorationProvider, Provi
|
|||||||
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 InputsTreeItem from "./settings/inputs";
|
||||||
|
import OptionTreeItem from "./settings/option";
|
||||||
|
import OptionsTreeItem from "./settings/options";
|
||||||
import RunnersTreeItem from "./settings/runners";
|
import RunnersTreeItem from "./settings/runners";
|
||||||
import SecretsTreeItem from "./settings/secrets";
|
import SecretsTreeItem from "./settings/secrets";
|
||||||
import { SettingContextValue } from "./settings/setting";
|
import { SettingContextValue } from "./settings/setting";
|
||||||
@@ -42,7 +44,7 @@ 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)) {
|
} else if ([SecretsTreeItem.contextValue, VariablesTreeItem.contextValue, InputsTreeItem.contextValue, RunnersTreeItem.contextValue, OptionsTreeItem.contextValue].includes(uri.scheme)) {
|
||||||
const hasAllValues = params.get('hasAllValues') === 'true';
|
const hasAllValues = params.get('hasAllValues') === 'true';
|
||||||
|
|
||||||
if (!hasAllValues) {
|
if (!hasAllValues) {
|
||||||
@@ -50,11 +52,12 @@ export class DecorationProvider implements FileDecorationProvider {
|
|||||||
color: new ThemeColor('GitHubLocalActions.red')
|
color: new ThemeColor('GitHubLocalActions.red')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else if (Object.values(SettingContextValue).includes(uri.scheme as any)) {
|
} else if ([...Object.values(SettingContextValue), OptionTreeItem].includes(uri.scheme as any)) {
|
||||||
const isSelected = params.get('isSelected') === 'true';
|
const isSelected = params.get('isSelected') === 'true';
|
||||||
const hasValue = params.get('hasValue') === 'true';
|
const hasValue = params.get('hasValue') === 'true';
|
||||||
|
const editable = params.get('editable') === 'true';
|
||||||
|
|
||||||
if (isSelected && !hasValue) {
|
if (isSelected && !hasValue && editable) {
|
||||||
return {
|
return {
|
||||||
badge: '?',
|
badge: '?',
|
||||||
color: new ThemeColor('GitHubLocalActions.red')
|
color: new ThemeColor('GitHubLocalActions.red')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, 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 { CustomSetting, Setting } from "../../settingsManager";
|
||||||
import { StorageKey } from "../../storageManager";
|
import { StorageKey } from "../../storageManager";
|
||||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
import SettingTreeItem from "./setting";
|
import SettingTreeItem from "./setting";
|
||||||
@@ -10,7 +10,7 @@ export default class InputsTreeItem extends TreeItem implements GithubLocalActio
|
|||||||
static contextValue = 'githubLocalActions.inputs';
|
static contextValue = 'githubLocalActions.inputs';
|
||||||
storageKey = StorageKey.InputFiles;
|
storageKey = StorageKey.InputFiles;
|
||||||
|
|
||||||
constructor(public workspaceFolder: WorkspaceFolder, inputs: Setting[], inputFiles: SettingFile[]) {
|
constructor(public workspaceFolder: WorkspaceFolder, inputs: Setting[], inputFiles: CustomSetting[]) {
|
||||||
super('Inputs', TreeItemCollapsibleState.Collapsed);
|
super('Inputs', TreeItemCollapsibleState.Collapsed);
|
||||||
const selectedInputFiles = inputFiles.filter(inputFile => inputFile.selected);
|
const selectedInputFiles = inputFiles.filter(inputFile => inputFile.selected);
|
||||||
this.description = `${inputs.filter(input => input.selected).length}/${inputs.length}` +
|
this.description = `${inputs.filter(input => input.selected).length}/${inputs.length}` +
|
||||||
|
|||||||
29
src/views/settings/option.ts
Normal file
29
src/views/settings/option.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { ThemeIcon, TreeItem, TreeItemCheckboxState, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||||
|
import { CustomSetting } from "../../settingsManager";
|
||||||
|
import { StorageKey } from "../../storageManager";
|
||||||
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
|
|
||||||
|
export default class OptionTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||||
|
static contextValue = 'githubLocalActions.option';
|
||||||
|
option: CustomSetting;
|
||||||
|
storageKey: StorageKey;
|
||||||
|
|
||||||
|
constructor(public workspaceFolder: WorkspaceFolder, option: CustomSetting) {
|
||||||
|
super(option.name, TreeItemCollapsibleState.None);
|
||||||
|
this.option = option;
|
||||||
|
this.storageKey = StorageKey.Options;
|
||||||
|
this.description = option.path;
|
||||||
|
this.contextValue = `${OptionTreeItem.contextValue}_${option.notEditable ? `` : `editable`}`;
|
||||||
|
this.iconPath = new ThemeIcon('symbol-property');
|
||||||
|
this.checkboxState = option.selected ? TreeItemCheckboxState.Checked : TreeItemCheckboxState.Unchecked;
|
||||||
|
this.tooltip = `Option: ${option.name}\n` +
|
||||||
|
(option.path ? `Value: ${option.path}\n` : ``) +
|
||||||
|
(option.default ? `Default: ${option.default}\n` : ``) +
|
||||||
|
`Description: ${option.description}`;
|
||||||
|
this.resourceUri = Uri.parse(`${OptionTreeItem.contextValue}:${option.name}?isSelected=${option.selected}&hasValue=${option.path !== ''}&editable=${!option.notEditable}`, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/views/settings/options.ts
Normal file
32
src/views/settings/options.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||||
|
import { act } from "../../extension";
|
||||||
|
import { CustomSetting } from "../../settingsManager";
|
||||||
|
import { StorageKey } from "../../storageManager";
|
||||||
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
|
import OptionTreeItem from "./option";
|
||||||
|
|
||||||
|
export default class OptionsTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||||
|
static contextValue = 'githubLocalActions.options';
|
||||||
|
storageKey: StorageKey;
|
||||||
|
|
||||||
|
constructor(public workspaceFolder: WorkspaceFolder, options: CustomSetting[]) {
|
||||||
|
super('Options', TreeItemCollapsibleState.Collapsed);
|
||||||
|
this.storageKey = StorageKey.Options;
|
||||||
|
this.description = `${options.filter(option => option.selected).length}/${options.length}`;
|
||||||
|
this.contextValue = OptionsTreeItem.contextValue;
|
||||||
|
this.iconPath = new ThemeIcon('gear');
|
||||||
|
const hasAllValues = options.filter(option => option.selected && option.path === '' && !option.notEditable).length === 0;
|
||||||
|
this.resourceUri = Uri.parse(`${OptionsTreeItem.contextValue}:Options?hasAllValues=${hasAllValues}`, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||||
|
const items: GithubLocalActionsTreeItem[] = [];
|
||||||
|
|
||||||
|
const settings = await act.settingsManager.getSettings(this.workspaceFolder, false);
|
||||||
|
for (const option of settings.options) {
|
||||||
|
items.push(new OptionTreeItem(this.workspaceFolder, option));
|
||||||
|
}
|
||||||
|
|
||||||
|
return items.sort((a, b) => a.label!.toString().localeCompare(b.label!.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||||
import { act } from "../../extension";
|
import { act } from "../../extension";
|
||||||
import { SettingFile } from "../../settingsManager";
|
import { CustomSetting } from "../../settingsManager";
|
||||||
import { StorageKey } from "../../storageManager";
|
import { StorageKey } from "../../storageManager";
|
||||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
import SettingFileTreeItem from "./settingFile";
|
import SettingFileTreeItem from "./settingFile";
|
||||||
@@ -9,7 +9,7 @@ export default class PayloadsTreeItem extends TreeItem implements GithubLocalAct
|
|||||||
static contextValue = 'githubLocalActions.payloads';
|
static contextValue = 'githubLocalActions.payloads';
|
||||||
storageKey = StorageKey.PayloadFiles;
|
storageKey = StorageKey.PayloadFiles;
|
||||||
|
|
||||||
constructor(public workspaceFolder: WorkspaceFolder, payloadFiles: SettingFile[]) {
|
constructor(public workspaceFolder: WorkspaceFolder, payloadFiles: CustomSetting[]) {
|
||||||
super('Payloads', TreeItemCollapsibleState.Collapsed);
|
super('Payloads', TreeItemCollapsibleState.Collapsed);
|
||||||
const selectedPayloadFiles = payloadFiles.filter(payloadFile => payloadFile.selected);
|
const selectedPayloadFiles = payloadFiles.filter(payloadFile => payloadFile.selected);
|
||||||
this.description = selectedPayloadFiles.length > 0 ? `${selectedPayloadFiles[0].name}` : ``;
|
this.description = selectedPayloadFiles.length > 0 ? `${selectedPayloadFiles[0].name}` : ``;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, 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 { CustomSetting, Setting } from "../../settingsManager";
|
||||||
import { StorageKey } from "../../storageManager";
|
import { StorageKey } from "../../storageManager";
|
||||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
import SettingTreeItem from "./setting";
|
import SettingTreeItem from "./setting";
|
||||||
@@ -10,7 +10,7 @@ export default class SecretsTreeItem extends TreeItem implements GithubLocalActi
|
|||||||
static contextValue = 'githubLocalActions.secrets';
|
static contextValue = 'githubLocalActions.secrets';
|
||||||
storageKey = StorageKey.SecretFiles;
|
storageKey = StorageKey.SecretFiles;
|
||||||
|
|
||||||
constructor(public workspaceFolder: WorkspaceFolder, secrets: Setting[], secretFiles: SettingFile[]) {
|
constructor(public workspaceFolder: WorkspaceFolder, secrets: Setting[], secretFiles: CustomSetting[]) {
|
||||||
super('Secrets', TreeItemCollapsibleState.Collapsed);
|
super('Secrets', TreeItemCollapsibleState.Collapsed);
|
||||||
const selectedSecretFiles = secretFiles.filter(secretFile => secretFile.selected);
|
const selectedSecretFiles = secretFiles.filter(secretFile => secretFile.selected);
|
||||||
this.description = `${secrets.filter(secret => secret.selected).length}/${secrets.length}` +
|
this.description = `${secrets.filter(secret => secret.selected).length}/${secrets.length}` +
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { ThemeIcon, TreeItem, TreeItemCheckboxState, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
import { ThemeIcon, TreeItem, TreeItemCheckboxState, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||||
import { SettingFile } from "../../settingsManager";
|
import { CustomSetting } from "../../settingsManager";
|
||||||
import { StorageKey } from "../../storageManager";
|
import { StorageKey } from "../../storageManager";
|
||||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
|
|
||||||
export default class SettingFileTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
export default class SettingFileTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||||
settingFile: SettingFile;
|
settingFile: CustomSetting;
|
||||||
storageKey: StorageKey;
|
storageKey: StorageKey;
|
||||||
|
|
||||||
constructor(public workspaceFolder: WorkspaceFolder, settingFile: SettingFile, storageKey: StorageKey, treeItem: { contextValue: string, iconPath: ThemeIcon }) {
|
constructor(public workspaceFolder: WorkspaceFolder, settingFile: CustomSetting, storageKey: StorageKey, treeItem: { contextValue: string, iconPath: ThemeIcon }) {
|
||||||
super(settingFile.name, TreeItemCollapsibleState.None);
|
super(settingFile.name, TreeItemCollapsibleState.None);
|
||||||
this.settingFile = settingFile;
|
this.settingFile = settingFile;
|
||||||
this.storageKey = storageKey;
|
this.storageKey = storageKey;
|
||||||
@@ -16,10 +16,10 @@ export default class SettingFileTreeItem extends TreeItem implements GithubLocal
|
|||||||
this.iconPath = treeItem.iconPath;
|
this.iconPath = treeItem.iconPath;
|
||||||
this.checkboxState = settingFile.selected ? TreeItemCheckboxState.Checked : TreeItemCheckboxState.Unchecked;
|
this.checkboxState = settingFile.selected ? TreeItemCheckboxState.Checked : TreeItemCheckboxState.Unchecked;
|
||||||
this.tooltip = `Name: ${settingFile.name}\n` +
|
this.tooltip = `Name: ${settingFile.name}\n` +
|
||||||
`Path: ${settingFile.path}\n`;
|
`Path: ${settingFile.path}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getSecretTreeItem(workspaceFolder: WorkspaceFolder, secretFile: SettingFile): SettingFileTreeItem {
|
static getSecretTreeItem(workspaceFolder: WorkspaceFolder, secretFile: CustomSetting): SettingFileTreeItem {
|
||||||
return new SettingFileTreeItem(
|
return new SettingFileTreeItem(
|
||||||
workspaceFolder,
|
workspaceFolder,
|
||||||
secretFile,
|
secretFile,
|
||||||
@@ -31,7 +31,7 @@ export default class SettingFileTreeItem extends TreeItem implements GithubLocal
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getVariableTreeItem(workspaceFolder: WorkspaceFolder, variableFile: SettingFile): SettingFileTreeItem {
|
static getVariableTreeItem(workspaceFolder: WorkspaceFolder, variableFile: CustomSetting): SettingFileTreeItem {
|
||||||
return new SettingFileTreeItem(
|
return new SettingFileTreeItem(
|
||||||
workspaceFolder,
|
workspaceFolder,
|
||||||
variableFile,
|
variableFile,
|
||||||
@@ -43,7 +43,7 @@ export default class SettingFileTreeItem extends TreeItem implements GithubLocal
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getInputTreeItem(workspaceFolder: WorkspaceFolder, inputFile: SettingFile): SettingFileTreeItem {
|
static getInputTreeItem(workspaceFolder: WorkspaceFolder, inputFile: CustomSetting): SettingFileTreeItem {
|
||||||
return new SettingFileTreeItem(
|
return new SettingFileTreeItem(
|
||||||
workspaceFolder,
|
workspaceFolder,
|
||||||
inputFile,
|
inputFile,
|
||||||
@@ -55,7 +55,7 @@ export default class SettingFileTreeItem extends TreeItem implements GithubLocal
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPayloadTreeItem(workspaceFolder: WorkspaceFolder, payloadFile: SettingFile): SettingFileTreeItem {
|
static getPayloadTreeItem(workspaceFolder: WorkspaceFolder, payloadFile: CustomSetting): SettingFileTreeItem {
|
||||||
return new SettingFileTreeItem(
|
return new SettingFileTreeItem(
|
||||||
workspaceFolder,
|
workspaceFolder,
|
||||||
payloadFile,
|
payloadFile,
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
|
import * as os from "os";
|
||||||
|
import * as path from "path";
|
||||||
import { CancellationToken, commands, EventEmitter, ExtensionContext, QuickPickItem, QuickPickItemKind, ThemeIcon, TreeCheckboxChangeEvent, TreeDataProvider, TreeItem, TreeItemCheckboxState, Uri, window, workspace } from "vscode";
|
import { CancellationToken, commands, EventEmitter, ExtensionContext, QuickPickItem, QuickPickItemKind, ThemeIcon, TreeCheckboxChangeEvent, TreeDataProvider, TreeItem, TreeItemCheckboxState, Uri, window, workspace } from "vscode";
|
||||||
|
import { Option } from "../../act";
|
||||||
import { act } from "../../extension";
|
import { act } from "../../extension";
|
||||||
import { SettingFileName, Visibility } from "../../settingsManager";
|
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 OptionTreeItem from "./option";
|
||||||
|
import OptionsTreeItem from "./options";
|
||||||
import PayloadsTreeItem from "./payloads";
|
import PayloadsTreeItem from "./payloads";
|
||||||
import SecretsTreeItem from "./secrets";
|
import SecretsTreeItem from "./secrets";
|
||||||
import SettingTreeItem from "./setting";
|
import SettingTreeItem from "./setting";
|
||||||
@@ -111,6 +116,242 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
commands.registerCommand('githubLocalActions.addOption', async (optionsTreeItem: OptionsTreeItem) => {
|
||||||
|
let options: any[] = [
|
||||||
|
{
|
||||||
|
label: Option.ActionCachePath,
|
||||||
|
description: this.getCacheDirectory(['act']),
|
||||||
|
detail: 'Defines the path where the actions get cached and host workspaces are created.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.ActionOfflineMode,
|
||||||
|
detail: 'If action contents exists, it will not be fetched and pulled again. If this is turned on, it will turn off force pull.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Actor,
|
||||||
|
description: 'nektos/act',
|
||||||
|
detail: 'User that triggered the event.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.ArtifactServerAddr,
|
||||||
|
description: '',
|
||||||
|
detail: 'Defines the address to which the artifact server binds. If not set, nektos/act will use the outbound IP address of this machine. This means that it will try to access the internet and return the local IP address of the connection. If the machine cannot access the internet, it returns a preferred IP address from network interfaces. If no IP address is found, this will not be set.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.ArtifactServerPath,
|
||||||
|
description: '',
|
||||||
|
detail: 'Defines the path where the artifact server stores uploads and retrieves downloads from. If not specified, the artifact server will not start.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.ArtifactServerPort,
|
||||||
|
description: '34567',
|
||||||
|
detail: 'Defines the port where the artifact server listens.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Bind,
|
||||||
|
detail: 'Bind working directory to container, rather than copy.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.CacheServerAddr,
|
||||||
|
description: '',
|
||||||
|
detail: 'Defines the address to which the cache server binds. If not set, nektos/act will use the outbound IP address of this machine. This means that it will try to access the internet and return the local IP address of the connection. If the machine cannot access the internet, it returns a preferred IP address from network interfaces. If no IP address is found, this will not be set.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.CacheServerPath,
|
||||||
|
description: this.getCacheDirectory(['actcache']),
|
||||||
|
detail: 'Defines the path where the cache server stores caches.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.CacheServerPort,
|
||||||
|
description: '0',
|
||||||
|
detail: 'Defines the port where the artifact server listens. 0 means a randomly available port.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.ContainerArchitecture,
|
||||||
|
description: '',
|
||||||
|
detail: 'The architecture which should be used to run containers (e.g.: linux/amd64). If not specified, the host default architecture will be used. This requires Docker server API Version 1.41+ (ignored on earlier Docker server platforms).'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.ContainerCapAdd,
|
||||||
|
description: '',
|
||||||
|
detail: 'Kernel capabilities to add to the workflow containers (e.g. SYS_PTRACE).'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.ContainerCapDrop,
|
||||||
|
description: '',
|
||||||
|
detail: 'Kernel capabilities to remove from the workflow containers (e.g. SYS_PTRACE).'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.ContainerDaemonSocket,
|
||||||
|
description: '',
|
||||||
|
detail: 'URI to Docker Engine socket (e.g.: unix://~/.docker/run/docker.sock or - to disable bind mounting the socket).'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.ContainerOptions,
|
||||||
|
description: '',
|
||||||
|
detail: 'Custom docker container options for the job container without an options property in the job definition.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.DefaultBranch,
|
||||||
|
description: '',
|
||||||
|
detail: 'The name of the main branch.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.DetectEvent,
|
||||||
|
detail: 'Use first event type from workflow as event that triggered the workflow.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Directory,
|
||||||
|
description: '.',
|
||||||
|
detail: 'The working directory used when running a nektos/act command.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.DryRun,
|
||||||
|
detail: 'Disable container creation and validate only workflow correctness.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.GithubInstance,
|
||||||
|
description: 'github.com',
|
||||||
|
detail: 'The GitHub instance to use. Only use this when using GitHub Enterprise Server.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.InsecureSecrets,
|
||||||
|
detail: 'Show secrets while printing logs (NOT RECOMMENDED!).'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Json,
|
||||||
|
detail: 'Output logs in json format.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.LocalRepository,
|
||||||
|
description: '',
|
||||||
|
detail: 'Replaces the specified repository and ref with a local folder (e.g. https://github.com/test/test@v0=/home/act/test or test/test@v0=/home/act/test, the latter matches any hosts or protocols).'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.LogPrefixJobId,
|
||||||
|
detail: 'Output the job id within non-json logs instead of the entire name.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Network,
|
||||||
|
description: 'host',
|
||||||
|
detail: 'Sets a docker network name.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.NoCacheServer,
|
||||||
|
detail: 'Disable cache server.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.NoRecurse,
|
||||||
|
detail: 'Flag to disable running workflows from subdirectories of specified path in --workflows/-W flag.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.NoSkipCheckout,
|
||||||
|
detail: 'Do not skip actions/checkout.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Privileged,
|
||||||
|
detail: 'Use privileged mode.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Pull,
|
||||||
|
detail: 'Pull docker image(s) even if already present.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Quiet,
|
||||||
|
detail: 'Disable logging of output from steps.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Rebuild,
|
||||||
|
detail: 'Rebuild local action docker image(s) even if already present.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.RemoteName,
|
||||||
|
description: 'origin',
|
||||||
|
detail: 'Git remote name that will be used to retrieve the URL of Git repo.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.ReplaceGheActionTokenWithGithubCom,
|
||||||
|
description: '',
|
||||||
|
detail: 'If you are using replace-ghe-action-with-github-com and you want to use private actions on GitHub, you have to set a personal access token.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.ReplaceGheActionWithGithubCom,
|
||||||
|
description: '',
|
||||||
|
detail: 'If you are using GitHub Enterprise Server and allow specified actions from GitHub (github.com), you can set actions on this.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Reuse,
|
||||||
|
detail: 'Don\'t remove container(s) on successfully completed workflow(s) to maintain state between runs.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Rm,
|
||||||
|
detail: 'Automatically remove container(s)/volume(s) after a workflow(s) failure.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.UseGitignore,
|
||||||
|
detail: 'Controls whether paths specified in a .gitignore file should be copied into the container.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.UseNewActionCache,
|
||||||
|
detail: 'Enable using the new Action Cache for storing Actions locally.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Userns,
|
||||||
|
description: '',
|
||||||
|
detail: 'User namespace to use.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: Option.Verbose,
|
||||||
|
detail: 'Enable verbose output.'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
options.forEach((option, index) => {
|
||||||
|
options[index].label = options[index].label.slice(2)
|
||||||
|
options[index].iconPath = new ThemeIcon('symbol-property');
|
||||||
|
})
|
||||||
|
|
||||||
|
const settings = await act.settingsManager.getSettings(optionsTreeItem.workspaceFolder, false);
|
||||||
|
const optionNames = settings.options.map(option => option.name);
|
||||||
|
options = options.filter(option => !optionNames.includes(option.label));
|
||||||
|
|
||||||
|
const selectedOption = await window.showQuickPick(options, {
|
||||||
|
title: 'Select the option to add',
|
||||||
|
placeHolder: 'Option',
|
||||||
|
matchOnDetail: true
|
||||||
|
});
|
||||||
|
|
||||||
|
if (selectedOption) {
|
||||||
|
const requiresInputFromUser: boolean = selectedOption.description !== undefined;
|
||||||
|
let value: string | undefined;
|
||||||
|
|
||||||
|
if (requiresInputFromUser) {
|
||||||
|
value = await window.showInputBox({
|
||||||
|
prompt: `Enter a value for the option`,
|
||||||
|
placeHolder: `Option value`,
|
||||||
|
value: selectedOption.description
|
||||||
|
});
|
||||||
|
|
||||||
|
if (value === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await act.settingsManager.editCustomSetting(
|
||||||
|
optionsTreeItem.workspaceFolder,
|
||||||
|
{
|
||||||
|
name: selectedOption.label,
|
||||||
|
path: value || '',
|
||||||
|
selected: false,
|
||||||
|
notEditable: !requiresInputFromUser,
|
||||||
|
default: selectedOption.description,
|
||||||
|
description: selectedOption.detail
|
||||||
|
},
|
||||||
|
optionsTreeItem.storageKey
|
||||||
|
);
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
}),
|
||||||
commands.registerCommand('githubLocalActions.locatePayloadFiles', async (payloadsTreeItem: PayloadsTreeItem) => {
|
commands.registerCommand('githubLocalActions.locatePayloadFiles', async (payloadsTreeItem: PayloadsTreeItem) => {
|
||||||
const payloadFilesUris = await window.showOpenDialog({
|
const payloadFilesUris = await window.showOpenDialog({
|
||||||
title: 'Locate Payload Files',
|
title: 'Locate Payload Files',
|
||||||
@@ -125,6 +366,20 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
commands.registerCommand('githubLocalActions.editOption', async (optionTreeItem: OptionTreeItem) => {
|
||||||
|
const value = await window.showInputBox({
|
||||||
|
prompt: `Enter a value for the option (${optionTreeItem.option.name})`,
|
||||||
|
placeHolder: `Option value`,
|
||||||
|
value: optionTreeItem.option.path
|
||||||
|
});
|
||||||
|
|
||||||
|
if (value !== undefined) {
|
||||||
|
const newOption = optionTreeItem.option;
|
||||||
|
newOption.path = value;
|
||||||
|
await act.settingsManager.editCustomSetting(optionTreeItem.workspaceFolder, newOption, optionTreeItem.storageKey);
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
}),
|
||||||
commands.registerCommand('githubLocalActions.openSettingFile', async (settingFileTreeItem: SettingFileTreeItem) => {
|
commands.registerCommand('githubLocalActions.openSettingFile', async (settingFileTreeItem: SettingFileTreeItem) => {
|
||||||
try {
|
try {
|
||||||
const document = await workspace.openTextDocument(settingFileTreeItem.settingFile.path);
|
const document = await workspace.openTextDocument(settingFileTreeItem.settingFile.path);
|
||||||
@@ -138,8 +393,11 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
commands.registerCommand('githubLocalActions.removeSettingFile', async (settingFileTreeItem: SettingFileTreeItem) => {
|
commands.registerCommand('githubLocalActions.removeCustomSetting', async (customTreeItem: SettingFileTreeItem | OptionTreeItem) => {
|
||||||
await act.settingsManager.removeSettingFile(settingFileTreeItem.workspaceFolder, settingFileTreeItem.settingFile, settingFileTreeItem.storageKey);
|
const existingCustomSetting = customTreeItem instanceof SettingFileTreeItem ?
|
||||||
|
customTreeItem.settingFile :
|
||||||
|
customTreeItem.option;
|
||||||
|
await act.settingsManager.removeCustomSetting(customTreeItem.workspaceFolder, existingCustomSetting, customTreeItem.storageKey);
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}),
|
}),
|
||||||
commands.registerCommand('githubLocalActions.deleteSettingFile', async (settingFileTreeItem: SettingFileTreeItem) => {
|
commands.registerCommand('githubLocalActions.deleteSettingFile', async (settingFileTreeItem: SettingFileTreeItem) => {
|
||||||
@@ -297,28 +555,32 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
async onDidChangeCheckboxState(event: TreeCheckboxChangeEvent<SettingTreeItem | SettingFileTreeItem>) {
|
async onDidChangeCheckboxState(event: TreeCheckboxChangeEvent<SettingTreeItem | SettingFileTreeItem | OptionTreeItem>) {
|
||||||
for await (const [treeItem, state] of event.items) {
|
for await (const [treeItem, state] of event.items) {
|
||||||
if (treeItem instanceof SettingTreeItem) {
|
if (treeItem instanceof SettingTreeItem) {
|
||||||
const newSetting = treeItem.setting;
|
const newSetting = treeItem.setting;
|
||||||
newSetting.selected = (state === TreeItemCheckboxState.Checked);
|
newSetting.selected = (state === TreeItemCheckboxState.Checked);
|
||||||
await act.settingsManager.editSetting(treeItem.workspaceFolder, newSetting, treeItem.storageKey);
|
await act.settingsManager.editSetting(treeItem.workspaceFolder, newSetting, treeItem.storageKey);
|
||||||
|
} else if (treeItem instanceof OptionTreeItem) {
|
||||||
|
const newOption = treeItem.option;
|
||||||
|
newOption.selected = (state === TreeItemCheckboxState.Checked);
|
||||||
|
await act.settingsManager.editCustomSetting(treeItem.workspaceFolder, newOption, treeItem.storageKey);
|
||||||
} else {
|
} else {
|
||||||
const isSelected = (state === TreeItemCheckboxState.Checked);
|
const isSelected = (state === TreeItemCheckboxState.Checked);
|
||||||
|
|
||||||
// Update check box state for current setting file tree item
|
// Update check box state for current setting file tree item
|
||||||
const newSettingFile = treeItem.settingFile;
|
const newSettingFile = treeItem.settingFile;
|
||||||
newSettingFile.selected = isSelected;
|
newSettingFile.selected = isSelected;
|
||||||
await act.settingsManager.editSettingFile(treeItem.workspaceFolder, newSettingFile, treeItem.storageKey);
|
await act.settingsManager.editCustomSetting(treeItem.workspaceFolder, newSettingFile, treeItem.storageKey);
|
||||||
|
|
||||||
// Update check box state for other setting file tree items
|
// Update check box state for other setting file tree items
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
const settingFiles = await act.settingsManager.getSettingFiles(treeItem.workspaceFolder, treeItem.storageKey);
|
const settingFiles = await act.settingsManager.getCustomSettings(treeItem.workspaceFolder, treeItem.storageKey);
|
||||||
for (const settingFile of settingFiles) {
|
for (const settingFile of settingFiles) {
|
||||||
if (settingFile.selected && settingFile.path !== treeItem.settingFile.path) {
|
if (settingFile.selected && settingFile.path !== treeItem.settingFile.path) {
|
||||||
const newSettingFile = settingFile;
|
const newSettingFile = settingFile;
|
||||||
newSettingFile.selected = false;
|
newSettingFile.selected = false;
|
||||||
await act.settingsManager.editSettingFile(treeItem.workspaceFolder, newSettingFile, treeItem.storageKey);
|
await act.settingsManager.editCustomSetting(treeItem.workspaceFolder, newSettingFile, treeItem.storageKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -359,4 +621,10 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCacheDirectory(paths: string[]) {
|
||||||
|
const userHomeDir = os.homedir();
|
||||||
|
const cacheHomeDir = process.env.XDG_CACHE_HOME || path.join(userHomeDir, '.cache');
|
||||||
|
return path.join(cacheHomeDir, ...paths);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, 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 { CustomSetting, Setting } from "../../settingsManager";
|
||||||
import { StorageKey } from "../../storageManager";
|
import { StorageKey } from "../../storageManager";
|
||||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
import SettingTreeItem from "./setting";
|
import SettingTreeItem from "./setting";
|
||||||
@@ -10,7 +10,7 @@ export default class VariablesTreeItem extends TreeItem implements GithubLocalAc
|
|||||||
static contextValue = 'githubLocalActions.variables';
|
static contextValue = 'githubLocalActions.variables';
|
||||||
storageKey = StorageKey.VariableFiles;
|
storageKey = StorageKey.VariableFiles;
|
||||||
|
|
||||||
constructor(public workspaceFolder: WorkspaceFolder, variables: Setting[], variableFiles: SettingFile[]) {
|
constructor(public workspaceFolder: WorkspaceFolder, variables: Setting[], variableFiles: CustomSetting[]) {
|
||||||
super('Variables', TreeItemCollapsibleState.Collapsed);
|
super('Variables', TreeItemCollapsibleState.Collapsed);
|
||||||
const selectedVariableFiles = variableFiles.filter(variableFile => variableFile.selected);
|
const selectedVariableFiles = variableFiles.filter(variableFile => variableFile.selected);
|
||||||
this.description = `${variables.filter(variable => variable.selected).length}/${variables.length}` +
|
this.description = `${variables.filter(variable => variable.selected).length}/${variables.length}` +
|
||||||
|
|||||||
@@ -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 OptionsTreeItem from "./options";
|
||||||
import PayloadsTreeItem from "./payloads";
|
import PayloadsTreeItem from "./payloads";
|
||||||
import RunnersTreeItem from "./runners";
|
import RunnersTreeItem from "./runners";
|
||||||
import SecretsTreeItem from "./secrets";
|
import SecretsTreeItem from "./secrets";
|
||||||
@@ -25,7 +26,8 @@ export default class WorkspaceFolderSettingsTreeItem extends TreeItem implements
|
|||||||
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)
|
new PayloadsTreeItem(this.workspaceFolder, settings.payloadFiles),
|
||||||
|
new OptionsTreeItem(this.workspaceFolder, settings.options)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
|
|||||||
Reference in New Issue
Block a user