mirror of
https://github.com/oslook/cursor-ai-downloads.git
synced 2025-09-27 03:35:57 +08:00
feat(windows): add system-wide installation support (#8)
- Simplify URL transformation for Windows system-wide installer - Replace 'user-setup/CursorUserSetup' with 'system-setup/CursorSetup' - Fix #8: Include system-wide installation links for Windows users Reference: https://github.com/oslook/cursor-ai-downloads/issues/8
This commit is contained in:
@@ -55,8 +55,8 @@ interface VersionHistory {
|
|||||||
|
|
||||||
const PLATFORMS: PlatformMap = {
|
const PLATFORMS: PlatformMap = {
|
||||||
windows: {
|
windows: {
|
||||||
platforms: ['win32-x64', 'win32-arm64'],
|
platforms: ['win32-x64-user', 'win32-arm64-user', 'win32-x64-system', 'win32-arm64-system'],
|
||||||
readableNames: ['win32-x64', 'win32-arm64'],
|
readableNames: ['win32-x64-user', 'win32-arm64-user', 'win32-x64-system', 'win32-arm64-system'],
|
||||||
section: 'Windows Installer'
|
section: 'Windows Installer'
|
||||||
},
|
},
|
||||||
mac: {
|
mac: {
|
||||||
@@ -76,8 +76,8 @@ const PLATFORMS: PlatformMap = {
|
|||||||
*/
|
*/
|
||||||
function extractVersion(url: string): string {
|
function extractVersion(url: string): string {
|
||||||
// For Windows
|
// For Windows
|
||||||
const winMatch = url.match(/CursorUserSetup-[^-]+-([0-9.]+)\.exe/);
|
const winMatch = url.match(/Cursor(User|)Setup-[^-]+-([0-9.]+)\.exe/);
|
||||||
if (winMatch && winMatch[1]) return winMatch[1];
|
if (winMatch && winMatch[2]) return winMatch[2];
|
||||||
|
|
||||||
// For other URLs, try to find version pattern
|
// For other URLs, try to find version pattern
|
||||||
const versionMatch = url.match(/[0-9]+\.[0-9]+\.[0-9]+/);
|
const versionMatch = url.match(/[0-9]+\.[0-9]+\.[0-9]+/);
|
||||||
@@ -99,8 +99,17 @@ function formatDate(date: Date): string {
|
|||||||
*/
|
*/
|
||||||
async function fetchLatestDownloadUrl(platform: string): Promise<string | null> {
|
async function fetchLatestDownloadUrl(platform: string): Promise<string | null> {
|
||||||
try {
|
try {
|
||||||
|
let apiPlatform = platform;
|
||||||
|
let isSystemVersion = false;
|
||||||
|
|
||||||
|
// Handle system version URLs
|
||||||
|
if (platform.endsWith('-system')) {
|
||||||
|
apiPlatform = platform.replace('-system', '');
|
||||||
|
isSystemVersion = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Simple fetch without complex retry logic
|
// Simple fetch without complex retry logic
|
||||||
const response = await fetch(`https://www.cursor.com/api/download?platform=${platform}&releaseTrack=latest`, {
|
const response = await fetch(`https://www.cursor.com/api/download?platform=${apiPlatform}&releaseTrack=latest`, {
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Cursor-Version-Checker',
|
'User-Agent': 'Cursor-Version-Checker',
|
||||||
'Cache-Control': 'no-cache',
|
'Cache-Control': 'no-cache',
|
||||||
@@ -114,7 +123,13 @@ async function fetchLatestDownloadUrl(platform: string): Promise<string | null>
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json() as DownloadResponse;
|
const data = await response.json() as DownloadResponse;
|
||||||
return data.downloadUrl;
|
let downloadUrl = data.downloadUrl;
|
||||||
|
|
||||||
|
if (isSystemVersion) {
|
||||||
|
downloadUrl = downloadUrl.replace('user-setup/CursorUserSetup', 'system-setup/CursorSetup');
|
||||||
|
}
|
||||||
|
|
||||||
|
return downloadUrl;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error fetching download URL for platform ${platform}:`, error instanceof Error ? error.message : 'Unknown error');
|
console.error(`Error fetching download URL for platform ${platform}:`, error instanceof Error ? error.message : 'Unknown error');
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user