Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function deleteSite(client: SiteClient): Promise {
const confirmMessage: string = localize('deleteConfirmation', 'Are you sure you want to delete "{0}"?', client.fullName);
await ext.ui.showWarningMessage(confirmMessage, { modal: true }, DialogResponses.deleteResponse, DialogResponses.cancel);
let plan: AppServicePlan | undefined;
let deletePlan: boolean = false;
if (!client.isSlot) {
// API calls not necessary for deployment slots
plan = await client.getAppServicePlan();
}
if (!client.isSlot && plan && !isNullOrUndefined(plan.numberOfSites) && plan.numberOfSites < 2) {
const message: string = localize('deleteLastServicePlan', 'This is the last app in the App Service plan "{0}". Do you want to delete this App Service plan to prevent unexpected charges?', plan.name);
const input: vscode.MessageItem = await ext.ui.showWarningMessage(message, { modal: true }, DialogResponses.yes, DialogResponses.no, DialogResponses.cancel);
deletePlan = input === DialogResponses.yes;
}
const deleting: string = localize('Deleting', 'Deleting "{0}"...', client.fullName);
const deleteSucceeded: string = localize('DeleteSucceeded', 'Successfully deleted "{0}".', client.fullName);
await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: deleting }, async (): Promise => {
ext.outputChannel.appendLog(deleting);
await client.deleteMethod({ deleteEmptyServerFarm: deletePlan });
vscode.window.showInformationMessage(deleteSucceeded);
ext.outputChannel.appendLog(deleteSucceeded);
});
}
const addedKeys: string[] = [];
const updatedKeys: string[] = [];
const userIgnoredKeys: string[] = [];
const matchingKeys: string[] = [];
for (const key of Object.keys(sourceSettings)) {
if (destinationSettings[key] === undefined) {
addedKeys.push(key);
destinationSettings[key] = sourceSettings[key];
} else if (destinationSettings[key] !== sourceSettings[key]) {
if (!suppressPrompt) {
const yesToAll: MessageItem = { title: localize('yesToAll', 'Yes to all') };
const noToAll: MessageItem = { title: localize('noToAll', 'No to all') };
const message: string = localize('overwriteSetting', 'Setting "{0}" already exists in "{1}". Overwrite?', key, destinationName);
const result: MessageItem = await ext.ui.showWarningMessage(message, { modal: true }, DialogResponses.yes, yesToAll, DialogResponses.no, noToAll);
if (result === DialogResponses.yes) {
overwriteSetting = true;
} else if (result === yesToAll) {
overwriteSetting = true;
suppressPrompt = true;
} else if (result === DialogResponses.no) {
overwriteSetting = false;
} else if (result === noToAll) {
overwriteSetting = false;
suppressPrompt = true;
}
}
if (overwriteSetting) {
updatedKeys.push(key);
destinationSettings[key] = sourceSettings[key];
for (const key of Object.keys(sourceSettings)) {
if (destinationSettings[key] === undefined) {
addedKeys.push(key);
destinationSettings[key] = sourceSettings[key];
} else if (destinationSettings[key] !== sourceSettings[key]) {
if (!suppressPrompt) {
const yesToAll: MessageItem = { title: localize('yesToAll', 'Yes to all') };
const noToAll: MessageItem = { title: localize('noToAll', 'No to all') };
const message: string = localize('overwriteSetting', 'Setting "{0}" already exists in "{1}". Overwrite?', key, destinationName);
const result: MessageItem = await ext.ui.showWarningMessage(message, { modal: true }, DialogResponses.yes, yesToAll, DialogResponses.no, noToAll);
if (result === DialogResponses.yes) {
overwriteSetting = true;
} else if (result === yesToAll) {
overwriteSetting = true;
suppressPrompt = true;
} else if (result === DialogResponses.no) {
overwriteSetting = false;
} else if (result === noToAll) {
overwriteSetting = false;
suppressPrompt = true;
}
}
if (overwriteSetting) {
updatedKeys.push(key);
destinationSettings[key] = sourceSettings[key];
} else {
userIgnoredKeys.push(key);
}
} else {
matchingKeys.push(key);
}