Skip to content

Commit ec62f15

Browse files
committed
Updates downloads
1 parent e65e424 commit ec62f15

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@sveltejs/adapter-node": "^5.2.8",
1515
"@sveltejs/kit": "^2.7.2",
1616
"@sveltejs/vite-plugin-svelte": "^3.1.2",
17+
"@types/semver": "^7.5.8",
1718
"mdsvex": "^0.12.3",
1819
"postcss": "^8.4.47",
1920
"postcss-import": "^15.1.0",
@@ -26,5 +27,8 @@
2627
"unist-util-visit": "^4.1.2",
2728
"vite": "^5.4.9"
2829
},
29-
"type": "module"
30+
"type": "module",
31+
"dependencies": {
32+
"semver": "^7.6.3"
33+
}
3034
}

src/lib/components/info.svelte

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
<script lang="ts">
22
import type { Stats } from "$lib/stats";
3+
import semver from "semver";
34
45
export let stats: Stats;
56
67
function prettyNumber(x: number) {
78
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
89
}
10+
11+
function getLatestVersion(): string {
12+
let latest = "0.0.0";
13+
14+
for (const version of Object.keys(stats.builds)) {
15+
if (semver.gt(version, latest)) {
16+
latest = version;
17+
}
18+
}
19+
20+
return latest;
21+
}
922
</script>
1023

1124
<div class="container">
@@ -15,8 +28,7 @@
1528
<p>Online Players: {prettyNumber(stats.onlinePlayers)}</p>
1629

1730
<div class="buttons">
18-
<a href="https://adfoc.us/81926897739205" target="_blank" class="button"><img src="/icons/download.svg" alt="download"> Release {stats.version} [{stats.mcVersion}]</a>
19-
<a href="https://adfoc.us/819268106314032" target="_blank" class="button"><img src="/icons/download.svg" alt="download"> Dev Build {stats.devBuildVersion} [{stats.devBuildMcVersion}]</a>
31+
<a href="https://adfoc.us/81926897739205" target="_blank" class="button"><img src="/icons/download.svg" alt="download"> Meteor Client [{getLatestVersion()} - {stats.builds[getLatestVersion()]}]</a>
2032
<p>If you're looking for older versions of Meteor, read <a href="/faq/old-versions">this</a>.</p>
2133
<a href="/api/downloadBaritone" target="_blank" class="button"><img src="/icons/download.svg" alt="download"> *Baritone [{stats.baritoneMcVersion}]</a>
2234
</div>

src/lib/stats.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
export interface Stats {
2-
version: string;
3-
devBuildVersion: string;
1+
export interface Builds {
2+
[version: string]: number;
3+
}
44

5-
mcVersion: string;
6-
devBuildMcVersion: string;
5+
export interface Stats {
6+
builds: Builds;
77
baritoneMcVersion: string;
88

99
downloads: number;
@@ -14,11 +14,7 @@ export async function fetchStats(fetch: any): Promise<Stats> {
1414
let stats = await (await fetch("https://meteorclient.com/api/stats")).json();
1515

1616
return {
17-
version: stats.version,
18-
devBuildVersion: stats.dev_build_version,
19-
20-
mcVersion: stats.mc_version,
21-
devBuildMcVersion: stats.dev_build_mc_version,
17+
builds: stats.builds,
2218
baritoneMcVersion: stats.baritone_mc_version,
2319

2420
downloads: stats.downloads,

src/routes/download/+server.ts

-5
This file was deleted.

0 commit comments

Comments
 (0)