...
This commit is contained in:
@@ -8,16 +8,19 @@ playcmds.run(
|
||||
!!docusaurus.define
|
||||
path_build: "/tmp/docusaurus_build"
|
||||
path_publish: "/tmp/docusaurus_publish"
|
||||
reset: 1
|
||||
install: 1
|
||||
template_update: 1
|
||||
// reset: 1
|
||||
// install: 1
|
||||
// template_update: 1
|
||||
|
||||
!!docusaurus.add name:"tfgrid_docs"
|
||||
git_url:"https://git.threefold.info/tfgrid/docs_tfgrid4/src/branch/main/ebooks/tech"
|
||||
git_root:"/tmp/code"
|
||||
git_reset:1
|
||||
git_pull:1
|
||||
sitename:"tfgrid_docs"
|
||||
git_url:"https://git.ourworld.tf/tfgrid/docs_tfgrid4/src/branch/main/ebooks/tech"
|
||||
// git_root:"/tmp/code"
|
||||
// git_reset:1
|
||||
// git_pull:1
|
||||
|
||||
!!docusaurus.build
|
||||
// !!docusaurus.build
|
||||
|
||||
// !!docusaurus.dev site:"tfgrid_docs" open:true watch_changes:true
|
||||
'
|
||||
)!
|
||||
@@ -97,6 +97,27 @@ pub fn (mut plbook PlayBook) exists_once(args FindArgs) bool {
|
||||
return res.len == 1
|
||||
}
|
||||
|
||||
//checks it exists once, if more than one it returns error
|
||||
pub fn (mut plbook PlayBook) max_once(args FindArgs) !bool {
|
||||
mut res := plbook.find(args) or { [] }
|
||||
if res.len > 1 {
|
||||
return error("found more than one action: '${args.filter}'")
|
||||
}
|
||||
return res.len == 1
|
||||
}
|
||||
|
||||
|
||||
//will give error on what is not done yet
|
||||
pub fn (mut plbook PlayBook) ensure_processed(args FindArgs) ! {
|
||||
mut res := plbook.find(args) or { [] }
|
||||
for item in res {
|
||||
if !item.done {
|
||||
return error("action not done: '${item.actor}.${item.name}'")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn (mut plbook PlayBook) exists(args FindArgs) bool {
|
||||
mut res := plbook.find(args) or { [] }
|
||||
return res.len > 0
|
||||
|
||||
@@ -63,14 +63,6 @@ pub fn dsite_add(args_ AddArgs) !&DocSite {
|
||||
osal.rm('${args.path}/sync.sh')!
|
||||
osal.rm('${args.path}/.DS_Store')!
|
||||
|
||||
mut website := site.get(name: args.sitename)!
|
||||
|
||||
mut myconfig := new_configuration(website.siteconfig)! // go from site.SiteConfig to docusaurus.Configuration
|
||||
|
||||
if myconfig.main.name.len == 0 {
|
||||
return error('main.name is not set in the site configuration')
|
||||
}
|
||||
|
||||
mut f := factory_get()!
|
||||
|
||||
if args.path_publish == '' {
|
||||
@@ -80,21 +72,16 @@ pub fn dsite_add(args_ AddArgs) !&DocSite {
|
||||
path_build_ := '${f.path_build.path}/${args.sitename}'
|
||||
|
||||
// get our website
|
||||
console.print_debug('Docusaurus site ${args.sitename} at ${args.path}.')
|
||||
mut mysite := site.new(name: args.sitename)!
|
||||
if site.exists(name: args.sitename) {
|
||||
console.print_debug('Docusaurus site ${args.sitename} already exists, using existing site.')
|
||||
mysite = site.get(name: args.sitename)!
|
||||
} else {
|
||||
if !args.play {
|
||||
return error('Docusaurus site ${args.sitename} does not exist, please set play to true to create it.')
|
||||
}
|
||||
console.print_debug('Creating new Docusaurus site ${args.sitename}.')
|
||||
mut plbook := playbook.new(path: '${args.path}/cfg')!
|
||||
if plbook.actions.len == 0 {
|
||||
return error('No actions found in playbook at ${args.path}/cfg')
|
||||
}
|
||||
site.play(mut plbook)!
|
||||
mysite = site.get(name: args.sitename) or {
|
||||
return error('Failed to get site after playing playbook: ${args.sitename}')
|
||||
}
|
||||
}
|
||||
|
||||
// Create the DocSite instance
|
||||
mut dsite := &DocSite{
|
||||
@@ -102,7 +89,7 @@ pub fn dsite_add(args_ AddArgs) !&DocSite {
|
||||
path_src: pathlib.get_dir(path: args.path, create: false)!
|
||||
path_publish: pathlib.get_dir(path: args.path_publish, create: true)!
|
||||
path_build: pathlib.get_dir(path: path_build_, create: true)!
|
||||
config: new_configuration(website.siteconfig)!
|
||||
config: new_configuration(mysite.siteconfig)!
|
||||
website: mysite
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
|
||||
// check if docusaurus.define exists, if not, we create a default factory
|
||||
mut f := DocSiteFactory{}
|
||||
if plbook.exists_once(filter: 'docusaurus.define') {
|
||||
if plbook.max_once(filter: 'docusaurus.define')! {
|
||||
mut a := plbook.get(filter: 'docusaurus.define') or {
|
||||
panic('docusaurus.define action not found, this should not happen.')
|
||||
}
|
||||
@@ -41,10 +41,10 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
|
||||
dsite_add(
|
||||
sitename: site_name
|
||||
path: p.get('path')!
|
||||
git_url: p.get('git_url')!
|
||||
path: p.get_default('path', '')!
|
||||
git_url: p.get_default('git_url','')!
|
||||
git_reset: p.get_default_false('git_reset')
|
||||
git_root: p.get('git_root')!
|
||||
git_root: p.get_default('git_root','')!
|
||||
git_pull: p.get_default_false('git_pull')
|
||||
path_publish: p.get_default('path_publish', f.path_publish.path)!
|
||||
play: false // need to make sure we don't play again
|
||||
@@ -80,4 +80,6 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
dsite.build()!
|
||||
action.done = true
|
||||
}
|
||||
|
||||
plbook.ensure_processed(filter: 'docusaurus.')!
|
||||
}
|
||||
|
||||
@@ -5,16 +5,28 @@ import freeflowuniverse.herolib.core.texttools
|
||||
import time
|
||||
|
||||
pub fn play(mut plbook PlayBook) ! {
|
||||
|
||||
if !plbook.exists(filter: 'site.') {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Handle multiple site configurations
|
||||
mut config_actions := plbook.find(filter: 'site.config')!
|
||||
|
||||
println('Playing site configuration...')
|
||||
// println(config_actions)
|
||||
// if true{panic('site.play not implemented yet, this is a stub')}
|
||||
|
||||
if config_actions.len == 0 {
|
||||
return error('No site.config actions found')
|
||||
}
|
||||
|
||||
// Process each site configuration separately
|
||||
for mut config_action in config_actions {
|
||||
mut website := play_config_single(mut config_action)!
|
||||
mut website := play_config_single( *config_action)!
|
||||
|
||||
config_action.done = true // Mark the action as done
|
||||
|
||||
mut config := &website.siteconfig
|
||||
|
||||
@@ -28,7 +40,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
}
|
||||
}
|
||||
|
||||
fn play_config_single(mut action Action) !&Site {
|
||||
fn play_config_single(action Action) !&Site {
|
||||
mut p := action.params
|
||||
name := p.get('name') or { return error('need to specify name in site.config.\n${action}') }
|
||||
|
||||
@@ -45,9 +57,6 @@ fn play_config_single(mut action Action) !&Site {
|
||||
config.base_url = p.get_default('base_url', config.base_url)!
|
||||
config.url_home = p.get_default('url_home', config.url_home)!
|
||||
config.name = name
|
||||
|
||||
action.done = true // Mark the action as done
|
||||
|
||||
return website
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user