|
1 | 1 | import * as vscode from 'vscode';
|
2 | 2 | import { pluginDocs } from './constants';
|
3 | 3 | import { VersionPreference } from './enums';
|
4 |
| -import { executeCommand, isConfigFile } from './helpers'; |
| 4 | +import { executeCommand, isConfigFile, openUpgradeDocumentation, upgradeDevProxyWithPackageManager } from './helpers'; |
5 | 5 | import { isDevProxyRunning, getDevProxyExe } from './detect';
|
6 | 6 |
|
7 | 7 | export const registerCommands = (context: vscode.ExtensionContext, configuration: vscode.WorkspaceConfiguration) => {
|
@@ -80,8 +80,41 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration
|
80 | 80 |
|
81 | 81 | context.subscriptions.push(
|
82 | 82 | vscode.commands.registerCommand('dev-proxy-toolkit.upgrade', async () => {
|
83 |
| - const url = 'https://aka.ms/devproxy/upgrade'; |
84 |
| - vscode.env.openExternal(vscode.Uri.parse(url)); |
| 83 | + const platform = process.platform; |
| 84 | + const versionPreference = configuration.get('version') as VersionPreference; |
| 85 | + |
| 86 | + // Handle Linux early - always redirect to documentation |
| 87 | + if (platform === 'linux') { |
| 88 | + openUpgradeDocumentation(); |
| 89 | + return; |
| 90 | + } |
| 91 | + |
| 92 | + // Handle Windows |
| 93 | + if (platform === 'win32') { |
| 94 | + const packageId = versionPreference === VersionPreference.Stable ? 'Microsoft.DevProxy' : 'Microsoft.DevProxy.Beta'; |
| 95 | + const upgradeCommand = `winget upgrade ${packageId} --silent`; |
| 96 | + |
| 97 | + const upgraded = await upgradeDevProxyWithPackageManager('winget', packageId, upgradeCommand); |
| 98 | + if (!upgraded) { |
| 99 | + openUpgradeDocumentation(); |
| 100 | + } |
| 101 | + return; |
| 102 | + } |
| 103 | + |
| 104 | + // Handle macOS |
| 105 | + if (platform === 'darwin') { |
| 106 | + const packageId = versionPreference === VersionPreference.Stable ? 'dev-proxy' : 'dev-proxy-beta'; |
| 107 | + const upgradeCommand = `brew upgrade ${packageId}`; |
| 108 | + |
| 109 | + const upgraded = await upgradeDevProxyWithPackageManager('brew', packageId, upgradeCommand); |
| 110 | + if (!upgraded) { |
| 111 | + openUpgradeDocumentation(); |
| 112 | + } |
| 113 | + return; |
| 114 | + } |
| 115 | + |
| 116 | + // Unknown platform - redirect to documentation |
| 117 | + openUpgradeDocumentation(); |
85 | 118 | }));
|
86 | 119 |
|
87 | 120 | context.subscriptions.push(
|
|
0 commit comments