diff --git a/servlets/amadeus-flight-api/prepare.sh b/servlets/amadeus-flight-api/prepare.sh index ec08baf..9fbb93c 100644 --- a/servlets/amadeus-flight-api/prepare.sh +++ b/servlets/amadeus-flight-api/prepare.sh @@ -1,16 +1,22 @@ #!/bin/bash +set -eou pipefail # Function to check if a command exists command_exists () { command -v "$1" >/dev/null 2>&1 } +# Function to compare version numbers for "less than" +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" && test "$1" != "$2" +} + missing_deps=0 # Check for Go if ! (command_exists go); then missing_deps=1 - echo "❌ Go (supported version between 1.18 - 1.22) is not installed." + echo "❌ Go (supported version between 1.20 - 1.24) is not installed." echo "" echo "To install Go, visit the official download page:" echo "👉 https://go.dev/dl/" @@ -26,27 +32,29 @@ if ! (command_exists go); then echo "🔹 Arch Linux:" echo " sudo pacman -S go" echo "" + echo "🔹 Windows:" + echo " scoop install go" + echo "" fi -# Check for the right version of Go, needed by TinyGo (supports go 1.18 - 1.22) +# Check for the right version of Go, needed by TinyGo (supports go 1.20 - 1.24) if (command_exists go); then compat=0 - for v in `seq 18 22`; do + for v in `seq 20 24`; do if (go version | grep -q "go1.$v"); then compat=1 fi done if [ $compat -eq 0 ]; then - echo "❌ Supported Go version is not installed. Must be Go 1.18 - 1.22." + echo "❌ Supported Go version is not installed. Must be Go 1.20 - 1.24." echo "" fi fi - ARCH=$(arch) -# Check for TinyGo +# Check for TinyGo and its version if ! (command_exists tinygo); then missing_deps=1 echo "❌ TinyGo is not installed." @@ -61,12 +69,24 @@ if ! (command_exists tinygo); then echo " brew install tinygo" echo "" echo "🔹 Ubuntu/Debian:" - echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_$ARCH.deb" - echo " sudo dpkg -i tinygo_0.31.2_$ARCH.deb" + echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_$ARCH.deb" + echo " sudo dpkg -i tinygo_0.34.0_$ARCH.deb" echo "" echo "🔹 Arch Linux:" echo " pacman -S extra/tinygo" echo "" + echo "🔹 Windows:" + echo " scoop install tinygo" + echo "" +else + # Check TinyGo version + tinygo_version=$(tinygo version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1) + if version_lt "$tinygo_version" "0.34.0"; then + missing_deps=1 + echo "❌ TinyGo version must be >= 0.34.0 (current version: $tinygo_version)" + echo "Please update TinyGo to a newer version." + echo "" + fi fi go install golang.org/x/tools/cmd/goimports@latest diff --git a/servlets/assembly-ai/prepare.sh b/servlets/assembly-ai/prepare.sh index ac30fff..9fbb93c 100644 --- a/servlets/assembly-ai/prepare.sh +++ b/servlets/assembly-ai/prepare.sh @@ -6,9 +6,9 @@ command_exists () { command -v "$1" >/dev/null 2>&1 } -# Function to compare version numbers -version_gt() { - test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1" +# Function to compare version numbers for "less than" +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" && test "$1" != "$2" } missing_deps=0 @@ -16,7 +16,7 @@ missing_deps=0 # Check for Go if ! (command_exists go); then missing_deps=1 - echo "❌ Go (supported version between 1.18 - 1.23) is not installed." + echo "❌ Go (supported version between 1.20 - 1.24) is not installed." echo "" echo "To install Go, visit the official download page:" echo "👉 https://go.dev/dl/" @@ -37,17 +37,17 @@ if ! (command_exists go); then echo "" fi -# Check for the right version of Go, needed by TinyGo (supports go 1.18 - 1.23) +# Check for the right version of Go, needed by TinyGo (supports go 1.20 - 1.24) if (command_exists go); then compat=0 - for v in `seq 18 23`; do + for v in `seq 20 24`; do if (go version | grep -q "go1.$v"); then compat=1 fi done if [ $compat -eq 0 ]; then - echo "❌ Supported Go version is not installed. Must be Go 1.18 - 1.23." + echo "❌ Supported Go version is not installed. Must be Go 1.20 - 1.24." echo "" fi fi @@ -81,12 +81,12 @@ if ! (command_exists tinygo); then else # Check TinyGo version tinygo_version=$(tinygo version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1) - if ! version_gt "$tinygo_version" "0.34.0"; then + if version_lt "$tinygo_version" "0.34.0"; then missing_deps=1 - echo "❌ TinyGo version must be greater than 0.34.0 (current version: $tinygo_version)" + echo "❌ TinyGo version must be >= 0.34.0 (current version: $tinygo_version)" echo "Please update TinyGo to a newer version." echo "" fi fi -go install golang.org/x/tools/cmd/goimports@latest \ No newline at end of file +go install golang.org/x/tools/cmd/goimports@latest diff --git a/servlets/bluesky/prepare.sh b/servlets/bluesky/prepare.sh index ec08baf..9fbb93c 100644 --- a/servlets/bluesky/prepare.sh +++ b/servlets/bluesky/prepare.sh @@ -1,16 +1,22 @@ #!/bin/bash +set -eou pipefail # Function to check if a command exists command_exists () { command -v "$1" >/dev/null 2>&1 } +# Function to compare version numbers for "less than" +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" && test "$1" != "$2" +} + missing_deps=0 # Check for Go if ! (command_exists go); then missing_deps=1 - echo "❌ Go (supported version between 1.18 - 1.22) is not installed." + echo "❌ Go (supported version between 1.20 - 1.24) is not installed." echo "" echo "To install Go, visit the official download page:" echo "👉 https://go.dev/dl/" @@ -26,27 +32,29 @@ if ! (command_exists go); then echo "🔹 Arch Linux:" echo " sudo pacman -S go" echo "" + echo "🔹 Windows:" + echo " scoop install go" + echo "" fi -# Check for the right version of Go, needed by TinyGo (supports go 1.18 - 1.22) +# Check for the right version of Go, needed by TinyGo (supports go 1.20 - 1.24) if (command_exists go); then compat=0 - for v in `seq 18 22`; do + for v in `seq 20 24`; do if (go version | grep -q "go1.$v"); then compat=1 fi done if [ $compat -eq 0 ]; then - echo "❌ Supported Go version is not installed. Must be Go 1.18 - 1.22." + echo "❌ Supported Go version is not installed. Must be Go 1.20 - 1.24." echo "" fi fi - ARCH=$(arch) -# Check for TinyGo +# Check for TinyGo and its version if ! (command_exists tinygo); then missing_deps=1 echo "❌ TinyGo is not installed." @@ -61,12 +69,24 @@ if ! (command_exists tinygo); then echo " brew install tinygo" echo "" echo "🔹 Ubuntu/Debian:" - echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_$ARCH.deb" - echo " sudo dpkg -i tinygo_0.31.2_$ARCH.deb" + echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_$ARCH.deb" + echo " sudo dpkg -i tinygo_0.34.0_$ARCH.deb" echo "" echo "🔹 Arch Linux:" echo " pacman -S extra/tinygo" echo "" + echo "🔹 Windows:" + echo " scoop install tinygo" + echo "" +else + # Check TinyGo version + tinygo_version=$(tinygo version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1) + if version_lt "$tinygo_version" "0.34.0"; then + missing_deps=1 + echo "❌ TinyGo version must be >= 0.34.0 (current version: $tinygo_version)" + echo "Please update TinyGo to a newer version." + echo "" + fi fi go install golang.org/x/tools/cmd/goimports@latest diff --git a/servlets/brave-search/prepare.sh b/servlets/brave-search/prepare.sh index ec08baf..9fbb93c 100644 --- a/servlets/brave-search/prepare.sh +++ b/servlets/brave-search/prepare.sh @@ -1,16 +1,22 @@ #!/bin/bash +set -eou pipefail # Function to check if a command exists command_exists () { command -v "$1" >/dev/null 2>&1 } +# Function to compare version numbers for "less than" +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" && test "$1" != "$2" +} + missing_deps=0 # Check for Go if ! (command_exists go); then missing_deps=1 - echo "❌ Go (supported version between 1.18 - 1.22) is not installed." + echo "❌ Go (supported version between 1.20 - 1.24) is not installed." echo "" echo "To install Go, visit the official download page:" echo "👉 https://go.dev/dl/" @@ -26,27 +32,29 @@ if ! (command_exists go); then echo "🔹 Arch Linux:" echo " sudo pacman -S go" echo "" + echo "🔹 Windows:" + echo " scoop install go" + echo "" fi -# Check for the right version of Go, needed by TinyGo (supports go 1.18 - 1.22) +# Check for the right version of Go, needed by TinyGo (supports go 1.20 - 1.24) if (command_exists go); then compat=0 - for v in `seq 18 22`; do + for v in `seq 20 24`; do if (go version | grep -q "go1.$v"); then compat=1 fi done if [ $compat -eq 0 ]; then - echo "❌ Supported Go version is not installed. Must be Go 1.18 - 1.22." + echo "❌ Supported Go version is not installed. Must be Go 1.20 - 1.24." echo "" fi fi - ARCH=$(arch) -# Check for TinyGo +# Check for TinyGo and its version if ! (command_exists tinygo); then missing_deps=1 echo "❌ TinyGo is not installed." @@ -61,12 +69,24 @@ if ! (command_exists tinygo); then echo " brew install tinygo" echo "" echo "🔹 Ubuntu/Debian:" - echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_$ARCH.deb" - echo " sudo dpkg -i tinygo_0.31.2_$ARCH.deb" + echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_$ARCH.deb" + echo " sudo dpkg -i tinygo_0.34.0_$ARCH.deb" echo "" echo "🔹 Arch Linux:" echo " pacman -S extra/tinygo" echo "" + echo "🔹 Windows:" + echo " scoop install tinygo" + echo "" +else + # Check TinyGo version + tinygo_version=$(tinygo version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1) + if version_lt "$tinygo_version" "0.34.0"; then + missing_deps=1 + echo "❌ TinyGo version must be >= 0.34.0 (current version: $tinygo_version)" + echo "Please update TinyGo to a newer version." + echo "" + fi fi go install golang.org/x/tools/cmd/goimports@latest diff --git a/servlets/crypto-hash/prepare.sh b/servlets/crypto-hash/prepare.sh index 5ef3b82..9fbb93c 100644 --- a/servlets/crypto-hash/prepare.sh +++ b/servlets/crypto-hash/prepare.sh @@ -6,12 +6,17 @@ command_exists () { command -v "$1" >/dev/null 2>&1 } +# Function to compare version numbers for "less than" +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" && test "$1" != "$2" +} + missing_deps=0 # Check for Go if ! (command_exists go); then missing_deps=1 - echo "❌ Go (supported version between 1.18 - 1.23) is not installed." + echo "❌ Go (supported version between 1.20 - 1.24) is not installed." echo "" echo "To install Go, visit the official download page:" echo "👉 https://go.dev/dl/" @@ -27,35 +32,29 @@ if ! (command_exists go); then echo "🔹 Arch Linux:" echo " sudo pacman -S go" echo "" + echo "🔹 Windows:" + echo " scoop install go" + echo "" fi -# Check for the right version of Go, needed by TinyGo (supports go 1.18 - 1.23) +# Check for the right version of Go, needed by TinyGo (supports go 1.20 - 1.24) if (command_exists go); then compat=0 - for v in `seq 18 23`; do + for v in `seq 20 24`; do if (go version | grep -q "go1.$v"); then compat=1 fi done if [ $compat -eq 0 ]; then - echo "❌ Supported Go version is not installed. Must be Go 1.18 - 1.23." + echo "❌ Supported Go version is not installed. Must be Go 1.20 - 1.24." echo "" fi fi -# Exit with a bad exit code if any dependencies are missing -if [ "$missing_deps" -ne 0 ]; then - echo "Install the missing dependencies and ensure they are on your path. Then run this command again." - # TODO: remove sleep when cli bug is fixed - sleep 2 - exit 1 -fi - - ARCH=$(arch) -# Check for TinyGo +# Check for TinyGo and its version if ! (command_exists tinygo); then missing_deps=1 echo "❌ TinyGo is not installed." @@ -70,20 +69,24 @@ if ! (command_exists tinygo); then echo " brew install tinygo" echo "" echo "🔹 Ubuntu/Debian:" - echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_$ARCH.deb" - echo " sudo dpkg -i tinygo_0.31.2_$ARCH.deb" + echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_$ARCH.deb" + echo " sudo dpkg -i tinygo_0.34.0_$ARCH.deb" echo "" echo "🔹 Arch Linux:" echo " pacman -S extra/tinygo" echo "" + echo "🔹 Windows:" + echo " scoop install tinygo" + echo "" +else + # Check TinyGo version + tinygo_version=$(tinygo version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1) + if version_lt "$tinygo_version" "0.34.0"; then + missing_deps=1 + echo "❌ TinyGo version must be >= 0.34.0 (current version: $tinygo_version)" + echo "Please update TinyGo to a newer version." + echo "" + fi fi go install golang.org/x/tools/cmd/goimports@latest - -# Exit with a bad exit code if any dependencies are missing -if [ "$missing_deps" -ne 0 ]; then - echo "Install the missing dependencies and ensure they are on your path. Then run this command again." - # TODO: remove sleep when cli bug is fixed - sleep 2 - exit 1 -fi \ No newline at end of file diff --git a/servlets/github/prepare.sh b/servlets/github/prepare.sh index ec08baf..9fbb93c 100644 --- a/servlets/github/prepare.sh +++ b/servlets/github/prepare.sh @@ -1,16 +1,22 @@ #!/bin/bash +set -eou pipefail # Function to check if a command exists command_exists () { command -v "$1" >/dev/null 2>&1 } +# Function to compare version numbers for "less than" +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" && test "$1" != "$2" +} + missing_deps=0 # Check for Go if ! (command_exists go); then missing_deps=1 - echo "❌ Go (supported version between 1.18 - 1.22) is not installed." + echo "❌ Go (supported version between 1.20 - 1.24) is not installed." echo "" echo "To install Go, visit the official download page:" echo "👉 https://go.dev/dl/" @@ -26,27 +32,29 @@ if ! (command_exists go); then echo "🔹 Arch Linux:" echo " sudo pacman -S go" echo "" + echo "🔹 Windows:" + echo " scoop install go" + echo "" fi -# Check for the right version of Go, needed by TinyGo (supports go 1.18 - 1.22) +# Check for the right version of Go, needed by TinyGo (supports go 1.20 - 1.24) if (command_exists go); then compat=0 - for v in `seq 18 22`; do + for v in `seq 20 24`; do if (go version | grep -q "go1.$v"); then compat=1 fi done if [ $compat -eq 0 ]; then - echo "❌ Supported Go version is not installed. Must be Go 1.18 - 1.22." + echo "❌ Supported Go version is not installed. Must be Go 1.20 - 1.24." echo "" fi fi - ARCH=$(arch) -# Check for TinyGo +# Check for TinyGo and its version if ! (command_exists tinygo); then missing_deps=1 echo "❌ TinyGo is not installed." @@ -61,12 +69,24 @@ if ! (command_exists tinygo); then echo " brew install tinygo" echo "" echo "🔹 Ubuntu/Debian:" - echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_$ARCH.deb" - echo " sudo dpkg -i tinygo_0.31.2_$ARCH.deb" + echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_$ARCH.deb" + echo " sudo dpkg -i tinygo_0.34.0_$ARCH.deb" echo "" echo "🔹 Arch Linux:" echo " pacman -S extra/tinygo" echo "" + echo "🔹 Windows:" + echo " scoop install tinygo" + echo "" +else + # Check TinyGo version + tinygo_version=$(tinygo version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1) + if version_lt "$tinygo_version" "0.34.0"; then + missing_deps=1 + echo "❌ TinyGo version must be >= 0.34.0 (current version: $tinygo_version)" + echo "Please update TinyGo to a newer version." + echo "" + fi fi go install golang.org/x/tools/cmd/goimports@latest diff --git a/servlets/google-maps-image/prepare.sh b/servlets/google-maps-image/prepare.sh index ec08baf..9fbb93c 100644 --- a/servlets/google-maps-image/prepare.sh +++ b/servlets/google-maps-image/prepare.sh @@ -1,16 +1,22 @@ #!/bin/bash +set -eou pipefail # Function to check if a command exists command_exists () { command -v "$1" >/dev/null 2>&1 } +# Function to compare version numbers for "less than" +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" && test "$1" != "$2" +} + missing_deps=0 # Check for Go if ! (command_exists go); then missing_deps=1 - echo "❌ Go (supported version between 1.18 - 1.22) is not installed." + echo "❌ Go (supported version between 1.20 - 1.24) is not installed." echo "" echo "To install Go, visit the official download page:" echo "👉 https://go.dev/dl/" @@ -26,27 +32,29 @@ if ! (command_exists go); then echo "🔹 Arch Linux:" echo " sudo pacman -S go" echo "" + echo "🔹 Windows:" + echo " scoop install go" + echo "" fi -# Check for the right version of Go, needed by TinyGo (supports go 1.18 - 1.22) +# Check for the right version of Go, needed by TinyGo (supports go 1.20 - 1.24) if (command_exists go); then compat=0 - for v in `seq 18 22`; do + for v in `seq 20 24`; do if (go version | grep -q "go1.$v"); then compat=1 fi done if [ $compat -eq 0 ]; then - echo "❌ Supported Go version is not installed. Must be Go 1.18 - 1.22." + echo "❌ Supported Go version is not installed. Must be Go 1.20 - 1.24." echo "" fi fi - ARCH=$(arch) -# Check for TinyGo +# Check for TinyGo and its version if ! (command_exists tinygo); then missing_deps=1 echo "❌ TinyGo is not installed." @@ -61,12 +69,24 @@ if ! (command_exists tinygo); then echo " brew install tinygo" echo "" echo "🔹 Ubuntu/Debian:" - echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_$ARCH.deb" - echo " sudo dpkg -i tinygo_0.31.2_$ARCH.deb" + echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_$ARCH.deb" + echo " sudo dpkg -i tinygo_0.34.0_$ARCH.deb" echo "" echo "🔹 Arch Linux:" echo " pacman -S extra/tinygo" echo "" + echo "🔹 Windows:" + echo " scoop install tinygo" + echo "" +else + # Check TinyGo version + tinygo_version=$(tinygo version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1) + if version_lt "$tinygo_version" "0.34.0"; then + missing_deps=1 + echo "❌ TinyGo version must be >= 0.34.0 (current version: $tinygo_version)" + echo "Please update TinyGo to a newer version." + echo "" + fi fi go install golang.org/x/tools/cmd/goimports@latest diff --git a/servlets/historical-flight-api/prepare.sh b/servlets/historical-flight-api/prepare.sh index 5ef3b82..9fbb93c 100644 --- a/servlets/historical-flight-api/prepare.sh +++ b/servlets/historical-flight-api/prepare.sh @@ -6,12 +6,17 @@ command_exists () { command -v "$1" >/dev/null 2>&1 } +# Function to compare version numbers for "less than" +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" && test "$1" != "$2" +} + missing_deps=0 # Check for Go if ! (command_exists go); then missing_deps=1 - echo "❌ Go (supported version between 1.18 - 1.23) is not installed." + echo "❌ Go (supported version between 1.20 - 1.24) is not installed." echo "" echo "To install Go, visit the official download page:" echo "👉 https://go.dev/dl/" @@ -27,35 +32,29 @@ if ! (command_exists go); then echo "🔹 Arch Linux:" echo " sudo pacman -S go" echo "" + echo "🔹 Windows:" + echo " scoop install go" + echo "" fi -# Check for the right version of Go, needed by TinyGo (supports go 1.18 - 1.23) +# Check for the right version of Go, needed by TinyGo (supports go 1.20 - 1.24) if (command_exists go); then compat=0 - for v in `seq 18 23`; do + for v in `seq 20 24`; do if (go version | grep -q "go1.$v"); then compat=1 fi done if [ $compat -eq 0 ]; then - echo "❌ Supported Go version is not installed. Must be Go 1.18 - 1.23." + echo "❌ Supported Go version is not installed. Must be Go 1.20 - 1.24." echo "" fi fi -# Exit with a bad exit code if any dependencies are missing -if [ "$missing_deps" -ne 0 ]; then - echo "Install the missing dependencies and ensure they are on your path. Then run this command again." - # TODO: remove sleep when cli bug is fixed - sleep 2 - exit 1 -fi - - ARCH=$(arch) -# Check for TinyGo +# Check for TinyGo and its version if ! (command_exists tinygo); then missing_deps=1 echo "❌ TinyGo is not installed." @@ -70,20 +69,24 @@ if ! (command_exists tinygo); then echo " brew install tinygo" echo "" echo "🔹 Ubuntu/Debian:" - echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_$ARCH.deb" - echo " sudo dpkg -i tinygo_0.31.2_$ARCH.deb" + echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_$ARCH.deb" + echo " sudo dpkg -i tinygo_0.34.0_$ARCH.deb" echo "" echo "🔹 Arch Linux:" echo " pacman -S extra/tinygo" echo "" + echo "🔹 Windows:" + echo " scoop install tinygo" + echo "" +else + # Check TinyGo version + tinygo_version=$(tinygo version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1) + if version_lt "$tinygo_version" "0.34.0"; then + missing_deps=1 + echo "❌ TinyGo version must be >= 0.34.0 (current version: $tinygo_version)" + echo "Please update TinyGo to a newer version." + echo "" + fi fi go install golang.org/x/tools/cmd/goimports@latest - -# Exit with a bad exit code if any dependencies are missing -if [ "$missing_deps" -ne 0 ]; then - echo "Install the missing dependencies and ensure they are on your path. Then run this command again." - # TODO: remove sleep when cli bug is fixed - sleep 2 - exit 1 -fi \ No newline at end of file diff --git a/servlets/sqlite/install-wasi-sdk.sh b/servlets/sqlite/install-wasi-sdk.sh new file mode 100755 index 0000000..9a9721a --- /dev/null +++ b/servlets/sqlite/install-wasi-sdk.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Orignal from: https://github.com/Shopify/javy + +set -euo pipefail + +PATH_TO_SDK="./wasi-sdk" +if [[ ! -d $PATH_TO_SDK ]]; then + TMPGZ=$(mktemp) + VERSION_MAJOR="24" + VERSION_MINOR="0" + ARCH=$(uname -m) + if [[ "$(uname -s)" == "Darwin" ]]; then + curl --fail --location --silent https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${VERSION_MAJOR}/wasi-sdk-${VERSION_MAJOR}.${VERSION_MINOR}-${ARCH}-macos.tar.gz --output $TMPGZ + else + curl --fail --location --silent https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${VERSION_MAJOR}/wasi-sdk-${VERSION_MAJOR}.${VERSION_MINOR}-${ARCH}-linux.tar.gz --output $TMPGZ + fi + mkdir $PATH_TO_SDK + tar xf $TMPGZ -C $PATH_TO_SDK --strip-components=1 +fi diff --git a/servlets/sqlite/prepare.sh b/servlets/sqlite/prepare.sh index edafa78..c916c93 100644 --- a/servlets/sqlite/prepare.sh +++ b/servlets/sqlite/prepare.sh @@ -56,3 +56,11 @@ fi if ! (rustup target list --installed | grep -q '^wasm32-unknown-unknown$'); then rustup target add wasm32-unknown-unknown fi + +# Check for ./wasi-sdk +if ! (command_exists wasi-sdk/bin/clang); then + echo "Installing wasi-sdk." + echo "" + source ./install-wasi-sdk.sh + export PATH=$PWD/wasi-sdk/bin:$PATH +fi diff --git a/servlets/sqlite/xtp.toml b/servlets/sqlite/xtp.toml index 185f643..8612da6 100755 --- a/servlets/sqlite/xtp.toml +++ b/servlets/sqlite/xtp.toml @@ -8,7 +8,7 @@ name = "sqlite" [scripts] # xtp plugin build runs this script to generate the wasm file - build = "cargo build --release --target wasm32-wasip1" + build = 'PATH="$PWD/wasi-sdk/bin:$PATH"; cargo build --release --target wasm32-wasip1' # xtp plugin init runs this script to format the plugin code format = "cargo fmt" diff --git a/servlets/tenor-gifs/prepare.sh b/servlets/tenor-gifs/prepare.sh index 5ef3b82..9fbb93c 100644 --- a/servlets/tenor-gifs/prepare.sh +++ b/servlets/tenor-gifs/prepare.sh @@ -6,12 +6,17 @@ command_exists () { command -v "$1" >/dev/null 2>&1 } +# Function to compare version numbers for "less than" +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" && test "$1" != "$2" +} + missing_deps=0 # Check for Go if ! (command_exists go); then missing_deps=1 - echo "❌ Go (supported version between 1.18 - 1.23) is not installed." + echo "❌ Go (supported version between 1.20 - 1.24) is not installed." echo "" echo "To install Go, visit the official download page:" echo "👉 https://go.dev/dl/" @@ -27,35 +32,29 @@ if ! (command_exists go); then echo "🔹 Arch Linux:" echo " sudo pacman -S go" echo "" + echo "🔹 Windows:" + echo " scoop install go" + echo "" fi -# Check for the right version of Go, needed by TinyGo (supports go 1.18 - 1.23) +# Check for the right version of Go, needed by TinyGo (supports go 1.20 - 1.24) if (command_exists go); then compat=0 - for v in `seq 18 23`; do + for v in `seq 20 24`; do if (go version | grep -q "go1.$v"); then compat=1 fi done if [ $compat -eq 0 ]; then - echo "❌ Supported Go version is not installed. Must be Go 1.18 - 1.23." + echo "❌ Supported Go version is not installed. Must be Go 1.20 - 1.24." echo "" fi fi -# Exit with a bad exit code if any dependencies are missing -if [ "$missing_deps" -ne 0 ]; then - echo "Install the missing dependencies and ensure they are on your path. Then run this command again." - # TODO: remove sleep when cli bug is fixed - sleep 2 - exit 1 -fi - - ARCH=$(arch) -# Check for TinyGo +# Check for TinyGo and its version if ! (command_exists tinygo); then missing_deps=1 echo "❌ TinyGo is not installed." @@ -70,20 +69,24 @@ if ! (command_exists tinygo); then echo " brew install tinygo" echo "" echo "🔹 Ubuntu/Debian:" - echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_$ARCH.deb" - echo " sudo dpkg -i tinygo_0.31.2_$ARCH.deb" + echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_$ARCH.deb" + echo " sudo dpkg -i tinygo_0.34.0_$ARCH.deb" echo "" echo "🔹 Arch Linux:" echo " pacman -S extra/tinygo" echo "" + echo "🔹 Windows:" + echo " scoop install tinygo" + echo "" +else + # Check TinyGo version + tinygo_version=$(tinygo version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1) + if version_lt "$tinygo_version" "0.34.0"; then + missing_deps=1 + echo "❌ TinyGo version must be >= 0.34.0 (current version: $tinygo_version)" + echo "Please update TinyGo to a newer version." + echo "" + fi fi go install golang.org/x/tools/cmd/goimports@latest - -# Exit with a bad exit code if any dependencies are missing -if [ "$missing_deps" -ne 0 ]; then - echo "Install the missing dependencies and ensure they are on your path. Then run this command again." - # TODO: remove sleep when cli bug is fixed - sleep 2 - exit 1 -fi \ No newline at end of file diff --git a/servlets/trello/prepare.sh b/servlets/trello/prepare.sh index 52222b7..9fbb93c 100644 --- a/servlets/trello/prepare.sh +++ b/servlets/trello/prepare.sh @@ -1,16 +1,22 @@ #!/bin/bash +set -eou pipefail # Function to check if a command exists command_exists () { command -v "$1" >/dev/null 2>&1 } +# Function to compare version numbers for "less than" +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" && test "$1" != "$2" +} + missing_deps=0 # Check for Go if ! (command_exists go); then missing_deps=1 - echo "❌ Go (supported version between 1.18 - 1.23) is not installed." + echo "❌ Go (supported version between 1.20 - 1.24) is not installed." echo "" echo "To install Go, visit the official download page:" echo "👉 https://go.dev/dl/" @@ -26,27 +32,29 @@ if ! (command_exists go); then echo "🔹 Arch Linux:" echo " sudo pacman -S go" echo "" + echo "🔹 Windows:" + echo " scoop install go" + echo "" fi -# Check for the right version of Go, needed by TinyGo (supports go 1.18 - 1.23) +# Check for the right version of Go, needed by TinyGo (supports go 1.20 - 1.24) if (command_exists go); then compat=0 - for v in `seq 18 23`; do + for v in `seq 20 24`; do if (go version | grep -q "go1.$v"); then compat=1 fi done if [ $compat -eq 0 ]; then - echo "❌ Supported Go version is not installed. Must be Go 1.18 - 1.23." + echo "❌ Supported Go version is not installed. Must be Go 1.20 - 1.24." echo "" fi fi - ARCH=$(arch) -# Check for TinyGo +# Check for TinyGo and its version if ! (command_exists tinygo); then missing_deps=1 echo "❌ TinyGo is not installed." @@ -61,12 +69,24 @@ if ! (command_exists tinygo); then echo " brew install tinygo" echo "" echo "🔹 Ubuntu/Debian:" - echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_$ARCH.deb" - echo " sudo dpkg -i tinygo_0.31.2_$ARCH.deb" + echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_$ARCH.deb" + echo " sudo dpkg -i tinygo_0.34.0_$ARCH.deb" echo "" echo "🔹 Arch Linux:" echo " pacman -S extra/tinygo" echo "" + echo "🔹 Windows:" + echo " scoop install tinygo" + echo "" +else + # Check TinyGo version + tinygo_version=$(tinygo version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1) + if version_lt "$tinygo_version" "0.34.0"; then + missing_deps=1 + echo "❌ TinyGo version must be >= 0.34.0 (current version: $tinygo_version)" + echo "Please update TinyGo to a newer version." + echo "" + fi fi go install golang.org/x/tools/cmd/goimports@latest diff --git a/servlets/wordpress/prepare.sh b/servlets/wordpress/prepare.sh index 52222b7..9fbb93c 100644 --- a/servlets/wordpress/prepare.sh +++ b/servlets/wordpress/prepare.sh @@ -1,16 +1,22 @@ #!/bin/bash +set -eou pipefail # Function to check if a command exists command_exists () { command -v "$1" >/dev/null 2>&1 } +# Function to compare version numbers for "less than" +version_lt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" && test "$1" != "$2" +} + missing_deps=0 # Check for Go if ! (command_exists go); then missing_deps=1 - echo "❌ Go (supported version between 1.18 - 1.23) is not installed." + echo "❌ Go (supported version between 1.20 - 1.24) is not installed." echo "" echo "To install Go, visit the official download page:" echo "👉 https://go.dev/dl/" @@ -26,27 +32,29 @@ if ! (command_exists go); then echo "🔹 Arch Linux:" echo " sudo pacman -S go" echo "" + echo "🔹 Windows:" + echo " scoop install go" + echo "" fi -# Check for the right version of Go, needed by TinyGo (supports go 1.18 - 1.23) +# Check for the right version of Go, needed by TinyGo (supports go 1.20 - 1.24) if (command_exists go); then compat=0 - for v in `seq 18 23`; do + for v in `seq 20 24`; do if (go version | grep -q "go1.$v"); then compat=1 fi done if [ $compat -eq 0 ]; then - echo "❌ Supported Go version is not installed. Must be Go 1.18 - 1.23." + echo "❌ Supported Go version is not installed. Must be Go 1.20 - 1.24." echo "" fi fi - ARCH=$(arch) -# Check for TinyGo +# Check for TinyGo and its version if ! (command_exists tinygo); then missing_deps=1 echo "❌ TinyGo is not installed." @@ -61,12 +69,24 @@ if ! (command_exists tinygo); then echo " brew install tinygo" echo "" echo "🔹 Ubuntu/Debian:" - echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_$ARCH.deb" - echo " sudo dpkg -i tinygo_0.31.2_$ARCH.deb" + echo " wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_$ARCH.deb" + echo " sudo dpkg -i tinygo_0.34.0_$ARCH.deb" echo "" echo "🔹 Arch Linux:" echo " pacman -S extra/tinygo" echo "" + echo "🔹 Windows:" + echo " scoop install tinygo" + echo "" +else + # Check TinyGo version + tinygo_version=$(tinygo version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n1) + if version_lt "$tinygo_version" "0.34.0"; then + missing_deps=1 + echo "❌ TinyGo version must be >= 0.34.0 (current version: $tinygo_version)" + echo "Please update TinyGo to a newer version." + echo "" + fi fi go install golang.org/x/tools/cmd/goimports@latest