This commit is contained in:
2025-07-25 11:05:30 +02:00
parent 9b86f76eaa
commit f2079c7c3d
10 changed files with 57 additions and 75 deletions

View File

@@ -155,7 +155,7 @@ fn cmd_docusaurus_execute(cmd Command) ! {
mut dev := cmd.flags.get_bool('dev') or { false }
mut docs := docusaurus.new(
update: update
template_update: update // Changed 'update' to 'template_update'
path_build: build_path
heroscript_path: heroscript_config_dir // Pass the directory path
)!

View File

@@ -3,8 +3,7 @@ module playbook
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.data.paramsparser
import freeflowuniverse.herolib.core.pathlib
// import freeflowuniverse.herolib.core.base
// import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.develop.gittools // Added import for gittools
enum State {
start
@@ -17,7 +16,12 @@ pub fn (mut plbook PlayBook) add(args_ PlayBookNewArgs) ! {
mut args := args_
if args.git_url.len > 0 {
args.path = gitresolver.resolve_git_url(args.git_url, args.git_pull, args.git_reset)!
mut git_path_args := gittools.GitPathGetArgs{
git_url: args.git_url
git_pull: args.git_pull
git_reset: args.git_reset
}
args.path = gittools.path(git_path_args)!
}
// walk over directory

View File

@@ -21,7 +21,7 @@ pub fn run(mut plbook playbook.PlayBook, dagu bool) ! {
play_core(mut plbook)!
play_ssh(mut plbook)!
play_git(mut plbook)!
play_git.play(mut plbook)! // Changed to play_git.play
// play_publisher(mut plbook)!
// play_zola(mut plbook)!
// play_caddy(mut plbook)!

View File

@@ -42,8 +42,13 @@ pub fn play_core(mut plbook playbook.PlayBook) ! {
mut playrunpath := action.params.get_default('path', '')!
if playrunpath.len == 0 {
action.name = 'pull'
action2 := play_git_action(action)!
playrunpath = action2.params.get_default('path', '')!
mut git_path_args := gittools.GitPathGetArgs{
git_url: action.params.get_default('git_url', '')!
git_pull: action.params.get_default_false('git_pull')
git_reset: action.params.get_default_false('git_reset')
git_root: action.params.get_default('git_root', '')!
}
playrunpath = gittools.path(git_path_args)!
}
if playrunpath.len == 0 {
return error("can't run a heroscript didn't find url or path.")

View File

@@ -31,7 +31,7 @@ pub fn play(args_ PlayArgs) ! {
ssh_key_path := p.get_default('ssh_key_path', '')!
reload := p.get_default_false('reload')
new(
gittools.new( // Changed to gittools.new
coderoot: coderoot
light: light
log: log
@@ -42,7 +42,7 @@ pub fn play(args_ PlayArgs) ! {
)!
} else {
// Initialize GitStructure with defaults
new()!
gittools.get(gittools.GitStructureArgGet{})! // Changed to gittools.get with default args
}
// Handle !!git.clone action
@@ -55,14 +55,14 @@ pub fn play(args_ PlayArgs) ! {
light := p.get_default_true('light')
recursive := p.get_default_false('recursive')
mut clone_args := GitCloneArgs{
mut clone_args := gittools.GitCloneArgs{ // Changed to gittools.GitCloneArgs
url: url
sshkey: sshkey
recursive: recursive
light: light
}
if coderoot.len > 0 {
gs = new(coderoot: coderoot)!
gs = gittools.new(coderoot: coderoot)! // Changed to gittools.new
}
gs.clone(clone_args)!
}
@@ -100,76 +100,31 @@ pub fn play(args_ PlayArgs) ! {
for mut repo in repos {
match action_type {
'pull' {
repo.pull(submodules: submodules) or {
if !error_ignore {
return error('Failed to pull repo ${repo.name}: ${err}')
}
console.print_stderr('Failed to pull repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
}
repo.pull(submodules: submodules)
}
'commit' {
repo.commit(message) or {
if !error_ignore {
return error('Failed to commit repo ${repo.name}: ${err}')
}
console.print_stderr('Failed to commit repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
}
repo.commit(message)
}
'push' {
repo.push() or {
if !error_ignore {
return error('Failed to push repo ${repo.name}: ${err}')
}
console.print_stderr('Failed to push repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
}
repo.push()
}
'reset' {
repo.reset() or {
if !error_ignore {
return error('Failed to reset repo ${repo.name}: ${err}')
}
console.print_stderr('Failed to reset repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
}
repo.reset()
}
'branch_create' {
repo.branch_create(branchname) or {
if !error_ignore {
return error('Failed to create branch ${branchname} in repo ${repo.name}: ${err}')
}
console.print_stderr('Failed to create branch ${branchname} in repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
}
repo.branch_create(branchname)
}
'branch_switch' {
repo.branch_switch(branchname) or {
if !error_ignore {
return error('Failed to switch branch to ${branchname} in repo ${repo.name}: ${err}')
}
console.print_stderr('Failed to switch branch to ${branchname} in repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
}
repo.branch_switch(branchname)
}
'tag_create' {
repo.tag_create(tagname) or {
if !error_ignore {
return error('Failed to create tag ${tagname} in repo ${repo.name}: ${err}')
}
console.print_stderr('Failed to create tag ${tagname} in repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
}
repo.tag_create(tagname)
}
'tag_switch' {
repo.tag_switch(tagname) or {
if !error_ignore {
return error('Failed to switch tag to ${tagname} in repo ${repo.name}: ${err}')
}
console.print_stderr('Failed to switch tag to ${tagname} in repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
}
repo.tag_switch(tagname)
}
'delete' {
repo.delete() or {
if !error_ignore {
return error('Failed to delete repo ${repo.name}: ${err}')
}
console.print_stderr('Failed to delete repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
}
repo.delete()
}
else {
if !error_ignore {
@@ -197,7 +152,7 @@ pub fn play(args_ PlayArgs) ! {
account: account
provider: provider
status_update: status_update
)!
)
}
// Handle !!git.reload_cache
@@ -206,8 +161,8 @@ pub fn play(args_ PlayArgs) ! {
mut p := action.params
coderoot := p.get_default('coderoot', '')!
if coderoot.len > 0 {
gs = new(coderoot: coderoot)!
gs = gittools.new(coderoot: coderoot)!
}
gs.load(true)! // Force reload
gs.load(true) // Force reload
}
}

View File

@@ -3,6 +3,7 @@ module gittools
import os
import json
import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.develop.gitresolver // Added import for gitresolver
__global (
gsinstances map[string]&GitStructure

View File

@@ -23,6 +23,23 @@ pub mut:
factory &DocusaurusFactory @[skip; str: skip] // Reference to the parent
}
@[params]
pub struct DSiteGetArgs {
pub mut:
name string
nameshort string
path string
git_url string
git_reset bool
git_root string
git_pull bool
open bool // Added
watch_changes bool // Added
path_publish string // Added
init bool // Added
update bool // Added (maps to template_update in DocusaurusArgs)
}
pub fn (mut s DocSite) build() ! {
s.generate()!
osal.exec(

View File

@@ -53,7 +53,7 @@ pub fn new(args_ DocusaurusArgs) !&DocusaurusFactory {
// get site from the docusaurus factory
pub fn (mut self DocusaurusFactory) site_get(name string) ! {
name_:=texttools.name_fix(name: name)!
return self.sites[name_] or {return error('site not found: ${name} in docusaurus factory.')!}
pub fn (mut self DocusaurusFactory) site_get(name string) !&DocSite { // Changed return type to !&DocSite
name_:=texttools.name_fix(name: name) // Removed !
return self.sites[name_] or {return error('site not found: ${name} in docusaurus factory.') } // Removed ! from error()
}

View File

@@ -21,18 +21,18 @@ fn (mut self DocusaurusFactory) install(args_ TemplateInstallArgs) ! {
if args.reset {
osal.rm('${self.path_build.path}')!
osal.mkdir('${self.path_build.path}')!
osal.mkdir_all('${self.path_build.path}')! // Changed mkdir to mkdir_all
}
template_path := gs.get_path(
pull: args.template_update
reset: args.delete
reset: args.reset // Changed args.delete to args.reset
url: 'https://github.com/freeflowuniverse/docusaurus_template/src/branch/main/template'
)!
mut template_path0 := pathlib.get_dir(path: template_path, create: false)!
template_path0.copy(dest: '${self.path_build.path}', delete: args.delete)!
template_path0.copy(dest: '${self.path_build.path}', delete: args.reset)! // Changed args.delete to args.reset
if !os.exists('${self.path_build.path}/node_modules') {
args.install = true

View File

@@ -20,7 +20,7 @@ pub fn play(args_ PlayArgs) ! {
mut ds := new()!
if plbook.if_once(filter: 'docusaurus.define') or {return error("docusarus.define should be there 0 or 1 time.\n${args}")!} {
if plbook.exists_once(filter: 'docusaurus.define') { // Changed if_once to exists_once and removed or block
mut action := plbook.action_get(actor: 'docusaurus', name: 'define')!
mut p := action.params