You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- If asdf is not found, install new asdf version instead of old one
- Don't block further installation of the tools after installing asdf
(following up on
#1 (comment))
- Don't cancel asdf install on unrecognized shell, give instructions to
update PATH instead
- Minor improvements to asdf install confirmation prompt: detect
non-interactive shell and display the relevant err msg
STARKNET_FOUNDRY_UNINSTALL_INSTRUCTIONS="Try removing snforge and sncast binaries from ${LOCAL_BIN}"
13
+
SCRIPT_VERSION="0.2.0"
14
+
DEFAULT_ASDF_VERSION="v0.16.2"
11
15
12
16
usage() {
13
17
cat <<EOF
@@ -18,11 +22,14 @@ Usage: $0 [OPTIONS]
18
22
Options:
19
23
-h, --help Print help
20
24
-V, --version Print script version
25
+
-y, --yes Disable confirmation prompt
21
26
22
27
EOF
23
28
}
24
29
25
30
main() {
31
+
_need_interaction=true
32
+
26
33
forargin"$@";do
27
34
case"$arg"in
28
35
-h | --help)
@@ -33,13 +40,16 @@ main() {
33
40
say "starkup $SCRIPT_VERSION"
34
41
exit 0
35
42
;;
43
+
-y | --yes)
44
+
_need_interaction=false
45
+
;;
36
46
*)
37
47
err "invalid option '$arg'. For more information, try '--help'."
38
48
;;
39
49
esac
40
50
done
41
51
42
-
assert_dependencies
52
+
assert_dependencies"$_need_interaction"
43
53
assert_not_installed_outside_asdf
44
54
45
55
install_latest_asdf_plugin "scarb"
@@ -52,7 +62,6 @@ main() {
52
62
install_latest_version "starknet-foundry"
53
63
set_global_latest_version "starknet-foundry"
54
64
55
-
_shell_config=""
56
65
_completion_message=""
57
66
58
67
case${SHELL:-""}in
@@ -73,23 +82,20 @@ main() {
73
82
_completion_message="Run '. ${_shell_config}'"
74
83
;;
75
84
*)
85
+
say "Could not detect shell. Make sure ${LOCAL_BIN_ESCAPED} and ${ASDF_SHIMS_ESCAPED} are added to your PATH."
76
86
_completion_message="Source your shell configuration file"
77
87
;;
78
88
esac
79
89
80
-
if! check_cmd universal-sierra-compiler;then
81
-
_local_bin="${HOME}/.local/bin"
82
-
say "Couldn't finish universal-sierra-compiler installation, try manually adding ${_local_bin} to your PATH."
83
-
fi
84
-
85
90
say "Installation complete. ${_completion_message} or start a new terminal session to use the installed tools."
86
91
}
87
92
88
93
assert_dependencies() {
94
+
_need_interaction="$1"
89
95
need_cmd curl
90
96
need_cmd git
91
97
if! check_cmd asdf;then
92
-
install_asdf_interactively
98
+
install_asdf "$_need_interaction"
93
99
fi
94
100
}
95
101
@@ -224,61 +230,79 @@ is_asdf_legacy() {
224
230
printf'%s\n%s'"$_version""0.16.0"| sort -V | head -n1 | grep -xqvF "0.16.0"
225
231
}
226
232
227
-
install_asdf_interactively() {
228
-
_profile=""
229
-
_pref_shell=""
230
-
_completion_message=""
231
-
_asdf_path="$HOME/.asdf"
232
-
233
-
case${SHELL:-""}in
234
-
*/zsh)
235
-
_profile=$HOME/.zshrc
236
-
_pref_shell=zsh
237
-
_completion_message="Run 'source ${_profile}'"
238
-
;;
239
-
*/bash)
240
-
if [ "$(uname)"="Darwin" ];then
241
-
_profile=$HOME/.bash_profile
233
+
install_asdf() {
234
+
_need_interaction="$1"
235
+
_answer=""
236
+
if"$_need_interaction";then
237
+
say "asdf-vm is required but not found.\nFor seamless updates, install it using a package manager (e.g., Homebrew, AUR helpers). See details: ${ASDF_INSTALL_DOCS}.\nAlternatively, the script can install asdf-vm directly, but manual updates might be needed later.\nProceed with direct installation? (y/N):"
238
+
if [ !-t 0 ];then
239
+
# Starkup is going to want to ask for confirmation by
240
+
# reading stdin. This script may be piped into `sh` though
241
+
# and wouldn't have stdin to pass to its children. Instead we're
242
+
# going to explicitly connect /dev/tty to the installer's stdin.
243
+
if [ !-t 1 ] || [ !-r /dev/tty ];then
244
+
err "Unable to run interactively."
245
+
fi
246
+
read -r _answer </dev/tty
242
247
else
243
-
_profile=$HOME/.bashrc
248
+
read -r _answer
244
249
fi
245
-
_pref_shell=bash
246
-
_completion_message="Run 'source ${_profile}'"
247
-
;;
248
-
*/sh)
249
-
_profile=$HOME/.profile
250
-
_pref_shell="sh"
251
-
_completion_message="Run '. ${_profile}'"
252
-
;;
253
-
esac
254
-
255
-
if [ -z"$_profile" ] || [ -z"$_pref_shell" ];then
256
-
err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}."
*) err "Unsupported platform ${_os}-${_arch}. Please install asdf-vm manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." ;;
274
+
esac
260
275
261
-
say "asdf-vm is required. Do you want to install it now? (y/N): "
262
-
# Starkup is going to want to ask for confirmation by
263
-
# reading stdin. This script may be piped into `sh` though
264
-
# and wouldn't have stdin to pass to its children. Instead we're
265
-
# going to explicitly connect /dev/tty to the installer's stdin.
0 commit comments