@@ -9,6 +9,9 @@ RED='\033[0;31m'
99GREEN=' \033[0;32m'
1010YELLOW=' \033[1;33m'
1111BLUE=' \033[0;34m'
12+ CYAN=' \033[0;36m'
13+ PURPLE=' \033[0;35m'
14+ BOLD=' \033[1m'
1215NC=' \033[0m' # No Color
1316
1417# Print colored messages.
@@ -28,6 +31,14 @@ warning() {
2831 echo -e " ${YELLOW} β ${NC} $1 "
2932}
3033
34+ step () {
35+ echo -e " ${CYAN} β${NC} $1 "
36+ }
37+
38+ socket_brand () {
39+ echo -e " ${PURPLE} β‘${NC} $1 "
40+ }
41+
3142# Detect platform and architecture.
3243detect_platform () {
3344 local os
@@ -46,6 +57,10 @@ detect_platform() {
4657 ;;
4758 * )
4859 error " Unsupported operating system: $( uname -s) "
60+ echo " "
61+ info " π‘ Socket CLI supports Linux, macOS, and Windows."
62+ info " If you think this is an error, please open an issue at:"
63+ info " https://github.com/SocketDev/socket-cli/issues"
4964 exit 1
5065 ;;
5166 esac
@@ -60,6 +75,10 @@ detect_platform() {
6075 ;;
6176 * )
6277 error " Unsupported architecture: $( uname -m) "
78+ echo " "
79+ info " π‘ Socket CLI supports x64 and arm64 architectures."
80+ info " If you think this is an error, please open an issue at:"
81+ info " https://github.com/SocketDev/socket-cli/issues"
6382 exit 1
6483 ;;
6584 esac
@@ -79,12 +98,20 @@ get_latest_version() {
7998 elif command -v wget & > /dev/null; then
8099 version=$( wget -qO- " https://registry.npmjs.org/${package_name} /latest" | grep -o ' "version": *"[^"]*"' | head -1 | sed ' s/"version": *"\([^"]*\)"/\1/' )
81100 else
82- error " Neither curl nor wget found. Please install one of them."
101+ error " Neither curl nor wget found on your system"
102+ echo " "
103+ info " π‘ Please install curl or wget to continue:"
104+ info " macOS: brew install curl"
105+ info " Ubuntu: sudo apt-get install curl"
106+ info " Fedora: sudo dnf install curl"
83107 exit 1
84108 fi
85109
86110 if [ -z " $version " ]; then
87111 error " Failed to fetch latest version from npm registry"
112+ echo " "
113+ info " π‘ This might be a temporary network issue. Please try again."
114+ info " If the problem persists, check your internet connection."
88115 exit 1
89116 fi
90117
@@ -118,21 +145,21 @@ install_socket_cli() {
118145 local bin_dir
119146 local symlink_path
120147
121- info " Detecting platform..."
148+ step " Detecting your platform..."
122149 platform=$( detect_platform)
123- success " Platform detected: $platform "
150+ success " Platform detected: ${BOLD} $ platform${NC} "
124151
125152 # Construct package name.
126153 package_name=" @socketbin/cli-${platform} "
127154
128- info " Fetching latest version..."
155+ step " Fetching latest version from npm ..."
129156 version=$( get_latest_version " $package_name " )
130- success " Latest version: $ version"
157+ success " Found version ${BOLD} $ version${NC} "
131158
132159 # Construct download URL from npm registry.
133160 download_url=" https://registry.npmjs.org/${package_name} /-/cli-${platform} -${version} .tgz"
134161
135- info " Downloading Socket CLI from npm registry "
162+ step " Downloading Socket CLI π¦ "
136163
137164 # Create DLX directory structure.
138165 dlx_dir=" ${HOME} /.socket/_dlx"
@@ -154,10 +181,10 @@ install_socket_cli() {
154181 wget -qO " $temp_tarball " " $download_url "
155182 fi
156183
157- success " Downloaded tarball "
184+ success " Package downloaded successfully "
158185
159186 # Extract tarball.
160- info " Extracting binary... "
187+ step " Capturing lightning in a bottle β‘ "
161188 tar -xzf " $temp_tarball " -C " $install_dir "
162189
163190 # Find the binary (it's in package/bin/socket or package/bin/socket.exe).
@@ -169,6 +196,8 @@ install_socket_cli() {
169196
170197 if [ ! -f " $binary_path " ]; then
171198 error " Binary not found at expected path: $binary_path "
199+ echo " "
200+ info " π‘ This might be a temporary issue with the package. Try again in a moment."
172201 exit 1
173202 fi
174203
@@ -179,13 +208,14 @@ install_socket_cli() {
179208 # Clear macOS quarantine attribute.
180209 if [ " $platform " = " darwin-x64" ] || [ " $platform " = " darwin-arm64" ]; then
181210 xattr -d com.apple.quarantine " $binary_path " 2> /dev/null || true
211+ success " Cleared macOS security restrictions"
182212 fi
183213 fi
184214
185215 # Clean up tarball.
186216 rm " $temp_tarball "
187217
188- success " Installed to $ binary_path"
218+ success " Binary ready at ${BOLD} $ binary_path${NC} "
189219
190220 # Create symlink in user's local bin directory.
191221 bin_dir=" ${HOME} /.local/bin"
@@ -194,37 +224,49 @@ install_socket_cli() {
194224
195225 # Remove existing symlink if present.
196226 if [ -L " $symlink_path " ] || [ -f " $symlink_path " ]; then
227+ step " Replacing existing installation..."
197228 rm " $symlink_path "
198229 fi
199230
200231 # Create symlink.
232+ step " Creating command shortcut..."
201233 ln -s " $binary_path " " $symlink_path "
202- success " Created symlink: $symlink_path -> $binary_path "
234+ success " Command ready: ${BOLD} socket${NC} "
235+
236+ echo " "
203237
204238 # Check if ~/.local/bin is in PATH.
205239 if [[ " :$PATH :" != * " :${bin_dir} :" * ]]; then
206- warning " ~/.local/bin is not in your PATH "
240+ warning " Almost there! One more step needed... "
207241 echo " "
208- echo " Add it to your PATH by adding this to your shell profile (~/.bashrc, ~/.zshrc, etc.):"
242+ echo " Add ${BOLD} ~/.local/bin${NC} to your PATH by adding this line to your shell profile:"
243+ echo " ${BOLD} (~/.bashrc, ~/.zshrc, ~/.bash_profile, or ~/.profile)${NC} "
209244 echo " "
210- echo " export PATH=\"\$ HOME/.local/bin:\$ PATH\" "
245+ echo " ${CYAN} export PATH=\"\$ HOME/.local/bin:\$ PATH\" ${NC} "
246+ echo " "
247+ echo " Then restart your shell or run: ${CYAN} source ~/.zshrc${NC} (or your shell config)"
211248 echo " "
212249 else
213- success " ~/.local/bin is already in your PATH "
250+ success " Your PATH is already configured perfectly! "
214251 fi
215252
216253 echo " "
217- success " Socket CLI installed successfully!"
254+ socket_brand " ${BOLD} Socket CLI installed successfully!${NC} π"
255+ echo " "
256+ info " π‘ Quick start:"
257+ echo " ${CYAN} socket --help${NC} Get started with Socket"
258+ echo " ${CYAN} socket self-update${NC} Update to the latest version"
218259 echo " "
219- info " Run 'socket --help' to get started"
220- info " Run 'socket self-update' to update to the latest version"
260+ socket_brand " Happy securing! π"
221261}
222262
223263# Main execution.
224264main () {
225265 echo " "
226- echo " Socket CLI Installer"
227- echo " ===================="
266+ echo -e " ${PURPLE}${BOLD} β‘ Socket CLI Installer β‘${NC} "
267+ echo -e " ${BOLD} βββββββββββββββββββββββββββ${NC} "
268+ echo " "
269+ echo " Secure your dependencies with Socket Security"
228270 echo " "
229271
230272 install_socket_cli
0 commit comments