import { join } from 'path' ; import { commands , MessageItem , Uri , window } from "vscode" ; import { UserCancelledError } from "vscode-azureextensionui" ; import { ext } from '../extensionVariables' ; import { localize } from '../localize' ; import { ParsedSite } from '../SiteClient' ; import { delay } from '../utils/delay' ; import { updateWorkspaceSetting } from '../utils/settings' ; import { AppSource , IDeployContext } from './IDeployContext' ; export async function showDeployConfirmation ( context , site , deployCommandId ) { const warning = localize ( 'confirmDeploy' , 'Are you sure you want to deploy to "{0}"? This will overwrite any previous deployment and cannot be undone.' , site . fullName ) ; const items = [ { title : localize ( 'deploy' , 'Deploy' ) } ] ; const resetDefault = { title : 'Reset default' } ; if ( context . appSource === AppSource . setting ) { items . push ( resetDefault ) ; } const result = await context . ui . showWarningMessage ( warning , { modal : true , stepName : 'confirmDestructiveDeployment' } , ... items ) ; await delay ( 500 ) ; if ( result === resetDefault ) { const settingsPath = join ( context . workspaceFolder . uri . fsPath , '.vscode' , 'settings.json' ) ; await updateWorkspaceSetting ( context . defaultAppSetting , '' , context . workspaceFolder . uri . fsPath , ext . prefix ) ; await window . showTextDocument ( Uri . file ( settingsPath ) ) ; void commands . executeCommand ( deployCommandId ) ; throw new UserCancelledError ( 'resetDefault' ) ; } }