-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathextension.ts
144 lines (121 loc) · 8.46 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
/*---------------------------------------------------------------------------------------------
* 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 { registerAppServiceExtensionVariables } from '@microsoft/vscode-azext-azureappservice';
import { registerAzureUtilsExtensionVariables, type AzureAccountTreeItemBase } from '@microsoft/vscode-azext-azureutils';
import { callWithTelemetryAndErrorHandling, createApiProvider, createAzExtOutputChannel, createExperimentationService, registerErrorHandler, registerEvent, registerReportIssueCommand, registerUIExtensionVariables, type IActionContext, type apiUtils } from '@microsoft/vscode-azext-utils';
import { AzExtResourceType, getAzureResourcesExtensionApi } from '@microsoft/vscode-azureresources-api';
import * as vscode from 'vscode';
import { FunctionAppResolver } from './FunctionAppResolver';
import { FunctionsLocalResourceProvider } from './LocalResourceProvider';
import { createFunctionFromApi } from './commands/api/createFunctionFromApi';
import { downloadAppSettingsFromApi } from './commands/api/downloadAppSettingsFromApi';
import { revealTreeItem } from './commands/api/revealTreeItem';
import { uploadAppSettingsFromApi } from './commands/api/uploadAppSettingsFromApi';
import { runPostFunctionCreateStepsFromCache } from './commands/createFunction/FunctionCreateStepBase';
import { startFuncProcessFromApi } from './commands/pickFuncProcess';
import { registerCommands } from './commands/registerCommands';
import { func } from './constants';
import { BallerinaDebugProvider } from './debug/BallerinaDebugProvider';
import { FuncTaskProvider } from './debug/FuncTaskProvider';
import { JavaDebugProvider } from './debug/JavaDebugProvider';
import { NodeDebugProvider } from './debug/NodeDebugProvider';
import { PowerShellDebugProvider } from './debug/PowerShellDebugProvider';
import { PythonDebugProvider } from './debug/PythonDebugProvider';
import { handleUri } from './downloadAzureProject/handleUri';
import { ext } from './extensionVariables';
import { registerFuncHostTaskEvents } from './funcCoreTools/funcHostTask';
import { validateFuncCoreToolsInstalled } from './funcCoreTools/validateFuncCoreToolsInstalled';
import { validateFuncCoreToolsIsLatest } from './funcCoreTools/validateFuncCoreToolsIsLatest';
import { getResourceGroupsApi } from './getExtensionApi';
import { CentralTemplateProvider } from './templates/CentralTemplateProvider';
import { registerContentProvider } from './utils/textUtils';
import { verifyVSCodeConfigOnActivate } from './vsCodeConfig/verifyVSCodeConfigOnActivate';
import { type AzureFunctionsExtensionApi } from './vscode-azurefunctions.api';
import { listLocalFunctions } from './workspace/listLocalFunctions';
import { listLocalProjects } from './workspace/listLocalProjects';
import { DurableTaskSchedulerDataBranchProvider } from './tree/durableTaskScheduler/DurableTaskSchedulerDataBranchProvider';
import { HttpDurableTaskSchedulerClient } from './tree/durableTaskScheduler/DurableTaskSchedulerClient';
export async function activateInternal(context: vscode.ExtensionContext, perfStats: { loadStartTime: number; loadEndTime: number }, ignoreBundle?: boolean): Promise<apiUtils.AzureExtensionApiProvider> {
ext.context = context;
ext.ignoreBundle = ignoreBundle;
ext.outputChannel = createAzExtOutputChannel('Azure Functions', ext.prefix);
context.subscriptions.push(ext.outputChannel);
registerUIExtensionVariables(ext);
registerAzureUtilsExtensionVariables(ext);
registerAppServiceExtensionVariables(ext);
await callWithTelemetryAndErrorHandling('azureFunctions.activate', async (activateContext: IActionContext) => {
activateContext.telemetry.properties.isActivationEvent = 'true';
activateContext.telemetry.measurements.mainFileLoad = (perfStats.loadEndTime - perfStats.loadStartTime) / 1000;
void runPostFunctionCreateStepsFromCache();
void validateFuncCoreToolsIsLatest();
const validateEventId: string = 'azureFunctions.validateFunctionProjects';
void callWithTelemetryAndErrorHandling(validateEventId, async (actionContext: IActionContext) => {
await verifyVSCodeConfigOnActivate(actionContext, vscode.workspace.workspaceFolders);
});
registerEvent(validateEventId, vscode.workspace.onDidChangeWorkspaceFolders, async (actionContext: IActionContext, event: vscode.WorkspaceFoldersChangeEvent) => {
await verifyVSCodeConfigOnActivate(actionContext, event.added);
});
const templateProvider = new CentralTemplateProvider();
ext.templateProvider.registerExtensionVariable(templateProvider);
context.subscriptions.push(templateProvider);
// Suppress "Report an Issue" button for all errors in favor of the command
registerErrorHandler(c => c.errorHandling.suppressReportIssue = true);
registerReportIssueCommand('azureFunctions.reportIssue');
const schedulerClient = new HttpDurableTaskSchedulerClient();
const dataBranchProvider = new DurableTaskSchedulerDataBranchProvider(schedulerClient);
registerCommands({
dts: {
dataBranchProvider,
schedulerClient
}
});
registerFuncHostTaskEvents();
const nodeDebugProvider: NodeDebugProvider = new NodeDebugProvider();
const pythonDebugProvider: PythonDebugProvider = new PythonDebugProvider();
const javaDebugProvider: JavaDebugProvider = new JavaDebugProvider();
const ballerinaDebugProvider: BallerinaDebugProvider = new BallerinaDebugProvider();
const powershellDebugProvider: PowerShellDebugProvider = new PowerShellDebugProvider();
// 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.debug.registerDebugConfigurationProvider('ballerina', ballerinaDebugProvider));
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('PowerShell', powershellDebugProvider));
context.subscriptions.push(vscode.workspace.registerTaskProvider(func, new FuncTaskProvider(nodeDebugProvider, pythonDebugProvider, javaDebugProvider, ballerinaDebugProvider, powershellDebugProvider)));
context.subscriptions.push(vscode.window.registerUriHandler({
handleUri
}));
registerContentProvider();
ext.experimentationService = await createExperimentationService(context);
ext.rgApi = await getResourceGroupsApi();
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
ext.azureAccountTreeItem = ext.rgApi.appResourceTree._rootTreeItem as AzureAccountTreeItemBase;
ext.rgApi.registerApplicationResourceResolver(AzExtResourceType.FunctionApp, new FunctionAppResolver());
ext.rgApi.registerWorkspaceResourceProvider('func', new FunctionsLocalResourceProvider());
const azureResourcesApi = await getAzureResourcesExtensionApi(context, '2.0.0');
ext.rgApiV2 = azureResourcesApi;
azureResourcesApi.resources.registerAzureResourceBranchDataProvider('DurableTaskScheduler' as AzExtResourceType, dataBranchProvider);
});
return createApiProvider([<AzureFunctionsExtensionApi>{
revealTreeItem,
createFunction: createFunctionFromApi,
downloadAppSettings: downloadAppSettingsFromApi,
uploadAppSettings: uploadAppSettingsFromApi,
listLocalProjects: listLocalProjects,
listLocalFunctions: listLocalFunctions,
isFuncCoreToolsInstalled: async (message: string) => {
return await callWithTelemetryAndErrorHandling('azureFunctions.api.isFuncCoreToolsInstalled', async (context: IActionContext) => {
return await validateFuncCoreToolsInstalled(context, message, undefined);
});
},
startFuncProcess: startFuncProcessFromApi,
apiVersion: '1.10.0'
}]);
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
export function deactivateInternal(): void {
}