First try implements AutoUpdate
This commit is contained in:
parent
aeb0ba6320
commit
8701ea5d4a
14
main.js
14
main.js
@ -4,8 +4,7 @@ const fs = require("fs")
|
||||
const ipc = ipcMain
|
||||
const { io } = require("socket.io-client");
|
||||
const log = require("./sublog");
|
||||
const { platform } = require("os");
|
||||
|
||||
const updater = require("./updatetools")
|
||||
|
||||
// [Function] Main Window Function
|
||||
// BUILDER "build": "
|
||||
@ -31,7 +30,14 @@ async function createWindow() {
|
||||
|
||||
})
|
||||
|
||||
if(process.env.DEV != "true") {
|
||||
|
||||
updater.checkUpdate()
|
||||
|
||||
} else {
|
||||
|
||||
log.update("Desactivation des mises a jour -> DEV MOD ENABLE")
|
||||
}
|
||||
|
||||
await win.loadFile("templates/login/login.html")
|
||||
|
||||
@ -373,8 +379,10 @@ app.whenReady().then(() => {
|
||||
|
||||
//[Operation] - Check settings
|
||||
|
||||
createWindow()
|
||||
log.client("Submanager - Version : " + require("./package.json").version + " - Raphix")
|
||||
log.client("Starting Application")
|
||||
createWindow()
|
||||
|
||||
|
||||
app.on('activate', () => {
|
||||
|
||||
|
878
package-lock.json
generated
878
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,12 @@
|
||||
{
|
||||
"name": "subsonics-manager",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"description": "Manager for subsonics",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"dev": "set DEV=true& electron .",
|
||||
"build": "electron-packager . submanager-app --platform='win32' --out='./dist/' --icon='./src/logo.ico' --overwrite --ignore='(settings.json)'"
|
||||
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -17,13 +16,11 @@
|
||||
"author": "Raphix",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"decompress": "^4.2.1",
|
||||
"socket.io-client": "^4.6.1"
|
||||
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^24.1.2",
|
||||
"electron-packager": "^17.1.1"
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
38
sublog.js
38
sublog.js
@ -74,3 +74,41 @@ module.exports.client.error = (message) => {
|
||||
console.error("[Subsonics-Client] - [ERROR] - " + currentDate + " - " + message)
|
||||
}
|
||||
|
||||
module.exports.update = (message) => {
|
||||
|
||||
var date = new Date()
|
||||
|
||||
// [Date Format] - Format de la date
|
||||
|
||||
var gmonth = date.getMonth()
|
||||
var gday = date.getDate()
|
||||
var gHour = date.getHours()
|
||||
var gMinute = date.getMinutes()
|
||||
var gSecondes = date.getSeconds()
|
||||
|
||||
|
||||
if(date.getMonth() + 1 <= 9) {
|
||||
gmonth = "0" + (date.getMonth() + 1)
|
||||
}
|
||||
|
||||
if(date.getDate() + 1 <= 9) {
|
||||
gday = "0" + date.getDate()
|
||||
}
|
||||
|
||||
if(date.getHours() + 1 <= 9) {
|
||||
gHour = "0" + date.getHours()
|
||||
}
|
||||
|
||||
if(date.getMinutes() + 1 <= 9) {
|
||||
gMinute = "0" + date.getMinutes()
|
||||
}
|
||||
|
||||
if(date.getSeconds() + 1 <= 9) {
|
||||
gSecondes = "0" + date.getSeconds()
|
||||
}
|
||||
|
||||
var currentDate = date.getFullYear() + "-" + gmonth + "-" + gday + "-" + gHour + "h" + "-" + gMinute + "m" + "-" + gSecondes + "s"
|
||||
|
||||
console.error("[Subsonics-Update] - " + currentDate + " - " + message)
|
||||
}
|
||||
|
||||
|
BIN
templates/common/mettre-a-jour.png
Normal file
BIN
templates/common/mettre-a-jour.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
63
templates/update/update.css
Normal file
63
templates/update/update.css
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
|
||||
.top-title {
|
||||
|
||||
padding: 5% !important;
|
||||
}
|
||||
|
||||
.box {
|
||||
|
||||
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: rgb(38, 37, 37);
|
||||
padding: 10%;
|
||||
color: white;
|
||||
border-radius: 15px;
|
||||
box-shadow: 2px 2px 5px rgb(38, 37, 37) ;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
align-items: center
|
||||
}
|
||||
|
||||
.loading {
|
||||
|
||||
width: 30%;
|
||||
height: 30%;
|
||||
filter: invert(1)
|
||||
|
||||
}
|
||||
|
||||
.loadingRot {
|
||||
|
||||
-webkit-animation: rotating 1s linear infinite;
|
||||
animation: rotating 1s linear infinite;
|
||||
text-align: center;
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
|
||||
.loadingSpan {
|
||||
|
||||
font-size: 20vw;
|
||||
}
|
||||
|
||||
|
||||
.infoSpan {
|
||||
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@-webkit-keyframes rotating {
|
||||
from{
|
||||
-webkit-transform: rotate(0deg);
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to{
|
||||
-webkit-transform: rotate(360deg);
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
34
templates/update/update.html
Normal file
34
templates/update/update.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Submanager - Login</title>
|
||||
<link rel="stylesheet" href="../common/common.css">
|
||||
<link rel="stylesheet" href="update.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<div class="top-title">
|
||||
<h1><img class="top-logo rounded" src="../../src/logo.png" alt="Logo"> Subsonics</h1>
|
||||
</div>
|
||||
</header>
|
||||
<div id="content">
|
||||
<div class="content">
|
||||
<div class="box">
|
||||
<p>Mise à jour de l'application</p>
|
||||
<span id="loadingSpan" class="loadingSpan"><img class="loading" src="../common/mettre-a-jour.png"></span>
|
||||
<br>
|
||||
<p class="infoSpan">Veuillez patienter pendant que l'application se met à jour !</p>
|
||||
<span class="infoSpan"><p>Submanager - Version : <span id="version"></span></p></span>
|
||||
<img style="width: 5%; height: 5%;" class="loadingRot" src="../common/spinner-third-svgrepo-com.svg">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="../common/bundle.js"></script>
|
||||
<script src="update.js"></script>
|
||||
</body>
|
||||
</html>
|
12
templates/update/update.js
Normal file
12
templates/update/update.js
Normal file
@ -0,0 +1,12 @@
|
||||
const {ipcRenderer} = require("electron");
|
||||
const packageJson = require("../../package.json")
|
||||
const ipc = ipcRenderer;
|
||||
const fs = require("fs")
|
||||
|
||||
const minimizeBtn = document.getElementById("minimizeBtn")
|
||||
|
||||
document.getElementById("version").innerHTML = packageJson.version
|
||||
|
||||
|
||||
|
||||
|
71
updatetools.js
Normal file
71
updatetools.js
Normal file
@ -0,0 +1,71 @@
|
||||
const log = require("./sublog")
|
||||
const { BrowserWindow, app } = require("electron")
|
||||
const https = require('https');
|
||||
const fs = require('fs');
|
||||
const BWin = BrowserWindow
|
||||
const path = require("path")
|
||||
const decompress = require('decompress');
|
||||
|
||||
|
||||
module.exports.checkUpdate = () => {
|
||||
|
||||
log.update("Verification des mises a jour ... Processing !")
|
||||
|
||||
fetch("https://git.raphix.fr/subsonics/manager/raw/branch/main/package.json").then(resp => resp.json()).then(resp => checkUpdateProcessing(resp)).catch(err => log.update("Erreur lors de la verification des mises a jour !"))
|
||||
}
|
||||
|
||||
function checkUpdateProcessing(serverPackage) {
|
||||
|
||||
const clientPackage = require("./package")
|
||||
|
||||
if(serverPackage.version.replace(".", "") > clientPackage.version.replace(".", "")) {
|
||||
|
||||
log.update("Verification des mises a jour ... Finish !")
|
||||
log.update("Mise a jour disponible ! Nouvelle version : " + serverPackage.version + " - Client : " + clientPackage.version + " - Git : " + serverPackage.version)
|
||||
update()
|
||||
|
||||
} else {
|
||||
|
||||
log.update("Verification des mises a jour ... Finish !")
|
||||
log.update("Cette version est la derniere version ! - Client : " + clientPackage.version + " - Git : " + serverPackage.version)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
const win = BWin.getFocusedWindow()
|
||||
win.loadFile("templates/update/update.html")
|
||||
|
||||
log.update("Téléchargement de la mise à jour ... Processing !")
|
||||
|
||||
if(fs.existsSync(__dirname + path.sep + "update.tar.gz")) {
|
||||
|
||||
fs.rmSync("update.tar.gz")
|
||||
}
|
||||
|
||||
const updatePack = fs.createWriteStream(__dirname + path.sep + "update.tar.gz");
|
||||
const request = http.get("https://git.raphix.fr/subsonics/manager/archive/main.tar.gz", function(response) {
|
||||
response.pipe(file);
|
||||
|
||||
// after download completed close filestream
|
||||
updatePack.on("finish", () => {
|
||||
updatePack.close();
|
||||
log.update("Téléchargement de la mise à jour ... Finish !")
|
||||
|
||||
install(__dirname + path.sep + "update.tar.gz")
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function install(filename) {
|
||||
decompress(filename, 'tmp').then(files => {
|
||||
console.log('done!');
|
||||
});
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user