Skip to content

Commit

Permalink
updating modlist, fixed CIT, recursive file downloads
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
jgaribsin committed Feb 19, 2024
1 parent c039986 commit 8979810
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ yarn-error.log*
_archive
foo*
bar*
/reports/*
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 9 additions & 1 deletion src/providers/DownloadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions src/providers/DownloadMods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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==';
Expand Down
67 changes: 27 additions & 40 deletions src/providers/JavaDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,47 +78,33 @@ export async function getJre(): Promise<string> {
// 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;

Expand All @@ -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);
Expand Down
97 changes: 81 additions & 16 deletions src/stores/SourcesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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:
Expand Down

0 comments on commit 8979810

Please sign in to comment.