Dragonfly Download Bin #198

Merged
Sirherobrine23 merged 3 commits from DragonflyDownload into main 2021-09-27 00:48:45 +00:00
Showing only changes of commit 0a15389cee - Show all commits

View File

@ -328,24 +328,16 @@ module.exports.v2 = async (version = true) => {
if (valid_platform.dragonfly) { if (valid_platform.dragonfly) {
if (LocalServersVersions.dragonfly !== version) { if (LocalServersVersions.dragonfly !== version) {
// Add info to ReturnObject // Add info to ReturnObject
ReturnObject.url = "https://github.com/df-mc/dragonfly/tree/master"; ReturnObject.url = ServerDownloadJSON.dragonfly[version][process.platform][bds.arch]
ReturnObject.data = ""; ReturnObject.data = ServerDownloadJSON.dragonfly[version].data;
// Build Dragonfly // Download
const TmpDragonflyDir = path.join(os.tmpdir(), `dragonfly_${Math.random().toString(36).substring(7)}`); let DgBin = path.join(ServersPaths.dragonfly, "Dragonfly");
child_process.execFileSync("git", ["clone", "https://github.com/df-mc/dragonfly", "--depth", "1", TmpDragonflyDir]); if (process.platform === "win32") DgBin += ".exe";
let DragonflyPackageOut = path.join(ServersPaths.dragonfly, "DragonFly"); fs.writeFileSync(DgBin, await Request.buffer(ReturnObject.url), "binary");
if (process.platform === "win32") DragonflyPackageOut += ".exe";
child_process.execFileSync("go", ["build", "-o", DragonflyPackageOut], {cwd: TmpDragonflyDir});
// move Dragonfly to ServersPaths
fs.renameSync(DragonflyPackageOut, path.join(ServersPaths.dragonfly, path.basename(DragonflyPackageOut)));
// Remove Build Dir
fs.rmSync(TmpDragonflyDir, {recursive: true, force: true});
// Update Server Version // Update Server Version
bds.BdsSettigs.UpdateServerVersion(Math.random().toString(), CurrentPlatform); bds.BdsSettigs.UpdateServerVersion(version, CurrentPlatform);
} else { } else {
ReturnObject.skip = true; ReturnObject.skip = true;
} }