Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unity versions scrapping not getting all the versions #54

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!');
};