Skip to content

Commit

Permalink
feat(dashmate)!: confirm a node reset (#2160)
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov authored Sep 26, 2024
1 parent 5aab08d commit 0609fe8
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions packages/dashmate/src/commands/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 0609fe8

Please sign in to comment.