Explicitly specify ordering of steps in wizard (#1143)

This commit is contained in:
Eric Jizba 2019-04-01 08:55:35 -07:00 коммит произвёл GitHub
Родитель 7cb7887765
Коммит dcb51982ca
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 47 добавлений и 43 удалений

14
package-lock.json сгенерированный
Просмотреть файл

@ -9848,9 +9848,9 @@
}
},
"vscode-azureappservice": {
"version": "0.34.1",
"resolved": "https://registry.npmjs.org/vscode-azureappservice/-/vscode-azureappservice-0.34.1.tgz",
"integrity": "sha512-5pqXGIxHxi6A17Q4RcdWSqa7B9ZcbzhR06odtuoTdnfFU49nemXkiVVNB3r7uogRJdU7lYRfIRIRM+5ZyIsLFg==",
"version": "0.35.0",
"resolved": "https://registry.npmjs.org/vscode-azureappservice/-/vscode-azureappservice-0.35.0.tgz",
"integrity": "sha512-X/YOTYZEJKVreexLsC/dEdqNVDMmydy9tWsGECQWlaZ1D2mw1eiQt4Q8xskNPgo//xUr15FzYaSxKgPvldC5Ew==",
"requires": {
"archiver": "^2.0.3",
"azure-arm-resource": "^3.0.0-preview",
@ -9865,7 +9865,7 @@
"request": "^2.83.0",
"request-promise": "^4.2.2",
"simple-git": "~1.92.0",
"vscode-azureextensionui": "^0.22.1",
"vscode-azureextensionui": "^0.23.0",
"vscode-azurekudu": "^0.1.9",
"vscode-nls": "^4.0.0",
"websocket": "^1.0.25"
@ -10248,9 +10248,9 @@
}
},
"vscode-azureextensionui": {
"version": "0.22.2",
"resolved": "https://registry.npmjs.org/vscode-azureextensionui/-/vscode-azureextensionui-0.22.2.tgz",
"integrity": "sha512-j/RfJs/grWHDgGmVCcUhEDSrbSfxGqF0DCdBJk8PZ9e6jLStl1KE6wdxmSrB6TAkieqSg+GbTjGc+e+7z5ha+g==",
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/vscode-azureextensionui/-/vscode-azureextensionui-0.23.0.tgz",
"integrity": "sha512-K35st1GdO0fed0vuRCHFO6OksH0Bonva5jJUVrnWmWriucnQq7crnA+85WPlh4l+720APcY8d1MjGes8o7O76A==",
"requires": {
"azure-arm-resource": "^3.0.0-preview",
"azure-arm-storage": "^3.1.0",

Просмотреть файл

@ -891,8 +891,8 @@
"ps-tree": "^1.1.1",
"request-promise": "^4.2.4",
"semver": "^5.7.0",
"vscode-azureappservice": "^0.34.1",
"vscode-azureextensionui": "^0.22.2",
"vscode-azureappservice": "^0.35.0",
"vscode-azureextensionui": "^0.23.0",
"vscode-azurekudu": "^0.1.8",
"vscode-nls": "^4.1.0",
"websocket": "^1.0.25",

Просмотреть файл

@ -36,6 +36,8 @@ export function runPostFunctionCreateStepsFromCache(): void {
}
export abstract class FunctionCreateStepBase<T extends IFunctionWizardContext> extends AzureWizardExecuteStep<T> {
public priority: number = 220;
/**
* Returns the full path to the new function file
*/

Просмотреть файл

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardPromptStep, IAzureQuickPickItem, IAzureQuickPickOptions, IWizardOptions } from 'vscode-azureextensionui';
import { AzureWizardExecuteStep, AzureWizardPromptStep, IAzureQuickPickItem, IAzureQuickPickOptions, IWizardOptions } from 'vscode-azureextensionui';
import { ProjectLanguage, ProjectRuntime, TemplateFilter, templateFilterSetting } from '../../constants';
import { ext } from '../../extensionVariables';
import { localize } from '../../localize';
@ -96,8 +96,24 @@ export class FunctionListStep extends AzureWizardPromptStep<IFunctionWizardConte
}
}
const executeSteps: AzureWizardExecuteStep<IFunctionWizardContext>[] = [];
switch (wizardContext.language) {
case ProjectLanguage.Java:
executeSteps.push(await JavaFunctionCreateStep.createStep(wizardContext.actionContext));
break;
case ProjectLanguage.CSharp:
executeSteps.push(await DotnetFunctionCreateStep.createStep(wizardContext.actionContext));
break;
case ProjectLanguage.TypeScript:
executeSteps.push(new TypeScriptFunctionCreateStep());
break;
default:
executeSteps.push(new ScriptFunctionCreateStep());
break;
}
const title: string = localize('createFunction', 'Create new {0}', template.name);
return { promptSteps, title };
return { promptSteps, executeSteps, title };
} else {
return undefined;
}
@ -162,30 +178,6 @@ export class FunctionListStep extends AzureWizardPromptStep<IFunctionWizardConte
}
}
export async function addFunctionSteps(wizardContext: IFunctionWizardContext, options: IWizardOptions<IFunctionWizardContext>, stepOptions: IFunctionListStepOptions): Promise<void> {
// tslint:disable-next-line: strict-boolean-expressions
options.promptSteps = options.promptSteps || [];
// tslint:disable-next-line: strict-boolean-expressions
options.executeSteps = options.executeSteps || [];
options.promptSteps.push(await FunctionListStep.createFunctionListStep(wizardContext, stepOptions));
switch (wizardContext.language) {
case ProjectLanguage.Java:
options.executeSteps.push(await JavaFunctionCreateStep.createStep(wizardContext.actionContext));
break;
case ProjectLanguage.CSharp:
options.executeSteps.push(await DotnetFunctionCreateStep.createStep(wizardContext.actionContext));
break;
case ProjectLanguage.TypeScript:
options.executeSteps.push(new TypeScriptFunctionCreateStep());
break;
default:
options.executeSteps.push(new ScriptFunctionCreateStep());
break;
}
}
interface IFunctionListStepOptions {
isProjectWizard: boolean;
templateId: string | undefined;

Просмотреть файл

@ -17,6 +17,8 @@ export interface IConnection {
}
export abstract class AzureConnectionCreateStepBase<T extends IFunctionWizardContext> extends AzureWizardExecuteStep<T> {
public priority: number = 200;
private readonly _setting: IFunctionSetting;
constructor(setting: IFunctionSetting) {

Просмотреть файл

@ -4,14 +4,14 @@
*--------------------------------------------------------------------------------------------*/
import { window, workspace, WorkspaceFolder } from 'vscode';
import { AzureWizard, IActionContext, IWizardOptions, UserCancelledError } from 'vscode-azureextensionui';
import { AzureWizard, IActionContext, UserCancelledError } from 'vscode-azureextensionui';
import { ProjectLanguage, ProjectRuntime } from '../../constants';
import { NoWorkspaceError } from '../../errors';
import { addLocalFuncTelemetry } from '../../funcCoreTools/getLocalFuncCoreToolsVersion';
import { localize } from '../../localize';
import { verifyAndPromptToCreateProject } from '../createNewProject/verifyIsProject';
import { verifyInitForVSCode } from '../initProjectForVSCode/verifyVSCodeConfig';
import { addFunctionSteps } from './FunctionListStep';
import { FunctionListStep } from './FunctionListStep';
import { IFunctionWizardContext } from './IFunctionWizardContext';
export async function createFunction(
@ -48,9 +48,9 @@ export async function createFunction(
[language, runtime] = await verifyInitForVSCode(actionContext, projectPath, language, runtime);
const wizardContext: IFunctionWizardContext = { actionContext, projectPath, workspacePath, runtime, language, functionName };
const wizardOptions: IWizardOptions<IFunctionWizardContext> = {};
await addFunctionSteps(wizardContext, wizardOptions, { templateId, caseSensitiveFunctionSettings, isProjectWizard: false });
const wizard: AzureWizard<IFunctionWizardContext> = new AzureWizard(wizardContext, wizardOptions);
const wizard: AzureWizard<IFunctionWizardContext> = new AzureWizard(wizardContext, {
promptSteps: [await FunctionListStep.createFunctionListStep(wizardContext, { templateId, caseSensitiveFunctionSettings, isProjectWizard: false })]
});
await wizard.prompt(actionContext);
await wizard.execute(actionContext);
}

Просмотреть файл

@ -12,6 +12,8 @@ import { nonNullProp } from '../../../utils/nonNull';
import { IFunctionWizardContext } from '../IFunctionWizardContext';
export class LocalAppSettingCreateStep extends AzureWizardExecuteStep<IFunctionWizardContext> {
public priority: number = 210;
private readonly _nameKey: string;
private readonly _valueKey: string;

Просмотреть файл

@ -10,7 +10,7 @@ import { ext } from '../../extensionVariables';
import { localize } from '../../localize';
import { getFuncExtensionSetting } from '../../ProjectSettings';
import { nonNullProp } from '../../utils/nonNull';
import { addFunctionSteps } from '../createFunction/FunctionListStep';
import { FunctionListStep } from '../createFunction/FunctionListStep';
import { addInitVSCodeStep } from '../initProjectForVSCode/InitVSCodeLanguageStep';
import { IProjectWizardContext } from './IProjectWizardContext';
import { JavaAppNameStep } from './javaSteps/JavaAppNameStep';
@ -96,11 +96,11 @@ export class NewProjectLanguageStep extends AzureWizardPromptStep<IProjectWizard
// All languages except Java support creating a function after creating a project
// Java needs to fix this issue first: https://github.com/Microsoft/vscode-azurefunctions/issues/81
if (language !== ProjectLanguage.Java) {
await addFunctionSteps(wizardContext, wizardOptions, {
promptSteps.push(await FunctionListStep.createFunctionListStep(wizardContext, {
isProjectWizard: true,
templateId: this._templateId,
caseSensitiveFunctionSettings: this._caseSensitiveFunctionSettings
});
}));
}
return wizardOptions;

Просмотреть файл

@ -8,6 +8,8 @@ import { AzureWizardExecuteStep } from 'vscode-azureextensionui';
import { IProjectWizardContext } from './IProjectWizardContext';
export class OpenFolderStep extends AzureWizardExecuteStep<IProjectWizardContext> {
public priority: number = 250;
public async execute(wizardContext: IProjectWizardContext): Promise<void> {
// tslint:disable-next-line:strict-boolean-expressions
const openFolders: WorkspaceFolder[] = workspace.workspaceFolders || [];

Просмотреть файл

@ -12,6 +12,8 @@ import { gitUtils } from '../../../utils/gitUtils';
import { IProjectWizardContext } from '../IProjectWizardContext';
export abstract class ProjectCreateStepBase extends AzureWizardExecuteStep<IProjectWizardContext> {
public priority: number = 10;
public abstract async executeCore(wizardContext: IProjectWizardContext): Promise<void>;
public async execute(wizardContext: IProjectWizardContext, progress: Progress<{ message?: string | undefined; increment?: number | undefined }>): Promise<void> {

Просмотреть файл

@ -14,6 +14,8 @@ import { IFunctionWizardContext } from '../../createFunction/IFunctionWizardCont
import { IProjectWizardContext } from '../../createNewProject/IProjectWizardContext';
export abstract class InitVSCodeStepBase extends AzureWizardExecuteStep<IProjectWizardContext> {
public priority: number = 20;
protected preDeployTask?: string;
protected excludedFiles?: string[];
protected otherSettings: { [key: string]: string } = {};