feat: get versions

This commit is contained in:
Artemy 2023-06-18 18:52:39 +03:00
parent dfa54d3f65
commit 4a5b47e054
4 changed files with 90 additions and 4 deletions

36
components/utils.js Normal file
View file

@ -0,0 +1,36 @@
const axios = require("axios");
async function getVersions() {
return (
await axios.get(
"https://launchermeta.mojang.com/mc/game/version_manifest_v2.json"
)
).data.versions;
}
async function getLatestVersion() {
return getVersions()[0];
}
async function getLatestRelease() {
return (
await axios.get(
"https://launchermeta.mojang.com/mc/game/version_manifest_v2.json"
)
).data.latest.release;
}
async function getLatestSnapshot() {
return (
await axios.get(
"https://launchermeta.mojang.com/mc/game/version_manifest_v2.json"
)
).data.latest.snapshot;
}
module.exports = {
getVersions,
getLatestVersion,
getLatestRelease,
getLatestSnapshot,
};

View file

@ -1,4 +1,5 @@
module.exports = {
Client: require('./components/launcher'),
Authenticator: require('./components/authenticator')
}
Client: require("./components/launcher"),
Authenticator: require("./components/authenticator"),
utils: require("./components/utils"),
};

48
package-lock.json generated
View file

@ -10,6 +10,7 @@
"license": "MIT",
"dependencies": {
"adm-zip": "^0.4.13",
"axios": "^1.4.0",
"checksum": "^0.1.1",
"request": "^2.88.0",
"uuid": "^8.3.2"
@ -295,6 +296,29 @@
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz",
"integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg=="
},
"node_modules/axios": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
"dependencies": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/axios/node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -1138,6 +1162,25 @@
"integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==",
"dev": true
},
"node_modules/follow-redirects": {
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/for-each": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
@ -2229,6 +2272,11 @@
"node": ">=0.4.0"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/psl": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",

View file

@ -1,11 +1,12 @@
{
"name": "pimi-launcher-core",
"version": "1.0.0",
"version": "1.1.0",
"description": "Core for pimi-launcher (Minecraft)",
"main": "index.js",
"types": "./index.d.ts",
"dependencies": {
"adm-zip": "^0.4.13",
"axios": "^1.4.0",
"checksum": "^0.1.1",
"request": "^2.88.0",
"uuid": "^8.3.2"