Fix strapi new without db args

Stop project creation if one of db argument is missing
Better detection for using db arguments
This commit is contained in:
Jim Laurie 2018-02-08 11:53:45 +01:00
parent b5e8b0997f
commit b1bcc13952
2 changed files with 10 additions and 2 deletions

View File

@ -29,6 +29,7 @@ const logger = require('strapi-utils').logger;
module.exports = (scope, cb) => {
// App info.
const hasDatabaseConfig = !!scope.database;
_.defaults(scope, {
name: scope.name === '.' || !scope.name ? scope.name : path.basename(process.cwd()),
author: process.env.USER || 'A Strapi developer',
@ -116,7 +117,6 @@ module.exports = (scope, cb) => {
}
])
.then(answers => {
if (hasDatabaseConfig) {
const databaseChoice = _.find(databaseChoices, ['value.database', scope.database.settings.client]);
answers.client = {

View File

@ -42,7 +42,15 @@ module.exports = function (name, cliArguments) {
developerMode
};
if (_.values(_.omit(cliArguments, ['dev'])).length) {
const dbArguments = ['dbclient', 'dbhost', 'dbport', 'dbname', 'dbusername', 'dbpassword'];
const matchingDbArguments = _.intersection(_.keys(cliArguments), dbArguments);
if (matchingDbArguments.length) {
if (matchingDbArguments.length !== dbArguments.length) {
logger.warn(`Some database arguments are missing. Required arguments list: ${dbArguments}`);
return process.exit(1);
}
scope.database = {
settings: {
client: cliArguments.dbclient,