mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
admin: Add etherpad update check
This update check notifies admin on startup (via console) or in /admin UI that they need to update Etherpad.
This commit is contained in:
parent
8deac52c84
commit
cffd04446e
4 changed files with 53 additions and 2 deletions
|
@ -4,6 +4,7 @@ var installer = require('ep_etherpad-lite/static/js/pluginfw/installer');
|
||||||
var plugins = require('ep_etherpad-lite/static/js/pluginfw/plugins');
|
var plugins = require('ep_etherpad-lite/static/js/pluginfw/plugins');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var semver = require('semver');
|
var semver = require('semver');
|
||||||
|
const UpdateCheck = require('ep_etherpad-lite/node/utils/UpdateCheck');
|
||||||
|
|
||||||
exports.expressCreateServer = function(hook_name, args, cb) {
|
exports.expressCreateServer = function(hook_name, args, cb) {
|
||||||
args.app.get('/admin/plugins', function(req, res) {
|
args.app.get('/admin/plugins', function(req, res) {
|
||||||
|
@ -23,7 +24,8 @@ exports.expressCreateServer = function(hook_name, args, cb) {
|
||||||
|
|
||||||
res.send(eejs.require("ep_etherpad-lite/templates/admin/plugins-info.html", {
|
res.send(eejs.require("ep_etherpad-lite/templates/admin/plugins-info.html", {
|
||||||
gitCommit: gitCommit,
|
gitCommit: gitCommit,
|
||||||
epVersion: epVersion
|
epVersion: epVersion,
|
||||||
|
latestVersion: UpdateCheck.getLatestVersion()
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var log4js = require('log4js')
|
const log4js = require('log4js')
|
||||||
, NodeVersion = require('./utils/NodeVersion')
|
, NodeVersion = require('./utils/NodeVersion')
|
||||||
|
, UpdateCheck = require('./utils/UpdateCheck')
|
||||||
;
|
;
|
||||||
|
|
||||||
log4js.replaceConsole();
|
log4js.replaceConsole();
|
||||||
|
@ -38,6 +39,9 @@ NodeVersion.enforceMinNodeVersion('10.13.0');
|
||||||
*/
|
*/
|
||||||
NodeVersion.checkDeprecationStatus('10.13.0', '1.8.3');
|
NodeVersion.checkDeprecationStatus('10.13.0', '1.8.3');
|
||||||
|
|
||||||
|
// Check if Etherpad version is up-to-date
|
||||||
|
UpdateCheck.check();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* start up stats counting system
|
* start up stats counting system
|
||||||
*/
|
*/
|
||||||
|
|
44
src/node/utils/UpdateCheck.js
Normal file
44
src/node/utils/UpdateCheck.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
const semver = require('semver');
|
||||||
|
const settings = require('./Settings');
|
||||||
|
const request = require('request');
|
||||||
|
|
||||||
|
let infos;
|
||||||
|
|
||||||
|
function loadEtherpadInformations() {
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
request('https://static.etherpad.org/info.json', function (er, response, body) {
|
||||||
|
if (er) return reject(er);
|
||||||
|
|
||||||
|
try {
|
||||||
|
infos = JSON.parse(body);
|
||||||
|
return resolve(infos);
|
||||||
|
} catch (err) {
|
||||||
|
return reject(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.getLatestVersion = function() {
|
||||||
|
exports.needsUpdate();
|
||||||
|
return infos.latestVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.needsUpdate = function(cb) {
|
||||||
|
loadEtherpadInformations().then(function(info) {
|
||||||
|
if (semver.gt(info.latestVersion, settings.getEpVersion())) {
|
||||||
|
if (cb) return cb(true);
|
||||||
|
}
|
||||||
|
}).catch(function (err) {
|
||||||
|
console.error('Can not perform Etherpad update check: ' + err)
|
||||||
|
if (cb) return cb(false);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.check = function() {
|
||||||
|
exports.needsUpdate(function (needsUpdate) {
|
||||||
|
if (needsUpdate) {
|
||||||
|
console.warn('Update available: Download the actual version ' + infos.latestVersion)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
|
@ -24,6 +24,7 @@
|
||||||
<div class="innerwrapper">
|
<div class="innerwrapper">
|
||||||
<h2>Etherpad version</h2>
|
<h2>Etherpad version</h2>
|
||||||
<p>Version number: <%= epVersion %></p>
|
<p>Version number: <%= epVersion %></p>
|
||||||
|
<p>Latest available version: <%= latestVersion %></p>
|
||||||
<p>Git sha: <a href='https://github.com/ether/etherpad-lite/commit/<%= gitCommit %>'><%= gitCommit %></a></p>
|
<p>Git sha: <a href='https://github.com/ether/etherpad-lite/commit/<%= gitCommit %>'><%= gitCommit %></a></p>
|
||||||
|
|
||||||
<h2>Installed plugins</h2>
|
<h2>Installed plugins</h2>
|
||||||
|
|
Loading…
Reference in a new issue