Added fancy printing when building, fixed compressionlevel attempting to be set when no compression is specified

Signed-off-by: arzumify <jliwin98@danwin1210.de>
This commit is contained in:
Tracker-Friendly 2024-10-29 12:51:04 +00:00
parent d6adc1c775
commit 6b483f712e
4 changed files with 49 additions and 26 deletions

View File

@ -1,13 +1,33 @@
#!/bin/sh #!/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 path=$(realpath "$(dirname "$0")") || exit 1
search_dir="$path/services-src" searchDir="$path/services-src"
find -L "$search_dir" -type f -name "build.sh" | while read -r build_script; do find -L "$searchDir" -type f -name "build.sh" | while read -r buildScript; do
echo "Running $build_script..." clear
build_dir=$(dirname "$build_script") buildDir=$(dirname "$buildScript")
(cd "$build_dir" && ./build.sh) || { fancy "\033[1;104m" "Starting build of $(basename "$buildDir")..."
echo "Error: $build_script failed." (cd "$buildDir" && ./build.sh) || {
printf "\033[1;31mError: %s failed.\033[0m\n" "$buildScript"
exit 1 exit 1
} }
done done
clear
fancy "\033[1;105m" "Building Fulgens..."
go build --ldflags "-s -w" -o "$path/fulgens" || exit 1 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!"

13
main.go
View File

@ -539,14 +539,15 @@ func parseConfig(path string) Config {
} }
// Set the compression level // Set the compression level
compressionLevelI64, err := config.Global.CompressionLevelJN.Int64() if config.Global.Compression != "" {
if err != nil { compressionLevelI64, err := config.Global.CompressionLevelJN.Int64()
slog.Error("Error parsing compression level: ", err) if err != nil {
os.Exit(1) slog.Error("Error parsing compression level: ", err)
os.Exit(1)
}
config.Global.CompressionLevel = int(compressionLevelI64)
} }
config.Global.CompressionLevel = int(compressionLevelI64)
// Validate the configuration // Validate the configuration
err = validate.Struct(config) err = validate.Struct(config)
if err != nil { if err != nil {

View File

@ -5,19 +5,19 @@ resourceDir="$path/../../resources/00000000-0000-0000-0000-000000000004"
rm -rf "$resourceDir" || exit 1 rm -rf "$resourceDir" || exit 1
rm -rf "$path/../../services/auth.fgs" || exit 1 rm -rf "$path/../../services/auth.fgs" || exit 1
cd "$path" || 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 go build -o "$path/../../services/auth.fgs" --buildmode=plugin -ldflags "-s -w" || exit 1
mkdir -p "$resourceDir/static/wasm" || exit 1 mkdir -p "$resourceDir/static/wasm" || exit 1
cd "$path/resources/wasm/login" || exit 1 find -L "$path/resources/wasm" -type f -name "main.go" | while read -r mainGo; do
GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/login.wasm" -ldflags "-s -w" || exit 1 buildDir=$(dirname "$mainGo")
cd "$path/resources/wasm/signup" || exit 1 baseName=$(basename "$buildDir")
GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/signup.wasm" -ldflags "-s -w" || exit 1 printf "\033[1;34m\033[1;33mBuilding WASM object %s...\033[0m\n" "$baseName"
cd "$path/resources/wasm/authorize" || exit 1 (cd "$buildDir" && GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/$(basename "$buildDir").wasm" -ldflags "-s -w") || {
GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/authorize.wasm" -ldflags "-s -w" || exit 1 printf "\033[1;31mError: %s failed.\033[0m\n" "$mainGo"
cd "$path/resources/wasm/dashboard" || exit 1 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 done
GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/testApp.wasm" -ldflags "-s -w" || exit 1 printf "\033[1;34mCopying static files...\033[0m\n"
cd "$path/resources/wasm/clientKeyShare" || exit 1
GOOS=js GOARCH=wasm go build -o "$resourceDir/static/wasm/clientKeyShare.wasm" -ldflags "-s -w" || exit 1
cp -r "$path/resources/static" "$resourceDir/" || exit 1 cp -r "$path/resources/static" "$resourceDir/" || exit 1
cp -r "$path/resources/templates" "$resourceDir/" || exit 1 cp -r "$path/resources/templates" "$resourceDir/" || exit 1
printf "\033[1;36mauth.fgs has been built successfully!\033[0m\n"

View File

@ -2,4 +2,6 @@
path=$(realpath "$(dirname "$0")") || exit 1 path=$(realpath "$(dirname "$0")") || exit 1
rm -rf "$path/../../services/storage.fgs" || 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 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"