Skip to content

Commit 316c954

Browse files
committed
Add Discover URLs to watch command. Closes #225
Closes #225
1 parent 7c4561b commit 316c954

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
> **Note**: odd version numbers, for example, `0.13.0`, are not included in this changelog. They are used to test the new features and fixes before the final release.
99
10-
## [0.23.3] - Unreleased
10+
## [0.23.4] - Unreleased
1111

1212
### Added:
1313

1414
- Support for using Dev Proxy Beta with commands
15+
- Command: `dev-proxy-toolkit.discover-urls-to-watch` - Start Dev Proxy in discovery mode
1516

1617
### Changed:
1718

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ The following sections describe the features that the extension contributes to V
3131
- `Dev Proxy Toolkit: Stop recording`- Only available when Dev Proxy is recording
3232
- `Dev Proxy Toolkit: Open configuration file`- Only available when Dev Proxy is installed
3333
- `Dev Proxy Toolkit: Create configuration file`- Only available when Dev Proxy is installed
34+
- `Dev Proxy Toolkit: Discover URLs to watch` - Only available when Dev Proxy is not running
3435

3536
### Diagnostics
3637

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@
7676
"category": "Dev Proxy Toolkit",
7777
"icon": "$(file-code)",
7878
"enablement": "isDevProxyInstalled"
79+
},
80+
{
81+
"command": "dev-proxy-toolkit.discover-urls-to-watch",
82+
"title": "Discover URLs to watch",
83+
"category": "Dev Proxy Toolkit",
84+
"icon": "$(debug-start)",
85+
"enablement": "!isDevProxyRunning"
7986
}
8087
],
8188
"menus": {

src/commands.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,36 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration
302302
vscode.window.showErrorMessage('Failed to create new config file');
303303
}
304304
}));
305+
306+
context.subscriptions.push(
307+
vscode.commands.registerCommand('dev-proxy-toolkit.discover-urls-to-watch', async () => {
308+
const newTerminal = configuration.get('newTerminal') as boolean;
309+
310+
let terminal: vscode.Terminal;
311+
312+
if (!newTerminal && vscode.window.activeTerminal) {
313+
terminal = vscode.window.activeTerminal;
314+
} else {
315+
terminal = vscode.window.createTerminal('Dev Proxy');
316+
317+
}
318+
319+
const processNames = await vscode.window.showInputBox({
320+
prompt: 'Enter the process names (space separated). Leave empty to intercept requests from all processes.',
321+
placeHolder: 'msedge pwsh',
322+
value: '',
323+
title: 'Intercept requests from specific processes',
324+
validateInput: (value: string) => {
325+
// can be empty string, but if not, must contain space separated process names
326+
if (value && !/^[a-zA-Z0-9\s]+$/.test(value)) {
327+
return 'Process names can only contain alphanumeric characters and spaces';
328+
}
329+
return undefined; // no error
330+
}
331+
});
332+
333+
processNames !== undefined && processNames.trim() !== ''
334+
? terminal.sendText(`${devProxyExe} --discover --watch-process-names ${processNames.trim()}`)
335+
: terminal.sendText(`${devProxyExe} --discover`);
336+
}));
305337
};

0 commit comments

Comments
 (0)