From 2876d4c0eddcce2e45309c04cd9ddd92cc9a5898 Mon Sep 17 00:00:00 2001 From: oskarth Date: Thu, 1 Feb 2024 11:33:40 +0800 Subject: [PATCH] fix(scripts): Move toml out of prelude to avoid catch-22 --- scripts/_prelude.sh | 11 ----------- scripts/build_android.sh | 11 +++++++++++ scripts/build_ios.sh | 11 +++++++++++ scripts/prepare_ci.sh | 9 --------- scripts/update_bindings.sh | 11 +++++++++++ 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/scripts/_prelude.sh b/scripts/_prelude.sh index 255b315f..ffae1347 100644 --- a/scripts/_prelude.sh +++ b/scripts/_prelude.sh @@ -34,15 +34,4 @@ print_action() { print_warning() { printf "\n${YELLOW}$1${DEFAULT}\n" -} - -# Check if toml-cli is installed -if ! command -v toml &> /dev/null; then - echo -e "${RED}toml (toml-cli) is not installed. Please install it to continue.${DEFAULT}" - exit 1 -fi - -# Function to read value from TOML file and remove quotes -read_toml() { - toml get "$1" "$2" | tr -d '"' } \ No newline at end of file diff --git a/scripts/build_android.sh b/scripts/build_android.sh index 51dc8842..91692bd7 100755 --- a/scripts/build_android.sh +++ b/scripts/build_android.sh @@ -3,6 +3,17 @@ # Source the script prelude source "scripts/_prelude.sh" +# Check if toml-cli is installed +if ! command -v toml &> /dev/null; then + echo -e "${RED}toml (toml-cli) is not installed. Please install it to continue.${DEFAULT}" + exit 1 +fi + +# Function to read value from TOML file and remove quotes +read_toml() { + toml get "$1" "$2" | tr -d '"' +} + # Check if a configuration file was passed as an argument if [ "$#" -ne 1 ]; then echo -e "\n${RED}Usage: $0 path/to/config.toml${DEFAULT}" diff --git a/scripts/build_ios.sh b/scripts/build_ios.sh index fa2c8837..0117abd0 100755 --- a/scripts/build_ios.sh +++ b/scripts/build_ios.sh @@ -3,6 +3,17 @@ # Source the script prelude source "scripts/_prelude.sh" +# Check if toml-cli is installed +if ! command -v toml &> /dev/null; then + echo -e "${RED}toml (toml-cli) is not installed. Please install it to continue.${DEFAULT}" + exit 1 +fi + +# Function to read value from TOML file and remove quotes +read_toml() { + toml get "$1" "$2" | tr -d '"' +} + # Check if a configuration file was passed as an argument if [ "$#" -ne 1 ]; then echo -e "\n${RED}Usage: $0 path/to/config.toml${DEFAULT}" diff --git a/scripts/prepare_ci.sh b/scripts/prepare_ci.sh index 97863d70..2f521008 100755 --- a/scripts/prepare_ci.sh +++ b/scripts/prepare_ci.sh @@ -131,13 +131,4 @@ else echo "uniffi-bindgen already installed, skipping." fi -# Install toml-cli binary -print_action "[config] Installing toml-cli..." -if ! command -v toml &> /dev/null -then - cargo install toml-cli -else - echo "toml already installed, skipping." -fi - print_action "Done! Please run ./scripts/buld_ios.sh to build for iOS." diff --git a/scripts/update_bindings.sh b/scripts/update_bindings.sh index 44da449f..d4178377 100755 --- a/scripts/update_bindings.sh +++ b/scripts/update_bindings.sh @@ -3,6 +3,17 @@ # Source the script prelude source "scripts/_prelude.sh" +# Check if toml-cli is installed +if ! command -v toml &> /dev/null; then + echo -e "${RED}toml (toml-cli) is not installed. Please install it to continue.${DEFAULT}" + exit 1 +fi + +# Function to read value from TOML file and remove quotes +read_toml() { + toml get "$1" "$2" | tr -d '"' +} + # NOTE: This is quite noisy so turning off by default # Coloring the -x output (commands) DEBUG_COLOR="${DEFAULT}"