docusaurus

This commit is contained in:
2025-02-02 19:24:10 +03:00
parent cfa9f877b3
commit 0fd5062408
29 changed files with 1290 additions and 78 deletions

View File

@@ -0,0 +1,13 @@
!!hero_code.generate_installer
name:'bun'
classname:'Bun'
singleton:1
templates:0
default:1
title:''
supported_platforms:''
reset:0
startupmanager:0
hasconfig:0
build:0

View File

@@ -0,0 +1,72 @@
module bun
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.installers.ulist
import os
//////////////////// following actions are not specific to instance of the object
// checks if a certain version or above is installed
fn installed() !bool {
res := os.execute('${osal.profile_path_source_and()!} bun -version')
if res.exit_code != 0 {
return false
}
r := res.output.split_into_lines().filter(it.trim_space().len > 0)
if r.len != 1 {
return error("couldn't parse bun version.\n${res.output}")
}
// println(" ${texttools.version(version)} <= ${texttools.version(r[0])}")
if texttools.version(version) <= texttools.version(r[0]) {
return true
}
return false
}
//get the Upload List of the files
fn ulist_get() !ulist.UList {
//optionally build a UList which is all paths which are result of building, is then used e.g. in upload
return ulist.UList{}
}
//uploads to S3 server if configured
fn upload() ! {
// installers.upload(
// cmdname: 'bun'
// source: '${gitpath}/target/x86_64-unknown-linux-musl/release/bun'
// )!
}
fn install() ! {
console.print_header('install bun')
osal.exec(cmd: 'curl -fsSL https://bun.sh/install | bash')!
}
fn destroy() ! {
// osal.process_kill_recursive(name:'bun')!
osal.cmd_delete('bun')!
osal.package_remove('
bun
')!
//will remove all paths where bun is found
osal.profile_path_add_remove(paths2delete:"bun")!
osal.rm("
~/.bun
")!
}

View File

@@ -0,0 +1,82 @@
module bun
import freeflowuniverse.herolib.core.base
import freeflowuniverse.herolib.core.playbook
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.sysadmin.startupmanager
import freeflowuniverse.herolib.osal.zinit
import time
__global (
bun_global map[string]&Bun
bun_default string
)
/////////FACTORY
@[params]
pub struct ArgsGet{
pub mut:
name string
}
pub fn get(args_ ArgsGet) !&Bun {
return &Bun{}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS ///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
fn startupmanager_get(cat zinit.StartupManagerType) !startupmanager.StartupManager {
// unknown
// screen
// zinit
// tmux
// systemd
match cat{
.zinit{
console.print_debug("startupmanager: zinit")
return startupmanager.get(cat:.zinit)!
}
.systemd{
console.print_debug("startupmanager: systemd")
return startupmanager.get(cat:.systemd)!
}else{
console.print_debug("startupmanager: auto")
return startupmanager.get()!
}
}
}
@[params]
pub struct InstallArgs{
pub mut:
reset bool
}
pub fn (mut self Bun) install(args InstallArgs) ! {
switch(self.name)
if args.reset || (!installed()!) {
install()!
}
}
pub fn (mut self Bun) destroy() ! {
switch(self.name)
destroy()!
}
//switch instance to be used for bun
pub fn switch(name string) {
bun_default = name
}

View File

@@ -0,0 +1,29 @@
module bun
import freeflowuniverse.herolib.data.paramsparser
import os
pub const version = '1.2.2'
const singleton = true
const default = true
//THIS THE THE SOURCE OF THE INFORMATION OF THIS FILE, HERE WE HAVE THE CONFIG OBJECT CONFIGURED AND MODELLED
@[heap]
pub struct Bun {
pub mut:
name string = 'default'
}
fn obj_init(obj_ Bun)!Bun{
//never call get here, only thing we can do here is work on object itself
mut obj:=obj_
return obj
}
//called before start if done
fn configure() ! {
//mut installer := get()!
}

View File

@@ -0,0 +1,44 @@
# bun
To get started
```vlang
import freeflowuniverse.herolib.installers.something.bun as bun_installer
heroscript:="
!!bun.configure name:'test'
password: '1234'
port: 7701
!!bun.start name:'test' reset:1
"
bun_installer.play(heroscript=heroscript)!
//or we can call the default and do a start with reset
//mut installer:= bun_installer.get()!
//installer.start(reset:true)!
```
## example heroscript
```hero
!!bun.configure
homedir: '/home/user/bun'
username: 'admin'
password: 'secretpassword'
title: 'Some Title'
host: 'localhost'
port: 8888
```