feat: Improved tailwind installer
This commit is contained in:
@@ -4,12 +4,12 @@ import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.core
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.installers.ulist
|
||||
import os
|
||||
|
||||
pub const version = '3.4.12'
|
||||
//////////////////// following actions are not specific to instance of the object
|
||||
|
||||
// checks if a certain version or above is installed
|
||||
fn installed_() !bool {
|
||||
fn installed() !bool {
|
||||
res := os.execute('tailwind -h')
|
||||
if res.exit_code == 0 {
|
||||
r := res.output.split_into_lines().filter(it.contains('tailwindcss v'))
|
||||
@@ -26,7 +26,21 @@ fn installed_() !bool {
|
||||
return false
|
||||
}
|
||||
|
||||
pub fn install_() ! {
|
||||
// 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: 'tailwind'
|
||||
// source: '${gitpath}/target/x86_64-unknown-linux-musl/release/tailwind'
|
||||
// )!
|
||||
}
|
||||
|
||||
fn install() ! {
|
||||
console.print_header('install tailwind')
|
||||
|
||||
mut url := ''
|
||||
@@ -54,5 +68,4 @@ pub fn install_() ! {
|
||||
)!
|
||||
}
|
||||
|
||||
fn destroy_() ! {
|
||||
}
|
||||
fn destroy() ! {}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
module tailwind
|
||||
|
||||
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 freeflowuniverse.herolib.ui.console
|
||||
import time
|
||||
|
||||
__global (
|
||||
tailwind_global map[string]&Tailwind
|
||||
@@ -17,13 +15,43 @@ __global (
|
||||
@[params]
|
||||
pub struct ArgsGet {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
name string
|
||||
}
|
||||
|
||||
pub fn get(args_ ArgsGet) !&Tailwind {
|
||||
return &Tailwind{}
|
||||
}
|
||||
|
||||
@[params]
|
||||
pub struct PlayArgs {
|
||||
pub mut:
|
||||
heroscript string // if filled in then plbook will be made out of it
|
||||
plbook ?playbook.PlayBook
|
||||
reset bool
|
||||
}
|
||||
|
||||
pub fn play(args_ PlayArgs) ! {
|
||||
mut args := args_
|
||||
|
||||
mut plbook := args.plbook or { playbook.new(text: args.heroscript)! }
|
||||
|
||||
mut other_actions := plbook.find(filter: 'tailwind.')!
|
||||
for other_action in other_actions {
|
||||
if other_action.name in ['destroy', 'install', 'build'] {
|
||||
mut p := other_action.params
|
||||
reset := p.get_default_false('reset')
|
||||
if other_action.name == 'destroy' || reset {
|
||||
console.print_debug('install action tailwind.destroy')
|
||||
destroy()!
|
||||
}
|
||||
if other_action.name == 'install' {
|
||||
console.print_debug('install action tailwind.install')
|
||||
install()!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS ///////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -58,18 +86,24 @@ pub mut:
|
||||
|
||||
pub fn (mut self Tailwind) install(args InstallArgs) ! {
|
||||
switch(self.name)
|
||||
if args.reset || (!installed_()!) {
|
||||
install_()!
|
||||
if args.reset || (!installed()!) {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (mut self Tailwind) destroy() ! {
|
||||
switch(self.name)
|
||||
|
||||
destroy_()!
|
||||
destroy()!
|
||||
}
|
||||
|
||||
// switch instance to be used for tailwind
|
||||
pub fn switch(name string) {
|
||||
tailwind_default = name
|
||||
}
|
||||
|
||||
// helpers
|
||||
|
||||
@[params]
|
||||
pub struct DefaultConfigArgs {
|
||||
instance string = 'default'
|
||||
}
|
||||
|
||||
@@ -1,25 +1,36 @@
|
||||
module tailwind
|
||||
|
||||
import freeflowuniverse.herolib.data.paramsparser
|
||||
import os
|
||||
import freeflowuniverse.herolib.data.encoderhero
|
||||
|
||||
pub const version = '3.4.12'
|
||||
const singleton = false
|
||||
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 Tailwind {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
}
|
||||
|
||||
fn obj_init(obj_ Tailwind) !Tailwind {
|
||||
// never call get here, only thing we can do here is work on object itself
|
||||
mut obj := obj_
|
||||
return obj
|
||||
// your checking & initialization code if needed
|
||||
fn obj_init(mycfg_ Tailwind) !Tailwind {
|
||||
mut mycfg := mycfg_
|
||||
return mycfg
|
||||
}
|
||||
|
||||
// called before start if done
|
||||
fn configure() ! {
|
||||
// mut installer := get()!
|
||||
}
|
||||
|
||||
/////////////NORMALLY NO NEED TO TOUCH
|
||||
|
||||
pub fn heroscript_dumps(obj Tailwind) !string {
|
||||
return encoderhero.encode[Tailwind](obj)!
|
||||
}
|
||||
|
||||
pub fn heroscript_loads(heroscript string) !Tailwind {
|
||||
mut obj := encoderhero.decode[Tailwind](heroscript)!
|
||||
return obj
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user