mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
🎨 send LTS parameter if requesting the update check service (#7954)
no issue - the update check service now supports a LTS option - sending lts=false will force the update check service to search for the latest non LTS release - as 1.0.0 is still in alpha, there is no latest release available - that's why the update check service returns an error saying, there is no latest release available - this error get's logged to shell right now - as soon as we release 1.0.0, the error auto disappears No behaviour change in any previous alpha version or any LTS release as they don't send the LTS option.
This commit is contained in:
parent
867cce09e3
commit
c870710fcb
1 changed files with 16 additions and 12 deletions
|
@ -39,16 +39,16 @@ var crypto = require('crypto'),
|
||||||
checkEndpoint = 'updates.ghost.org';
|
checkEndpoint = 'updates.ghost.org';
|
||||||
|
|
||||||
function updateCheckError(err) {
|
function updateCheckError(err) {
|
||||||
|
err = errors.utils.deserialize(err);
|
||||||
|
|
||||||
api.settings.edit(
|
api.settings.edit(
|
||||||
{settings: [{key: 'nextUpdateCheck', value: Math.round(Date.now() / 1000 + 24 * 3600)}]},
|
{settings: [{key: 'nextUpdateCheck', value: Math.round(Date.now() / 1000 + 24 * 3600)}]},
|
||||||
internal
|
internal
|
||||||
);
|
);
|
||||||
|
|
||||||
logging.error(new errors.GhostError({
|
err.context = i18n.t('errors.update-check.checkingForUpdatesFailed.error');
|
||||||
err: err,
|
err.help = i18n.t('errors.update-check.checkingForUpdatesFailed.help', {url: 'http://support.ghost.org'});
|
||||||
context: i18n.t('errors.update-check.checkingForUpdatesFailed.error'),
|
logging.error(err);
|
||||||
help: i18n.t('errors.update-check.checkingForUpdatesFailed.help', {url: 'http://support.ghost.org'})
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,6 +126,7 @@ function updateCheckData() {
|
||||||
data.user_count = users && users.users && users.users.length ? users.users.length : 0;
|
data.user_count = users && users.users && users.users.length ? users.users.length : 0;
|
||||||
data.blog_created_at = users && users.users && users.users[0] && users.users[0].created_at ? moment(users.users[0].created_at).unix() : '';
|
data.blog_created_at = users && users.users && users.users[0] && users.users[0].created_at ? moment(users.users[0].created_at).unix() : '';
|
||||||
data.npm_version = npm.trim();
|
data.npm_version = npm.trim();
|
||||||
|
data.lts = false;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}).catch(updateCheckError);
|
}).catch(updateCheckError);
|
||||||
|
@ -155,6 +156,11 @@ function updateCheckRequest() {
|
||||||
res.on('end', function onEnd() {
|
res.on('end', function onEnd() {
|
||||||
try {
|
try {
|
||||||
resData = JSON.parse(resData);
|
resData = JSON.parse(resData);
|
||||||
|
|
||||||
|
if (this.statusCode >= 400) {
|
||||||
|
return reject(resData);
|
||||||
|
}
|
||||||
|
|
||||||
resolve(resData);
|
resolve(resData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(i18n.t('errors.update-check.unableToDecodeUpdateResponse.error'));
|
reject(i18n.t('errors.update-check.unableToDecodeUpdateResponse.error'));
|
||||||
|
@ -202,6 +208,11 @@ function updateCheckResponse(response) {
|
||||||
api.settings.edit({settings: [{key: 'displayUpdateNotification', value: response.version}]}, internal)
|
api.settings.edit({settings: [{key: 'displayUpdateNotification', value: response.version}]}, internal)
|
||||||
]).then(function () {
|
]).then(function () {
|
||||||
var messages = response.messages || [];
|
var messages = response.messages || [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* by default the update check service returns messages: []
|
||||||
|
* but the latest release version get's stored anyway, because we adding the `displayUpdateNotification` ^
|
||||||
|
*/
|
||||||
return Promise.map(messages, createCustomNotification);
|
return Promise.map(messages, createCustomNotification);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -230,13 +241,6 @@ function showUpdateNotification() {
|
||||||
return api.settings.read(_.extend({key: 'displayUpdateNotification'}, internal)).then(function then(response) {
|
return api.settings.read(_.extend({key: 'displayUpdateNotification'}, internal)).then(function then(response) {
|
||||||
var display = response.settings[0];
|
var display = response.settings[0];
|
||||||
|
|
||||||
// Version 0.4 used boolean to indicate the need for an update. This special case is
|
|
||||||
// translated to the version string.
|
|
||||||
// TODO: remove in future version.
|
|
||||||
if (display.value === 'false' || display.value === 'true' || display.value === '1' || display.value === '0') {
|
|
||||||
display.value = '0.4.0';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (display && display.value && currentVersion && semver.gt(display.value, currentVersion)) {
|
if (display && display.value && currentVersion && semver.gt(display.value, currentVersion)) {
|
||||||
return display.value;
|
return display.value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue