From 76c596b4291c8546f0a1176c310aca229427a525 Mon Sep 17 00:00:00 2001 From: Sebatian Rath Date: Fri, 23 Jan 2026 18:57:33 -0500 Subject: [PATCH] Add core/dir-create@v1 --- .../interface_core_dir-create_v1.go | 20 +++++++ nodes/dir-create@v1.go | 54 +++++++++++++++++++ nodes/dir-create@v1.yml | 40 ++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 node_interfaces/interface_core_dir-create_v1.go create mode 100644 nodes/dir-create@v1.go create mode 100644 nodes/dir-create@v1.yml diff --git a/node_interfaces/interface_core_dir-create_v1.go b/node_interfaces/interface_core_dir-create_v1.go new file mode 100644 index 0000000..74fa10d --- /dev/null +++ b/node_interfaces/interface_core_dir-create_v1.go @@ -0,0 +1,20 @@ +// Code generated by actrun. DO NOT EDIT. + +package node_interfaces + +import "github.com/actionforge/actrun-cli/core" // Create a directory on the file system. + +// ==> (o) Inputs + +// If true, creates all parent directories as needed (like mkdir -p). If false, only creates the final directory and fails if parent directories don't exist. +const Core_dir_create_v1_Input_create_parents core.InputId = "create_parents" +const Core_dir_create_v1_Input_exec core.InputId = "exec" +// The path of the directory to create. +const Core_dir_create_v1_Input_path core.InputId = "path" + +// Outputs (o) ==> + +// Executes if the directory creation fails. +const Core_dir_create_v1_Output_exec_err core.OutputId = "exec-err" +// Executes if the directory creation is successful. +const Core_dir_create_v1_Output_exec_success core.OutputId = "exec-success" diff --git a/nodes/dir-create@v1.go b/nodes/dir-create@v1.go new file mode 100644 index 0000000..67c504f --- /dev/null +++ b/nodes/dir-create@v1.go @@ -0,0 +1,54 @@ +package nodes + +import ( + _ "embed" + "os" + + "github.com/actionforge/actrun-cli/core" + ni "github.com/actionforge/actrun-cli/node_interfaces" +) + +//go:embed dir-create@v1.yml +var dirCreateDefinition string + +type DirCreateNode struct { + core.NodeBaseComponent + core.Executions + core.Inputs + core.Outputs +} + +func (n *DirCreateNode) ExecuteImpl(c *core.ExecutionState, inputId core.InputId, prevError error) error { + path, err := core.InputValueById[string](c, n, ni.Core_dir_create_v1_Input_path) + if err != nil { + return err + } + + mkdirAll, err := core.InputValueById[bool](c, n, ni.Core_dir_create_v1_Input_create_parents) + if err != nil { + return err + } + + var mkdirErr error + if mkdirAll { + mkdirErr = os.MkdirAll(path, 0755) + } else { + mkdirErr = os.Mkdir(path, 0755) + } + + if mkdirErr != nil { + err := core.CreateErr(c, mkdirErr, "failed to create directory") + return n.Execute(ni.Core_dir_create_v1_Output_exec_err, c, err) + } + + return n.Execute(ni.Core_dir_create_v1_Output_exec_success, c, nil) +} + +func init() { + err := core.RegisterNodeFactory(dirCreateDefinition, func(ctx any, parent core.NodeBaseInterface, parentId string, nodeDef map[string]any, validate bool) (core.NodeBaseInterface, []error) { + return &DirCreateNode{}, nil + }) + if err != nil { + panic(err) + } +} diff --git a/nodes/dir-create@v1.yml b/nodes/dir-create@v1.yml new file mode 100644 index 0000000..43b1cd5 --- /dev/null +++ b/nodes/dir-create@v1.yml @@ -0,0 +1,40 @@ +yaml-version: 3.0 + +id: core/dir-create +name: Dir Create +version: 1 +icon: tablerFolderPlus +category: filesystem +short_desc: Create a directory on the file system. +style: + header: + background: rgb(197, 147, 31) + body: + background: "rgb(164 115 29)" +inputs: + exec: + exec: true + index: 0 + path: + name: Path + type: string + index: 1 + required: true + desc: The path of the directory to create. + create_parents: + name: Create Parents + type: bool + index: 2 + default: true + desc: If true, creates all parent directories as needed (like mkdir -p). If false, only creates the final directory and fails if parent directories don't exist. +outputs: + exec-success: + name: Success + exec: true + index: 0 + desc: Executes if the directory creation is successful. + exec-err: + name: Error + exec: true + index: 1 + desc: Executes if the directory creation fails.