From 1eee970ebb873046c4cecb2a5d9de48127b558e3 Mon Sep 17 00:00:00 2001 From: Fokke Zandbergen Date: Thu, 16 Apr 2015 11:30:53 +0200 Subject: [PATCH] Allow NodeBB version to be set via config to package.json version can be incremented when needed. --- app.js | 21 +++++++++++---------- src/controllers/admin.js | 4 ++-- src/controllers/api.js | 5 ++--- src/meta/configs.js | 4 ++-- src/plugins/load.js | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app.js b/app.js index 1299cfdf4a..66f16da88c 100644 --- a/app.js +++ b/app.js @@ -54,14 +54,6 @@ if(os.platform() === 'linux') { }); } -if (!process.send) { - // If run using `node app`, log GNU copyright info along with server info - winston.info('NodeBB v' + pkg.version + ' Copyright (C) 2013-2014 NodeBB Inc.'); - winston.info('This program comes with ABSOLUTELY NO WARRANTY.'); - winston.info('This is free software, and you are welcome to redistribute it under certain conditions.'); - winston.info(''); -} - // Alternate configuration file support var configFile = path.join(__dirname, '/config.json'), configExists; @@ -89,7 +81,8 @@ function loadConfig() { nconf.defaults({ base_dir: __dirname, themes_path: path.join(__dirname, 'node_modules'), - views_dir: path.join(__dirname, 'public/templates') + views_dir: path.join(__dirname, 'public/templates'), + version: pkg.version }); if (!nconf.get('isCluster')) { @@ -101,6 +94,14 @@ function loadConfig() { nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path'))); nconf.set('core_templates_path', path.join(__dirname, 'src/views')); nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-vanilla/templates')); + + if (!process.send) { + // If run using `node app`, log GNU copyright info along with server info + winston.info('NodeBB v' + nconf.get('version') + ' Copyright (C) 2013-2014 NodeBB Inc.'); + winston.info('This program comes with ABSOLUTELY NO WARRANTY.'); + winston.info('This is free software, and you are welcome to redistribute it under certain conditions.'); + winston.info(''); + } } function start() { @@ -120,7 +121,7 @@ function start() { if (nconf.get('isPrimary') === 'true') { winston.info('Time: %s', (new Date()).toString()); - winston.info('Initializing NodeBB v%s', pkg.version); + winston.info('Initializing NodeBB v%s', nconf.get('version')); winston.verbose('* using configuration stored in: %s', configFile); var host = nconf.get(nconf.get('database') + ':host'), diff --git a/src/controllers/admin.js b/src/controllers/admin.js index 8b1e3f7d35..26f7b148d3 100644 --- a/src/controllers/admin.js +++ b/src/controllers/admin.js @@ -3,6 +3,7 @@ var async = require('async'), fs = require('fs'), path = require('path'), + nconf = require('nconf'), user = require('../user'), categories = require('../categories'), @@ -16,7 +17,6 @@ var async = require('async'), plugins = require('../plugins'), widgets = require('../widgets'), groups = require('../groups'), - pkg = require('../../package.json'), validator = require('validator'); @@ -63,7 +63,7 @@ adminController.home = function(req, res, next) { return next(err); } res.render('admin/general/dashboard', { - version: pkg.version, + version: nconf.get('version'), notices: results.notices, stats: results.stats }); diff --git a/src/controllers/api.js b/src/controllers/api.js index bf00491099..c531f6d87b 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -1,7 +1,6 @@ "use strict"; -var pkg = require('./../../package.json'), - meta = require('./../meta'), +var meta = require('./../meta'), user = require('./../user'), plugins = require('./../plugins'), widgets = require('../widgets'), @@ -26,7 +25,7 @@ apiController.getConfig = function(req, res, next) { config.relative_path = nconf.get('relative_path'); config.socketioTransports = nconf.get('socket.io:transports') || ['polling', 'websocket']; config.websocketAddress = nconf.get('socket.io:address') || ''; - config.version = pkg.version; + config.version = nconf.get('version'); config.siteTitle = validator.escape(meta.config.title || meta.config.browserTitle || 'NodeBB'); config.showSiteTitle = parseInt(meta.config.showSiteTitle, 10) === 1; config.postDelay = meta.config.postDelay; diff --git a/src/meta/configs.js b/src/meta/configs.js index e6d97f211b..65ffb45b11 100644 --- a/src/meta/configs.js +++ b/src/meta/configs.js @@ -4,7 +4,7 @@ var winston = require('winston'), db = require('../database'), pubsub = require('../pubsub'), - pkg = require('../../package.json'); + nconf = require('nconf'); module.exports = function(Meta) { @@ -28,7 +28,7 @@ module.exports = function(Meta) { Meta.configs.list = function (callback) { db.getObject('config', function (err, config) { config = config || {}; - config.version = pkg.version; + config.version = nconf.get('version'); callback(err, config); }); }; diff --git a/src/plugins/load.js b/src/plugins/load.js index 0637427a12..619e2a2131 100644 --- a/src/plugins/load.js +++ b/src/plugins/load.js @@ -5,7 +5,7 @@ var fs = require('fs'), semver = require('semver'), async = require('async'), winston = require('winston'), - pkg = require('../../package.json'), + nconf = require('nconf'), utils = require('../../public/src/utils'); @@ -62,7 +62,7 @@ module.exports = function(Plugins) { } if (pluginData.nbbpm && pluginData.nbbpm.compatibility && semver.validRange(pluginData.nbbpm.compatibility)) { - if (!semver.gtr(pkg.version, pluginData.nbbpm.compatibility)) { + if (!semver.gtr(nconf.get('version'), pluginData.nbbpm.compatibility)) { display(); } } else {