Skip to content

Commit

Permalink
feat: 添加自动安装脚本并优化文档
Browse files Browse the repository at this point in the history
  • Loading branch information
yuaotian committed Dec 14, 2024
2 parents 9e7d6be + 2b2fb6d commit 3316f8b
Show file tree
Hide file tree
Showing 6 changed files with 878 additions and 65 deletions.
143 changes: 128 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,86 @@ this is a mistake.

### 💻 System Support

**Windows**AMD64 & ARM64
**macOS**AMD64 & ARM64
**Linux**AMD64 & ARM64
**Windows**x64
**macOS**Intel & M-series
**Linux**x64 & ARM64

### 📥 Installation

#### Automatic Installation (Recommended)

**Linux/macOS**
```bash
curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/install.sh | bash
curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/scripts/install.sh | sudo bash
```

**Windows** (Run in PowerShell as Admin)
**Windows** (Run PowerShell as Admin)
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; $arch = if ([Environment]::Is64BitOperatingSystem) { if ([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -eq 'Arm64') { 'arm64' } else { 'amd64' } } else { 'amd64' }; $ver = (irm https://api.github.com/repos/yuaotian/go-cursor-help/releases/latest).tag_name.TrimStart('v'); $outfile = "$env:TEMP\cursor_id_modifier.exe"; irm "https://github.com/yuaotian/go-cursor-help/releases/download/v${ver}/cursor_id_modifier_${ver}_windows_${arch}.exe" -OutFile $outfile; & $outfile; Remove-Item -Path $outfile -ErrorAction SilentlyContinue
irm https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/scripts/install.ps1 | iex
```

The installation script will automatically:
- Request necessary privileges (sudo/admin)
- Close any running Cursor instances
- Backup existing configuration
- Install the tool
- Add it to system PATH
- Clean up temporary files

#### Manual Installation

1. Download the latest release for your system from the [releases page](https://github.com/yuaotian/go-cursor-help/releases)
2. Extract and run with administrator/root privileges:
```bash
# Linux/macOS
sudo ./cursor-id-modifier

# Windows (PowerShell Admin)
.\cursor-id-modifier.exe
```

#### Manual Configuration Method

1. Close Cursor completely
2. Navigate to the configuration file location:
- Windows: `%APPDATA%\Cursor\User\globalStorage\storage.json`
- macOS: `~/Library/Application Support/Cursor/User/globalStorage/storage.json`
- Linux: `~/.config/Cursor/User/globalStorage/storage.json`
3. Create a backup of `storage.json`
4. Edit `storage.json` and update these fields with new random UUIDs:
```json
{
"telemetry.machineId": "generate-new-uuid",
"telemetry.macMachineId": "generate-new-uuid",
"telemetry.devDeviceId": "generate-new-uuid",
"telemetry.sqmId": "generate-new-uuid",
"lastModified": "2024-01-01T00:00:00.000Z",
"version": "1.0.1"
}
```
5. Save the file and restart Cursor

### 🔧 Technical Details

The program modifies Cursor's `storage.json` config file:
#### Configuration Files
The program modifies Cursor's `storage.json` config file located at:
- Windows: `%APPDATA%\Cursor\User\globalStorage\`
- macOS: `~/Library/Application Support/Cursor/User/globalStorage/`
- Linux: `~/.config/Cursor/User/globalStorage/`

Generates new unique identifiers for:
#### Modified Fields
The tool generates new unique identifiers for:
- `telemetry.machineId`
- `telemetry.macMachineId`
- `telemetry.devDeviceId`
- `telemetry.sqmId`

#### Safety Features
- Automatic backup of existing configuration
- Safe process termination
- Atomic file operations
- Error handling and rollback

---

# 🌏 Chinese
Expand All @@ -73,37 +124,99 @@ this is a mistake.

### 💻 系统支持

**Windows**AMD64和ARM64
**macOS**AMD64和ARM64
**Linux**AMD64和ARM64
**Windows**x64
**macOS**Intel和M系列
**Linux**x64和ARM64

### 📥 安装方法

#### 自动安装(推荐)

**Linux/macOS**
```bash
curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/install.sh | bash
curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/scripts/install.sh | sudo bash
```

**Windows** (以管理员身份运行PowerShell)
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; $arch = if ([Environment]::Is64BitOperatingSystem) { if ([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -eq 'Arm64') { 'arm64' } else { 'amd64' } } else { 'amd64' }; $ver = (irm https://api.github.com/repos/yuaotian/go-cursor-help/releases/latest).tag_name.TrimStart('v'); $outfile = "$env:TEMP\cursor_id_modifier.exe"; irm "https://github.com/yuaotian/go-cursor-help/releases/download/v${ver}/cursor_id_modifier_${ver}_windows_${arch}.exe" -OutFile $outfile; & $outfile; Remove-Item -Path $outfile -ErrorAction SilentlyContinue
irm https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/scripts/install.ps1 | iex
```

安装脚本会自动:
- 请求必要的权限(sudo/管理员)
- 关闭所有运行中的Cursor实例
- 备份现有配置
- 安装工具
- 添加到系统PATH
- 清理临时文件

#### 手动安装

1.[发布页面](https://github.com/yuaotian/go-cursor-help/releases)下载适合您系统的最新版本
2. 解压并以管理员/root权限运行:
```bash
# Linux/macOS
sudo ./cursor-id-modifier

# Windows (PowerShell 管理员)
.\cursor-id-modifier.exe
```

#### 手动配置方法

1. 完全关闭 Cursor
2. 找到配置文件位置:
- Windows: `%APPDATA%\Cursor\User\globalStorage\storage.json`
- macOS: `~/Library/Application Support/Cursor/User/globalStorage/storage.json`
- Linux: `~/.config/Cursor/User/globalStorage/storage.json`
3. 备份 `storage.json`
4. 编辑 `storage.json` 并更新以下字段(使用新的随机UUID):
```json
{
"telemetry.machineId": "生成新的uuid",
"telemetry.macMachineId": "生成新的uuid",
"telemetry.devDeviceId": "生成新的uuid",
"telemetry.sqmId": "生成新的uuid",
"lastModified": "2024-01-01T00:00:00.000Z",
"version": "1.0.1"
}
```
5. 保存文件并重启 Cursor

### 🔧 技术细节

程序修改Cursor的`storage.json`配置文件:
#### 配置文件
程序修改Cursor的`storage.json`配置文件,位于:
- Windows: `%APPDATA%\Cursor\User\globalStorage\`
- macOS: `~/Library/Application Support/Cursor/User/globalStorage/`
- Linux: `~/.config/Cursor/User/globalStorage/`

生成新的唯一标识符:
#### 修改字段
工具会生成新的唯一标识符:
- `telemetry.machineId`
- `telemetry.macMachineId`
- `telemetry.devDeviceId`
- `telemetry.sqmId`

#### 安全特性
- 自动备份现有配置
- 安全的进程终止
- 原子文件操作
- 错误处理和回滚

## 📄 License

MIT License

Copyright (c) 2024

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

50 changes: 0 additions & 50 deletions install.sh

This file was deleted.

128 changes: 128 additions & 0 deletions scripts/build_all.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
@echo off
setlocal EnableDelayedExpansion

:: 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]=bin directory does not exist, no cleanup needed"
set "EN_MESSAGES[5]=Starting builds for all platforms..."
set "EN_MESSAGES[6]=Building for"
set "EN_MESSAGES[7]=Build successful:"
set "EN_MESSAGES[8]=Build failed for"
set "EN_MESSAGES[9]=All builds completed! Total time:"
set "EN_MESSAGES[10]=seconds"

set "CN_MESSAGES[0]=开始构建版本"
set "CN_MESSAGES[1]=使用优化标志:"
set "CN_MESSAGES[2]=正在清理旧的构建文件..."
set "CN_MESSAGES[3]=清理完成"
set "CN_MESSAGES[4]=bin 目录不存在,无需清理"
set "CN_MESSAGES[5]=开始编译所有平台..."
set "CN_MESSAGES[6]=正在构建"
set "CN_MESSAGES[7]=构建成功:"
set "CN_MESSAGES[8]=构建失败:"
set "CN_MESSAGES[9]=所有构建完成!总耗时:"
set "CN_MESSAGES[10]="

:: 设置版本信息 / Set version
set VERSION=2.0.0

:: 设置颜色代码 / Set color codes
set "GREEN=[32m"
set "RED=[31m"
set "YELLOW=[33m"
set "RESET=[0m"

:: 设置编译优化标志 / Set build optimization flags
set "LDFLAGS=-s -w"
set "BUILDMODE=pie"
set "GCFLAGS=-N -l"

:: 设置 CGO / Set CGO
set CGO_ENABLED=0

:: 检测系统语言 / Detect system language
for /f "tokens=2 delims==" %%a in ('wmic os get OSLanguage /value') do set OSLanguage=%%a
if "%OSLanguage%"=="2052" (set LANG=cn) else (set LANG=en)

:: 显示编译信息 / Display build info
echo %YELLOW%!%LANG%_MESSAGES[0]! %VERSION%%RESET%
echo %YELLOW%!%LANG%_MESSAGES[1]! LDFLAGS=%LDFLAGS%, BUILDMODE=%BUILDMODE%%RESET%
echo %YELLOW%CGO_ENABLED=%CGO_ENABLED%%RESET%

:: 清理旧的构建文件 / Clean old builds
echo %YELLOW%!%LANG%_MESSAGES[2]!%RESET%
if exist "..\bin" (
rd /s /q "..\bin"
echo %GREEN%!%LANG%_MESSAGES[3]!%RESET%
) else (
echo %YELLOW%!%LANG%_MESSAGES[4]!%RESET%
)

:: 创建输出目录 / Create output directory
mkdir "..\bin" 2>nul

:: 定义目标平台数组 / Define target platforms array
set platforms[0].os=windows
set platforms[0].arch=amd64
set platforms[0].ext=.exe
set platforms[0].suffix=

set platforms[1].os=darwin
set platforms[1].arch=amd64
set platforms[1].ext=
set platforms[1].suffix=_intel

set platforms[2].os=darwin
set platforms[2].arch=arm64
set platforms[2].ext=
set platforms[2].suffix=_m1

set platforms[3].os=linux
set platforms[3].arch=amd64
set platforms[3].ext=
set platforms[3].suffix=

:: 设置开始时间 / Set start time
set start_time=%time%

:: 编译所有目标 / Build all targets
echo !%LANG%_MESSAGES[5]!

for /L %%i in (0,1,3) do (
set "os=!platforms[%%i].os!"
set "arch=!platforms[%%i].arch!"
set "ext=!platforms[%%i].ext!"
set "suffix=!platforms[%%i].suffix!"

echo.
echo !%LANG%_MESSAGES[6]! !os! !arch!...

set GOOS=!os!
set GOARCH=!arch!

:: 构建输出文件名 / Build output filename
set "outfile=..\bin\cursor_id_modifier_v%VERSION%_!os!_!arch!!suffix!!ext!"

:: 执行构建 / Execute build
go build -trimpath -buildmode=%BUILDMODE% -ldflags="%LDFLAGS%" -gcflags="%GCFLAGS%" -o "!outfile!" ..\main.go

if !errorlevel! equ 0 (
echo %GREEN%!%LANG%_MESSAGES[7]! !outfile!%RESET%
) else (
echo %RED%!%LANG%_MESSAGES[8]! !os! !arch!%RESET%
)
)

:: 计算总耗时 / Calculate total time
set end_time=%time%
set /a duration = %end_time:~0,2% * 3600 + %end_time:~3,2% * 60 + %end_time:~6,2% - (%start_time:~0,2% * 3600 + %start_time:~3,2% * 60 + %start_time:~6,2%)

echo.
echo %GREEN%!%LANG%_MESSAGES[9]! %duration% !%LANG%_MESSAGES[10]!%RESET%
if exist "..\bin" dir /b "..\bin"

pause
endlocal
Loading

0 comments on commit 3316f8b

Please sign in to comment.