Fabric Profile
HughSparks opened this issue · 1 comments
HughSparks commented
I can barely code but I thought I would try to modify an existing profile (Mojang) for fabric.
I'm happy to answer any questions about my thought process.
var async = require('async');
var path = require('path');
var fs = require('fs-extra');
var profile = require('./template');
exports.profile = {
name: "Fabric Offical Installer Jars",
request_args: {
url: 'https://meta.fabricmc.net/v2/versions/installer,
json: true
},
handler: function (profile_dir, body, callback) {
var request = require('request');
var p = [];
var q = async.queue(function (obj, cb) {
async.waterfall([
async.apply(request, obj.url),
function (response, body, inner_cb) {
inner_cb(response.statusCode != 200, body)
},
function (body, inner_cb) {
var parsed = JSON.parse(body);
for (var idx in p)
if (p[idx]['id'] == obj['id'])
try {
p[idx]['url'] = parsed['downloads']['server']['url'];
} catch (e) { }
inner_cb();
}
])
cb();
}, 2);
q.pause();
try { // BEGIN PARSING LOGIC
for (var index in body.versions) {
var item = new profile();
var ref_obj = body.versions[index];
item['id'] = ref_obj['version'];
item['time'] = new Date().getTime();
item['releaseTime'] = new Date().getTime();
item['group'] = 'fabric';
item['webui_desc'] = 'Fabric Installer';
item['weight'] = 0;
item['filename'] = 'fabric-installer-{0}.jar'.format(ref_obj['version']);
item['downloaded'] = fs.existsSync(path.join(profile_dir, item.id, item.filename));
item['version'] = ref_obj['version'];
item['release_version'] = '';
item['url'] = 'https://maven.fabricmc.net/net/fabricmc/fabric-installer/{0}/fabric-installer-{0}.jar'.format(item.version);
switch (ref_obj['stable']) {
case 'true':
item['stable'] = 'release';
q.push({ id: item['version'], url: ref_obj.url });
p.push(item);
break;
default:
item['version'] = 'old_version'; //old_alpha, old_beta
//q.push({ id: item['id'], url: ref_obj.url });
break;
}
//p.push(item);
}
} catch (e) { }
q.resume();
q.drain = function () {
callback(null, p);
}
}, //end handler
postdownload: function (profile_dir, dest_filepath, callback) {
callback();
}
}
Also I'm submitting my enhancement here because I couldn't figure out how to make a branch or a submition.
Deleted user commented
I would love a native Fabric profile for MineOS. It looks like there's some conversation on that subject here: https://discourse.codeemo.com/t/fabric-on-mineos/3400