-
Notifications
You must be signed in to change notification settings - Fork 133
/
extension.ts
150 lines (137 loc) · 10.9 KB
/
extension.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as vscode from 'vscode';
import { AppSettingsTreeItem, AppSettingTreeItem, registerAppServiceExtensionVariables } from 'vscode-azureappservice';
import { AzureParentTreeItem, AzureTreeDataProvider, AzureTreeItem, AzureUserInput, callWithTelemetryAndErrorHandling, createApiProvider, createTelemetryReporter, IActionContext, registerCommand, registerEvent, registerUIExtensionVariables } from 'vscode-azureextensionui';
// tslint:disable-next-line:no-submodule-imports
import { AzureExtensionApiProvider } from 'vscode-azureextensionui/api';
import { decryptLocalSettings } from './commands/appSettings/decryptLocalSettings';
import { downloadAppSettings } from './commands/appSettings/downloadAppSettings';
import { encryptLocalSettings } from './commands/appSettings/encryptLocalSettings';
import { uploadAppSettings } from './commands/appSettings/uploadAppSettings';
import { configureDeploymentSource } from './commands/configureDeploymentSource';
import { copyFunctionUrl } from './commands/copyFunctionUrl';
import { createChildNode } from './commands/createChildNode';
import { createFunction } from './commands/createFunction/createFunction';
import { createFunctionApp } from './commands/createFunctionApp';
import { createNewProject } from './commands/createNewProject/createNewProject';
import { initProjectForVSCode } from './commands/createNewProject/initProjectForVSCode';
import { validateFunctionProjects } from './commands/createNewProject/validateFunctionProjects';
import { deleteNode } from './commands/deleteNode';
import { deploy } from './commands/deploy';
import { connectToGitHub } from './commands/deployments/connectToGitHub';
import { disconnectRepo } from './commands/deployments/disconnectRepo';
import { redeployDeployment } from './commands/deployments/redeployDeployment';
import { viewDeploymentLogs } from './commands/deployments/viewDeploymentLogs';
import { editAppSetting } from './commands/editAppSetting';
import { startStreamingLogs } from './commands/logstream/startStreamingLogs';
import { stopStreamingLogs } from './commands/logstream/stopStreamingLogs';
import { openInPortal } from './commands/openInPortal';
import { pickFuncProcess } from './commands/pickFuncProcess';
import { remoteDebugFunctionApp } from './commands/remoteDebugFunctionApp';
import { renameAppSetting } from './commands/renameAppSetting';
import { restartFunctionApp } from './commands/restartFunctionApp';
import { startFunctionApp } from './commands/startFunctionApp';
import { stopFunctionApp } from './commands/stopFunctionApp';
import { swapSlot } from './commands/swapSlot';
import { func } from './constants';
import { FuncTaskProvider } from './debug/FuncTaskProvider';
import { JavaDebugProvider } from './debug/JavaDebugProvider';
import { NodeDebugProvider } from './debug/NodeDebugProvider';
import { PythonDebugProvider } from './debug/PythonDebugProvider';
import { ext } from './extensionVariables';
import { registerFuncHostTaskEvents } from './funcCoreTools/funcHostTask';
import { installOrUpdateFuncCoreTools } from './funcCoreTools/installOrUpdateFuncCoreTools';
import { uninstallFuncCoreTools } from './funcCoreTools/uninstallFuncCoreTools';
import { validateFuncCoreToolsIsLatest } from './funcCoreTools/validateFuncCoreToolsIsLatest';
import { getTemplateProvider } from './templates/TemplateProvider';
import { FunctionAppProvider } from './tree/FunctionAppProvider';
import { FunctionTreeItem } from './tree/FunctionTreeItem';
import { ProductionSlotTreeItem } from './tree/ProductionSlotTreeItem';
import { ProxyTreeItem } from './tree/ProxyTreeItem';
import { SlotsTreeItem } from './tree/SlotsTreeItem';
export async function activateInternal(context: vscode.ExtensionContext, perfStats: { loadStartTime: number; loadEndTime: number }): Promise<AzureExtensionApiProvider> {
ext.context = context;
ext.reporter = createTelemetryReporter(context);
ext.outputChannel = vscode.window.createOutputChannel('Azure Functions');
context.subscriptions.push(ext.outputChannel);
ext.ui = new AzureUserInput(context.globalState);
registerUIExtensionVariables(ext);
registerAppServiceExtensionVariables(ext);
await callWithTelemetryAndErrorHandling('azureFunctions.activate', async function (this: IActionContext): Promise<void> {
this.properties.isActivationEvent = 'true';
this.measurements.mainFileLoad = (perfStats.loadEndTime - perfStats.loadStartTime) / 1000;
// tslint:disable-next-line:no-floating-promises
validateFuncCoreToolsIsLatest();
ext.tree = new AzureTreeDataProvider(FunctionAppProvider, 'azureFunctions.loadMore');
context.subscriptions.push(ext.tree);
context.subscriptions.push(vscode.window.registerTreeDataProvider('azureFunctionsExplorer', ext.tree));
const validateEventId: string = 'azureFunctions.validateFunctionProjects';
// tslint:disable-next-line:no-floating-promises
callWithTelemetryAndErrorHandling(validateEventId, async function (this: IActionContext): Promise<void> {
await validateFunctionProjects(this, vscode.workspace.workspaceFolders);
});
registerEvent(validateEventId, vscode.workspace.onDidChangeWorkspaceFolders, async function (this: IActionContext, event: vscode.WorkspaceFoldersChangeEvent): Promise<void> {
await validateFunctionProjects(this, event.added);
});
ext.templateProviderTask = getTemplateProvider();
registerCommand('azureFunctions.selectSubscriptions', () => vscode.commands.executeCommand('azure-account.selectSubscriptions'));
registerCommand('azureFunctions.refresh', async (node?: AzureTreeItem) => await ext.tree.refresh(node));
registerCommand('azureFunctions.pickProcess', pickFuncProcess);
registerCommand('azureFunctions.loadMore', async (node: AzureTreeItem) => await ext.tree.loadMore(node));
registerCommand('azureFunctions.openInPortal', openInPortal);
registerCommand('azureFunctions.createFunction', async function (this: IActionContext, functionAppPath?: string, templateId?: string, functionName?: string, functionSettings?: {}): Promise<void> {
await createFunction(this, functionAppPath, templateId, functionName, functionSettings);
});
registerCommand('azureFunctions.createNewProject', async function (this: IActionContext, functionAppPath?: string, language?: string, runtime?: string, openFolder?: boolean | undefined, templateId?: string, functionName?: string, functionSettings?: {}): Promise<void> {
await createNewProject(this, functionAppPath, language, runtime, openFolder, templateId, functionName, functionSettings);
});
registerCommand('azureFunctions.initProjectForVSCode', async function (this: IActionContext): Promise<void> { await initProjectForVSCode(this); });
registerCommand('azureFunctions.createFunctionApp', createFunctionApp);
registerCommand('azureFunctions.startFunctionApp', startFunctionApp);
registerCommand('azureFunctions.stopFunctionApp', stopFunctionApp);
registerCommand('azureFunctions.restartFunctionApp', restartFunctionApp);
registerCommand('azureFunctions.deleteFunctionApp', async (node?: AzureParentTreeItem) => await deleteNode(ProductionSlotTreeItem.contextValue, node));
registerCommand('azureFunctions.deploy', deploy);
registerCommand('azureFunctions.configureDeploymentSource', configureDeploymentSource);
registerCommand('azureFunctions.copyFunctionUrl', copyFunctionUrl);
registerCommand('azureFunctions.startStreamingLogs', startStreamingLogs);
registerCommand('azureFunctions.stopStreamingLogs', stopStreamingLogs);
registerCommand('azureFunctions.deleteFunction', async (node?: AzureTreeItem) => await deleteNode(FunctionTreeItem.contextValue, node));
registerCommand('azureFunctions.appSettings.add', async (node?: AzureParentTreeItem) => await createChildNode(AppSettingsTreeItem.contextValue, node));
registerCommand('azureFunctions.appSettings.download', downloadAppSettings);
registerCommand('azureFunctions.appSettings.upload', uploadAppSettings);
registerCommand('azureFunctions.appSettings.edit', editAppSetting);
registerCommand('azureFunctions.appSettings.rename', renameAppSetting);
registerCommand('azureFunctions.appSettings.decrypt', decryptLocalSettings);
registerCommand('azureFunctions.appSettings.encrypt', encryptLocalSettings);
registerCommand('azureFunctions.appSettings.delete', async (node?: AppSettingTreeItem) => await deleteNode(AppSettingTreeItem.contextValue, node));
registerCommand('azureFunctions.debugFunctionAppOnAzure', remoteDebugFunctionApp);
registerCommand('azureFunctions.deleteProxy', async (node?: AzureTreeItem) => await deleteNode(ProxyTreeItem.contextValue, node));
registerCommand('azureFunctions.installOrUpdateFuncCoreTools', installOrUpdateFuncCoreTools);
registerCommand('azureFunctions.uninstallFuncCoreTools', uninstallFuncCoreTools);
registerCommand('azureFunctions.redeploy', redeployDeployment);
registerCommand('azureFunctions.viewDeploymentLogs', viewDeploymentLogs);
registerCommand('azureFunctions.connectToGitHub', connectToGitHub);
registerCommand('azureFunctions.disconnectRepo', disconnectRepo);
registerCommand('azureFunctions.swapSlot', swapSlot);
registerCommand('azureFunctions.createSlot', async (node?: AzureParentTreeItem) => await createChildNode(SlotsTreeItem.contextValue, node));
registerCommand('azureFunctions.toggleAppSettingVisibility', async (node: AppSettingTreeItem) => { await node.toggleValueVisibility(); }, 250);
registerFuncHostTaskEvents();
const nodeDebugProvider: NodeDebugProvider = new NodeDebugProvider();
const pythonDebugProvider: PythonDebugProvider = new PythonDebugProvider();
const javaDebugProvider: JavaDebugProvider = new JavaDebugProvider();
// These don't actually overwrite "node", "python", etc. - they just add to it
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('node', nodeDebugProvider));
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('python', pythonDebugProvider));
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('java', javaDebugProvider));
context.subscriptions.push(vscode.workspace.registerTaskProvider(func, new FuncTaskProvider(nodeDebugProvider, pythonDebugProvider, javaDebugProvider)));
});
return createApiProvider([]);
}
// tslint:disable-next-line:no-empty
export function deactivateInternal(): void {
}