From f3217225ae711e1c802cfffed67053362f04d638 Mon Sep 17 00:00:00 2001 From: Rebecca Hum Date: Wed, 7 Aug 2024 14:46:40 -0600 Subject: [PATCH] Do same for delete --- src/bin/vip-config-envvar-delete.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/bin/vip-config-envvar-delete.js b/src/bin/vip-config-envvar-delete.js index 89219a463..6984b213a 100755 --- a/src/bin/vip-config-envvar-delete.js +++ b/src/bin/vip-config-envvar-delete.js @@ -3,6 +3,7 @@ import chalk from 'chalk'; import command from '../lib/cli/command'; +import { formatEnvironment } from '../lib/cli/format'; import { appQuery, deleteEnvVar, validateNameWithMessage } from '../lib/envvar/api'; import { cancel, confirm, promptForValue } from '../lib/envvar/input'; import { debug, getEnvContext } from '../lib/envvar/logging'; @@ -37,6 +38,24 @@ export async function deleteEnvVarCommand( arg, opt ) { variable_name: name, }; + const envName = opt.env.type; + const appName = opt.app.name; + + if ( ! opt.skipConfirmation && envName === 'production' ) { + const yes = await confirm( + `Are you sure you want to delete the environment variable ${ name } on ${ formatEnvironment( + envName + ) } for site ${ appName }?` + ); + + if ( ! yes ) { + trackEvent( 'wpcli_confirm_cancel', trackingParams ).catch( () => {} ); + + console.log( 'Command cancelled' ); + process.exit(); + } + } + debug( `Request: Delete environment variable ${ JSON.stringify( name ) } for ${ getEnvContext( opt.app,