From 4480dca6d31b5a234667a94dab105faaae22b70e Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Wed, 11 Dec 2024 11:28:43 +0100 Subject: [PATCH 01/31] wip --- starknetup.sh | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 starknetup.sh diff --git a/starknetup.sh b/starknetup.sh new file mode 100755 index 0000000..dc99e28 --- /dev/null +++ b/starknetup.sh @@ -0,0 +1,82 @@ +#!/bin/sh +# shellcheck shell=dash + +set -eu + +ASDF_REPO="https://github.com/asdf-vm/asdf" + +main() { + assert_dependencies + assert_not_installed "scarb" "starknet-foundry" + install_asdf_plugins "scarb" "starknet-foundry" + install_latest_versions "scarb" "starknet-foundry" + set_global_versions "scarb" "starknet-foundry" + say "Starknet tools installed successfully." +} + +assert_dependencies() { + need_cmd curl + need_cmd git + + if ! check_cmd asdf; then + err "asdf-vm is required. Please refer to ${ASDF_REPO} for installation instructions." + fi +} + +assert_not_installed() { + for tool in "$@"; do + if check_cmd "$tool"; then + warn "$tool is already installed. Please uninstall it before running this script." + warn "For more information, refer to the documentation: https://docs.starknet.io/documentation/" + fi + done +} + +install_asdf_plugins() { + for plugin in "$@"; do + if ! asdf plugin list | grep -q "$plugin"; then + ensure asdf plugin add "$plugin" + fi + done +} + +install_latest_versions() { + for tool in "$@"; do + ensure asdf install "$tool" latest + done +} + +set_global_versions() { + for tool in "$@"; do + ensure asdf global "$tool" latest + done +} + +say() { + printf 'starknetup: %s\n' "$1" +} + +warn() { + say "Warning: $1" >&2 +} + +err() { + say "$1" >&2 + exit 1 +} + +need_cmd() { + if ! check_cmd "$1"; then + err "need '$1' (command not found)" + fi +} + +check_cmd() { + command -v "$1" > /dev/null 2>&1 +} + +ensure() { + if ! "$@"; then err "command failed: $*"; fi +} + +main "$@" || exit 1 From 5b513bce0cc9dc71231955e567bc0ad11eb85cf6 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Wed, 11 Dec 2024 17:44:18 +0100 Subject: [PATCH 02/31] Include uninstall docs for 'scarb' and 'starknet-foundry' --- starknetup.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index dc99e28..758c157 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -4,10 +4,13 @@ set -eu ASDF_REPO="https://github.com/asdf-vm/asdf" +SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" +STARKNET_FOUNDRY_UNINSTALL_DOCS="" main() { assert_dependencies - assert_not_installed "scarb" "starknet-foundry" + assert_not_installed "scarb" $SCARB_UNINSTALL_DOCS + assert_not_installed "starknet-foundry" $STARKNET_FOUNDRY_UNINSTALL_DOCS install_asdf_plugins "scarb" "starknet-foundry" install_latest_versions "scarb" "starknet-foundry" set_global_versions "scarb" "starknet-foundry" @@ -24,12 +27,14 @@ assert_dependencies() { } assert_not_installed() { - for tool in "$@"; do + local tool="$1" + local uninstall_docs_url="$2" + + if ! asdf which "$tool" > /dev/null 2>&1; then if check_cmd "$tool"; then - warn "$tool is already installed. Please uninstall it before running this script." - warn "For more information, refer to the documentation: https://docs.starknet.io/documentation/" + err "$tool is already installed outside of asdf. Please uninstall it and re-run this script again. For more information, refer to the documentation: $uninstall_docs_url" fi - done + fi } install_asdf_plugins() { From ba89422b687426fb51abc7986695b1ddfe01916b Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Wed, 11 Dec 2024 18:23:45 +0100 Subject: [PATCH 03/31] Improve plugin installation; Misc --- starknetup.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index 758c157..378fc48 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -5,13 +5,14 @@ set -eu ASDF_REPO="https://github.com/asdf-vm/asdf" SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" -STARKNET_FOUNDRY_UNINSTALL_DOCS="" +STARKNET_FOUNDRY_UNINSTALL_DOCS="PENDING" main() { assert_dependencies assert_not_installed "scarb" $SCARB_UNINSTALL_DOCS assert_not_installed "starknet-foundry" $STARKNET_FOUNDRY_UNINSTALL_DOCS - install_asdf_plugins "scarb" "starknet-foundry" + install_asdf_plugin "scarb" + install_asdf_plugin "starknet-foundry" install_latest_versions "scarb" "starknet-foundry" set_global_versions "scarb" "starknet-foundry" say "Starknet tools installed successfully." @@ -37,12 +38,13 @@ assert_not_installed() { fi } -install_asdf_plugins() { - for plugin in "$@"; do - if ! asdf plugin list | grep -q "$plugin"; then - ensure asdf plugin add "$plugin" - fi - done +install_asdf_plugin() { + local plugin="$1" + if asdf plugin list | grep -q "$plugin"; then + ensure asdf plugin update "$plugin" + else + ensure asdf plugin add "$plugin" + fi } install_latest_versions() { From e4771edd7de9c78c1a1260a5cf9c4aa2aa13e072 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Wed, 11 Dec 2024 18:41:44 +0100 Subject: [PATCH 04/31] Add bold info messages on supported platforms --- starknetup.sh | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index 378fc48..befa53a 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -7,7 +7,11 @@ ASDF_REPO="https://github.com/asdf-vm/asdf" SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" STARKNET_FOUNDRY_UNINSTALL_DOCS="PENDING" +ANSI_ESCAPES_ARE_VALID=false + main() { + determine_ansi_escapes_valid + assert_dependencies assert_not_installed "scarb" $SCARB_UNINSTALL_DOCS assert_not_installed "starknet-foundry" $STARKNET_FOUNDRY_UNINSTALL_DOCS @@ -18,6 +22,18 @@ main() { say "Starknet tools installed successfully." } +determine_ansi_escapes_valid() { + if [ -t 2 ]; then + if [ "${TERM+set}" = 'set' ]; then + case "$TERM" in + xterm*|rxvt*|urxvt*|linux*|vt*) + ANSI_ESCAPES_ARE_VALID=true + ;; + esac + fi + fi +} + assert_dependencies() { need_cmd curl need_cmd git @@ -60,15 +76,27 @@ set_global_versions() { } say() { - printf 'starknetup: %s\n' "$1" + if $ANSI_ESCAPES_ARE_VALID; then + printf "\033[1mstarknetup:\033[0m %s\n" "$1" + else + printf "starknetup: %s\n" "$1" + fi } warn() { - say "Warning: $1" >&2 + if $ANSI_ESCAPES_ARE_VALID; then + printf "\033[1mstarknetup: warn:\033[0m %s\n" "$1" >&2 + else + printf "starknetup: warn: %s\n" "$1" >&2 + fi } err() { - say "$1" >&2 + if $ANSI_ESCAPES_ARE_VALID; then + printf "\033[1mstarknetup: error:\033[0m %s\n" "$1" >&2 + else + printf "starknetup: error: %s\n" "$1" >&2 + fi exit 1 } From abb7286f144d7fe929bc5a4e86a9f9092f9c01d9 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Wed, 11 Dec 2024 18:45:00 +0100 Subject: [PATCH 05/31] Replace bulk installation with individual version installation --- starknetup.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index befa53a..f7e13e1 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -17,7 +17,8 @@ main() { assert_not_installed "starknet-foundry" $STARKNET_FOUNDRY_UNINSTALL_DOCS install_asdf_plugin "scarb" install_asdf_plugin "starknet-foundry" - install_latest_versions "scarb" "starknet-foundry" + install_latest_version "scarb" + install_latest_version "starknet-foundry" set_global_versions "scarb" "starknet-foundry" say "Starknet tools installed successfully." } @@ -63,10 +64,9 @@ install_asdf_plugin() { fi } -install_latest_versions() { - for tool in "$@"; do - ensure asdf install "$tool" latest - done +install_latest_version() { + local tool="$1" + ensure asdf install "$tool" latest } set_global_versions() { From bd3beddf5affb091cb023ab5d75cb1b016cd4322 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Wed, 11 Dec 2024 18:50:12 +0100 Subject: [PATCH 06/31] Refactor global version setting --- starknetup.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index f7e13e1..4a529ee 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -19,7 +19,8 @@ main() { install_asdf_plugin "starknet-foundry" install_latest_version "scarb" install_latest_version "starknet-foundry" - set_global_versions "scarb" "starknet-foundry" + set_global_version "scarb" + set_global_version "starknet-foundry" say "Starknet tools installed successfully." } @@ -69,10 +70,9 @@ install_latest_version() { ensure asdf install "$tool" latest } -set_global_versions() { - for tool in "$@"; do - ensure asdf global "$tool" latest - done +set_global_version() { + local tool="$1" + ensure asdf global "$tool" latest } say() { From eb3222a28655a66613d9a328e8348ad707ed3dfe Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Wed, 11 Dec 2024 19:11:21 +0100 Subject: [PATCH 07/31] Reinstall foundry to ensure latest version of USC is installed --- starknetup.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/starknetup.sh b/starknetup.sh index 4a529ee..ee5a0d1 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -18,6 +18,8 @@ main() { install_asdf_plugin "scarb" install_asdf_plugin "starknet-foundry" install_latest_version "scarb" + # Reinstall to ensure latest version of USC is installed + uninstall_latest_version "starknet-foundry" install_latest_version "starknet-foundry" set_global_version "scarb" set_global_version "starknet-foundry" @@ -70,6 +72,12 @@ install_latest_version() { ensure asdf install "$tool" latest } +uninstall_latest_version() { + local tool="$1" + local latest_version=$(asdf latest "$tool") + ensure asdf uninstall "$tool" "$latest_version" +} + set_global_version() { local tool="$1" ensure asdf global "$tool" latest From e2acb492dab2081a1db6dcc7cdd1849f53a36b1f Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Wed, 11 Dec 2024 19:19:51 +0100 Subject: [PATCH 08/31] refactor --- starknetup.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index ee5a0d1..b94729b 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -13,17 +13,22 @@ main() { determine_ansi_escapes_valid assert_dependencies + assert_not_installed "scarb" $SCARB_UNINSTALL_DOCS assert_not_installed "starknet-foundry" $STARKNET_FOUNDRY_UNINSTALL_DOCS - install_asdf_plugin "scarb" + + install_asdf_plugin "scarb" install_asdf_plugin "starknet-foundry" install_latest_version "scarb" + # Reinstall to ensure latest version of USC is installed uninstall_latest_version "starknet-foundry" install_latest_version "starknet-foundry" + set_global_version "scarb" set_global_version "starknet-foundry" - say "Starknet tools installed successfully." + + say "Starknet tools installed successfully." } determine_ansi_escapes_valid() { From 8492df38dce3d76dbd1595f72be64118fe706f68 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Wed, 11 Dec 2024 19:20:19 +0100 Subject: [PATCH 09/31] refactor --- starknetup.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index b94729b..3f5560c 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -15,17 +15,15 @@ main() { assert_dependencies assert_not_installed "scarb" $SCARB_UNINSTALL_DOCS - assert_not_installed "starknet-foundry" $STARKNET_FOUNDRY_UNINSTALL_DOCS - install_asdf_plugin "scarb" - install_asdf_plugin "starknet-foundry" install_latest_version "scarb" + set_global_version "scarb" + assert_not_installed "starknet-foundry" $STARKNET_FOUNDRY_UNINSTALL_DOCS + install_asdf_plugin "starknet-foundry" # Reinstall to ensure latest version of USC is installed uninstall_latest_version "starknet-foundry" install_latest_version "starknet-foundry" - - set_global_version "scarb" set_global_version "starknet-foundry" say "Starknet tools installed successfully." From 7b97b9a680ec9c833bc9be5b796b03e4fa41731d Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Fri, 13 Dec 2024 13:04:08 +0100 Subject: [PATCH 10/31] wip --- starknetup.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index 3f5560c..753d8f8 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -25,8 +25,6 @@ main() { uninstall_latest_version "starknet-foundry" install_latest_version "starknet-foundry" set_global_version "starknet-foundry" - - say "Starknet tools installed successfully." } determine_ansi_escapes_valid() { @@ -94,14 +92,6 @@ say() { fi } -warn() { - if $ANSI_ESCAPES_ARE_VALID; then - printf "\033[1mstarknetup: warn:\033[0m %s\n" "$1" >&2 - else - printf "starknetup: warn: %s\n" "$1" >&2 - fi -} - err() { if $ANSI_ESCAPES_ARE_VALID; then printf "\033[1mstarknetup: error:\033[0m %s\n" "$1" >&2 From b8e5bbe896717194133ca50e557ea0497162aa79 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Fri, 13 Dec 2024 13:56:27 +0100 Subject: [PATCH 11/31] wip --- starknetup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/starknetup.sh b/starknetup.sh index 753d8f8..0c1de51 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -25,6 +25,8 @@ main() { uninstall_latest_version "starknet-foundry" install_latest_version "starknet-foundry" set_global_version "starknet-foundry" + + say "Installation complete" } determine_ansi_escapes_valid() { From b97cd29830d1012586cb5f69bb2dfab852c380b1 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Fri, 13 Dec 2024 16:27:15 +0100 Subject: [PATCH 12/31] Add version and help args --- starknetup.sh | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index 0c1de51..ea97a8e 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -6,27 +6,56 @@ set -eu ASDF_REPO="https://github.com/asdf-vm/asdf" SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" STARKNET_FOUNDRY_UNINSTALL_DOCS="PENDING" +SCRIPT_VERSION="0.1.0" ANSI_ESCAPES_ARE_VALID=false +usage() { + cat < /dev/null 2>&1; then if check_cmd "$tool"; then - err "$tool is already installed outside of asdf. Please uninstall it and re-run this script again. For more information, refer to the documentation: $uninstall_docs_url" + err "$tool is already installed outside of asdf. Please uninstall it and re-run this script. Refer to $uninstall_docs_url" fi fi } @@ -77,7 +105,8 @@ install_latest_version() { uninstall_latest_version() { local tool="$1" - local latest_version=$(asdf latest "$tool") + local latest_version + latest_version=$(asdf latest "$tool") ensure asdf uninstall "$tool" "$latest_version" } @@ -117,4 +146,4 @@ ensure() { if ! "$@"; then err "command failed: $*"; fi } -main "$@" || exit 1 +main "$@" || exit 1 \ No newline at end of file From a095e67f20a0c883f04ab070b3fc3b9109012522 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Fri, 13 Dec 2024 16:28:20 +0100 Subject: [PATCH 13/31] wip --- starknetup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index ea97a8e..d7c349c 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -45,12 +45,12 @@ main() { assert_dependencies assert_not_installed "scarb" $SCARB_UNINSTALL_DOCS - install_asdf_plugin "scarb" + install_latest_asdf_plugin "scarb" install_latest_version "scarb" set_global_version "scarb" assert_not_installed "starknet-foundry" $STARKNET_FOUNDRY_UNINSTALL_DOCS - install_asdf_plugin "starknet-foundry" + install_latest_asdf_plugin "starknet-foundry" uninstall_latest_version "starknet-foundry" install_latest_version "starknet-foundry" set_global_version "starknet-foundry" @@ -89,7 +89,7 @@ assert_not_installed() { fi } -install_asdf_plugin() { +install_latest_asdf_plugin() { local plugin="$1" if asdf plugin list | grep -q "$plugin"; then ensure asdf plugin update "$plugin" From 92ce4a10afeac8b2cba35598c53b0d6844d4e0c6 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Fri, 13 Dec 2024 16:33:22 +0100 Subject: [PATCH 14/31] wip --- starknetup.sh | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index d7c349c..0fb72dd 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -8,8 +8,6 @@ SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" STARKNET_FOUNDRY_UNINSTALL_DOCS="PENDING" SCRIPT_VERSION="0.1.0" -ANSI_ESCAPES_ARE_VALID=false - usage() { cat <&2 - else - printf "starknetup: error: %s\n" "$1" >&2 - fi + say "$1" >&2 exit 1 } @@ -146,4 +122,4 @@ ensure() { if ! "$@"; then err "command failed: $*"; fi } -main "$@" || exit 1 \ No newline at end of file +main "$@" || exit 1 From 5c0d9474e702e038ee68e851056510594ffdd8fd Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Fri, 13 Dec 2024 20:21:47 +0100 Subject: [PATCH 15/31] Fix `uninstall_latest_version` --- starknetup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/starknetup.sh b/starknetup.sh index 0fb72dd..8b1fa1c 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -91,7 +91,10 @@ uninstall_latest_version() { local tool="$1" local latest_version latest_version=$(asdf latest "$tool") - ensure asdf uninstall "$tool" "$latest_version" + + if asdf list "$tool" "^${latest_version}$" >/dev/null 2>&1; then + ensure asdf uninstall "$tool" "$latest_version" + fi } set_global_version() { From 4cd9a6b4f0655811ae69651cf3b79b911feaf10e Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Fri, 13 Dec 2024 20:21:59 +0100 Subject: [PATCH 16/31] Add interactive installation for asdf-vm --- starknetup.sh | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/starknetup.sh b/starknetup.sh index 8b1fa1c..484ffbc 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -8,6 +8,9 @@ SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" STARKNET_FOUNDRY_UNINSTALL_DOCS="PENDING" SCRIPT_VERSION="0.1.0" +LOCAL_BIN="${HOME}/.local/bin" +LOCAL_BIN_ESCAPED="\$HOME/.local/bin" + usage() { cat <>"$_profile" && echo ". \$HOME/.asdf/asdf.sh" >>"$_profile" + echo >>"$_profile" && echo ". \$HOME/.asdf/completions/asdf.bash" >>"$_profile" + printf "asdf-vm has been installed. Please restart your shell for the changes to take effect.\n" + exit 0 + ;; + * ) + err "asdf-vm is required. Please install it manually and re-run this script. Refer to ${ASDF_REPO} for installation instructions." + ;; + esac + else + err "asdf-vm is required. Please install it manually and re-run this script. Refer to ${ASDF_REPO} for installation instructions." + fi +} + main "$@" || exit 1 From 6434249983b6728e120dcd8e63f0185cba55fcc6 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Fri, 13 Dec 2024 21:03:06 +0100 Subject: [PATCH 17/31] update description --- starknetup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknetup.sh b/starknetup.sh index 484ffbc..df0d82f 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -13,7 +13,7 @@ LOCAL_BIN_ESCAPED="\$HOME/.local/bin" usage() { cat < Date: Fri, 13 Dec 2024 21:03:31 +0100 Subject: [PATCH 18/31] update shell-based installation instructions --- starknetup.sh | 62 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index df0d82f..90d4d25 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -131,39 +131,83 @@ ensure() { install_asdf_interactively() { local _profile local _pref_shell + local _asdf_dir="$HOME/.asdf" + case ${SHELL:-""} in */zsh) _profile=$HOME/.zshrc _pref_shell=zsh ;; + */fish) + _profile=$HOME/.config/fish/config.fish + _pref_shell=fish + ;; + */elvish) + _profile=$HOME/.config/elvish/rc.elv + _pref_shell=elvish + ;; + */pwsh) + _profile=$HOME/.config/powershell/profile.ps1 + _pref_shell=pwsh + ;; + */nu) + _profile=$HOME/.config/nushell/config.nu + _pref_shell=nu + ;; */ash) _profile=$HOME/.profile _pref_shell=ash ;; */bash) - _profile=$HOME/.bashrc + if [ "$(uname)" = "Darwin" ]; then + _profile=$HOME/.bash_profile + else + _profile=$HOME/.bashrc + fi _pref_shell=bash ;; - */fish) - _profile=$HOME/.config/fish/config.fish - _pref_shell=fish - ;; *) err "could not detect shell, manually add '${LOCAL_BIN_ESCAPED}' to your PATH." ;; esac if [ -n "$_profile" ]; then + if [ ! -f "$_profile" ]; then + touch "$_profile" + fi + printf "asdf-vm is required. Do you want to install it now? (y/N): " read -r answer case $answer in [Yy]* ) printf "Installing asdf-vm...\n" - git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3 - echo >>"$_profile" && echo ". \$HOME/.asdf/asdf.sh" >>"$_profile" - echo >>"$_profile" && echo ". \$HOME/.asdf/completions/asdf.bash" >>"$_profile" + git clone https://github.com/asdf-vm/asdf.git "$_asdf_dir" --branch v0.14.1 + + case $_pref_shell in + zsh|bash|ash) + echo >>"$_profile" && echo ". ${_asdf_dir}/asdf.sh" >>"$_profile" + echo >>"$_profile" && echo ". ${_asdf_dir}/completions/asdf.bash" >>"$_profile" + ;; + fish) + echo >>"$_profile" && echo "source ${_asdf_dir}/asdf.fish" >>"$_profile" + mkdir -p "$HOME/.config/fish/completions" + ln -s "${_asdf_dir}/completions/asdf.fish" "$HOME/.config/fish/completions" + ;; + elvish) + echo >>"$_profile" && echo "use asdf _asdf; var asdf~ = $_asdf:asdf~" >>"$_profile" + echo >>"$_profile" && echo "set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~" >>"$_profile" + ;; + pwsh) + echo >>"$_profile" && echo ". '${_asdf_dir}/asdf.ps1'" >>"$_profile" + ;; + nu) + echo >>"$_profile" && echo "\$env.ASDF_DIR = '${_asdf_dir}'" >>"$_profile" + echo >>"$_profile" && echo "source '${_asdf_dir}/asdf.nu'" >>"$_profile" + ;; + esac + printf "asdf-vm has been installed. Please restart your shell for the changes to take effect.\n" - exit 0 + exit 0 ;; * ) err "asdf-vm is required. Please install it manually and re-run this script. Refer to ${ASDF_REPO} for installation instructions." From 503ee7e1ede55fe6a87ae7b7d71d28bf3467e6b2 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Fri, 13 Dec 2024 21:11:50 +0100 Subject: [PATCH 19/31] Drop support for all shels except bash, zshrc, ash --- starknetup.sh | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index 90d4d25..7c02474 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -138,22 +138,6 @@ install_asdf_interactively() { _profile=$HOME/.zshrc _pref_shell=zsh ;; - */fish) - _profile=$HOME/.config/fish/config.fish - _pref_shell=fish - ;; - */elvish) - _profile=$HOME/.config/elvish/rc.elv - _pref_shell=elvish - ;; - */pwsh) - _profile=$HOME/.config/powershell/profile.ps1 - _pref_shell=pwsh - ;; - */nu) - _profile=$HOME/.config/nushell/config.nu - _pref_shell=nu - ;; */ash) _profile=$HOME/.profile _pref_shell=ash @@ -167,7 +151,7 @@ install_asdf_interactively() { _pref_shell=bash ;; *) - err "could not detect shell, manually add '${LOCAL_BIN_ESCAPED}' to your PATH." + err "asdf-vm is required. Please install it manually and re-run this script. Refer to ${ASDF_REPO} for installation instructions." ;; esac @@ -188,22 +172,6 @@ install_asdf_interactively() { echo >>"$_profile" && echo ". ${_asdf_dir}/asdf.sh" >>"$_profile" echo >>"$_profile" && echo ". ${_asdf_dir}/completions/asdf.bash" >>"$_profile" ;; - fish) - echo >>"$_profile" && echo "source ${_asdf_dir}/asdf.fish" >>"$_profile" - mkdir -p "$HOME/.config/fish/completions" - ln -s "${_asdf_dir}/completions/asdf.fish" "$HOME/.config/fish/completions" - ;; - elvish) - echo >>"$_profile" && echo "use asdf _asdf; var asdf~ = $_asdf:asdf~" >>"$_profile" - echo >>"$_profile" && echo "set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~" >>"$_profile" - ;; - pwsh) - echo >>"$_profile" && echo ". '${_asdf_dir}/asdf.ps1'" >>"$_profile" - ;; - nu) - echo >>"$_profile" && echo "\$env.ASDF_DIR = '${_asdf_dir}'" >>"$_profile" - echo >>"$_profile" && echo "source '${_asdf_dir}/asdf.nu'" >>"$_profile" - ;; esac printf "asdf-vm has been installed. Please restart your shell for the changes to take effect.\n" From 12b03c5588328722206f50dab3ec468411fe44a9 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Fri, 13 Dec 2024 21:14:54 +0100 Subject: [PATCH 20/31] Update asdf-vm installation instructions to use new documentation link --- starknetup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index 7c02474..b5fe7eb 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -3,7 +3,7 @@ set -eu -ASDF_REPO="https://github.com/asdf-vm/asdf" +ASDF_INSTALL_DOCS="https://asdf-vm.com/guide/getting-started.html" SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" STARKNET_FOUNDRY_UNINSTALL_DOCS="PENDING" SCRIPT_VERSION="0.1.0" @@ -151,7 +151,7 @@ install_asdf_interactively() { _pref_shell=bash ;; *) - err "asdf-vm is required. Please install it manually and re-run this script. Refer to ${ASDF_REPO} for installation instructions." + err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." ;; esac @@ -178,11 +178,11 @@ install_asdf_interactively() { exit 0 ;; * ) - err "asdf-vm is required. Please install it manually and re-run this script. Refer to ${ASDF_REPO} for installation instructions." + err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." ;; esac else - err "asdf-vm is required. Please install it manually and re-run this script. Refer to ${ASDF_REPO} for installation instructions." + err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." fi } From bedaacf3c77d81757b86637d4f3bb68dc57f8811 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Mon, 16 Dec 2024 13:14:11 +0100 Subject: [PATCH 21/31] wip --- starknetup.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index b5fe7eb..af5e94d 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -8,8 +8,6 @@ SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" STARKNET_FOUNDRY_UNINSTALL_DOCS="PENDING" SCRIPT_VERSION="0.1.0" -LOCAL_BIN="${HOME}/.local/bin" -LOCAL_BIN_ESCAPED="\$HOME/.local/bin" usage() { cat <>"$_profile" && echo ". ${_asdf_dir}/asdf.sh" >>"$_profile" - echo >>"$_profile" && echo ". ${_asdf_dir}/completions/asdf.bash" >>"$_profile" ;; esac - printf "asdf-vm has been installed. Please restart your shell for the changes to take effect.\n" + printf "asdf-vm has been installed. Run 'source ${_profile}' or start a new terminal session and re-run this script.\n" exit 0 ;; * ) From 6d12210e4455cb897ac9eef429c7681ec64623e3 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Mon, 16 Dec 2024 13:17:59 +0100 Subject: [PATCH 22/31] misc --- starknetup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index af5e94d..6b50050 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -129,7 +129,7 @@ ensure() { install_asdf_interactively() { local _profile local _pref_shell - local _asdf_dir="$HOME/.asdf" + local _asdf_path="$HOME/.asdf" case ${SHELL:-""} in */zsh) @@ -163,11 +163,11 @@ install_asdf_interactively() { case $answer in [Yy]* ) printf "Installing asdf-vm...\n" - git clone https://github.com/asdf-vm/asdf.git "$_asdf_dir" --branch v0.14.1 + git clone https://github.com/asdf-vm/asdf.git "$_asdf_path" --branch v0.14.1 case $_pref_shell in zsh|bash|ash) - echo >>"$_profile" && echo ". ${_asdf_dir}/asdf.sh" >>"$_profile" + echo >>"$_profile" && echo ". ${_asdf_path}/asdf.sh" >>"$_profile" ;; esac From 940a5cbae348976443e48719b2eac0825e0dc9ea Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Mon, 16 Dec 2024 13:20:59 +0100 Subject: [PATCH 23/31] Add basic CI --- .github/workflows/ci.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6dbdc76 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y curl git + + - name: Setup asdf + uses: asdf-vm/actions/setup@v3.0.2 + + - name: Run starknetup + run: | + ./starknetup.sh + scarb --version + snforge --version + universal-sierra-compiler --version From 9230a1ffb9c92c2a8917e143e4dd958b90b1c6a2 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Mon, 16 Dec 2024 13:28:28 +0100 Subject: [PATCH 24/31] Update CI --- .github/workflows/ci.yml | 82 ++++++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6dbdc76..170b134 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,22 +8,72 @@ on: jobs: test: + name: test ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y curl git + + - name: Setup asdf + uses: asdf-vm/actions/setup@v3.0.2 + + - name: Fetch latest Scarb version from GitHub releases + id: scarb_version + shell: pwsh + run: | + $location = (Invoke-WebRequest -Uri "https://github.com/software-mansion/scarb/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location + $latest_version = ($location -replace '^.*/v','') + echo "Latest Scarb version found is $latest_version" + echo "LATEST_SCARB_VERSION=$latest_version" >> $env:GITHUB_OUTPUT + + - name: Fetch latest Starknet Foundry version from GitHub releases + id: foundry_version + shell: pwsh + run: | + $location = (Invoke-WebRequest -Uri "https://github.com/foundry-rs/starknet-foundry/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location + $latest_version = ($location -replace '^.*/v','') + echo "Latest Starknet Foundry version found is $latest_version" + echo "LATEST_SNFOUNDRY_VERSION=$latest_version" >> $env:GITHUB_OUTPUT + + - name: Fetch latest Universal Sierra Compiler version from GitHub releases + id: usc_version + shell: pwsh + run: | + $location = (Invoke-WebRequest -Uri "https://github.com/software-mansion/universal-sierra-compiler/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location + $latest_version = ($location -replace '^.*/v','') + echo "Latest Universal Sierra Compiler version found is $latest_version" + echo "LATEST_USC_VERSION=$latest_version" >> $env:GITHUB_OUTPUT + + - name: Run starknetup + run: ./starknetup.sh + + - name: Check Scarb latest + run: scarb --version | grep "scarb ${{ steps.scarb_version.outputs.LATEST_SCARB_VERSION }}" + + - name: Check Starknet Foundry latest + run: snforge --version | grep "${{ steps.foundry_version.outputs.LATEST_SNFOUNDRY_VERSION }}" + + - name: Check Universal Sierra Compiler latest + run: universal-sierra-compiler --version | grep "${{ steps.usc_version.outputs.LATEST_USC_VERSION }}" + + shellcheck: runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: shellcheck bin/* lib/* + shfmt: + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y curl git - - - name: Setup asdf - uses: asdf-vm/actions/setup@v3.0.2 - - - name: Run starknetup - run: | - ./starknetup.sh - scarb --version - snforge --version - universal-sierra-compiler --version + - uses: mfinelli/setup-shfmt@v3 + - uses: actions/checkout@v4 + - run: shfmt --diff . From d35a563ea3136d31e7d9c0fe816f3fc1e6c82193 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Mon, 16 Dec 2024 13:42:10 +0100 Subject: [PATCH 25/31] Fix format checks --- .github/workflows/ci.yml | 4 +- starknetup.sh | 246 +++++++++++++++++++-------------------- 2 files changed, 124 insertions(+), 126 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 170b134..94e51ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,11 +69,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: shellcheck bin/* lib/* + - run: shellcheck starknetup.sh shfmt: runs-on: ubuntu-latest steps: - uses: mfinelli/setup-shfmt@v3 - uses: actions/checkout@v4 - - run: shfmt --diff . + - run: shfmt --diff starknetup.sh diff --git a/starknetup.sh b/starknetup.sh index 6b50050..28843b1 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -8,9 +8,8 @@ SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" STARKNET_FOUNDRY_UNINSTALL_DOCS="PENDING" SCRIPT_VERSION="0.1.0" - usage() { - cat < /dev/null 2>&1; then - if check_cmd "$tool"; then - err "$tool is already installed outside of asdf. Please uninstall it and re-run this script. Refer to $uninstall_docs_url" - fi - fi + local tool="$1" + local uninstall_docs_url="$2" + + if ! asdf which "$tool" >/dev/null 2>&1; then + if check_cmd "$tool"; then + err "$tool is already installed outside of asdf. Please uninstall it and re-run this script. Refer to $uninstall_docs_url" + fi + fi } install_latest_asdf_plugin() { - local plugin="$1" - if asdf plugin list | grep -q "$plugin"; then - ensure asdf plugin update "$plugin" - else - ensure asdf plugin add "$plugin" - fi + local plugin="$1" + if asdf plugin list | grep -q "$plugin"; then + ensure asdf plugin update "$plugin" + else + ensure asdf plugin add "$plugin" + fi } install_latest_version() { - local tool="$1" - ensure asdf install "$tool" latest + local tool="$1" + ensure asdf install "$tool" latest } uninstall_latest_version() { - local tool="$1" - local latest_version - latest_version=$(asdf latest "$tool") - - if asdf list "$tool" "^${latest_version}$" >/dev/null 2>&1; then - ensure asdf uninstall "$tool" "$latest_version" - fi + local tool="$1" + local latest_version + latest_version=$(asdf latest "$tool") + + if asdf list "$tool" "^${latest_version}$" >/dev/null 2>&1; then + ensure asdf uninstall "$tool" "$latest_version" + fi } set_global_version() { - local tool="$1" - ensure asdf global "$tool" latest + local tool="$1" + ensure asdf global "$tool" latest } say() { - printf "starknetup: %s\n" "$1" + printf "starknetup: %s\n" "$1" } err() { - say "$1" >&2 - exit 1 + say "$1" >&2 + exit 1 } need_cmd() { - if ! check_cmd "$1"; then - err "need '$1' (command not found)" - fi + if ! check_cmd "$1"; then + err "need '$1' (command not found)" + fi } check_cmd() { - command -v "$1" > /dev/null 2>&1 + command -v "$1" >/dev/null 2>&1 } ensure() { - if ! "$@"; then err "command failed: $*"; fi + if ! "$@"; then err "command failed: $*"; fi } install_asdf_interactively() { - local _profile - local _pref_shell - local _asdf_path="$HOME/.asdf" - - case ${SHELL:-""} in - */zsh) - _profile=$HOME/.zshrc - _pref_shell=zsh - ;; - */ash) - _profile=$HOME/.profile - _pref_shell=ash - ;; - */bash) - if [ "$(uname)" = "Darwin" ]; then - _profile=$HOME/.bash_profile - else - _profile=$HOME/.bashrc - fi - _pref_shell=bash - ;; - *) - err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." - ;; - esac - - if [ -n "$_profile" ]; then - if [ ! -f "$_profile" ]; then - touch "$_profile" - fi - - printf "asdf-vm is required. Do you want to install it now? (y/N): " - read -r answer - case $answer in - [Yy]* ) - printf "Installing asdf-vm...\n" - git clone https://github.com/asdf-vm/asdf.git "$_asdf_path" --branch v0.14.1 - - case $_pref_shell in - zsh|bash|ash) - echo >>"$_profile" && echo ". ${_asdf_path}/asdf.sh" >>"$_profile" - ;; - esac - - printf "asdf-vm has been installed. Run 'source ${_profile}' or start a new terminal session and re-run this script.\n" - exit 0 - ;; - * ) - err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." - ;; - esac - else - err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." - fi + local _profile + local _pref_shell + local _asdf_path="$HOME/.asdf" + + case ${SHELL:-""} in + */zsh) + _profile=$HOME/.zshrc + _pref_shell=zsh + ;; + */ash) + _profile=$HOME/.profile + _pref_shell=ash + ;; + */bash) + if [ "$(uname)" = "Darwin" ]; then + _profile=$HOME/.bash_profile + else + _profile=$HOME/.bashrc + fi + _pref_shell=bash + ;; + *) + err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." + ;; + esac + + if [ -n "$_profile" ]; then + if [ ! -f "$_profile" ]; then + touch "$_profile" + fi + + printf "asdf-vm is required. Do you want to install it now? (y/N): " + read -r answer + case $answer in + [Yy]*) + printf "Installing asdf-vm...\n" + git clone https://github.com/asdf-vm/asdf.git "$_asdf_path" --branch v0.14.1 + + case $_pref_shell in + zsh | bash | ash) + echo >>"$_profile" && echo ". ${_asdf_path}/asdf.sh" >>"$_profile" + ;; + esac + + printf "asdf-vm has been installed. Run 'source %s' or start a new terminal session and re-run this script.\n" "$_profile" + exit 0 + ;; + *) + err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." + ;; + esac + else + err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." + fi } main "$@" || exit 1 From 491aded2734292f6340b21ef8e50ef06d003ce9a Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Mon, 16 Dec 2024 13:52:23 +0100 Subject: [PATCH 26/31] improve ci --- .github/workflows/ci.yml | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94e51ee..b399a07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,13 +18,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y curl git - - name: Setup asdf - uses: asdf-vm/actions/setup@v3.0.2 + uses: asdf-vm/actions/setup@v3 - name: Fetch latest Scarb version from GitHub releases id: scarb_version @@ -33,16 +28,16 @@ jobs: $location = (Invoke-WebRequest -Uri "https://github.com/software-mansion/scarb/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location $latest_version = ($location -replace '^.*/v','') echo "Latest Scarb version found is $latest_version" - echo "LATEST_SCARB_VERSION=$latest_version" >> $env:GITHUB_OUTPUT + echo "LATEST=$latest_version" >> $env:GITHUB_OUTPUT - name: Fetch latest Starknet Foundry version from GitHub releases - id: foundry_version + id: snfoundry_version shell: pwsh run: | $location = (Invoke-WebRequest -Uri "https://github.com/foundry-rs/starknet-foundry/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location $latest_version = ($location -replace '^.*/v','') echo "Latest Starknet Foundry version found is $latest_version" - echo "LATEST_SNFOUNDRY_VERSION=$latest_version" >> $env:GITHUB_OUTPUT + echo "LATEST=$latest_version" >> $env:GITHUB_OUTPUT - name: Fetch latest Universal Sierra Compiler version from GitHub releases id: usc_version @@ -51,19 +46,21 @@ jobs: $location = (Invoke-WebRequest -Uri "https://github.com/software-mansion/universal-sierra-compiler/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location $latest_version = ($location -replace '^.*/v','') echo "Latest Universal Sierra Compiler version found is $latest_version" - echo "LATEST_USC_VERSION=$latest_version" >> $env:GITHUB_OUTPUT + echo "LATEST=$latest_version" >> $env:GITHUB_OUTPUT - name: Run starknetup run: ./starknetup.sh - name: Check Scarb latest - run: scarb --version | grep "scarb ${{ steps.scarb_version.outputs.LATEST_SCARB_VERSION }}" + run: scarb --version | grep "scarb ${{ steps.scarb_version.outputs.LATEST }}" - name: Check Starknet Foundry latest - run: snforge --version | grep "${{ steps.foundry_version.outputs.LATEST_SNFOUNDRY_VERSION }}" + run: | + snforge --version | grep "snforge ${{ steps.snfoundry_version.outputs.LATEST }}" + sncast --version | grep "sncast ${{ steps.snfoundry_version.outputs.LATEST }}" - name: Check Universal Sierra Compiler latest - run: universal-sierra-compiler --version | grep "${{ steps.usc_version.outputs.LATEST_USC_VERSION }}" + run: universal-sierra-compiler --version | grep "universal-sierra-compiler ${LATEST}" shellcheck: runs-on: ubuntu-latest From 426cf35590c93164c141da16884d96f0eac05ee0 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Mon, 16 Dec 2024 14:01:02 +0100 Subject: [PATCH 27/31] fix prints --- starknetup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index 28843b1..31f28a4 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -67,7 +67,7 @@ assert_not_installed() { if ! asdf which "$tool" >/dev/null 2>&1; then if check_cmd "$tool"; then - err "$tool is already installed outside of asdf. Please uninstall it and re-run this script. Refer to $uninstall_docs_url" + err "$tool is already installed outside of asdf. Please uninstall it and re-run this script. For uninstallation instructions, refer to $uninstall_docs_url" fi fi } @@ -156,11 +156,11 @@ install_asdf_interactively() { touch "$_profile" fi - printf "asdf-vm is required. Do you want to install it now? (y/N): " + say "asdf-vm is required. Do you want to install it now? (y/N): " read -r answer case $answer in [Yy]*) - printf "Installing asdf-vm...\n" + say "Installing asdf-vm...\n" git clone https://github.com/asdf-vm/asdf.git "$_asdf_path" --branch v0.14.1 case $_pref_shell in @@ -169,7 +169,7 @@ install_asdf_interactively() { ;; esac - printf "asdf-vm has been installed. Run 'source %s' or start a new terminal session and re-run this script.\n" "$_profile" + say "asdf-vm has been installed. Run 'source ${_profile}' or start a new terminal session and re-run this script." exit 0 ;; *) From 7e25f6b05abf4164d4c801f3469abd4c37a30015 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Mon, 16 Dec 2024 14:05:03 +0100 Subject: [PATCH 28/31] misc --- starknetup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/starknetup.sh b/starknetup.sh index 31f28a4..0b8fa65 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -46,6 +46,8 @@ main() { assert_not_installed "starknet-foundry" $STARKNET_FOUNDRY_UNINSTALL_DOCS install_latest_asdf_plugin "starknet-foundry" + + # Reinstall to ensure the latest version of USC is installed uninstall_latest_version "starknet-foundry" install_latest_version "starknet-foundry" set_global_version "starknet-foundry" @@ -67,7 +69,7 @@ assert_not_installed() { if ! asdf which "$tool" >/dev/null 2>&1; then if check_cmd "$tool"; then - err "$tool is already installed outside of asdf. Please uninstall it and re-run this script. For uninstallation instructions, refer to $uninstall_docs_url" + err "$tool is already installed outside of asdf. Please uninstall it and re-run this script. For uninstallation instructions, refer to $uninstall_docs_url." fi fi } From 1ed90003d297ecbd9c401de779d5bc3bbb113f6d Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Mon, 16 Dec 2024 14:06:31 +0100 Subject: [PATCH 29/31] misc --- starknetup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index 0b8fa65..9ea1223 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -42,7 +42,7 @@ main() { assert_not_installed "scarb" $SCARB_UNINSTALL_DOCS install_latest_asdf_plugin "scarb" install_latest_version "scarb" - set_global_version "scarb" + set_global_latest_version "scarb" assert_not_installed "starknet-foundry" $STARKNET_FOUNDRY_UNINSTALL_DOCS install_latest_asdf_plugin "starknet-foundry" @@ -50,7 +50,7 @@ main() { # Reinstall to ensure the latest version of USC is installed uninstall_latest_version "starknet-foundry" install_latest_version "starknet-foundry" - set_global_version "starknet-foundry" + set_global_latest_version "starknet-foundry" say "Installation complete" } @@ -98,7 +98,7 @@ uninstall_latest_version() { fi } -set_global_version() { +set_global_latest_version() { local tool="$1" ensure asdf global "$tool" latest } From 4fb7c8cf6093f5a59ab68df397f1cd21b38dcec1 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Wed, 18 Dec 2024 18:29:35 +0100 Subject: [PATCH 30/31] Fetch and install latest version of asdf --- starknetup.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/starknetup.sh b/starknetup.sh index 9ea1223..bc4179f 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -7,6 +7,7 @@ ASDF_INSTALL_DOCS="https://asdf-vm.com/guide/getting-started.html" SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" STARKNET_FOUNDRY_UNINSTALL_DOCS="PENDING" SCRIPT_VERSION="0.1.0" +DEFAULT_ASDF_VERSION ="v0.14.1" usage() { cat < Date: Thu, 19 Dec 2024 12:48:03 +0100 Subject: [PATCH 31/31] fix --- starknetup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starknetup.sh b/starknetup.sh index bc4179f..fadd7bf 100755 --- a/starknetup.sh +++ b/starknetup.sh @@ -7,7 +7,7 @@ ASDF_INSTALL_DOCS="https://asdf-vm.com/guide/getting-started.html" SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" STARKNET_FOUNDRY_UNINSTALL_DOCS="PENDING" SCRIPT_VERSION="0.1.0" -DEFAULT_ASDF_VERSION ="v0.14.1" +DEFAULT_ASDF_VERSION="v0.14.1" usage() { cat <