-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathOutputLocationStep.ts
More file actions
38 lines (32 loc) · 2.25 KB
/
OutputLocationStep.ts
File metadata and controls
38 lines (32 loc) · 2.25 KB
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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils";
import { angularOutputLocation, appArtifactSubpathSetting, outputSubpathSetting } from "../../constants";
import { localize } from "../../utils/localize";
import { getWorkspaceSetting } from "../../utils/settingsUtils";
import { validateLocationYaml } from "../../utils/yamlUtils";
import { IStaticWebAppWizardContext } from "./IStaticWebAppWizardContext";
import { addLocationTelemetry } from "./addLocationTelemetry";
export class OutputLocationStep extends AzureWizardPromptStep<IStaticWebAppWizardContext> {
public async prompt(context: IStaticWebAppWizardContext): Promise<void> {
const defaultValue: string = context.buildPreset?.outputLocation ?? 'build';
const workspaceSetting: string | undefined = getWorkspaceSetting(outputSubpathSetting, context.uri);
context.outputLocation = (await context.ui.showInputBox({
value: workspaceSetting || getWorkspaceSetting(appArtifactSubpathSetting, context.uri) || defaultValue,
prompt: localize('publishLocation', "Enter the location of your build output relative to your app's location or leave blank if it has no build. For example, setting a value of 'build' when your app location is set to 'app' will cause the content at 'app/build' to be served."),
learnMoreLink: 'https://aka.ms/SwaOutLoc',
validateInput: (value: string): string | undefined => {
if (value === angularOutputLocation) {
return localize('fillProjectName', 'Fill in the name of your Angular project.');
}
return validateLocationYaml(value, 'output_location');
}
})).trim();
addLocationTelemetry(context, 'outputLocation', defaultValue, workspaceSetting);
}
public shouldPrompt(context: IStaticWebAppWizardContext): boolean {
return !context.outputLocation;
}
}