import fetch from 'node-fetch'; import path from 'path'; import fs from 'fs'; async function download() { let response = await fetch("https://patcher-production.robocraft.org/Builds/builds_index.json"); let json = await response.json(); const latestBuild = json.AvailableBuilds.pop(); console.log("Latest build:", latestBuild); response = await fetch(`https://patcher-production.robocraft.org/Builds/build_${latestBuild}.json`); json = await response.json(); for (const entry of json.Entries) { console.log("Downloading", entry.RelativePath); await fs.promises.mkdir(path.dirname("game/" + entry.RelativePath), { recursive: true }) response = await fetch(`https://patcher-production.robocraft.org/Builds/${latestBuild}/Game/${entry.RelativePath}`); const writeStream = fs.createWriteStream("game/" + entry.RelativePath); response.body.pipe(writeStream); } console.log("Done!"); } download();