Browse Source

feat: enhance installation script with requirement checks and streamlined download process

- Added a function to check for required commands (curl).
- Simplified the download function to exclusively use curl for downloading assets.
- Improved error handling and user feedback when fetching the latest release information.
- Updated the main installation function to construct the binary name directly and provide clearer output during the installation process.
pull/85/head
dacrab 5 months ago
parent
commit
ad7ae6fa58
  1. 53
      CHANGELOG.md
  2. 68
      scripts/install.sh

53
CHANGELOG.md

@ -0,0 +1,53 @@
# 📝 Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.1.23] - 2024-12-29 🚀
### ✨ Features
- **Initial Release**: First public release of Cursor ID Modifier
- **Multi-Platform Support**:
- 🪟 Windows (x64, x86)
- 🍎 macOS (Intel & Apple Silicon)
- 🐧 Linux (x64, x86, ARM64)
- **Installation**:
- Automated installation scripts for all platforms
- One-line installation commands
- Secure download and verification
- **Core Functionality**:
- Telemetry ID modification for Cursor IDE
- Automatic process management
- Secure configuration handling
### 🐛 Bug Fixes
- **Installation**:
- Fixed environment variable preservation in sudo operations
- Enhanced error handling during installation
- Improved binary download reliability
- **Process Management**:
- Improved Cursor process detection accuracy
- Enhanced process termination reliability
- Better handling of edge cases
- **User Experience**:
- Enhanced error messages and user feedback
- Improved progress indicators
- Better handling of system permissions
### 🔧 Technical Improvements
- Optimized binary size with proper build flags
- Enhanced cross-platform compatibility
- Improved error handling and logging
- Better system resource management
### 📚 Documentation
- Added comprehensive installation instructions
- Included platform-specific guidelines
- Enhanced error troubleshooting guide
---
*For more details about the changes, please refer to the [commit history](https://github.com/dacrab/go-cursor-help/commits/main).*
[0.1.22]: https://github.com/dacrab/go-cursor-help/releases/tag/v0.1.23

68
scripts/install.sh

@ -13,6 +13,14 @@ NC='\033[0m'
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
# Check for required commands
check_requirements() {
if ! command -v curl >/dev/null 2>&1; then
echo -e "${RED}Error: curl is required${NC}"
exit 1
fi
}
# Detect system information
detect_system() {
local os arch suffix
@ -42,19 +50,11 @@ detect_system() {
echo "$os $arch $suffix"
}
# Download with progress using curl or wget
# Download with progress
download() {
local url="$1"
local output="$2"
if command -v curl >/dev/null 2>&1; then
curl -#L "$url" -o "$output"
elif command -v wget >/dev/null 2>&1; then
wget --show-progress -q "$url" -O "$output"
else
echo -e "${RED}Error: curl or wget is required${NC}"
exit 1
fi
}
# Check and create installation directory
@ -69,38 +69,10 @@ setup_install_dir() {
fi
}
# Find matching asset from release
find_asset() {
local json="$1"
local os="$2"
local arch="$3"
local suffix="$4"
# Try possible binary names
local binary_names=(
"cursor-id-modifier_${os}_${arch}${suffix}" # lowercase os
"cursor-id-modifier_$(tr '[:lower:]' '[:upper:]' <<< ${os:0:1})${os:1}_${arch}${suffix}" # capitalized os
)
local url=""
for name in "${binary_names[@]}"; do
echo -e "${BLUE}Looking for asset: $name${NC}"
url=$(echo "$json" | grep -o "\"browser_download_url\": \"[^\"]*${name}\"" | cut -d'"' -f4)
if [ -n "$url" ]; then
echo -e "${GREEN}Found matching asset: $name${NC}"
echo "$url"
return 0
fi
done
# If no match found, show available assets
echo -e "${YELLOW}Available assets:${NC}"
echo "$json" | grep "\"name\":" | cut -d'"' -f4
return 1
}
# Main installation function
main() {
check_requirements
echo -e "${BLUE}Starting installation...${NC}"
# Detect system
@ -109,7 +81,6 @@ main() {
# Set installation directory
INSTALL_DIR="/usr/local/bin"
[ "$OS" = "darwin" ] && INSTALL_DIR="/usr/local/bin"
# Setup installation directory
setup_install_dir "$INSTALL_DIR"
@ -117,17 +88,22 @@ main() {
# Get latest release info
echo -e "${BLUE}Fetching latest release information...${NC}"
LATEST_URL="https://api.github.com/repos/dacrab/go-cursor-help/releases/latest"
RELEASE_JSON=$(curl -s "$LATEST_URL")
# Find matching asset
DOWNLOAD_URL=$(find_asset "$RELEASE_JSON" "$OS" "$ARCH" "$SUFFIX")
# Construct binary name
BINARY_NAME="cursor-id-modifier_${OS}_${ARCH}${SUFFIX}"
echo -e "${BLUE}Looking for asset: $BINARY_NAME${NC}"
# Get download URL directly
DOWNLOAD_URL=$(curl -s "$LATEST_URL" | tr -d '\n' | grep -o "\"browser_download_url\": \"[^\"]*${BINARY_NAME}[^\"]*\"" | cut -d'"' -f4)
if [ -z "$DOWNLOAD_URL" ]; then
echo -e "${RED}Error: Could not find appropriate binary for $OS $ARCH${NC}"
exit 1
fi
echo -e "${BLUE}Downloading latest release...${NC}"
echo -e "${GREEN}Found matching asset: $BINARY_NAME${NC}"
echo -e "${BLUE}Downloading from: $DOWNLOAD_URL${NC}"
download "$DOWNLOAD_URL" "$TMP_DIR/cursor-id-modifier"
# Install binary
@ -138,9 +114,9 @@ main() {
echo -e "${GREEN}Installation completed successfully!${NC}"
echo -e "${BLUE}Running cursor-id-modifier...${NC}"
# Run the program
# Run the program with sudo, preserving environment variables
export AUTOMATED_MODE=1
if ! cursor-id-modifier; then
if ! sudo -E cursor-id-modifier; then
echo -e "${RED}Failed to run cursor-id-modifier${NC}"
exit 1
fi

Loading…
Cancel
Save