From 0609fe82fa4e2bb2c8c9aec4412c8f3e45d7b721 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 26 Sep 2024 12:17:58 +0300 Subject: [PATCH] feat(dashmate)!: confirm a node reset (#2160) --- packages/dashmate/src/commands/reset.js | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/packages/dashmate/src/commands/reset.js b/packages/dashmate/src/commands/reset.js index 99b640cdfc..8ce7bd65c8 100644 --- a/packages/dashmate/src/commands/reset.js +++ b/packages/dashmate/src/commands/reset.js @@ -38,6 +38,49 @@ export default class ResetCommand extends ConfigBaseCommand { ) { const tasks = new Listr( [ + { + enabled: (ctx) => !ctx.isForce, + task: async (ctx, task) => { + let message; + if (ctx.isHardReset) { + if (ctx.keepData) { + message = 'Are you sure you want to reset your node configuration? Data will be' + + ' kept.'; + if (ctx.isPlatformOnlyReset) { + message = 'Are you sure you want to reset platform related configuration? Data' + + ' will be kept'; + } + } else { + message = 'Are you sure you want to reset your node data and configuration?'; + if (ctx.isPlatformOnlyReset) { + message = 'Are you sure you want to reset platform related data and configuration?'; + } + } + } else if (ctx.keepData) { + message = 'Are you sure you want to reset docker containers?'; + if (ctx.isPlatformOnlyReset) { + message = 'Are you sure you want to reset platform related docker containers?'; + } + } else { + message = 'Are you sure you want to reset your node data?'; + if (ctx.isPlatformOnlyReset) { + message = 'Are you sure you want to reset platform related data?'; + } + } + + const agreement = await task.prompt({ + type: 'toggle', + name: 'confirm', + message, + enabled: 'Yes', + disabled: 'No', + }); + + if (!agreement) { + throw new Error('Reset operation was declined'); + } + }, + }, { title: `Reset ${config.getName()} node`, task: () => resetNodeTask(config),