Skip to content

Commit

Permalink
Merge pull request #15974 from strapi/enhancement/transfer-error-mess…
Browse files Browse the repository at this point in the history
…aging
  • Loading branch information
innerdvations committed Mar 8, 2023
2 parents 16e67e3 + 606a88e commit 49df2f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 7 additions & 5 deletions packages/core/strapi/bin/strapi.js
Expand Up @@ -313,7 +313,7 @@ program
},
]);
if (!answers.fromToken?.length) {
exitWith(0, 'No token entered, aborting transfer.');
exitWith(1, 'No token entered, aborting transfer.');
}
thisCommand.opts().fromToken = answers.fromToken;
}
Expand All @@ -336,13 +336,14 @@ program
},
]);
if (!answers.toToken?.length) {
exitWith(0, 'No token entered, aborting transfer.');
exitWith(1, 'No token entered, aborting transfer.');
}
thisCommand.opts().toToken = answers.toToken;
}

await confirmMessage(
'The transfer will delete all data in the remote database and media files. Are you sure you want to proceed?'
'The transfer will delete all data in the remote database and media files. Are you sure you want to proceed?',
{ failMessage: 'Transfer process aborted' }
)(thisCommand);
}
)
Expand Down Expand Up @@ -412,7 +413,7 @@ program
},
]);
if (!answers.key?.length) {
exitWith(0, 'No key entered, aborting import.');
exitWith(1, 'No key entered, aborting import.');
}
opts.key = answers.key;
}
Expand Down Expand Up @@ -450,7 +451,8 @@ program
.hook(
'preAction',
confirmMessage(
'The import will delete all data in your database and media files. Are you sure you want to proceed?'
'The import will delete all data in your database and media files. Are you sure you want to proceed?',
{ failMessage: 'Import process aborted' }
)
)
.action(getLocalScript('transfer/import'));
Expand Down
5 changes: 3 additions & 2 deletions packages/core/strapi/lib/commands/utils/commander.js
Expand Up @@ -96,8 +96,9 @@ const promptEncryptionKey = async (thisCommand) => {
*
* @param {string} message The message to confirm with user
* @param {object} options Additional options
* @param {string|undefined} options.failMessage The message to display when prompt is not confirmed
*/
const confirmMessage = (message) => {
const confirmMessage = (message, { failMessage } = {}) => {
return async (command) => {
// if we have a force option, assume yes
const opts = command.opts();
Expand All @@ -116,7 +117,7 @@ const confirmMessage = (message) => {
},
]);
if (!answers.confirm) {
exitWith(0);
exitWith(1, failMessage);
}
};
};
Expand Down

0 comments on commit 49df2f4

Please sign in to comment.