提交 6de05cbd 编写于 作者: J Jim LAURIE

Add debug option on strapi new

上级 080fd172
......@@ -266,8 +266,8 @@ module.exports = (scope, cb) => {
try {
require(path.join(`${scope.tmpPath}`, '/node_modules/', `${scope.client.connector}/lib/utils/connectivity.js`))(scope, cb.success, connectionValidation);
} catch(err) {
shell.rm('-r', scope.tmpPath);
console.log(err);
shell.rm('-r', scope.tmpPath);
cb.error();
}
});
......
'use strict';
// Core
const path = require('path');
// Public node modules
const inquirer = require('inquirer');
const rimraf = require('rimraf');
module.exports = (scope, success, error) => {
// eslint-disable-next-line import/no-unresolved
const knex = require('knex')({
let knex;
try {
// eslint-disable-next-line import/no-unresolved
knex = require('knex');
} catch (err) {
// eslint-disable-next-line import/no-unresolved
knex = require(path.resolve(scope.tmpPath, 'node_modules', 'knex'));
}
knex = knex({
client: scope.client.module,
connection: Object.assign({}, scope.database.settings, {
user: scope.database.settings.username
......@@ -48,10 +60,16 @@ module.exports = (scope, success, error) => {
})
.catch((err) => {
if (err.sql) {
console.log('⚠️ Server connection has failed! Make sure your database server is running.');
console.log('⚠️ Server connection has failed! Make sure your database server is running.');
} else {
console.log(`⚠️ Database connection has failed! Make sure your "${scope.database.settings.database}" database exist.`);
console.log(`⚠️ Database connection has failed! Make sure your "${scope.database.settings.database}" database exist.`);
}
if (scope.debug) {
console.log('🐛 Full error log:');
console.log(err);
}
error();
});
};
......@@ -29,7 +29,13 @@ module.exports = (scope, success, error) => {
Mongoose.connect(`mongodb${srv ? '+srv' : ''}://${scope.database.settings.host}${!srv ? `:${scope.database.settings.port}` : ''}/`, connectOptions, function (err) {
if (err) {
console.log('⚠️ Database connection has failed! Make sure your database is running.');
console.log('⚠️ Database connection has failed! Make sure your database is running.');
if (scope.debug) {
console.log('🐛 Full error log:');
console.log(err);
}
return error();
}
......
......@@ -42,7 +42,8 @@ module.exports = function (name, cliArguments) {
generatorType: 'new',
name,
strapiPackageJSON: packageJSON,
developerMode
developerMode,
debug: cliArguments.debug !== undefined
};
const dbArguments = ['dbclient', 'dbhost', 'dbport', 'dbname', 'dbusername', 'dbpassword'];
......
......@@ -53,6 +53,7 @@ program
program
.command('new')
.option('-d, --dev', 'Development mode')
.option('--debug', 'Display database connection error')
.option('--dbclient <dbclient>', 'Database client')
.option('--dbhost <dbhost>', 'Database host')
.option('--dbport <dbport>', 'Database port')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册