Merge branch 'development_actions007' into development_ourdb_new
# Conflicts: # lib/data/dedupestor/dedupestor.v # lib/data/dedupestor/dedupestor_test.v
This commit is contained in:
14
.gitignore
vendored
14
.gitignore
vendored
@@ -1,4 +1,13 @@
|
||||
|
||||
# Additional ignore files and directories
|
||||
Thumbs.db
|
||||
# Logs
|
||||
logs/
|
||||
*.log
|
||||
*.out
|
||||
# Compiled Python files
|
||||
*.pyc
|
||||
*.pyo
|
||||
__pycache__/
|
||||
*dSYM/
|
||||
.vmodules/
|
||||
.vscode
|
||||
@@ -28,4 +37,5 @@ output/
|
||||
.stellar
|
||||
data.ms/
|
||||
test_basic
|
||||
cli/hero
|
||||
cli/hero
|
||||
.aider*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env -S v -n -w -parallel-cc -enable-globals run
|
||||
// #!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
#!/usr/bin/env -S v -n -cg -w -parallel-cc -enable-globals run
|
||||
// #!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import os
|
||||
import flag
|
||||
|
||||
@@ -51,7 +51,7 @@ fn do() ! {
|
||||
mut cmd := Command{
|
||||
name: 'hero'
|
||||
description: 'Your HERO toolset.'
|
||||
version: '1.0.14'
|
||||
version: '1.0.21'
|
||||
}
|
||||
|
||||
// herocmds.cmd_run_add_flags(mut cmd)
|
||||
@@ -102,6 +102,7 @@ fn do() ! {
|
||||
// herocmds.cmd_juggler(mut cmd)
|
||||
herocmds.cmd_generator(mut cmd)
|
||||
herocmds.cmd_docusaurus(mut cmd)
|
||||
herocmds.cmd_starlight(mut cmd)
|
||||
// herocmds.cmd_docsorter(mut cmd)
|
||||
// cmd.add_command(publishing.cmd_publisher(pre_func))
|
||||
cmd.setup()
|
||||
|
||||
86
examples/aitest/dir_listing.vsh
Executable file
86
examples/aitest/dir_listing.vsh
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
|
||||
// Helper function to format file sizes
|
||||
fn format_size(size i64) string {
|
||||
if size < 1024 {
|
||||
return '${size} B'
|
||||
} else if size < 1024 * 1024 {
|
||||
kb := f64(size) / 1024.0
|
||||
return '${kb:.1f} KB'
|
||||
} else if size < 1024 * 1024 * 1024 {
|
||||
mb := f64(size) / (1024.0 * 1024.0)
|
||||
return '${mb:.1f} MB'
|
||||
} else {
|
||||
gb := f64(size) / (1024.0 * 1024.0 * 1024.0)
|
||||
return '${gb:.1f} GB'
|
||||
}
|
||||
}
|
||||
|
||||
// Set parameters directly in the script
|
||||
// Change these values as needed
|
||||
target_dir := '/tmp' // Current directory by default
|
||||
show_hidden := false // Set to true to show hidden files
|
||||
recursive := false // Set to true for recursive listing
|
||||
|
||||
// Create a Path object for the target directory
|
||||
mut path := pathlib.get(target_dir)
|
||||
|
||||
// Ensure the directory exists and is a directory
|
||||
if path.exist == .no {
|
||||
eprintln('Error: Directory "${target_dir}" does not exist')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
if path.cat != .dir && path.cat != .linkdir {
|
||||
eprintln('Error: "${target_dir}" is not a directory')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Main execution
|
||||
println('Listing contents of: ${path.absolute()}')
|
||||
println('----------------------------')
|
||||
|
||||
// Define list arguments
|
||||
mut list_args := pathlib.ListArgs{
|
||||
recursive: recursive,
|
||||
ignoredefault: !show_hidden
|
||||
}
|
||||
|
||||
// Use pathlib to list the directory contents
|
||||
mut list_result := path.list(list_args) or {
|
||||
eprintln('Error listing directory: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Print each file/directory
|
||||
for p in list_result.paths {
|
||||
// Skip the root directory itself
|
||||
if p.path == path.path {
|
||||
continue
|
||||
}
|
||||
|
||||
// Calculate the level based on the path depth relative to the root
|
||||
rel_path := p.path.replace(list_result.root, '')
|
||||
level := rel_path.count('/') - if rel_path.starts_with('/') { 1 } else { 0 }
|
||||
|
||||
// Print indentation based on level
|
||||
if level > 0 {
|
||||
print(' '.repeat(level))
|
||||
}
|
||||
|
||||
// Print file/directory info
|
||||
name := p.name()
|
||||
if p.cat == .dir || p.cat == .linkdir {
|
||||
println('📁 ${name}/')
|
||||
} else {
|
||||
// Get file size
|
||||
file_size := os.file_size(p.path)
|
||||
println('📄 ${name} (${format_size(file_size)})')
|
||||
}
|
||||
}
|
||||
|
||||
println('----------------------------')
|
||||
println('Done!')
|
||||
25
examples/biztools/bizmodel.vsh
Executable file
25
examples/biztools/bizmodel.vsh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
//#!/usr/bin/env -S v -cg -enable-globals run
|
||||
import freeflowuniverse.herolib.biz.bizmodel
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.core.playcmds
|
||||
import os
|
||||
|
||||
const playbook_path = os.dir(@FILE) + '/playbook'
|
||||
const build_path = os.join_path(os.dir(@FILE), '/docusaurus')
|
||||
|
||||
buildpath := '${os.home_dir()}/hero/var/mdbuild/bizmodel'
|
||||
|
||||
mut model := bizmodel.getset("example")!
|
||||
model.workdir = build_path
|
||||
model.play(mut playbook.new(path: playbook_path)!)!
|
||||
|
||||
println(model.sheet)
|
||||
println(model.sheet.export()!)
|
||||
|
||||
model.sheet.export(path:"~/Downloads/test.csv")!
|
||||
model.sheet.export(path:"~/code/github/freeflowuniverse/starlight_template/src/content/test.csv")!
|
||||
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
bizmodel
|
||||
dest
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
//#!/usr/bin/env -S v -cg -enable-globals run
|
||||
import freeflowuniverse.herolib.data.doctree
|
||||
import freeflowuniverse.herolib.biz.bizmodel
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.core.playcmds
|
||||
import freeflowuniverse.herolib.web.mdbook
|
||||
import os
|
||||
|
||||
const wikipath = os.dir(@FILE) + '/wiki'
|
||||
const summarypath = os.dir(@FILE) + '/wiki/summary.md'
|
||||
|
||||
buildpath := '${os.home_dir()}/hero/var/mdbuild/bizmodel'
|
||||
|
||||
mut m := bizmodel.getset('example')!
|
||||
m.workdir = wikipath
|
||||
m.play(mut playbook.new(path: wikipath)!)!
|
||||
m.export_sheets()!
|
||||
bizmodel.set(m)
|
||||
|
||||
// // execute the actions so we have the info populated
|
||||
// // playcmds.run(mut plb,false)!
|
||||
|
||||
// // just run the doctree & mdbook and it should
|
||||
// // load the doctree, these are all collections
|
||||
// mut tree := doctree.new(name: 'bizmodel')!
|
||||
// tree.scan(path: wikipath)!
|
||||
// tree.export(dest: buildpath, reset: true)!
|
||||
|
||||
// // mut bm:=bizmodel.get("test")!
|
||||
// // println(bm)
|
||||
|
||||
// mut mdbooks := mdbook.get()!
|
||||
// mdbooks.generate(
|
||||
// name: 'bizmodel'
|
||||
// summary_path: summarypath
|
||||
// doctree_path: buildpath
|
||||
// title: 'bizmodel example'
|
||||
// )!
|
||||
// mdbook.book_open('bizmodel')!
|
||||
@@ -1,8 +0,0 @@
|
||||
# Hr Overview
|
||||
|
||||
|
||||
|
||||
!!!bizmodel.employees_wiki bizname:'test'
|
||||
|
||||
|
||||
> note: Nr People like 0:5,20:5 means, month 0 (start) is 5, month 20 its 5 people
|
||||
@@ -1,5 +0,0 @@
|
||||
# CTO
|
||||
|
||||
!!!bizmodel.employee_wiki bizname:'test' name:'despiegk'
|
||||
|
||||
!!wiki.include page:cto_description.md
|
||||
@@ -1,3 +0,0 @@
|
||||
## CTO Description
|
||||
|
||||
this is a page to test nested includes
|
||||
@@ -1,52 +0,0 @@
|
||||
# This is our business model planner
|
||||
|
||||
## P&L Overview
|
||||
|
||||
|
||||
<!-- period is in months, 3 means every quarter -->
|
||||
|
||||
|
||||
!!bizmodel.graph_bar_row rowname:revenue_total unit:million title:'A Title' title_sub:'Sub' sheetname:'bizmodel_test'
|
||||
|
||||
Unit is in Million USD.
|
||||
|
||||
!!bizmodel.graph_bar_row rowname:revenue_total unit:million sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.graph_line_row rowname:revenue_total unit:million sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.graph_pie_row rowname:revenue_total unit:million size:'80%' sheetname:'bizmodel_test'
|
||||
|
||||
## FUNDING
|
||||
|
||||
!!bizmodel.sheet_wiki includefilter:'funding' sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.sheet_wiki title:'REVENUE' includefilter:rev sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.sheet_wiki title:'Revenue Total' includefilter:'revtotal' sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.sheet_wiki title:'REVENUE' includefilter:'revtotal2' sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.sheet_wiki title:'COGS' includefilter:'cogs' sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.sheet_wiki title:'Margin' includefilter:'margin' sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.sheet_wiki title:'HR Teams' includefilter:'hrnr' sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.sheet_wiki title:'HR Costs' includefilter:'hrcost' sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.sheet_wiki title:'COSTS' includefilter:'ocost' sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.sheet_wiki title:'HR Costs' includefilter:'hrcost' sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.sheet_wiki title:'P&L Overview' includefilter:'pl' sheetname:'bizmodel_test'
|
||||
|
||||
!!bizmodel.sheet_wiki title:'P&L Overview' includefilter:'pl' sheetname:'bizmodel_test'
|
||||
|
||||
## Some Details
|
||||
|
||||
> show how we can do per month
|
||||
|
||||
!!bizmodel.sheet_wiki includefilter:'pl' period_months:1 sheetname:'bizmodel_test'
|
||||
|
||||
|
||||
|
||||
4
examples/biztools/bizmodel_docusaurus/.gitignore
vendored
Normal file
4
examples/biztools/bizmodel_docusaurus/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
bizmodel
|
||||
dest
|
||||
wiki
|
||||
build
|
||||
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
37
examples/biztools/bizmodel_docusaurus/bizmodel_docusaurus.vsh
Executable file
37
examples/biztools/bizmodel_docusaurus/bizmodel_docusaurus.vsh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
//#!/usr/bin/env -S v -cg -enable-globals run
|
||||
import freeflowuniverse.herolib.biz.bizmodel
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.core.playcmds
|
||||
import os
|
||||
|
||||
//TODO: need to fix wrong location
|
||||
const playbook_path = os.dir(@FILE) + '/playbook'
|
||||
const build_path = os.join_path(os.dir(@FILE), '/docusaurus')
|
||||
|
||||
buildpath := '${os.home_dir()}/hero/var/mdbuild/bizmodel'
|
||||
|
||||
mut model := bizmodel.getset("example")!
|
||||
model.workdir = build_path
|
||||
model.play(mut playbook.new(path: playbook_path)!)!
|
||||
|
||||
println(model.sheet)
|
||||
println(model.sheet.export()!)
|
||||
|
||||
// model.sheet.export(path:"~/Downloads/test.csv")!
|
||||
// model.sheet.export(path:"~/code/github/freeflowuniverse/starlight_template/src/content/test.csv")!
|
||||
|
||||
|
||||
|
||||
|
||||
report := model.new_report(
|
||||
name: 'example_report'
|
||||
title: 'Example Business Model'
|
||||
)!
|
||||
|
||||
report.export(
|
||||
path: build_path
|
||||
overwrite: true
|
||||
format: .docusaurus
|
||||
)!
|
||||
@@ -0,0 +1 @@
|
||||
output dir of example
|
||||
22
examples/biztools/bizmodel_docusaurus/docusaurus/build.sh
Executable file
22
examples/biztools/bizmodel_docusaurus/docusaurus/build.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "${script_dir}"
|
||||
|
||||
echo "Docs directory: $script_dir"
|
||||
|
||||
cd "${HOME}/hero/var/docusaurus"
|
||||
|
||||
export PATH=/tmp/docusaurus_build/node_modules/.bin:${HOME}/.bun/bin/:$PATH
|
||||
|
||||
rm -rf /Users/despiegk/hero/var/docusaurus/build/
|
||||
|
||||
. ${HOME}/.zprofile
|
||||
|
||||
bun docusaurus build
|
||||
|
||||
mkdir -p /Users/despiegk/code/github/freeflowuniverse/herolib/examples/biztools/bizmodel/example/docusaurus
|
||||
echo SYNC TO /Users/despiegk/code/github/freeflowuniverse/herolib/examples/biztools/bizmodel/example/docusaurus
|
||||
rsync -rv --delete /Users/despiegk/hero/var/docusaurus/build/ /Users/despiegk/code/github/freeflowuniverse/herolib/examples/biztools/bizmodel/example/docusaurus/
|
||||
@@ -0,0 +1 @@
|
||||
{"style":"dark","links":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"","title":"Docusaurus","tagline":"","favicon":"img/favicon.png","url":"http://localhost","url_home":"docs/introduction","baseUrl":"/","image":"img/tf_graph.png","metadata":{"description":"Docusaurus","image":"Docusaurus","title":"Docusaurus"},"buildDest":[],"buildDestDev":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"title":"Business Model","items":[{"href":"https://threefold.info/kristof/","label":"ThreeFold Technology","position":"right"},{"href":"https://threefold.io","label":"Operational Plan","position":"left"}]}
|
||||
16
examples/biztools/bizmodel_docusaurus/docusaurus/develop.sh
Executable file
16
examples/biztools/bizmodel_docusaurus/docusaurus/develop.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "${script_dir}"
|
||||
|
||||
echo "Docs directory: $script_dir"
|
||||
|
||||
cd "${HOME}/hero/var/docusaurus"
|
||||
|
||||
export PATH=/tmp/docusaurus_build/node_modules/.bin:${HOME}/.bun/bin/:$PATH
|
||||
|
||||
. ${HOME}/.zprofile
|
||||
|
||||
bun run start -p 3100
|
||||
@@ -4,11 +4,31 @@
|
||||
|
||||
This company is a cloud company ...
|
||||
|
||||
- name, e.g. for a specific project
|
||||
- descr, description of the revenue line item
|
||||
- revenue_items: does one of revenue, is not exterpolated
|
||||
- revenue_growth: is a revenue stream which is being extrapolated
|
||||
- revenue_setup, revenue for 1 item '1000usd'
|
||||
- revenue_setup_delay
|
||||
- revenue_monthly, revenue per month for 1 item
|
||||
- revenue_monthly_delay, how many months before monthly revenue starts
|
||||
- maintenance_month_perc, how much percent of revenue_setup will come back over months
|
||||
- cogs_setup, cost of good for 1 item at setup
|
||||
- cogs_setup_delay, how many months before setup cogs starts, after sales
|
||||
- cogs_setup_perc: what is percentage of the cogs (can change over time) for setup e.g. 0:50%
|
||||
|
||||
- cogs_monthly, cost of goods for the monthly per 1 item
|
||||
- cogs_monthly_delay, how many months before monthly cogs starts, after sales
|
||||
- cogs_monthly_perc: what is percentage of the cogs (can change over time) for monthly e.g. 0:5%,12:10%
|
||||
|
||||
- nr_sold: how many do we sell per month (is in growth format e.g. 10:100,20:200, default is 1)
|
||||
- nr_months_recurring: how many months is recurring, if 0 then no recurring
|
||||
|
||||
```js
|
||||
!!bizmodel.revenue_define bizname:'test'
|
||||
descr:'OEM Deals'
|
||||
revenue_time:'10:1000000EUR,15:3333,20:1200000'
|
||||
cogs_perc: '1:5%,20:10%'
|
||||
revenue_items:'10:1000000EUR,15:3333,20:1200000'
|
||||
cogs_setup_perc: '1:5%,20:10%'
|
||||
|
||||
!!bizmodel.revenue_define bizname:'test'
|
||||
descr:'License Deals'
|
||||
@@ -23,6 +43,7 @@ This company is a cloud company ...
|
||||
revenue_nr:'10:1000,24:2000,60:40000'
|
||||
cogs_perc: '10%'
|
||||
rev_delay_month: 1
|
||||
|
||||
```
|
||||
|
||||
## Revenue Items Recurring
|
||||
7
examples/installers/cometbft.vsh
Executable file
7
examples/installers/cometbft.vsh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.installers.db.cometbft as cometbft_installer
|
||||
|
||||
// coredns_installer.delete()!
|
||||
mut installer := cometbft_installer.get()!
|
||||
installer.install()!
|
||||
@@ -8,33 +8,5 @@ import freeflowuniverse.herolib.core
|
||||
|
||||
core.interactive_set()! // make sure the sudo works so we can do things even if it requires those rights
|
||||
|
||||
// import freeflowuniverse.herolib.data.dbfs
|
||||
// import freeflowuniverse.herolib.installers.lang.vlang
|
||||
// import freeflowuniverse.herolib.installers.db.redis as redis_installer
|
||||
// import freeflowuniverse.herolib.installers.infra.coredns as coredns_installer
|
||||
// import freeflowuniverse.herolib.installers.sysadmintools.daguserver as dagu_installer
|
||||
// import freeflowuniverse.herolib.installers.sysadmintools.b2 as b2_installer
|
||||
// import freeflowuniverse.herolib.installers.net.mycelium as mycelium_installer
|
||||
// import freeflowuniverse.herolib.osal.screen
|
||||
// import freeflowuniverse.herolib.osal
|
||||
|
||||
// redis_installer.new()!
|
||||
// dagu_installer.install(passwd:"1234",secret:"1234",restart:true)!
|
||||
|
||||
// coredns_installer.install()!
|
||||
// mycelium_installer.install()!
|
||||
// mycelium_installer.restart()!
|
||||
|
||||
// mut screens:=screen.new()!
|
||||
// println(screens)
|
||||
|
||||
// dagu_installer.check(secret:"1234")!
|
||||
|
||||
// vlang.v_analyzer_install()!
|
||||
|
||||
// b2_installer.install()!
|
||||
|
||||
// rust.install(reset:false)!
|
||||
// python.install(reset:false)!
|
||||
// nodejs.install(reset:false)!
|
||||
golang.install(reset: false)!
|
||||
mut i1:=golang.get()!
|
||||
i1.install()!
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid.models
|
||||
import freeflowuniverse.herolib.threefold.grid3.models
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import json
|
||||
import log
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import freeflowuniverse.herolib.threefold.grid.models
|
||||
import freeflowuniverse.herolib.threefold.grid3.models
|
||||
import log
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import freeflowuniverse.herolib.threefold.grid.models
|
||||
import freeflowuniverse.herolib.threefold.grid3.models
|
||||
import log
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid.models
|
||||
import freeflowuniverse.herolib.threefold.grid3.models
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import json
|
||||
import log
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid.models
|
||||
import freeflowuniverse.herolib.threefold.grid3.models
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import log
|
||||
import os
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid.models
|
||||
import freeflowuniverse.herolib.threefold.grid3.models
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import log
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid.models
|
||||
import freeflowuniverse.herolib.threefold.grid3.models
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import flag
|
||||
import rand
|
||||
import json
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid.models
|
||||
import freeflowuniverse.herolib.threefold.grid3.models
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.gridproxy.model { NodeFilter }
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy.model { NodeFilter }
|
||||
import rand
|
||||
import log
|
||||
import os
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
contract_id := u64(119450)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
fn get_contracts_example() ! {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
fn get_farms_example() ! {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
fn get_gateway_nodes_example() ! {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
mut gp_client := gridproxy.new(net: .test, cache: true)!
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
fn get_nodes_example() ! {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.gridproxy.model { NodeStatus }
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy.model { NodeStatus }
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
fn get_online_grid_stats_example() ! {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
fn get_all_twins_example() ! {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid.models
|
||||
import freeflowuniverse.herolib.threefold.grid3.models
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import time
|
||||
import flag
|
||||
import rand
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env -S v -gc none -no-retry-compilation -d use_openssl -enable-globals -cg run
|
||||
|
||||
//#!/usr/bin/env -S v -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals -cg run
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.tfgrid3deployer
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.deployer
|
||||
import freeflowuniverse.herolib.installers.threefold.griddriver
|
||||
import os
|
||||
import time
|
||||
@@ -20,9 +19,9 @@ deployment.add_machine(
|
||||
cpu: 1
|
||||
memory: 2
|
||||
planetary: false
|
||||
public_ip4: true
|
||||
wireguard: true
|
||||
public_ip4: false
|
||||
size: 10 // 10 gig
|
||||
mycelium: tfgrid3deployer.Mycelium{}
|
||||
)
|
||||
deployment.deploy()!
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env -S v -gc none -d use_openssl -enable-globals -cg run
|
||||
|
||||
//#!/usr/bin/env -S v -gc none -cc tcc -d use_openssl -enable-globals -cg run
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.tfgrid3deployer
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.deployer
|
||||
import freeflowuniverse.herolib.installers.threefold.griddriver
|
||||
import os
|
||||
import time
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env -S v -gc none -no-retry-compilation -d use_openssl -enable-globals -cg run
|
||||
|
||||
//#!/usr/bin/env -S v -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals -cg run
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.tfgrid3deployer
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.deployer
|
||||
import freeflowuniverse.herolib.installers.threefold.griddriver
|
||||
import os
|
||||
import time
|
||||
|
||||
@@ -7,8 +7,8 @@ This script automates the deployment of an OpenWebUI instance on the ThreeFold G
|
||||
- V compiler installed
|
||||
- OpenSSL support enabled
|
||||
- herolib dependencies:
|
||||
- `freeflowuniverse.herolib.threefold.gridproxy`
|
||||
- `freeflowuniverse.herolib.threefold.tfgrid3deployer`
|
||||
- `freeflowuniverse.herolib.threefold.grid3.gridproxy`
|
||||
- `freeflowuniverse.herolib.threefold.grid3.deployer`
|
||||
- `freeflowuniverse.herolib.installers.threefold.griddriver`
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.tfgrid3deployer
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.deployer
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.installers.threefold.griddriver
|
||||
|
||||
fn main() {
|
||||
griddriver.install()!
|
||||
|
||||
v := tfgrid3deployer.get()!
|
||||
println('cred: ${v}')
|
||||
deployment_name := 'my_deployment27'
|
||||
@@ -19,19 +16,17 @@ fn main() {
|
||||
cpu: 1
|
||||
memory: 2
|
||||
planetary: false
|
||||
public_ip4: true
|
||||
mycelium: tfgrid3deployer.Mycelium{}
|
||||
nodes: [u32(167)]
|
||||
)
|
||||
deployment.add_machine(
|
||||
name: 'my_vm2'
|
||||
cpu: 1
|
||||
memory: 2
|
||||
planetary: false
|
||||
public_ip4: true
|
||||
mycelium: tfgrid3deployer.Mycelium{}
|
||||
// nodes: [u32(164)]
|
||||
public_ip4: false
|
||||
nodes: [167]
|
||||
)
|
||||
// deployment.add_machine(
|
||||
// name: 'my_vm2'
|
||||
// cpu: 1
|
||||
// memory: 2
|
||||
// planetary: false
|
||||
// public_ip4: true
|
||||
// // nodes: [u32(164)]
|
||||
// )
|
||||
|
||||
deployment.add_zdb(name: 'my_zdb', password: 'my_passw&rd', size: 2)
|
||||
deployment.add_webname(name: 'mywebname2', backend: 'http://37.27.132.47:8000')
|
||||
|
||||
39
examples/threefold/tfgrid3deployer/vm.vsh
Executable file
39
examples/threefold/tfgrid3deployer/vm.vsh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.deployer
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
const node_id = u32(2009)
|
||||
const deployment_name = 'vmtestdeployment'
|
||||
|
||||
fn deploy_vm() ! {
|
||||
mut deployment := deployer.new_deployment(deployment_name)!
|
||||
deployment.add_machine(
|
||||
name: 'vm1'
|
||||
cpu: 1
|
||||
memory: 2
|
||||
planetary: false
|
||||
public_ip4: true
|
||||
nodes: [node_id]
|
||||
)
|
||||
deployment.deploy()!
|
||||
println(deployment)
|
||||
}
|
||||
|
||||
fn delete_vm() ! {
|
||||
deployer.delete_deployment(deployment_name)!
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if os.args.len < 2 {
|
||||
println('Please provide a command: "deploy" or "delete"')
|
||||
return
|
||||
}
|
||||
match os.args[1] {
|
||||
'deploy' { deploy_vm()! }
|
||||
'delete' { delete_vm()! }
|
||||
else { println('Invalid command. Use "deploy" or "delete"') }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env -S v -gc none -cc tcc -d use_openssl -enable-globals -cg run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.tfgrid3deployer
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.deployer
|
||||
import freeflowuniverse.herolib.installers.threefold.griddriver
|
||||
import os
|
||||
import time
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#!/usr/bin/env -S v -gc none -d use_openssl -enable-globals -cg run
|
||||
|
||||
//#!/usr/bin/env -S v -gc none -cc tcc -d use_openssl -enable-globals -cg run
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.tfgrid3deployer
|
||||
import freeflowuniverse.herolib.threefold.grid3.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.grid3.deployer
|
||||
import freeflowuniverse.herolib.installers.threefold.griddriver
|
||||
import os
|
||||
import time
|
||||
|
||||
griddriver.install()!
|
||||
res2 := tfgrid3deployer.filter_nodes()!
|
||||
println(res2)
|
||||
exit(0)
|
||||
|
||||
v := tfgrid3deployer.get()!
|
||||
println('cred: ${v}')
|
||||
@@ -18,7 +20,7 @@ deployment.add_machine(
|
||||
cpu: 1
|
||||
memory: 2
|
||||
planetary: false
|
||||
public_ip4: true
|
||||
public_ip4: false
|
||||
size: 10 // 10 gig
|
||||
mycelium: tfgrid3deployer.Mycelium{}
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.vfs.webdav
|
||||
import freeflowuniverse.herolib.vfs.vfsnested
|
||||
import freeflowuniverse.herolib.vfs.vfscore
|
||||
import freeflowuniverse.herolib.vfs.vfsourdb
|
||||
// import freeflowuniverse.herolib.vfs.webdav
|
||||
import freeflowuniverse.herolib.vfs.vfs_nested
|
||||
import freeflowuniverse.herolib.vfs.vfs_core
|
||||
import freeflowuniverse.herolib.vfs.vfs_ourdb
|
||||
|
||||
mut high_level_vfs := vfsnested.new()
|
||||
|
||||
@@ -17,11 +17,11 @@ high_level_vfs.add_vfs('/data', vfs1) or { panic(err) }
|
||||
high_level_vfs.add_vfs('/config', vfs2) or { panic(err) }
|
||||
high_level_vfs.add_vfs('/data/backup', vfs3) or { panic(err) } // Nested under /data
|
||||
|
||||
// Create WebDAV Server that uses high level VFS
|
||||
mut webdav_server := webdav.new_app(
|
||||
vfs: high_level_vfs
|
||||
user_db: {
|
||||
'omda': '123'
|
||||
}
|
||||
)!
|
||||
webdav_server.run()
|
||||
// // Create WebDAV Server that uses high level VFS
|
||||
// mut webdav_server := webdav.new_app(
|
||||
// vfs: high_level_vfs
|
||||
// user_db: {
|
||||
// 'omda': '123'
|
||||
// }
|
||||
// )!
|
||||
// webdav_server.run()
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.web.docusaurus
|
||||
// import freeflowuniverse.herolib.data.doctree
|
||||
|
||||
// Create a new docusaurus factory
|
||||
mut docs := docusaurus.new(
|
||||
build_path: '/tmp/docusaurus_build'
|
||||
)!
|
||||
|
||||
// Create a new docusaurus site
|
||||
mut site := docs.dev(
|
||||
url: 'https://git.ourworld.tf/despiegk/docs_kristof'
|
||||
)!
|
||||
|
||||
// FOR FUTURE TO ADD CONTENT FROM DOCTREE
|
||||
|
||||
// Create a doctree for content
|
||||
// mut tree := doctree.new(name: 'content')!
|
||||
|
||||
// // Add some content from a git repository
|
||||
// tree.scan(
|
||||
// git_url: 'https://github.com/yourusername/your-docs-repo'
|
||||
// git_pull: true
|
||||
// )!
|
||||
|
||||
// // Export the content to the docusaurus site
|
||||
// tree.export(
|
||||
// destination: '${site.path_build.path}/docs'
|
||||
// reset: true
|
||||
// keep_structure: true
|
||||
// exclude_errors: false
|
||||
// )!
|
||||
|
||||
// Build the docusaurus site
|
||||
// site.build()!
|
||||
|
||||
// Generate the static site
|
||||
// site.generate()!
|
||||
|
||||
// Optionally open the site in a browser
|
||||
// site.open()!
|
||||
94
examples/webtools/markdown_renderer/markdown_parser.vsh
Executable file
94
examples/webtools/markdown_renderer/markdown_parser.vsh
Executable file
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none run
|
||||
|
||||
import freeflowuniverse.herolib.data.markdownparser2
|
||||
|
||||
// Sample markdown text
|
||||
text := '# Heading 1
|
||||
|
||||
This is a paragraph with **bold** and *italic* text.
|
||||
|
||||
## Heading 2
|
||||
|
||||
- List item 1
|
||||
- List item 2
|
||||
- Nested item
|
||||
- List item 3
|
||||
|
||||
```v
|
||||
fn main() {
|
||||
println("Hello, world!")
|
||||
}
|
||||
```
|
||||
|
||||
> This is a blockquote
|
||||
> with multiple lines
|
||||
|
||||
| Column 1 | Column 2 | Column 3 |
|
||||
|----------|:--------:|---------:|
|
||||
| Left | Center | Right |
|
||||
| Cell 1 | Cell 2 | Cell 3 |
|
||||
|
||||
[Link to V language](https://vlang.io)
|
||||
|
||||

|
||||
|
||||
Footnote reference[^1]
|
||||
|
||||
[^1]: This is a footnote.
|
||||
'
|
||||
|
||||
// Example 1: Using the plain text renderer
|
||||
println('=== PLAINTEXT RENDERING ===')
|
||||
println(markdownparser2.to_plain(text))
|
||||
println('')
|
||||
|
||||
// Example 2: Using the structure renderer to show markdown structure
|
||||
println('=== STRUCTURE RENDERING ===')
|
||||
println(markdownparser2.to_structure(text))
|
||||
|
||||
// Example 3: Using the navigator to find specific elements
|
||||
println('\n=== NAVIGATION EXAMPLE ===')
|
||||
|
||||
// Parse the markdown text
|
||||
doc := markdownparser2.parse(text)
|
||||
|
||||
// Create a navigator
|
||||
mut nav := markdownparser2.new_navigator(doc)
|
||||
|
||||
// Find all headings
|
||||
headings := nav.find_all_by_type(.heading)
|
||||
println('Found ${headings.len} headings:')
|
||||
for heading in headings {
|
||||
level := heading.attributes['level']
|
||||
println(' ${'#'.repeat(level.int())} ${heading.content}')
|
||||
}
|
||||
|
||||
// Find all code blocks
|
||||
code_blocks := nav.find_all_by_type(.code_block)
|
||||
println('\nFound ${code_blocks.len} code blocks:')
|
||||
for block in code_blocks {
|
||||
language := block.attributes['language']
|
||||
println(' Language: ${language}')
|
||||
println(' Content length: ${block.content.len} characters')
|
||||
}
|
||||
|
||||
// Find all list items
|
||||
list_items := nav.find_all_by_type(.list_item)
|
||||
println('\nFound ${list_items.len} list items:')
|
||||
for item in list_items {
|
||||
println(' - ${item.content}')
|
||||
}
|
||||
|
||||
// Find content containing specific text
|
||||
if element := nav.find_by_content('blockquote') {
|
||||
println('\nFound element containing "blockquote":')
|
||||
println(' Type: ${element.typ}')
|
||||
println(' Content: ${element.content}')
|
||||
}
|
||||
|
||||
// Find all footnotes
|
||||
println('\nFootnotes:')
|
||||
for id, footnote in nav.footnotes() {
|
||||
println(' [^${id}]: ${footnote.content}')
|
||||
}
|
||||
|
||||
27
examples/webtools/markdown_renderer/markdown_render.vsh
Executable file
27
examples/webtools/markdown_renderer/markdown_render.vsh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
// import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import log
|
||||
import os
|
||||
import markdown
|
||||
import freeflowuniverse.herolib.data.markdownparser2
|
||||
|
||||
path2:="${os.home_dir()}/code/github/freeflowuniverse/herolib/examples/webtools/mdbook_markdown/content/links.md"
|
||||
path1:="${os.home_dir()}/code/github/freeflowuniverse/herolib/examples/webtools/mdbook_markdown/content/test.md"
|
||||
|
||||
text := os.read_file(path1)!
|
||||
|
||||
// Example 1: Using the built-in plaintext renderer
|
||||
println('=== PLAINTEXT RENDERING ===')
|
||||
println(markdown.to_plain(text))
|
||||
println('')
|
||||
|
||||
// Example 2: Using our custom structure renderer to show markdown structure
|
||||
println('=== STRUCTURE RENDERING ===')
|
||||
println(markdownparser2.to_structure(text))
|
||||
|
||||
// // Example 3: Using a simple markdown example to demonstrate structure
|
||||
// println('\n=== STRUCTURE OF A SIMPLE MARKDOWN EXAMPLE ===')
|
||||
// simple_md := '# Heading 1\n\nThis is a paragraph with **bold** and *italic* text.\n\n- List item 1\n- List item 2\n\n```v\nfn main() {\n\tprintln("Hello, world!")\n}\n```\n\n[Link to V language](https://vlang.io)'
|
||||
// println(markdown.to_structure(simple_md))
|
||||
29
examples/webtools/mdbook_markdown/content/cybercity.md
Normal file
29
examples/webtools/mdbook_markdown/content/cybercity.md
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
sidebar_position: 10
|
||||
title: 'Dunia CyberCity'
|
||||
description: 'Co-create the Future'
|
||||
---
|
||||
|
||||

|
||||
|
||||
|
||||
We are building a 700,000 m2 Regenerative Startup Cyber City
|
||||
|
||||
- 100% co-owned
|
||||
- regenerative
|
||||
- autonomous zone
|
||||
|
||||
a city for startups and its creators
|
||||
|
||||
- build a system for augmented collective intelligence
|
||||
- operate business wise from a digital freezone
|
||||
- (co)own assets (shares, digital currencies) safely and privately
|
||||
|
||||
|
||||
## More Info
|
||||
|
||||
> see [https://friends.threefold.info/cybercity](https://friends.threefold.info/cybercity)
|
||||
|
||||
- login:```planet```
|
||||
- passwd:```first```
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.data.doctree
|
||||
|
||||
@@ -11,16 +11,17 @@ mut tree := doctree.new(name: 'test')!
|
||||
// git_root string
|
||||
// git_pull bool
|
||||
// load bool = true // means we scan automatically the added collection
|
||||
for project in 'projectinca, legal, why, web4,tfgrid3'.split(',').map(it.trim_space()) {
|
||||
for project in 'projectinca, legal, why'.split(',').map(it.trim_space()) {
|
||||
tree.scan(
|
||||
git_url: 'https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/development/collections/${project}'
|
||||
git_pull: false
|
||||
)!
|
||||
}
|
||||
|
||||
|
||||
tree.export(
|
||||
destination: '/tmp/test'
|
||||
destination: '/tmp/mdexport'
|
||||
reset: true
|
||||
keep_structure: true
|
||||
//keep_structure: true
|
||||
exclude_errors: false
|
||||
)!
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
// import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
17
examples/webtools/starllight_example.vsh
Executable file
17
examples/webtools/starllight_example.vsh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.web.starlight
|
||||
// import freeflowuniverse.herolib.data.doctree
|
||||
|
||||
// Create a new starlight factory
|
||||
mut docs := starlight.new(
|
||||
build_path: '/tmp/starlight_build'
|
||||
)!
|
||||
|
||||
// Create a new starlight site
|
||||
mut site := docs.get(
|
||||
url: 'https://git.ourworld.tf/tfgrid/docs_aibox'
|
||||
init:true //init means we put config files if not there
|
||||
)!
|
||||
|
||||
site.dev()!
|
||||
@@ -4,7 +4,7 @@ set -e
|
||||
|
||||
os_name="$(uname -s)"
|
||||
arch_name="$(uname -m)"
|
||||
version='1.0.14'
|
||||
version='1.0.21'
|
||||
|
||||
|
||||
# Base URL for GitHub releases
|
||||
|
||||
1
lib/biz/bizmodel/.gitignore
vendored
Normal file
1
lib/biz/bizmodel/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
testdata
|
||||
@@ -15,7 +15,7 @@ pub fn (mut m BizModel) act(action Action) !Action {
|
||||
m.funding_define_action(action)!
|
||||
}
|
||||
'revenue_define' {
|
||||
m.funding_define_action(action)!
|
||||
m.revenue_action(action)!
|
||||
}
|
||||
'costcenter_define' {
|
||||
m.costcenter_define_action(action)!
|
||||
@@ -58,7 +58,7 @@ fn (mut m BizModel) export_sheet_action(action Action) !Action {
|
||||
}
|
||||
|
||||
fn (mut m BizModel) export_graph_title_action(action Action) !Action {
|
||||
return m.export_action(m.sheet.wiki_title_chart(row_args_from_params(action.params)!), action)
|
||||
return m.export_action(m.sheet.wiki_title_chart(row_args_from_params(action.params)!)!, action)
|
||||
}
|
||||
|
||||
fn (mut m BizModel) export_graph_line_action(action Action) !Action {
|
||||
|
||||
@@ -5,18 +5,6 @@ import freeflowuniverse.herolib.web.docusaurus
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
|
||||
pub struct Export {
|
||||
pub:
|
||||
path string
|
||||
overwrite bool
|
||||
format ExportFormat
|
||||
}
|
||||
|
||||
pub enum ExportFormat {
|
||||
docusaurus
|
||||
mdbook
|
||||
}
|
||||
|
||||
pub struct Report {
|
||||
pub:
|
||||
name string
|
||||
@@ -36,7 +24,15 @@ pub fn (b BizModel) new_report(report Report) !Report {
|
||||
name := if report.name != '' {report.name} else { texttools.snake_case(report.title) }
|
||||
path := pathlib.get_dir(
|
||||
path: os.join_path(os.home_dir(), '/hero/var/bizmodel/reports/${name}')
|
||||
create: true
|
||||
empty: true
|
||||
)!
|
||||
|
||||
b.write_introduction(path.path)!
|
||||
b.write_operational_plan(path.path)!
|
||||
b.write_revenue_model(path.path)!
|
||||
b.write_cost_structure(path.path)!
|
||||
|
||||
return Report {
|
||||
...report,
|
||||
name: name
|
||||
@@ -52,39 +48,104 @@ pub fn (b BizModel) new_report(report Report) !Report {
|
||||
// b.export_fundraising(export)
|
||||
}
|
||||
|
||||
pub struct Export {
|
||||
pub:
|
||||
path string
|
||||
overwrite bool
|
||||
format ExportFormat
|
||||
}
|
||||
|
||||
pub enum ExportFormat {
|
||||
docusaurus
|
||||
mdbook
|
||||
}
|
||||
|
||||
pub fn (r Report) export(export Export) ! {
|
||||
match export.format {
|
||||
.docusaurus {
|
||||
mut dir := pathlib.get_dir(path: r.path)!
|
||||
dir.copy(dest: '${export.path}/docs', delete: true)!
|
||||
mut factory := docusaurus.new()!
|
||||
mut site := factory.get(
|
||||
name: r.name
|
||||
path: r.path
|
||||
path: export.path
|
||||
publish_path: export.path
|
||||
config: docusaurus.Config {} //TODO: is this needed
|
||||
init: true
|
||||
config: docusaurus.Config {
|
||||
navbar: docusaurus.Navbar {
|
||||
title: "Business Model",
|
||||
items: [
|
||||
docusaurus.NavbarItem{
|
||||
"href": "https://threefold.info/kristof/",
|
||||
"label": "ThreeFold Technology",
|
||||
"position": "right"
|
||||
},
|
||||
docusaurus.NavbarItem{
|
||||
"href": "https://threefold.io",
|
||||
"label": "Operational Plan",
|
||||
"position": "left"
|
||||
}
|
||||
]
|
||||
}
|
||||
main: docusaurus.Main {
|
||||
url_home: 'docs/introduction'
|
||||
}
|
||||
} //TODO: is this needed
|
||||
)!
|
||||
site.build()!
|
||||
site.generate()!
|
||||
}
|
||||
.mdbook {panic('MDBook export not fully implemented')}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (b BizModel) export_operational_plan(export Export) ! {
|
||||
mut hr_page := pathlib.get_file(path: '${export.path}/human_resources.md')!
|
||||
hr_page.template_write('./templates/human_resources.md', export.overwrite)!
|
||||
pub fn (model BizModel) write_introduction(path string) ! {
|
||||
mut index_page := pathlib.get_file(path: '${path}/introduction.md')!
|
||||
// mut tmpl_index := $tmpl('templates/index.md')
|
||||
index_page.template_write($tmpl('templates/introduction.md'), true)!
|
||||
}
|
||||
|
||||
for key, employee in b.employees {
|
||||
mut employee_page := pathlib.get_file(path: '${export.path}/${texttools.snake_case(employee.name)}.md')!
|
||||
employee_page.template_write('./templates/employee.md', export.overwrite)!
|
||||
pub fn (model BizModel) write_operational_plan(path string) ! {
|
||||
mut dir := pathlib.get_dir(path: '${path}/operational_plan')!
|
||||
mut ops_page := pathlib.get_file(path: '${dir.path}/operational_plan.md')!
|
||||
ops_page.write('# Operational Plan')!
|
||||
|
||||
mut hr_dir := pathlib.get_dir(path: '${dir.path}/human_resources')!
|
||||
mut hr_page := pathlib.get_file(path: '${hr_dir.path}/human_resources.md')!
|
||||
hr_page.template_write($tmpl('./templates/human_resources.md'), true)!
|
||||
|
||||
for key, employee in model.employees {
|
||||
mut employee_page := pathlib.get_file(path: '${hr_dir.path}/${texttools.snake_case(employee.name)}.md')!
|
||||
employee_cost_chart := model.sheet.line_chart(rowname:'hr_cost_${employee.name}', unit: .million)!.mdx()
|
||||
employee_page.template_write($tmpl('./templates/employee.md'), true)!
|
||||
}
|
||||
|
||||
mut depts_dir := pathlib.get_dir(path: '${dir.path}/departments')!
|
||||
for key, department in model.departments {
|
||||
mut dept_page := pathlib.get_file(path: '${depts_dir.path}/${texttools.snake_case(department.name)}.md')!
|
||||
// dept_cost_chart := model.sheet.line_chart(rowname:'hr_cost_${employee.name}', unit: .million)!.mdx()
|
||||
// println(employee_cost_chart)
|
||||
dept_page.template_write($tmpl('./templates/department.md'), true)!
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (b BizModel) export_revenue_model(export Export) ! {
|
||||
println('begin')
|
||||
mut overview_page := pathlib.get_file(path: '${export.path}/revenue_overview.md')!
|
||||
overview_page.template_write('./templates/overview.md', export.overwrite)!
|
||||
pub fn (model BizModel) write_revenue_model(path string) ! {
|
||||
mut dir := pathlib.get_dir(path: '${path}/revenue_model')!
|
||||
mut rm_page := pathlib.get_file(path: '${dir.path}/revenue_model.md')!
|
||||
rm_page.write('# Revenue Model')!
|
||||
|
||||
mut products_dir := pathlib.get_dir(path: '${dir.path}/products')!
|
||||
mut products_page := pathlib.get_file(path: '${products_dir.path}/products.md')!
|
||||
products_page.template_write('# Products', true)!
|
||||
|
||||
for key, product in b.products {
|
||||
mut product_page := pathlib.get_file(path: '${export.path}/${texttools.snake_case(product.name)}.md')!
|
||||
product_page.template_write('./templates/product.md', export.overwrite)!
|
||||
name1 := 'example'
|
||||
for key, product in model.products {
|
||||
mut product_page := pathlib.get_file(path: '${products_dir.path}/${texttools.snake_case(product.name)}.md')!
|
||||
product_page.template_write($tmpl('./templates/product.md'), true)!
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (model BizModel) write_cost_structure(path string) ! {
|
||||
mut dir := pathlib.get_dir(path: '${path}/cost_structure')!
|
||||
mut cs_page := pathlib.get_file(path: '${dir.path}/cost_structure.md')!
|
||||
cs_page.write('# Cost Structure')!
|
||||
}
|
||||
@@ -62,7 +62,7 @@ fn employee_wiki(p paramsparser.Params, sim BizModel) !string {
|
||||
|
||||
// theme := 'light'
|
||||
// theme := 'dark' // Removed unused variable
|
||||
mut t := $tmpl('./templates/employee.md')
|
||||
mut t := $tmpl('./templates/employee_old.md')
|
||||
return t
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import freeflowuniverse.herolib.biz.spreadsheet
|
||||
pub struct BizModel {
|
||||
pub mut:
|
||||
name string
|
||||
description string
|
||||
workdir string = '${os.home_dir()}/hero/var/bizmodel'
|
||||
sheet &spreadsheet.Sheet
|
||||
employees map[string]&Employee
|
||||
|
||||
@@ -13,12 +13,10 @@ import freeflowuniverse.herolib.core.texttools
|
||||
// - cogs_setup, cost of good for 1 item at setup
|
||||
// - cogs_setup_delay, how many months before setup cogs starts, after sales
|
||||
// - cogs_setup_perc: what is percentage of the cogs (can change over time) for setup e.g. 0:50%
|
||||
|
||||
// - cogs_monthly, cost of goods for the monthly per 1 item
|
||||
// - cogs_monthly_delay, how many months before monthly cogs starts, after sales
|
||||
// - cogs_monthly_perc: what is percentage of the cogs (can change over time) for monthly e.g. 0:5%,12:10%
|
||||
|
||||
// - nr_sold: how many do we sell per month (is in growth format e.g. 10:100,20:200)
|
||||
// - nr_sold: how many do we sell per month (is in growth format e.g. 10:100,20:200, default is 1)
|
||||
// - nr_months_recurring: how many months is recurring, if 0 then no recurring
|
||||
//
|
||||
fn (mut m BizModel) revenue_action(action Action) !Action {
|
||||
@@ -62,6 +60,10 @@ fn (mut m BizModel) revenue_action(action Action) !Action {
|
||||
extrapolate: false
|
||||
)!
|
||||
|
||||
println(action)
|
||||
println(revenue)
|
||||
exit(0)
|
||||
|
||||
mut revenue_setup := m.sheet.row_new(
|
||||
name: '${name}_revenue_setup'
|
||||
growth: action.params.get_default('revenue_setup', '0:0')!
|
||||
@@ -139,11 +141,6 @@ fn (mut m BizModel) revenue_action(action Action) !Action {
|
||||
aggregatetype: .avg
|
||||
)!
|
||||
|
||||
// if true{
|
||||
// println(cogs_setup_perc)
|
||||
// println(cogs_monthly_perc)
|
||||
// panic("sdsd")
|
||||
// }
|
||||
|
||||
mut nr_sold := m.sheet.row_new(
|
||||
name: '${name}_nr_sold'
|
||||
@@ -211,10 +208,6 @@ fn (mut m BizModel) revenue_action(action Action) !Action {
|
||||
nrmonths: nr_months_recurring
|
||||
aggregatetype: .max
|
||||
)!
|
||||
// if true{
|
||||
// println(nr_sold_recurring)
|
||||
// panic('sd')
|
||||
// }
|
||||
}
|
||||
|
||||
// cogs as percentage of revenue
|
||||
@@ -229,16 +222,17 @@ fn (mut m BizModel) revenue_action(action Action) !Action {
|
||||
name: '${name}_cogs_monthly_from_perc'
|
||||
)!
|
||||
|
||||
// if true{
|
||||
// println(revenue_setup_total)
|
||||
// println(cogs_setup_perc)
|
||||
// println(cogs_setup_from_perc)
|
||||
// println("montlhy")
|
||||
// println(revenue_monthly_total)
|
||||
// println(cogs_monthly_perc)
|
||||
// println(cogs_monthly_from_perc)
|
||||
// panic("sdsd")
|
||||
// }
|
||||
println(action)
|
||||
println(nr_sold)
|
||||
println(revenue)
|
||||
println(revenue_setup_total)
|
||||
println(revenue_monthly_total)
|
||||
println(cogs_setup_perc)
|
||||
println(cogs_setup_from_perc)
|
||||
println(cogs_monthly_perc)
|
||||
println(cogs_monthly_from_perc)
|
||||
exit(0)
|
||||
|
||||
|
||||
// mut cogs_from_perc:=cogs_perc.action(action:.multiply,rows:[revenue],name:"cogs_from_perc")!
|
||||
|
||||
|
||||
6
lib/biz/bizmodel/templates/department.md
Normal file
6
lib/biz/bizmodel/templates/department.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# @{department.name}
|
||||
|
||||
|
||||
`@{department.description}`
|
||||
|
||||
**Cost To The Company:**
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
`@{employee.cost}`
|
||||
|
||||
@{employee_cost_chart}
|
||||
|
||||
@if employee.cost_percent_revenue > 0.0
|
||||
|
||||
|
||||
27
lib/biz/bizmodel/templates/employee_old.md
Normal file
27
lib/biz/bizmodel/templates/employee_old.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# @{employee.name}
|
||||
|
||||
|
||||
`@{employee.description}`
|
||||
|
||||
> department: `@{employee.department}`
|
||||
|
||||
**Cost To The Company:**
|
||||
|
||||
`@{employee.cost}`
|
||||
|
||||
@if employee.cost_percent_revenue > 0.0
|
||||
|
||||
**Cost Percent Revenue:**
|
||||
|
||||
`@{employee.cost_percent_revenue}%`
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@if employee.nrpeople.len > 1
|
||||
|
||||
**Number of People in this group**
|
||||
|
||||
`@{employee.nrpeople}`
|
||||
|
||||
@end
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
| Name | Title | Nr People |
|
||||
|------|-------|-------|
|
||||
@for employee in model.employees.values().filter(it.department == dept.name)
|
||||
| @{employee_names[employee.name]} | @{employee.title} | @{employee.nrpeople} |
|
||||
@end
|
||||
|
||||
@for employee in model.employees.values()
|
||||
| @{employee.name} | @{employee.title} | @{employee.nrpeople} |
|
||||
@end
|
||||
49
lib/biz/bizmodel/templates/introduction.md
Normal file
49
lib/biz/bizmodel/templates/introduction.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# @{model.name}
|
||||
|
||||
@{model.description}
|
||||
|
||||
## FUNDING
|
||||
|
||||
@{model.sheet.wiki(includefilter:['funding']) or {panic(err)}}
|
||||
|
||||
## REVENUE vs COGS
|
||||
|
||||
@{model.sheet.wiki(includefilter:['rev']) or {panic(err)}}
|
||||
|
||||
#### Revenue Lines
|
||||
|
||||
@{model.sheet.wiki(title:'Revenue Total', includefilter:['revtotal']) or {panic(err)}}
|
||||
|
||||
#### COGS Lines
|
||||
|
||||
@{model.sheet.wiki(title:'COGS', includefilter:['cogstotal']) or {panic(err)}}
|
||||
|
||||
## HR
|
||||
|
||||
@{model.sheet.wiki(title:'HR Teams', includefilter:['hrnr']) or {panic(err)}}
|
||||
|
||||
@{model.sheet.wiki(title:'HR Costs', includefilter:['hrcost']) or {panic(err)}}
|
||||
|
||||
## Operational Costs
|
||||
|
||||
@{model.sheet.wiki(title:'COSTS', includefilter:['ocost']) or {panic(err)}}
|
||||
|
||||
## P&L Overview
|
||||
|
||||
<!-- period is in months, 3 means every quarter -->
|
||||
|
||||
@{model.sheet.wiki(title:'P&L Overview', includefilter:['pl']) or {panic(err)}}
|
||||
|
||||
@{model.sheet.bar_chart(rowname:'revenue_total', unit: .million, title:'A Title', title_sub:'Sub') or {panic(err)}.mdx()}
|
||||
|
||||
Unit is in Million USD.
|
||||
|
||||
@{model.sheet.line_chart(rowname:'revenue_total', unit: .million) or {panic(err)}.mdx()}
|
||||
|
||||
@{model.sheet.pie_chart(rowname:'revenue_total', unit: .million, size:'80%') or {panic(err)}.mdx()}
|
||||
|
||||
## Some Details
|
||||
|
||||
> show how we can do per month
|
||||
|
||||
@{model.sheet.wiki(includefilter:['pl'], period_type:.month) or {panic(err)}}
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
Product ${name1} has revenue events (one offs)
|
||||
|
||||
!!!spreadsheet.sheet_wiki
|
||||
@{model.sheet.wiki() or {''}}
|
||||
namefilter:'${name1}_revenue,${name1}_cogs,${name1}_cogs_perc,${name1}_maintenance_month_perc' sheetname:'bizmodel_tf9
|
||||
|
||||
- COGS = Cost of Goods Sold (is our cost to deliver the product/service)
|
||||
@@ -21,7 +21,7 @@ Product ${name1} has revenue events (one offs)
|
||||
|
||||
Product sold and its revenue/cost of goods
|
||||
|
||||
!!!spreadsheet.sheet_wiki
|
||||
@{model.sheet.wiki() or {''}}
|
||||
namefilter:'${name1}_nr_sold,${name1}_revenue_setup,${name1}_revenue_monthly,${name1}_cogs_setup,${name1}_cogs_setup_perc,${name1}_cogs_monthly,${name1}_cogs_monthly_perc'
|
||||
sheetname:'bizmodel_tf9
|
||||
|
||||
@@ -40,20 +40,19 @@ This product ${name1} is recurring, means customer pays per month ongoing, the p
|
||||
|
||||
#### the revenue/cogs calculated
|
||||
|
||||
|
||||
!!!spreadsheet.sheet_wiki
|
||||
@{model.sheet.wiki() or {''}}
|
||||
namefilter:'${name1}_nr_sold_recurring'
|
||||
sheetname:'bizmodel_tf9
|
||||
|
||||
This results in following revenues and cogs:
|
||||
|
||||
!!!spreadsheet.sheet_wiki
|
||||
@{model.sheet.wiki() or {''}}
|
||||
namefilter:'${name1}_revenue_setup_total,${name1}_revenue_monthly_total,${name1}_cogs_setup_total,${name1}_cogs_monthly_total,${name1}_cogs_setup_from_perc,${name1}_cogs_monthly_from_perc,${name1}_maintenance_month,
|
||||
${name1}_revenue_monthly_recurring,${name1}_cogs_monthly_recurring'
|
||||
sheetname:'bizmodel_tf9
|
||||
|
||||
resulting revenues:
|
||||
!!!spreadsheet.sheet_wiki
|
||||
@{model.sheet.wiki() or {''}}
|
||||
namefilter:'${name1}_revenue_total,${name1}_cogs_total'
|
||||
sheetname:'bizmodel_tf9
|
||||
|
||||
@@ -61,8 +60,3 @@ resulting revenues:
|
||||
!!!spreadsheet.graph_line_row rowname:'${name1}_cogs_total' unit:million sheetname:'bizmodel_tf9'
|
||||
|
||||
!!!spreadsheet.graph_line_row rowname:'${name1}_revenue_total' unit:million sheetname:'bizmodel_tf9'
|
||||
|
||||
|
||||
@end //product has_revenue
|
||||
|
||||
@end //loop
|
||||
68
lib/biz/bizmodel/templates/product_old.md
Normal file
68
lib/biz/bizmodel/templates/product_old.md
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
# @{product.title}
|
||||
|
||||
@{product.description}
|
||||
|
||||
#### parameters for the product
|
||||
|
||||
@if product.has_oneoffs
|
||||
|
||||
Product ${name1} has revenue events (one offs)
|
||||
|
||||
!!!spreadsheet.sheet_wiki
|
||||
namefilter:'${name1}_revenue,${name1}_cogs,${name1}_cogs_perc,${name1}_maintenance_month_perc' sheetname:'bizmodel_tf9
|
||||
|
||||
- COGS = Cost of Goods Sold (is our cost to deliver the product/service)
|
||||
- maintenance is fee we charge to the customer per month in relation to the revenue we charged e.g. 1% of a product which was sold for 1m EUR means we charge 1% of 1 m EUR per month.
|
||||
|
||||
@end //one offs
|
||||
|
||||
@if product.has_items
|
||||
|
||||
Product sold and its revenue/cost of goods
|
||||
|
||||
!!!spreadsheet.sheet_wiki
|
||||
namefilter:'${name1}_nr_sold,${name1}_revenue_setup,${name1}_revenue_monthly,${name1}_cogs_setup,${name1}_cogs_setup_perc,${name1}_cogs_monthly,${name1}_cogs_monthly_perc'
|
||||
sheetname:'bizmodel_tf9
|
||||
|
||||
- nr sold, is the nr sold per month of ${name1}
|
||||
- revenue setup is setup per item for ${name1}, this is the money we receive. Similar there is a revenue monthly.
|
||||
- cogs = Cost of Goods Sold (is our cost to deliver the product)
|
||||
- can we as a setup per item, or per month per item
|
||||
|
||||
@if product.nr_months_recurring>1
|
||||
|
||||
This product ${name1} is recurring, means customer pays per month ongoing, the period customer is paying for in months is: **${product.nr_months_recurring}**
|
||||
|
||||
@end //recurring
|
||||
|
||||
@end
|
||||
|
||||
#### the revenue/cogs calculated
|
||||
|
||||
|
||||
!!!spreadsheet.sheet_wiki
|
||||
namefilter:'${name1}_nr_sold_recurring'
|
||||
sheetname:'bizmodel_tf9
|
||||
|
||||
This results in following revenues and cogs:
|
||||
|
||||
!!!spreadsheet.sheet_wiki
|
||||
namefilter:'${name1}_revenue_setup_total,${name1}_revenue_monthly_total,${name1}_cogs_setup_total,${name1}_cogs_monthly_total,${name1}_cogs_setup_from_perc,${name1}_cogs_monthly_from_perc,${name1}_maintenance_month,
|
||||
${name1}_revenue_monthly_recurring,${name1}_cogs_monthly_recurring'
|
||||
sheetname:'bizmodel_tf9
|
||||
|
||||
resulting revenues:
|
||||
!!!spreadsheet.sheet_wiki
|
||||
namefilter:'${name1}_revenue_total,${name1}_cogs_total'
|
||||
sheetname:'bizmodel_tf9
|
||||
|
||||
|
||||
!!!spreadsheet.graph_line_row rowname:'${name1}_cogs_total' unit:million sheetname:'bizmodel_tf9'
|
||||
|
||||
!!!spreadsheet.graph_line_row rowname:'${name1}_revenue_total' unit:million sheetname:'bizmodel_tf9'
|
||||
|
||||
|
||||
@end //product has_revenue
|
||||
|
||||
@end //loop
|
||||
138
lib/biz/spreadsheet/charts.v
Normal file
138
lib/biz/spreadsheet/charts.v
Normal file
@@ -0,0 +1,138 @@
|
||||
module spreadsheet
|
||||
|
||||
import freeflowuniverse.herolib.data.markdownparser.elements
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.web.echarts
|
||||
|
||||
pub fn (s Sheet) title_chart(args RowGetArgs) echarts.EChartsOption {
|
||||
return echarts.EChartsOption{
|
||||
title: echarts.Title{
|
||||
text: args.title
|
||||
subtext: args.title_sub
|
||||
left: 'center'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (s Sheet) line_chart(args_ RowGetArgs) !echarts.EChartsOption {
|
||||
mut args := args_
|
||||
|
||||
rownames := s.rownames_get(args)!
|
||||
header := s.header_get_as_string(args.period_type)!
|
||||
mut series := []echarts.Series{}
|
||||
|
||||
for rowname in rownames {
|
||||
data := s.data_get_as_string(RowGetArgs{
|
||||
...args
|
||||
rowname: rowname
|
||||
})!
|
||||
series << echarts.Series{
|
||||
name: rowname
|
||||
type_: 'line'
|
||||
stack: 'Total'
|
||||
data: data.split(',')
|
||||
}
|
||||
}
|
||||
|
||||
return echarts.EChartsOption{
|
||||
title: s.title_chart(args).title
|
||||
tooltip: echarts.Tooltip{
|
||||
trigger: 'axis'
|
||||
}
|
||||
legend: echarts.Legend{
|
||||
data: rownames
|
||||
}
|
||||
grid: echarts.Grid{
|
||||
left: '3%'
|
||||
right: '4%'
|
||||
bottom: '3%'
|
||||
contain_label: true
|
||||
}
|
||||
toolbox: echarts.Toolbox{
|
||||
feature: echarts.ToolboxFeature{
|
||||
save_as_image: {}
|
||||
}
|
||||
}
|
||||
x_axis: echarts.XAxis{
|
||||
type_: 'category'
|
||||
boundary_gap: false
|
||||
data: header.split(',')
|
||||
}
|
||||
y_axis: echarts.YAxis{
|
||||
type_: 'value'
|
||||
}
|
||||
series: series
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (s Sheet) bar_chart(args_ RowGetArgs) !echarts.EChartsOption {
|
||||
mut args := args_
|
||||
args.rowname = s.rowname_get(args)!
|
||||
header := s.header_get_as_list(args.period_type)!
|
||||
data := s.data_get_as_list(args)!
|
||||
|
||||
return echarts.EChartsOption{
|
||||
title: s.title_chart(args).title
|
||||
x_axis: echarts.XAxis{
|
||||
type_: 'category'
|
||||
data: header
|
||||
}
|
||||
y_axis: echarts.YAxis{
|
||||
type_: 'value'
|
||||
}
|
||||
series: [
|
||||
echarts.Series{
|
||||
name: args.rowname
|
||||
type_: 'bar'
|
||||
data: data
|
||||
stack: ''
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (s Sheet) pie_chart(args_ RowGetArgs) !echarts.EChartsOption {
|
||||
mut args := args_
|
||||
args.rowname = s.rowname_get(args)!
|
||||
header := s.header_get_as_list(args.period_type)!
|
||||
data := s.data_get_as_list(args)!
|
||||
|
||||
if header.len != data.len {
|
||||
return error('Data and header lengths must match.')
|
||||
}
|
||||
|
||||
mut pie_data := []map[string]string{}
|
||||
for i, _ in data {
|
||||
pie_data << {
|
||||
'value': data[i].trim_space().trim("'")
|
||||
'name': header[i].trim_space().trim("'")
|
||||
}
|
||||
}
|
||||
|
||||
return echarts.EChartsOption{
|
||||
title: s.title_chart(args).title
|
||||
tooltip: echarts.Tooltip{
|
||||
trigger: 'item'
|
||||
}
|
||||
legend: echarts.Legend{
|
||||
data: header
|
||||
orient: 'vertical'
|
||||
left: 'left'
|
||||
}
|
||||
series: [
|
||||
echarts.Series{
|
||||
name: 'Data'
|
||||
type_: 'pie'
|
||||
radius: args.size.int()
|
||||
data: pie_data.map(it.str())
|
||||
emphasis: echarts.Emphasis{
|
||||
item_style: echarts.ItemStyle{
|
||||
shadow_blur: 10
|
||||
shadow_offset_x: 0
|
||||
shadow_color: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
77
lib/biz/spreadsheet/charts_test.v
Normal file
77
lib/biz/spreadsheet/charts_test.v
Normal file
@@ -0,0 +1,77 @@
|
||||
module spreadsheet
|
||||
|
||||
import freeflowuniverse.herolib.data.markdownparser.elements
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.web.echarts
|
||||
|
||||
fn test_title_chart() {
|
||||
mut s := sheet_new() or { panic(err) }
|
||||
mut nrnodes := s.row_new(
|
||||
name: 'nrnodes'
|
||||
growth: '5:100,55:1000'
|
||||
tags: 'cat:nodes color:yellow urgent'
|
||||
)!
|
||||
args := RowGetArgs{
|
||||
rowname: 'nrnodes'
|
||||
title: 'Main Title'
|
||||
title_sub: 'Subtitle'
|
||||
}
|
||||
title := s.title_chart(args).title
|
||||
assert title.text == 'Main Title'
|
||||
assert title.subtext == 'Subtitle'
|
||||
assert title.left == 'center'
|
||||
}
|
||||
|
||||
fn test_line_chart() {
|
||||
mut s := sheet_new() or { panic(err) }
|
||||
mut nrnodes := s.row_new(
|
||||
name: 'nrnodes'
|
||||
growth: '5:100,55:1000'
|
||||
tags: 'cat:nodes color:yellow urgent'
|
||||
)!
|
||||
args := RowGetArgs{
|
||||
rowname: 'nrnodes'
|
||||
title: 'Line Chart'
|
||||
period_type: .month
|
||||
}
|
||||
option := s.line_chart(args) or { panic(err) }
|
||||
assert option.title.text == 'Line Chart'
|
||||
assert option.tooltip.trigger == 'axis'
|
||||
assert option.grid.contain_label == true
|
||||
}
|
||||
|
||||
fn test_bar_chart() {
|
||||
mut s := sheet_new() or { panic(err) }
|
||||
mut nrnodes := s.row_new(
|
||||
name: 'nrnodes'
|
||||
growth: '5:100,55:1000'
|
||||
tags: 'cat:nodes color:yellow urgent'
|
||||
)!
|
||||
args := RowGetArgs{
|
||||
rowname: 'nrnodes'
|
||||
title: 'Bar Chart'
|
||||
period_type: .year
|
||||
}
|
||||
option := s.bar_chart(args) or { panic(err) }
|
||||
assert option.title.text == 'Bar Chart'
|
||||
assert option.x_axis.type_ == 'category'
|
||||
assert option.y_axis.type_ == 'value'
|
||||
}
|
||||
|
||||
fn test_pie_chart() {
|
||||
mut s := sheet_new() or { panic(err) }
|
||||
mut nrnodes := s.row_new(
|
||||
name: 'nrnodes'
|
||||
growth: '5:100,55:1000'
|
||||
tags: 'cat:nodes color:yellow urgent'
|
||||
)!
|
||||
args := RowGetArgs{
|
||||
rowname: 'nrnodes'
|
||||
title: 'Pie Chart'
|
||||
period_type: .quarter
|
||||
}
|
||||
option := s.pie_chart(args) or { panic(err) }
|
||||
assert option.title.text == 'Pie Chart'
|
||||
assert option.tooltip.trigger == 'item'
|
||||
assert option.legend.data.len > 0
|
||||
}
|
||||
@@ -92,7 +92,7 @@ pub fn playmacro(action Action) !string {
|
||||
content = sh.wiki(args) or { panic(err) }
|
||||
}
|
||||
'graph_title_row' {
|
||||
content = sh.wiki_title_chart(args)
|
||||
content = sh.wiki_title_chart(args)!
|
||||
}
|
||||
'graph_line_row' {
|
||||
content = sh.wiki_line_chart(args)!
|
||||
|
||||
@@ -202,7 +202,7 @@ pub fn (s Sheet) tosmaller(args_ ToYearQuarterArgs) !&Sheet {
|
||||
// tagsfilter []string
|
||||
// tags if set will see that there is at least one corresponding tag per row
|
||||
// rawsfilter is list of names of rows which will be included
|
||||
pub fn (mut s Sheet) toyear(args ToYearQuarterArgs) !&Sheet {
|
||||
pub fn (s Sheet) toyear(args ToYearQuarterArgs) !&Sheet {
|
||||
mut args2 := args
|
||||
args2.period_months = 12
|
||||
return s.tosmaller(args2)
|
||||
@@ -215,7 +215,7 @@ pub fn (mut s Sheet) toyear(args ToYearQuarterArgs) !&Sheet {
|
||||
// tagsfilter []string
|
||||
// tags if set will see that there is at least one corresponding tag per row
|
||||
// rawsfilter is list of names of rows which will be included
|
||||
pub fn (mut s Sheet) toquarter(args ToYearQuarterArgs) !&Sheet {
|
||||
pub fn (s Sheet) toquarter(args ToYearQuarterArgs) !&Sheet {
|
||||
mut args2 := args
|
||||
args2.period_months = 3
|
||||
return s.tosmaller(args2)
|
||||
@@ -260,7 +260,9 @@ pub fn (mut s Sheet) json() string {
|
||||
|
||||
// find row, report error if not found
|
||||
pub fn (s Sheet) row_get(name string) !&Row {
|
||||
row := s.rows[name] or { return error('could not find row with name: ${name}, available rows: ${s.rows.keys()}') }
|
||||
row := s.rows[name] or {
|
||||
return error('could not find row with name: ${name}, available rows: ${s.rows.keys()}')
|
||||
}
|
||||
return row
|
||||
}
|
||||
|
||||
|
||||
49
lib/biz/spreadsheet/sheet_export.v
Normal file
49
lib/biz/spreadsheet/sheet_export.v
Normal file
@@ -0,0 +1,49 @@
|
||||
module spreadsheet
|
||||
import os
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
|
||||
@[params]
|
||||
pub struct ExportArgs{
|
||||
pub mut:
|
||||
path string
|
||||
}
|
||||
|
||||
fn format_number(val f64) string {
|
||||
if val < 0.001 && val > -0.001 {
|
||||
return '0'
|
||||
}
|
||||
if val >= 1000.0 || val <= -1000.0 {
|
||||
return int(val).str()
|
||||
}
|
||||
// Format small numbers with 3 decimal places to handle floating point precision
|
||||
return '${val:.3f}'
|
||||
}
|
||||
|
||||
pub fn (mut s Sheet) export(args ExportArgs) !string {
|
||||
mut result := []string{}
|
||||
|
||||
// Add headers
|
||||
mut header_row := ['Name', 'Description', 'AggregateType', 'Tags', 'Subgroup']
|
||||
header_row << s.header()!
|
||||
result << header_row.join('|')
|
||||
|
||||
// Add rows
|
||||
for _, row in s.rows {
|
||||
mut row_data := [row.name, row.description, row.aggregatetype.str(), row.tags, row.subgroup]
|
||||
for cell in row.cells {
|
||||
if cell.empty {
|
||||
row_data << '-'
|
||||
} else {
|
||||
row_data << format_number(cell.val)
|
||||
}
|
||||
}
|
||||
result << row_data.join('|')
|
||||
}
|
||||
|
||||
if args.path.len>0{
|
||||
mut p:=pathlib.get_file(path:args.path.replace("~",os.home_dir()), create:true, delete:true)!
|
||||
p.write(result.join('\n'))!
|
||||
}
|
||||
|
||||
return result.join('\n')
|
||||
}
|
||||
@@ -71,19 +71,19 @@ pub fn (s Sheet) rowname_get(args RowGetArgs) !string {
|
||||
}
|
||||
|
||||
// return e.g. "'Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6'" if year, is for header
|
||||
pub fn (mut s Sheet) header_get_as_list(period_type PeriodType) ![]string {
|
||||
pub fn (s Sheet) header_get_as_list(period_type PeriodType) ![]string {
|
||||
str := s.header_get_as_string(period_type)!
|
||||
return str.split(',')
|
||||
}
|
||||
|
||||
// return e.g. "'Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6'" if year, is for header
|
||||
pub fn (mut s Sheet) data_get_as_list(args RowGetArgs) ![]string {
|
||||
pub fn (s Sheet) data_get_as_list(args RowGetArgs) ![]string {
|
||||
str := s.data_get_as_string(args)!
|
||||
return str.split(',')
|
||||
}
|
||||
|
||||
// return e.g. "'Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6'" if year, is for header
|
||||
pub fn (mut s Sheet) header_get_as_string(period_type PeriodType) !string {
|
||||
pub fn (s Sheet) header_get_as_string(period_type PeriodType) !string {
|
||||
err_pre := "Can't get header for sheet:${s.name}\n"
|
||||
nryears := int(s.nrcol / 12)
|
||||
mut out := ''
|
||||
@@ -112,7 +112,7 @@ pub fn (mut s Sheet) header_get_as_string(period_type PeriodType) !string {
|
||||
}
|
||||
|
||||
// return the values
|
||||
pub fn (mut s Sheet) data_get_as_string(args RowGetArgs) !string {
|
||||
pub fn (s Sheet) data_get_as_string(args RowGetArgs) !string {
|
||||
if args.rowname == '' {
|
||||
return error('rowname needs to be specified')
|
||||
}
|
||||
@@ -166,7 +166,7 @@ pub fn (mut s Sheet) data_get_as_string(args RowGetArgs) !string {
|
||||
}
|
||||
|
||||
// use RowGetArgs to get to smaller version of sheet
|
||||
pub fn (mut s Sheet) filter(args RowGetArgs) !&Sheet {
|
||||
pub fn (s Sheet) filter(args RowGetArgs) !&Sheet {
|
||||
period_months := match args.period_type {
|
||||
.year { 12 }
|
||||
.month { 1 }
|
||||
|
||||
@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
// format a sheet properly in wiki format
|
||||
|
||||
pub fn (mut s Sheet) wiki(args_ RowGetArgs) !string {
|
||||
pub fn (s Sheet) wiki(args_ RowGetArgs) !string {
|
||||
mut args := args_
|
||||
|
||||
_ := match args.period_type {
|
||||
|
||||
@@ -3,22 +3,12 @@ module spreadsheet
|
||||
import freeflowuniverse.herolib.data.markdownparser.elements
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
pub fn (mut s Sheet) wiki_title_chart(args RowGetArgs) string {
|
||||
if args.title.len > 0 {
|
||||
titletxt := "
|
||||
title: {
|
||||
text: '${args.title}',
|
||||
subtext: '${args.title_sub}',
|
||||
left: 'center'
|
||||
},
|
||||
"
|
||||
return titletxt
|
||||
}
|
||||
return ''
|
||||
pub fn (s Sheet) wiki_title_chart(args RowGetArgs) !string {
|
||||
return s.title_chart(args).markdown()
|
||||
}
|
||||
|
||||
pub fn (mut s_ Sheet) wiki_row_overview(args RowGetArgs) !string {
|
||||
mut s := s_.filter(args)!
|
||||
pub fn (s_ Sheet) wiki_row_overview(args RowGetArgs) !string {
|
||||
s := s_.filter(args)!
|
||||
|
||||
rows_values := s.rows.values().map([it.name, it.description, it.tags])
|
||||
mut rows := []elements.Row{}
|
||||
@@ -43,146 +33,18 @@ pub fn (mut s_ Sheet) wiki_row_overview(args RowGetArgs) !string {
|
||||
|
||||
// produce a nice looking bar chart see
|
||||
// https://echarts.apache.org/examples/en/editor.html?c=line-stack
|
||||
pub fn (mut s Sheet) wiki_line_chart(args_ RowGetArgs) !string {
|
||||
mut args := args_
|
||||
|
||||
rownames := s.rownames_get(args)!
|
||||
header := s.header_get_as_string(args.period_type)!
|
||||
mut series_lines := []string{}
|
||||
|
||||
for rowname in rownames {
|
||||
data := s.data_get_as_string(RowGetArgs{
|
||||
...args
|
||||
rowname: rowname
|
||||
})!
|
||||
series_lines << '{
|
||||
name: \'${rowname}\',
|
||||
type: \'line\',
|
||||
stack: \'Total\',
|
||||
data: [${data}]
|
||||
}'
|
||||
}
|
||||
|
||||
// TODO: need to implement the multiple results which can come back from the args, can be more than 1
|
||||
|
||||
// header := s.header_get_as_string(args.period_type)!
|
||||
// data := s.data_get_as_string(args)!
|
||||
// console.print_debug('HERE! ${header}')
|
||||
// console.print_debug('HERE!! ${data}')
|
||||
|
||||
template := "
|
||||
${s.wiki_title_chart(args)}
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: ${rownames}
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true
|
||||
},
|
||||
toolbox: {
|
||||
feature: {
|
||||
saveAsImage: {}
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: [${header}]
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [${series_lines.join(',')}]
|
||||
"
|
||||
out := remove_empty_line('```echarts\n{${template}\n};\n```\n')
|
||||
return out
|
||||
pub fn (s Sheet) wiki_line_chart(args_ RowGetArgs) !string {
|
||||
return s.line_chart(args_)!.markdown()
|
||||
}
|
||||
|
||||
// produce a nice looking bar chart see
|
||||
// https://echarts.apache.org/examples/en/index.html#chart-type-bar
|
||||
pub fn (mut s Sheet) wiki_bar_chart(args_ RowGetArgs) !string {
|
||||
mut args := args_
|
||||
args.rowname = s.rowname_get(args)!
|
||||
header := s.header_get_as_string(args.period_type)!
|
||||
data := s.data_get_as_string(args)!
|
||||
bar1 := "
|
||||
${s.wiki_title_chart(args)}
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: [${header}]
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
data: [${data}],
|
||||
type: 'bar',
|
||||
showBackground: true,
|
||||
backgroundStyle: {
|
||||
color: 'rgba(180, 180, 180, 0.2)'
|
||||
}
|
||||
}
|
||||
]
|
||||
"
|
||||
out := remove_empty_line('```echarts\n{${bar1}\n};\n```\n')
|
||||
return out
|
||||
pub fn (s Sheet) wiki_bar_chart(args_ RowGetArgs) !string {
|
||||
return s.bar_chart(args_)!.markdown()
|
||||
}
|
||||
|
||||
// produce a nice looking bar chart see
|
||||
// https://echarts.apache.org/examples/en/index.html#chart-type-bar
|
||||
pub fn (mut s Sheet) wiki_pie_chart(args_ RowGetArgs) !string {
|
||||
mut args := args_
|
||||
args.rowname = s.rowname_get(args)!
|
||||
header := s.header_get_as_list(args.period_type)!
|
||||
data := s.data_get_as_list(args)!
|
||||
|
||||
mut radius := ''
|
||||
if args.size.len > 0 {
|
||||
radius = "radius: '${args.size}',"
|
||||
}
|
||||
|
||||
if header.len != data.len {
|
||||
return error('data and header lengths must match.\n${header}\n${data}')
|
||||
}
|
||||
|
||||
mut data_lines := []string{}
|
||||
for i, _ in data {
|
||||
data_lines << '{ value: ${data[i]}, name: ${header[i]}}'
|
||||
}
|
||||
data_str := '[${data_lines.join(',')}]'
|
||||
|
||||
bar1 := "
|
||||
${s.wiki_title_chart(args)}
|
||||
tooltip: {
|
||||
trigger: 'item'
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: 'Access From',
|
||||
type: 'pie',
|
||||
${radius}
|
||||
data: ${data_str},
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
"
|
||||
out := remove_empty_line('```echarts\n{${bar1}\n};\n```\n')
|
||||
return out
|
||||
pub fn (s Sheet) wiki_pie_chart(args_ RowGetArgs) !string {
|
||||
return s.pie_chart(args_)!.markdown()
|
||||
}
|
||||
|
||||
@@ -9,10 +9,18 @@ pub mut:
|
||||
reset bool // regenerate all, dangerous !!!
|
||||
interactive bool // if we want to ask
|
||||
path string
|
||||
playonly bool
|
||||
model ?GenModel
|
||||
cat ?Cat
|
||||
}
|
||||
|
||||
pub struct PlayArgs {
|
||||
pub mut:
|
||||
name string
|
||||
modulepath string
|
||||
}
|
||||
|
||||
|
||||
// the default to start with
|
||||
//
|
||||
// reset bool // regenerate all, dangerous !!!
|
||||
@@ -20,7 +28,9 @@ pub mut:
|
||||
// path string
|
||||
// model ?GenModel
|
||||
// cat ?Cat
|
||||
pub fn do(args_ GenerateArgs) ! {
|
||||
//
|
||||
// will return the module path where we need to execute a play command as well as the name of
|
||||
pub fn do(args_ GenerateArgs) ! PlayArgs{
|
||||
mut args := args_
|
||||
|
||||
console.print_header('Generate code for path: ${args.path} (reset:${args.reset}, interactive:${args.interactive})')
|
||||
@@ -51,9 +61,9 @@ pub fn do(args_ GenerateArgs) ! {
|
||||
}
|
||||
}
|
||||
|
||||
if model.cat == .unknown {
|
||||
model.cat = args.cat or { return error('cat needs to be specified for generator.') }
|
||||
}
|
||||
// if model.cat == .unknown {
|
||||
// model.cat = args.cat or { return error('cat needs to be specified for generator.') }
|
||||
// }
|
||||
|
||||
if args.interactive {
|
||||
ask(args.path)!
|
||||
@@ -64,5 +74,15 @@ pub fn do(args_ GenerateArgs) ! {
|
||||
|
||||
console.print_debug(args)
|
||||
|
||||
generate(args)!
|
||||
//only generate if playonly is false and there is a classname
|
||||
if !args.playonly && model.classname.len>0{
|
||||
generate(args)!
|
||||
}
|
||||
|
||||
|
||||
return PlayArgs{
|
||||
name: model.play_name
|
||||
modulepath: model.module_path
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,8 @@ pub mut:
|
||||
build bool = true
|
||||
hasconfig bool = true
|
||||
cat Cat // dont' set default
|
||||
play_name string // e.g. docusaurus is what we look for
|
||||
module_path string // e.g.freeflowuniverse.herolib.web.docusaurus
|
||||
}
|
||||
|
||||
pub enum Cat {
|
||||
@@ -37,7 +39,6 @@ pub fn gen_model_set(args GenerateArgs) ! {
|
||||
.installer { $tmpl('templates/heroscript_installer') }
|
||||
else { return error('Invalid category: ${model.cat}') }
|
||||
}
|
||||
|
||||
pathlib.template_write(heroscript_templ, '${args.path}/.heroscript', true)!
|
||||
}
|
||||
|
||||
@@ -108,8 +109,30 @@ pub fn gen_model_get(path string, create bool) !GenModel {
|
||||
model.name = os.base(path).to_lower()
|
||||
}
|
||||
|
||||
console.print_debug('Code generator get: ${model}')
|
||||
model.play_name = model.name
|
||||
|
||||
pathsub:=path.replace('${os.home_dir()}/code/github/','')
|
||||
model.module_path = pathsub.replace("/",".").replace(".lib.",".")
|
||||
|
||||
// !!hero_code.play
|
||||
// name:'docusaurus'
|
||||
|
||||
mut play_actions := plbook.find(filter: 'hero_code.play')!
|
||||
if play_actions.len>1{
|
||||
return error("should have max 1 hero_code.play action in ${config_path.path}")
|
||||
}
|
||||
if play_actions.len==1{
|
||||
mut p := play_actions[0].params
|
||||
model.play_name = p.get_default('name',model.name)!
|
||||
}
|
||||
|
||||
if model.module_path.contains("docusaurus"){
|
||||
println(model)
|
||||
println("4567ujhjk")
|
||||
exit(0)
|
||||
}
|
||||
|
||||
|
||||
return model
|
||||
// return GenModel{}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user