Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashmate)!: confirm a node reset #2160

Open
wants to merge 1 commit into
base: v1.4-dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions packages/dashmate/src/commands/reset.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import chalk from 'chalk';

Check failure on line 1 in packages/dashmate/src/commands/reset.js

View workflow job for this annotation

GitHub Actions / JS packages (dashmate) / Linting

'chalk' is defined but never used
import { Listr } from 'listr2';

import { Flags } from '@oclif/core';
import process from 'process';

Check failure on line 5 in packages/dashmate/src/commands/reset.js

View workflow job for this annotation

GitHub Actions / JS packages (dashmate) / Linting

'process' is defined but never used
import ConfigBaseCommand from '../oclif/command/ConfigBaseCommand.js';
import MuteOneLineError from '../oclif/errors/MuteOneLineError.js';

Expand Down Expand Up @@ -38,6 +40,49 @@
) {
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 you 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 you 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 you 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('Archive creation was declined');
}
},
},
{
title: `Reset ${config.getName()} node`,
task: () => resetNodeTask(config),
Expand Down
Loading