From 89798104018ae4eee5e2b2a521a73f52463bb0b4 Mon Sep 17 00:00:00 2001 From: jgaribsin Date: Sun, 18 Feb 2024 17:58:08 -0700 Subject: [PATCH] updating modlist, fixed CIT, recursive file downloads - using the modlist from the website - installer creates CIT config file to fix initial launch issue - file downloads now appropriately follow 300 codes for futureproofing --- .gitignore | 1 + package.json | 2 +- src/providers/DownloadFile.ts | 10 +++- src/providers/DownloadMods.ts | 18 +++++++ src/providers/JavaDownload.ts | 67 ++++++++++-------------- src/stores/SourcesStore.ts | 97 +++++++++++++++++++++++++++++------ 6 files changed, 137 insertions(+), 58 deletions(-) diff --git a/.gitignore b/.gitignore index 46070cd..dbf4299 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ yarn-error.log* _archive foo* bar* +/reports/* diff --git a/package.json b/package.json index 969cc97..23cf6d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "drehmal-installer", - "version": "0.3.0", + "version": "0.3.1", "description": "Drehmal, Minecraft map installer", "productName": "Drehmal Installer", "author": "jgaribsin", diff --git a/src/providers/DownloadFile.ts b/src/providers/DownloadFile.ts index a11fba1..f33ea59 100644 --- a/src/providers/DownloadFile.ts +++ b/src/providers/DownloadFile.ts @@ -18,11 +18,19 @@ export function downloadFile( // User-Agent: github_username/project_name/1.56.0 (launcher.com) const options = { headers: { - 'User-Agent': 'Drehmal-Team/installer/0.2.0 (drehmal.net)', + 'User-Agent': 'Drehmal-Team/installer/0.3.1 (drehmal.net)', // 'accept-encoding': 'gzip, deflate, br', }, }; https.get(url, options).on('response', function (res: any) { + if (res.statusCode > 300 && res.statusCode < 400) { + console.log( + `Got ${res.statusCode} for ${url}, redirecting to ${res.headers.location}` + ); + return downloadFile(res.headers.location, savePath, ref).then(() => + resolve() + ); + } // const startTime = Date.now(); let downloaded = 0; const contentLength = +(res.headers['content-length'] as string); diff --git a/src/providers/DownloadMods.ts b/src/providers/DownloadMods.ts index 4bd425c..680af71 100644 --- a/src/providers/DownloadMods.ts +++ b/src/providers/DownloadMods.ts @@ -51,6 +51,24 @@ export async function downloadMods(ref: Ref) { } } await processArray(modList); + + const configPath = path.join(drehmalDir.value, 'config'); + if (!fs.existsSync(configPath)) fs.mkdirSync(configPath, { recursive: true }); + console.log(`Creating CIT config file in "${configPath}"`); + const citJsonConfig = { + enabled: true, + mute_errors: false, + mute_warns: false, + citenchantment_scroll_multiplier: 8.0, + cache_ms: 50, + broken_paths: false, + }; + fs.writeFileSync( + path.join(configPath, 'citresewn.json'), + JSON.stringify(citJsonConfig), + 'utf-8' + ); + ref.value.label = 'Mods successfully downloaded!'; ref.value.img = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAACXBIWXMAAAsTAAALEwEAmpwYAAACqElEQVRYhdVYzY7SUBT+Tu1CTWRaG4UncKMOxOWMhhg37khYwBgT43P4ADyIiSawMLBzA0LUWRLGv4VPwMwECjVhiJYeF6W1pTBD7+2Mw7e67b0993733HvOd0r1ahuFUh6NWoexgSiU8tSodUDMjEatw0QETb/2v9cVCyPzBMyMQilPVK+2GQAUhbClbRaR8egEjuMeJBUA9JvX/U7DSElP8OJp59T+1+/z0nMMBpa/8eZw4hLx4JG4mlKjX8ZALqOv7Ov1TWn7U8uGYaQwGFj+u4hFkUnKO02/zQBq+09OHb+324LDDFpz/LI1Ti079E4FxbKxFPfSGq6Qa+jn8NeZ47fTmt/u9U35BRCgkgST8m4TzPF39NW7B6HnZw9bmDkc244HAqC4zhVDNq1DIXmX3r+tQVXk7Ciyi0jgZCYCKSIOMxTJnfRAkp4VioOVYhffjsZ4++mx0KSlQJQjANX53agUu+j1TaG7IhzQbccR/TSUZw4OE4haIHEiIijvtsDMyGV0KY9GwRdLJBvIHw4nK7YTIbI332lvaYtnPOiJ78djvPmYlCf+IREiwUz95XAU6c+mNZ/kzDmfsicRIl6mrhS72E5roagEuES/Ho1Q/SyWudeBMBFVWZ2CglGJ4YZYGSm0DqhebbNXjxhGKpb6fZnvYPLHjtyJSrHrtw/6pp8nVqG00wQRYnlsatm+jDeHE7nMfse4kYjWymV0Xz2L4lzC76K6vQjIi8ZLohqlPOLtvFeXeDhLKy1GNdE6JIhEjlY2HdBOa1R8yWutJUSmlh27bl+8E88ffcDM4YgMUYjgsHglGFzjIkIrHgwsGEZq6cA4uHtra+n737MZfhxb0vYBhP6gAPM84j0E/29tAszhxG8ruDzVqgzIO1oEgIMMNwgEAH8Bhif2yStQayoAAAAOZVhJZk1NACoAAAAIAAAAAAAAANJTkwAAAABJRU5ErkJggg=='; diff --git a/src/providers/JavaDownload.ts b/src/providers/JavaDownload.ts index a0e7323..b1213c9 100644 --- a/src/providers/JavaDownload.ts +++ b/src/providers/JavaDownload.ts @@ -78,47 +78,33 @@ export async function getJre(): Promise { // https://api.adoptium.net/v3/binary/latest/17/ga/windows/x64/jre/hotspot/normal/eclipse const url = `https://api.adoptium.net/v3/binary/latest/${flags.feature_version}/${flags.release_type}/${flags.os}/${flags.arch}/${flags.image_type}/${flags.jvm_impl}/${flags.heap_size}/${flags.vendor}`; - const options = { - headers: { - 'User-Agent': 'Drehmal-Team/installer/0.2.0 (drehmal.net)', - // 'accept-encoding': 'gzip, deflate, br', - }, - }; - const result = (await new Promise((resolve, reject) => { - // API responds with two redirects, TODO: recursively follow 302 redirects - https.get(url, options).on('response', (res: any) => { - https.get(res.headers.location, options).on('response', (res: any) => { - const downloadUrl = res.headers.location; - console.log(`Downloading Java zip from: "${downloadUrl}"`); - downloadFile(downloadUrl, filePath).then(async () => { - console.log(`Java zip successfully downloaded to: "${filePath}"`); - - if (platform === 'win32') - await extract(filePath, { dir: javaPath }); - else await tar.x({ file: filePath, cwd: javaPath }); - fs.unlinkSync(filePath); - console.log(`Java zip successfully extracted to: "${javaPath}"`); - - javawExe = findFile(javaPath, javaNames[0]); - javaExe = findFile(javaPath, javaNames[1]); - if (javaExe && javawExe) { - console.log(`Setting Java Exe path to "${javaExe}"`); - javaStorePath.value = javaExe; - console.log(`Setting Javaw Exe path to "${javawExe}"`); - javawStorePath.value = javawExe; - if (platform !== 'win32') { - console.log('Making javaw executable'); - ipcRenderer.invoke('execute', `chmod +x "${javawExe}"`); - } - - resolve(javawExe); - } else - reject( - `Could not find ${javaNames[0]} ${javaNames[1]} in "${javaPath}" after downloading` - ); - }); - }); + downloadFile(url, filePath).then(async () => { + console.log(`Java zip successfully downloaded to: "${filePath}"`); + + if (platform === 'win32') await extract(filePath, { dir: javaPath }); + else await tar.x({ file: filePath, cwd: javaPath }); + fs.unlinkSync(filePath); + console.log(`Java zip successfully extracted to: "${javaPath}"`); + + console.log(`Checking for Java runtime in "${javaPath}"`); + javawExe = findFile(javaPath, javaNames[0]); + javaExe = findFile(javaPath, javaNames[1]); + if (javaExe && javawExe) { + console.log(`Setting Java Exe path to "${javaExe}"`); + javaStorePath.value = javaExe; + console.log(`Setting Javaw Exe path to "${javawExe}"`); + javawStorePath.value = javawExe; + if (platform !== 'win32') { + console.log('Making javaw executable'); + ipcRenderer.invoke('execute', `chmod +x "${javawExe}"`); + } + + resolve(javawExe); + } else + reject( + `Could not find ${javaNames[0]} ${javaNames[1]} in "${javaPath}" after downloading` + ); }); })) as string; @@ -130,6 +116,7 @@ function findFile(dir: string, filename: string): string { const files = fs.readdirSync(dir); for (const file of files) { const filePath = path.join(dir, file); + if (filePath.endsWith('.zip')) continue; if (fs.statSync(filePath).isDirectory()) { const recursive = findFile(filePath, filename); diff --git a/src/stores/SourcesStore.ts b/src/stores/SourcesStore.ts index 99e75aa..1b0d805 100644 --- a/src/stores/SourcesStore.ts +++ b/src/stores/SourcesStore.ts @@ -35,7 +35,16 @@ export const useSourcesStore = defineStore('sources', () => { 'https://maven.fabricmc.net/net/fabricmc/fabric-installer/0.11.2/fabric-installer-0.11.2.jar', minecraftVersion: '1.17.1', }, + // using https://www.drehmal.net/2-2-mod-list modList: [ + { + name: 'Animatica', + url: 'https://modrinth.com/mod/animatica', + source: + 'https://cdn.modrinth.com/data/PRN43VSY/versions/0.4%2B1.17/animatica-0.4%2B1.17.jar', + mc_version: '1.17.1', + mod_version: '0.4', + }, { name: 'CIT Resewn', url: 'https://modrinth.com/mod/cit-resewn', @@ -45,12 +54,36 @@ export const useSourcesStore = defineStore('sources', () => { mod_version: '0.9.1', }, { - name: 'Entity Texture Features', - url: 'https://modrinth.com/mod/entitytexturefeatures', + name: 'Cull Leaves', + url: 'https://modrinth.com/mod/cull-leaves', source: - 'https://cdn.modrinth.com/data/BVzZfTc1/versions/a4YzsmzU/entity_texture_features_fabric_1.17.1-4.3.1.jar', + 'https://cdn.modrinth.com/data/GNxdLCoP/versions/2.3.2/cullleaves-2.3.2.jar', mc_version: '1.17.1', - mod_version: '4.3.1', + mod_version: '2.3.2', + }, + { + name: 'Dynamic FPS', + url: 'https://modrinth.com/mod/dynamic-fps', + source: + 'https://cdn.modrinth.com/data/LQ3K71Q1/versions/v2.0.6/dynamic-fps-2.0.6.jar', + mc_version: '1.17.1', + mod_version: '2.0.6', + }, + { + name: 'Entity Culling', + url: 'https://modrinth.com/mod/entity-culling', + source: + 'https://cdn.modrinth.com/data/NNAgCjsB/versions/1.5.0-fabric-1.17/entityculling-fabric-mc1.17.1-1.5.0.jar', + mc_version: '1.17.1', + mod_version: '1.5.0', + }, + { + name: 'Fabric API', + url: 'https://modrinth.com/mod/fabric-api', + source: + 'https://cdn.modrinth.com/data/P7dR8mSH/versions/0.46.1%2B1.17/fabric-api-0.46.1%2B1.17.jar', + mc_version: '1.17.1', + mod_version: '0.46.1', }, { name: 'FabricSkyboxes', @@ -68,6 +101,14 @@ export const useSourcesStore = defineStore('sources', () => { mc_version: '1.17.1', mod_version: '1.0.1', }, + { + name: 'Iris Shaders', + url: 'https://modrinth.com/mod/iris', + source: + 'https://cdn.modrinth.com/data/YL57xq9U/versions/pkGrlTNQ/iris-mc1.17.1-1.2.7.jar', + mc_version: '1.17.1', + mod_version: '1.2.7', + }, { name: 'LambDynamicLights', url: 'https://modrinth.com/mod/lambdynamiclights', @@ -77,20 +118,28 @@ export const useSourcesStore = defineStore('sources', () => { mod_version: 'LambDynamicLights 2.1.0 (1.17-1.18)', }, { - name: 'Fabric API', - url: 'https://modrinth.com/mod/fabric-api', + name: 'Lazy DFU', + url: 'https://modrinth.com/mod/lazydfu', source: - 'https://cdn.modrinth.com/data/P7dR8mSH/versions/0.46.1%2B1.17/fabric-api-0.46.1%2B1.17.jar', + 'https://cdn.modrinth.com/data/hvFnDODi/versions/0.1.2/lazydfu-0.1.2.jar', mc_version: '1.17.1', - mod_version: '0.46.1', + mod_version: '0.1.2', }, { - name: 'Animatica', - url: 'https://modrinth.com/mod/animatica', + name: 'Lithium', + url: 'https://modrinth.com/mod/lithium', source: - 'https://cdn.modrinth.com/data/PRN43VSY/versions/0.4%2B1.17/animatica-0.4%2B1.17.jar', + 'https://cdn.modrinth.com/data/gvQqBUqZ/versions/mc1.17.1-0.7.5/lithium-fabric-mc1.17.1-0.7.5.jar', mc_version: '1.17.1', - mod_version: '0.4', + mod_version: '0.7.5', + }, + { + name: 'Starlight', + url: 'https://modrinth.com/mod/starlight', + source: + 'https://cdn.modrinth.com/data/H8CaAYZC/versions/Starlight%201.0.0%201.17.x/starlight-1.0.0%2Bfabric.73f6d37.jar', + mc_version: '1.17.1', + mod_version: '1.0.0', }, { name: 'Sodium', @@ -117,12 +166,28 @@ export const useSourcesStore = defineStore('sources', () => { mod_version: '1.5.0', }, { - name: 'Dynamic FPS', - url: 'https://modrinth.com/mod/dynamic-fps', + name: 'WI Zoom', + url: 'https://modrinth.com/mod/wi-zoom', source: - 'https://cdn.modrinth.com/data/LQ3K71Q1/versions/v2.0.6/dynamic-fps-2.0.6.jar', + 'https://cdn.modrinth.com/data/o7DitHWP/versions/OYzl0qI6/WI-Zoom-1.3-MC1.17.1.jar', mc_version: '1.17.1', - mod_version: '2.0.6', + mod_version: '1.3', + }, + { + name: 'Entity Texture Features', + url: 'https://modrinth.com/mod/entitytexturefeatures', + source: + 'https://cdn.modrinth.com/data/BVzZfTc1/versions/a4YzsmzU/entity_texture_features_fabric_1.17.1-4.3.1.jar', + mc_version: '1.17.1', + mod_version: '4.3.1', + }, + { + name: 'CEM', + url: 'https://github.com/YoungSoulluoS/cem_Fork', + source: + 'https://github.com/YoungSoulluoS/cem_Fork/releases/download/Soul_Fork_10_1.19.4/cem-0.7.1_S8_1.17.jar', + mc_version: '1.17.1', + mod_version: '0.7.1', }, ], launcher_icon: