aboutsummaryrefslogtreecommitdiff
path: root/src/versionChecker
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2021-09-19 19:43:11 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2021-09-19 19:43:11 +0200
commit7bdce37fd3f18e2712e18c4e2c64cac69af0aca1 (patch)
treeb7ad3f1cca92e2dfd2664ae9e65652bd03ff58b2 /src/versionChecker
parente6880cd8ccf82d993f222cb14b4860581654acb8 (diff)
downloadLuxcena-Neo-7bdce37fd3f18e2712e18c4e2c64cac69af0aca1.tar.gz
Luxcena-Neo-7bdce37fd3f18e2712e18c4e2c64cac69af0aca1.zip
:boom: Introduce new UI based on svelte, and rewrite a lot of the node app and the NeoRuntime
Diffstat (limited to 'src/versionChecker')
-rw-r--r--src/versionChecker/index.js58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/versionChecker/index.js b/src/versionChecker/index.js
deleted file mode 100644
index cee1486..0000000
--- a/src/versionChecker/index.js
+++ /dev/null
@@ -1,58 +0,0 @@
-let fs = require("fs-extra");
-let url = require("url");
-let request = require('request');
-let exec = require("child_process").exec;
-
-class versionChecker {
-
- constructor(configJson, packageJson) {
- this.config = JSON.parse(fs.readFileSync(configJson));
- this.CPackageJson = JSON.parse(fs.readFileSync(packageJson));
-
- this.version = this.CPackageJson["version"];
- this.repoVersion = this.version;
- this.checkFrequency = this.config["checkInterval"] * 100 * 10 * 60 * 60; // takes in hours
- this.repoLink = this.CPackageJson["repository"]["url"];
- this.repoBranch = this.config["branch"];
-
- this.checkVersion(this); // Because we have to send the reference in our interval, we have to to it here as well
- this.updateChecker = setInterval(this.checkVersion, this.checkFrequency, this); // We have to send a reference to this class
- }
-
- checkVersion(parent) {
- if (typeof(parent) == "undefined") { parent = this; }
- let path = url.parse(parent.repoLink);
- let link = "https://raw.githubusercontent.com" + path.pathname + '/' + parent.repoBranch + "/package.json";
-
- request.get(link, (error, response, body) => {
- if (!error && response.statusCode === 200) {
- let remotePackageJSON = JSON.parse(body);
- this.repoVersion = remotePackageJSON["version"];
- if (parent.VersionIsNewerThan(this.repoVersion, parent.version)) {
- global.log("A new version is available on \"" + parent.repoBranch + "\" (v" + this.repoVersion + ")", "INFO");
- }
- } else {
- global.log("Could not find latest version! Please check you internet connection.", "ERROR");
- }
- });
- }
-
- VersionIsNewerThan(check, current) {
- let checkParts = check.split(".");
- let currentParts = current.split(".");
- let lCheckParts = checkParts.length;
- let lCurrentParts = currentParts.length;
-
- for (let i = 0; i < lCheckParts; i++) {
- if (i >= lCurrentParts) { return true; }
- if (Number (checkParts[i]) > Number (currentParts[i])) { return true; }
- if (Number (checkParts[i]) < Number (currentParts[i])) { return false; }
- }
- return false;
- }
-
-}
-module.exports = (configJson, packageJson) => {
- return new versionChecker(configJson, packageJson);
-};