diff --git a/CHANGELOG.md b/CHANGELOG.md index e606379..bb5ffd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.19.0] - Unreleased +### Added: + +- Command: `dev-proxy-toolkit.config-open` - Open configuration file + ### Changed: -- Commands: Refactored stop command logic +- Command: Refactored stop command logic ## [0.18.3] - 2025-03-03 diff --git a/README.md b/README.md index 3b7d174..dedfd94 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ The following sections describe the features that the extension contributes to V - `Dev Proxy Toolkit: Raise mock request` - Only available when Dev Proxy is running - `Dev Proxy Toolkit: Start recording` - Only available when Dev Proxy is running - `Dev Proxy Toolkit: Stop recording`- Only available when Dev Proxy is recording +- `Dev Proxy Toolkit: Open configuration file`- Only available when Dev Proxy is installed ### Diagnostics diff --git a/package.json b/package.json index 7cf12bb..497ed64 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,13 @@ "category": "Dev Proxy Toolkit", "icon": "$(circle-slash)", "enablement": "isDevProxyRunning && isDevProxyRecording" + }, + { + "command": "dev-proxy-toolkit.config-open", + "title": "Open configuration file", + "category": "Dev Proxy Toolkit", + "icon": "$(file-code)", + "enablement": "isDevProxyInstalled" } ], "menus": { @@ -170,4 +177,4 @@ "dependencies": { "json-to-ast": "^2.1.0" } -} +} \ No newline at end of file diff --git a/src/commands.ts b/src/commands.ts index b960754..b5e679e 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; import { pluginDocs } from './constants'; -import { VersionPreference } from './enums'; +import { VersionExeName, VersionPreference } from './enums'; import { executeCommand, isConfigFile } from './helpers'; export const registerCommands = (context: vscode.ExtensionContext, configuration: vscode.WorkspaceConfiguration) => { @@ -187,4 +187,12 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration vscode.window.showErrorMessage('Failed to stop recording'); } })); -}; \ No newline at end of file + + context.subscriptions.push( + vscode.commands.registerCommand('dev-proxy-toolkit.config-open', async () => { + const versionPreference = configuration.get('version') as VersionPreference; + versionPreference === VersionPreference.Stable + ? await executeCommand(`${VersionExeName.Stable} config open`) + : await executeCommand(`${VersionExeName.Beta} config open`); + })); +}; diff --git a/src/state.ts b/src/state.ts index e62b7e2..55f346f 100644 --- a/src/state.ts +++ b/src/state.ts @@ -3,5 +3,7 @@ import { detectDevProxyInstall } from './detect'; import { VersionPreference } from './enums'; export const updateGlobalState = async (context: vscode.ExtensionContext, versionPreference: VersionPreference) => { - context.globalState.update('devProxyInstall', await detectDevProxyInstall(versionPreference)); + const devProxyInstall = await detectDevProxyInstall(versionPreference); + vscode.commands.executeCommand('setContext', 'isDevProxyInstalled', devProxyInstall.isInstalled); + context.globalState.update('devProxyInstall', devProxyInstall); }; \ No newline at end of file