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

Add Execute Step in createFunction API #3150

Merged
merged 4 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest something clearer indicating that this is specifically right before the folder is opened. Maybe beforeOpenFolderExecuteStep

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, ok nevermind. Forgot that the order is based on the priority instead. In that case this is fine - although you should update the comment to indicate that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still isn't accurate - it's not guaranteed to be before the OpenFolderStep. I'd just remove that and say executed in the order determined by the priority of the step

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could include the priority number of OpenFolderStep so people know to set the priority lower than that (lower in this case is higher priority)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that - but then if the priority is ever changed it's slightly annoying to have to remember to update this comment as well. Maybe do that but also provide a link to the code line so it's easy to verify as well?

}