...
This commit is contained in:
@@ -29,27 +29,11 @@ pub mut:
|
||||
// git_root string
|
||||
// git_pull bool
|
||||
// ```
|
||||
pub fn (mut tree Tree) scan(args_ TreeScannerArgs) ! {
|
||||
mut args := args_
|
||||
if args.git_url.len > 0 {
|
||||
mut gs := gittools.get(coderoot: args.git_root)!
|
||||
mut repo := gs.get_repo(
|
||||
url: args.git_url
|
||||
pull: args.git_pull
|
||||
reset: args.git_reset
|
||||
)!
|
||||
args.path = repo.get_path_of_url(args.git_url)!
|
||||
}
|
||||
|
||||
if args.path.len == 0 {
|
||||
return error('Path needs to be provided.')
|
||||
}
|
||||
|
||||
mut path := pathlib.get_dir(path: args.path)!
|
||||
pub fn (mut tree Tree) scan(args TreeScannerArgs) ! {
|
||||
mut path := gittools.path(path: args.path, git_url: args.git_url, git_reset: args.git_reset, git_root: args.git_root, git_pull: args.git_pull)!
|
||||
if !path.is_dir() {
|
||||
return error('path is not a directory')
|
||||
}
|
||||
|
||||
if path.file_exists('.site') {
|
||||
move_site_to_collection(mut path)!
|
||||
}
|
||||
|
||||
@@ -6,15 +6,45 @@ below is powerful command, will get the repo, put on right location, you can for
|
||||
|
||||
```v
|
||||
import freeflowuniverse.herolib.develop.gittools
|
||||
mut gs := gittools.new()!
|
||||
mydocs_path:=gs.get_path(
|
||||
// path string
|
||||
// git_url string
|
||||
// git_reset bool
|
||||
// git_root string
|
||||
// git_pull bool
|
||||
// currentdir bool // can use currentdir, if true, will use current directory as base path if not giturl or path specified
|
||||
mydocs_path:=gittools.path(
|
||||
pull:true,
|
||||
reset:false,
|
||||
url:'https://git.threefold.info/tfgrid/info_docs_depin/src/branch/main/docs'
|
||||
git_url:'https://git.threefold.info/tfgrid/info_docs_depin/src/branch/main/docs'
|
||||
)!
|
||||
|
||||
println(mydocs_path)
|
||||
|
||||
//the returned path is from pathlib, so its easy to further process
|
||||
|
||||
//more complete example
|
||||
|
||||
@[params]
|
||||
pub struct GitPathGetArgs {
|
||||
pub mut:
|
||||
someotherparams string // you can add other params here if you want
|
||||
//gittools will use these params to find the right path
|
||||
path string
|
||||
git_url string
|
||||
git_reset bool
|
||||
git_root string
|
||||
git_pull bool
|
||||
}
|
||||
pub fn something(args GitPathGetArgs) !string{
|
||||
mut path := gittools.path(path: args.path, git_url: args.git_url, git_reset: args.git_reset, git_root: args.git_root, git_pull: args.git_pull)!
|
||||
if !path.is_dir() {
|
||||
return error('path is not a directory')
|
||||
}
|
||||
if path.file_exists('.site') {
|
||||
move_site_to_collection(mut path)!
|
||||
}
|
||||
return path.path
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Repository Management
|
||||
|
||||
@@ -104,3 +104,43 @@ pub fn get(args_ GitStructureArgGet) !&GitStructure {
|
||||
|
||||
return gsinstances[rediskey_] or { panic('bug') }
|
||||
}
|
||||
|
||||
|
||||
@[params]
|
||||
pub struct GitPathGetArgs {
|
||||
pub mut:
|
||||
path string
|
||||
git_url string
|
||||
git_reset bool
|
||||
git_root string
|
||||
git_pull bool
|
||||
currentdir bool //can use currentdir
|
||||
}
|
||||
|
||||
|
||||
//return pathlib Path based on, will pull...
|
||||
// params:
|
||||
// path string
|
||||
// git_url string
|
||||
// git_reset bool
|
||||
// git_root string
|
||||
// git_pull bool
|
||||
pub fn path(args_ GitPathGetArgs) !pathlib.Path {
|
||||
mut args:= args_
|
||||
if args.path.trim_space() == '' && args.currentdir{
|
||||
args.path = os.getwd()
|
||||
}
|
||||
if args.git_url.len > 0 {
|
||||
mut gs := gittools.get(coderoot: args.git_root)!
|
||||
mut repo := gs.get_repo(
|
||||
url: args.git_url
|
||||
pull: args.git_pull
|
||||
reset: args.git_reset
|
||||
)!
|
||||
args.path = repo.get_path_of_url(args.git_url)!
|
||||
}
|
||||
if args.path.len == 0 {
|
||||
return error('Path needs to be provided.')
|
||||
}
|
||||
return pathlib.get(args.path)
|
||||
}
|
||||
|
||||
@@ -14,16 +14,20 @@ pub struct DSiteGetArgs {
|
||||
pub mut:
|
||||
name string
|
||||
nameshort string
|
||||
path string
|
||||
url string
|
||||
//gittools will use these params to find the right path
|
||||
path string
|
||||
git_url string
|
||||
git_reset bool
|
||||
git_root string
|
||||
git_pull bool
|
||||
//more params
|
||||
path_publish string //default empty
|
||||
// path_build string //default empty
|
||||
production bool
|
||||
watch_changes bool = true
|
||||
update bool
|
||||
open bool
|
||||
init bool // means create new one if needed
|
||||
deploykey string
|
||||
// deploykey string
|
||||
// config ?Configuration
|
||||
}
|
||||
|
||||
@@ -31,20 +35,11 @@ pub fn (mut f DocusaurusFactory) get(args_ DSiteGetArgs) !&DocSite {
|
||||
console.print_header(' Docusaurus: ${args_.name}')
|
||||
mut args := args_
|
||||
|
||||
// coderoot:"${os.home_dir()}/hero/var/publishcode"
|
||||
mut gs := gittools.new(ssh_key_path: args.deploykey)!
|
||||
|
||||
if args.url.len > 0 {
|
||||
args.path = gs.get_path(url: args.url)!
|
||||
mut path := gittools.path(path: args.path, git_url: args.git_url, git_reset: args.git_reset, git_root: args.git_root, git_pull: args.git_pull,currentdir:true)!
|
||||
if !path.is_dir() {
|
||||
return error('path is not a directory')
|
||||
}
|
||||
|
||||
|
||||
|
||||
if args.path.trim_space() == '' {
|
||||
args.path = os.getwd()
|
||||
}
|
||||
args.path = args.path.replace('~', os.home_dir())
|
||||
|
||||
configpath:='${args.path}/cfg'
|
||||
if ! os.exists(configpath) {
|
||||
return error("can't find config file in ${configpath}")
|
||||
@@ -97,7 +92,7 @@ pub fn (mut f DocusaurusFactory) get(args_ DSiteGetArgs) !&DocSite {
|
||||
|
||||
mut ds := DocSite{
|
||||
name: args.name
|
||||
url: args.url
|
||||
// url: args.url
|
||||
path_src: pathlib.get_dir(path: args.path, create: false)!
|
||||
path_publish: pathlib.get_dir(path:args.path_publish)!
|
||||
args: args
|
||||
|
||||
56
lib/web/docusaurus/play.v
Normal file
56
lib/web/docusaurus/play.v
Normal file
@@ -0,0 +1,56 @@
|
||||
module doctree
|
||||
|
||||
import freeflowuniverse.herolib.core.playbook { PlayBook }
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
|
||||
@[params]
|
||||
pub struct PlayArgs {
|
||||
pub mut:
|
||||
heroscript string
|
||||
heroscript_path string
|
||||
plbook ?PlayBook
|
||||
reset bool
|
||||
}
|
||||
|
||||
|
||||
pub fn play(args_ PlayArgs) ! {
|
||||
|
||||
mut args := args_
|
||||
mut plbook := args.plbook or { playbook.new(text: args.heroscript,path:args.heroscript_path)! }
|
||||
|
||||
mut ds := docusaurus.new()!
|
||||
|
||||
actions_define := plbook.find(filter: 'docusaurus.define')!
|
||||
if actions_define.len >1 {
|
||||
return error("found multiple docusaurus.play actions, only one is allowed")
|
||||
}
|
||||
for action in actions_define{
|
||||
mut p := action.params
|
||||
path_publish := p.get_default('path_publish',"")!
|
||||
path_build := p.get_default('path_build',"")!
|
||||
production := p.get_default_false('production')
|
||||
update := p.get_default_false('update')
|
||||
ds = docusaurus.new(
|
||||
path_publish: path_publish
|
||||
path_build: path_build
|
||||
production: production
|
||||
update: update
|
||||
)!
|
||||
}
|
||||
|
||||
actions := plbook.find(filter: 'docusaurus.add')!
|
||||
for action in actions {
|
||||
mut p := action.params
|
||||
name := p.get_default('name',"main")!
|
||||
path := p.get_default('path',"")!
|
||||
git_url := p.get_default('git_url',"")!
|
||||
git_reset:= p.get_default_false('git_reset')
|
||||
git_pull:= p.get_default_false('git_pull')
|
||||
|
||||
mut site:=ds.get(url:url,path:path,name:"atest")!
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user