Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions node_interfaces/interface_core_dir-create_v1.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions nodes/dir-create@v1.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
40 changes: 40 additions & 0 deletions nodes/dir-create@v1.yml
Original file line number Diff line number Diff line change
@@ -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.
Loading