Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate extension to v1.5 #2353

Merged
merged 14 commits into from
Jan 18, 2023
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"microsoft.web/sites"
]
},
"azure": {
"branches": [
{
"type": "AppServices"
}
]
},
"commands": [
{
"command": "appService.CreateWebApp",
Expand Down Expand Up @@ -345,12 +352,12 @@
"view/item/context": [
{
"command": "appService.CreateWebApp",
"when": "view == azureResourceGroups && viewItem =~ /azureResourceTypeGroup.*microsoft.web/sites(?!/)/",
"when": "view == azureResourceGroups && viewItem =~ /appservices/i && viewItem =~ /azureResourceTypeGroup/i",
"group": "1_subscriptionGeneralCommands@1"
},
{
"command": "appService.CreateWebAppAdvanced",
"when": "view == azureResourceGroups && viewItem =~ /azureResourceTypeGroup.*microsoft.web/sites(?!/)/",
"when": "view == azureResourceGroups && viewItem =~ /appservices/i && viewItem =~ /azureResourceTypeGroup/i",
"group": "1_subscriptionGeneralCommands@2"
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/commands/createSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export async function createSlot(context: IActionContext, node?: DeploymentSlots
if (siteConfig.scmType !== ScmType.None) {
switch (siteConfig.scmType) {
case ScmType.LocalGit:
await editScmType(context, createdSlot, ScmType.LocalGit, false);
await editScmType(context, createdSlot, undefined, ScmType.LocalGit, false);
break;
case ScmType.GitHub:
await editScmType(context, createdSlot, ScmType.GitHub, false);
await editScmType(context, createdSlot, undefined, ScmType.GitHub, false);
break;
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/createWebApp/createWebApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getCreatedWebAppMessage, showCreatedWebAppMessage } from "./showCreated
import { WebAppStackStep } from "./stacks/WebAppStackStep";
import { WebAppCreateStep } from "./WebAppCreateStep";

export async function createWebApp(context: IActionContext & Partial<ICreateChildImplContext>, node?: SubscriptionTreeItemBase | undefined, suppressCreatedWebAppMessage: boolean = false): Promise<SiteTreeItem> {
export async function createWebApp(context: IActionContext & Partial<ICreateChildImplContext>, node?: SubscriptionTreeItemBase | undefined, _nodes?: (SubscriptionTreeItemBase | undefined)[], suppressCreatedWebAppMessage: boolean = false): Promise<SiteTreeItem> {
if (!node) {
node = <SubscriptionTreeItemBase>await ext.rgApi.tree.showTreeItemPicker(SubscriptionTreeItemBase.contextValue, context);
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/deployments/connectToGitHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ export async function connectToGitHub(context: IActionContext, target?: GenericT
node = <DeploymentsTreeItem>target.parent;
}

await editScmType(context, node, ScmType.GitHub);
await editScmType(context, node, undefined, ScmType.GitHub);
}
2 changes: 1 addition & 1 deletion src/commands/deployments/editScmType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ext } from "../../extensionVariables";
import { ResolvedWebAppResource } from "../../tree/ResolvedWebAppResource";
import { SiteTreeItem } from "../../tree/SiteTreeItem";

export async function editScmType(context: IActionContext, node?: SiteTreeItem | DeploymentsTreeItem, newScmType?: ScmType, showToast?: boolean): Promise<void> {
export async function editScmType(context: IActionContext, node?: SiteTreeItem | DeploymentsTreeItem, _nodes?: (SiteTreeItem | DeploymentsTreeItem)[], newScmType?: ScmType, showToast?: boolean): Promise<void> {
if (!node) {
node = await ext.rgApi.pickAppResource<SiteTreeItem>(context, {
filter: webAppFilter,
Expand Down
5 changes: 3 additions & 2 deletions src/commands/installCosmosDBExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzExtTreeItem, IActionContext } from '@microsoft/vscode-azext-utils';
import { AzExtTreeItem, IActionContext, nonNullValue } from '@microsoft/vscode-azext-utils';
import { CosmosDBTreeItem } from '../tree/CosmosDBTreeItem';
import { installExtension } from '../utils/installExtension';

export async function installCosmosDBExtension(context: IActionContext, treeItem: AzExtTreeItem): Promise<void> {
export async function installCosmosDBExtension(context: IActionContext, node?: AzExtTreeItem): Promise<void> {
const treeItem = nonNullValue(node);
const extensionId: string = 'ms-azuretools.vscode-cosmosdb';
if (await installExtension(extensionId)) {
if (treeItem.parent) {
Expand Down
5 changes: 3 additions & 2 deletions src/commands/openInPortal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

import { DeploymentsTreeItem, DeploymentTreeItem } from "@microsoft/vscode-azext-azureappservice";
import { openInPortal as uiOpenInPortal } from '@microsoft/vscode-azext-azureutils';
import { AzExtTreeItem, IActionContext } from "@microsoft/vscode-azext-utils";
import { AzExtTreeItem, IActionContext, nonNullValue } from "@microsoft/vscode-azext-utils";
import { DeploymentSlotsTreeItem } from "../tree/DeploymentSlotsTreeItem";
import { matchContextValue } from "../utils/contextUtils";
import { nonNullProp } from "../utils/nonNull";

export async function openInPortal(context: IActionContext, node: AzExtTreeItem): Promise<void> {
export async function openInPortal(context: IActionContext, treeItem?: AzExtTreeItem): Promise<void> {
const node = nonNullValue(treeItem);
if (matchContextValue(node.contextValue, [DeploymentSlotsTreeItem.contextValue])) {
// the deep link for slots does not follow the conventional pattern of including its parent in the path name so this is how we extract the slot's id
await uiOpenInPortal(node, `${nonNullProp(node, 'parent').id}/deploymentSlotsV2`);
Expand Down
88 changes: 44 additions & 44 deletions src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { AppSettingTreeItem, registerSiteCommand } from '@microsoft/vscode-azext-azureappservice';
import { openInPortal as uiOpenInPortal } from '@microsoft/vscode-azext-azureutils';
import { AzExtTreeItem, IActionContext, registerCommand } from '@microsoft/vscode-azext-utils';
import { AzExtTreeItem, IActionContext, nonNullValue, registerCommandWithTreeNodeUnwrapping, unwrapArgs } from '@microsoft/vscode-azext-utils';
import { ext } from '../extensionVariables';
import { DeploymentSlotsNATreeItem, ScaleUpTreeItem } from '../tree/DeploymentSlotsTreeItem';
import { addAppSetting } from './appSettings/addAppSetting';
Expand Down Expand Up @@ -47,47 +47,47 @@ import { swapSlots } from './swapSlots';
import { viewProperties } from './viewProperties';

export function registerCommands(): void {
registerCommand('appService.AddAzureDatabasesConnection', addCosmosDBConnection);
registerCommand('appService.appSettings.Add', addAppSetting);
registerCommand('appService.appSettings.Delete', deleteAppSetting);
registerCommand('appService.appSettings.Download', downloadAppSettings);
registerCommand('appService.appSettings.Edit', editAppSetting);
registerCommand('appService.appSettings.Rename', renameAppSetting);
registerCommand('appService.appSettings.ToggleSlotSetting', toggleSlotSetting);
registerCommand('appService.appSettings.Upload', uploadAppSettings);
registerCommand('appService.Browse', browseWebsite);
registerCommand('appService.ConfigureDeploymentSource', editScmType);
registerCommand('appService.connectToGitHub', connectToGitHub);
registerCommand('appService.CreateSlot', createSlot);
registerCommand('appService.CreateWebApp', createWebApp);
registerCommand('appService.CreateWebAppAdvanced', createWebAppAdvanced);
registerCommand('appService.Delete', deleteWebApp);
registerCommand('appService.DeploymentScript', generateDeploymentScript);
registerCommand('appService.DisconnectRepo', disconnectRepo);
registerCommand('appService.EnableFileLogging', enableFileLogging);
registerCommand('appService.InstallCosmosDBExtension', installCosmosDBExtension);
registerCommand('appService.LoadMore', async (actionContext: IActionContext, node: AzExtTreeItem) => await ext.rgApi.tree.loadMore(node, actionContext));
registerCommand('appService.openFile', showFile, 500);
registerCommand('appService.OpenInPortal', openInPortal);
registerCommand('appService.Refresh', async (actionContext: IActionContext, node?: AzExtTreeItem) => await ext.rgApi.tree.refresh(actionContext, node));
registerCommand('appService.RemoveCosmosDBConnection', removeCosmosDBConnection);
registerCommand('appService.Restart', restartWebApp);
registerCommand('appService.RevealConnection', revealConnection);
registerCommand('appService.RevealConnectionInAppSettings', revealConnectionInAppSettings);
registerCommand('appService.ScaleUp', async (_context: IActionContext, node: DeploymentSlotsNATreeItem | ScaleUpTreeItem) => await uiOpenInPortal(node, node.scaleUpId));
registerCommand('appService.showOutputChannel', () => { ext.outputChannel.show(); });
registerCommand('appService.Start', startWebApp);
registerCommand('appService.StartRemoteDebug', startRemoteDebug);
registerCommand('appService.StartSsh', startSsh);
registerCommand('appService.startStreamingLogs', startStreamingLogs);
registerCommand('appService.Stop', stopWebApp);
registerCommand('appService.StopLogStream', stopStreamingLogs);
registerCommand('appService.SwapSlots', swapSlots);
registerCommand('appService.toggleAppSettingVisibility', async (actionContext: IActionContext, node: AppSettingTreeItem) => { await node.toggleValueVisibility(actionContext); }, 250);
registerCommand('appService.ViewCommitInGitHub', viewCommitInGitHub);
registerCommand('appService.ViewProperties', viewProperties);
registerSiteCommand('appService.Deploy', deploy);
registerSiteCommand('appService.DeploySlot', deploySlot);
registerSiteCommand('appService.Redeploy', redeployDeployment);
registerSiteCommand('appService.viewDeploymentLogs', viewDeploymentLogs);
registerCommandWithTreeNodeUnwrapping('appService.AddAzureDatabasesConnection', addCosmosDBConnection);
registerCommandWithTreeNodeUnwrapping('appService.appSettings.Add', addAppSetting);
registerCommandWithTreeNodeUnwrapping('appService.appSettings.Delete', deleteAppSetting);
registerCommandWithTreeNodeUnwrapping('appService.appSettings.Download', downloadAppSettings);
registerCommandWithTreeNodeUnwrapping('appService.appSettings.Edit', editAppSetting);
registerCommandWithTreeNodeUnwrapping('appService.appSettings.Rename', renameAppSetting);
registerCommandWithTreeNodeUnwrapping('appService.appSettings.ToggleSlotSetting', toggleSlotSetting);
registerCommandWithTreeNodeUnwrapping('appService.appSettings.Upload', uploadAppSettings);
registerCommandWithTreeNodeUnwrapping('appService.Browse', browseWebsite);
registerCommandWithTreeNodeUnwrapping('appService.ConfigureDeploymentSource', editScmType);
registerCommandWithTreeNodeUnwrapping('appService.connectToGitHub', connectToGitHub);
registerCommandWithTreeNodeUnwrapping('appService.CreateSlot', createSlot);
registerCommandWithTreeNodeUnwrapping('appService.CreateWebApp', createWebApp);
registerCommandWithTreeNodeUnwrapping('appService.CreateWebAppAdvanced', createWebAppAdvanced);
registerCommandWithTreeNodeUnwrapping('appService.Delete', deleteWebApp);
registerCommandWithTreeNodeUnwrapping('appService.DeploymentScript', generateDeploymentScript);
registerCommandWithTreeNodeUnwrapping('appService.DisconnectRepo', disconnectRepo);
registerCommandWithTreeNodeUnwrapping('appService.EnableFileLogging', enableFileLogging);
registerCommandWithTreeNodeUnwrapping('appService.InstallCosmosDBExtension', installCosmosDBExtension);
registerCommandWithTreeNodeUnwrapping('appService.LoadMore', async (actionContext: IActionContext, node?: AzExtTreeItem) => await ext.rgApi.tree.loadMore(nonNullValue(node), actionContext));
registerCommandWithTreeNodeUnwrapping('appService.openFile', showFile, 500);
registerCommandWithTreeNodeUnwrapping('appService.OpenInPortal', openInPortal);
registerCommandWithTreeNodeUnwrapping('appService.Refresh', async (actionContext: IActionContext, node?: AzExtTreeItem) => await ext.rgApi.tree.refresh(actionContext, node));
registerCommandWithTreeNodeUnwrapping('appService.RemoveCosmosDBConnection', removeCosmosDBConnection);
registerCommandWithTreeNodeUnwrapping('appService.Restart', restartWebApp);
registerCommandWithTreeNodeUnwrapping('appService.RevealConnection', revealConnection);
registerCommandWithTreeNodeUnwrapping('appService.RevealConnectionInAppSettings', revealConnectionInAppSettings);
registerCommandWithTreeNodeUnwrapping('appService.ScaleUp', async (_context: IActionContext, node?: DeploymentSlotsNATreeItem | ScaleUpTreeItem) => await uiOpenInPortal(nonNullValue(node), nonNullValue(node).scaleUpId));
registerCommandWithTreeNodeUnwrapping('appService.showOutputChannel', () => { ext.outputChannel.show(); });
registerCommandWithTreeNodeUnwrapping('appService.Start', startWebApp);
registerCommandWithTreeNodeUnwrapping('appService.StartRemoteDebug', startRemoteDebug);
registerCommandWithTreeNodeUnwrapping('appService.StartSsh', startSsh);
registerCommandWithTreeNodeUnwrapping('appService.startStreamingLogs', startStreamingLogs);
registerCommandWithTreeNodeUnwrapping('appService.Stop', stopWebApp);
registerCommandWithTreeNodeUnwrapping('appService.StopLogStream', stopStreamingLogs);
registerCommandWithTreeNodeUnwrapping('appService.SwapSlots', swapSlots);
registerCommandWithTreeNodeUnwrapping('appService.toggleAppSettingVisibility', async (actionContext: IActionContext, node?: AppSettingTreeItem) => { await nonNullValue(node).toggleValueVisibility(actionContext); }, 250);
registerCommandWithTreeNodeUnwrapping('appService.ViewCommitInGitHub', viewCommitInGitHub);
registerCommandWithTreeNodeUnwrapping('appService.ViewProperties', viewProperties);
registerSiteCommand('appService.Deploy', unwrapArgs(deploy));
registerSiteCommand('appService.DeploySlot', unwrapArgs(deploySlot));
registerSiteCommand('appService.Redeploy', unwrapArgs(redeployDeployment));
registerSiteCommand('appService.viewDeploymentLogs', unwrapArgs(viewDeploymentLogs));
}
3 changes: 2 additions & 1 deletion src/commands/viewProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { IActionContext, nonNullValue, openReadOnlyJson } from '@microsoft/vscod
import { localize } from '../localize';
import { SiteTreeItem } from '../tree/SiteTreeItem';

export async function viewProperties(context: IActionContext, node: SiteTreeItem): Promise<void> {
export async function viewProperties(context: IActionContext, treeItem?: SiteTreeItem): Promise<void> {
const node = nonNullValue(treeItem);
const client = await node.site.createClient(context);
await node.runWithTemporaryDescription(context, localize('retrievingProps', 'Retrieving properties...'), async () => {
// `siteConfig` already exists on `node.site`, but has very limited properties for some reason. We want to get the full site config
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { registerAppServiceExtensionVariables } from '@microsoft/vscode-azext-azureappservice';
import { registerAzureUtilsExtensionVariables } from '@microsoft/vscode-azext-azureutils';
import { callWithTelemetryAndErrorHandling, createApiProvider, createAzExtOutputChannel, createExperimentationService, IActionContext, registerErrorHandler, registerReportIssueCommand, registerUIExtensionVariables } from '@microsoft/vscode-azext-utils';
import { AzExtResourceType, callWithTelemetryAndErrorHandling, createApiProvider, createAzExtOutputChannel, createExperimentationService, IActionContext, registerErrorHandler, registerReportIssueCommand, registerUIExtensionVariables } from '@microsoft/vscode-azext-utils';
import { AzureExtensionApi, AzureExtensionApiProvider } from '@microsoft/vscode-azext-utils/api';
import * as vscode from 'vscode';
import { AppServiceFileSystem } from './AppServiceFileSystem';
Expand Down Expand Up @@ -44,7 +44,7 @@ export async function activateInternal(

ext.experimentationService = await createExperimentationService(context);
ext.rgApi = await getResourceGroupsApi();
ext.rgApi.registerApplicationResourceResolver('ms-azuretools.vscode-azureappservice', new WebAppResolver());
ext.rgApi.registerApplicationResourceResolver(AzExtResourceType.AppServices, new WebAppResolver());

ext.fileSystem = new AppServiceFileSystem(ext.rgApi.tree);
context.subscriptions.push(vscode.workspace.registerFileSystemProvider(AppServiceFileSystem.scheme, ext.fileSystem));
Expand Down