Merge branch 'paul-bastelt' into 'main'

Paul bastelt muss ins main... dalli

See merge request julscha/sectorfileupdater!2
This commit is contained in:
Julian 2022-11-05 20:38:15 +00:00
commit b6d23d2380
11 changed files with 617 additions and 869 deletions

View File

@ -6,12 +6,12 @@ Dieses kleine Tool soll GNG Sector Müll beheben. Leider beschäftigt sich jeder
* Select ES Folder
* Version herausfinden / eingeben
* Updates prüfen (file from Server mit Update Möglichkeiten) bspw (vonVersion-nachVersion):
* 2200-2201
* 2200-2202
* 2200-2203
* 2200-2204
* 2200-2205
* 2200-2206
* 2207-2201
* 2207-2202
* 2207-2203
* 2207-2204
* 2207-2205
* 2207-2206
* Update herunterladen und enpacken
* Hierbei werden neue und modifizierte Dateien verändert. (Erkannt wird das vorab mit einem Server script, welches die Fullpackes vergleicht und mittels git vergleicht. Einschränkung hier --diff-filter=ACRTUXBD)
* Inline, wie bei Git ist hier nicht möglich, da nicht git vorrausgesetzt werden kann auf dem Zielcomputer

7
updater/data-out.yaml Normal file
View File

@ -0,0 +1,7 @@
cid:
save: true
id: 0
password:
save: true
pass: NaN
currentInstalledAirac: 0

1250
updater/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,8 @@
"@octokit/core": "^4.0.5",
"decompress-zip": "^0.3.3",
"electron-dl": "^3.3.1",
"electron-squirrel-startup": "^1.0.0"
"electron-squirrel-startup": "^1.0.0",
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@electron-forge/cli": "^6.0.0-beta.66",

View File

@ -0,0 +1 @@
folderPath: "C:\\Euroscope"

View File

@ -0,0 +1,7 @@
cid:
save: true
id: 1467870
password:
save: false
pass: "Testen123"
currentInstalledAirac: 2205

View File

@ -7,15 +7,15 @@
</head>
<body>
<button id="download" class"button is-primary">Download</button>
<button id="dirs">Open</button>
<button id="dirs">Select Directory</button>
<button id="extract">Extract ZIP</button>
<p id="ouput">Output Test here</p>
<p>Input URL</p>
<input type="text" id="urlBox" name="name" size="80">
<p>Input Directory</p>
<input type="text" id="dirBox" name="name" size="80">
<progress id="progressbar" max="100" value="70"></progress>
<input type="file" id="dirs" webkitdirectory directory/>
<p id="ouput">Output Test here</p>
<progress id="progressbar" max="100" value="0"></progress>
<script src="./renderer.js"></script>
</body>
</html>

View File

@ -3,6 +3,8 @@ const { download } = require("electron-dl");
const path = require('path');
//Menu.setApplicationMenu(false); // Top Bar removal
var fs = require('fs');
const yaml = require('js-yaml');
var DecompressZip = require('decompress-zip');
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
// eslint-disable-next-line global-require
@ -10,6 +12,21 @@ if (require('electron-squirrel-startup')) {
app.quit();
}
var filepath;
let data = {
cid: {
save: true,
id: 0
},
password: {
save: true,
pass: "NaN"
},
currentInstalledAirac: 0
};
const createWindow = () => {
// Create the browser window.
const mainWindow = new BrowserWindow({
@ -24,14 +41,35 @@ const createWindow = () => {
});
mainWindow.loadFile(path.join(__dirname, 'index.html'));
mainWindow.webContents.openDevTools();
/*
// Read system yaml
try {
let fileContents = fs.readFileSync('sectorfileUpdater.yaml', 'utf8');
filepath = yaml.load(fileContents).folderPath;
} catch (e) {
}
// Read config yaml
try {
let fileContents = fs.readFileSync(filepath + 'sectorfileUpdater.yaml', 'utf8');
data = yaml.load(fileContents);
console.log(data);
console.log(data.cid.id);
} catch (e) {
console.log(e);
ipcRenderer.send("savefile", {});
}*/
// Select Directory
ipcMain.on('select-dirs', async(event, arg) => {
const result = await dialog.showOpenDialog(mainWindow, {
filepath = await dialog.showOpenDialog(mainWindow, {
properties: ['openDirectory']
})
console.log('directories selected', result.filePaths)
})
console.log('directories selected', filepath.filePaths)
mainWindow.webContents.send("filepath", filepath.filePaths);
// Save directory to file
});
// Download a file
ipcMain.on("download", (event, info) => {
@ -42,7 +80,28 @@ const createWindow = () => {
});
// Write to a file
ipcMain.on("saveFile", () => {
let yamlStr = yaml.dump(data);
fs.writeFileSync(filepath + 'sectorfileUpdater.yaml', yamlStr, 'utf8');
});
// Unzip content
ipcMain.on("extract", () => {
//console.log(directory.directoryPath);
var unzipper = new DecompressZip("F:\\Desktop.zip");
unzipper.extract({
path: "F:\\test\\" // directory.directoryPath
});
// Notify "progress" of the decompressed files
unzipper.on('progress', function(fileIndex, fileCount) {
console.log('Extracted file ' + (fileIndex + 1) + ' of ' + fileCount);
});
// Notify when everything is extracted
unzipper.on('extract', function(log) {
console.log('Finished extracting', log);
});
});
};
@ -59,6 +118,8 @@ app.on('ready', createWindow);
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', () => {
let yamlStr = yaml.dump(data);
fs.writeFileSync('data-out.yaml', yamlStr, 'utf8');
if (process.platform !== 'darwin') {
app.quit();
}
@ -71,12 +132,3 @@ app.on('activate', () => {
createWindow();
}
});
// Write to a file
ipcMain.on("saveFile", (event, location, txtVal) => {
fs.writeFile(location, txtVal.toString(), (err) => {
if (!err) { console.log("File.written"); } else {
console.log(err);
}
});
});

View File

@ -1 +1,9 @@
const { contextBridge, ipcRenderer } = require('electron')
process.once('loaded', () => {
window.addEventListener('message', evt => {
if (evt.data.type === 'select-dirs') {
ipcRenderer.send('select-dirs')
}
})
})

View File

@ -1,4 +1,5 @@
const { ipcRenderer, dialog } = require('electron');
var DecompressZip = require('decompress-zip');
ipcRenderer.on("download complete", (event, file) => {
console.log(file); // Full file path
@ -10,8 +11,8 @@ ipcRenderer.on("download progress", (event, progress) => {
document.getElementById('progressbar').value = cleanProgressInPercentages;
});
let donwloadbtn = document.getElementById('download');
donwloadbtn.addEventListener('click', (e) => {
let donwloadBtn = document.getElementById('download');
donwloadBtn.addEventListener('click', (e) => {
let directoryPath = document.getElementById('dirBox');
let urlPath = document.getElementById('urlBox');
ipcRenderer.send("download", {
@ -20,19 +21,23 @@ donwloadbtn.addEventListener('click', (e) => {
});
});
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('dirs').addEventListener('click', function() {
openFile();
});
});
function openFile() {
ipcRenderer.send('openFolder', () => {
console.log("Event sent.");
});
}
ipcRenderer.on('folderData', (event, data) => {
console.log(data)
let directoryBtn = document.getElementById('dirs');
directoryBtn.addEventListener('click', (e) => {
window.postMessage({
type: 'select-dirs'
})
});
ipcRenderer.on("filepath", (event, file) => {
document.getElementById('dirBox').innerText = file;
});
let extractBtn = document.getElementById('extract');
extractBtn.addEventListener('click', () => {
let directoryPath = document.getElementById('dirBox');
let urlPath = document.getElementById('urlBox');
ipcRenderer.send("extract", {
url: urlPath.value,
properties: { directory: directoryPath.value }
});
});

View File

@ -416,9 +416,9 @@
"universal-user-agent" "^6.0.0"
"@octokit/openapi-types@^13.11.0":
"integrity" "sha512-1QYzZrwnn3rTQE7ZoSxXrO8lhu0aIbac1c+qIPOPEaVXBWSaUyLV1x9yt4uDQOwmu6u5ywVS8OJgs+ErDLf6vQ=="
"resolved" "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-13.12.0.tgz"
"version" "13.12.0"
"integrity" "sha512-4EuKSk3N95UBWFau3Bz9b3pheQ8jQYbKmBL5+GSuY8YDPDwu03J4BjI+66yNi8aaX/3h1qDpb0mbBkLdr+cfGQ=="
"resolved" "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-13.13.1.tgz"
"version" "13.13.1"
"@octokit/request-error@^3.0.0":
"integrity" "sha512-ym4Bp0HTP7F3VFssV88WD1ZyCIRoE8H35pXSKwLeMizcdZAYc/t6N9X9Yr9n6t3aG9IH75XDnZ6UeZph0vHMWQ=="
@ -442,9 +442,9 @@
"universal-user-agent" "^6.0.0"
"@octokit/types@^7.0.0":
"integrity" "sha512-aHm+olfIZjQpzoODpl+RCZzchKOrdSLJs+yfI7pMMcmB19Li6vidgx0DwUDO/Ic4Q3fq/lOjJORVCcLZefcrJw=="
"resolved" "https://registry.npmjs.org/@octokit/types/-/types-7.5.0.tgz"
"version" "7.5.0"
"integrity" "sha512-Zk4OUMLCSpXNI8KZZn47lVLJSsgMyCimsWWQI5hyjZg7hdYm0kjotaIkbG0Pp8SfU2CofMBzonboTqvzn3FrJA=="
"resolved" "https://registry.npmjs.org/@octokit/types/-/types-7.5.1.tgz"
"version" "7.5.1"
dependencies:
"@octokit/openapi-types" "^13.11.0"
@ -520,9 +520,9 @@
"version" "5.1.2"
"@types/node@*", "@types/node@^16.11.26":
"integrity" "sha512-6u+36Dj3aDzhfBVUf/mfmc92OEdzQ2kx2jcXGdigfl70E/neV21ZHE6UCz4MDzTRcVqGAM27fk+DLXvyDsn3Jw=="
"resolved" "https://registry.npmjs.org/@types/node/-/node-16.11.59.tgz"
"version" "16.11.59"
"integrity" "sha512-3OxnrEQLBz8EIIaHpg3CibmTAEGkDBcHY4fL5cnBwg2vd2yvHrUDGWxK+MlYPeXWWIoJJW79dGtU+oeBr6166Q=="
"resolved" "https://registry.npmjs.org/@types/node/-/node-16.11.63.tgz"
"version" "16.11.63"
"@types/responselike@*", "@types/responselike@^1.0.0":
"integrity" "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA=="
@ -599,6 +599,11 @@
"delegates" "^1.0.0"
"readable-stream" "^3.6.0"
"argparse@^2.0.1":
"integrity" "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
"resolved" "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz"
"version" "2.0.1"
"asar@^2.0.1":
"integrity" "sha512-d2Ovma+bfqNpvBzY/KU8oPY67ZworixTpkjSx0PCXnQi67c2cXmssaTxpFDUM0ttopXoGx/KRxNg/GDThYbXQA=="
"resolved" "https://registry.npmjs.org/asar/-/asar-2.1.0.tgz"
@ -853,13 +858,13 @@
"resolved" "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz"
"version" "3.0.0"
"cliui@^7.0.2":
"integrity" "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ=="
"resolved" "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz"
"version" "7.0.4"
"cliui@^8.0.1":
"integrity" "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ=="
"resolved" "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz"
"version" "8.0.1"
dependencies:
"string-width" "^4.2.0"
"strip-ansi" "^6.0.0"
"strip-ansi" "^6.0.1"
"wrap-ansi" "^7.0.0"
"clone-response@^1.0.2":
@ -1961,6 +1966,13 @@
"resolved" "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz"
"version" "2.0.0"
"js-yaml@^4.1.0":
"integrity" "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA=="
"resolved" "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz"
"version" "4.1.0"
dependencies:
"argparse" "^2.0.1"
"json-buffer@3.0.0":
"integrity" "sha512-CuUqjv0FUZIdXkHPI8MezCnFCdaTAacej1TZYulLoAg1h/PhwkdXFN4V/gzY4g+fMBCOV2xF+rp7t2XD2ns/NQ=="
"resolved" "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz"
@ -2323,9 +2335,9 @@
"version" "1.0.5"
"node-abi@^3.0.0":
"integrity" "sha512-YPG3Co0luSu6GwOBsmIdGW6Wx0NyNDLg/hriIyDllVsNwnI6UeqaWShxC3lbH4LtEQUgoLP3XR1ndXiDAWvmRw=="
"resolved" "https://registry.npmjs.org/node-abi/-/node-abi-3.24.0.tgz"
"version" "3.24.0"
"integrity" "sha512-p+0xx5ruIQ+8X57CRIMxbTZRT7tU0Tjn2C/aAK68AEMrbGsCo6IjnDdPNhEyyjWCT4bRtzomXchYd3sSgk3BJQ=="
"resolved" "https://registry.npmjs.org/node-abi/-/node-abi-3.25.0.tgz"
"version" "3.25.0"
dependencies:
"semver" "^7.3.5"
@ -2767,7 +2779,16 @@
"isarray" "0.0.1"
"string_decoder" "~0.10.x"
"readable-stream@^3.4.0", "readable-stream@^3.6.0":
"readable-stream@^3.4.0":
"integrity" "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA=="
"resolved" "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz"
"version" "3.6.0"
dependencies:
"inherits" "^2.0.3"
"string_decoder" "^1.1.1"
"util-deprecate" "^1.0.1"
"readable-stream@^3.6.0":
"integrity" "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA=="
"resolved" "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz"
"version" "3.6.0"
@ -2888,9 +2909,9 @@
"queue-microtask" "^1.2.2"
"rxjs@^7.5.5":
"integrity" "sha512-dnyv2/YsXhnm461G+R/Pe5bWP41Nm6LBXEYWI6eiFP4fiwx6WRI/CD0zbdVAudd9xwLEF2IDcKXLHit0FYjUzw=="
"resolved" "https://registry.npmjs.org/rxjs/-/rxjs-7.5.6.tgz"
"version" "7.5.6"
"integrity" "sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA=="
"resolved" "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz"
"version" "7.5.7"
dependencies:
"tslib" "^2.1.0"
@ -2987,9 +3008,9 @@
"socks" "^2.6.2"
"socks@^2.6.2":
"integrity" "sha512-scnOe9y4VuiNUULJN72GrM26BNOjVsfPXI+j+98PkyEfsIXroa5ofyjT+FzGvn/xHs73U2JtoBYAVx9Hl4quSA=="
"resolved" "https://registry.npmjs.org/socks/-/socks-2.7.0.tgz"
"version" "2.7.0"
"integrity" "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ=="
"resolved" "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz"
"version" "2.7.1"
dependencies:
"ip" "^2.0.0"
"smart-buffer" "^4.2.0"
@ -3398,11 +3419,11 @@
"version" "21.1.1"
"yargs@^17.0.1":
"integrity" "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA=="
"resolved" "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz"
"version" "17.5.1"
"integrity" "sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g=="
"resolved" "https://registry.npmjs.org/yargs/-/yargs-17.6.0.tgz"
"version" "17.6.0"
dependencies:
"cliui" "^7.0.2"
"cliui" "^8.0.1"
"escalade" "^3.1.1"
"get-caller-file" "^2.0.5"
"require-directory" "^2.1.1"