Skip to content

Commit cbfb001

Browse files
committed
fix: most recent patch version not listed
1 parent 4103997 commit cbfb001

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/index.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { UnityChangeset } from "./unityChangeset.ts";
2+
import { distinctBy, sortBy } from "https://deno.land/std@0.180.0/collections/mod.ts";
23

34
const REGEXP_HUB_LINKS = /unityhub:\/\/\d{4}\.\d+\.\d+(a|b|f)\d+\/\w{12}/g;
45
const UNITY_ARCHIVE_URL = "https://unity3d.com/get-unity/download/archive";
56
const UNITY_ALPHA_URL = "https://unity3d.com/unity/alpha/";
67
const UNITY_BETA_URL = "https://unity3d.com/unity/beta/";
7-
const UNITY_RSS_URL = "https://unity3d.com/unity/beta/latest.xml";
8+
const UNITY_RSS_URL = "https://unity.com/releases/editor/releases.xml";
9+
const UNITY_BETA_RSS_URL = "https://unity3d.com/unity/beta/latest.xml";
810

911
/*
1012
* Get an Unity changeset from specific Unity version.
@@ -18,7 +20,7 @@ export async function getUnityChangeset(
1820
const lifecycle = match?.[1] as string;
1921
switch (lifecycle) {
2022
case "f":
21-
return (await getUnityChangesetsFromUrl(UNITY_ARCHIVE_URL))
23+
return (await scrapeArchivedChangesets())
2224
.filter((c) => c.version === version)[0];
2325
case "a":
2426
return (await getUnityChangesetsFromUrl(UNITY_ALPHA_URL + version))
@@ -37,16 +39,22 @@ export async function getUnityChangeset(
3739
* Scrape the archived Unity changesets from Unity archives.
3840
* @returns The Unity changesets.
3941
*/
40-
export function scrapeArchivedChangesets(): Promise<UnityChangeset[]> {
41-
return getUnityChangesetsFromUrl(UNITY_ARCHIVE_URL);
42+
export async function scrapeArchivedChangesets(): Promise<UnityChangeset[]> {
43+
const changesets = (await getUnityChangesetsFromUrl(UNITY_ARCHIVE_URL))
44+
.concat(await getUnityChangesetsFromUrl(UNITY_RSS_URL));
45+
46+
return sortBy(
47+
distinctBy(changesets, (c) => c.versionNumber),
48+
(c) => -c.versionNumber,
49+
);
4250
}
4351

4452
/*
4553
* Scrape the alpha/beta Unity changesets from Unity RSS feed.
4654
* @returns The Unity changesets (alpha/beta).
4755
*/
4856
export function scrapeBetaChangesets(): Promise<UnityChangeset[]> {
49-
return getUnityChangesetsFromUrl(UNITY_RSS_URL);
57+
return getUnityChangesetsFromUrl(UNITY_BETA_RSS_URL);
5058
}
5159

5260
async function getUnityChangesetsFromUrl(

0 commit comments

Comments
 (0)