mirror of
https://github.com/JustusPlays78/SectorFileUpdater.git
synced 2025-04-29 10:10:57 +00:00
Merge branch 'paul-bastelt' into 'main'
Paul bastelt See merge request julscha/sectorfileupdater!1
This commit is contained in:
commit
3bb0c78022
37
README.md
37
README.md
@ -1,7 +1,36 @@
|
||||
# Sectorfile Updater
|
||||
Dieses kleine Tool soll GNG Sector Müll beheben. Leider beschäftigt sich jeder, jeden beschissenen AIRAC Cycle Monat damit, seine Daten neuaufzusetzten und wieder alle Daten einzutragen. So nicht, dachte sich eines Tages PaBr und Herr Schalli war sofort dabei. Sie sagten: "Wir machen diesen Fuck nicht mehr mit" und entwickelten in ewigen Nächsten diese Problemlösung.
|
||||
|
||||
## TO DO
|
||||
- ...
|
||||
## Programmschritte:
|
||||
|
||||
## Done
|
||||
- ...
|
||||
* 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
|
||||
* 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
|
||||
* _Optional_: Alte Dateien können gelöscht werden. Hauptsächlich betrifft das Sectorfiles sowie alte config Dateien von Plugins
|
||||
|
||||
## Technische Herausfoderungen:
|
||||
* Electron APP (Multiplatform Support (theorie, da ES nur auf Windows läuft))
|
||||
* Namenskonvention in html, css & js:
|
||||
* Camelcase (https://en.wikipedia.org/wiki/Camel_case)
|
||||
* Bash Scripting
|
||||
|
||||
## ToDo:
|
||||
* Folder Selector
|
||||
* Version Selector
|
||||
* Input User Variable Save to txt/json/yaml file
|
||||
* UI
|
||||
* unzip
|
||||
* delete old non used files Option
|
||||
|
||||
## Done:
|
||||
* Download
|
||||
* Progressbar Download
|
9
git-commit.sh
Normal file
9
git-commit.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# $1 = Changes
|
||||
# $2 = Branch
|
||||
|
||||
git add .
|
||||
git commit -m "$1"
|
||||
git push -uf origin paul-bastelt
|
||||
#git push -uf paulgit paul-bastelt
|
BIN
release-test-lustigeDateiv1.zip
Normal file
BIN
release-test-lustigeDateiv1.zip
Normal file
Binary file not shown.
BIN
release-test-lustigeDateiv2.zip
Normal file
BIN
release-test-lustigeDateiv2.zip
Normal file
Binary file not shown.
61
updater/.gitlab/actions/release/action.yml
Normal file
61
updater/.gitlab/actions/release/action.yml
Normal file
@ -0,0 +1,61 @@
|
||||
name: Electron Builder Action
|
||||
author: Samuel Meuli
|
||||
description: GitHub Action for building and releasing Electron apps
|
||||
|
||||
inputs:
|
||||
github_token:
|
||||
description: GitHub authentication token
|
||||
required: true
|
||||
mac_certs:
|
||||
description: Base64-encoded code signing certificate for macOS
|
||||
required: false
|
||||
mac_certs_password:
|
||||
description: Password for decrypting `mac_certs`
|
||||
required: false
|
||||
release:
|
||||
description: Whether the app should be released after a successful build
|
||||
required: false
|
||||
default: false
|
||||
windows_certs:
|
||||
description: Base64-encoded code signing certificate for Windows
|
||||
required: false
|
||||
windows_certs_password:
|
||||
description: Password for decrypting `windows_certs`
|
||||
required: false
|
||||
package_root:
|
||||
description: Directory where NPM/Yarn commands should be run
|
||||
required: false
|
||||
default: "."
|
||||
build_script_name:
|
||||
description: Name of the optional NPM build script which is executed before `electron-builder`
|
||||
required: false
|
||||
default: build
|
||||
skip_build:
|
||||
description: Whether the action should execute the NPM build script before running `electron-builder`
|
||||
required: false
|
||||
default: false
|
||||
use_vue_cli:
|
||||
description: Whether to run `electron-builder` using the Vue CLI plugin instead of calling the command directly
|
||||
required: false
|
||||
default: false
|
||||
args:
|
||||
description: Other arguments to pass to the `electron-builder` command, e.g. configuration overrides
|
||||
required: false
|
||||
default: ""
|
||||
max_attempts:
|
||||
description: Maximum number of attempts for completing the build and release step
|
||||
required: false
|
||||
default: "1"
|
||||
|
||||
# Deprecated
|
||||
app_root:
|
||||
description: Directory where `electron-builder` commands should be run
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: node12
|
||||
main: index.js
|
||||
|
||||
branding:
|
||||
icon: upload-cloud
|
||||
color: blue
|
156
updater/.gitlab/actions/release/index.js
Normal file
156
updater/.gitlab/actions/release/index.js
Normal file
@ -0,0 +1,156 @@
|
||||
const { execSync } = require("child_process");
|
||||
const { existsSync, readFileSync } = require("fs");
|
||||
const { join } = require("path");
|
||||
|
||||
/**
|
||||
* Logs to the console
|
||||
*/
|
||||
const log = (msg) => console.log(`\n${msg}`); // eslint-disable-line no-console
|
||||
|
||||
/**
|
||||
* Exits the current process with an error code and message
|
||||
*/
|
||||
const exit = (msg) => {
|
||||
console.error(msg);
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the provided shell command and redirects stdout/stderr to the console
|
||||
*/
|
||||
const run = (cmd, cwd) => execSync(cmd, { encoding: "utf8", stdio: "inherit", cwd });
|
||||
|
||||
/**
|
||||
* Determines the current operating system (one of ["mac", "windows", "linux"])
|
||||
*/
|
||||
const getPlatform = () => {
|
||||
switch (process.platform) {
|
||||
case "darwin":
|
||||
return "mac";
|
||||
case "win32":
|
||||
return "windows";
|
||||
default:
|
||||
return "linux";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the value for an environment variable (or `null` if it's not defined)
|
||||
*/
|
||||
const getEnv = (name) => process.env[name.toUpperCase()] || null;
|
||||
|
||||
/**
|
||||
* Sets the specified env variable if the value isn't empty
|
||||
*/
|
||||
const setEnv = (name, value) => {
|
||||
if (value) {
|
||||
process.env[name.toUpperCase()] = value.toString();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the value for an input variable (or `null` if it's not defined). If the variable is
|
||||
* required and doesn't have a value, abort the action
|
||||
*/
|
||||
const getInput = (name, required) => {
|
||||
const value = getEnv(`INPUT_${name}`);
|
||||
if (required && !value) {
|
||||
exit(`"${name}" input variable is not defined`);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Installs NPM dependencies and builds/releases the Electron app
|
||||
*/
|
||||
const runAction = () => {
|
||||
const platform = getPlatform();
|
||||
const release = getInput("release", true) === "true";
|
||||
const pkgRoot = getInput("package_root", true);
|
||||
const buildScriptName = getInput("build_script_name", true);
|
||||
const skipBuild = getInput("skip_build") === "true";
|
||||
const useVueCli = getInput("use_vue_cli") === "true";
|
||||
const args = getInput("args") || "";
|
||||
const maxAttempts = Number(getInput("max_attempts") || "1");
|
||||
|
||||
// TODO: Deprecated option, remove in v2.0. `electron-builder` always requires a `package.json` in
|
||||
// the same directory as the Electron app, so the `package_root` option should be used instead
|
||||
const appRoot = getInput("app_root") || pkgRoot;
|
||||
|
||||
const pkgJsonPath = join(pkgRoot, "package.json");
|
||||
const pkgLockPath = join(pkgRoot, "package-lock.json");
|
||||
|
||||
// Determine whether NPM should be used to run commands (instead of Yarn, which is the default)
|
||||
const useNpm = existsSync(pkgLockPath);
|
||||
log(`Will run ${useNpm ? "NPM" : "Yarn"} commands in directory "${pkgRoot}"`);
|
||||
|
||||
// Make sure `package.json` file exists
|
||||
if (!existsSync(pkgJsonPath)) {
|
||||
exit(`\`package.json\` file not found at path "${pkgJsonPath}"`);
|
||||
}
|
||||
|
||||
// Copy "github_token" input variable to "GH_TOKEN" env variable (required by `electron-builder`)
|
||||
setEnv("GH_TOKEN", getInput("github_token", true));
|
||||
|
||||
// Require code signing certificate and password if building for macOS. Export them to environment
|
||||
// variables (required by `electron-builder`)
|
||||
if (platform === "mac") {
|
||||
const mac_certs = getInput("mac_certs");
|
||||
const mac_certs_password = getInput("mac_certs_password");
|
||||
if (mac_certs && mac_certs_password) {
|
||||
setEnv("CSC_LINK", mac_certs);
|
||||
setEnv("CSC_KEY_PASSWORD", mac_certs_password);
|
||||
} else {
|
||||
setEnv("CSC_IDENTITY_AUTO_DISCOVERY", "false");
|
||||
}
|
||||
} else if (platform === "windows") {
|
||||
setEnv("CSC_LINK", getInput("windows_certs"));
|
||||
setEnv("CSC_KEY_PASSWORD", getInput("windows_certs_password"));
|
||||
}
|
||||
|
||||
// Disable console advertisements during install phase
|
||||
setEnv("ADBLOCK", true);
|
||||
|
||||
// log(`Installing dependencies using ${useNpm ? "NPM" : "Yarn"}…`);
|
||||
// run(useNpm ? "npm install" : "yarn", pkgRoot);
|
||||
|
||||
// Run NPM build script if it exists
|
||||
if (skipBuild) {
|
||||
log("Skipping build script because `skip_build` option is set");
|
||||
} else {
|
||||
log("Running the build script…");
|
||||
if (useNpm) {
|
||||
run(`npm run ${buildScriptName} --if-present`, pkgRoot);
|
||||
} else {
|
||||
// TODO: Use `yarn run ${buildScriptName} --if-present` once supported
|
||||
// https://github.com/yarnpkg/yarn/issues/6894
|
||||
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
|
||||
if (pkgJson.scripts && pkgJson.scripts[buildScriptName]) {
|
||||
run(`yarn run ${buildScriptName}`, pkgRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log(`Building${release ? " and releasing" : ""} the Electron app…`);
|
||||
const cmd = useVueCli ? "vue-cli-service electron:build" : `electron-builder`;
|
||||
for (let i = 0; i < maxAttempts; i += 1) {
|
||||
try {
|
||||
run(
|
||||
`${useNpm ? "npx --no-install" : "yarn run"} ${cmd} --${platform} ${
|
||||
release ? "--publish always" : ""
|
||||
} ${args}`,
|
||||
appRoot,
|
||||
);
|
||||
break;
|
||||
} catch (err) {
|
||||
if (i < maxAttempts - 1) {
|
||||
log(`Attempt ${i + 1} failed:`);
|
||||
log(err);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
runAction();
|
38
updater/.gitlab/workflows/build.yml
Normal file
38
updater/.gitlab/workflows/build.yml
Normal file
@ -0,0 +1,38 @@
|
||||
name: Build/release
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Install Node.js, NPM and Yarn
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14
|
||||
|
||||
- name: Installing dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Tsc
|
||||
run: npx tsc
|
||||
|
||||
- name: Build/release Electron app
|
||||
uses: ./.github/actions/release
|
||||
with:
|
||||
skip_build: false
|
||||
# GitHub token, automatically provided to the action
|
||||
# (No need to define this secret in the repo settings)
|
||||
github_token: ${{ secrets.DEPLOY_TOKEN }}
|
||||
|
||||
# If the commit is tagged with a version (e.g. "v1.0.0"),
|
||||
# release the app after building
|
||||
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
11392
updater/package-lock.json
generated
Normal file
11392
updater/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -45,6 +45,9 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@octokit/core": "^4.0.5",
|
||||
"decompress-zip": "^0.3.3",
|
||||
"electron-dl": "^3.3.1",
|
||||
"electron-squirrel-startup": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -53,6 +56,6 @@
|
||||
"@electron-forge/maker-rpm": "^6.0.0-beta.66",
|
||||
"@electron-forge/maker-squirrel": "^6.0.0-beta.66",
|
||||
"@electron-forge/maker-zip": "^6.0.0-beta.66",
|
||||
"electron": "20.1.4"
|
||||
"electron": "^21.0.1"
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
|
||||
Arial, sans-serif;
|
||||
margin: auto;
|
||||
max-width: 38rem;
|
||||
padding: 2rem;
|
||||
}
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
||||
margin: auto;
|
||||
max-width: 38rem;
|
||||
padding: 2rem;
|
||||
}
|
@ -6,7 +6,16 @@
|
||||
<link rel="stylesheet" href="index.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
<p>Welcome to your Electron application.</p>
|
||||
<button id="download" class"button is-primary">Download</button>
|
||||
<button id="dirs">Open</button>
|
||||
|
||||
<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>
|
||||
<script src="./renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,29 +1,55 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const { app, BrowserWindow, dialog, ipcMain } = require('electron');
|
||||
const { download } = require("electron-dl");
|
||||
const path = require('path');
|
||||
//Menu.setApplicationMenu(false); // Top Bar removal
|
||||
var fs = require('fs');
|
||||
|
||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||
// eslint-disable-next-line global-require
|
||||
if (require('electron-squirrel-startup')) {
|
||||
app.quit();
|
||||
app.quit();
|
||||
}
|
||||
|
||||
const createWindow = () => {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
},
|
||||
});
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
nodeIntegrationInWorker: true,
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
},
|
||||
});
|
||||
mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
||||
mainWindow.webContents.openDevTools();
|
||||
|
||||
// Select Directory
|
||||
ipcMain.on('select-dirs', async(event, arg) => {
|
||||
const result = await dialog.showOpenDialog(mainWindow, {
|
||||
properties: ['openDirectory']
|
||||
})
|
||||
console.log('directories selected', result.filePaths)
|
||||
})
|
||||
|
||||
// Download a file
|
||||
ipcMain.on("download", (event, info) => {
|
||||
// https://dms.pabr.de/s/SpBiQYADTNak7R5/download
|
||||
info.properties.onProgress = status => mainWindow.webContents.send("download progress", status);
|
||||
download(BrowserWindow.getFocusedWindow(), info.url, info.properties)
|
||||
.then(dl => mainWindow.webContents.send("download complete", dl.getSavePath()));
|
||||
});
|
||||
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
||||
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
@ -33,18 +59,24 @@ 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', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and import them here.
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
});
|
1
updater/src/preload.js
Normal file
1
updater/src/preload.js
Normal file
@ -0,0 +1 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
38
updater/src/renderer.js
Normal file
38
updater/src/renderer.js
Normal file
@ -0,0 +1,38 @@
|
||||
const { ipcRenderer, dialog } = require('electron');
|
||||
|
||||
ipcRenderer.on("download complete", (event, file) => {
|
||||
console.log(file); // Full file path
|
||||
// Datei entpacken
|
||||
});
|
||||
|
||||
ipcRenderer.on("download progress", (event, progress) => {
|
||||
const cleanProgressInPercentages = Math.floor(progress.percent * 100); // Without decimal point
|
||||
document.getElementById('progressbar').value = cleanProgressInPercentages;
|
||||
});
|
||||
|
||||
let donwloadbtn = document.getElementById('download');
|
||||
donwloadbtn.addEventListener('click', (e) => {
|
||||
let directoryPath = document.getElementById('dirBox');
|
||||
let urlPath = document.getElementById('urlBox');
|
||||
ipcRenderer.send("download", {
|
||||
url: urlPath.value,
|
||||
properties: { directory: directoryPath.value }
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
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)
|
||||
})
|
5121
updater/yarn.lock
5121
updater/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user