From 6719515666fe54ec1cd0f30ff6e98d9cb6c0df25 Mon Sep 17 00:00:00 2001 From: motm32 Date: Tue, 18 Oct 2022 10:15:02 -0700 Subject: [PATCH 1/3] Upgrade extension to V2 --- package-lock.json | 14 +++++++------- package.json | 29 +++++++++++++++++++---------- src/extension.ts | 26 +++++++++++++------------- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9f3d668d..6f46fe83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@azure/arm-resources": "^5.0.0", "@azure/arm-resources-profile-2020-09-01-hybrid": "^1.0.0", "@microsoft/vscode-azext-azureutils": "^0.3.4", - "@microsoft/vscode-azext-utils": "^0.3.9", + "@microsoft/vscode-azext-utils": "file:../vscode-azuretools/utils/microsoft-vscode-azext-utils-0.3.15.tgz", "fs-extra": "^8.1.0", "open": "^8.0.4", "semver": "^5.7.0", @@ -994,9 +994,10 @@ } }, "node_modules/@microsoft/vscode-azext-utils": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-0.3.9.tgz", - "integrity": "sha512-xVUxksOGsf6UfAgisLsf+SIVumvY/28Tgsm3HMNf4b+UX4/YSSFTWhZ8oeJ4Y/q9W0c1gbOMagjR+KPcE/7V9g==", + "version": "0.3.15", + "resolved": "file:../vscode-azuretools/utils/microsoft-vscode-azext-utils-0.3.15.tgz", + "integrity": "sha512-HYPX2gvbSa+Q1w0kfIIW9h7ggrKI37nhEZQ+yqnA4FUTSw4fVGbXvW5dbRxCXZbcts/pPTo7RLyiVl9OKUXVhw==", + "license": "MIT", "dependencies": { "@vscode/extension-telemetry": "^0.6.2", "dayjs": "^1.11.2", @@ -12935,9 +12936,8 @@ } }, "@microsoft/vscode-azext-utils": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@microsoft/vscode-azext-utils/-/vscode-azext-utils-0.3.9.tgz", - "integrity": "sha512-xVUxksOGsf6UfAgisLsf+SIVumvY/28Tgsm3HMNf4b+UX4/YSSFTWhZ8oeJ4Y/q9W0c1gbOMagjR+KPcE/7V9g==", + "version": "file:..\\vscode-azuretools\\utils\\microsoft-vscode-azext-utils-0.3.15.tgz", + "integrity": "sha512-HYPX2gvbSa+Q1w0kfIIW9h7ggrKI37nhEZQ+yqnA4FUTSw4fVGbXvW5dbRxCXZbcts/pPTo7RLyiVl9OKUXVhw==", "requires": { "@vscode/extension-telemetry": "^0.6.2", "dayjs": "^1.11.2", diff --git a/package.json b/package.json index 3c2ec7ac..39057aa1 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,15 @@ ], "main": "./main.js", "contributes": { + "x-azResourcesV2": { + "application": { + "branches": [ + { + "type": "VirtualMachines" + } + ] + } + }, "x-azResources": { "activation": { "onFetch": [ @@ -122,47 +131,47 @@ "view/item/context": [ { "command": "azureVirtualMachines.createVirtualMachine", - "when": "view == azureResourceGroups && viewItem =~ /azureResourceTypeGroup.*microsoft.compute/virtualmachines/", + "when": "view == azureResourceGroupsV2 && viewItem =~ /virtualmachines/i && viewItem =~ /azureResourceTypeGroup/i", "group": "1@1" }, { "command": "azureVirtualMachines.createVirtualMachineAdvanced", - "when": "view == azureResourceGroups && viewItem =~ /azureResourceTypeGroup.*microsoft.compute/virtualmachines/", + "when": "view == azureResourceGroupsV2 && viewItem =~ /virtualmachines/i && viewItem =~ /azureResourceTypeGroup/i", "group": "1@2" }, { "command": "azureVirtualMachines.copyIpAddress", - "when": "view == azureResourceGroups && viewItem =~ /VirtualMachine$/", + "when": "view == azureResourceGroupsV2 && viewItem =~ /VirtualMachine$/", "group": "1@2" }, { "command": "azureVirtualMachines.startVirtualMachine", - "when": "view == azureResourceGroups && viewItem =~ /VirtualMachine$/", + "when": "view == azureResourceGroupsV2 && viewItem =~ /VirtualMachine$/", "group": "2@1" }, { "command": "azureVirtualMachines.restartVirtualMachine", - "when": "view == azureResourceGroups && viewItem =~ /VirtualMachine$/", + "when": "view == azureResourceGroupsV2 && viewItem =~ /VirtualMachine$/", "group": "2@2" }, { "command": "azureVirtualMachines.stopVirtualMachine", - "when": "view == azureResourceGroups && viewItem =~ /VirtualMachine$/", + "when": "view == azureResourceGroupsV2 && viewItem =~ /VirtualMachine$/", "group": "2@3" }, { "command": "azureVirtualMachines.deleteVirtualMachine", - "when": "view == azureResourceGroups && viewItem =~ /VirtualMachine$/", + "when": "view == azureResourceGroupsV2 && viewItem =~ /VirtualMachine$/", "group": "2@4" }, { "command": "azureVirtualMachines.openInRemoteSsh", - "when": "view == azureResourceGroups && viewItem =~ /linuxVirtualMachine/", + "when": "view == azureResourceGroupsV2 && viewItem =~ /linuxVirtualMachine/", "group": "1@1" }, { "command": "azureVirtualMachines.addSshKey", - "when": "view == azureResourceGroups && viewItem =~ /linuxVirtualMachine/", + "when": "view == azureResourceGroupsV2 && viewItem =~ /linuxVirtualMachine/", "group": "1@3" } ], @@ -234,7 +243,7 @@ "@azure/arm-resources": "^5.0.0", "@azure/arm-resources-profile-2020-09-01-hybrid": "^1.0.0", "@microsoft/vscode-azext-azureutils": "^0.3.4", - "@microsoft/vscode-azext-utils": "^0.3.9", + "@microsoft/vscode-azext-utils": "file:../vscode-azuretools/utils/microsoft-vscode-azext-utils-0.3.15.tgz", "fs-extra": "^8.1.0", "open": "^8.0.4", "semver": "^5.7.0", diff --git a/src/extension.ts b/src/extension.ts index ef819b97..60d7b127 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -6,7 +6,7 @@ 'use strict'; import { registerAzureUtilsExtensionVariables } from '@microsoft/vscode-azext-azureutils'; -import { callWithTelemetryAndErrorHandling, createApiProvider, createAzExtOutputChannel, IActionContext, registerCommand, registerErrorHandler, registerReportIssueCommand, registerUIExtensionVariables } from '@microsoft/vscode-azext-utils'; +import { AzExtResourceType, callWithTelemetryAndErrorHandling, createApiProvider, createAzExtOutputChannel, IActionContext, registerCommandWithTreeNodeUnwrapping, registerErrorHandler, registerReportIssueCommand, registerUIExtensionVariables } from '@microsoft/vscode-azext-utils'; import { AzureExtensionApi, AzureExtensionApiProvider } from '@microsoft/vscode-azext-utils/api'; import { AzureHostExtensionApi } from '@microsoft/vscode-azext-utils/hostapi'; import * as vscode from 'vscode'; @@ -37,17 +37,17 @@ export async function activateInternal(context: vscode.ExtensionContext, perfSta activateContext.telemetry.properties.isActivationEvent = 'true'; activateContext.telemetry.measurements.mainFileLoad = (perfStats.loadEndTime - perfStats.loadStartTime) / 1000; - registerCommand('azureVirtualMachines.createVirtualMachine', createVirtualMachine); - registerCommand('azureVirtualMachines.createVirtualMachineAdvanced', createVirtualMachineAdvanced); - registerCommand('azureVirtualMachines.startVirtualMachine', startVirtualMachine); - registerCommand('azureVirtualMachines.restartVirtualMachine', restartVirtualMachine); - registerCommand('azureVirtualMachines.stopVirtualMachine', stopVirtualMachine); - registerCommand('azureVirtualMachines.addSshKey', addSshKey); - registerCommand('azureVirtualMachines.deleteVirtualMachine', deleteVirtualMachine); - registerCommand('azureVirtualMachines.copyIpAddress', copyIpAddress); - registerCommand('azureVirtualMachines.openInRemoteSsh', openInRemoteSsh); - registerCommand('azureVirtualMachines.showOutputChannel', () => { ext.outputChannel.show(); }); - registerCommand('azureVirtualMachines.showRemoteSshExtension', () => { void vscode.commands.executeCommand('extension.open', remoteSshExtensionId); }); + registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.createVirtualMachine', createVirtualMachine); + registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.createVirtualMachineAdvanced', createVirtualMachineAdvanced); + registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.startVirtualMachine', startVirtualMachine); + registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.restartVirtualMachine', restartVirtualMachine); + registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.stopVirtualMachine', stopVirtualMachine); + registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.addSshKey', addSshKey); + registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.deleteVirtualMachine', deleteVirtualMachine); + registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.copyIpAddress', copyIpAddress); + registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.openInRemoteSsh', openInRemoteSsh); + registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.showOutputChannel', () => { ext.outputChannel.show(); }); + registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.showRemoteSshExtension', () => { void vscode.commands.executeCommand('extension.open', remoteSshExtensionId); }); // Suppress "Report an Issue" button for all errors in favor of the command registerErrorHandler(c => c.errorHandling.suppressReportIssue = true); @@ -57,7 +57,7 @@ export async function activateInternal(context: vscode.ExtensionContext, perfSta if (rgApiProvider) { const api = rgApiProvider.getApi('0.0.1'); ext.rgApi = api; - api.registerApplicationResourceResolver('Microsoft.Compute/virtualMachines', new VirtualMachineResolver()); + api.registerApplicationResourceResolver(AzExtResourceType.VirtualMachines, new VirtualMachineResolver()); } else { throw new Error('Could not find the Azure Resource Groups extension'); } From 747e98f88495f723fbd870d40095121d97a8ec5c Mon Sep 17 00:00:00 2001 From: Alex Weininger Date: Tue, 18 Oct 2022 13:49:46 -0700 Subject: [PATCH 2/3] Update launch config --- .vscode/launch.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 7c80c911..907e2253 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -20,16 +20,13 @@ } }, { - "name": "Launch Extension(s)", + "name": "Launch Extension + Host", "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", "args": [ "--extensionDevelopmentPath=${workspaceFolder}", - "--extensionDevelopmentPath=${workspaceFolder}/../vscode-azureresourcegroups", - "--extensionDevelopmentPath=${workspaceFolder}/../vscode-azureappservice", - "--extensionDevelopmentPath=${workspaceFolder}/../vscode-azurefunctions", - "--extensionDevelopmentPath=${workspaceFolder}/../vscode-azurestaticwebapps" + "--extensionDevelopmentPath=${workspaceFolder}/../vscode-azureresourcegroups" ], "outFiles": [ "${workspaceFolder}/out/**/*.js" From a57e1a1d01f37af90dbd0ddf9fa70269f47b1640 Mon Sep 17 00:00:00 2001 From: motm32 Date: Tue, 18 Oct 2022 14:26:34 -0700 Subject: [PATCH 3/3] Add back registerCommand to commands that aren't invoked from the tree. --- src/extension.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 60d7b127..7c35a426 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -6,7 +6,7 @@ 'use strict'; import { registerAzureUtilsExtensionVariables } from '@microsoft/vscode-azext-azureutils'; -import { AzExtResourceType, callWithTelemetryAndErrorHandling, createApiProvider, createAzExtOutputChannel, IActionContext, registerCommandWithTreeNodeUnwrapping, registerErrorHandler, registerReportIssueCommand, registerUIExtensionVariables } from '@microsoft/vscode-azext-utils'; +import { AzExtResourceType, callWithTelemetryAndErrorHandling, createApiProvider, createAzExtOutputChannel, IActionContext, registerCommand, registerCommandWithTreeNodeUnwrapping, registerErrorHandler, registerReportIssueCommand, registerUIExtensionVariables } from '@microsoft/vscode-azext-utils'; import { AzureExtensionApi, AzureExtensionApiProvider } from '@microsoft/vscode-azext-utils/api'; import { AzureHostExtensionApi } from '@microsoft/vscode-azext-utils/hostapi'; import * as vscode from 'vscode'; @@ -46,8 +46,8 @@ export async function activateInternal(context: vscode.ExtensionContext, perfSta registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.deleteVirtualMachine', deleteVirtualMachine); registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.copyIpAddress', copyIpAddress); registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.openInRemoteSsh', openInRemoteSsh); - registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.showOutputChannel', () => { ext.outputChannel.show(); }); - registerCommandWithTreeNodeUnwrapping('azureVirtualMachines.showRemoteSshExtension', () => { void vscode.commands.executeCommand('extension.open', remoteSshExtensionId); }); + registerCommand('azureVirtualMachines.showOutputChannel', () => { ext.outputChannel.show(); }); + registerCommand('azureVirtualMachines.showRemoteSshExtension', () => { void vscode.commands.executeCommand('extension.open', remoteSshExtensionId); }); // Suppress "Report an Issue" button for all errors in favor of the command registerErrorHandler(c => c.errorHandling.suppressReportIssue = true);