Skip to content

Commit

Permalink
Fix unity versions scrapping not getting all the versions
Browse files Browse the repository at this point in the history
  • Loading branch information
brako committed Oct 11, 2024
1 parent e3d917f commit ffdde86
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions functions/src/logic/ingestUnityVersions/scrapeVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ export const scrapeVersions = async (): Promise<EditorVersionInfo[]> => {

const scripts = document.querySelectorAll('script');

const allVersions = new Map<string, EditorVersionInfo>();

for (const script of scripts) {
if (script.textContent) {
const matches = [...script.textContent.matchAll(unity_version_regex)];
if (matches.length > 0) {
const uniqueVersions = new Set<string>();
return matches
const versions = matches
.filter((match) => {
// Filter out prerelease and unsupported versions
const [_, major, minor, patch, changeSet] = match;
Expand All @@ -23,8 +24,7 @@ export const scrapeVersions = async (): Promise<EditorVersionInfo[]> => {
.map((match) => {
const [_, major, minor, patch, changeSet] = match;
const version = `${major}.${minor}.${patch}`;
if (!uniqueVersions.has(version)) {
uniqueVersions.add(version);
if (!allVersions.has(version)) {
return {
version,
changeSet,
Expand All @@ -38,9 +38,17 @@ export const scrapeVersions = async (): Promise<EditorVersionInfo[]> => {
return null;
})
.filter((version) => version !== null) as EditorVersionInfo[];

versions.forEach((it) => {
allVersions.set(it.version, it);
});
}
}
}

if (allVersions.size > 0) {
return Array.from(allVersions.values());
}

throw new Error('No Unity versions found!');
};

0 comments on commit ffdde86

Please sign in to comment.