refactor(scripts): 移除旧版构建和修改脚本

- 删除 Windows 批处理构建脚本 (build_all.bat)
- 删除 Linux Shell 构建脚本 (build_all.sh)
- 删除 Python 实现的 Cursor ID 修改器主脚本 (cursor_id_modifier.py)
- 为后续重构和优化清理旧代码
This commit is contained in:
煎饼果子卷鲨鱼辣椒
2025-12-21 01:47:44 +08:00
parent f5f1e64eec
commit aaa76fc387
19 changed files with 0 additions and 3906 deletions

View File

@@ -1,74 +0,0 @@
@echo off
setlocal EnableDelayedExpansion
:: Build optimization flags
set "OPTIMIZATION_FLAGS=-trimpath -ldflags=\"-s -w\""
set "BUILD_JOBS=4"
:: Messages / 消息
set "EN_MESSAGES[0]=Starting build process for version"
set "EN_MESSAGES[1]=Using optimization flags:"
set "EN_MESSAGES[2]=Cleaning old builds..."
set "EN_MESSAGES[3]=Cleanup completed"
set "EN_MESSAGES[4]=Starting builds for all platforms..."
set "EN_MESSAGES[5]=Building for"
set "EN_MESSAGES[6]=Build successful:"
set "EN_MESSAGES[7]=All builds completed!"
:: Colors
set "GREEN=[32m"
set "RED=[31m"
set "RESET=[0m"
:: Cleanup function
:cleanup
if exist "..\bin" (
rd /s /q "..\bin"
echo %GREEN%!EN_MESSAGES[3]!%RESET%
)
mkdir "..\bin" 2>nul
:: Build function with optimizations
:build
set "os=%~1"
set "arch=%~2"
set "ext="
if "%os%"=="windows" set "ext=.exe"
echo %GREEN%!EN_MESSAGES[5]! %os%/%arch%%RESET%
set "CGO_ENABLED=0"
set "GOOS=%os%"
set "GOARCH=%arch%"
start /b cmd /c "go build -trimpath -ldflags=\"-s -w\" -o ..\bin\%os%\%arch%\cursor-id-modifier%ext% -a -installsuffix cgo -mod=readonly ..\cmd\cursor-id-modifier"
exit /b 0
:: Main execution
echo %GREEN%!EN_MESSAGES[0]!%RESET%
echo %GREEN%!EN_MESSAGES[1]! %OPTIMIZATION_FLAGS%%RESET%
call :cleanup
echo %GREEN%!EN_MESSAGES[4]!%RESET%
:: Start builds in parallel
set "pending=0"
for %%o in (windows linux darwin) do (
for %%a in (amd64 386) do (
call :build %%o %%a
set /a "pending+=1"
if !pending! geq %BUILD_JOBS% (
timeout /t 1 /nobreak >nul
set "pending=0"
)
)
)
:: Wait for all builds to complete
:wait_builds
timeout /t 2 /nobreak >nul
tasklist /fi "IMAGENAME eq go.exe" 2>nul | find "go.exe" >nul
if not errorlevel 1 goto wait_builds
echo %GREEN%!EN_MESSAGES[7]!%RESET%

View File

@@ -1,143 +0,0 @@
#!/bin/bash
# 设置颜色代码 / Set color codes
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color / 无颜色
# Build optimization flags
OPTIMIZATION_FLAGS="-trimpath -ldflags=\"-s -w\""
PARALLEL_JOBS=$(nproc || echo "4") # Get number of CPU cores or default to 4
# Messages / 消息
EN_MESSAGES=(
"Starting build process for version"
"Cleaning old builds..."
"Creating bin directory..."
"Failed to create bin directory"
"Building for"
"Successfully built:"
"Failed to build for"
"Build Summary:"
"Successful builds:"
"Failed builds:"
"Generated files:"
)
CN_MESSAGES=(
"开始构建版本"
"正在清理旧的构建文件..."
"正在创建bin目录..."
"创建bin目录失败"
"正在构建"
"构建成功:"
"构建失败:"
"构建摘要:"
"成功构建数:"
"失败构建数:"
"生成的文件:"
"构建过程被中断"
"错误:"
)
# 版本信息 / Version info
VERSION="1.0.0"
# Detect system language / 检测系统语言
detect_language() {
if [[ $(locale | grep "LANG=zh_CN") ]]; then
echo "cn"
else
echo "en"
fi
}
# Get message based on language / 根据语言获取消息
get_message() {
local index=$1
local lang=$(detect_language)
if [[ "$lang" == "cn" ]]; then
echo "${CN_MESSAGES[$index]}"
else
echo "${EN_MESSAGES[$index]}"
fi
}
# 错误处理函数 / Error handling function
handle_error() {
echo -e "${RED}$(get_message 12) $1${NC}"
exit 1
}
# 清理函数 / Cleanup function
cleanup() {
if [ -d "../bin" ]; then
rm -rf ../bin
echo -e "${GREEN}$(get_message 1)${NC}"
fi
}
# Build function with optimizations
build() {
local os=$1
local arch=$2
local ext=""
[ "$os" = "windows" ] && ext=".exe"
echo -e "${GREEN}$(get_message 4) $os/$arch${NC}"
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build \
-trimpath \
-ldflags="-s -w" \
-o "../bin/$os/$arch/cursor-id-modifier$ext" \
-a -installsuffix cgo \
-mod=readonly \
../cmd/cursor-id-modifier &
}
# Parallel build execution
build_all() {
local builds=0
local max_parallel=$PARALLEL_JOBS
# Define build targets
declare -A targets=(
["linux/amd64"]=1
["linux/386"]=1
["linux/arm64"]=1
["windows/amd64"]=1
["windows/386"]=1
["darwin/amd64"]=1
["darwin/arm64"]=1
)
for target in "${!targets[@]}"; do
IFS='/' read -r os arch <<< "$target"
build "$os" "$arch"
((builds++))
if ((builds >= max_parallel)); then
wait
builds=0
fi
done
# Wait for remaining builds
wait
}
# Main execution
main() {
cleanup
mkdir -p ../bin || { echo -e "${RED}$(get_message 3)${NC}"; exit 1; }
build_all
echo -e "${GREEN}Build completed successfully${NC}"
}
# 捕获错误信号 / Catch error signals
trap 'echo -e "\n${RED}$(get_message 11)${NC}"; exit 1' INT TERM
# 执行主函数 / Execute main function
main

View File

@@ -1,318 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: cursor_id_modifier\n"
"POT-Creation-Date: 2025-04-25 12:00+0000\n"
"PO-Revision-Date: 2025-04-25 12:00+0000\n"
"Language-Team: None\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "Error: No translation file found for domain 'cursor_id_modifier' in {}/zh_CN/LC_MESSAGES/"
msgstr ""
msgid "========== Cursor ID modification tool log start {} =========="
msgstr ""
msgid "[INFO] {} {}"
msgstr ""
msgid "[WARN] {} {}"
msgstr ""
msgid "[ERROR] {} {}"
msgstr ""
msgid "[DEBUG] {} {}"
msgstr ""
msgid "[CMD] {} Executing command: {}"
msgstr ""
msgid "[CMD] {}:"
msgstr ""
msgid "Unable to get username"
msgstr ""
msgid "Finding Cursor installation path..."
msgstr ""
msgid "Found Cursor installation path: {}"
msgstr ""
msgid "Found Cursor via which: {}"
msgstr ""
msgid "Cursor executable not found, will try using config directory"
msgstr ""
msgid "Found Cursor via search: {}"
msgstr ""
msgid "Finding Cursor resource directory..."
msgstr ""
msgid "Found Cursor resource directory: {}"
msgstr ""
msgid "Found resource directory via binary path: {}"
msgstr ""
msgid "Cursor resource directory not found"
msgstr ""
msgid "Please run this script with sudo"
msgstr ""
msgid "Example: sudo {}"
msgstr ""
msgid "Checking Cursor processes..."
msgstr ""
msgid "Getting process details for {}:"
msgstr ""
msgid "No running Cursor processes found"
msgstr ""
msgid "Found running Cursor processes"
msgstr ""
msgid "Attempting to terminate Cursor processes..."
msgstr ""
msgid "Attempting to forcefully terminate processes..."
msgstr ""
msgid "Waiting for processes to terminate, attempt {}/{}..."
msgstr ""
msgid "Cursor processes successfully terminated"
msgstr ""
msgid "Unable to terminate Cursor processes after {} attempts"
msgstr ""
msgid "Please manually terminate the processes and try again"
msgstr ""
msgid "Configuration file does not exist, skipping backup"
msgstr ""
msgid "Configuration backed up to: {}"
msgstr ""
msgid "Backup failed"
msgstr ""
msgid "File does not exist: {}"
msgstr ""
msgid "Unable to modify file permissions: {}"
msgstr ""
msgid "Generated temporary file is empty"
msgstr ""
msgid "Unable to write to file: {}"
msgstr ""
msgid "Machine code reset options"
msgstr ""
msgid "Do you need to reset the machine code? (Usually, modifying JS files is sufficient):"
msgstr ""
msgid "Don't reset - only modify JS files"
msgstr ""
msgid "Reset - modify both config file and machine code"
msgstr ""
msgid "[INPUT_DEBUG] Machine code reset option selected: {}"
msgstr ""
msgid "You chose to reset the machine code"
msgstr ""
msgid "Found existing configuration file: {}"
msgstr ""
msgid "Setting new device and machine IDs..."
msgstr ""
msgid "New device ID: {}"
msgstr ""
msgid "New machine ID: {}"
msgstr ""
msgid "Configuration file modified successfully"
msgstr ""
msgid "Configuration file modification failed"
msgstr ""
msgid "Configuration file not found, this is normal, skipping ID modification"
msgstr ""
msgid "You chose not to reset the machine code, will only modify JS files"
msgstr ""
msgid "Configuration processing completed"
msgstr ""
msgid "Finding Cursor's JS files..."
msgstr ""
msgid "Searching for JS files in resource directory: {}"
msgstr ""
msgid "Found JS file: {}"
msgstr ""
msgid "No JS files found in resource directory, trying other directories..."
msgstr ""
msgid "Searching directory: {}"
msgstr ""
msgid "No modifiable JS files found"
msgstr ""
msgid "Found {} JS files to modify"
msgstr ""
msgid "Starting to modify Cursor's JS files..."
msgstr ""
msgid "Unable to find modifiable JS files"
msgstr ""
msgid "Processing file: {}"
msgstr ""
msgid "Unable to create backup for file: {}"
msgstr ""
msgid "Found x-cursor-checksum setting code"
msgstr ""
msgid "Successfully modified x-cursor-checksum setting code"
msgstr ""
msgid "Failed to modify x-cursor-checksum setting code"
msgstr ""
msgid "Found IOPlatformUUID keyword"
msgstr ""
msgid "Successfully injected randomUUID call into a$ function"
msgstr ""
msgid "Failed to modify a$ function"
msgstr ""
msgid "Successfully injected randomUUID call into v5 function"
msgstr ""
msgid "Failed to modify v5 function"
msgstr ""
msgid "Completed universal modification"
msgstr ""
msgid "File already contains custom injection code, skipping modification"
msgstr ""
msgid "Completed most universal injection"
msgstr ""
msgid "File has already been modified, skipping modification"
msgstr ""
msgid "Failed to modify any JS files"
msgstr ""
msgid "Successfully modified {} JS files"
msgstr ""
msgid "Disabling Cursor auto-update..."
msgstr ""
msgid "Found update configuration file: {}"
msgstr ""
msgid "Disabled update configuration file: {}"
msgstr ""
msgid "Found updater: {}"
msgstr ""
msgid "Disabled updater: {}"
msgstr ""
msgid "No update configuration files or updaters found"
msgstr ""
msgid "Successfully disabled auto-update"
msgstr ""
msgid "You selected: {}"
msgstr ""
msgid "This script only supports Linux systems"
msgstr ""
msgid "Script started..."
msgstr ""
msgid "System information: {}"
msgstr ""
msgid "Current user: {}"
msgstr ""
msgid "System version information"
msgstr ""
msgid "Cursor Linux startup tool"
msgstr ""
msgid "Important notice"
msgstr ""
msgid "This tool prioritizes modifying JS files, which is safer and more reliable"
msgstr ""
msgid "Modifying Cursor JS files..."
msgstr ""
msgid "JS files modified successfully!"
msgstr ""
msgid "JS file modification failed, but configuration file modification may have succeeded"
msgstr ""
msgid "If Cursor still indicates the device is disabled after restarting, please rerun this script"
msgstr ""
msgid "Please restart Cursor to apply the new configuration"
msgstr ""
msgid "Follow the WeChat public account [Pancake AI] to discuss more Cursor tips and AI knowledge (script is free, join the group via the public account for more tips and experts)"
msgstr ""
msgid "Script execution completed"
msgstr ""
msgid "========== Cursor ID modification tool log end {} =========="
msgstr ""
msgid "Detailed log saved to: {}"
msgstr ""
msgid "If you encounter issues, please provide this log file to the developer for troubleshooting"
msgstr ""

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +0,0 @@
#!/bin/bash
REPO_DIR="$PWD"
LOCALES_DIR="$REPO_DIR/locales"
msginit -i cursor_id_modifier.pot -o $LOCALES_DIR/en_US/LC_MESSAGES/cursor_id_modifier.po -l en_US
for lang in en_US zh_CN; do
cd $LOCALES_DIR/$lang/LC_MESSAGES
msgfmt -o cursor_id_modifier.mo cursor_id_modifier.po
done

View File

@@ -1,193 +0,0 @@
# Check for admin rights and handle elevation
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
if (-NOT $isAdmin) {
# Detect PowerShell version and path
$pwshPath = if (Get-Command "pwsh" -ErrorAction SilentlyContinue) {
(Get-Command "pwsh").Source # PowerShell 7+
} elseif (Test-Path "$env:ProgramFiles\PowerShell\7\pwsh.exe") {
"$env:ProgramFiles\PowerShell\7\pwsh.exe"
} else {
"powershell.exe" # Windows PowerShell
}
try {
Write-Host "`nRequesting administrator privileges..." -ForegroundColor Cyan
$scriptPath = $MyInvocation.MyCommand.Path
$argList = "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`""
Start-Process -FilePath $pwshPath -Verb RunAs -ArgumentList $argList -Wait
exit
}
catch {
Write-Host "`nError: Administrator privileges required" -ForegroundColor Red
Write-Host "Please run this script from an Administrator PowerShell window" -ForegroundColor Yellow
Write-Host "`nTo do this:" -ForegroundColor Cyan
Write-Host "1. Press Win + X" -ForegroundColor White
Write-Host "2. Click 'Windows Terminal (Admin)' or 'PowerShell (Admin)'" -ForegroundColor White
Write-Host "3. Run the installation command again" -ForegroundColor White
Write-Host "`nPress enter to exit..."
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
exit 1
}
}
# Set TLS to 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Create temporary directory
$TmpDir = Join-Path $env:TEMP ([System.Guid]::NewGuid().ToString())
New-Item -ItemType Directory -Path $TmpDir | Out-Null
# Cleanup function
function Cleanup {
if (Test-Path $TmpDir) {
Remove-Item -Recurse -Force $TmpDir
}
}
# Error handler
trap {
Write-Host "Error: $_" -ForegroundColor Red
Cleanup
Write-Host "Press enter to exit..."
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
exit 1
}
# Detect system architecture
function Get-SystemArch {
if ([Environment]::Is64BitOperatingSystem) {
return "x86_64"
} else {
return "i386"
}
}
# Download with progress
function Get-FileWithProgress {
param (
[string]$Url,
[string]$OutputFile
)
try {
$webClient = New-Object System.Net.WebClient
$webClient.Headers.Add("User-Agent", "PowerShell Script")
$webClient.DownloadFile($Url, $OutputFile)
return $true
}
catch {
Write-Host "Failed to download: $_" -ForegroundColor Red
return $false
}
}
# Main installation function
function Install-CursorModifier {
Write-Host "Starting installation..." -ForegroundColor Cyan
# Detect architecture
$arch = Get-SystemArch
Write-Host "Detected architecture: $arch" -ForegroundColor Green
# Set installation directory
$InstallDir = "$env:ProgramFiles\CursorModifier"
if (!(Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir | Out-Null
}
# Get latest release
try {
$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/yuaotian/go-cursor-help/releases/latest"
Write-Host "Found latest release: $($latestRelease.tag_name)" -ForegroundColor Cyan
# Look for Windows binary with our architecture
$version = $latestRelease.tag_name.TrimStart('v')
Write-Host "Version: $version" -ForegroundColor Cyan
$possibleNames = @(
"cursor-id-modifier_${version}_windows_x86_64.exe",
"cursor-id-modifier_${version}_windows_$($arch).exe"
)
$asset = $null
foreach ($name in $possibleNames) {
Write-Host "Checking for asset: $name" -ForegroundColor Cyan
$asset = $latestRelease.assets | Where-Object { $_.name -eq $name }
if ($asset) {
Write-Host "Found matching asset: $($asset.name)" -ForegroundColor Green
break
}
}
if (!$asset) {
Write-Host "`nAvailable assets:" -ForegroundColor Yellow
$latestRelease.assets | ForEach-Object { Write-Host "- $($_.name)" }
throw "Could not find appropriate Windows binary for $arch architecture"
}
$downloadUrl = $asset.browser_download_url
}
catch {
Write-Host "Failed to get latest release: $_" -ForegroundColor Red
exit 1
}
# Download binary
Write-Host "`nDownloading latest release..." -ForegroundColor Cyan
$binaryPath = Join-Path $TmpDir "cursor-id-modifier.exe"
if (!(Get-FileWithProgress -Url $downloadUrl -OutputFile $binaryPath)) {
exit 1
}
# Install binary
Write-Host "Installing..." -ForegroundColor Cyan
try {
Copy-Item -Path $binaryPath -Destination "$InstallDir\cursor-id-modifier.exe" -Force
# Add to PATH if not already present
$currentPath = [Environment]::GetEnvironmentVariable("Path", "Machine")
if ($currentPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("Path", "$currentPath;$InstallDir", "Machine")
}
}
catch {
Write-Host "Failed to install: $_" -ForegroundColor Red
exit 1
}
Write-Host "Installation completed successfully!" -ForegroundColor Green
Write-Host "Running cursor-id-modifier..." -ForegroundColor Cyan
# Run the program
try {
& "$InstallDir\cursor-id-modifier.exe"
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to run cursor-id-modifier" -ForegroundColor Red
exit 1
}
}
catch {
Write-Host "Failed to run cursor-id-modifier: $_" -ForegroundColor Red
exit 1
}
}
# Run installation
try {
Install-CursorModifier
}
catch {
Write-Host "Installation failed: $_" -ForegroundColor Red
Cleanup
Write-Host "Press enter to exit..."
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
exit 1
}
finally {
Cleanup
if ($LASTEXITCODE -ne 0) {
Write-Host "Press enter to exit..." -ForegroundColor Green
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
}
}

View File

@@ -1,127 +0,0 @@
#!/bin/bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;36m'
YELLOW='\033[0;33m'
NC='\033[0m'
# Temporary directory for downloads
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
case "$(uname -s)" in
Linux*) os="linux";;
Darwin*) os="darwin";;
*) echo -e "${RED}Unsupported OS${NC}"; exit 1;;
esac
case "$(uname -m)" in
x86_64)
arch="x86_64"
;;
aarch64|arm64)
arch="arm64"
;;
i386|i686)
arch="i386"
;;
*) echo -e "${RED}Unsupported architecture${NC}"; exit 1;;
esac
echo "$os $arch"
}
# Download with progress
download() {
local url="$1"
local output="$2"
curl -#L "$url" -o "$output"
}
# Check and create installation directory
setup_install_dir() {
local install_dir="$1"
if [ ! -d "$install_dir" ]; then
mkdir -p "$install_dir" || {
echo -e "${RED}Failed to create installation directory${NC}"
exit 1
}
fi
}
# Main installation function
main() {
check_requirements
echo -e "${BLUE}Starting installation...${NC}"
# Detect system
read -r OS ARCH SUFFIX <<< "$(detect_system)"
echo -e "${GREEN}Detected: $OS $ARCH${NC}"
# Set installation directory
INSTALL_DIR="/usr/local/bin"
# Setup installation directory
setup_install_dir "$INSTALL_DIR"
# Get latest release info
echo -e "${BLUE}Fetching latest release information...${NC}"
LATEST_URL="https://api.github.com/repos/yuaotian/go-cursor-help/releases/latest"
# Get latest version and remove 'v' prefix
VERSION=$(curl -s "$LATEST_URL" | grep "tag_name" | cut -d'"' -f4 | sed 's/^v//')
# Construct binary name
BINARY_NAME="cursor-id-modifier_${VERSION}_${OS}_${ARCH}"
echo -e "${BLUE}Looking for asset: $BINARY_NAME${NC}"
# Get download URL directly
DOWNLOAD_URL=$(curl -s "$LATEST_URL" | 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}"
echo -e "${YELLOW}Available assets:${NC}"
curl -s "$LATEST_URL" | grep "browser_download_url" | cut -d'"' -f4
exit 1
fi
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
echo -e "${BLUE}Installing...${NC}"
chmod +x "$TMP_DIR/cursor-id-modifier"
sudo mv "$TMP_DIR/cursor-id-modifier" "$INSTALL_DIR/"
echo -e "${GREEN}Installation completed successfully!${NC}"
echo -e "${BLUE}Running cursor-id-modifier...${NC}"
# Run the program with sudo, preserving environment variables
export AUTOMATED_MODE=1
if ! sudo -E cursor-id-modifier; then
echo -e "${RED}Failed to run cursor-id-modifier${NC}"
exit 1
fi
}
main