From c8d715126f7ad9ef04758e21941eed5461fbbf5f Mon Sep 17 00:00:00 2001 From: kristof de spiegeleer Date: Mon, 3 Feb 2025 12:37:19 +0300 Subject: [PATCH] s --- README.md | 2 +- cli/compile_upload.vsh | 1 + cli/hero.v | 2 +- install_hero.sh | 77 +++++++++++++++++++ lib/builder/builder_factory.v | 6 +- lib/core/herocmds/docusaurus.v | 36 ++++----- lib/core/playcmds/play_core.v | 19 +++-- lib/core/playcmds/play_doctree.v | 22 +++--- lib/core/playcmds/play_luadns.v | 15 ++-- lib/installers/lang/golang/golang_actions.v | 4 +- lib/installers/lang/rust/rust_actions.v | 6 +- .../garage_s3/garage_s3_actions.v | 14 ++-- lib/web/docusaurus/dsite.v | 6 +- 13 files changed, 143 insertions(+), 67 deletions(-) create mode 100755 install_hero.sh diff --git a/README.md b/README.md index 47ccd727..c6371502 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ bash /tmp/install_v.sh --analyzer --herolib ```bash -#~/code/github/freeflowuniverse/herolib/install_v.sh --help +~/code/github/freeflowuniverse/herolib/install_v.sh --help V & HeroLib Installer Script diff --git a/cli/compile_upload.vsh b/cli/compile_upload.vsh index 07c0841a..6ec88872 100755 --- a/cli/compile_upload.vsh +++ b/cli/compile_upload.vsh @@ -89,5 +89,6 @@ fn hero_upload() ! { } fn main() { + //os.execute_or_panic('${os.home_dir()}/code/github/freeflowuniverse/herolib/cli/compile.vsh -p') hero_upload() or { eprintln(err) exit(1) } } diff --git a/cli/hero.v b/cli/hero.v index 5a3a1869..3535fbfa 100644 --- a/cli/hero.v +++ b/cli/hero.v @@ -31,7 +31,7 @@ fn do() ! { mut cmd := Command{ name: 'hero' description: 'Your HERO toolset.' - version: '2.0.0' + version: '2.0.2' } // herocmds.cmd_run_add_flags(mut cmd) diff --git a/install_hero.sh b/install_hero.sh new file mode 100755 index 00000000..fbe8f1ab --- /dev/null +++ b/install_hero.sh @@ -0,0 +1,77 @@ +#!/bin/bash -e + +set -e + +os_name="$(uname -s)" +arch_name="$(uname -m)" + +# Select the URL based on the platform +if [[ "$os_name" == "Linux" && "$arch_name" == "x86_64" ]]; then + url="https://f003.backblazeb2.com/file/threefold/linux-i64/hero" +elif [[ "$os_name" == "Darwin" && "$arch_name" == "arm64" ]]; then + url="https://f003.backblazeb2.com/file/threefold/macos-arm64/hero" +# elif [[ "$os_name" == "Darwin" && "$arch_name" == "x86_64" ]]; then +# url="https://f003.backblazeb2.com/file/threefold/macos-i64/hero" +else + echo "Unsupported platform." + exit 1 +fi + +if [[ "${OSNAME}" == "darwin"* ]]; then + [ -f /usr/local/bin/hero ] && rm /usr/local/bin/hero +fi + +if [ -z "$url" ]; then + echo "Could not find url to download." + echo $urls + exit 1 +fi +zprofile="${HOME}/.zprofile" +hero_bin_path="${HOME}/hero/bin" +temp_file="$(mktemp)" + +# Check if ~/.zprofile exists +if [ -f "$zprofile" ]; then + # Read each line and exclude any that modify the PATH with ~/hero/bin + while IFS= read -r line; do + if [[ ! "$line" =~ $hero_bin_path ]]; then + echo "$line" >> "$temp_file" + fi + done < "$zprofile" +else + touch "$zprofile" +fi +# Add ~/hero/bin to the PATH statement +echo "export PATH=\$PATH:$hero_bin_path" >> "$temp_file" +# Replace the original .zprofile with the modified version +mv "$temp_file" "$zprofile" +# Ensure the temporary file is removed (in case of script interruption before mv) +trap 'rm -f "$temp_file"' EXIT + +# Output the selected URL +echo "Download URL for your platform: $url" + +# Download the file +curl -o /tmp/downloaded_file -L "$url" + +# Check if file size is greater than 10 MB +file_size=$(du -m /tmp/downloaded_file | cut -f1) +if [ "$file_size" -ge 2 ]; then + # Create the target directory if it doesn't exist + mkdir -p ~/hero/bin + if [[ "$OSTYPE" == "darwin"* ]]; then + # Move and rename the file + mv /tmp/downloaded_file ~/hero/bin/hero + chmod +x ~/hero/bin/hero + else + mv /tmp/downloaded_file /usr/local/bin/hero + chmod +x /usr/local/bin/hero + fi + + echo "Hero installed properly" + export PATH=$PATH:$hero_bin_path + hero -version +else + echo "Downloaded file is less than 10 MB. Process aborted." + exit 1 +fi diff --git a/lib/builder/builder_factory.v b/lib/builder/builder_factory.v index bd2d2a57..40508c10 100644 --- a/lib/builder/builder_factory.v +++ b/lib/builder/builder_factory.v @@ -7,9 +7,9 @@ pub struct BuilderFactory { } pub fn new() !BuilderFactory { - mut c := base.context()! - mut bf := BuilderFactory{} - return bf + _ := base.context()! + mut bf := BuilderFactory{} + return bf } @[params] diff --git a/lib/core/herocmds/docusaurus.v b/lib/core/herocmds/docusaurus.v index e187ea0c..d045accd 100644 --- a/lib/core/herocmds/docusaurus.v +++ b/lib/core/herocmds/docusaurus.v @@ -81,25 +81,25 @@ fn cmd_docusaurus_execute(cmd Command) ! { // build_path: '/tmp/docusaurus_build' )! - if build{ - // Create a new docusaurus site - mut site := docs.build( - url:url - )! - } + if build{ + // Create a new docusaurus site + _ := docs.build( + url:url + )! + } - if builddev{ - // Create a new docusaurus site - mut site := docs.build_dev( - url:url - )! - } + if builddev{ + // Create a new docusaurus site + _ := docs.build_dev( + url:url + )! + } - if dev{ - // Create a new docusaurus site - mut site := docs.dev( - url:url - )! - } + if dev{ + // Create a new docusaurus site + _ := docs.dev( + url:url + )! + } } diff --git a/lib/core/playcmds/play_core.v b/lib/core/playcmds/play_core.v index cad378a8..42d8ebbb 100644 --- a/lib/core/playcmds/play_core.v +++ b/lib/core/playcmds/play_core.v @@ -18,20 +18,19 @@ pub fn play_core(mut plbook playbook.PlayBook) ! { session.interactive = p.get_default_false('interactive') } - if p.exists('coderoot') { - panic('implement') - mut coderoot := p.get_path_create('coderoot')! - - mut gs := gittools.get()! - } + if p.exists('coderoot') { + panic('implement') + // mut coderoot := p.get_path_create('coderoot')! + // mut gs := gittools.get()! + } action.done = true } - for mut action in plbook.find(filter: 'session.')! { - mut p := action.params - mut session := plbook.session + for mut action in plbook.find(filter: 'session.')! { + // mut p := action.params + // mut session := plbook.session - //!!session.env_set key:'JWT_SHARED_KEY' val:'...' + //!!session.env_set key:'JWT_SHARED_KEY' val:'...' action.done = true } diff --git a/lib/core/playcmds/play_doctree.v b/lib/core/playcmds/play_doctree.v index e7dfe16a..0ff085b3 100644 --- a/lib/core/playcmds/play_doctree.v +++ b/lib/core/playcmds/play_doctree.v @@ -26,15 +26,15 @@ pub fn play_doctree(mut plbook playbook.PlayBook) ! { trees[name] = tree } - for mut action in plbook.find(filter: 'doctree:add')! { - mut p := action.params - url := p.get_default('url', '')! - path := p.get_default('path', '')! - name := p.get('name')! + for mut action in plbook.find(filter: 'doctree:add')! { + mut p := action.params + // url := p.get_default('url', '')! + // path := p.get_default('path', '')! + name := p.get('name')! - mut tree := trees[name] or { return error('tree ${name} not found') } + _ := trees[name] or { return error('tree ${name} not found') } - // tree.scan( + // tree.scan( // path: path // git_url: url // git_reset: reset @@ -61,9 +61,9 @@ pub fn play_doctree(mut plbook playbook.PlayBook) ! { } for mut action in plbook.find(filter: 'doctree:export')! { - panic('implement') - mut p := action.params - name := p.get('name')! - action.done = true + panic('implement') + mut p := action.params + _ := p.get('name')! + action.done = true } } diff --git a/lib/core/playcmds/play_luadns.v b/lib/core/playcmds/play_luadns.v index 350dcd17..7f3485b5 100644 --- a/lib/core/playcmds/play_luadns.v +++ b/lib/core/playcmds/play_luadns.v @@ -5,14 +5,15 @@ import freeflowuniverse.herolib.core.playbook import os pub fn play_luadns(mut plbook playbook.PlayBook) ! { - mut buildroot := '${os.home_dir()}/hero/var/mdbuild' - mut publishroot := '${os.home_dir()}/hero/www/info' - mut coderoot := '' - // mut install := false - mut reset := false - mut pull := false + // Variables below are not used, commenting them out + // mut buildroot := '${os.home_dir()}/hero/var/mdbuild' + // mut publishroot := '${os.home_dir()}/hero/www/info' + // mut coderoot := '' + // mut install := false + // mut reset := false + // mut pull := false - for mut action in plbook.find(filter: 'luadns.set_domain')! { + for mut action in plbook.find(filter: 'luadns.set_domain')! { mut p := action.params url := p.get_default('url', '')! diff --git a/lib/installers/lang/golang/golang_actions.v b/lib/installers/lang/golang/golang_actions.v index 68ee4164..b56e9c90 100644 --- a/lib/installers/lang/golang/golang_actions.v +++ b/lib/installers/lang/golang/golang_actions.v @@ -50,8 +50,8 @@ fn install_() ! { expand_dir := '/tmp/golang' - // the downloader is cool, it will check the download succeeds and also check the minimum size - dest := osal.download( + // the downloader is cool, it will check the download succeeds and also check the minimum size + _ := osal.download( url: url minsize_kb: 40000 expand_dir: expand_dir diff --git a/lib/installers/lang/rust/rust_actions.v b/lib/installers/lang/rust/rust_actions.v index 24ddda1a..33aeec1d 100644 --- a/lib/installers/lang/rust/rust_actions.v +++ b/lib/installers/lang/rust/rust_actions.v @@ -42,10 +42,8 @@ fn upload_() ! { } fn install_() ! { - console.print_header('install rust') - version := '1.83.0' - - base.install()! + console.print_header('install rust') + base.install()! pl := core.platform()! diff --git a/lib/installers/sysadmintools/garage_s3/garage_s3_actions.v b/lib/installers/sysadmintools/garage_s3/garage_s3_actions.v index 1665465e..8527068d 100644 --- a/lib/installers/sysadmintools/garage_s3/garage_s3_actions.v +++ b/lib/installers/sysadmintools/garage_s3/garage_s3_actions.v @@ -29,10 +29,10 @@ fn installed() !bool { } fn install() ! { - console.print_header('install garage_s3') - mut installer := get()! - // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED - mut url := '' + console.print_header('install garage_s3') + //mut installer := get()! + // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED + mut url := '' if core.is_linux_arm()! { url = 'https://github.com/garage_s3-dev/garage_s3/releases/download/v${version}/garage_s3_${version}_linux_arm64.tar.gz' } else if core.is_linux_intel()! { @@ -75,9 +75,9 @@ fn startupcmd() ![]zinit.ZProcessNewArgs { } fn running_() !bool { - mut installer := get()! - // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED - // this checks health of garage_s3 + _ := get()! + // THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED + // this checks health of garage_s3 // curl http://localhost:3333/api/v1/s --oauth2-bearer 1234 works // url:='http://127.0.0.1:${cfg.port}/api/v1' // mut conn := httpconnection.new(name: 'garage_s3', url: url)! diff --git a/lib/web/docusaurus/dsite.v b/lib/web/docusaurus/dsite.v index 0ff8659e..3818dde9 100644 --- a/lib/web/docusaurus/dsite.v +++ b/lib/web/docusaurus/dsite.v @@ -159,9 +159,9 @@ pub mut: } pub fn (mut site DocSite) error(args ErrorArgs) { - path2 := pathlib.get(args.path) - e := SiteError{ - path: args.path + // path2 := pathlib.get(args.path) + e := SiteError{ + path: args.path msg: args.msg cat: args.cat }