Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async prompt(wizardContext: IAppServiceWizardContext): Promise {
// Cache hosting plan separately per subscription
const options: IAzureQuickPickOptions = { placeHolder: localize('selectPlan', 'Select a {0} App Service plan.', getWebsiteOSDisplayName(nonNullProp(wizardContext, 'newSiteOS'))), id: `AppServicePlanListStep/${wizardContext.subscriptionId}` };
wizardContext.plan = (await ext.ui.showQuickPick(this.getQuickPicks(wizardContext), options)).data;
wizardContext.telemetry.properties.newPlan = String(!wizardContext.plan);
if (wizardContext.plan) {
await LocationListStep.setLocation(wizardContext, wizardContext.plan.location);
}
}
if (await fse.pathExists(path.join(fsPath, 'package.json'))) {
wizardContext.recommendedSiteRuntime = [LinuxRuntimes.node];
} else if (await fse.pathExists(path.join(fsPath, 'requirements.txt'))) {
// requirements.txt are used to pip install so a good way to determine it's a Python app
wizardContext.recommendedSiteRuntime = [LinuxRuntimes.python];
}
actionContext.properties.recommendedSiteRuntime = wizardContext.recommendedSiteRuntime ? wizardContext.recommendedSiteRuntime.join(',') : undefined;
}
if (!advancedCreation) {
await LocationListStep.setLocation(wizardContext, 'centralus');
if (isJavaProject) {
// considering high resource requirement for Java applications, a higher plan sku is set here
wizardContext.newPlanSku = { name: 'P1v2', tier: 'PremiumV2', size: 'P1v2', family: 'P', capacity: 1 };
// to avoid 'Requested features are not supported in region' error
await LocationListStep.setLocation(wizardContext, 'westeurope');
}
// we only set the OS for the non-advanced creation scenario
// tslint:disable-next-line:strict-boolean-expressions
if (wizardContext.recommendedSiteRuntime) {
wizardContext.newSiteOS = WebsiteOS.linux;
} else {
await workspace.findFiles('*.csproj').then((files: Uri[]) => {
if (files.length > 0) {
wizardContext.newSiteOS = WebsiteOS.windows;
}
});
}
}
}
];
}
// only detect if one workspace is opened
if (workspace.workspaceFolders && workspace.workspaceFolders.length === 1) {
const fsPath: string = workspace.workspaceFolders[0].uri.fsPath;
if (await fse.pathExists(path.join(fsPath, 'package.json'))) {
wizardContext.recommendedSiteRuntime = [LinuxRuntimes.node];
} else if (await fse.pathExists(path.join(fsPath, 'requirements.txt'))) {
// requirements.txt are used to pip install so a good way to determine it's a Python app
wizardContext.recommendedSiteRuntime = [LinuxRuntimes.python];
}
actionContext.properties.recommendedSiteRuntime = wizardContext.recommendedSiteRuntime ? wizardContext.recommendedSiteRuntime.join(',') : undefined;
}
if (!advancedCreation) {
await LocationListStep.setLocation(wizardContext, 'centralus');
if (isJavaProject) {
// considering high resource requirement for Java applications, a higher plan sku is set here
wizardContext.newPlanSku = { name: 'P1v2', tier: 'PremiumV2', size: 'P1v2', family: 'P', capacity: 1 };
// to avoid 'Requested features are not supported in region' error
await LocationListStep.setLocation(wizardContext, 'westeurope');
}
// we only set the OS for the non-advanced creation scenario
// tslint:disable-next-line:strict-boolean-expressions
if (wizardContext.recommendedSiteRuntime) {
wizardContext.newSiteOS = WebsiteOS.linux;
} else {
await workspace.findFiles('*.csproj').then((files: Uri[]) => {
if (files.length > 0) {
wizardContext.newSiteOS = WebsiteOS.windows;
}
});