Skip to content

Commit

Permalink
feat(backup): add backup warning to major upgrade prompt
Browse files Browse the repository at this point in the history
- one more reminder to backup!
  • Loading branch information
ErisDS committed May 20, 2022
1 parent 1c689bb commit 5b83003
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/tasks/major-update/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ module.exports = async function ui(ctx) {
}

const autoUpgradeDefault = !results.error.all.length;
const answer = await ctx.ui.confirm(`Are you sure you want to proceed with migrating to Ghost ${ctx.version}?`, autoUpgradeDefault, {prefix: chalk.cyan('?')});
ctx.ui.log(`⚠ Have you run \`ghost backup\`?`, 'yellow');
const answer = await ctx.ui.confirm(`Are you sure you want to migrate to Ghost ${ctx.version}?`, autoUpgradeDefault, {prefix: chalk.cyan('?')});
if (!answer) {
throw new CliError({
message: `Update aborted. Your blog is still on ${ctx.activeVersion}.`,
Expand Down
10 changes: 5 additions & 5 deletions test/unit/tasks/major-update/ui-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const configStub = require('../../../utils/config-stub');
const stripAnsi = require('strip-ansi');

describe('Unit: Tasks > Major Update > UI', function () {
let ui, dataMock, ctx;
let ui; let dataMock; let ctx;

beforeEach(function () {
ctx = {
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('Unit: Tasks > Major Update > UI', function () {
});

await ui(ctx);
expect(ctx.ui.log.callCount).to.eql(5);
expect(ctx.ui.log.callCount).to.eql(6);
expect(ctx.ui.confirm.calledOnce).to.be.true;
expect(ctx.ui.confirm.args[0][1], 'confirm prompt default should be true').to.be.true;
});
Expand All @@ -74,7 +74,7 @@ describe('Unit: Tasks > Major Update > UI', function () {
});

await ui(ctx);
expect(ctx.ui.log.callCount).to.eql(7);
expect(ctx.ui.log.callCount).to.eql(8);
expect(ctx.ui.confirm.calledTwice).to.be.true;
expect(ctx.ui.confirm.args[1][1], 'confirm prompt default should be false').to.be.true;

Expand Down Expand Up @@ -111,7 +111,7 @@ describe('Unit: Tasks > Major Update > UI', function () {
});

await ui(ctx);
expect(ctx.ui.log.callCount).to.eql(8);
expect(ctx.ui.log.callCount).to.eql(9);
expect(ctx.ui.confirm.calledTwice).to.be.true;
expect(ctx.ui.confirm.args[1][1], 'confirm prompt default should be false').to.be.false;

Expand Down Expand Up @@ -154,7 +154,7 @@ describe('Unit: Tasks > Major Update > UI', function () {
expect(err.message).to.match(/Update aborted/);
expect(err.logMessageOnly).to.be.true;

expect(ctx.ui.log.callCount).to.eql(9);
expect(ctx.ui.log.callCount).to.eql(10);
expect(ctx.ui.confirm.calledTwice).to.be.true;

const output = stripAnsi(ctx.ui.log.args.join(' '));
Expand Down

0 comments on commit 5b83003

Please sign in to comment.