From 6b483f712e0b8d3c4e8dce0b2910378402e5bedd Mon Sep 17 00:00:00 2001 From: arzumify Date: Tue, 29 Oct 2024 12:51:04 +0000 Subject: [PATCH] Added fancy printing when building, fixed compressionlevel attempting to be set when no compression is specified Signed-off-by: arzumify --- build.sh | 34 +++++++++++++++++++++++++++------- main.go | 13 +++++++------ services-src/auth/build.sh | 26 +++++++++++++------------- services-src/storage/build.sh | 2 ++ 4 files changed, 49 insertions(+), 26 deletions(-) diff --git a/build.sh b/build.sh index 8f23769..67b9fac 100755 --- a/build.sh +++ b/build.sh @@ -1,13 +1,33 @@ #!/bin/sh + +clear + +fancy() { + width="$(tput cols)" + # Create a string of spaces based on the width + spaces=$(printf '%*s' "$width" '' | tr ' ' ' ') + + # Print the formatted output + printf "%b%s %s %s%s\n\033[0m" "$1" "$spaces" "$2" "$(printf '%*s' "$((width - ${#2} - 4))" '' | tr ' ' ' ')" "$spaces" +} + +fancy "\033[1;106m" "Welcome to fulgens! Starting build..." + +sleep 1 + path=$(realpath "$(dirname "$0")") || exit 1 -search_dir="$path/services-src" -find -L "$search_dir" -type f -name "build.sh" | while read -r build_script; do - echo "Running $build_script..." - build_dir=$(dirname "$build_script") - (cd "$build_dir" && ./build.sh) || { - echo "Error: $build_script failed." +searchDir="$path/services-src" +find -L "$searchDir" -type f -name "build.sh" | while read -r buildScript; do + clear + buildDir=$(dirname "$buildScript") + fancy "\033[1;104m" "Starting build of $(basename "$buildDir")..." + (cd "$buildDir" && ./build.sh) || { + printf "\033[1;31mError: %s failed.\033[0m\n" "$buildScript" exit 1 } done +clear +fancy "\033[1;105m" "Building Fulgens..." go build --ldflags "-s -w" -o "$path/fulgens" || exit 1 -echo "Fulgens has been built successfully." +clear +fancy "\033[1;102m" "Fulgensfas has been built successfully!" \ No newline at end of file diff --git a/main.go b/main.go index c96b011..396a065 100644 --- a/main.go +++ b/main.go @@ -539,14 +539,15 @@ func parseConfig(path string) Config { } // Set the compression level - compressionLevelI64, err := config.Global.CompressionLevelJN.Int64() - if err != nil { - slog.Error("Error parsing compression level: ", err) - os.Exit(1) + if config.Global.Compression != "" { + compressionLevelI64, err := config.Global.CompressionLevelJN.Int64() + if err != nil { + slog.Error("Error parsing compression level: ", err) + os.Exit(1) + } + config.Global.CompressionLevel = int(compressionLevelI64) } - config.Global.CompressionLevel = int(compressionLevelI64) - // Validate the configuration err = validate.Struct(config) if err != nil { diff --git a/services-src/auth/build.sh b/services-src/auth/build.sh index 7872946..fb353ce 100755 --- a/services-src/auth/build.sh +++ b/services-src/auth/build.sh @@ -5,19 +5,19 @@ resourceDir="$path/../../resources/00000000-0000-0000-0000-000000000004" rm -rf "$resourceDir" || exit 1 rm -rf "$path/../../services/auth.fgs" || exit 1 cd "$path" || exit 1 +printf "\033[1;35mBuilding auth.fgs...\033[0m\n" go build -o "$path/../../services/auth.fgs" --buildmode=plugin -ldflags "-s -w" || exit 1 mkdir -p "$resourceDir/static/wasm" || exit 1 -cd "$path/resources/wasm/login" || exit 1 -GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/login.wasm" -ldflags "-s -w" || exit 1 -cd "$path/resources/wasm/signup" || exit 1 -GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/signup.wasm" -ldflags "-s -w" || exit 1 -cd "$path/resources/wasm/authorize" || exit 1 -GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/authorize.wasm" -ldflags "-s -w" || exit 1 -cd "$path/resources/wasm/dashboard" || exit 1 -GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/dashboard.wasm" -ldflags "-s -w" || exit 1 -cd "$path/resources/wasm/testApp" || exit 1 -GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/testApp.wasm" -ldflags "-s -w" || exit 1 -cd "$path/resources/wasm/clientKeyShare" || exit 1 -GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/clientKeyShare.wasm" -ldflags "-s -w" || exit 1 +find -L "$path/resources/wasm" -type f -name "main.go" | while read -r mainGo; do + buildDir=$(dirname "$mainGo") + baseName=$(basename "$buildDir") + printf "\033[1;34m\033[1;33mBuilding WASM object %s...\033[0m\n" "$baseName" + (cd "$buildDir" && GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/$(basename "$buildDir").wasm" -ldflags "-s -w") || { + printf "\033[1;31mError: %s failed.\033[0m\n" "$mainGo" + exit 1 + } +done +printf "\033[1;34mCopying static files...\033[0m\n" cp -r "$path/resources/static" "$resourceDir/" || exit 1 -cp -r "$path/resources/templates" "$resourceDir/" || exit 1 \ No newline at end of file +cp -r "$path/resources/templates" "$resourceDir/" || exit 1 +printf "\033[1;36mauth.fgs has been built successfully!\033[0m\n" \ No newline at end of file diff --git a/services-src/storage/build.sh b/services-src/storage/build.sh index 0c7dacc..a869c2c 100755 --- a/services-src/storage/build.sh +++ b/services-src/storage/build.sh @@ -2,4 +2,6 @@ path=$(realpath "$(dirname "$0")") || exit 1 rm -rf "$path/../../services/storage.fgs" || exit 1 +printf "\033[1;35mBuilding storage.fgs...\033[0m\n" go build -o "$path/../../services/storage.fgs" --buildmode=plugin -ldflags "-s -w" || exit 1 +printf "\033[1;36mstorage.fgs has been built successfully!\033[0m\n" \ No newline at end of file