From 06a594e448142b1aa0a5776bd7328c00a4dd4898 Mon Sep 17 00:00:00 2001 From: Garry Trinder Date: Tue, 20 May 2025 12:14:26 -0700 Subject: [PATCH 1/2] Increment version to 0.23.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index ea723f4..b2f7d29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dev-proxy-toolkit", - "version": "0.23.0", + "version": "0.23.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dev-proxy-toolkit", - "version": "0.23.0", + "version": "0.23.1", "dependencies": { "json-to-ast": "^2.1.0" }, diff --git a/package.json b/package.json index d64b3bb..58ab162 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "dev-proxy-toolkit", "displayName": "Dev Proxy Toolkit", "description": "Makes it easy to create and update Dev Proxy configuration files.", - "version": "0.23.0", + "version": "0.23.1", "publisher": "garrytrinder", "engines": { "vscode": "^1.89.0" From e0a3ed9c8e01e44c15440f1d33f54c2ffaa52fc4 Mon Sep 17 00:00:00 2001 From: Garry Trinder Date: Tue, 20 May 2025 12:15:29 -0700 Subject: [PATCH 2/2] Add command support for Dev Proxy Beta. Closes #212 Closes #212 --- CHANGELOG.md | 6 +++++- src/commands.ts | 38 +++++++++++++++----------------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a39020c..d72dac5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 > **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. -## [0.23.0] - Unreleased +## [0.23.1] - Unreleased + +### Added: + +- Support for using Dev Proxy Beta with commands ### Changed: diff --git a/src/commands.ts b/src/commands.ts index b5fab7e..ccc26af 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1,13 +1,15 @@ import * as vscode from 'vscode'; import { pluginDocs } from './constants'; -import { VersionExeName, VersionPreference } from './enums'; +import { VersionPreference } from './enums'; import { executeCommand, isConfigFile } from './helpers'; -import { isDevProxyRunning } from './detect'; +import { isDevProxyRunning, getDevProxyExe } from './detect'; export const registerCommands = (context: vscode.ExtensionContext, configuration: vscode.WorkspaceConfiguration) => { + const versionPreference = configuration.get('version') as VersionPreference; + const devProxyExe = getDevProxyExe(configuration.get('version') as VersionPreference); + context.subscriptions.push( vscode.commands.registerCommand('dev-proxy-toolkit.install', async (platform: NodeJS.Platform) => { - const versionPreference = configuration.get('version') as VersionPreference; const message = vscode.window.setStatusBarMessage('Installing Dev Proxy...'); // we are on windows so we can use winget @@ -87,6 +89,7 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration const showTerminal = configuration.get('showTerminal') as boolean; const newTerminal = configuration.get('newTerminal') as boolean; + let terminal: vscode.Terminal; if (!newTerminal && vscode.window.activeTerminal) { @@ -98,15 +101,13 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration } vscode.window.activeTextEditor && isConfigFile(vscode.window.activeTextEditor.document) - ? terminal.sendText(`devproxy --config-file "${vscode.window.activeTextEditor.document.uri.fsPath}"`) - : terminal.sendText('devproxy'); + ? terminal.sendText(`${devProxyExe} --config-file "${vscode.window.activeTextEditor.document.uri.fsPath}"`) + : terminal.sendText(devProxyExe); })); context.subscriptions.push( vscode.commands.registerCommand('dev-proxy-toolkit.stop', async () => { const apiPort = configuration.get('apiPort') as number; - const versionPreference = configuration.get('version') as VersionPreference; - const exeName = versionPreference === VersionPreference.Stable ? VersionExeName.Stable : VersionExeName.Beta; await fetch(`http://localhost:${apiPort}/proxy/stopproxy`, { method: 'POST', @@ -119,7 +120,7 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration if (closeTerminal) { const checkProxyStatus = async () => { try { - return await isDevProxyRunning(exeName); + return await isDevProxyRunning(devProxyExe); } catch { return false; } @@ -148,8 +149,6 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration context.subscriptions.push( vscode.commands.registerCommand('dev-proxy-toolkit.restart', async () => { const apiPort = configuration.get('apiPort') as number; - const versionPreference = configuration.get('version') as VersionPreference; - const exeName = versionPreference === VersionPreference.Stable ? VersionExeName.Stable : VersionExeName.Beta; try { await fetch(`http://localhost:${apiPort}/proxy/stopproxy`, { @@ -161,7 +160,7 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration const checkProxyStatus = async () => { try { - return await isDevProxyRunning(exeName); + return await isDevProxyRunning(devProxyExe); } catch { return false; } @@ -192,8 +191,8 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration } vscode.window.activeTextEditor && isConfigFile(vscode.window.activeTextEditor.document) - ? terminal.sendText(`devproxy --config-file "${vscode.window.activeTextEditor.document.uri.fsPath}"`) - : terminal.sendText('devproxy'); + ? terminal.sendText(`${devProxyExe} --config-file "${vscode.window.activeTextEditor.document.uri.fsPath}"`) + : terminal.sendText(devProxyExe); } catch { vscode.window.showErrorMessage('Failed to restart Dev Proxy'); } @@ -247,23 +246,17 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration 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`); + await executeCommand(`${devProxyExe} config open`); })); context.subscriptions.push( vscode.commands.registerCommand('dev-proxy-toolkit.config-new', async () => { - const versionPreference = configuration.get('version') as VersionPreference; - const exeName = versionPreference === VersionPreference.Stable ? VersionExeName.Stable : VersionExeName.Beta; - // ask the user for the filename that they want to use const fileName = await vscode.window.showInputBox({ prompt: 'Enter the name of the new config file', + placeHolder: 'devproxyrc.json', value: 'devproxyrc.json', validateInput: (value: string) => { - console.log(value); const errors: string[] = []; if (!value) { @@ -286,7 +279,6 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration // we do this after the user has entered the filename try { const workspaceFolder = vscode.workspace.workspaceFolders?.[0].uri.fsPath; - console.log(workspaceFolder); const { type } = await vscode.workspace.fs.stat(vscode.Uri.file(`${workspaceFolder}/${fileName}`)); if (type === vscode.FileType.File) { vscode.window.showErrorMessage('A file with that name already exists'); @@ -300,7 +292,7 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration location: vscode.ProgressLocation.Notification, title: 'Creating new config file...' }, async () => { - await executeCommand(`${exeName} config new ${fileName}`, { cwd: vscode.workspace.workspaceFolders?.[0].uri.fsPath }); + await executeCommand(`${devProxyExe} config new ${fileName}`, { cwd: vscode.workspace.workspaceFolders?.[0].uri.fsPath }); }); const configUri = vscode.Uri.file(`${vscode.workspace.workspaceFolders?.[0].uri.fsPath}/${fileName}`);