Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Snippets: Updated all snippets to use new DLL name, `DevProxy.Plugins.dll`
- Notification: Upgrade notification invokes package manager to upgrade Dev Proxy
- Improved diagnostics range detection to ensure that they only appear againt the relevant code and don't overlap with ending quotes and commas
- Detection: Changed isDevProxyRunning check to use Dev Proxy API instead of process detection

## [0.24.0] - 2025-06-04

Expand Down
32 changes: 17 additions & 15 deletions src/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,27 @@ export const getOutdatedVersion = async (devProxyExe: string): Promise<string> =
};

export const isDevProxyRunning = async (devProxyExe: string): Promise<boolean> => {
const platform = os.platform();

if (platform === 'win32') {
const processId = await executeCommand(`pwsh.exe -c "(Get-Process ${devProxyExe} -ErrorAction SilentlyContinue).Id"`);
return processId.trim() !== '';
};
if (platform === 'darwin') {
const processId = await executeCommand(`$SHELL -c "ps -e -o pid=,comm= | awk \'\\$2==\"${devProxyExe}\" {print \\$1}\'"`);
return processId.trim() !== '';
};
if (platform === 'linux') {
const processId = await executeCommand(`/bin/bash -c "ps -e -o pid=,comm= | awk \'\\$2==\"${devProxyExe}\" {print \\$1}\'"`);
return processId.trim() !== '';
try {
// Get the API port from configuration
const configuration = vscode.workspace.getConfiguration('dev-proxy-toolkit');
const apiPort = configuration.get('apiPort') as number;

// Try to connect to the Dev Proxy API on the configured port
const response = await fetch(`http://127.0.0.1:${apiPort}/proxy`, {
method: 'GET',
signal: AbortSignal.timeout(2000), // 2 second timeout
});

// If we get any response (even an error), Dev Proxy is running
return response.status >= 200 && response.status < 500;
} catch (error) {
// If the request fails (connection refused, timeout, etc.), Dev Proxy is not running
return false;
}
return false;
};

export const getDevProxyExe = (versionPreference: VersionPreference) => {
return versionPreference === VersionPreference.Stable
? VersionExeName.Stable
: VersionExeName.Beta;
};
};
16 changes: 13 additions & 3 deletions src/test/examples/devproxyrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v0.24.0/rc.schema.json",
"plugins": []
}
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.29.0/rc.schema.json",
"plugins": [
{
"name": "LatencyPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll"
}
],
"urlsToWatch": ["https://jsonplaceholder.typicode.com/*"],
"logLevel": "information",
"newVersionNotification": "stable",
"showSkipMessages": true
}