Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 35dace9155 | |||
| 69e7c1cce9 | |||
| d21e71e615 | |||
|
|
f38d4249ef | ||
| 293dc3f1ac | |||
| 6492e42358 | |||
| 4aaf1bd6db | |||
| a56a251d7f |
@@ -51,7 +51,7 @@ fn do() ! {
|
|||||||
mut cmd := Command{
|
mut cmd := Command{
|
||||||
name: 'hero'
|
name: 'hero'
|
||||||
description: 'Your HERO toolset.'
|
description: 'Your HERO toolset.'
|
||||||
version: '1.0.16'
|
version: '1.0.20'
|
||||||
}
|
}
|
||||||
|
|
||||||
// herocmds.cmd_run_add_flags(mut cmd)
|
// herocmds.cmd_run_add_flags(mut cmd)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ set -e
|
|||||||
|
|
||||||
os_name="$(uname -s)"
|
os_name="$(uname -s)"
|
||||||
arch_name="$(uname -m)"
|
arch_name="$(uname -m)"
|
||||||
version='1.0.16'
|
version='1.0.20'
|
||||||
|
|
||||||
|
|
||||||
# Base URL for GitHub releases
|
# Base URL for GitHub releases
|
||||||
|
|||||||
143
lib/core/herocmds/starlight.v
Normal file
143
lib/core/herocmds/starlight.v
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
module herocmds
|
||||||
|
|
||||||
|
import freeflowuniverse.herolib.web.starlight
|
||||||
|
import os
|
||||||
|
import cli { Command, Flag }
|
||||||
|
|
||||||
|
pub fn cmd_starlight(mut cmdroot Command) {
|
||||||
|
mut cmd_run := Command{
|
||||||
|
name: 'starlight'
|
||||||
|
description: 'Generate, build, run starlight sites.'
|
||||||
|
required_args: 0
|
||||||
|
execute: cmd_starlight_execute
|
||||||
|
}
|
||||||
|
|
||||||
|
// cmd_run.add_flag(Flag{
|
||||||
|
// flag: .bool
|
||||||
|
// required: false
|
||||||
|
// name: 'reset'
|
||||||
|
// abbrev: 'r'
|
||||||
|
// description: 'will reset.'
|
||||||
|
// })
|
||||||
|
|
||||||
|
cmd_run.add_flag(Flag{
|
||||||
|
flag: .string
|
||||||
|
required: false
|
||||||
|
name: 'url'
|
||||||
|
abbrev: 'u'
|
||||||
|
// default: ''
|
||||||
|
description: 'Url where starlight source is.'
|
||||||
|
})
|
||||||
|
|
||||||
|
cmd_run.add_flag(Flag{
|
||||||
|
flag: .string
|
||||||
|
required: false
|
||||||
|
name: 'path'
|
||||||
|
abbrev: 'p'
|
||||||
|
// default: ''
|
||||||
|
description: 'Path where starlight source is.'
|
||||||
|
})
|
||||||
|
|
||||||
|
cmd_run.add_flag(Flag{
|
||||||
|
flag: .string
|
||||||
|
required: false
|
||||||
|
name: 'deploykey'
|
||||||
|
abbrev: 'dk'
|
||||||
|
// default: ''
|
||||||
|
description: 'Path of SSH Key used to deploy.'
|
||||||
|
})
|
||||||
|
|
||||||
|
cmd_run.add_flag(Flag{
|
||||||
|
flag: .string
|
||||||
|
required: false
|
||||||
|
name: 'publish'
|
||||||
|
// default: ''
|
||||||
|
description: 'Path where to publish.'
|
||||||
|
})
|
||||||
|
|
||||||
|
cmd_run.add_flag(Flag{
|
||||||
|
flag: .bool
|
||||||
|
required: false
|
||||||
|
name: 'buildpublish'
|
||||||
|
abbrev: 'bp'
|
||||||
|
description: 'build and publish.'
|
||||||
|
})
|
||||||
|
|
||||||
|
cmd_run.add_flag(Flag{
|
||||||
|
flag: .bool
|
||||||
|
required: false
|
||||||
|
name: 'builddevpublish'
|
||||||
|
abbrev: 'bpd'
|
||||||
|
description: 'build dev version and publish.'
|
||||||
|
})
|
||||||
|
|
||||||
|
cmd_run.add_flag(Flag{
|
||||||
|
flag: .bool
|
||||||
|
required: false
|
||||||
|
name: 'update'
|
||||||
|
description: 'update your environment the template and the repo you are working on (git pull).'
|
||||||
|
})
|
||||||
|
|
||||||
|
cmd_run.add_flag(Flag{
|
||||||
|
flag: .bool
|
||||||
|
required: false
|
||||||
|
name: 'dev'
|
||||||
|
abbrev: 'd'
|
||||||
|
description: 'Run your dev environment on local browser.'
|
||||||
|
})
|
||||||
|
|
||||||
|
cmd_run.add_flag(Flag{
|
||||||
|
flag: .bool
|
||||||
|
required: false
|
||||||
|
name: 'new'
|
||||||
|
abbrev: 'n'
|
||||||
|
description: 'create a new starlight site.'
|
||||||
|
})
|
||||||
|
|
||||||
|
cmdroot.add_command(cmd_run)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cmd_starlight_execute(cmd Command) ! {
|
||||||
|
mut update := cmd.flags.get_bool('update') or { false }
|
||||||
|
mut init := cmd.flags.get_bool('new') or { false }
|
||||||
|
mut url := cmd.flags.get_string('url') or { '' }
|
||||||
|
mut publish_path := cmd.flags.get_string('publish') or { '' }
|
||||||
|
mut deploykey := cmd.flags.get_string('deploykey') or { '' }
|
||||||
|
|
||||||
|
mut path := cmd.flags.get_string('path') or { '' }
|
||||||
|
|
||||||
|
mut buildpublish := cmd.flags.get_bool('buildpublish') or { false }
|
||||||
|
mut builddevpublish := cmd.flags.get_bool('builddevpublish') or { false }
|
||||||
|
mut dev := cmd.flags.get_bool('dev') or { false }
|
||||||
|
|
||||||
|
// if build== false && build== false && build== false {
|
||||||
|
// eprintln("specify build, builddev or dev")
|
||||||
|
// exit(1)
|
||||||
|
// }
|
||||||
|
|
||||||
|
mut docs := starlight.new(update: update)!
|
||||||
|
mut site := docs.get(
|
||||||
|
url: url
|
||||||
|
path: path
|
||||||
|
update: update
|
||||||
|
publish_path: publish_path
|
||||||
|
deploykey: deploykey
|
||||||
|
init: init
|
||||||
|
)!
|
||||||
|
|
||||||
|
if publish_path.len > 0 {
|
||||||
|
site.build()!
|
||||||
|
}
|
||||||
|
|
||||||
|
if buildpublish {
|
||||||
|
site.build_publish()!
|
||||||
|
}
|
||||||
|
|
||||||
|
if builddevpublish {
|
||||||
|
site.build_dev_publish()!
|
||||||
|
}
|
||||||
|
|
||||||
|
if dev {
|
||||||
|
site.dev()!
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,6 +50,9 @@ pub fn get_dir(args_ GetArgs) !Path {
|
|||||||
mut p2 := get_no_check(args.path)
|
mut p2 := get_no_check(args.path)
|
||||||
if args.check {
|
if args.check {
|
||||||
p2.check()
|
p2.check()
|
||||||
|
if args.delete {
|
||||||
|
p2.delete()!
|
||||||
|
}
|
||||||
p2.absolute()
|
p2.absolute()
|
||||||
if p2.exist == .no {
|
if p2.exist == .no {
|
||||||
if args.create {
|
if args.create {
|
||||||
@@ -64,9 +67,7 @@ pub fn get_dir(args_ GetArgs) !Path {
|
|||||||
if args.empty {
|
if args.empty {
|
||||||
p2.empty()!
|
p2.empty()!
|
||||||
}
|
}
|
||||||
if args.delete {
|
|
||||||
p2.delete()!
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return p2
|
return p2
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ pub fn new(args NewArgs) !&DedupeStore {
|
|||||||
|
|
||||||
return &DedupeStore{
|
return &DedupeStore{
|
||||||
radix: rt
|
radix: rt
|
||||||
data: db
|
data: &db
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,27 +36,27 @@ fn deserialize_node(data []u8) !Node {
|
|||||||
mut d := encoder.decoder_new(data)
|
mut d := encoder.decoder_new(data)
|
||||||
|
|
||||||
// Read and verify version
|
// Read and verify version
|
||||||
version_byte := d.get_u8()
|
version_byte := d.get_u8()!
|
||||||
if version_byte != version {
|
if version_byte != version {
|
||||||
return error('Invalid version byte: expected ${version}, got ${version_byte}')
|
return error('Invalid version byte: expected ${version}, got ${version_byte}')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read key segment
|
// Read key segment
|
||||||
key_segment := d.get_string()
|
key_segment := d.get_string()!
|
||||||
|
|
||||||
// Read value as []u8
|
// Read value as []u8
|
||||||
value_len := d.get_u16()
|
value_len := d.get_u16()!
|
||||||
mut value := []u8{len: int(value_len)}
|
mut value := []u8{len: int(value_len)}
|
||||||
for i in 0 .. int(value_len) {
|
for i in 0 .. int(value_len) {
|
||||||
value[i] = d.get_u8()
|
value[i] = d.get_u8()!
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read children
|
// Read children
|
||||||
children_len := d.get_u16()
|
children_len := d.get_u16()!
|
||||||
mut children := []NodeRef{cap: int(children_len)}
|
mut children := []NodeRef{cap: int(children_len)}
|
||||||
for _ in 0 .. children_len {
|
for _ in 0 .. children_len {
|
||||||
key_part := d.get_string()
|
key_part := d.get_string()!
|
||||||
node_id := d.get_u32()
|
node_id := d.get_u32()!
|
||||||
children << NodeRef{
|
children << NodeRef{
|
||||||
key_part: key_part
|
key_part: key_part
|
||||||
node_id: node_id
|
node_id: node_id
|
||||||
@@ -64,7 +64,7 @@ fn deserialize_node(data []u8) !Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read leaf flag
|
// Read leaf flag
|
||||||
is_leaf := d.get_u8() == 1
|
is_leaf := d.get_u8()! == 1
|
||||||
|
|
||||||
return Node{
|
return Node{
|
||||||
key_segment: key_segment
|
key_segment: key_segment
|
||||||
|
|||||||
@@ -12,5 +12,6 @@
|
|||||||
"title": "ThreeFold Technology Vision"
|
"title": "ThreeFold Technology Vision"
|
||||||
},
|
},
|
||||||
"buildDest":["root@info.ourworld.tf:/root/hero/www/info"],
|
"buildDest":["root@info.ourworld.tf:/root/hero/www/info"],
|
||||||
"buildDestDev":["root@info.ourworld.tf:/root/hero/www/infodev"]
|
"buildDestDev":["root@info.ourworld.tf:/root/hero/www/infodev"],
|
||||||
|
"copyright": "someone"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,10 @@ pub fn load_config(cfg_dir string) !Config {
|
|||||||
|
|
||||||
// Load and parse footer config
|
// Load and parse footer config
|
||||||
footer_content := os.read_file(os.join_path(cfg_dir, 'footer.json'))!
|
footer_content := os.read_file(os.join_path(cfg_dir, 'footer.json'))!
|
||||||
footer := json.decode(Footer, footer_content)!
|
footer := json.decode(Footer, footer_content) or {
|
||||||
|
eprintln('footer.json in ${cfg_dir} is not in the right format please fix.\nError: ${err}')
|
||||||
|
exit(99)
|
||||||
|
}
|
||||||
|
|
||||||
// Load and parse main config
|
// Load and parse main config
|
||||||
main_config_path := os.join_path(cfg_dir, 'main.json')
|
main_config_path := os.join_path(cfg_dir, 'main.json')
|
||||||
@@ -115,7 +118,10 @@ pub fn load_config(cfg_dir string) !Config {
|
|||||||
|
|
||||||
// Load and parse navbar config
|
// Load and parse navbar config
|
||||||
navbar_content := os.read_file(os.join_path(cfg_dir, 'navbar.json'))!
|
navbar_content := os.read_file(os.join_path(cfg_dir, 'navbar.json'))!
|
||||||
navbar := json.decode(Navbar, navbar_content)!
|
navbar := json.decode(Navbar, navbar_content) or {
|
||||||
|
eprintln('navbar.json in ${cfg_dir} is not in the right format please fix.\nError: ${err}')
|
||||||
|
exit(99)
|
||||||
|
}
|
||||||
|
|
||||||
return Config{
|
return Config{
|
||||||
footer: footer
|
footer: footer
|
||||||
|
|||||||
@@ -209,13 +209,15 @@ fn (mut site DocSite) template_install() ! {
|
|||||||
mut build_dev_publish_ := site.path_build.file_get_new('build_dev_publish.sh')!
|
mut build_dev_publish_ := site.path_build.file_get_new('build_dev_publish.sh')!
|
||||||
build_dev_publish_.template_write(build_dev_publish, true)!
|
build_dev_publish_.template_write(build_dev_publish, true)!
|
||||||
build_dev_publish_.chmod(0o700)!
|
build_dev_publish_.chmod(0o700)!
|
||||||
|
|
||||||
|
develop_templ := $tmpl('templates/develop_src.sh')
|
||||||
mut develop2_ := site.path_src.file_get_new('develop.sh')!
|
mut develop2_ := site.path_src.file_get_new('develop.sh')!
|
||||||
develop2_.template_write(develop, true)!
|
develop2_.template_write(develop_templ, true)!
|
||||||
develop2_.chmod(0o700)!
|
develop2_.chmod(0o700)!
|
||||||
|
|
||||||
|
build_templ := $tmpl('templates/build_src.sh')
|
||||||
mut build2_ := site.path_src.file_get_new('build.sh')!
|
mut build2_ := site.path_src.file_get_new('build.sh')!
|
||||||
build2_.template_write(build, true)!
|
build2_.template_write(build_templ, true)!
|
||||||
build2_.chmod(0o700)!
|
build2_.chmod(0o700)!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,4 +55,7 @@ fn (mut self DocusaurusFactory) template_install(args TemplateInstallArgs) ! {
|
|||||||
)!
|
)!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mut aa := template_path.dir_get("docs") or {return}
|
||||||
|
aa.delete()!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
6
lib/web/docusaurus/templates/build_src.sh
Executable file
6
lib/web/docusaurus/templates/build_src.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
script_dir="???cd "???dirname "??{BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
cd "??{script_dir}"
|
||||||
|
|
||||||
|
hero docusaurus -bp
|
||||||
6
lib/web/docusaurus/templates/develop_src.sh
Executable file
6
lib/web/docusaurus/templates/develop_src.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
script_dir="???cd "???dirname "??{BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
cd "??{script_dir}"
|
||||||
|
|
||||||
|
hero docusaurus -d
|
||||||
@@ -87,10 +87,10 @@ pub fn (mut s DocSite) dev()! {
|
|||||||
console.print_item(' 2. To detach from screen: Press Ctrl+A then D')
|
console.print_item(' 2. To detach from screen: Press Ctrl+A then D')
|
||||||
console.print_item(' 3. To list all screens: screen -ls')
|
console.print_item(' 3. To list all screens: screen -ls')
|
||||||
console.print_item('The site content is on::')
|
console.print_item('The site content is on::')
|
||||||
console.print_item(' 1. location of documents: ${s.path_src.path}/docs')
|
console.print_item(' 1. location of documents: ${s.path_src.path}/src')
|
||||||
if osal.cmd_exists('code') {
|
if osal.cmd_exists('code') {
|
||||||
console.print_item(' 2. We opened above dir in vscode.')
|
console.print_item(' 2. We opened above dir in vscode.')
|
||||||
osal.exec(cmd: 'code ${s.path_src.path}/docs')!
|
osal.exec(cmd: 'code ${s.path_src.path}/src')!
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the watcher in a separate thread
|
// Start the watcher in a separate thread
|
||||||
@@ -99,7 +99,7 @@ pub fn (mut s DocSite) dev()! {
|
|||||||
println('\n')
|
println('\n')
|
||||||
|
|
||||||
if s.args.watch_changes {
|
if s.args.watch_changes {
|
||||||
docs_path := '${s.path_src.path}/docs'
|
docs_path := '${s.path_src.path}/src'
|
||||||
watch_docs(docs_path, s.path_src.path, s.path_build.path)!
|
watch_docs(docs_path, s.path_src.path, s.path_build.path)!
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ pub fn (mut site DocSite) generate() ! {
|
|||||||
aa.copy(dest: '${site.path_build.path}/${item}')!
|
aa.copy(dest: '${site.path_build.path}/${item}')!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for item in ['docs'] {
|
for item in ['src'] {
|
||||||
if os.exists('${site.path_src.path}/${item}') {
|
if os.exists('${site.path_src.path}/${item}') {
|
||||||
mut aa := site.path_src.dir_get(item)!
|
mut aa := site.path_src.dir_get(item)!
|
||||||
aa.copy(dest: '${site.path_build.path}/${item}', delete: true)!
|
aa.copy(dest: '${site.path_build.path}/${item}', delete: true)!
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ fn handle_file_change(event notifier.NotifyEvent, path string, args map[string]s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get relative path from docs directory
|
// Get relative path from docs directory
|
||||||
rel_path := path.replace('${args['path_src']}/docs/', '')
|
rel_path := path.replace('${args['path_src']}/src/', '')
|
||||||
dest_path := '${args['path_build']}/docs/${rel_path}'
|
dest_path := '${args['path_build']}/src/${rel_path}'
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
.create, .modify {
|
.create, .modify {
|
||||||
|
|||||||
@@ -181,6 +181,10 @@ systemd_process_test.v
|
|||||||
data/graphdb
|
data/graphdb
|
||||||
data/radixtree
|
data/radixtree
|
||||||
clients/livekit
|
clients/livekit
|
||||||
|
data/radixtree
|
||||||
|
data/dedupestor
|
||||||
|
core/playcmds
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user