From 4f7810090a3bc06fd7cbc549a17fac0aa99e59ec Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 15 Apr 2014 11:55:54 -0400 Subject: [PATCH] first pass #1384 --- install/databases.js | 1 - package.json | 29 ++++++++++------------------- src/install.js | 40 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/install/databases.js b/install/databases.js index 17a0092d94..b0ca45e3e3 100644 --- a/install/databases.js +++ b/install/databases.js @@ -7,7 +7,6 @@ var async = require('async'), questions = {}; -// maybe this should go into install/database.js function success(err, config, callback) { if (!config) { return callback(new Error('aborted')); diff --git a/package.json b/package.json index e8202d8648..b06ab1c8ad 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,10 @@ "test": "mocha ./tests/database.js -t 1000" }, "dependencies": { - "socket.io": "~0.9.16", "express": "3.2.0", "express-namespace": "~0.1.1", + "socket.io": "~0.9.16", + "socket.io-wildcard": "~0.1.1", "passport": "~0.2.0", "passport-local": "0.1.6", "marked": "0.2.8", @@ -26,7 +27,6 @@ "gravatar": "1.0.6", "nconf": "~0.6.7", "sitemap": "~0.7.1", - "reds": "~0.2.4", "winston": "~0.7.2", "rss": "~0.2.0", "prompt": "~0.2.11", @@ -36,29 +36,20 @@ "semver": "~2.2.1", "string": "~1.7.0", "xregexp": "~2.0.0", - "socket.io-wildcard": "~0.1.1", "bcryptjs": "~0.7.10", + "less": "~1.6.3", + "daemon": "~1.1.0", + "underscore": "~1.6.0", + "mkdirp": "~0.3.5", + "rimraf": "~2.2.6", + "reds": "~0.2.4", + "npm": "^1.4.6", "nodebb-plugin-mentions": "~0.4.0", "nodebb-plugin-markdown": "~0.4.1", "nodebb-widget-essentials": "~0.0.21", "nodebb-theme-vanilla": "~0.0.19", "nodebb-theme-lavender": "~0.0.25", - "nodebb-plugin-soundpack-default": "~0.1.0", - "less": "~1.6.3", - "daemon": "~1.1.0", - "underscore": "~1.6.0", - "mkdirp": "~0.3.5", - "rimraf": "~2.2.6" - }, - "optionalDependencies": { - "redis": "0.8.3", - "hiredis": "~0.1.15", - "connect-redis": "1.4.5", - "mongodb": "~1.3.19", - "connect-mongo": "0.4.0", - "levelup": "^0.18.2", - "leveldown": "^0.10.2", - "connect-leveldb": "^0.1.5" + "nodebb-plugin-soundpack-default": "~0.1.0" }, "devDependencies": { "mocha": "~1.13.0" diff --git a/src/install.js b/src/install.js index 90f731eeb5..da0763c777 100644 --- a/src/install.js +++ b/src/install.js @@ -121,7 +121,7 @@ function checkCIFlag(next) { } function setupConfig(next) { - var configureDatabases = require('./../install/databases'); + var configureDatabases = require('../install/databases'); // prompt prepends "prompt: " to questions, let's clear that. prompt.start(); @@ -195,7 +195,43 @@ function completeConfigSetup(err, config, next) { return next(err); } - require('./database').init(next); + setupDatabase(server_conf, next); + }); +} + +function setupDatabase(server_conf, next) { + var npm = require('npm'), + packages = []; + + npm.load({ + loglevel: 'silly' + }, function(err) { + if (err) { + next(err); + } + + switch(server_conf.database) { + case 'redis': + packages = packages.concat(['redis', 'hiredis', 'connect-redis']); + break; + + case 'mongo': + packages = packages.concat(['mongodb', 'connect-mongo']); + break; + + case 'level': + packages = packages.concat(['levelup', 'leveldown', 'connect-level']); + break; + } + + console.log(packages); + npm.commands.install(packages, function(err) { + if (err) { + return next(err); + } + + require('./database').init(next); + }); }); }