mirror of
https://github.com/AltarikMC/Launcher
synced 2024-11-22 06:19:50 +01:00
removed axios in favor to node-fetch
This commit is contained in:
parent
cb37aa7eee
commit
0a32249782
42
package-lock.json
generated
42
package-lock.json
generated
@ -12,7 +12,6 @@
|
|||||||
"win32"
|
"win32"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.26.0",
|
|
||||||
"electron-is-dev": "^2.0.0",
|
"electron-is-dev": "^2.0.0",
|
||||||
"electron-log": "^4.4.6",
|
"electron-log": "^4.4.6",
|
||||||
"electron-squirrel-startup": "^1.0.0",
|
"electron-squirrel-startup": "^1.0.0",
|
||||||
@ -21,6 +20,7 @@
|
|||||||
"izitoast": "^1.4.0",
|
"izitoast": "^1.4.0",
|
||||||
"minecraft-launcher-core": "^3.16.12",
|
"minecraft-launcher-core": "^3.16.12",
|
||||||
"msmc": "^3.0.6",
|
"msmc": "^3.0.6",
|
||||||
|
"node-fetch": "^2.6.7",
|
||||||
"vue": "^3.2.31"
|
"vue": "^3.2.31"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -1337,14 +1337,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz",
|
||||||
"integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA=="
|
"integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA=="
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
|
||||||
"version": "0.26.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.26.0.tgz",
|
|
||||||
"integrity": "sha512-lKoGLMYtHvFrPVt3r+RBMp9nh34N0M8zEfCWqdWZx6phynIEhQqAdydpyBAAG211zlhX9Rgu08cOamy6XjE5Og==",
|
|
||||||
"dependencies": {
|
|
||||||
"follow-redirects": "^1.14.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/balanced-match": {
|
"node_modules/balanced-match": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||||
@ -3137,25 +3129,6 @@
|
|||||||
"node": ">=6 <7 || >=8"
|
"node": ">=6 <7 || >=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/follow-redirects": {
|
|
||||||
"version": "1.14.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
|
||||||
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==",
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "individual",
|
|
||||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"debug": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/forever-agent": {
|
"node_modules/forever-agent": {
|
||||||
"version": "0.6.1",
|
"version": "0.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
|
||||||
@ -7981,14 +7954,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz",
|
||||||
"integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA=="
|
"integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA=="
|
||||||
},
|
},
|
||||||
"axios": {
|
|
||||||
"version": "0.26.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.26.0.tgz",
|
|
||||||
"integrity": "sha512-lKoGLMYtHvFrPVt3r+RBMp9nh34N0M8zEfCWqdWZx6phynIEhQqAdydpyBAAG211zlhX9Rgu08cOamy6XjE5Og==",
|
|
||||||
"requires": {
|
|
||||||
"follow-redirects": "^1.14.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||||
@ -9368,11 +9333,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"follow-redirects": {
|
|
||||||
"version": "1.14.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
|
||||||
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w=="
|
|
||||||
},
|
|
||||||
"forever-agent": {
|
"forever-agent": {
|
||||||
"version": "0.6.1",
|
"version": "0.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
"electron": "^18.0.0"
|
"electron": "^18.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.26.0",
|
|
||||||
"electron-is-dev": "^2.0.0",
|
"electron-is-dev": "^2.0.0",
|
||||||
"electron-log": "^4.4.6",
|
"electron-log": "^4.4.6",
|
||||||
"electron-squirrel-startup": "^1.0.0",
|
"electron-squirrel-startup": "^1.0.0",
|
||||||
@ -41,6 +40,7 @@
|
|||||||
"izitoast": "^1.4.0",
|
"izitoast": "^1.4.0",
|
||||||
"minecraft-launcher-core": "^3.16.12",
|
"minecraft-launcher-core": "^3.16.12",
|
||||||
"msmc": "^3.0.6",
|
"msmc": "^3.0.6",
|
||||||
|
"node-fetch": "^2.6.7",
|
||||||
"vue": "^3.2.31"
|
"vue": "^3.2.31"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
@ -35,6 +35,9 @@ app = vue.createApp({
|
|||||||
position: 'topRight',
|
position: 'topRight',
|
||||||
resetOnHover: true,
|
resetOnHover: true,
|
||||||
})
|
})
|
||||||
|
setInterval(() => {
|
||||||
|
ipcRenderer.send("pageReady")
|
||||||
|
}, 500)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
invalidateData () {
|
invalidateData () {
|
||||||
@ -150,10 +153,6 @@ ipcRenderer.on('launch', (_e, _args) => {
|
|||||||
root.loadingMessageHidden = true
|
root.loadingMessageHidden = true
|
||||||
})
|
})
|
||||||
|
|
||||||
setInterval(() => {
|
|
||||||
ipcRenderer.send("pageReady")
|
|
||||||
}, 500)
|
|
||||||
|
|
||||||
ipcRenderer.on("modsInformations", (_e, args) => {
|
ipcRenderer.on("modsInformations", (_e, args) => {
|
||||||
if(args === null) {
|
if(args === null) {
|
||||||
root.modsInformationsLoaded = false
|
root.modsInformationsLoaded = false
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// const {default: iziToast } = require('izitoast')
|
|
||||||
|
|
||||||
app = vue.createApp({
|
app = vue.createApp({
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const { app, BrowserWindow, Menu, ipcMain, autoUpdater, dialog } = require('electron')
|
const { app, BrowserWindow, Menu, ipcMain, autoUpdater, dialog } = require('electron')
|
||||||
const logger = require('electron-log')
|
const logger = require('electron-log')
|
||||||
const { join } = require('path')
|
const { join } = require('path')
|
||||||
|
|
||||||
if (require('electron-squirrel-startup')) {
|
if (require('electron-squirrel-startup')) {
|
||||||
require("./install.js").handleSquirrelEvent(app)
|
require("./install.js").handleSquirrelEvent(app)
|
||||||
app.quit()
|
app.quit()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const isDev = require('electron-is-dev')
|
const isDev = require('electron-is-dev')
|
||||||
const { Client, Authenticator } = require('minecraft-launcher-core')
|
const { Client, Authenticator } = require('minecraft-launcher-core')
|
||||||
const axios = require('axios').default
|
const fetch = require('node-fetch').default
|
||||||
const hasha = require('hasha');
|
const hasha = require('hasha')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const { join } = require('path')
|
const { join } = require('path')
|
||||||
const constants = require("constants")
|
const constants = require("constants")
|
||||||
@ -128,17 +128,25 @@ class Minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getModsInformations(event) {
|
getModsInformations(event) {
|
||||||
axios.get("https://altarik.fr/launcher.json").then(o => {
|
fetch("https://altarik.fr/launcher.json").then(response => {
|
||||||
if(o.status === 200 && o.headers["content-type"] === "application/json") {
|
if(response.ok) {
|
||||||
let folder = join(process.env.LOCALAPPDATA, "altarik-launcher", "data")
|
response.json().then(data => {
|
||||||
if(!fs.existsSync(folder))
|
let folder = join(process.env.LOCALAPPDATA, "altarik-launcher", "data")
|
||||||
fs.mkdirSync(folder, {recursive: true})
|
if(!fs.existsSync(folder))
|
||||||
let file = join(folder, "launcher.json")
|
fs.mkdirSync(folder, {recursive: true})
|
||||||
if(fs.existsSync(file))
|
let file = join(folder, "launcher.json")
|
||||||
fs.rmSync(file)
|
if(fs.existsSync(file))
|
||||||
fs.writeFileSync(file, JSON.stringify(o.data))
|
fs.rmSync(file)
|
||||||
event.sender.send('modsInformations', this.extractModsInformations(o.data))
|
fs.writeFileSync(file, JSON.stringify(data))
|
||||||
|
event.sender.send('modsInformations', this.extractModsInformations(data))
|
||||||
|
}).catch(err => {
|
||||||
|
event.sender.send('modsInformations', this.extractModsFromFileSystem())
|
||||||
|
logger.warn(err)
|
||||||
|
logger.warn("An error occured while trying to connect to server")
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
|
logger.warn("Unable to connect to server")
|
||||||
|
logger.warn(err)
|
||||||
event.sender.send('modsInformations', this.extractModsFromFileSystem())
|
event.sender.send('modsInformations', this.extractModsFromFileSystem())
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
@ -222,17 +230,21 @@ class Minecraft {
|
|||||||
|
|
||||||
downloadMods(link, path) {
|
downloadMods(link, path) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.get(link, {responseType: "stream"}).then(res => {
|
fetch(link).then(response => {
|
||||||
if(res.status === 200) {
|
if(response.ok) {
|
||||||
if(fs.existsSync(path))
|
if(fs.existsSync(path))
|
||||||
fs.rmSync(path)
|
fs.rmSync(path)
|
||||||
res.data.pipe(fs.createWriteStream(path));
|
const dest = fs.createWriteStream(path)
|
||||||
res.data.on("end", () => {
|
response.body.pipe(dest)
|
||||||
|
response.body.on("end", () => {
|
||||||
logger.log("download completed");
|
logger.log("download completed");
|
||||||
resolve("download completed")
|
resolve("download completed")
|
||||||
})
|
})
|
||||||
|
dest.on("error", () => {
|
||||||
|
reject("An error appenned when using stream")
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
reject(res.status)
|
reject(response.status)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
reject(err)
|
reject(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user