Skip to content

Commit b2d0215

Browse files
committed
Add config open command. Closes #210
1 parent 301c555 commit b2d0215

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
1010
## [0.19.0] - Unreleased
1111

12+
### Added:
13+
14+
- Command: `dev-proxy-toolkit.config-open` - Open configuration file
15+
1216
### Changed:
1317

14-
- Commands: Refactored stop command logic
18+
- Command: Refactored stop command logic
1519

1620
## [0.18.3] - 2025-03-03
1721

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The following sections describe the features that the extension contributes to V
2828
- `Dev Proxy Toolkit: Raise mock request` - Only available when Dev Proxy is running
2929
- `Dev Proxy Toolkit: Start recording` - Only available when Dev Proxy is running
3030
- `Dev Proxy Toolkit: Stop recording`- Only available when Dev Proxy is recording
31+
- `Dev Proxy Toolkit: Open configuration file`- Only available when Dev Proxy is installed
3132

3233
### Diagnostics
3334

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@
5555
"category": "Dev Proxy Toolkit",
5656
"icon": "$(circle-slash)",
5757
"enablement": "isDevProxyRunning && isDevProxyRecording"
58+
},
59+
{
60+
"command": "dev-proxy-toolkit.config-open",
61+
"title": "Open configuration file",
62+
"category": "Dev Proxy Toolkit",
63+
"icon": "$(file-code)",
64+
"enablement": "isDevProxyInstalled"
5865
}
5966
],
6067
"menus": {
@@ -170,4 +177,4 @@
170177
"dependencies": {
171178
"json-to-ast": "^2.1.0"
172179
}
173-
}
180+
}

src/commands.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as vscode from 'vscode';
22
import { pluginDocs } from './constants';
3-
import { VersionPreference } from './enums';
3+
import { VersionExeName, VersionPreference } from './enums';
44
import { executeCommand, isConfigFile } from './helpers';
55

66
export const registerCommands = (context: vscode.ExtensionContext, configuration: vscode.WorkspaceConfiguration) => {
@@ -187,4 +187,12 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration
187187
vscode.window.showErrorMessage('Failed to stop recording');
188188
}
189189
}));
190-
};
190+
191+
context.subscriptions.push(
192+
vscode.commands.registerCommand('dev-proxy-toolkit.config-open', async () => {
193+
const versionPreference = configuration.get('version') as VersionPreference;
194+
versionPreference === VersionPreference.Stable
195+
? await executeCommand(`${VersionExeName.Stable} config open`)
196+
: await executeCommand(`${VersionExeName.Beta} config open`);
197+
}));
198+
};

src/state.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ import { detectDevProxyInstall } from './detect';
33
import { VersionPreference } from './enums';
44

55
export const updateGlobalState = async (context: vscode.ExtensionContext, versionPreference: VersionPreference) => {
6-
context.globalState.update('devProxyInstall', await detectDevProxyInstall(versionPreference));
6+
const devProxyInstall = await detectDevProxyInstall(versionPreference);
7+
vscode.commands.executeCommand('setContext', 'isDevProxyInstalled', devProxyInstall.isInstalled);
8+
context.globalState.update('devProxyInstall', devProxyInstall);
79
};

0 commit comments

Comments
 (0)