diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9feeb88 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + check-latest: true + + - name: Set Repository Variables + run: | + echo "GITHUB_REPOSITORY_OWNER=$(echo ${{ github.repository }} | cut -d '/' -f 1)" >> $GITHUB_ENV + echo "GITHUB_REPOSITORY_NAME=$(echo ${{ github.repository }} | cut -d '/' -f 2)" >> $GITHUB_ENV + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 5bbf1e9..bab1c11 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,6 @@ go.sum # System files .DS_Store -Thumbs.db \ No newline at end of file +Thumbs.db + +.vscode diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..862b38d --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,56 @@ +project_name: cursor-id-modifier + +before: + hooks: + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + ldflags: + - -s -w -X main.version={{.Version}} + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + mod_timestamp: '{{ .CommitTimestamp }}' + flags: + - -trimpath + binary: cursor_id_modifier_{{ .Version }}_{{ .Os }}_{{ .Arch }} + +archives: + - format: binary + name_template: "{{ .Binary }}" + allow_different_binary_count: true + +changelog: + use: github + sort: asc + groups: + - title: Features + regexp: "^.*feat[(\\w)]*:+.*$" + order: 0 + - title: 'Bug Fixes' + regexp: "^.*fix[(\\w)]*:+.*$" + order: 1 + - title: Others + order: 999 + filters: + exclude: + - '^docs:' + - '^test:' + - '^ci:' + - '^chore:' + - Merge pull request + - Merge branch + +release: + github: + owner: '{{ .Env.GITHUB_REPOSITORY_OWNER }}' + name: '{{ .Env.GITHUB_REPOSITORY_NAME }}' + draft: false + prerelease: auto + mode: replace diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index c37fb4b..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "cSpell.words": [ - "apprun", - "buildmode", - "certutil", - "dylib", - "enabledelayedexpansion", - "endlocal", - "errorlevel", - "fatih", - "gcflags", - "GOARCH", - "hashfile", - "IMAGENAME", - "killall", - "ldflags", - "LOCALAPPDATA", - "mktemp", - "msys", - "pgrep", - "pkill", - "runas", - "setlocal", - "taskkill", - "tasklist", - "trimpath", - "urandom", - "uuidgen", - "xattr" - ] -} \ No newline at end of file diff --git a/README.md b/README.md index b8e8f7a..099207a 100644 --- a/README.md +++ b/README.md @@ -27,69 +27,22 @@ this is a mistake. ### ๐Ÿ’ป System Support -**Windows** โœ… x64 -**macOS** โœ… Intel & M-series -**Linux** โœ… x64 & ARM64 +**Windows** โœ… AMD64 & ARM64 +**macOS** โœ… AMD64 & ARM64 +**Linux** โœ… AMD64 & ARM64 ### ๐Ÿ“ฅ Installation -#### Automatic Installation - **Linux/macOS** ```bash -curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/install.sh | bash -s -- --auto-sudo && rm -f /tmp/cursor_id_modifier_* +curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/install.sh | bash ``` **Windows** (Run in PowerShell as Admin) ```powershell -Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/bin/cursor_id_modifier_v2.5.0_windows_amd64.exe')); Remove-Item -Path "$env:TEMP\cursor-id-modifier.exe" -ErrorAction SilentlyContinue +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 ``` -#### Manual 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" - } - ``` -5. Save the file and restart Cursor - -#### Script Method (Alternative) - -If you prefer using scripts directly, you can use these platform-specific scripts: - -**For Linux/macOS:** -1. Download the [cursor_modifier.sh](cursor_modifier.sh) -2. Make it executable: - ```bash - chmod +x cursor_modifier.sh - ``` -3. Run with sudo: - ```bash - sudo ./cursor_modifier.sh - ``` - -**For Windows:** -1. Download the [cursor_modifier.bat](cursor_modifier.bat) -2. Right-click and "Run as administrator" - -These scripts will: -- Automatically detect system language (English/Chinese) -- Check for and close any running Cursor instances -- Generate new random IDs -- Update the configuration file -- Show the results with a nice UI - ### ๐Ÿ”ง Technical Details The program modifies Cursor's `storage.json` config file: @@ -120,69 +73,22 @@ this is a mistake. ### ๐Ÿ’ป ็ณป็ปŸๆ”ฏๆŒ -**Windows** โœ… x64 -**macOS** โœ… Intelๅ’ŒM็ณปๅˆ— -**Linux** โœ… x64ๅ’ŒARM64 +**Windows** โœ… AMD64ๅ’ŒARM64 +**macOS** โœ… AMD64ๅ’ŒARM64 +**Linux** โœ… AMD64ๅ’ŒARM64 ### ๐Ÿ“ฅ ๅฎ‰่ฃ…ๆ–นๆณ• -#### ่‡ชๅŠจๅฎ‰่ฃ… - **Linux/macOS** ```bash -curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/install.sh | bash -s -- --auto-sudo && rm -f /tmp/cursor_id_modifier_* +curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/master/install.sh | bash ``` **Windows** (ไปฅ็ฎก็†ๅ‘˜่บซไปฝ่ฟ่กŒPowerShell) ```powershell -Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/bin/cursor_id_modifier_v2.5.0_windows_amd64.exe')); Remove-Item -Path "$env:TEMP\cursor-id-modifier.exe" -ErrorAction SilentlyContinue +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 ``` -#### ๆ‰‹ๅŠจๆ–นๆณ• - -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" - } - ``` -5. ไฟๅญ˜ๆ–‡ไปถๅนถ้‡ๅฏ Cursor - -#### ่„šๆœฌๆ–นๆณ•๏ผˆๆ›ฟไปฃๆ–นๆณ•๏ผ‰ - -ๅฆ‚ๆžœๆ‚จๅ–œๆฌข็›ดๆŽฅไฝฟ็”จ่„šๆœฌ๏ผŒๅฏไปฅไฝฟ็”จ่ฟ™ไบ›็‰นๅฎšๅนณๅฐ็š„่„šๆœฌ๏ผš - -**้€‚็”จไบŽ Linux/macOS๏ผš** -1. ไธ‹่ฝฝ [cursor_modifier.sh](cursor_modifier.sh) -2. ไฝฟๅ…ถๅฏๆ‰ง่กŒ๏ผš - ```bash - chmod +x cursor_modifier.sh - ``` -3. ็”จ sudo ่ฟ่กŒ - ```bash - sudo ./cursor_modifier.sh - ``` - -**้€‚็”จไบŽ Windows๏ผš** -1. ไธ‹่ฝฝ [cursor_modifier.bat](cursor_modifier.bat) -2. ๅณ้”ฎๅ•ๅ‡ปๅนถ โ€œไปฅ็ฎก็†ๅ‘˜่บซไปฝ่ฟ่กŒโ€ใ€‚ - -่ฟ™ไบ›่„šๆœฌๅฐ† -- ่‡ชๅŠจๆฃ€ๆต‹็ณป็ปŸ่ฏญ่จ€๏ผˆ่‹ฑ่ฏญ/ไธญๆ–‡๏ผ‰ -- ๆฃ€ๆŸฅๅนถๅ…ณ้—ญไปปไฝ•ๆญฃๅœจ่ฟ่กŒ็š„ๅ…‰ๆ ‡ๅฎžไพ‹ -- ็”Ÿๆˆๆ–ฐ็š„้šๆœบ ID -- ๆ›ดๆ–ฐ้…็ฝฎๆ–‡ไปถ -- ไปฅๆผ‚ไบฎ็š„็”จๆˆท็•Œ้ขๆ˜พ็คบ็ป“ๆžœ - ### ๐Ÿ”ง ๆŠ€ๆœฏ็ป†่Š‚ ็จ‹ๅบไฟฎๆ”นCursor็š„`storage.json`้…็ฝฎๆ–‡ไปถ๏ผš @@ -201,14 +107,3 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManage 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. - diff --git a/bin/cursor_id_modifier_v2.5.0_darwin_amd64_intel b/bin/cursor_id_modifier_v2.5.0_darwin_amd64_intel deleted file mode 100644 index d400db4..0000000 Binary files a/bin/cursor_id_modifier_v2.5.0_darwin_amd64_intel and /dev/null differ diff --git a/bin/cursor_id_modifier_v2.5.0_darwin_arm64_m1 b/bin/cursor_id_modifier_v2.5.0_darwin_arm64_m1 deleted file mode 100644 index 4d58680..0000000 Binary files a/bin/cursor_id_modifier_v2.5.0_darwin_arm64_m1 and /dev/null differ diff --git a/bin/cursor_id_modifier_v2.5.0_linux_amd64 b/bin/cursor_id_modifier_v2.5.0_linux_amd64 deleted file mode 100644 index 84af9f7..0000000 Binary files a/bin/cursor_id_modifier_v2.5.0_linux_amd64 and /dev/null differ diff --git a/bin/cursor_id_modifier_v2.5.0_windows_amd64.exe b/bin/cursor_id_modifier_v2.5.0_windows_amd64.exe deleted file mode 100644 index 463b6e0..0000000 Binary files a/bin/cursor_id_modifier_v2.5.0_windows_amd64.exe and /dev/null differ diff --git a/bin/md5_checksums.txt b/bin/md5_checksums.txt deleted file mode 100644 index 3f59c53..0000000 --- a/bin/md5_checksums.txt +++ /dev/null @@ -1,7 +0,0 @@ -MD5 Checksums -============= - -c3f03388afd01cd2d9f6c58348abf8e1 cursor_id_modifier_v2.5.0_windows_amd64.exe -b2caec6c3bede8f51245e5b74b11b96c cursor_id_modifier_v2.5.0_darwin_amd64_intel -8e93f913d653e26bf522bde78b51a26a cursor_id_modifier_v2.5.0_darwin_arm64_m1 -73db2eb340c0f5878a206ddc63693f77 cursor_id_modifier_v2.5.0_linux_amd64 diff --git a/cursor_modifier.bat b/cursor_modifier.bat deleted file mode 100644 index 43d38d8..0000000 --- a/cursor_modifier.bat +++ /dev/null @@ -1,139 +0,0 @@ -@echo off -chcp 65001 >nul -setlocal EnableDelayedExpansion - -:: ็‰ˆๆœฌๅท -set "VERSION=2.5.0" - -:: ๆฃ€ๆต‹่ฏญ่จ€ -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" -) - -:: ๅคš่ฏญ่จ€ๆ–‡ๆœฌ -if "%LANG%"=="cn" ( - set "SUCCESS_MSG=[โˆš] ้…็ฝฎๆ–‡ไปถๅทฒๆˆๅŠŸๆ›ดๆ–ฐ๏ผ" - set "RESTART_MSG=[!] ่ฏทๆ‰‹ๅŠจ้‡ๅฏ Cursor ไปฅไฝฟๆ›ดๆ–ฐ็”Ÿๆ•ˆ" - set "READING_CONFIG=ๆญฃๅœจ่ฏปๅ–้…็ฝฎๆ–‡ไปถ..." - set "GENERATING_IDS=ๆญฃๅœจ็”Ÿๆˆๆ–ฐ็š„ๆ ‡่ฏ†็ฌฆ..." - set "CHECKING_PROCESSES=ๆญฃๅœจๆฃ€ๆŸฅ่ฟ่กŒไธญ็š„ Cursor ๅฎžไพ‹..." - set "CLOSING_PROCESSES=ๆญฃๅœจๅ…ณ้—ญ Cursor ๅฎžไพ‹..." - set "PROCESSES_CLOSED=ๆ‰€ๆœ‰ Cursor ๅฎžไพ‹ๅทฒๅ…ณ้—ญ" - set "PLEASE_WAIT=่ฏท็จๅ€™..." -) else ( - set "SUCCESS_MSG=[โˆš] Configuration file updated successfully!" - set "RESTART_MSG=[!] Please restart Cursor manually for changes to take effect" - set "READING_CONFIG=Reading configuration file..." - set "GENERATING_IDS=Generating new identifiers..." - set "CHECKING_PROCESSES=Checking for running Cursor instances..." - set "CLOSING_PROCESSES=Closing Cursor instances..." - set "PROCESSES_CLOSED=All Cursor instances have been closed" - set "PLEASE_WAIT=Please wait..." -) - -:: ๆฃ€ๆŸฅ็ฎก็†ๅ‘˜ๆƒ้™ -net session >nul 2>&1 -if %errorLevel% neq 0 ( - echo ่ฏทไปฅ็ฎก็†ๅ‘˜่บซไปฝ่ฟ่กŒๆญค่„šๆœฌ - echo Please run this script as administrator - pause - exit /b 1 -) - -:: ไธป็จ‹ๅบ -:main -cls -call :printBanner - -echo %CHECKING_PROCESSES% -tasklist | find /i "Cursor.exe" >nul -if %errorLevel% equ 0 ( - echo %CLOSING_PROCESSES% - taskkill /F /IM "Cursor.exe" >nul 2>&1 - timeout /t 2 >nul - echo %PROCESSES_CLOSED% -) - -set "CONFIG_PATH=%APPDATA%\Cursor\User\globalStorage\storage.json" -echo %READING_CONFIG% - -echo %GENERATING_IDS% -:: ็”Ÿๆˆ้šๆœบID -set "machineId=" -set "macMachineId=" -set "devDeviceId=" -set "sqmId=" - -:: ็”Ÿๆˆ32ไฝ้šๆœบID -for /L %%i in (1,1,32) do ( - set /a "r=!random! %% 16" - set "hex=0123456789abcdef" - for %%j in (!r!) do set "machineId=!machineId!!hex:~%%j,1!" -) - -for /L %%i in (1,1,32) do ( - set /a "r=!random! %% 16" - for %%j in (!r!) do set "macMachineId=!macMachineId!!hex:~%%j,1!" -) - -:: ็”ŸๆˆUUIDๆ ผๅผ็š„devDeviceId -for /L %%i in (1,1,32) do ( - set /a "r=!random! %% 16" - for %%j in (!r!) do set "devDeviceId=!devDeviceId!!hex:~%%j,1!" - if %%i==8 set "devDeviceId=!devDeviceId!-" - if %%i==12 set "devDeviceId=!devDeviceId!-" - if %%i==16 set "devDeviceId=!devDeviceId!-" - if %%i==20 set "devDeviceId=!devDeviceId!-" -) - -for /L %%i in (1,1,32) do ( - set /a "r=!random! %% 16" - for %%j in (!r!) do set "sqmId=!sqmId!!hex:~%%j,1!" -) - -:: ๅˆ›ๅปบ้…็ฝฎ็›ฎๅฝ• -if not exist "%APPDATA%\Cursor\User\globalStorage" ( - mkdir "%APPDATA%\Cursor\User\globalStorage" -) - -:: ็”Ÿๆˆ้…็ฝฎๆ–‡ไปถ -( -echo { -echo "telemetry.macMachineId": "%macMachineId%", -echo "telemetry.machineId": "%machineId%", -echo "telemetry.devDeviceId": "%devDeviceId%", -echo "telemetry.sqmId": "%sqmId%" -echo } -) > "%CONFIG_PATH%" - -echo. -echo ============================================================ -echo %SUCCESS_MSG% -echo %RESTART_MSG% -echo ============================================================ -echo. -echo Config file location: -echo %CONFIG_PATH% -echo. -pause -exit /b - -:: ๆ‰“ๅฐbanner -:printBanner -echo. -echo โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— -echo โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•— -echo โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• -echo โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ•šโ•โ•โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•— -echo โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ -echo โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ• โ•šโ•โ•โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ• โ•šโ•โ• -echo. -echo ^>^> Cursor ID Modifier v1.0 ^<^< -echo [ By Pancake Fruit Rolled Shark Chili ] -echo. -exit /b - -endlocal \ No newline at end of file diff --git a/cursor_modifier.sh b/cursor_modifier.sh deleted file mode 100644 index 752108b..0000000 --- a/cursor_modifier.sh +++ /dev/null @@ -1,211 +0,0 @@ -#!/bin/bash - -# ็‰ˆๆœฌๅท - ไธŽๅ…ถไป–ๆ–‡ไปถไฟๆŒไธ€่‡ด -VERSION="2.5.0" - -# ้ขœ่‰ฒๅฎšไน‰ -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -CYAN='\033[0;36m' -NC='\033[0m' - -# ่ฏญ่จ€ๆฃ€ๆต‹ไผ˜ๅŒ– -detect_language() { - local lang - if [ -n "$LANG" ]; then - lang="$LANG" - else - lang=$(locale | grep "LANG=" | cut -d= -f2) - fi - - if [[ $lang == *"zh"* ]]; then - echo "cn" - else - echo "en" - fi -} - -LANG=$(detect_language) - -# ๅคš่ฏญ่จ€ๆ–‡ๆœฌ - ไฟฎๅค็ผ–็ ้—ฎ้ข˜ -if [ "$LANG" == "cn" ]; then - SUCCESS_MSG="[โˆš] ้…็ฝฎๆ–‡ไปถๅทฒๆˆๅŠŸๆ›ดๆ–ฐ๏ผ" - RESTART_MSG="[!] ่ฏทๆ‰‹ๅŠจ้‡ๅฏ Cursor ไปฅไฝฟๆ›ดๆ–ฐ็”Ÿๆ•ˆ" - READING_CONFIG="ๆญฃๅœจ่ฏปๅ–้…็ฝฎๆ–‡ไปถ..." - GENERATING_IDS="ๆญฃๅœจ็”Ÿๆˆๆ–ฐ็š„ๆ ‡่ฏ†็ฌฆ..." - CHECKING_PROCESSES="ๆญฃๅœจๆฃ€ๆŸฅ่ฟ่กŒไธญ็š„ Cursor ๅฎžไพ‹..." - CLOSING_PROCESSES="ๆญฃๅœจๅ…ณ้—ญ Cursor ๅฎžไพ‹..." - PROCESSES_CLOSED="ๆ‰€ๆœ‰ Cursor ๅฎžไพ‹ๅทฒๅ…ณ้—ญ" - PLEASE_WAIT="่ฏท็จๅ€™..." - ERROR_NO_ROOT="่ฏทไฝฟ็”จ sudo ่ฟ่กŒๆญค่„šๆœฌ" - ERROR_CONFIG_PATH="ๆ— ๆณ•่Žทๅ–้…็ฝฎๆ–‡ไปถ่ทฏๅพ„" - ERROR_CREATE_DIR="ๆ— ๆณ•ๅˆ›ๅปบ้…็ฝฎ็›ฎๅฝ•" - ERROR_WRITE_CONFIG="ๆ— ๆณ•ๅ†™ๅ…ฅ้…็ฝฎๆ–‡ไปถ" -else - SUCCESS_MSG="[โˆš] Configuration file updated successfully!" - RESTART_MSG="[!] Please restart Cursor manually for changes to take effect" - READING_CONFIG="Reading configuration file..." - GENERATING_IDS="Generating new identifiers..." - CHECKING_PROCESSES="Checking for running Cursor instances..." - CLOSING_PROCESSES="Closing Cursor instances..." - PROCESSES_CLOSED="All Cursor instances have been closed" - PLEASE_WAIT="Please wait..." - ERROR_NO_ROOT="Please run this script with sudo" - ERROR_CONFIG_PATH="Unable to get config file path" - ERROR_CREATE_DIR="Unable to create config directory" - ERROR_WRITE_CONFIG="Unable to write config file" -fi - -# ็”Ÿๆˆ้šๆœบID - ๆทปๅŠ ้”™่ฏฏๅค„็† -generate_machine_id() { - if ! command -v openssl >/dev/null 2>&1; then - echo "$(head -c 32 /dev/urandom | xxd -p)" - else - openssl rand -hex 32 - fi -} - -generate_dev_device_id() { - local uuid="" - if command -v uuidgen >/dev/null 2>&1; then - uuid=$(uuidgen) - else - uuid=$(printf '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' \ - $RANDOM $RANDOM \ - $RANDOM \ - $(($RANDOM & 0x0fff | 0x4000)) \ - $(($RANDOM & 0x3fff | 0x8000)) \ - $RANDOM $RANDOM $RANDOM) - fi - echo "$uuid" -} - -# ่Žทๅ–้…็ฝฎๆ–‡ไปถ่ทฏๅพ„ - ไผ˜ๅŒ–่ทฏๅพ„ๅค„็† -get_config_path() { - local username=$1 - case "$(uname)" in - "Darwin") - echo "/Users/$username/Library/Application Support/Cursor/User/globalStorage/storage.json" - ;; - "Linux") - echo "/home/$username/.config/Cursor/User/globalStorage/storage.json" - ;; - *) - echo "" - return 1 - ;; - esac -} - -# ๆฃ€ๆŸฅCursor่ฟ›็จ‹ - ๆทปๅŠ ้”™่ฏฏๅค„็† -check_cursor_running() { - if ! command -v pgrep >/dev/null 2>&1; then - ps aux | grep -i "Cursor\|AppRun" | grep -v grep >/dev/null - else - pgrep -f "Cursor|AppRun" >/dev/null - fi -} - -# ๅ…ณ้—ญCursor่ฟ›็จ‹ - ไผ˜ๅŒ–่ฟ›็จ‹ๅ…ณ้—ญ -kill_cursor_processes() { - echo -e "${CYAN}$CLOSING_PROCESSES${NC}" - if command -v pkill >/dev/null 2>&1; then - pkill -f "Cursor|AppRun" - else - killall Cursor 2>/dev/null - killall AppRun 2>/dev/null - fi - sleep 2 - if check_cursor_running; then - if command -v pkill >/dev/null 2>&1; then - pkill -9 -f "Cursor|AppRun" - else - killall -9 Cursor 2>/dev/null - killall -9 AppRun 2>/dev/null - fi - fi - echo -e "${GREEN}$PROCESSES_CLOSED${NC}" -} - -# ๆ‰“ๅฐbanner - ไฟฎๅคๆ˜พ็คบ้—ฎ้ข˜ -print_banner() { - echo -e "${CYAN}" - echo ' โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— ' - echo ' โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—' - echo ' โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•' - echo ' โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ•šโ•โ•โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—' - echo ' โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘' - echo ' โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ• โ•šโ•โ•โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ• โ•šโ•โ•' - echo -e "${NC}" - echo -e "${YELLOW}\t\t>> Cursor ID Modifier ${VERSION} <<${NC}" - echo -e "${CYAN}\t\t [ By Pancake Fruit Rolled Shark Chili ]${NC}" - echo -} - -# ไธปๅ‡ฝๆ•ฐ - ๆทปๅŠ ้”™่ฏฏๅค„็† -main() { - # ๆฃ€ๆŸฅrootๆƒ้™ - if [ "$EUID" -ne 0 ]; then - echo -e "${RED}${ERROR_NO_ROOT}${NC}" - exit 1 - fi - - # ่Žทๅ–ๅฎž้™…็”จๆˆทๅ - REAL_USER=${SUDO_USER:-$USER} - - clear - print_banner - - # ็กฎไฟCursorๅทฒๅ…ณ้—ญ - if check_cursor_running; then - kill_cursor_processes - fi - - CONFIG_PATH=$(get_config_path "$REAL_USER") - if [ -z "$CONFIG_PATH" ]; then - echo -e "${RED}${ERROR_CONFIG_PATH}${NC}" - exit 1 - fi - echo -e "${CYAN}$READING_CONFIG${NC}" - - # ็”Ÿๆˆๆ–ฐ้…็ฝฎ - echo -e "${CYAN}$GENERATING_IDS${NC}" - NEW_CONFIG=$(cat </dev/null; then - echo -e "${RED}${ERROR_CREATE_DIR}${NC}" - exit 1 - fi - - # ไฟๅญ˜้…็ฝฎ - if ! echo "$NEW_CONFIG" > "$CONFIG_PATH"; then - echo -e "${RED}${ERROR_WRITE_CONFIG}${NC}" - exit 1 - fi - - chown "$REAL_USER" "$CONFIG_PATH" 2>/dev/null - chmod 644 "$CONFIG_PATH" 2>/dev/null - - # ๆ˜พ็คบๆˆๅŠŸๆถˆๆฏ - echo -e "\n${GREEN}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}" - echo -e "${GREEN}$SUCCESS_MSG${NC}" - echo -e "${YELLOW}$RESTART_MSG${NC}" - echo -e "${GREEN}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}" - - echo -e "\n้…็ฝฎๆ–‡ไปถไฝ็ฝฎ/Config file location:" - echo -e "${CYAN}$CONFIG_PATH${NC}\n" - - read -p "Press Enter to exit..." -} - -main "$@" \ No newline at end of file diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 29b582b..08a47ce --- a/install.sh +++ b/install.sh @@ -1,255 +1,50 @@ -#!/bin/bash +#!/usr/bin/env bash -# Version / ็‰ˆๆœฌๅท -VERSION="v2.5.0" - -# Configuration / ้…็ฝฎ -KEEP_BINARY=false -DOWNLOAD_DIR="/tmp" -INSTALL_DIR="/usr/local/bin" -AUTO_SUDO=false - -# Colors / ้ขœ่‰ฒ -RED='\033[31m' -GREEN='\033[32m' -YELLOW='\033[33m' -BLUE='\033[36m' -BOLD='\033[1m' -NC='\033[0m' - -# Separator / ๅˆ†้š”็บฟ -SEPARATOR="${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}" - -# Bilingual message functions / ๅŒ่ฏญๆถˆๆฏๅ‡ฝๆ•ฐ +# Error handling error() { - echo -e "\n${SEPARATOR}" - echo -e "${RED}${BOLD}โŒ Error:${NC} $1" - echo -e "${RED}${BOLD}โŒ ้”™่ฏฏ๏ผš${NC}$2" - echo -e "${SEPARATOR}\n" + echo -e "\033[31m\033[1mError:\033[0m $1" >&2 exit 1 } -info() { - echo -e "\n${BLUE}${BOLD}โ„น๏ธ [EN]:${NC} $1" - echo -e "${BLUE}${BOLD}โ„น๏ธ [ไธญๆ–‡]:${NC} $2\n" -} - -success() { - echo -e "\n${SEPARATOR}" - echo -e "${GREEN}${BOLD}โœ… [EN]:${NC} $1" - echo -e "${GREEN}${BOLD}โœ… [ไธญๆ–‡]:${NC} $2" - echo -e "${SEPARATOR}\n" -} - -warning() { - echo -e "\n${YELLOW}${BOLD}โš ๏ธ [EN]:${NC} $1" - echo -e "${YELLOW}${BOLD}โš ๏ธ [ไธญๆ–‡]:${NC} $2\n" -} - -# System detection / ็ณป็ปŸๆฃ€ๆต‹ -detect_platform() { - OS=$(uname -s | tr '[:upper:]' '[:lower:]') - ARCH=$(uname -m) - - case "$OS" in - linux*) - case "$ARCH" in - x86_64) BINARY_NAME="cursor_id_modifier_${VERSION}_linux_amd64" ;; - *) error "Unsupported Linux architecture: $ARCH" "ไธๆ”ฏๆŒ็š„Linuxๆžถๆž„๏ผš$ARCH" ;; - esac - ;; - darwin*) - case "$ARCH" in - x86_64) BINARY_NAME="cursor_id_modifier_${VERSION}_darwin_amd64_intel" ;; - arm64) BINARY_NAME="cursor_id_modifier_${VERSION}_darwin_arm64_m1" ;; - *) error "Unsupported macOS architecture: $ARCH" "ไธๆ”ฏๆŒ็š„macOSๆžถๆž„๏ผš$ARCH" ;; - esac - ;; - msys*|mingw*|cygwin*) - case "$ARCH" in - x86_64) BINARY_NAME="cursor_id_modifier_${VERSION}_windows_amd64.exe" ;; - *) error "Unsupported Windows architecture: $ARCH" "ไธๆ”ฏๆŒ็š„Windowsๆžถๆž„๏ผš$ARCH" ;; - esac - ;; - *) - error "Unsupported operating system: $OS" "ไธๆ”ฏๆŒ็š„ๆ“ไฝœ็ณป็ปŸ๏ผš$OS" - ;; - esac -} - -# System checks / ็ณป็ปŸๆฃ€ๆŸฅ -check_requirements() { - info "Checking system requirements..." "ๆญฃๅœจๆฃ€ๆŸฅ็ณป็ปŸ่ฆๆฑ‚..." - - # Check network connectivity / ๆฃ€ๆŸฅ็ฝ‘็ปœ่ฟžๆŽฅ - if ! ping -c 1 github.com >/dev/null 2>&1; then - error "No network connection to GitHub" "ๆ— ๆณ•่ฟžๆŽฅๅˆฐ GitHub" - fi - - # Check curl / ๆฃ€ๆŸฅcurl - if ! command -v curl >/dev/null 2>&1; then - error "curl is required. Please install curl first." \ - "้œ€่ฆๅฎ‰่ฃ… curlใ€‚่ฏทๅ…ˆๅฎ‰่ฃ… curl ๅŽๅ†่ฟ่กŒๆญค่„šๆœฌใ€‚" - fi -} - -# Privilege check / ๆƒ้™ๆฃ€ๆŸฅ -check_privileges() { - if [ "$EUID" -ne 0 ]; then - if [ "$AUTO_SUDO" = "true" ]; then - if command -v sudo >/dev/null 2>&1; then - info "Re-running with sudo..." "ไฝฟ็”จ sudo ้‡ๆ–ฐ่ฟ่กŒ..." - exec sudo bash "$0" "$@" - else - error "This script must be run as root. Please use sudo." \ - "ๆญค่„šๆœฌๅฟ…้กปไปฅ root ่บซไปฝ่ฟ่กŒใ€‚่ฏทไฝฟ็”จ sudoใ€‚" - fi - else - error "This script must be run as root. Please use sudo." \ - "ๆญค่„šๆœฌๅฟ…้กปไปฅ root ่บซไปฝ่ฟ่กŒใ€‚่ฏทไฝฟ็”จ sudoใ€‚" - fi - fi -} - -# Binary verification / ไบŒ่ฟ›ๅˆถ้ชŒ่ฏ -verify_binary() { - info "Verifying binary..." "ๆญฃๅœจ้ชŒ่ฏไบŒ่ฟ›ๅˆถๆ–‡ไปถ..." - - # Check file existence / ๆฃ€ๆŸฅๆ–‡ไปถๆ˜ฏๅฆๅญ˜ๅœจ - if [ ! -f "$DOWNLOAD_PATH" ]; then - error "Binary file download failed or does not exist" \ - "ไบŒ่ฟ›ๅˆถๆ–‡ไปถไธ‹่ฝฝๅคฑ่ดฅๆˆ–ไธๅญ˜ๅœจ" - fi - - # Check executable format / ๆฃ€ๆŸฅๅฏๆ‰ง่กŒๆ ผๅผ - if ! file "$DOWNLOAD_PATH" | grep -q "executable"; then - error "Downloaded file is not an executable" \ - "ไธ‹่ฝฝ็š„ๆ–‡ไปถไธๆ˜ฏๅฏๆ‰ง่กŒๆ–‡ไปถ" - fi - - # Check file size / ๆฃ€ๆŸฅๆ–‡ไปถๅคงๅฐ - local size=$(wc -c < "$DOWNLOAD_PATH") - if [ "$size" -lt 1000000 ]; then # At least 1MB / ่‡ณๅฐ‘1MB - error "Downloaded file size is abnormal" \ - "ไธ‹่ฝฝ็š„ๆ–‡ไปถๅคงๅฐๅผ‚ๅธธ" - fi +# Detect platform +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +ARCH=$(uname -m) - # Set executable permissions / ่ฎพ็ฝฎๅฏๆ‰ง่กŒๆƒ้™ - info "Setting executable permissions..." "ๆญฃๅœจ่ฎพ็ฝฎๅฏๆ‰ง่กŒๆƒ้™..." - if ! chmod +x "$DOWNLOAD_PATH"; then - error "Failed to set executable permissions" "ๆ— ๆณ•่ฎพ็ฝฎๅฏๆ‰ง่กŒๆƒ้™" - fi -} +# Get latest version +VERSION=$(curl -sL "https://api.github.com/repos/realies/go-cursor-help/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') +[ -z "$VERSION" ] && error "Could not determine latest version" -# Cleanup functions / ๆธ…็†ๅ‡ฝๆ•ฐ -cleanup_old_version() { - if [ -f "$INSTALL_DIR/cursor-id-modifier" ]; then - info "Removing old version..." "ๆญฃๅœจๅˆ ้™คๆ—ง็‰ˆ..." - rm -f "$INSTALL_DIR/cursor-id-modifier" || \ - error "Failed to remove old version" "ๅˆ ้™คๆ—ง็‰ˆๆœฌๅคฑ่ดฅ" - fi -} - -cleanup_temp_files() { - if [ "$KEEP_BINARY" = "false" ]; then - rm -f "$DOWNLOAD_PATH" - rm -f "$INSTALL_DIR/cursor-id-modifier-wrapper" - fi -} - -# Parse arguments / ่งฃๆžๅ‚ๆ•ฐ -parse_args() { - while [[ $# -gt 0 ]]; do - case $1 in - --auto-sudo) - AUTO_SUDO=true - shift - ;; - --keep-binary) - KEEP_BINARY=true - shift - ;; - --download-dir=*) - DOWNLOAD_DIR="${1#*=}" - shift - ;; - *) - shift - ;; +# Get binary name based on platform +case "$OS" in + linux*) + case "$ARCH" in + x86_64) BINARY="cursor_id_modifier_${VERSION}_linux_amd64" ;; + aarch64|arm64) BINARY="cursor_id_modifier_${VERSION}_linux_arm64" ;; + *) error "Unsupported Linux architecture: $ARCH" ;; esac - done -} + ;; + darwin*) + case "$ARCH" in + x86_64) BINARY="cursor_id_modifier_${VERSION}_darwin_amd64" ;; + arm64) BINARY="cursor_id_modifier_${VERSION}_darwin_arm64" ;; + *) error "Unsupported macOS architecture: $ARCH" ;; + esac + ;; + *) error "Unsupported operating system: $OS" ;; +esac -# Print banner / ๆ‰“ๅฐๆจชๅน… -print_banner() { - echo -e "\n${BLUE}${BOLD}" - echo " โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—" - echo " โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—" - echo " โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•" - echo " โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ•šโ•โ•โ•โ•โ–ˆโ–ˆ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—" - echo " โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘" - echo " โ•šโ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ• โ•šโ•โ•โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ• โ•šโ•โ• โ•šโ•โ•" - echo -e "${NC}" - echo -e "${YELLOW}${BOLD} >> Cursor ID Modifier ${VERSION} <<${NC}" - echo -e "${BLUE}${BOLD} [ By Pancake Fruit Rolled Shark Chili ]${NC}\n" -} +# Set up cleanup trap +trap 'rm -f "./${BINARY}"' EXIT + +# Download and run +DOWNLOAD_URL="https://github.com/realies/go-cursor-help/releases/download/v${VERSION}/${BINARY}" +echo "Downloading from: ${DOWNLOAD_URL}" -# Main installation process / ไธปๅฎ‰่ฃ…ๆต็จ‹ -main() { - check_privileges "$@" - - print_banner - - info "Starting installation of cursor-id-modifier ${VERSION}..." \ - "ๅผ€ๅง‹ๅฎ‰่ฃ… cursor-id-modifier ${VERSION}..." - - detect_platform - check_requirements - - # Create installation directory / ๅˆ›ๅปบๅฎ‰่ฃ…็›ฎๅฝ• - mkdir -p "$INSTALL_DIR" 2>/dev/null || \ - error "Failed to create installation directory" "ๆ— ๆณ•ๅˆ›ๅปบๅฎ‰่ฃ…็›ฎๅฝ•" - - # Download binary / ไธ‹่ฝฝไบŒ่ฟ›ๅˆถๆ–‡ไปถ - info "Downloading cursor-id-modifier ($OS-$ARCH)..." \ - "ๆญฃๅœจไธ‹่ฝฝ cursor-id-modifier ($OS-$ARCH)..." - - DOWNLOAD_URL="https://github.com/yuaotian/go-cursor-help/raw/refs/heads/master/bin/$BINARY_NAME" - DOWNLOAD_PATH="$DOWNLOAD_DIR/$BINARY_NAME" - - if ! curl -L --progress-bar "$DOWNLOAD_URL" -o "$DOWNLOAD_PATH"; then - error "Failed to download binary" "ไธ‹่ฝฝไบŒ่ฟ›ๅˆถๆ–‡ไปถๅคฑ่ดฅ" - fi - - success "Download completed" "ไธ‹่ฝฝๅฎŒๆˆ" - - verify_binary - cleanup_old_version - - # Install binary / ๅฎ‰่ฃ…ไบŒ่ฟ›ๅˆถๆ–‡ไปถ - info "Installing binary..." "ๆญฃๅœจๅฎ‰่ฃ…ไบŒ่ฟ›ๅˆถๆ–‡ไปถ..." - if ! cp "$DOWNLOAD_PATH" "$INSTALL_DIR/cursor-id-modifier"; then - error "Failed to install binary" "ๅฎ‰่ฃ…ไบŒ่ฟ›ๅˆถๆ–‡ไปถๅคฑ่ดฅ" - fi - - # Create wrapper script / ๅˆ›ๅปบๅŒ…่ฃ…่„šๆœฌ - cat > "$INSTALL_DIR/cursor-id-modifier-wrapper" << 'EOF' -#!/bin/bash -if [ "$(uname -s)" = "Darwin" ]; then - sudo /usr/local/bin/cursor-id-modifier "$@" -else - sudo /usr/local/bin/cursor-id-modifier "$@" +# Download with error checking +if ! curl -fL "$DOWNLOAD_URL" -o "./${BINARY}"; then + error "Download failed. HTTP error from GitHub" fi -EOF - chmod +x "$INSTALL_DIR/cursor-id-modifier-wrapper" - - # Cleanup / ๆธ…็† - cleanup_temp_files - - success "Installation successful! Run 'cursor-id-modifier-wrapper' from anywhere." \ - "ๅฎ‰่ฃ…ๆˆๅŠŸ๏ผ็Žฐๅœจๅฏไปฅๅœจไปปไฝ•ไฝ็ฝฎ่ฟ่กŒ 'cursor-id-modifier-wrapper'ใ€‚" -} -# Start installation / ๅผ€ๅง‹ๅฎ‰่ฃ… -parse_args "$@" -main "$@" \ No newline at end of file +chmod +x "./${BINARY}" +echo "Running cursor-id-modifier..." +sudo "./${BINARY}" diff --git a/main.go b/main.go index 7804ad4..fea54ee 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,9 @@ import ( "github.com/fatih/color" ) +// Version information +var version = "dev" // This will be overwritten by goreleaser + // Types and Constants / ็ฑปๅž‹ๅ’Œๅธธ้‡ type Language string @@ -31,9 +34,6 @@ const ( CN Language = "cn" EN Language = "en" - // Version / ็‰ˆๆœฌๅท - Version = "2.5.0" - // Error types / ้”™่ฏฏ็ฑปๅž‹ ErrPermission = "permission_error" ErrConfig = "config_error" @@ -204,17 +204,15 @@ func generateDevDeviceId() string { } // File Operations / ๆ–‡ไปถๆ“ไฝœ -func getConfigPath(username string) (string, error) { // Modified to take username +func getConfigPath(username string) (string, error) { var configDir string switch runtime.GOOS { case "windows": configDir = filepath.Join(os.Getenv("APPDATA"), "Cursor", "User", "globalStorage") case "darwin": - homeDir := filepath.Join("/home/", username) - configDir = filepath.Join(homeDir, "Library", "Application Support", "Cursor", "User", "globalStorage") + configDir = filepath.Join("/Users", username, "Library", "Application Support", "Cursor", "User", "globalStorage") case "linux": - homeDir := filepath.Join("/home/", username) - configDir = filepath.Join(homeDir, ".config", "Cursor", "User", "globalStorage") + configDir = filepath.Join("/home", username, ".config", "Cursor", "User", "globalStorage") default: return "", fmt.Errorf("unsupported operating system: %s", runtime.GOOS) } @@ -884,7 +882,7 @@ func printCyberpunkBanner() { โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ• โ•šโ•โ•โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ• โ•šโ•โ• ` cyan.Println(banner) - yellow.Println("\t\t>> Cursor ID Modifier v1.0 <<") + yellow.Printf("\t\t>> Cursor ID Modifier %s <<\n", version) magenta.Println("\t\t [ By Pancake Fruit Rolled Shark Chili ]") langText := "ๅฝ“ๅ‰่ฏญ่จ€/Language: " diff --git a/scripts/build_all.bat b/scripts/build_all.bat deleted file mode 100644 index 42e7f3a..0000000 --- a/scripts/build_all.bat +++ /dev/null @@ -1,118 +0,0 @@ -@echo off -setlocal EnableDelayedExpansion - -:: ่ฎพ็ฝฎ็‰ˆๆœฌไฟกๆฏ -set VERSION=2.5.0 - -:: ่ฎพ็ฝฎ้ขœ่‰ฒไปฃ็  -set "GREEN=[32m" -set "RED=[31m" -set "YELLOW=[33m" -set "RESET=[0m" -set "CYAN=[36m" - -:: ่ฎพ็ฝฎ็ผ–่ฏ‘ไผ˜ๅŒ–ๆ ‡ๅฟ— -set "LDFLAGS=-s -w" -set "BUILDMODE=pie" -set "GCFLAGS=-N -l" - -:: ่ฎพ็ฝฎ CGO -set CGO_ENABLED=0 - -:: ๆ˜พ็คบ็ผ–่ฏ‘ไฟกๆฏ -echo %YELLOW%ๅผ€ๅง‹ๆž„ๅปบ version %VERSION%%RESET% -echo %YELLOW%ไฝฟ็”จไผ˜ๅŒ–ๆ ‡ๅฟ—: LDFLAGS=%LDFLAGS%, BUILDMODE=%BUILDMODE%%RESET% -echo %YELLOW%CGO_ENABLED=%CGO_ENABLED%%RESET% - -:: ๆธ…็†ๆ—ง็š„ๆž„ๅปบๆ–‡ไปถ -echo %YELLOW%ๆธ…็†ๆ—ง็š„ๆž„ๅปบๆ–‡ไปถ...%RESET% -if exist "..\bin" ( - rd /s /q "..\bin" - echo %GREEN%ๆธ…็†ๅฎŒๆˆ%RESET% -) else ( - echo %YELLOW%bin ็›ฎๅฝ•ไธๅญ˜ๅœจ๏ผŒๆ— ้œ€ๆธ…็†%RESET% -) - -:: ๅˆ›ๅปบ่พ“ๅ‡บ็›ฎๅฝ• -mkdir "..\bin" 2>nul - -:: ๅฎšไน‰็›ฎๆ ‡ๅนณๅฐๆ•ฐ็ป„ -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=%time% - -:: ๅˆ›ๅปบ MD5 ไฟกๆฏๆ–‡ไปถ -echo MD5 Checksums > ..\bin\md5_checksums.txt -echo ============= >> ..\bin\md5_checksums.txt -echo. >> ..\bin\md5_checksums.txt - -:: ็ผ–่ฏ‘ๆ‰€ๆœ‰็›ฎๆ ‡ -echo ๅผ€ๅง‹็ผ–่ฏ‘ๆ‰€ๆœ‰ๅนณๅฐ... - -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 Building for !os! !arch!... - - set GOOS=!os! - set GOARCH=!arch! - - :: ๆž„ๅปบ่พ“ๅ‡บๆ–‡ไปถๅ - set "outfile=..\bin\cursor_id_modifier_v%VERSION%_!os!_!arch!!suffix!!ext!" - - :: ๆ‰ง่กŒๆž„ๅปบ - go build -trimpath -buildmode=%BUILDMODE% -ldflags="%LDFLAGS%" -gcflags="%GCFLAGS%" -o "!outfile!" ..\main.go - - if !errorlevel! equ 0 ( - echo %GREEN%Build successful: !outfile!%RESET% - - :: ่ฎก็ฎ—ๅนถๆ˜พ็คบ MD5 - certutil -hashfile "!outfile!" MD5 | findstr /v "CertUtil" | findstr /v "MD5" > md5.tmp - set /p MD5=> ..\bin\md5_checksums.txt - echo %CYAN%MD5: !MD5!%RESET% - ) else ( - echo %RED%Build failed for !os! !arch!%RESET% - ) -) - -:: ่ฎก็ฎ—ๆ€ป่€—ๆ—ถ -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%ๆ‰€ๆœ‰ๆž„ๅปบๅฎŒๆˆ! ๆ€ป่€—ๆ—ถ: %duration% ็ง’%RESET% -echo %CYAN%MD5 ๆ ก้ชŒๅ€ผๅทฒไฟๅญ˜ๅˆฐ bin/md5_checksums.txt%RESET% -if exist "..\bin" dir /b "..\bin" - -:: ๆ˜พ็คบ MD5 ๆ ก้ชŒๆ–‡ไปถๅ†…ๅฎน -echo. -echo %YELLOW%MD5 ๆ ก้ชŒๅ€ผ:%RESET% -type ..\bin\md5_checksums.txt - -pause -endlocal \ No newline at end of file diff --git a/scripts/build_all.sh b/scripts/build_all.sh deleted file mode 100644 index 0f8b9eb..0000000 --- a/scripts/build_all.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash - -# ่ฎพ็ฝฎ้ขœ่‰ฒไปฃ็  -GREEN='\033[0;32m' -RED='\033[0;31m' -NC='\033[0m' # No Color - -# ็‰ˆๆœฌไฟกๆฏ -VERSION="2.5.0" - -# ้”™่ฏฏๅค„็†ๅ‡ฝๆ•ฐ -handle_error() { - echo -e "${RED}Error: $1${NC}" - exit 1 -} - -# ๆธ…็†ๅ‡ฝๆ•ฐ -cleanup() { - echo "Cleaning old builds..." - rm -rf ../bin -} - -# ๅˆ›ๅปบ่พ“ๅ‡บ็›ฎๅฝ• -create_output_dir() { - echo "Creating bin directory..." - mkdir -p ../bin || handle_error "Failed to create bin directory" -} - -# ๆž„ๅปบๅ‡ฝๆ•ฐ -build() { - local os=$1 - local arch=$2 - local suffix=$3 - - echo -e "\nBuilding for $os ($arch)..." - - output_name="../bin/cursor_id_modifier_v${VERSION}_${os}_${arch}${suffix}" - - GOOS=$os GOARCH=$arch go build -o "$output_name" ../main.go - - if [ $? -eq 0 ]; then - echo -e "${GREEN}โœ“ Successfully built: ${output_name}${NC}" - else - echo -e "${RED}โœ— Failed to build for $os $arch${NC}" - return 1 - fi -} - -# ไธปๅ‡ฝๆ•ฐ -main() { - # ๆ˜พ็คบๆž„ๅปบไฟกๆฏ - echo "Starting build process for version ${VERSION}" - - # ๆธ…็†ๆ—งๆ–‡ไปถ - cleanup - - # ๅˆ›ๅปบ่พ“ๅ‡บ็›ฎๅฝ• - create_output_dir - - # ๅฎšไน‰ๆž„ๅปบ็›ฎๆ ‡ - declare -A targets=( - ["windows_amd64"]=".exe" - ["darwin_amd64"]="" - ["darwin_arm64"]="" - ["linux_amd64"]="" - ) - - # ๆž„ๅปบ่ฎกๆ•ฐๅ™จ - local success_count=0 - local fail_count=0 - - # ้ๅކๆ‰€ๆœ‰็›ฎๆ ‡่ฟ›่กŒๆž„ๅปบ - for target in "${!targets[@]}"; do - os=${target%_*} - arch=${target#*_} - suffix=${targets[$target]} - - if build "$os" "$arch" "$suffix"; then - ((success_count++)) - else - ((fail_count++)) - fi - done - - # ๆ˜พ็คบๆž„ๅปบ็ป“ๆžœ - echo -e "\nBuild Summary:" - echo -e "${GREEN}Successful builds: $success_count${NC}" - if [ $fail_count -gt 0 ]; then - echo -e "${RED}Failed builds: $fail_count${NC}" - fi - - # ๆ˜พ็คบ็”Ÿๆˆ็š„ๆ–‡ไปถๅˆ—่กจ - echo -e "\nGenerated files:" - ls -1 ../bin -} - -# ๆ•่Žท้”™่ฏฏไฟกๅท -trap 'echo -e "\n${RED}Build process interrupted${NC}"; exit 1' INT TERM - -# ๆ‰ง่กŒไธปๅ‡ฝๆ•ฐ -main \ No newline at end of file diff --git a/scripts/build_linux.sh b/scripts/build_linux.sh deleted file mode 100644 index d123076..0000000 --- a/scripts/build_linux.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -echo "Building for Linux..." -export GOOS=linux -export GOARCH=amd64 -go build -o ../bin/cursor_id_modifier_linux ../main.go -echo "Build complete: ../bin/cursor_id_modifier_linux" \ No newline at end of file diff --git a/scripts/build_mac.sh b/scripts/build_mac.sh deleted file mode 100644 index 02b48ab..0000000 --- a/scripts/build_mac.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -echo "Building for macOS..." -export GOOS=darwin -export GOARCH=amd64 -go build -o ../bin/cursor_id_modifier_mac ../main.go -echo "Build complete: ../bin/cursor_id_modifier_mac" - -# Build for Apple Silicon -echo "Building for macOS ARM64..." -export GOOS=darwin -export GOARCH=arm64 -go build -o ../bin/cursor_id_modifier_mac_arm64 ../main.go -echo "Build complete: ../bin/cursor_id_modifier_mac_arm64" \ No newline at end of file diff --git a/scripts/build_windows.bat b/scripts/build_windows.bat deleted file mode 100644 index 6481f33..0000000 --- a/scripts/build_windows.bat +++ /dev/null @@ -1,6 +0,0 @@ -@echo off -echo Building for Windows... -set GOOS=windows -set GOARCH=amd64 -go build -o ../bin/cursor_id_modifier.exe ../main.go -echo Build complete: ../bin/cursor_id_modifier.exe \ No newline at end of file