4
0
mirror of https://github.com/AltarikMC/Launcher synced 2024-11-21 06:09:51 +01:00

dump to snapshot

This commit is contained in:
Quentin Legot 2021-02-07 17:34:57 +01:00
parent c2a512883d
commit ad8103bc64
4 changed files with 80 additions and 64 deletions

35
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "altarik-launcher", "name": "altarik-launcher",
"version": "0.1.0", "version": "0.1.1-SNPASHOT",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1400,9 +1400,9 @@
} }
}, },
"electron-is-dev": { "electron-is-dev": {
"version": "0.3.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/electron-is-dev/-/electron-is-dev-0.3.0.tgz", "resolved": "https://registry.npmjs.org/electron-is-dev/-/electron-is-dev-1.2.0.tgz",
"integrity": "sha1-FOb9pcaOnk7L7/nM8DfL18BcWv4=" "integrity": "sha512-R1oD5gMBPS7PVU8gJwH6CtT0e6VSoD0+SzSnYpNm+dBkcijgA+K7VAMHDfnRq/lkKPZArpzplTW6jfiMYosdzw=="
}, },
"electron-notarize": { "electron-notarize": {
"version": "1.0.0", "version": "1.0.0",
@ -2298,14 +2298,6 @@
"assert-plus": "^1.0.0" "assert-plus": "^1.0.0"
} }
}, },
"github-url-to-object": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/github-url-to-object/-/github-url-to-object-4.0.4.tgz",
"integrity": "sha512-1Ri1pR8XTfzLpbtPz5MlW/amGNdNReuExPsbF9rxLsBfO1GH9RtDBamhJikd0knMWq3RTTQDbTtw0GGvvEAJEA==",
"requires": {
"is-url": "^1.1.0"
}
},
"glob": { "glob": {
"version": "7.1.6", "version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
@ -2637,11 +2629,6 @@
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
}, },
"is-url": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz",
"integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww=="
},
"is-utf8": { "is-utf8": {
"version": "0.2.1", "version": "0.2.1",
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
@ -3091,7 +3078,8 @@
"ms": { "ms": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
}, },
"mute-stream": { "mute-stream": {
"version": "0.0.8", "version": "0.0.8",
@ -4520,17 +4508,6 @@
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"dev": true "dev": true
}, },
"update-electron-app": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/update-electron-app/-/update-electron-app-2.0.1.tgz",
"integrity": "sha512-e4xEner89UZZaBGYJbYlMdL1uUrC0VjOsTAL2N4opPjzFtn+j7mdsJJsnyXZzUVeLY+8tuCX4XEsUM98oBHmZg==",
"requires": {
"electron-is-dev": "^0.3.0",
"github-url-to-object": "^4.0.4",
"is-url": "^1.2.4",
"ms": "^2.1.1"
}
},
"uri-js": { "uri-js": {
"version": "4.4.0", "version": "4.4.0",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz",

View File

@ -1,8 +1,9 @@
{ {
"name": "altarik-launcher", "name": "altarik-launcher",
"version": "0.1.0", "version": "0.1.1-SNAPSHOT",
"description": "Altarik Launcher", "description": "Altarik Launcher",
"main": "src/server/main.js", "main": "src/server/main.js",
"repository": "AltarikMC/Launcher",
"scripts": { "scripts": {
"start": "electron-forge start", "start": "electron-forge start",
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
@ -18,9 +19,9 @@
"electron": "^11.2.3" "electron": "^11.2.3"
}, },
"dependencies": { "dependencies": {
"electron-is-dev": "^1.2.0",
"electron-squirrel-startup": "^1.0.0", "electron-squirrel-startup": "^1.0.0",
"minecraft-launcher-core": "^3.16.1", "minecraft-launcher-core": "^3.16.1"
"update-electron-app": "^2.0.1"
}, },
"config": { "config": {
"forge": "./config.forge.js" "forge": "./config.forge.js"

View File

@ -4,38 +4,8 @@ if (require('electron-squirrel-startup')) {
require("./install.js").handleSquirrelEvent(app) require("./install.js").handleSquirrelEvent(app)
app.quit() app.quit()
} }
const server = 'https://update.electronjs.org' // don't work
const feed = `${server}/OWNER/REPO/${process.platform}-${process.arch}/${app.getVersion()}` //require('./updater.js').configUpdater(app, autoUpdater, dialog)
autoUpdater.setFeedURL(feed)
setInterval(() => {
autoUpdater.checkForUpdates()
}, 10 * 60 * 1000) // 10 minutes
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
const dialogOpts = {
type: 'info',
buttons: ['Rédémarrer', 'Plus tard'],
title: 'Une mise à jour du launcher est disponible',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'Une nouvelle version du launcher a été téléchargé. Redémarrez l\'application pour appliquer les mises à jour.'
}
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) autoUpdater.quitAndInstall()
})
})
autoUpdater.on('error', message => {
console.error('There was a problem updating the application')
console.error(message)
const dialogOpts = {
type: 'info',
buttons: ['Fermer'],
title: 'Erreur lors de la tentetive de mise à jour de l\'application',
message: "Une Erreur est survenur de lros de la mise à jour du launcher"
}
dialog.showMessageBox(dialogOpts)
})
const { Client, Authenticator } = require('minecraft-launcher-core') const { Client, Authenticator } = require('minecraft-launcher-core')
const appdata = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Preferences' : process.env.HOME + "/.local/share") const appdata = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Preferences' : process.env.HOME + "/.local/share")

68
src/server/updater.js Normal file
View File

@ -0,0 +1,68 @@
const isDev = require('electron-is-dev')
const { Notification } = require('electron')
const os = require('os')
const pkg = require('../../package.json')
const { format } = require('util')
const server = 'https://update.electronjs.org'
function initUpdater(autoUpdater) {
autoUpdater.checkForUpdates()
setInterval(() => {
autoUpdater.checkForUpdates()
}, 10 * 60 * 1000) // 10 minutes
}
function configUpdater(app, autoUpdater, dialog) {
if(isDev)
return
const feed = `${server}/${pkg.repository}/${process.platform}-${process.arch}/${app.getVersion()}`
autoUpdater.setFeedURL(feed)
app.isReady ? initUpdater(autoUpdater) : app.on("ready", () => initUpdater(autoUpdater))
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName, releaseDate, updateURL) => {
showNotification(releaseNotes, updateURL)
const dialogOpts = {
type: 'info',
buttons: ['Rédémarrer', 'Plus tard'],
title: 'Une mise à jour du launcher est disponible',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'Une nouvelle version du launcher a été téléchargé. Redémarrez l\'application pour appliquer les mises à jour.'
}
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) autoUpdater.quitAndInstall()
})
})
autoUpdater.on('error', message => {
console.error('There was a problem updating the application')
console.error(message)
showNotification(feed)
const dialogOpts = {
type: 'info',
buttons: ['Fermer'],
title: 'Erreur lors de la tentative de mise à jour du launcher',
message: "Une erreur est survenue lros de la tentative de mise à jour du launcher",
detail: message
}
dialog.showMessageBox(dialogOpts)
})
autoUpdater.on('update-available', () => {
showNotification("Altarik launcher", "downloading update")
})
}
function showNotification(title, body="") {
const content = {
title: title,
body: body
}
new Notification(content).show()
}
module.exports = {
configUpdater
}