-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
Β·152 lines (128 loc) Β· 3.45 KB
/
setup.sh
File metadata and controls
executable file
Β·152 lines (128 loc) Β· 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
#
# T3 Foundation Gemstone Project [t3gemstone.org]
#
# This file is copied from the jetify.com/devbox
# SPDX-License-Identifier: Apache-2.0
set -euo pipefail
readonly TITLE="π T3 Gemstone Board Examples"
readonly DOCS_URL="https://docs.t3gemstone.org"
readonly COMMUNITY_URL="https://community.t3gemstone.org"
readonly BOLD="$(tput bold 2>/dev/null || echo '')"
readonly GREY="$(tput setaf 8 2>/dev/null || echo '')"
readonly UNDERLINE="$(tput smul 2>/dev/null || echo '')"
readonly RED="$(tput setaf 1 2>/dev/null || echo '')"
readonly GREEN="$(tput setaf 2 2>/dev/null || echo '')"
readonly YELLOW="$(tput setaf 3 2>/dev/null || echo '')"
readonly BLUE="$(tput setaf 4 2>/dev/null || echo '')"
readonly MAGENTA="$(tput setaf 5 2>/dev/null || echo '')"
readonly CYAN="$(tput setaf 6 2>/dev/null || echo '')"
readonly NO_COLOR="$(tput sgr0 2>/dev/null || echo '')"
readonly CLEAR_LAST_MSG="\033[1F\033[0K"
readonly DESCRIPTION=$(
cat <<EOF
This script downloads and installs T3 Gemstone Board's required packages π¦ for the development of examples.
Powered by Devbox, uv, ${BOLD}Love${NO_COLOR} and ${BOLD}Passion${NO_COLOR}.
EOF
)
SILENT="${SILENT:-0}"
parse_flags() {
while [ "$#" -gt 0 ]; do
case "$1" in
-s | --silent)
SILENT=1
shift 1
;;
*)
error "Unknown option: $1"
exit 1
;;
esac
done
}
has() {
command -v "$1" 1>/dev/null 2>&1
}
delay() {
sleep ${1:-0.3}
}
title() {
local -r text="$*"
printf "\n%s\n" "${BOLD}${MAGENTA}${text}${NO_COLOR}"
}
header() {
local -r text="$*"
printf "%s\n" "${BOLD}${text}${NO_COLOR}"
}
plain() {
local -r text="$*"
printf "%s\n" "${text}"
}
info() {
local -r text="$*"
printf "%s\n" "${BOLD}${GREY}β${NO_COLOR} ${text}"
}
warn() {
local -r text="$*"
printf "%s\n" "${YELLOW}! $*${NO_COLOR}"
}
error() {
local -r text="$*"
printf "%s\n" "${RED}β ${text}${NO_COLOR}" >&2
}
success() {
local -r text="$*"
printf "%s\n" "${GREEN}β${NO_COLOR} ${text}"
}
start_task() {
local -r text="$*"
printf "%s\n" "${BOLD}${GREY}β${NO_COLOR} ${text}..."
}
end_task() {
local -r text="$*"
printf "${CLEAR_LAST_MSG}%s\n" "${GREEN}β${NO_COLOR} ${text}... [DONE]"
}
fail_task() {
local -r text="$*"
printf "${CLEAR_LAST_MSG}%s\n" "${RED}β ${text}... [FAILED]${NO_COLOR}" >&2
}
check_requirements() {
start_task requirements
for i in "curl" "git" "sudo"; do
if ! has "$i"; then
echo "$i must be installed to start the installation! For Help: $DOCS_URL/sdk"
fail_task
return 1
fi
done
success
end_task requirements
}
install_devbox() {
start_task devbox
has "devbox" && success || { curl -fsSL https://get.jetify.com/devbox | bash && success || fail_task; }
end_task devbox
}
intro_msg() {
title "${TITLE}"
printf "\n"
plain "${DESCRIPTION}"
printf "\n"
}
next_steps_msg() {
printf "\n"
header "What's the next?"
plain " 1. ${BOLD}Learn how to build π a new world${NO_COLOR}"
plain " ${GREY}Read the docs at ${UNDERLINE}${BLUE}${DOCS_URL}${NO_COLOR}"
plain " 2. ${BOLD}Get help and give feedback${NO_COLOR}"
plain " ${GREY}Join our community at ${UNDERLINE}${BLUE}${COMMUNITY_URL}${NO_COLOR}"
printf "\n"
}
main() {
intro_msg
delay 3
check_requirements
install_devbox
next_steps_msg
}
main "$@"