* Detect the installed Claude Desktop version. * On macOS, reads CFBundleShortVersionString from the app plist. * On Windows, finds the highest app-X.Y.Z directory in the Squirrel install. * Returns null if version cannot be determined.
()
| 89 | * Returns null if version cannot be determined. |
| 90 | */ |
| 91 | async function getDesktopVersion(): Promise<string | null> { |
| 92 | const platform = process.platform |
| 93 | |
| 94 | if (platform === 'darwin') { |
| 95 | const { code, stdout } = await execFileNoThrow('defaults', [ |
| 96 | 'read', |
| 97 | '/Applications/Claude.app/Contents/Info.plist', |
| 98 | 'CFBundleShortVersionString', |
| 99 | ]) |
| 100 | if (code !== 0) { |
| 101 | return null |
| 102 | } |
| 103 | const version = stdout.trim() |
| 104 | return version.length > 0 ? version : null |
| 105 | } else if (platform === 'win32') { |
| 106 | const localAppData = process.env.LOCALAPPDATA |
| 107 | if (!localAppData) { |
| 108 | return null |
| 109 | } |
| 110 | const installDir = join(localAppData, 'AnthropicClaude') |
| 111 | try { |
| 112 | const entries = await readdir(installDir) |
| 113 | const versions = entries |
| 114 | .filter(e => e.startsWith('app-')) |
| 115 | .map(e => e.slice(4)) |
| 116 | .filter(v => semverCoerce(v) !== null) |
| 117 | .sort((a, b) => { |
| 118 | const ca = semverCoerce(a)! |
| 119 | const cb = semverCoerce(b)! |
| 120 | return ca.compare(cb) |
| 121 | }) |
| 122 | return versions.length > 0 ? versions[versions.length - 1]! : null |
| 123 | } catch { |
| 124 | return null |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | return null |
| 129 | } |
| 130 | |
| 131 | export type DesktopInstallStatus = |
| 132 | | { status: 'not-installed' } |
no test coverage detected