diff --git a/.gitignore b/.gitignore index e75c547..733ff52 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ /classes /dev /dist +/versions /tmp tmp bin diff --git a/meta/lib/constants.js b/meta/lib/constants.js deleted file mode 100644 index 5f41af7..0000000 --- a/meta/lib/constants.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -(function(){ - var c = {}; - c.modid = "engineersdecor"; - c.mod_registry_name = function() { return c.modid; } - c.local_assets_root = function() { return "src/main/resources/assets/" + c.mod_registry_name(); } - c.reference_repository = function() { return "git@github.com:stfwi/engineers-decor.git"; } - c.gradle_property_modversion = function() { return "version_engineersdecor"; } - c.gradle_property_version_minecraft = function() { return "version_minecraft"; } - c.gradle_property_version_forge = function() { return "version_forge"; } - c.project_download_inet_page = function() { return "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/"; } - c.options = { - without_ref_repository_check: true - }; - c.languages = { - "en_us": { code:"en_us", name:"English", region:"United States" }, - "de_de": { code:"de_de", name:"German", region:"Germany" }, - "ru_ru": { code:"ru_ru", name:"Russian", region:"Russia" }, - "zh_cn": { code:"zh_cn", name:"Chinese", region:"China" } - } - Object.freeze(c.languages); - Object.freeze(c); - return c; -}); diff --git a/meta/lib/liblang.1.12.js b/meta/lib/liblang.1.12.js deleted file mode 100644 index 0aafca3..0000000 --- a/meta/lib/liblang.1.12.js +++ /dev/null @@ -1,206 +0,0 @@ -"use strict"; -(function(constants){ - var me = {}; - - /** - * Loads the raw data of the lang file. - * @returns {object} - */ - me.load_raw = function(file_path, remove_comments) { - const lang_code = fs.basename(file_path).replace(/\..*$/,"").trim().toLowerCase(); - var lines = fs.readfile(file_path).trim().split("\n"); - var was_eol_escape = false; - for(var i in lines) { - if(was_eol_escape) { - var k=0; - for(k=i-1; k>=0; --k) { - if(lines[k] != null) { - lines[k] += "\n" + lines[i]; - break; - } - } - was_eol_escape = lines[i].match(/[^\\][\\]$/) != null; - lines[i] = null; - } else { - lines[i] = lines[i].trim(); - was_eol_escape = lines[i].match(/[^\\][\\]$/) != null; - } - } - lines = lines.filter(function(l){return (l!==null)}); - if(!!remove_comments) lines = lines.filter(function(l){return (l.trim().search(/^#/)!=0)}); - return { code:lang_code, data:lines }; - } - - /** - * Loads a language into a unified object format - */ - me.load = function(file_path) { - const modid = constants.mod_registry_name(); - const data = { - creative_tab: "", - config_title: "", - blocks: {}, - items: {}, - other: {}, - lang: {}, - invalid: {} - }; - var lines = me.load_raw(file_path, true).data.map(function(line){return line.replace(/[\s]*[\\][\r]?[\n][\s]*/mig, " ").trim()}); - for(var i in lines) { - if(!lines[i].length) continue; - const kv = lines[i].split("=", 2); - if(kv.length!=2) throw new Error("Invalid line " + i + " in '"+file_path+"': '"+lines[i]+"'"); - const key = kv[0].trim(); - const text = kv[1].trim(); - text = text.replace("\\\\n", "\n").replace("\\n", "\n"); - if(key.length == 0) { - throw new Error("Empty key in '"+file_path+"' line '" + lines[i] + "'"); - } else if(key.search("tile."+modid+".")==0) { - key = key.replace("tile."+modid+".", ""); - key = key.split(".", 2); - const block = key[0]; - const prop = key[1]; - if(data.blocks[block]===undefined) data.blocks[block] = {}; - data.blocks[block][prop] = text; - } else if(key.search("item."+modid+".")==0) { - key = key.replace("item."+modid+".", ""); - key = key.split(".", 2); - const item = key[0]; - const prop = key[1]; - if(data.items[item]===undefined) data.blocks[item] = {}; - data.blocks[item][prop] = text; - } else if(key.search(modid + ".config.title")==0) { - data.config_title = text; - } else if(key.search("itemGroup.tab" + modid)==0) { - data.creative_tab = text; - } else if(key.search(modid + ".")==0) { - data.other[key] = text; - } else { - data.invalid[key] = text; - } - } - const lang_code = fs.basename(file_path).replace(/[\.].*$/, "").trim().toLowerCase(); - if(constants.languages[lang_code] === undefined) throw new Error("No language header constants defined for '" + lang_code + "'"); - data.lang = constants.languages[lang_code]; - return data; - } - - /** - * Saves a language in the version specific MC format from - * a unified object format. - */ - me.save = function(file_path, lang_data) { - throw new Error("lang.save() not implemented yet for 1.12 lang files."); - } - - /** - * Adds missing entries to the language file, master is en_us. - * Applies to the CWD and 1.12.2 lang files. - * @returns {void} - */ - me.sync_languages = function(reflang_code) { - if(reflang_code===undefined) reflang_code = "en_us"; - reflang_code = reflang_code.trim().toLowerCase(); - function load() { - var lang_data = {}; - fs.find("./src/main/resources/assets/"+ constants.mod_registry_name() +"/lang", '*.lang', function(f){ - const r = me.load_raw(f); - lang_data[r.code] = r.data; - return false; - }); - return lang_data; - } - function reference_content(lang_data, reflang_code) { - var lang_lines = []; - for(var i in lang_data[reflang_code]) { - var txt = lang_data[reflang_code][i].trim(); - if((txt.search(/^#/)>=0) || (txt.search("=")<0)) { lang_lines.push(txt); continue; }; // comment "#" or empty line in the ref lang file - var kv = txt.split("=", 2); - var key = kv[0].trim(); - var val = kv[1].trim(); - var o = {key:key, tr:{}}; - o.tr[reflang_code] = val; - lang_lines.push(o); - } - delete lang_data[reflang_code]; - return lang_lines; - } - function add_language(lang_lines, lang_name, lang_data) { - const find_line = function(lines, key) { - for(var i in lines) { - if((typeof(lines[i]) !== "object")) continue; - if(lines[i].key.toLowerCase()==key.toLowerCase()) return i; - } - return -1; - }; - for(var i in lang_data) { - var txt = lang_data[i].trim(); - if(txt.search(/^#/)>=0) continue; - if(txt.search("=")<0) continue; - var kv = txt.split("=", 2); - var key = kv[0].trim(); - var val = kv[1].trim(); - var line_i = find_line(lang_lines, key); - if(line_i >= 0) { - lang_data[i] = undefined; - lang_lines[line_i].tr[lang_name] = val; - } - } - return lang_data; - } - - function complete_lang_lines(lang_lines, lang_names, reflang_code) { - var lang_outputs = {}; - for(var i in lang_names) lang_outputs[lang_names[i]] = []; - for(var i_line in lang_lines) { - var entry = lang_lines[i_line]; - if(typeof(entry) !== "object") { - for(var i in lang_names) lang_outputs[lang_names[i]].push(entry); - } else { - for(var i in lang_names) { - var name = lang_names[i]; - if(entry.tr[name] !== undefined) { - lang_outputs[name].push(entry.key + "=" + entry.tr[name]); - } else { - var added = entry.key + "=" + entry.tr[reflang_code]; - if((entry.key.search(/\.tip$/)>0) || (entry.key.search(/\.help$/)>0)) added = "#" + added; - lang_outputs[name].push(added); - if(added.search(/^#/)<0) print("[warn] Lang: Added default language for missing entry in " + name + ": '" + added + "'"); - } - } - } - } - return lang_outputs; - } - - var lang_data = load(); - var lang_names = Object.keys(lang_data); - var lang_lines = reference_content(lang_data, reflang_code); - for(var lang_name in lang_data) { - lang_data[lang_name] = add_language(lang_lines, lang_name, lang_data[lang_name]); - lang_data[lang_name] = lang_data[lang_name].filter(function(l){ return !!l; }); - if(lang_data[lang_name].length == 0) delete lang_data[lang_name]; - } - var output_data = complete_lang_lines(lang_lines, lang_names, reflang_code); - for(var i in output_data) output_data[i] = output_data[i].join("\n") + "\n\n"; - - // Remaining lines in lang files (not in the reference lang file) - for(var lang_name in lang_data) { - for(var i in lang_data[lang_name]) { - if(lang_data[lang_name][i].search(/^#/)<0) { - var added = "# " + lang_data[lang_name][i].replace(/^[#\s]+/,""); - output_data[lang_name] += added + "\n"; - print("[warn] Lang: Commented out unknown key in " + lang_name + ": '" + added + "'"); - } - } - } - for(var name in output_data) output_data[name] = output_data[name].trim() + "\n"; - - for(var name in output_data) { - fs.writefile("./src/main/resources/assets/"+ constants.mod_registry_name() +"/lang/" + name + ".lang", output_data[name]); - } - }; - - Object.freeze(me); - return me; -}); \ No newline at end of file diff --git a/meta/lib/liblang.1.13.js b/meta/lib/liblang.1.13.js deleted file mode 100644 index d136998..0000000 --- a/meta/lib/liblang.1.13.js +++ /dev/null @@ -1,192 +0,0 @@ -"use strict"; -(function(constants){ - var me = {}; - - const clone = function(o) { return JSON.parse(JSON.stringify(o)); } - - /** - * Loads the raw data of the lang file. - * @returns {object} - */ - me.load_raw = function(file_path) { - const lang_code = fs.basename(file_path).replace(/\..*$/,"").trim().toLowerCase(); - const data = JSON.parse(fs.readfile(file_path).trim()); - return { code:lang_code, data:data }; - } - - /** - * Loads - */ - me.load = function(file_path) { - const modid = constants.mod_registry_name(); - const data = { - creative_tab: "", - config_title: "", - blocks: {}, - items: {}, - other: {}, - lang: {}, - invalid: {} - }; - var lines = me.load_raw(file_path).data; - for(var objkey in lines) { - const key = objkey.trim(); - const text = lines[objkey].trim(); - if(key.length == 0) { - throw new Error("Empty key in '"+file_path+"' line '" + lines[i] + "'"); - } else if(key.search("block."+modid+".")==0) { - key = key.replace("block."+modid+".", ""); - key = key.split(".", 2); - const block = key[0]; - const prop = ((key.length<2) || (key[1]=="")) ? "name" : key[1]; - if(data.blocks[block]===undefined) data.blocks[block] = {}; - data.blocks[block][prop] = text; - } else if(key.search("item."+modid+".")==0) { - key = key.replace("item."+modid+".", ""); - key = key.split(".", 2); - const item = key[0]; - const prop = ((key.length<2) || (key[1]=="")) ? "name" : key[1]; - if(data.items[item]===undefined) data.blocks[item] = {}; - data.blocks[item][prop] = text; - } else if(key.search(modid + ".config.title")==0) { - data.config_title = text; - } else if(key.search("itemGroup.tab" + modid)==0) { - data.creative_tab = text; - } else if(key.search(modid + ".")==0) { - data.other[key] = text; - } else if(key.search("language")==0) { - key = key.replace("language", ""); - key = key.split(".", 2); - const prop = ((key.length<2) || (key[1]=="")) ? "name" : key[1]; - data.lang[prop] = text; - } else { - data.invalid[key] = text; - } - } - return data; - } - - /** - * Saves a language in the version specific MC format from - * a unified object format. - */ - me.save = function(file_path, data) { - if(Object.keys(data.invalid).length > 0) throw new Error("Given language data have entries in the marked-invalid data, fix this first."); - const modid = constants.mod_registry_name(); - var out = {}; - out["language"] = data.lang.name; - out["language.code"] = data.lang.code; - out["language.region"] = data.lang.region; - out["itemGroup.tab" + modid] = data.creative_tab; - out[modid+".config.title"] = data.config_title; - for(var it in data.other) { - out[it] = data.other[it]; - } - for(var blkname in data.blocks) { - var blk = data.blocks[blkname]; - for(var key in blk) { - if(key=="name") { - out["block."+modid+"."+blkname] = blk[key]; - } else { - out["block."+modid+"."+blkname+"."+key] = blk[key]; - } - } - } - for(var itemname in data.items) { - var item = data.items[itemname]; - for(var key in item) { - if(key=="name") { - out["item."+modid+"."+itemname] = item[key]; - } else { - out["item."+modid+"."+itemname+"."+key] = item[key]; - } - } - } - var txt = JSON.stringify(out,null,1); - var file_lang_code = fs.basename(file_path).replace(/\.json/,""); - const filename = fs.basename(file_path); - if(filename.toLowerCase() != filename) throw new Error("Language files must be completely lowercase."); - if(file_lang_code != data.lang.code) throw new Error("File name to save does not contain the language code of the given data."); - if(filename.search("\.json$") <= 0) throw new Error("File name to save must be a json file (lowercase)."); - if(!fs.isdir(fs.dirname(file_path))) throw new Error("File to save: Parent directory does not exist."); - fs.writefile(file_path, txt); - } - - /** - * Adds missing entries to the language file, master is en_us. - * Applies to the CWD and 1.12.2 lang files. - * @returns {void} - */ - me.sync_languages = function(reflang_code) { - const modid = constants.mod_registry_name(); - if(reflang_code===undefined) reflang_code = "en_us"; - reflang_code = reflang_code.trim().toLowerCase(); - function load() { - const lang_data = {}; - fs.find("./src/main/resources/assets/"+ modid +"/lang", '*.json', function(f){ - const r = me.load_raw(f); - lang_data[r.code] = r.data; - return false; - }); - return lang_data; - } - function sync_lang_data(lang_data, reflang_code) { - const lang_outputs = clone(lang_data); - const reflang = lang_data[reflang_code]; - for(var name in lang_data) { - if(name == reflang_code) continue; - const lang = lang_outputs[name]; - for(var key in reflang) { - if(lang[key] === undefined) { - lang[key] = clone(reflang[key]); - print("[warn] Lang: Added default language for missing entry in " + name + ": '" + key + "'"); - } - } - for(var key in lang) { - if((reflang[key] === undefined) && (lang[key].search(/^_/)<0)) { - lang["_"+key] = lang[key]; - print("[warn] Lang: Commented out obsolete entry in " + name + ": '" + key + "'"); - } - } - } - return lang_outputs; - } - - const sort_entries = function(data) { - data = clone(data); - const out = {}; - const move = function(key) { out[key] = data[key]; data[key] = undefined; delete data[key]; }; - move("language"); - move("language.code"); - move("language.region"); - move("itemGroup.tab"+modid); - move(modid+".config.title"); - const keys = Object.keys(data); - keys.sort(function(a, b) { - if((a.search(modid+".config.")==0) && (b.search(modid+".config.")<0) ) return -1; - if((b.search(modid+".config.")==0) && (a.search(modid+".config.")<0) ) return +1; - if((a.search(modid+".tooltip.")==0) && (b.search(modid+".tooltip.")<0) ) return -1; - if((b.search(modid+".tooltip.")==0) && (a.search(modid+".tooltip.")<0) ) return +1; - if((a.search("block."+modid+".")==0) && (b.search("block."+modid+".")<0) ) return -1; - if((b.search("block."+modid+".")==0) && (a.search("block."+modid+".")<0) ) return +1; - if((a.search("item."+modid+".")==0) && (b.search("item."+modid+".")<0) ) return -1; - if((b.search("item."+modid+".")==0) && (a.search("item."+modid+".")<0) ) return +1; - return (a>b ? 1 : (a 0) && readme[0].search(/^## Version history/i)<0) readme.shift(); - while((readme.length > 0) && readme[0].trim()=="") readme.shift(); - // version history section - if(!readme.length) throw new Error("Version history section not found in readme"); - readme.shift(); - var end_of_history = readme.length; - for(var i=0; i= 0) { end_of_history=i; break; } - if(end_of_history >= readme.length) throw new Error("Could not find the end-of-history header marker."); - // remove empty lines, splitters - while(readme.length >= end_of_history) readme.pop(); - while((readme.length >0) && (readme[readme.length-1].replace(/[\s-]/g,"")=="")) readme.pop(); - const min_indent = readme - .map(function(s){return s.search(/[^\s]/)}) - .filter(function(e){return e>=0}) - .reduce(function(acc,e){return (e 1) { - for(var i in readme) { readme[i] = readme[i].substr(min_indent-2); } - } - return readme.join("\n"); - } - - /** - * Returns the version history as array of version-text pairs from a given file path. - * @returns {array} - */ - me.parsing.readme_changelog = function(file_path) { - var readme = me.parsing.readme_history_section(file_path).split(/[\r]?[\n]/); - var versions = []; - var ver="", txt=[]; - const addversion = function(){ - if((ver.length == 0) && (txt.length == 0)) return; - if((ver.length > 0) != (txt.length > 0)) throw new Error("Version entry with empty corresponding text."); - for(var i in txt) txt[i] = txt[i].trim(); - for(var i=txt.length-1; i>0; --i) { - if((txt[i].length == 0) || (txt[i][0] == '[')) continue; - txt[i-1] += " " + txt[i]; - txt[i] = ""; - } - txt = txt.filter(function(v){return v.length>0;}); - for(var i in txt) txt[i] = txt[i].replace(/[\s]+/, " "); - versions.push({ver:ver,txt:txt}); - }; - for(var il in readme) { - var line = readme[il]; - if(line.replace(/[\s-]+/, "").length == 0) { - continue; // separator line - } if(line.search(/^[\s]*[~-][\s]*v[\d]+[\.][\d]+[\.][\d]/) == 0) { - addversion(); - var is_preversion = (line.search(/^[\s]*[~]/) == 0); - ver = line.replace(/^[\s]*[~-][\s]*/,"").replace(/[\s].*$/,"").toLowerCase(); - txt = [line.replace(ver, " ".repeat(ver.length)).replace(/^[\s]*[~-]/, function(m){ return " ".repeat(m.length); })]; - if(is_preversion) ver = "~" + ver; - } else { - txt.push(line); - } - } - addversion(); - return versions; - }; - - /** - * Returns the versions known from the readme - * @returns {array} - */ - me.parsing.readme_versions = function(file_path, no_pre_versions) { - var o = me.parsing.readme_changelog(file_path); - var versions = []; - for(var i in o) versions.push(o[i].ver); - if(!no_pre_versions) return versions; - versions = versions.filter(function(v){ return v[0]!="~"; }); - return versions; - } - - /** - * Returns the gradle.properties settings as key-value plain object. - * @returns {object} - */ - me.parsing.gradle_properties = function(file_path) { - var lines = fs.readfile(file_path).split(/[\r]?[\n]/); - var properties = {}; - for(var i in lines) { - var line = lines[i].trim(); - if(line.search("#")==0) continue; - if(line.search("//")>=0) { line=line.substr(0, line.search("//")).trim(); } - if(line.search(/^[a-z][a-z0-9_\.]+[=]/i) < 0) continue; - line = line.split("=", 2); - properties[line[0].trim()] = line[1].trim(); - } - return properties; - } - - /** - * Returns an object containing the version data for MC, forge, the - * mod, and the combined mod version. - */ - me.parsing.version_data = function() { - const properties = me.parsing.gradle_properties("gradle.properties"); - const version_minecraft = properties[constants.gradle_property_version_minecraft()]; - const version_forge = properties[constants.gradle_property_version_forge()]; - const version_mod = properties[constants.gradle_property_modversion()]; - const combined_version = version_minecraft + "-" + version_mod; - return { - minecraft: version_minecraft, - forge: version_forge, - mod: version_mod, - combined: combined_version - } - }; - - /** - * Changes one tab to two spaces in files with the given extension - * recursively found in the current working directory. - * @returns {void} - */ - me.sanatizing.tabs_to_spaces = function(extensions) { - var file_list = (function() { - var ls = []; - const ext = extensions; - for(var i in ext) ls = ls.concat(fs.find("./src", '*.'+ext[i])); - for(var i in ls) ls[i] = ls[i].replace(/\\/g,"/"); - ls.sort(); - ls.push("readme.md"); - return ls; - })(); - for(var file_i in file_list) { - var file = file_list[file_i]; - var txt = fs.readfile(file); - if(txt===undefined) throw new Error("Failed to read '" + file + "'"); - const txt_length = txt.length; - txt = txt.replace(/[\t]/g," "); - const n = txt.length - txt_length; - if(n > 0) { - print("File '" + file + "': Changed " + n + " tabs to 2 spaces." ); - fs.writefile(file, txt); - } - } - }; - - /** - * Removes space characters at the end of lines in files with the given - * extension recursively found in the current working directory. - * @returns {void} - */ - me.sanatizing.remove_trailing_whitespaces = function(extensions) { - var file_list = (function() { - var ls = []; - const ext = extensions; - for(var i in ext) ls = ls.concat(fs.find("./src", '*.'+ext[i])); - for(var i in ls) ls[i] = ls[i].replace(/\\/g,"/"); - ls.sort(); - ls.push("readme.md"); - return ls; - })(); - for(var file_i in file_list) { - var file = file_list[file_i]; - var txt = fs.readfile(file); - if(txt===undefined) throw new Error("Failed to read '" + file + "'"); - const txt_length = txt.length; - txt = txt.replace(/[\r\t ]+[\n]/g,"\n"); - const n = txt_length - txt.length; - if(n > 0) { - print("File '" + file + "': Fixed " + n + " lines with trailing whitespaces." ); - fs.writefile(file, txt); - } - } - }; - - /** - * Fixes "\\n" to "\n" in lang json files. - */ - me.sanatizing.lang_json_newline_fixes = function() { - var file_list = (function() { - var ls = []; - const dir = "./" + constants.local_assets_root() + "/lang"; - if(fs.isdir(dir)) { - ls = ls.concat(fs.find(dir, '*.json')); - for(var i in ls) ls[i] = ls[i].replace(/\\/g,"/"); - } - ls.sort(); - return ls; - })(); - for(var file_i in file_list) { - var file = file_list[file_i]; - var txt = fs.readfile(file); - if(txt===undefined) throw new Error("Failed to read '" + file + "'"); - txt = txt.replace(/\\\\n/g,"\\n"); - fs.writefile(file, txt); - } - }; - - /** - * Checks the versions specified in the gradle.properties against - * the last readme.md changelog version. Applies to the CWD. - * @returns {object} - */ - me.tasks.version_check = function(allow_preversions) { - var fails = []; - const properties = me.parsing.gradle_properties("gradle.properties"); - const version_minecraft = properties[constants.gradle_property_version_minecraft()]; - const version_forge = properties[constants.gradle_property_version_forge()]; - const version_mod = properties[constants.gradle_property_modversion()]; - const combined_version = version_minecraft + "-" + version_mod; - const readme_versions = me.parsing.readme_versions("readme.md").map(function(v){return v.replace(/^[v]/i, "").trim()}); - const readme_preversion_found = (readme_versions.filter(function(v){return v==("~v"+version_mod)}).length == 1); - var readme_version_found = readme_versions.filter(function(v){return v==version_mod}).length == 1; - if(allow_preversions && readme_preversion_found) readme_version_found = true; - if(!readme_version_found) fails.push("Version 'v" + version_mod + "' not found in the readme changelog."); - return { - fails: fails, - version_mod: version_mod, - combined_version: combined_version, - version_forge: version_forge, - preversion_found: readme_preversion_found - } - }; - - /** - * Distribution JAR pre-checks. - * @returns {array} - */ - me.tasks.dist_check = function() { - const uncommitted_changes = sys.shell("git status -s").trim(); - const gittags = sys.shell('git log -1 --format="%D"') - .replace(/[\s]/g,"").split(",") - .filter(function(s){ return s.indexOf("tag:")==0;}) - .map(function(s){ return s.replace(/^tag:/,"");}); - const modversion = fs.readfile("gradle.properties", function(line){ - if(line.trim().indexOf(constants.gradle_property_modversion())!=0) return false; - return line.replace(/^.*?=/,"").trim() - }).trim(); - const mcversion = fs.readfile("gradle.properties", function(line){ - if(line.trim().indexOf("version_minecraft")!=0) return false; - return line.replace(/^.*?=/,"").trim() - }).trim(); - const git_remote = sys.shell("git remote -v").trim(); - const git_branch = sys.shell("git rev-parse --abbrev-ref HEAD").trim(); - const git_diff = sys.shell("git diff .").trim(); - var fails = []; - if(modversion=="") fails.push("Could not determine '"+ constants.gradle_property_modversion() +"' from gradle properties."); - if(!gittags.length) fails.push("Version not tagged."); - const expected_commit_version = modversion.replace(/[-]/g,"") + "-mc" + mcversion; - if(!gittags.filter(function(s){return s.indexOf(expected_commit_version)>=0}).length) fails.push("No tag version on this commit matching the gradle properties version (should be v" + expected_commit_version + ")."); - if(((!constants.options.without_ref_repository_check)) && (git_remote.replace(/[\s]/g,"").indexOf(constants.reference_repository() + "(push)") < 0)) fails.push("Not the reference repository."); - //if(git_branch != "develop") fails.push("Not a valid branch for dist. (branch:'"+git_branch+"', must be 'develop')"); - if(git_diff !== "") fails.push("Not everything committed to the GIT repository."); - return fails; - }; - - /** - * Returns a version check object for the given MC version. - */ - me.tasks.changelog_data = function(mc_version) { - if(mc_version===undefined) throw new Error("No MC version given for generating an update JSON."); - mc_version = (""+mc_version).trim(); - function read_history() { - var readme = fs.readfile(fs.cwd() + "/readme.md"); - if(!readme) throw new Error("Failed to load readme.md"); - readme = readme.split(/[\r]?[\n]/); - while((readme.length > 0) && readme[0].search(/^## Version history/i)<0) readme.shift(); - // version history section - if(!readme.length) throw new Error("Version history section not found in readme"); - readme.shift(); - var end_of_history = readme.length; - for(var i=0; i= 0) { end_of_history=i; break; } - if(end_of_history >= readme.length) throw new Error("Could not find the end-of-history header marker."); - // remove empty lines, splitters - while(readme.length >= end_of_history) readme.pop(); - for(var i in readme) readme[i] = readme[i].replace(/[\s]+$/g,"").replace(/[\t]/g," "); - readme = readme.filter(function(a){return a.replace(/[\s-]+/g,"")!="";}); - // condense multilines to single line entries for each fix or feature. ([A] ... [M] ...) - for(var i=readme.length-1; i>0; --i) { - var line = readme[i].replace(/^\s+/,""); - if(line.search(/^[\[\-]/) < 0) { - readme[i-1] += " " + line; - readme[i] = ""; - } - } - readme = readme.filter(function(a){return a!="";}); - // Condense log entries sepatated with newlines to one line for each version - for(var i=readme.length-1; i>0; --i) { - var line = readme[i].replace(/^\s+/,""); - if(line.search(/^[-~]/) < 0) { - readme[i-1] += "\n" + line; - readme[i] = ""; - } - } - readme = readme.filter(function(a){return a!="";}); - // Separate versions. - var history = {}; - for(var i in readme) { - var line = readme[i].replace(/^[\sv-]+/g,"").trim(); - var ver = line.substr(0, line.search(" ")).trim().toLowerCase(); - var txt = line.substr(line.search(" ")).trim(); - if(ver.search("~")===0) continue; - if(history[ver] !== undefined) throw new Error("Double definition of version '" + ver + "' in the readme version history."); - history[ver] = txt; - } - return history; - } - var history = read_history(); - var latest_release = ""; - var latest_beta = ""; - for(var ver in history) { latest_beta=ver; break; } - for(var ver in history) if(ver.search(/(rc|b|a)/) < 0) { latest_release=ver; break; } - if(latest_release=="") latest_release = latest_beta; - var update_json = {} - update_json["homepage"] = constants.project_download_inet_page(); - update_json[mc_version] = history; - update_json["promos"] = {}; - update_json["promos"][""+mc_version+"-recommended"] = latest_release; - update_json["promos"][""+mc_version+"-latest"] = latest_beta; - return update_json; - }; - - // Standard tasks - var stdtasks = {}; - - stdtasks["dist-check"] = function() { - var fails = me.tasks.dist_check(); - if(fails.length == 0) return; - for(var i in fails) fails[i] = " - " + fails[i]; - alert("Dist check failed"); - alert(fails.join("\n")+"\n"); - exit(1); - }; - stdtasks["version-check"] = function(args) { - var r = me.tasks.version_check(!args.join().search("--no-preversions")>=0); - if(r.fails.length == 0) return; - alert("Version check failed:"); - for(var i in r.fails) alert(" - " + r.fails[i]); - alert("Version data:"); - alert(" - version_mod : '" + r.version_mod + "'"); - alert(" - combined_version : '" + r.combined_version + "'"); - alert(" - version_forge : '" + r.version_forge + "'"); - if(!!r.preversion_found) alert(" - PREVERSION FOUND : '~" + r.version_mod + "'"); - exit(1); - }; - stdtasks["version-html"] = function() { - if(!fs.isdir("dist")) throw new Error("'dist' directory does not exist."); - const hist = me.parsing.readme_history_section("readme.md"); - const version = me.parsing.version_data().combined; - const modid = constants.modid; - const html = "
\n" + (hist.replace(/&/g, "&").replace(/>/g, ">").replace(/";
-    fs.writefile("dist/" + modid + "-" + version + ".html", html);
-  };
-  stdtasks["sanitize"] = function() {
-    me.sanatizing.remove_trailing_whitespaces(['java','json','lang']);
-    me.sanatizing.tabs_to_spaces(['java','lang']);
-    me.sanatizing.lang_json_newline_fixes();
-  }
-  stdtasks["dist"] = function() {
-    stdtasks["version-html"]();
-  };
-  stdtasks["update-json"] = function() {
-    const version_minecraft = me.parsing.gradle_properties("gradle.properties").version_minecraft;
-    const json = me.tasks.changelog_data(version_minecraft);
-    fs.mkdir("./meta");
-    fs.writefile("./meta/update.json", JSON.stringify(json, null, 2));
-  };
-  stdtasks["dump-languages"] = function() {
-    const lang_version = (me.parsing.gradle_properties("gradle.properties").version_minecraft.search("1.12.")==0) ? "1.12" : "1.13";
-    const lang_extension = (lang_version == "1.12") ? ("lang") : ("json");
-    const liblang = include("../meta/lib/liblang."+lang_version+".js")(constants);
-    var lang_files = {};
-    fs.find("./src/main/resources/assets/"+ constants.mod_registry_name() +"/lang", '*.'+lang_extension, function(f){
-      const code = fs.basename(f).replace(/[\.].*$/,"").trim();
-      const data = liblang.load(f);
-      lang_files[code] = data;
-      return false;
-    });
-    print(JSON.stringify(lang_files,null,1));
-  };
-  stdtasks["datagen"] = function() {
-    sys.exec("gradlew.bat", ["--no-daemon", "runData"]);
-    // double check and really only copy json files.
-    const dst = fs.realpath("src/main/resources/data/" + constants.modid);
-    const src = fs.realpath("src/generated/resources/data/" + constants.modid);
-    if(!dst || !src) throw "Source or destination directory not found.";
-    if(!fs.isdir(src)) return;
-    const src_files = fs.find(src, "*.json");
-    const upath = function(s) { return s.replace(/[\\]/g,"/").replace(/^[\/]/,""); } // for correct display on win32
-    if(src_files===undefined) return 1;
-    for(var i in src_files) {
-      const srcfile = src_files[i];
-      const dstfile = srcfile.replace(src, dst);
-      const dstdir = fs.dirname(dstfile);
-      if(!fs.isdir(dstdir)) fs.mkdir(dstdir);
-      if(!fs.isfile(dstfile)) {
-        print("[copy] ", upath(srcfile.replace(src,"")));
-        fs.copy(srcfile, dstdir);
-      } else if(sys.hash.sha1(srcfile,true) != sys.hash.sha1(dstfile,true)) {
-        print("[edit] ", upath(srcfile.replace(src,"")));
-        fs.unlink(dstfile);
-        fs.copy(srcfile, dstdir);
-      }
-    }
-  };
-  stdtasks["sync-languages"] = function() {
-    const liblang = include( (me.parsing.version_data().minecraft == "1.12.2") ? ("../meta/lib/liblang.1.12.js") : ("../meta/lib/liblang.1.13.js"))(constants);
-    liblang.sync_languages();
-  };
-  stdtasks["install"] = function() {
-  };
-  stdtasks["start-server"] = function() {
-  };
-
-  /**
-   * Task main
-   */
-  me.run = function(tasks, args, no_std_tasks) {
-    const root_dir = fs.realpath(fs.dirname(sys.script)+"/../..");
-    if(!fs.isdir(root_dir+"/.git")) throw new Error("Missing git repository in parent directory of mod source.");
-    if(!no_std_tasks) {
-      for(var key in stdtasks) {
-        if(tasks[key]===undefined) tasks[key] = stdtasks[key];
-      }
-    }
-    const task_name = args[0];
-    var task_args = args.slice(1).map(function(v){return(v===undefined)?(""):(""+v).trim()}).filter(function(v){return(v.length>0)});
-    if(task_name===undefined) {
-      alert("No task specified.");
-      exit(1);
-    } else if((tasks[task_name])===undefined) {
-      alert("No task '" + task_name + "' defined.");
-      exit(1);
-    } else {
-      const pwd = fs.cwd();
-      try {
-        tasks[task_name](task_args);
-      } finally {
-        fs.chdir(pwd);
-      }
-    }
-  };
-
-  // Module include return value
-  Object.freeze(me.parsing);
-  Object.freeze(me.tasks);
-  Object.freeze(me);
-  return me;
-});
diff --git a/meta/lib/tasks.js b/meta/lib/tasks.js
deleted file mode 100644
index ecf41c2..0000000
--- a/meta/lib/tasks.js
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/djs
-"use strict";
-const root_dir = fs.realpath(fs.dirname(sys.script)+"/../..");
-const constants = include(fs.dirname(fs.realpath(sys.script)) + "/constants.js")();
-const libtask = include(fs.dirname(fs.realpath(sys.script)) + "/libtask.js")(constants);
-const modid = constants.mod_registry_name();
-var tasks = {};
-
-tasks["combined-update-json"] = function() {
-  const update_json = {
-    homepage: constants.project_download_inet_page(),
-    promos: {}
-  };
-  var update_json_src = [];
-  fs.find(root_dir + "/1.12/meta/", "update*.json", function(path){ update_json_src.push(JSON.parse(fs.readfile(path))); });
-  fs.find(root_dir + "/1.14/meta/", "update*.json", function(path){ update_json_src.push(JSON.parse(fs.readfile(path))); });
-  fs.find(root_dir + "/1.15/meta/", "update*.json", function(path){ update_json_src.push(JSON.parse(fs.readfile(path))); });
-  for(var i in update_json_src) {
-    const version_update_json = update_json_src[i];
-    for(var key in version_update_json) {
-      if(key=="homepage") {
-        continue;
-      } else if(key=="promos") {
-        for(var prkey in version_update_json.promos) {
-          update_json.promos[prkey] = version_update_json.promos[prkey];
-        }
-      } else {
-        update_json[key] = version_update_json[key];
-      }
-    }
-  }
-  update_json_src = undefined;
-  fs.mkdir(root_dir + "/meta");
-  fs.writefile(root_dir + "/meta/update.json", JSON.stringify(update_json, null, 2));
-};
-
-tasks["sync-main-repository"] = function() {
-  // step-by-step-verbose operations, as the code bases and copy data are different.
-  if((!fs.chdir(fs.dirname(fs.realpath(sys.script))+"/../..")) || (!fs.isdir(".git"))) throw new Error("Failed to switch to mod source directory.");
-  if(sys.shell("git remote -v") != "") throw new Error("Dev repository has a remote set.");
-  if(main_repo_local == "") throw new Error("Main repository (real) path not found.");
-  const test_repo_local = fs.cwd();
-  const main_repo_local = fs.realpath("../"+ constants.mod_registry_name() + "-github");
-  if(main_repo_local == fs.realpath(test_repo_local)) throw new Error("This is already the main repository");
-  const cd_dev = function(subdir) {
-    if((!fs.chdir(test_repo_local)) || (!fs.isdir(".git"))) throw new Error("Failed to switch to mod source directory.");
-    if((subdir!==undefined) && (!fs.chdir(subdir))) throw new Error("Failed to change to '" + subdir + "' of the test repository.");
-  }
-  const cd_main = function(subdir) {
-    if((!fs.chdir(main_repo_local)) || (!fs.isdir(".git"))) throw new Error("Failed to switch to main repository directory.");
-    if(fs.cwd().search("-github") < 0) throw new Error("Main repository is missing the '*-github' tag in the path name.");
-    if((subdir!==undefined) && (!fs.chdir(subdir))) throw new Error("Failed to change to '" + subdir + "' of the main repository.");
-  };
-  cd_main();
-  sys.shell("rm -rf documentation meta");
-  sys.shell("rm -f .gitignore credits.md license Makefile readme.md tasks.js");
-  cd_main("1.12"); sys.shell("rm -rf meta gradle src");
-  cd_main("1.14"); sys.shell("rm -rf meta gradle src");
-  cd_main("1.15"); sys.shell("rm -rf meta gradle src");
-  cd_dev();
-  sys.shell("cp -f .gitignore credits.md license Makefile readme.md tasks.js \"" + main_repo_local + "/\"")
-  sys.shell("cp -r documentation meta \"" + main_repo_local + "/\"")
-  {
-    cd_dev("1.12");
-    sys.shell("cp -f .gitignore build.gradle gradle.properties gradlew gradlew.bat Makefile readme.md tasks.js.* \"" + main_repo_local + "/1.12/\"")
-    sys.shell("cp -r gradle meta src \"" + main_repo_local + "/1.12/\"")
-  }
-  {
-    cd_dev("1.14");
-    sys.shell("cp -f .gitignore build.gradle gradle.properties gradlew gradlew.bat Makefile readme.md tasks.js \"" + main_repo_local + "/1.14/\"")
-    sys.shell("cp -r gradle meta src \"" + main_repo_local + "/1.14/\"")
-  }
-  {
-    cd_dev("1.15");
-    sys.shell("cp -f .gitignore build.gradle gradle.properties gradlew gradlew.bat Makefile readme.md tasks.js \"" + main_repo_local + "/1.15/\"")
-    sys.shell("cp -r gradle meta src \"" + main_repo_local + "/1.15/\"")
-  }
-  cd_main();
-  print("Main repository changes:");
-  print(sys.shell("git status -s"))
-};
-
-libtask.run(tasks, sys.args);