mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 17:06:16 -04: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
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)
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue