This commit is contained in:
2024-12-25 10:18:31 +01:00
parent 37d2501067
commit a7e714058f
37 changed files with 33 additions and 344 deletions

View File

@@ -1,6 +1,6 @@
module meilisearch module meilisearch
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import x.json2 import x.json2
import json import json

View File

@@ -1,6 +1,6 @@
module meilisearch module meilisearch
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import x.json2 import x.json2
import json import json

View File

@@ -1,7 +1,7 @@
module meilisearch module meilisearch
import freeflowuniverse.herolib.data.paramsparser import freeflowuniverse.herolib.data.paramsparser
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import os import os
pub const version = '1.0.0' pub const version = '1.0.0'

View File

@@ -1,7 +1,7 @@
module openai module openai
import json import json
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import os import os
import net.http import net.http

View File

@@ -3,7 +3,7 @@ module openai
import freeflowuniverse.herolib.core.base import freeflowuniverse.herolib.core.base
import freeflowuniverse.herolib.core.playbook import freeflowuniverse.herolib.core.playbook
import freeflowuniverse.herolib.ui as gui import freeflowuniverse.herolib.ui as gui
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
// import freeflowuniverse.herolib.ui.console // import freeflowuniverse.herolib.ui.console

View File

@@ -1,7 +1,7 @@
module openai module openai
import json import json
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import os import os
import net.http import net.http

View File

@@ -3,7 +3,7 @@ module openai
import json import json
import net.http import net.http
import os import os
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
const image_mine_type = 'image/png' const image_mine_type = 'image/png'

View File

@@ -13,7 +13,7 @@ The HTTPConnection module provides a robust HTTP client implementation with supp
## Basic Usage ## Basic Usage
```v ```v
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
// Create a new HTTP connection // Create a new HTTP connection
mut conn := HTTPConnection{ mut conn := HTTPConnection{

View File

@@ -1,7 +1,7 @@
module currency module currency
import json import json
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
struct ResponseBody { struct ResponseBody {
motd string motd string

View File

@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import freeflowuniverse.herolib.crypt.secrets import freeflowuniverse.herolib.crypt.secrets
import freeflowuniverse.herolib.sysadmin.startupmanager import freeflowuniverse.herolib.sysadmin.startupmanager
import freeflowuniverse.herolib.clients.zdb import freeflowuniverse.herolib.clients.zdb

View File

@@ -1,128 +0,0 @@
module herolib
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.installers.base
import freeflowuniverse.herolib.installers.lang.vlang
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.develop.gittools
import os
// install herolib will return true if it was already installed
@[params]
pub struct InstallArgs {
pub mut:
git_pull bool
git_reset bool
reset bool // means reinstall
}
pub fn install(args InstallArgs) ! {
// install herolib if it was already done will return true
console.print_header('install herolib (reset: ${args.reset})')
// osal.package_refresh()!
if args.reset {
osal.done_reset()!
}
base.install(develop: true)!
vlang.install(reset: args.reset)!
vlang.v_analyzer_install(reset: args.reset)!
mut gs := gittools.get()!
gs.config.light = true // means we clone depth 1
mut repo := gs.get_repo(
pull: args.git_pull
reset: args.git_reset
url: 'https://github.com/freeflowuniverse/herolib/tree/development/herolib'
)!
mut repo2 := gs.get_repo(
pull: args.git_pull
reset: args.git_reset
url: 'https://github.com/freeflowuniverse/webcomponents/tree/main/webcomponents'
)!
mut path1 := repo.get_path()!
mut path2 := repo2.get_path()!
mut path1p := pathlib.get_dir(path: path1, create: false)!
mut path2p := pathlib.get_dir(path: path2, create: false)!
path1p.link('${os.home_dir()}/.vmodules/freeflowuniverse/herolib', true)!
path2p.link('${os.home_dir()}/.vmodules/freeflowuniverse/webcomponents', true)!
// hero_compile()!
osal.done_set('install_herolib', 'OK')!
return
}
// check if herolibs installed and hero, if not do so
pub fn check() ! {
if osal.done_exists('install_herolib') {
return
}
install()!
}
// remove hero, hero, ...
pub fn uninstall() ! {
console.print_debug('uninstall hero & herolib')
cmd := '
rm -rf ${os.home_dir()}/hero
rm -rf ${os.home_dir()}/_code
rm -f /usr/local/bin/hero
rm -f /tmp/hero
rm -f /tmp/install*
rm -f /tmp/build_hero*
rm -rf /tmp/execscripts
'
osal.execute_stdout(cmd) or { return error('Cannot uninstall herolib/hero.\n${err}') }
}
pub fn hero_install(args InstallArgs) ! {
if args.reset == false && osal.done_exists('install_hero') {
console.print_debug('hero already installed')
return
}
console.print_header('install hero')
base.install()!
cmd := '
cd /tmp
export TERM=xterm
curl https://raw.githubusercontent.com/freeflowuniverse/herolib/development/scripts/install_hero.sh > /tmp/hero_install.sh
bash /tmp/hero_install.sh
'
osal.execute_stdout(cmd) or { return error('Cannot install hero.\n${err}') }
osal.done_set('install_hero', 'OK')!
return
}
pub fn hero_compile(args InstallArgs) ! {
if args.reset == false && osal.done_exists('compile_hero') {
console.print_debug('hero already compiled')
return
}
console.print_header('compile hero')
home_dir := os.home_dir()
cmd_hero := texttools.template_replace($tmpl('templates/hero.sh'))
osal.exec(cmd: cmd_hero, stdout: false)!
osal.execute_stdout(cmd_hero) or { return error('Cannot compile hero.\n${err}') }
osal.done_set('compile_hero', 'OK')!
return
}
// pub fn update() ! {
// console.print_header('package_install update herolib')
// if !(i.state == .reset) && osal.done_exists('install_herotools') {
// console.print_debug(' package_install was already done')
// return
// }
// osal.execute_silent('cd /tmp && export TERM=xterm && source /root/env.sh && ct_upgrade') or {
// return error('Cannot update hero tools.\n${err}')
// }
// osal.done_set('update_herotools', 'OK')!
// }

View File

@@ -1,21 +0,0 @@
export PATH=${home_dir}/hero/bin:??PATH
export TERM=xterm
cd ${home_dir}/code/github/freeflowuniverse/herolib/cli/hero
PRF="${home_dir}/.profile"
[ -f "??PRF" ] && source "??PRF"
if [[ "??OSTYPE" == "linux-gnu"* ]]; then
#v -enable-globals -w -cflags -static -cc gcc hero.v
v -enable-globals -w -n hero.v
export HEROPATH='/usr/local/bin/hero'
elif [[ "??OSTYPE" == "darwin"* ]]; then
v -enable-globals -w -n hero.v
export HEROPATH=${home_dir}/hero/bin/hero
fi
chmod +x hero
cp hero ??HEROPATH
rm hero

View File

@@ -1 +0,0 @@
https://github.com/v-analyzer/v-analyzer

View File

@@ -1,97 +0,0 @@
module vlang
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
import os
// import freeflowuniverse.herolib.sysadmin.downloader
pub fn v_analyzer_install(args_ InstallArgs) ! {
mut args := args_
console.print_header('install v-analyzer (reset: ${args.reset})')
version := '0.0.4'
_ := osal.platform()
res := os.execute('${osal.profile_path_source_and()} v-analyzer version')
if res.exit_code == 0 {
r := res.output.split_into_lines().filter(it.trim_space().starts_with('v-analyzer'))
if r.len != 1 {
return error("couldn't parse v-analyzer version.\n${res.output}")
}
mut myversion := r[0].all_after_first('version').trim_space()
if texttools.version(version) > texttools.version(myversion) {
args.reset = true
}
} else {
args.reset = true
}
if args.reset == false {
console.print_debug('v-analyzer already installed')
return
}
install()!
if args.reset {
console.print_header('install v-analyzer')
cmd := '
export TERM=xterm
mkdir -p ${os.home_dir()}/_code
cd ${os.home_dir()}/_code
rm -rf ${os.home_dir()}/_code/v-analyzer
git clone --filter=blob:none --recursive --shallow-submodules https://github.com/vlang/v-analyzer
cd v-analyzer
v build.vsh debug
'
osal.execute_stdout(cmd) or { return error('Cannot install hero.\n${err}') }
osal.cmd_add(
cmdname: 'v-analyzer'
source: '${os.home_dir()}/_code/v-analyzer/bin/v-analyzer'
)!
}
// if pl == .ubuntu {
// }else{
// mut url := ''
// if osal.is_linux_intel() {
// url = 'https://github.com/vlang/v-analyzer/releases/download/nightly/v-analyzer-linux-x86_64.zip'
// } else if osal.is_osx_arm() {
// url = 'https://github.com/vlang/v-analyzer/releases/download/nightly/v-analyzer-darwin-arm64.zip'
// } else if osal.is_osx_intel() {
// url = 'https://github.com/vlang/v-analyzer/releases/download/nightly/v-analyzer-darwin-x86_64.zip'
// } else {
// return error('unsported platform for installing v-analyzer')
// }
// mut dest := osal.download(
// url: url
// minsize_kb: 1000
// expand_dir: '/tmp/v-analyzer'
// )!
// mut binpath := dest.file_get('v-analyzer')!
// osal.cmd_add(
// cmdname: 'v-analyzer'
// source: binpath.path
// )!
// }
// if args.reset == false && osal.done_exists('install_v_analyzer') {
// console.print_debug(' v analyzer already installed')
// return
// }
// console.print_header('install v analyzer')
// cmd := '
// cd /tmp
// export TERM=xterm
// source ~/.profile
// rm -f install.sh
// curl -fksSL https://raw.githubusercontent.com/v-lang/v-analyzer/master/install.vsh > install.vsh
// v run install.vsh --no-interaction
// '
// osal.execute_stdout(cmd) or { return error('Cannot install hero.\n${err}') }
osal.done_set('install_v_analyzer', 'OK')!
return
}

View File

@@ -1,72 +0,0 @@
module vlang
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.ui.console
import os
import freeflowuniverse.herolib.installers.base
import freeflowuniverse.herolib.develop.gittools
// import freeflowuniverse.herolib.sysadmin.downloader
pub fn install(args_ InstallArgs) ! {
mut args := args_
version := '0.4.8'
console.print_header('install vlang (reset: ${args.reset})')
res := os.execute('${osal.profile_path_source_and()} v --version')
if res.exit_code == 0 {
r := res.output.split_into_lines().filter(it.trim_space().starts_with('V'))
if r.len != 1 {
return error("couldn't parse v version.\n${res.output}")
}
myversion := r[0].all_after_first('V ').all_before(' ').trim_space()
console.print_debug("V version: '${myversion}'")
if texttools.version(version) > texttools.version(myversion) {
// println(texttools.version(version))
// println(texttools.version(myversion))
// if true{panic("s")}
args.reset = true
}
} else {
args.reset = true
}
// install vlang if it was already done will return true
if args.reset == false {
return
}
base.develop()!
mut gs := gittools.get(coderoot: '${os.home_dir()}/_code')!
mut repo := gs.get_repo(
pull: true
reset: true
url: 'https://github.com/vlang/v/tree/master'
)!
mut path1 := repo.get_path()!
mut extra := ''
if osal.is_linux() {
extra = './v symlink'
} else {
extra = 'cp v ${os.home_dir()}/bin/'
}
cmd := '
cd ${path1}
make
${extra}
'
console.print_header('compile')
osal.exec(cmd: cmd, stdout: true)!
console.print_header('compile done')
osal.done_set('install_vlang', 'OK')!
return
}
@[params]
pub struct InstallArgs {
pub mut:
reset bool
}

View File

@@ -5,7 +5,7 @@ import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.sysadmin.startupmanager import freeflowuniverse.herolib.sysadmin.startupmanager
import freeflowuniverse.herolib.crypt.secrets import freeflowuniverse.herolib.crypt.secrets
// import freeflowuniverse.herolib.core.texttools // import freeflowuniverse.herolib.core.texttools
// import freeflowuniverse.herolib.clients.httpconnection // import freeflowuniverse.herolib.core.httpconnection
import os import os
import time import time

View File

@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import freeflowuniverse.herolib.sysadmin.startupmanager import freeflowuniverse.herolib.sysadmin.startupmanager
import os import os
import time import time

View File

@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import freeflowuniverse.herolib.sysadmin.startupmanager import freeflowuniverse.herolib.sysadmin.startupmanager
import os import os
import time import time

View File

@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import freeflowuniverse.herolib.sysadmin.startupmanager import freeflowuniverse.herolib.sysadmin.startupmanager
import os import os
import time import time

View File

@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import freeflowuniverse.herolib.sysadmin.startupmanager import freeflowuniverse.herolib.sysadmin.startupmanager
import os import os
import time import time

View File

@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import freeflowuniverse.herolib.sysadmin.startupmanager import freeflowuniverse.herolib.sysadmin.startupmanager
import os import os
import time import time

View File

@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import freeflowuniverse.herolib.sysadmin.startupmanager import freeflowuniverse.herolib.sysadmin.startupmanager
import os import os
import time import time

View File

@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import freeflowuniverse.herolib.sysadmin.startupmanager import freeflowuniverse.herolib.sysadmin.startupmanager
import os import os
import time import time

View File

@@ -3,7 +3,7 @@ module rclone
import freeflowuniverse.herolib.osal import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.clients.httpconnection import freeflowuniverse.herolib.core.httpconnection
import os import os
// checks if a certain version or above is installed // checks if a certain version or above is installed

View File

@@ -97,6 +97,10 @@ lib/data
" "
tests_ignore := " tests_ignore := "
"
tests_error := "
net_test.v net_test.v
systemd_process_test.v systemd_process_test.v
rpc_test.v rpc_test.v
@@ -107,11 +111,13 @@ tmux_test.v
startupmanager_test.v startupmanager_test.v
" "
// Split tests into array and remove empty lines // Split tests into array and remove empty lines
test_files := tests.split('\n').filter(it.trim_space() != '') test_files := tests.split('\n').filter(it.trim_space() != '')
test_files_ignore := tests_ignore.split('\n').filter(it.trim_space() != '') test_files_ignore := tests_ignore.split('\n').filter(it.trim_space() != '')
test_files_error := tests_error.split('\n').filter(it.trim_space() != '')
mut ignored_tests := []string{} mut tests_in_error := []string{}
// Check if Redis is available // Check if Redis is available
@@ -142,7 +148,7 @@ for test in test_files {
base_file := os.base(file) base_file := os.base(file)
if base_file in test_files_ignore { if base_file in test_files_ignore {
println('Ignoring test: ${file}') println('Ignoring test: ${file}')
ignored_tests << file tests_in_error << file
continue continue
} }
dotest(file, redis_available)! dotest(file, redis_available)!
@@ -150,20 +156,22 @@ for test in test_files {
} else if os.is_file(full_path) { } else if os.is_file(full_path) {
// If single file, run test if not in ignore list // If single file, run test if not in ignore list
base_file := os.base(full_path) base_file := os.base(full_path)
if base_file !in test_files_ignore { if base_file !in test_files_ignore && base_file !in test_files_error{
dotest(full_path, redis_available)! dotest(full_path, redis_available)!
} else { } else {
println('Ignoring test: ${full_path}') println('Ignoring test: ${full_path}')
ignored_tests << full_path if base_file !in test_files_ignore {
tests_in_error << full_path
}
} }
} }
} }
println('All (non skipped) tests ok') println('All (non skipped) tests ok')
if ignored_tests.len > 0 { if tests_in_error.len > 0 {
println('\n\033[31mTests that need to be fixed (not executed):') println('\n\033[31mTests that need to be fixed (not executed):')
for test in ignored_tests { for test in tests_in_error {
println(' ${test}') println(' ${test}')
} }
println('\033[0m') println('\033[0m')