Skip to content

Commit cbf9d54

Browse files
committed
Update cvm.sh to version 1.3.0 with enhanced version management and platform detection
1 parent 8164e4c commit cbf9d54

File tree

1 file changed

+60
-30
lines changed

1 file changed

+60
-30
lines changed

cvm.sh

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
#H# --list-local Lists locally available versions
1717
#H# --list-remote Lists versions available for download
1818
#H# --download <version> Downloads a version
19-
#H# --check Check latest versions available for download
2019
#H# --update Downloads and selects the latest version
2120
#H# --use <version> Selects a locally available version
2221
#H# --active Shows the currently selected version
2322
#H# --remove <version> Removes a locally available version
2423
#H# --install Adds an alias `cursor` and downloads the latest version
2524
#H# --uninstall Removes the Cursor version manager directory and alias
26-
#H# --update-script Updates the (cvm) script to the latest version
27-
#H# -v --version Shows the script version
25+
#H# --update-script Updates the (cvm.sh) script to the latest version
26+
#H# -v --version Shows the current and latest versions for cvm.sh and Cursor
2827
#H# -h --help Shows this message
2928

3029

@@ -34,18 +33,29 @@
3433
#
3534
CURSOR_DIR="$HOME/.local/share/cvm"
3635
DOWNLOADS_DIR="$CURSOR_DIR/app-images"
37-
CVM_VERSION="1.2.0"
36+
CVM_VERSION="1.3.0"
3837
_CACHE_FILE="/tmp/cursor_versions.json"
3938
VERSION_HISTORY_URL="https://raw.githubusercontent.com/oslook/cursor-ai-downloads/refs/heads/main/version-history.json"
4039
GITHUB_API_URL="https://api.github.com/repos/ivstiv/cursor-version-manager/releases/latest"
4140

41+
# Color definitions
42+
GREEN='\033[0;32m'
43+
ORANGE='\033[0;33m'
44+
NC='\033[0m' # No Color
45+
4246
#
4347
# Functions
4448
#
4549
help() {
4650
sed -rn 's/^#H# ?//;T;p' "$0"
4751
}
4852

53+
print_color() {
54+
color=$1
55+
text=$2
56+
printf "%b%s%b\n" "$color" "$text" "$NC"
57+
}
58+
4959
getLatestScriptVersion() {
5060
# Fetch latest release version from GitHub API
5161
latest_version=$(wget -qO- "$GITHUB_API_URL" | jq -r '.tag_name' 2>/dev/null)
@@ -77,15 +87,32 @@ getVersionHistory() {
7787
fi
7888
}
7989

90+
getPlatform() {
91+
architecture=$(uname -m)
92+
case "$architecture" in
93+
x86_64)
94+
echo "linux-x64"
95+
;;
96+
aarch64|arm64)
97+
echo "linux-arm64"
98+
;;
99+
*)
100+
echo "Unsupported architecture: $architecture"
101+
;;
102+
esac
103+
}
104+
105+
platform=$(getPlatform)
106+
80107
getRemoteVersions() {
81108
getVersionHistory | \
82-
jq -r '.versions[] | select(.platforms["linux-x64"] != null) | .version' \
109+
jq -r ".versions[] | select(.platforms[\"$platform\"] != null) | .version" \
83110
| sort -V
84111
}
85112

86113
getLatestRemoteVersion() {
87114
getVersionHistory | \
88-
jq -r '.versions[] | select(.platforms["linux-x64"] != null) | .version' \
115+
jq -r ".versions[] | select(.platforms[\"$platform\"] != null) | .version" \
89116
| sort -V \
90117
| tail -n1
91118
}
@@ -108,7 +135,7 @@ downloadVersion() {
108135
localFilename="cursor-$version.AppImage"
109136
url=$(
110137
getVersionHistory | \
111-
jq -r --arg v "$version" '.versions[] | select(.version == $v and .platforms["linux-x64"] != null) | .platforms["linux-x64"]'
138+
jq -r --arg v "$version" --arg platform "$platform" '.versions[] | select(.version == $v and .platforms[$platform] != null) | .platforms[$platform]'
112139
)
113140
echo "Downloading Cursor $version..."
114141
wget -O "$DOWNLOADS_DIR/$localFilename" "$url"
@@ -315,16 +342,37 @@ case "$1" in
315342
help
316343
;;
317344
--version|-v)
318-
echo "Current version: $CVM_VERSION"
345+
echo "Cursor Version Manager (cvm.sh):"
346+
echo " - Current version: $CVM_VERSION"
319347
if latest_version=$(getLatestScriptVersion); then
320348
if [ "$latest_version" != "$CVM_VERSION" ]; then
321-
echo "Latest version available: $latest_version"
322-
echo "You can download the latest version with: $0 --update-script"
349+
echo " - Latest version: $latest_version"
350+
print_color "$ORANGE" "There is a newer cvm.sh version available for download!"
351+
print_color "$ORANGE" "You can update the script with: $0 --update-script"
323352
else
324-
echo "You are running the latest version"
353+
print_color "$GREEN" "You are running the latest cvm.sh version!"
325354
fi
326355
else
327-
echo "Failed to check for latest version"
356+
echo "Failed to check for latest cvm.sh version"
357+
fi
358+
359+
echo ""
360+
echo "Cursor App Information:"
361+
latestRemoteVersion=$(getLatestRemoteVersion)
362+
latestLocalVersion=$(getLatestLocalVersion)
363+
activeVersion=$(getActiveVersion 2>/dev/null || echo "None")
364+
echo " - Latest remote version: $latestRemoteVersion"
365+
echo " - Latest locally available: $latestLocalVersion"
366+
echo " - Currently active: $activeVersion"
367+
368+
if [ "$latestRemoteVersion" != "$latestLocalVersion" ]; then
369+
print_color "$ORANGE" "There is a newer Cursor version available for download!"
370+
print_color "$ORANGE" "You can download and activate it with \`cvm --update\`"
371+
elif [ "$latestRemoteVersion" != "$activeVersion" ]; then
372+
print_color "$ORANGE" "There is a newer Cursor version already installed!"
373+
print_color "$ORANGE" "You can activate it with \`cvm --use $latestRemoteVersion\`"
374+
else
375+
print_color "$GREEN" "You are running the latest Cursor version!"
328376
fi
329377
;;
330378
--update)
@@ -364,24 +412,6 @@ case "$1" in
364412
fi
365413
echo "To select the downloaded version, run \`cvm --use $version\`"
366414
;;
367-
--check)
368-
latestRemoteVersion=$(getLatestRemoteVersion)
369-
latestLocalVersion=$(getLatestLocalVersion)
370-
activeVersion=$(getActiveVersion)
371-
echo "Latest remote version: $latestRemoteVersion"
372-
echo "Latest locally available: $latestLocalVersion"
373-
echo "Currently active: $activeVersion"
374-
375-
if [ "$latestRemoteVersion" != "$latestLocalVersion" ]; then
376-
echo "There is a newer version available for download!"
377-
echo "You can activate the latest version with \`cvm --update\`"
378-
elif [ "$latestRemoteVersion" != "$activeVersion" ]; then
379-
echo "There is a newer version already installed!"
380-
echo "You can activate the latest version with \`cvm --use $latestRemoteVersion\`"
381-
else
382-
echo "Already up to date."
383-
fi
384-
;;
385415
--active)
386416
getActiveVersion
387417
;;

0 commit comments

Comments
 (0)