Skip to content

Commit

Permalink
Add Execute Step in createFunction API (#3150)
Browse files Browse the repository at this point in the history
* add execute step in api to allow for execution of new azure function prior to openFolderStep

* address comments

* vbump apiVersion

* add comment
  • Loading branch information
VasuBhog authored May 5, 2022
1 parent f68e470 commit 8694350
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/commands/createNewProject/createNewProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export async function createNewProjectInternal(context: IActionContext, options:
const version: string = options.version || getGlobalSetting(funcVersionSetting) || await tryGetLocalFuncVersion(context, undefined) || latestGAVersion;
const projectTemplateKey: string | undefined = getGlobalSetting(projectTemplateKeySetting);
const wizardContext: Partial<IFunctionWizardContext> & IActionContext = Object.assign(context, options, { language, version: tryParseFuncVersion(version), projectTemplateKey });
const optionalExecuteStep = options.executeStep;

if (options.folderPath) {
FolderListStep.setProjectPath(wizardContext, options.folderPath);
Expand All @@ -64,7 +65,7 @@ export async function createNewProjectInternal(context: IActionContext, options:
const wizard: AzureWizard<IFunctionWizardContext> = new AzureWizard(wizardContext, {
title: localize('createNewProject', 'Create new project'),
promptSteps: [new FolderListStep(), new NewProjectLanguageStep(options.templateId, options.functionSettings), new OpenBehaviorStep()],
executeSteps: [new OpenFolderStep()]
executeSteps: optionalExecuteStep ? [optionalExecuteStep, new OpenFolderStep()] : [new OpenFolderStep()]
});
await wizard.prompt();
await wizard.execute();
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export async function activateInternal(context: vscode.ExtensionContext, perfSta
createFunction: createFunctionFromApi,
downloadAppSettings: downloadAppSettingsFromApi,
uploadAppSettings: uploadAppSettingsFromApi,
apiVersion: '1.7.0'
apiVersion: '1.8.0'
}]);
}

Expand Down
8 changes: 8 additions & 0 deletions src/vscode-azurefunctions.api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzureWizardExecuteStep, IActionContext } from "@microsoft/vscode-azext-utils";

export interface AzureFunctionsExtensionApi {
apiVersion: string;

Expand Down Expand Up @@ -83,4 +85,10 @@ export interface ICreateFunctionOptions {
* If set, it will automatically select the worker runtime for .NET with the matching targetFramework
*/
targetFramework?: string | string[];

/**
* If set, it will include a step that will be executed prior to OpenFolderStep determined by the priority of the step
* OpenFolder priority is 250 (https://github.com/microsoft/vscode-azurefunctions/blob/main/src/commands/createNewProject/OpenFolderStep.ts#L11)
*/
executeStep?: AzureWizardExecuteStep<IActionContext>;
}

0 comments on commit 8694350

Please sign in to comment.