read version information from... version.json

10.7.0-preview
Kyle K 2019-08-11 07:23:13 +00:00
parent 7189363f98
commit 3fb1d96370
3 changed files with 24 additions and 22 deletions

View File

@ -476,7 +476,10 @@ function getHash(cb) {
function writeChangesetId() { function writeChangesetId() {
var versionJson = new stream.Readable; var versionJson = new stream.Readable;
versionJson.push(JSON.stringify({ gitChangesetId: gitChangeSetId }, undefined, 2)); versionJson.push(JSON.stringify({
gitChangesetId: gitChangeSetId,
version: pkg.version
}, undefined, 2));
versionJson.push(null); versionJson.push(null);
return versionJson return versionJson
.pipe(source('version.json')) .pipe(source('version.json'))

View File

@ -5,7 +5,7 @@
function configuration_backup(callback) { function configuration_backup(callback) {
var activeProfile = null; var activeProfile = null;
var version = getManifestVersion(); var version = CONFIGURATOR.version;
if (version.indexOf(".") === -1) { if (version.indexOf(".") === -1) {
version = version + ".0.0"; version = version + ".0.0";

View File

@ -5,8 +5,20 @@ var analytics = undefined;
$(document).ready(function () { $(document).ready(function () {
$.getJSON('version.json', function(data) { $.getJSON('version.json', function(data) {
CONFIGURATOR.version = data.version;
CONFIGURATOR.gitChangesetId = data.gitChangesetId; CONFIGURATOR.gitChangesetId = data.gitChangesetId;
// Version in the ChromeApp's manifest takes precedence.
if(chrome.runtime && chrome.runtime.getManifest) {
var manifest = chrome.runtime.getManifest();
CONFIGURATOR.version = manifest.version;
// manifest.json for ChromeApp can't have a version
// with a prerelease tag eg 10.0.0-RC4
// Work around is to specify the prerelease version in version_name
if (manifest.version_name) {
CONFIGURATOR.version = manifest.version_name;
}
}
i18n.init(function() { i18n.init(function() {
startProcess(); startProcess();
initializeSerialBackend(); initializeSerialBackend();
@ -50,7 +62,7 @@ function setupAnalytics(result) {
var debugMode = typeof process === "object" && process.versions['nw-flavor'] === 'sdk'; var debugMode = typeof process === "object" && process.versions['nw-flavor'] === 'sdk';
analytics = new Analytics('UA-123002063-1', userId, 'Betaflight Configurator', getManifestVersion(), CONFIGURATOR.gitChangesetId, GUI.operating_system, checkForDebugVersions, optOut, debugMode, getBuildType()); analytics = new Analytics('UA-123002063-1', userId, 'Betaflight Configurator', CONFIGURATOR.version, CONFIGURATOR.gitChangesetId, GUI.operating_system, checkForDebugVersions, optOut, debugMode, getBuildType());
function logException(exception) { function logException(exception) {
analytics.sendException(exception.stack); analytics.sendException(exception.stack);
@ -79,7 +91,7 @@ function setupAnalytics(result) {
// and open it in external browser // and open it in external browser
GUI.nwGui.Shell.openExternal(url); GUI.nwGui.Shell.openExternal(url);
}); });
} else { } else if (!GUI.isOther()) {
// Looks like we're in Chrome - but the event does not actually get fired // Looks like we're in Chrome - but the event does not actually get fired
chrome.runtime.onSuspend.addListener(sendCloseEvent); chrome.runtime.onSuspend.addListener(sendCloseEvent);
} }
@ -96,9 +108,9 @@ function startProcess() {
// alternative - window.navigator.appVersion.match(/Chrome\/([0-9.]*)/)[1]; // alternative - window.navigator.appVersion.match(/Chrome\/([0-9.]*)/)[1];
GUI.log(i18n.getMessage('infoVersions',{operatingSystem: GUI.operating_system, GUI.log(i18n.getMessage('infoVersions',{operatingSystem: GUI.operating_system,
chromeVersion: window.navigator.appVersion.replace(/.*Chrome\/([0-9.]*).*/, "$1"), chromeVersion: window.navigator.appVersion.replace(/.*Chrome\/([0-9.]*).*/, "$1"),
configuratorVersion: getManifestVersion()})); configuratorVersion: CONFIGURATOR.version }));
$('#logo .version').text(getManifestVersion()); $('#logo .version').text(CONFIGURATOR.version);
updateStatusBarVersion(); updateStatusBarVersion();
updateTopBarVersion(); updateTopBarVersion();
@ -117,7 +129,7 @@ function startProcess() {
break; break;
} }
if (GUI.operating_system !== 'ChromeOS') { if (!GUI.isOther() && GUI.operating_system !== 'ChromeOS') {
checkForConfiguratorUpdates(); checkForConfiguratorUpdates();
} }
@ -557,7 +569,7 @@ function notifyOutdatedVersion(releaseData) {
} }
}); });
if (versions.length > 0 && semver.lt(getManifestVersion(), versions[0].tag_name)) { if (versions.length > 0 && semver.lt(CONFIGURATOR.version, versions[0].tag_name)) {
GUI.log(i18n.getMessage('configuratorUpdateNotice', [versions[0].tag_name, versions[0].html_url])); GUI.log(i18n.getMessage('configuratorUpdateNotice', [versions[0].tag_name, versions[0].html_url]));
var dialog = $('.dialogConfiguratorUpdate')[0]; var dialog = $('.dialogConfiguratorUpdate')[0];
@ -735,7 +747,7 @@ function getFirmwareVersion(firmwareVersion, firmwareId) {
} }
function getConfiguratorVersion() { function getConfiguratorVersion() {
return i18n.getMessage('versionLabelConfigurator') + ': ' + getManifestVersion(); return i18n.getMessage('versionLabelConfigurator') + ': ' + CONFIGURATOR.version;
} }
function updateTopBarVersion(firmwareVersion, firmwareId, hardwareId) { function updateTopBarVersion(firmwareVersion, firmwareId, hardwareId) {
@ -769,19 +781,6 @@ function updateStatusBarVersion(firmwareVersion, firmwareId, hardwareId) {
$('#status-bar .version').text(versionText); $('#status-bar .version').text(versionText);
} }
function getManifestVersion(manifest) {
if (!manifest) {
manifest = chrome.runtime.getManifest();
}
var version = manifest.version_name;
if (!version) {
version = manifest.version;
}
return version;
}
function showErrorDialog(message) { function showErrorDialog(message) {
var dialog = $('.dialogError')[0]; var dialog = $('.dialogError')[0];