feat: check for updates

This commit is contained in:
Nicolas Giard
2019-01-13 15:37:45 -05:00
parent 959f2ebde1
commit 63c044a09b
13 changed files with 95 additions and 15 deletions

View File

@@ -52,9 +52,12 @@ module.exports = {
appconfig.port = process.env.PORT || 80
}
const packageInfo = require(path.join(WIKI.ROOTPATH, 'package.json'))
WIKI.config = appconfig
WIKI.data = appdata
WIKI.version = require(path.join(WIKI.ROOTPATH, 'package.json')).version
WIKI.version = packageInfo.version
WIKI.releaseDate = packageInfo.releaseDate
},
/**

View File

@@ -25,12 +25,11 @@ module.exports = {
red.on('message', (channel, msg) => {
WIKI.events.emit(channel, msg)
})
red.subscribe('localization', (err, count) => {
red.subscribe('localization', 'updates', (err, count) => {
if (err) {
WIKI.logger.error(err)
process.exit(1)
}
WIKI.logger.info('Redis Subscriber connection: [ OK ]')
})
return red
}

View File

@@ -5,6 +5,25 @@ const Promise = require('bluebird')
/* global WIKI */
module.exports = {
updates: {
channel: 'BETA',
version: WIKI.version,
releaseDate: WIKI.releaseDate,
minimumVersionRequired: '2.0.0-beta.0',
minimumNodeRequired: '10.12.0'
},
init() {
// Listen for updates events
WIKI.events.on('updates', (infoRaw) => {
try {
this.updates = JSON.parse(infoRaw)
} catch (err) {
WIKI.logger.warn('Failed to parse updates info.')
}
})
return this
},
/**
* Upgrade from WIKI.js 1.x - MongoDB database
*