From e51694dc9157a187799193cd4ceb6d9f2965136e Mon Sep 17 00:00:00 2001 From: PaulaBras <68814660+PaulaBras@users.noreply.github.com> Date: Sat, 14 Jan 2023 01:26:26 +0100 Subject: [PATCH] updates, soc, simplify code --- updater/package-lock.json | 59 +++++++- updater/package.json | 6 +- updater/src/data_structure.js | 24 +++ updater/src/download.js | 20 +++ updater/src/getFiles.js | 40 +++++ updater/src/git_ops.js | 0 updater/src/html_elements.js | 19 +++ updater/src/index.html | 80 +++++----- updater/src/renderer.js | 276 ---------------------------------- updater/src/save.js | 36 +++++ updater/src/startup.js | 61 ++++++++ updater/src/unzip.js | 29 ++++ updater/yarn.lock | 21 +++ 13 files changed, 352 insertions(+), 319 deletions(-) create mode 100644 updater/src/data_structure.js create mode 100644 updater/src/download.js create mode 100644 updater/src/getFiles.js create mode 100644 updater/src/git_ops.js create mode 100644 updater/src/html_elements.js create mode 100644 updater/src/save.js create mode 100644 updater/src/startup.js create mode 100644 updater/src/unzip.js diff --git a/updater/package-lock.json b/updater/package-lock.json index e0dbeca..dea3f12 100644 --- a/updater/package-lock.json +++ b/updater/package-lock.json @@ -1,12 +1,12 @@ { - "name": "updater", - "version": "1.0.0", + "name": "sectorfile_updater", + "version": "0.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "updater", - "version": "1.0.0", + "name": "sectorfile_updater", + "version": "0.0.1", "license": "MIT", "dependencies": { "@octokit/core": "^4.0.5", @@ -15,6 +15,7 @@ "electron-squirrel-startup": "^1.0.0", "http": "^0.0.1-security", "js-yaml": "^4.1.0", + "simple-git": "^3.15.1", "superagent": "^8.0.3" }, "devDependencies": { @@ -544,6 +545,19 @@ "integrity": "sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==", "dev": true }, + "node_modules/@kwsites/file-exists": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", + "integrity": "sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==", + "dependencies": { + "debug": "^4.1.1" + } + }, + "node_modules/@kwsites/promise-deferred": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz", + "integrity": "sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==" + }, "node_modules/@malept/cross-spawn-promise": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@malept/cross-spawn-promise/-/cross-spawn-promise-2.0.0.tgz", @@ -5600,6 +5614,20 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "node_modules/simple-git": { + "version": "3.15.1", + "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-3.15.1.tgz", + "integrity": "sha512-73MVa5984t/JP4JcQt0oZlKGr42ROYWC3BcUZfuHtT3IHKPspIvL0cZBnvPXF7LL3S/qVeVHVdYYmJ3LOTw4Rg==", + "dependencies": { + "@kwsites/file-exists": "^1.1.1", + "@kwsites/promise-deferred": "^1.1.1", + "debug": "^4.3.4" + }, + "funding": { + "type": "github", + "url": "https://github.com/steveukx/git-js?sponsor=1" + } + }, "node_modules/smart-buffer": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", @@ -6854,6 +6882,19 @@ "integrity": "sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==", "dev": true }, + "@kwsites/file-exists": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", + "integrity": "sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==", + "requires": { + "debug": "^4.1.1" + } + }, + "@kwsites/promise-deferred": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz", + "integrity": "sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==" + }, "@malept/cross-spawn-promise": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@malept/cross-spawn-promise/-/cross-spawn-promise-2.0.0.tgz", @@ -10686,6 +10727,16 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "simple-git": { + "version": "3.15.1", + "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-3.15.1.tgz", + "integrity": "sha512-73MVa5984t/JP4JcQt0oZlKGr42ROYWC3BcUZfuHtT3IHKPspIvL0cZBnvPXF7LL3S/qVeVHVdYYmJ3LOTw4Rg==", + "requires": { + "@kwsites/file-exists": "^1.1.1", + "@kwsites/promise-deferred": "^1.1.1", + "debug": "^4.3.4" + } + }, "smart-buffer": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", diff --git a/updater/package.json b/updater/package.json index 460455f..76d0674 100644 --- a/updater/package.json +++ b/updater/package.json @@ -20,7 +20,8 @@ "config": { "forge": { "packagerConfig": {}, - "makers": [{ + "makers": [ + { "name": "@electron-forge/maker-squirrel", "config": { "name": "updater" @@ -50,6 +51,7 @@ "electron-squirrel-startup": "^1.0.0", "http": "^0.0.1-security", "js-yaml": "^4.1.0", + "simple-git": "^3.15.1", "superagent": "^8.0.3" }, "devDependencies": { @@ -60,4 +62,4 @@ "@electron-forge/maker-zip": "^6.0.0-beta.66", "electron": "^21.0.1" } -} \ No newline at end of file +} diff --git a/updater/src/data_structure.js b/updater/src/data_structure.js new file mode 100644 index 0000000..40c8f5d --- /dev/null +++ b/updater/src/data_structure.js @@ -0,0 +1,24 @@ +var systemstructure = { + path: "" +}; + +var structure = { + region: 0, + file: 0, + installcreds: false, // Not yet implemented + installhoppie: false, // Not yet implemented + cid: { + save: true, + id: -1 + }, + password: { + save: true, + pass: "" + }, + passwordhoppie: { + save: true, + pass: "" + }, + currentInstalledAirac: 0, + version: "v1" +}; \ No newline at end of file diff --git a/updater/src/download.js b/updater/src/download.js new file mode 100644 index 0000000..6ff9961 --- /dev/null +++ b/updater/src/download.js @@ -0,0 +1,20 @@ +function downloadFile(source, path) { + console.log(source); + const zipFile = source.split('/').pop(); + + superagent + .get(source).set("Referer", "http://files.aero-nav.com/") + .on('error', function(error) { + console.log(error); + }) + .pipe(fs.createWriteStream(path + "\\" + zipFile)) + .on('finish', function() { + // add code below to here + }); +} + +function createFolder(folder) { + if (!fs.existsSync(folder)) { + fs.mkdirSync(folder); + } +}; \ No newline at end of file diff --git a/updater/src/getFiles.js b/updater/src/getFiles.js new file mode 100644 index 0000000..dde3872 --- /dev/null +++ b/updater/src/getFiles.js @@ -0,0 +1,40 @@ +async function getUpdates() { + const courses = await superagent.get('https://files.aero-nav.com/'); + let text = courses.text.match(/Download Pages([^]*?)<\/body>/g); + console.log(text); + let liste = text[0].match(/(.*?)<\/b>/g).map(item => item.replace(/<\/?b>/g, "")); + + liste.forEach(item => { + var option = document.createElement("option"); + option.text = item; + dropDownGNG.add(option); + }); + getFiles(); +} + + +async function getFiles() { + await removeFileItems(); + let region = "https://files.aero-nav.com/" + dropDownGNG.options[dropDownGNG.selectedIndex].text; + let courses = await superagent.get(region); + let text = courses.text.split("Released
Input Directory
@@ -19,40 +21,44 @@Username
- - -Password
- - - Please be aware that the password you enter will be stored in plain - text in our system. This means that it will not be encrypted or - otherwise secured. We recommend that you do not use a password that - you also use for other important accounts, such as your email or - banking. Please use caution when entering your password and consider - using a unique and strong password specifically for this - account. -Password Hoppie
- - - Please be aware that the password you enter will be stored in plain - text in our system. This means that it will not be encrypted or - otherwise secured. We recommend that you do not use a password that - you also use for other important accounts, such as your email or - banking. Please use caution when entering your password and consider - using a unique and strong password specifically for this - account. -Username
+ + +Password
+ + + Please be aware that the password you enter will be stored in plain + text in our system. This means that it will not be encrypted or + otherwise secured. We recommend that you do not use a password that + you also use for other important accounts, such as your email or + banking. Please use caution when entering your password and consider + using a unique and strong password specifically for this + account. +Password Hoppie
+ + + Please be aware that the password you enter will be stored in plain + text in our system. This means that it will not be encrypted or + otherwise secured. We recommend that you do not use a password that + you also use for other important accounts, such as your email or + banking. Please use caution when entering your password and consider + using a unique and strong password specifically for this + account. +