From 3c1f7243d8635822dc56a0eb27145fd37abb8232 Mon Sep 17 00:00:00 2001 From: Evorp <3vorpgaming@gmail.com> Date: Sun, 10 Dec 2023 11:59:41 -0800 Subject: [PATCH] slightly improve version sorting --- src/helpers/choiceEmbed.ts | 2 +- src/helpers/functions/missing.ts | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/helpers/choiceEmbed.ts b/src/helpers/choiceEmbed.ts index 7a5a8167..75447a8a 100644 --- a/src/helpers/choiceEmbed.ts +++ b/src/helpers/choiceEmbed.ts @@ -75,7 +75,7 @@ export async function textureChoiceEmbed( const mappedResults: SelectMenuComponentOptionData[] = []; for (const result of results) { mappedResults.push({ - label: `[#${result.id}] (${result.paths[0].versions.sort(minecraftSorter).reverse()[0]}) ${ + label: `[#${result.id}] (${result.paths[0].versions.sort(minecraftSorter).at(-1)}) ${ result.name }`, description: result.paths[0].name, diff --git a/src/helpers/functions/missing.ts b/src/helpers/functions/missing.ts index 8070e2cc..10736136 100644 --- a/src/helpers/functions/missing.ts +++ b/src/helpers/functions/missing.ts @@ -8,6 +8,7 @@ import { join, normalize } from "path"; import blacklistedTextures from "@json/blacklisted_textures.json"; import axios from "axios"; import { FaithfulPack } from "@interfaces/firestorm"; +import minecraftSorter from "@utility/minecraftSorter"; // starting from process.cwd() export const BASE_REPOS_PATH = "repos"; @@ -59,7 +60,7 @@ export async function computeMissingResults( const defaultPath = join(basePath, getNameFromGit(defaultRepo)); const requestPath = join(basePath, getNameFromGit(requestRepo)); - // CLONE REPO IF NOT ALREADY CLONED + // clone repos if not already done (saves a lot of init lol) if (!existsSync(defaultPath)) { await callback(`Downloading default ${edition} pack...`); mkdirSync(defaultPath, { recursive: true }); @@ -76,9 +77,10 @@ export async function computeMissingResults( await axios.get(`${client.tokens.apiUrl}textures/versions/${edition}`) ).data; // latest version if versions doesn't include version (unexisting/unsupported) - if (!versions.includes(version)) version = versions[0]; + if (!versions.includes(version)) version = versions.sort(minecraftSorter).at(-1); await callback(`Updating packs with latest version of \`${version}\` known...`); + // same steps are used for both packs const steps = [ "git stash", "git remote update", @@ -87,16 +89,10 @@ export async function computeMissingResults( `git pull`, ]; - // same steps, just with different packs - await Promise.all([ - series(structuredClone(steps), { - cwd: defaultPath, - }), - series(structuredClone(steps), { - cwd: requestPath, - }), - ]); + await series(structuredClone(steps), { cwd: defaultPath }); + await series(structuredClone(steps), { cwd: requestPath }); + // now both repos are pointing to the same version and are ready to compare await callback("Searching for differences..."); const editionFilter = blacklistedTextures[edition].map(normalize);