Changed WebUI Version Check to SemVer. Also addes "Alpha" Channel (#692)

This commit is contained in:
b1rdhous3 2020-02-19 17:29:11 +01:00 committed by GitHub
parent 2db3f0c835
commit 065634076b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 660 additions and 42 deletions

View File

@ -735,6 +735,212 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
===========
semver-lite
===========
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========== ===========
tinkerforge tinkerforge
=========== ===========

View File

@ -22,17 +22,41 @@ $(document).ready( function(error) {
if(callback) if(callback)
{ {
var matches = 0;
for (var key in window.gitHubVersionList) for (var key in window.gitHubVersionList)
{ {
if(window.gitHubVersionList[key].name == null || (window.serverConfig.general.watchedVersionBranch == "Stable" && window.gitHubVersionList[key].prerelease == true)) if(window.gitHubVersionList[key].name == null || window.gitHubVersionList[key].tag_name.includes('rc') || (window.serverConfig.general.watchedVersionBranch == "Stable" && (window.gitHubVersionList[key].tag_name.includes('beta') || window.gitHubVersionList[key].tag_name.includes('alpha'))) || (window.serverConfig.general.watchedVersionBranch == "Beta" && window.gitHubVersionList[key].tag_name.includes('alpha')))
{ {
continue; continue;
} }
$('#versionlist').append('<div class="col-lg-6"><div class="panel panel-'+ (window.gitHubVersionList[key].prerelease == true ? "danger" : "default") +'"><div class="panel-heading"><i class="fa fa-television fa-fw"></i>Hyperion V'+window.gitHubVersionList[key].tag_name+'</div><div class="panel-body"><p><span style="font-weight:bold;">'+$.i18n('update_label_type') + '</span> ' + (window.gitHubVersionList[key].prerelease == true ? "Beta" : "Stable") + '</p><p><span style="font-weight:bold;">'+$.i18n('update_label_description')+'</span> '+window.gitHubVersionList[key].body+'</p><hr><a class="btn btn-primary" href="'+ window.gitHubVersionList[key].html_url +'" target="_blank"><i class="fa fa-list fa-fw"></i><span style="font-weight:bold;">'+$.i18n('update_button_changelog')+'</span></a><button type="button" class="btn btn-warning pull-right" ' + (window.gitHubVersionList[key].tag_name == window.currentVersion ? "disabled":"") + '><i class="fa fa-download fa-fw"></i>'+$.i18n('update_button_install')+'</button></div></div></div>'); var danger;
var type;
if (window.gitHubVersionList[key].tag_name.includes('beta'))
{
danger = 'warning';
type = 'Beta';
}
else if (window.gitHubVersionList[key].tag_name.includes('alpha'))
{
danger = 'danger';
type = 'Alpha';
}
else
{
danger = 'default';
type = 'Stable';
}
matches++;
$('#versionlist').append('<div class="col-lg-6"><div class="panel panel-'+ danger +'"><div class="panel-heading"><i class="fa fa-television fa-fw"></i>Hyperion V'+window.gitHubVersionList[key].tag_name+'</div><div class="panel-body"><p><span style="font-weight:bold;">'+$.i18n('update_label_type') + '</span> ' + type + '</p><p><span style="font-weight:bold;">'+$.i18n('update_label_description')+'</span> '+window.gitHubVersionList[key].body+'</p><hr><a class="btn btn-primary" href="'+ window.gitHubVersionList[key].html_url +'" target="_blank"><i class="fa fa-list fa-fw"></i><span style="font-weight:bold;">'+$.i18n('update_button_changelog')+'</span></a><button type="button" class="btn btn-warning pull-right" ' + (window.gitHubVersionList[key].tag_name == window.currentVersion ? "disabled":"") + '><i class="fa fa-download fa-fw"></i>'+$.i18n('update_button_install')+'</button></div></div></div>');
} }
$('#update_currver').append($.i18n('update_versreminder', currentVersion)); $('#update_currver').append($.i18n('update_versreminder', currentVersion));
if (matches == 0)
$('#versionlist').append($.i18n('update_no_updates_for_branch'));
} }
else else
{ {

View File

@ -55,7 +55,7 @@
"dashboard_infobox_label_instance": "Instanz:", "dashboard_infobox_label_instance": "Instanz:",
"dashboard_infobox_label_ports": "Ports (flat|proto):", "dashboard_infobox_label_ports": "Ports (flat|proto):",
"dashboard_infobox_label_watchedversionbranch": "Ausgewählter Versionszweig:", "dashboard_infobox_label_watchedversionbranch": "Ausgewählter Versionszweig:",
"dashboard_infobox_message_updatewarning": "Eine aktuellere Version von Hyperion ist verfügbar! (V$1)", "dashboard_infobox_message_updatewarning": "Eine aktuellere Version von Hyperion ist verfügbar! ($1)",
"dashboard_infobox_message_updatesuccess": "Du nutzt die aktuellste Version von Hyperion.", "dashboard_infobox_message_updatesuccess": "Du nutzt die aktuellste Version von Hyperion.",
"dashboard_infobox_label_statush": "Hyperion Status:", "dashboard_infobox_label_statush": "Hyperion Status:",
"dashboard_infobox_label_smartacc": "Schnellzugriff", "dashboard_infobox_label_smartacc": "Schnellzugriff",
@ -284,6 +284,7 @@
"update_label_type": "Art:", "update_label_type": "Art:",
"update_versreminder": "Deine Version: $1", "update_versreminder": "Deine Version: $1",
"update_error_getting_versions": "Wir hatten Probleme die verfügbaren Versionen zu ermitteln.", "update_error_getting_versions": "Wir hatten Probleme die verfügbaren Versionen zu ermitteln.",
"update_no_updates_for_branch": "Keine Updates für ausgewählten Channel verfügbar.",
"about_version": "Version", "about_version": "Version",
"about_build": "Build", "about_build": "Build",
"about_builddate": "Build Datum", "about_builddate": "Build Datum",

View File

@ -283,6 +283,7 @@
"update_label_type" : "Type:", "update_label_type" : "Type:",
"update_versreminder" : "Your version: $1", "update_versreminder" : "Your version: $1",
"update_error_getting_versions" : "We had trouble determining the latest available Version.", "update_error_getting_versions" : "We had trouble determining the latest available Version.",
"update_no_updates_for_branch": "No updates for selected version channel.",
"about_version" : "Version", "about_version" : "Version",
"about_build" : "Build", "about_build" : "Build",
"about_builddate" : "Build date", "about_builddate" : "Build date",

View File

@ -38,7 +38,7 @@
"dashboard_infobox_label_title": "Información", "dashboard_infobox_label_title": "Información",
"dashboard_infobox_label_currenthyp": "Tu versión de Hyperion:", "dashboard_infobox_label_currenthyp": "Tu versión de Hyperion:",
"dashboard_infobox_label_latesthyp": "Última versión de Hyperion:", "dashboard_infobox_label_latesthyp": "Última versión de Hyperion:",
"dashboard_infobox_message_updatewarning": "¡Una versión más nueva de Hyperion está disponible! (V$1)", "dashboard_infobox_message_updatewarning": "¡Una versión más nueva de Hyperion está disponible! ($1)",
"dashboard_infobox_message_updatesuccess": "Ejecutas la última versión de Hyperion.", "dashboard_infobox_message_updatesuccess": "Ejecutas la última versión de Hyperion.",
"dashboard_componentbox_label_title": "Estado de los componentes", "dashboard_componentbox_label_title": "Estado de los componentes",
"dashboard_componentbox_label_comp": "Estado de los componentes", "dashboard_componentbox_label_comp": "Estado de los componentes",

View File

@ -23,6 +23,9 @@
<!-- jQuery --> <!-- jQuery -->
<script src="js/lib/jquery.min.js"></script> <script src="js/lib/jquery.min.js"></script>
<!-- SemVer -->
<script src='js/lib/semver.js'></script>
<!-- Hyperion --> <!-- Hyperion -->
<script src="js/hyperion.js"></script> <script src="js/hyperion.js"></script>
<script src="js/ui_utils.js"></script> <script src="js/ui_utils.js"></script>

View File

@ -75,7 +75,7 @@ $(document).ready( function() {
// add more info // add more info
$('#dash_leddevice').html(window.serverConfig.device.type); $('#dash_leddevice').html(window.serverConfig.device.type);
$('#dash_currv').html(window.currentChannel+' '+window.currentVersion); $('#dash_currv').html(window.currentVersion);
$('#dash_instance').html(window.currentHyperionInstanceName); $('#dash_instance').html(window.currentHyperionInstanceName);
$('#dash_ports').html(window.serverConfig.flatbufServer.port+' | '+window.serverConfig.protoServer.port); $('#dash_ports').html(window.serverConfig.flatbufServer.port+' | '+window.serverConfig.protoServer.port);
$('#dash_watchedversionbranch').html(window.serverConfig.general.watchedVersionBranch); $('#dash_watchedversionbranch').html(window.serverConfig.general.watchedVersionBranch);
@ -83,16 +83,14 @@ $(document).ready( function() {
getReleases(function(callback){ getReleases(function(callback){
if(callback) if(callback)
{ {
var cleanLatestVersion = window.latestVersion.tag_name.replace(/\./g, ''); debugger;
var cleanCurrentVersion = window.currentVersion.replace(/\./g, ''); $('#dash_latev').html(window.latestVersion.tag_name);
$('#dash_latev').html(window.currentVersion); if (semverLite.gt(window.latestVersion.tag_name, window.currentVersion))
$('#dash_latev').html(window.latestVersion.tag_name + ' (' + (window.latestVersion.prerelease == true ? "Beta" : "Stable") + ')'); $('#versioninforesult').html('<div class="bs-callout bs-callout-warning" style="margin:0px"><a target="_blank" href="' + window.latestVersion.html_url + '">'+$.i18n('dashboard_infobox_message_updatewarning', window.latestVersion.tag_name) + '</a></div>');
if ( cleanCurrentVersion < cleanLatestVersion )
$('#versioninforesult').html('<div class="bs-callout bs-callout-warning" style="margin:0px">'+$.i18n('dashboard_infobox_message_updatewarning', window.latestVersion.tag_name) + ' (' + (window.latestVersion.prerelease == true ? "Beta" : "Stable") + ')</div>');
else else
$('#versioninforesult').html('<div class="bs-callout bs-callout-success" style="margin:0px">'+$.i18n('dashboard_infobox_message_updatesuccess')+'</div>'); $('#versioninforesult').html('<div class="bs-callout bs-callout-success" style="margin:0px">'+$.i18n('dashboard_infobox_message_updatesuccess')+'</div>');
} }
}); });

View File

@ -8,6 +8,8 @@ window.currentVersion = null;
window.latestVersion = null; window.latestVersion = null;
window.latestStableVersion = null; window.latestStableVersion = null;
window.latestBetaVersion = null; window.latestBetaVersion = null;
window.latestAlphaVersion = null;
window.latestRcVersion = null;
window.gitHubVersionList = null; window.gitHubVersionList = null;
window.serverInfo = {}; window.serverInfo = {};
window.serverSchema = {}; window.serverSchema = {};

View File

@ -0,0 +1,348 @@
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["semverLite"] = factory();
else
root["semverLite"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var SemverVersion = __webpack_require__(1);
var semver = {
version: '0.0.5',
SemverVersion: SemverVersion,
validate: function validate(version) {
return SemverVersion.validate(version);
},
compare: function compare(a, b, needCompareBuildVersion) {
return new SemverVersion(a).compare(new SemverVersion(b), needCompareBuildVersion);
},
format: function format(version) {
return new SemverVersion(version).format();
},
instance: function instance(version) {
return new SemverVersion(version);
},
compareMainVersion: function compareMainVersion(a, b) {
return new SemverVersion(a).compareMainVersion(new SemverVersion(b));
},
gt: function gt(a, b, needCompareBuildVersion) {
var result = this.compare(a, b, needCompareBuildVersion);
return result === 1;
},
gte: function gte(a, b, needCompareBuildVersion) {
var result = this.compare(a, b, needCompareBuildVersion);
return result === 1 || result === 0;
},
lt: function lt(a, b, needCompareBuildVersion) {
var result = this.compare(a, b, needCompareBuildVersion);
return result === -1;
},
lte: function lte(a, b, needCompareBuildVersion) {
var result = this.compare(a, b, needCompareBuildVersion);
return result === -1 || result === 0;
},
equal: function equal(a, b, needCompareBuildVersion) {
var result = this.compare(a, b, needCompareBuildVersion);
return result === 0;
},
equalMain: function equalMain(a, b) {
return new SemverVersion(a).mainVersion === new SemverVersion(b).mainVersion;
},
// 主版本转成数字类型方便比较
mainVersionToNumeric: function mainVersionToNumeric(version) {
var digit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
var semverVersion = new SemverVersion(version);
return semverVersion.mainVersionToNumeric(digit);
}
};
module.exports = semver;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var MAX_LENGTH = 256;
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
// 正则标识
// 数字,禁止纯数字补 0
var NUMERIC_IDENTIFIER = '0|[1-9]\\d*';
// 数字,字母,横线
var NUMERIC_LETTERS_IDENTIFIER = '[0-9A-Za-z-]*';
var BUILD_IDENTIFIER = '[0-9A-Za-z-]+';
// 数字和字母组合达到禁止纯数字补0的目的
var NON_NUMERIC_IDENTIFIER = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
var MAIN_VERSION_IDENTIFIER = '(' + NUMERIC_IDENTIFIER + ')\\.(' + NUMERIC_IDENTIFIER + ')\\.(' + NUMERIC_IDENTIFIER + ')';
// 先行版本号,由 ASCII 码的英数字和连接号 [0-9A-Za-z-] 组成,
// 且“禁止 MUST NOT ”留白。数字型的标识符号“禁止 MUST NOT ”在前方补零
var PRERELEASE_IDENTIFIER = '(?:' + NUMERIC_IDENTIFIER + '|' + NON_NUMERIC_IDENTIFIER + ')';
var PRERELEASE = '(?:\\-(' + PRERELEASE_IDENTIFIER + '(?:\\.' + PRERELEASE_IDENTIFIER + ')*))';
// 编译版本号
var BUILD = '(?:\\+(' + BUILD_IDENTIFIER + '(?:\\.' + BUILD_IDENTIFIER + ')*))';
var FULL_VERSION_IDENTIFIER = '^v?' + MAIN_VERSION_IDENTIFIER + PRERELEASE + '?' + BUILD + '?$';
// 根据正则标识实例化正则
var REGEX_MAIN_VERSION = new RegExp(MAIN_VERSION_IDENTIFIER);
var REGEX_FULL_VERSION = new RegExp(FULL_VERSION_IDENTIFIER);
var REGEX_NUMERIC = /^[0-9]+$/;
var SemverVersion = function () {
function SemverVersion(version) {
_classCallCheck(this, SemverVersion);
if (version instanceof SemverVersion) {
return version;
} else if (typeof version !== 'string') {
throw new TypeError('Invalid Version: ' + version);
}
if (version.length > MAX_LENGTH) {
throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
}
if (!(this instanceof SemverVersion)) {
return new SemverVersion(version);
}
var matches = version.trim().match(REGEX_FULL_VERSION);
this.rawVersion = version;
this.major = +matches[1];
this.minor = +matches[2];
this.patch = +matches[3];
this._isThrowVersionNumericError(this.major, 'major');
this._isThrowVersionNumericError(this.minor, 'minor');
this._isThrowVersionNumericError(this.patch, 'patch');
if (matches[4]) {
this.prereleaseArray = matches[4].split('.').map(function (id) {
if (REGEX_NUMERIC.test(id)) {
var num = +id;
if (num >= 0 && num < MAX_SAFE_INTEGER) {
return num;
}
}
return id;
});
} else {
this.prereleaseArray = [];
}
//this.build = matches[5] ? matches[5].split('.') : [];
this.prerelease = matches[4];
this.build = matches[5];
this.mainVersion = [this.major, this.minor, this.patch].join('.');
this.version = this.mainVersion + (this.prerelease ? '-' + this.prerelease : '') + (this.build ? '+' + this.build : '');
}
_createClass(SemverVersion, [{
key: '_isThrowVersionNumericError',
value: function _isThrowVersionNumericError(versionNumber, versionName) {
if (versionNumber > MAX_SAFE_INTEGER || this.major < 0) {
throw new TypeError('Invalid ' + versionName + ' version');
}
}
}, {
key: '_isNumeric',
value: function _isNumeric(numeric) {
return REGEX_NUMERIC.test(numeric);
}
}, {
key: '_padNumber',
value: function _padNumber(num, fill) {
var length = ('' + num).length;
return Array(fill > length ? fill - length + 1 || 0 : 0).join(0) + num;
}
}, {
key: 'mainVersionToNumeric',
value: function mainVersionToNumeric(digit) {
var numericStr = [this._padNumber(this.major, digit), this._padNumber(this.minor, digit), this._padNumber(this.patch, digit)].join('');
return parseInt(numericStr);
}
}, {
key: 'compare',
value: function compare(other) {
var needCompareBuildVersion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var otherSemver = other;
if (!(other instanceof SemverVersion)) {
otherSemver = new SemverVersion(other);
}
var result = this.compareMainVersion(otherSemver) || this.comparePreReleaseVersion(otherSemver);
if (!result && needCompareBuildVersion) {
return this.compareBuildVersion(otherSemver);
} else {
return result;
}
}
// 比较数字
}, {
key: 'compareNumeric',
value: function compareNumeric(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
}
}, {
key: 'compareIdentifiers',
value: function compareIdentifiers(a, b) {
var aIsNumeric = this._isNumeric(a);
var bIsNumeric = this._isNumeric(b);
if (aIsNumeric && bIsNumeric) {
a = +a;
b = +b;
}
// 字符比数字大
if (aIsNumeric && !bIsNumeric) {
return -1;
} else if (bIsNumeric && !aIsNumeric) {
return 1;
} else {
return this.compareNumeric(a, b);
}
}
}, {
key: 'compareMainVersion',
value: function compareMainVersion(otherSemver) {
return this.compareNumeric(this.major, otherSemver.major) || this.compareNumeric(this.minor, otherSemver.minor) || this.compareNumeric(this.patch, otherSemver.patch);
}
}, {
key: 'comparePreReleaseVersion',
value: function comparePreReleaseVersion(otherSemver) {
if (this.prereleaseArray.length && !otherSemver.prereleaseArray.length) {
return -1;
} else if (!this.prereleaseArray.length && otherSemver.prereleaseArray.length) {
return 1;
} else if (!this.prereleaseArray.length && !otherSemver.prereleaseArray.length) {
return 0;
}
var i = 0;
do {
var a = this.prereleaseArray[i];
var b = otherSemver.prereleaseArray[i];
if (a === undefined && b === undefined) {
return 0;
} else if (b === undefined) {
return 1;
} else if (a === undefined) {
return -1;
} else if (a === b) {
continue;
} else {
return this.compareIdentifiers(a, b);
}
} while (++i);
}
}, {
key: 'compareBuildVersion',
value: function compareBuildVersion(otherSemver) {
if (this.build && !otherSemver.build) {
return 1;
} else if (!this.build && otherSemver.build) {
return -1;
} else {
return this.compareIdentifiers(this.build, otherSemver.build);
}
}
}], [{
key: 'validate',
value: function validate(version) {
return REGEX_FULL_VERSION.test(version);
}
}]);
return SemverVersion;
}();
module.exports = SemverVersion;
/***/ })
/******/ ]);
});

View File

@ -866,38 +866,73 @@ function getReleases(callback)
success: function(releases) success: function(releases)
{ {
window.gitHubVersionList = releases; window.gitHubVersionList = releases;
var highestRelease = {
tag_name: '0.0.0'
};
var highestAlphaRelease = {
tag_name: '0.0.0'
};
var highestBetaRelease = {
tag_name: '0.0.0'
};
var highestRcRelease = {
tag_name: '0.0.0'
};
for(var i in releases) for(var i in releases) {
//drafts will be ignored
if(releases[i].draft)
continue;
if(releases[i].tag_name.includes('alpha'))
{ {
if(releases[i].prerelease == true) if (sem = semverLite.gt(releases[i].tag_name, highestAlphaRelease.tag_name))
{ highestAlphaRelease = releases[i];
window.latestBetaVersion = releases[i];
break;
} }
else if (releases[i].tag_name.includes('beta'))
{
if (sem = semverLite.gt(releases[i].tag_name, highestBetaRelease.tag_name))
highestBetaRelease = releases[i];
} }
else if (releases[i].tag_name.includes('rc'))
$.ajax({
url: window.gitHubReleaseApiUrl + "/latest",
method: 'get',
error: function(XMLHttpRequest, textStatus, errorThrown)
{ {
callback(false); if (semverLite.gt(releases[i].tag_name, highestRcRelease.tag_name))
}, highestRcRelease = releases[i];
success: function(latest)
{
window.latestStableVersion = latest;
if(window.serverConfig.general.watchedVersionBranch == "Beta" && window.latestStableVersion.tag_name.replace(/\./g, '') <= window.latestBetaVersion.tag_name.replace(/\./g, ''))
{
window.latestVersion = window.latestBetaVersion;
} }
else else
{ {
window.latestVersion = window.latestStableVersion; if (semverLite.gt(releases[i].tag_name, highestRelease.tag_name))
highestRelease = releases[i];
} }
}
window.latestStableVersion = highestRelease;
window.latestBetaVersion = highestBetaRelease;
window.latestAlphaVersion= highestAlphaRelease;
window.latestRcVersion = highestRcRelease;
if(window.serverConfig.general.watchedVersionBranch == "Beta" && semverLite.gt(highestBetaRelease.tag_name, highestRelease.tag_name))
window.latestVersion = highestBetaRelease;
else
window.latestVersion = highestRelease;
if(window.serverConfig.general.watchedVersionBranch == "Alpha" && semverLite.gt(highestAlphaRelease.tag_name, highestBetaRelease.tag_name))
window.latestVersion = highestAlphaRelease;
if(window.serverConfig.general.watchedVersionBranch == "Alpha" && semverLite.lt(highestAlphaRelease.tag_name, highestBetaRelease.tag_name))
window.latestVersion = highestBetaRelease;
//next two if statements are only necessary if we don't have a beta or stable release. We need one alpha release at least
if(window.latestVersion.tag_name == '0.0.0' && highestBetaRelease.tag_name != '0.0.0')
window.latestVersion = highestBetaRelease;
if(window.latestVersion.tag_name == '0.0.0' && highestAlphaRelease.tag_name != '0.0.0')
window.latestVersion = highestAlphaRelease;
callback(true); callback(true);
} }
}); });
}
})
} }

View File

@ -18,12 +18,12 @@
{ {
"type" : "string", "type" : "string",
"title" : "edt_conf_gen_watchedVersionBranch_title", "title" : "edt_conf_gen_watchedVersionBranch_title",
"enum" : ["Stable", "Beta"], "enum" : ["Stable", "Beta", "Alpha"],
"required" : true, "required" : true,
"access" : "expert", "access" : "expert",
"default" : "Stable", "default" : "Stable",
"options" : { "options" : {
"enum_titles" : ["Stable", "Beta"] "enum_titles" : ["Stable", "Beta", "Alpha"]
}, },
"propertyOrder" : 2 "propertyOrder" : 2
}, },