From 0e1450b5dbc8cd5dbfafa4c71657f2b125680a65 Mon Sep 17 00:00:00 2001 From: Mahmoud-Emad Date: Tue, 12 Aug 2025 13:37:01 +0300 Subject: [PATCH] chore: add debug prints and perform code cleanup - Add extensive debug prints for troubleshooting - Comment out docusaurus build/dev action logic - Rename gittools parameters for clarity (reset/pull) - Apply consistent formatting to function calls - Remove unused imports in playbook include module --- lib/core/herocmds/docusaurus.v | 54 ++++++++++++---------- lib/core/playbook/find.v | 3 ++ lib/core/playbook/playbook_include.v | 69 +++++++++++++--------------- lib/core/playcmds/factory.v | 7 +++ lib/web/site/play.v | 2 + 5 files changed, 74 insertions(+), 61 deletions(-) diff --git a/lib/core/herocmds/docusaurus.v b/lib/core/herocmds/docusaurus.v index d14c4fb3..9f29c2df 100644 --- a/lib/core/herocmds/docusaurus.v +++ b/lib/core/herocmds/docusaurus.v @@ -108,7 +108,6 @@ pub fn cmd_docusaurus(mut cmdroot Command) Command { description: 'Run your dev environment on local browser.' }) - cmdroot.add_command(cmd_run) return cmdroot } @@ -127,43 +126,48 @@ fn cmd_docusaurus_execute(cmd Command) ! { mut path := cmd.flags.get_string('path') or { '' } mut url := cmd.flags.get_string('url') or { '' } - if path=="" && url==""{ + if path == '' && url == '' { path = os.getwd() } - - docusaurus_path :=gittools.path( - git_url:url - path: path - reset: reset - pull: update + docusaurus_path := gittools.path( + git_url: url + path: path + git_reset: reset + git_pull: update )! // `docusaurus_path` is a pathlib.Path – we need its string representation - if ! os.exists(os.join_path(docusaurus_path.path, 'cfg')) { - error('Docusaurus configuration directory not found at: ${os.join_path(docusaurus_path.path, 'cfg')}') + if !os.exists(os.join_path(docusaurus_path.path, 'cfg')) { + error('Docusaurus configuration directory not found at: ${os.join_path(docusaurus_path.path, + 'cfg')}') } console.print_header('Running Docusaurus for: ${docusaurus_path}') - // The `playcmds.run` helper expects a string path. Use the underlying + // The `playcmds.run` helper expects a string path. Use the underlying // filesystem path from the pathlib.Path value. + println('DEBUG: The heroscript path is: ${docusaurus_path.path}') playcmds.run( heroscript_path: docusaurus_path.path - reset: false + reset: false )! - // ---------- ACTIONS ---------- - if buildpublish { - dsite_opt := docusaurus.new(path:docusaurus_path)! - dsite_opt.build()! - } else if dev { - dsite_opt.dev( - open: open_ - watch_changes: false - )! - } else { - // default: just build the static site - dsite_opt.build()! - } + // // ---------- ACTIONS ---------- + // mut dsite_opt := docusaurus.dsite_add( + // sitename: 'default' + // path: docusaurus_path.path + // )! + + // if buildpublish { + // dsite_opt.build()! + // } else if dev { + // dsite_opt.dev( + // open: open_ + // watch_changes: false + // )! + // } else { + // // default: just build the static site + // dsite_opt.build()! + // } } diff --git a/lib/core/playbook/find.v b/lib/core/playbook/find.v index d5a5173e..3827cbc0 100644 --- a/lib/core/playbook/find.v +++ b/lib/core/playbook/find.v @@ -94,7 +94,10 @@ pub fn (mut plbook PlayBook) find(args FindArgs) ![]&Action { // use this in play function to make sure we only have one of those actions, the one action is then returned pub fn (mut plbook PlayBook) ensure_once(args FindArgs) !&Action { + println('DEBUG: In the error') + mut res := plbook.find(args) or { [] } + println('res: ${res}') if res.len == 0 { return error('No actions found based on filter: ${args.filter}') } diff --git a/lib/core/playbook/playbook_include.v b/lib/core/playbook/playbook_include.v index 24aa6af3..7b6ff6a2 100644 --- a/lib/core/playbook/playbook_include.v +++ b/lib/core/playbook/playbook_include.v @@ -1,8 +1,5 @@ module playbook -import freeflowuniverse.herolib.core.texttools -import freeflowuniverse.herolib.data.paramsparser -import freeflowuniverse.herolib.core.pathlib import freeflowuniverse.herolib.develop.gittools // Added import for gittools // Include external playbook actions (from git repo or local path) @@ -13,42 +10,42 @@ import freeflowuniverse.herolib.develop.gittools // Added import for gittools // git_reset – reset local copy (bool, default false) // path – local path to include (optional) pub fn (mut plbook PlayBook) include() ! { - // Find all include actions in the playbook - mut inc_actions := plbook.find(filter: 'play.include')! - if inc_actions.len == 0 { - return - } + // Find all include actions in the playbook + mut inc_actions := plbook.find(filter: 'play.include')! + if inc_actions.len == 0 { + return + } - for mut inc in inc_actions { - mut p := inc.params + for mut inc in inc_actions { + mut p := inc.params - // Extract parameters with sensible defaults - git_url := p.get_default('git_url', '')! - git_pull := p.get_default_false('git_pull') - git_reset := p.get_default_false('git_reset') - path := p.get_default('path', '')! + // Extract parameters with sensible defaults + git_url := p.get_default('git_url', '')! + git_pull := p.get_default_false('git_pull') + git_reset := p.get_default_false('git_reset') + path := p.get_default('path', '')! - // Resolve the path to include - mut includepath := '' - if git_url != '' { - // Resolve a git repository path (may clone / pull) - includepath = gittools.path( - git_url: git_url, - path: path, - git_pull: git_pull, - git_reset: git_reset, - )!.path - } else { - includepath = path - } + // Resolve the path to include + mut includepath := '' + if git_url != '' { + // Resolve a git repository path (may clone / pull) + includepath = gittools.path( + git_url: git_url + path: path + git_pull: git_pull + git_reset: git_reset + )!.path + } else { + includepath = path + } - // Add the found content (files / directories) to the current playbook. - // `add` will handle reading files, recursing into directories, etc. - if includepath != '' { - plbook.add(path: includepath)! - } + // Add the found content (files / directories) to the current playbook. + // `add` will handle reading files, recursing into directories, etc. + if includepath != '' { + plbook.add(path: includepath)! + } - // Mark this include action as processed - inc.done = true - } + // Mark this include action as processed + inc.done = true + } } diff --git a/lib/core/playcmds/factory.v b/lib/core/playcmds/factory.v index 938cff90..f99b4b43 100644 --- a/lib/core/playcmds/factory.v +++ b/lib/core/playcmds/factory.v @@ -22,10 +22,13 @@ pub mut: pub fn run(args_ PlayArgs) ! { mut args := args_ + println('DEBUG: the args is: ${args}') mut plbook := args.plbook or { playbook.new(text: args.heroscript, path: args.heroscript_path)! } + println('DEBUG: The playbook is ${plbook}') + // Core actions play_core(mut plbook)! // Git actions @@ -39,8 +42,12 @@ pub fn run(args_ PlayArgs) ! { // Website / docs site.play(mut plbook)! + println('DEBUG: Site play is done') doctree.play(mut plbook)! + println('DEBUG: doctree play is done') + docusaurus.play(mut plbook)! + println('DEBUG: docusaurus play is done') // Ensure we did not leave any actions un‑processed plbook.empty_check()! diff --git a/lib/web/site/play.v b/lib/web/site/play.v index 3052c92b..d2ed6b4a 100644 --- a/lib/web/site/play.v +++ b/lib/web/site/play.v @@ -9,6 +9,8 @@ pub fn play(mut plbook PlayBook) ! { return } + println('DEBUG: Before the error') + mut config_action := plbook.ensure_once(filter: 'site.config')! mut p := config_action.params