def __init__(self, directory=Path.cwd(), wrapper=False): if wrapper: self._gradle = sh.Command(str((directory / 'gradlew').absolute())) else: self._gradle = sh.env.gradle self._gradle = bake_nice_tty(self._gradle) self.dir = directory
def main(path=None): try: launcher = dl_launcher() ghpages = clone_downloads() path = path or (sys.argv[1] if len(sys.argv) > 1 else input_path()) file_dir = Path(path).absolute().resolve() if not file_dir.exists(): fail("{} doesn't exist".format(file_dir)) print('Loading from {}'.format(file_dir)) package_data = discover_data(file_dir) patch_version = discover_patch_version() launcher_version = discover_launcher_version(launcher) + '-' + patch_version fail_if_no_changes(ghpages, package_data['version'], launcher_version) apply_launcher_patches(launcher) (launcher_bootstrap, launcher_fancy, launcher_builder) = build_launcher(Gradle(directory=launcher, wrapper=True)) print('Found LBO ' + str(launcher_bootstrap)) print('Found LFA ' + str(launcher_fancy)) print('Found LBL ' + str(launcher_builder)) print('Launcher version ' + launcher_version) client_dir = build_modpack(java_jar.bake(launcher_builder), package_data['version'], file_dir) server_dir = build_server(bake_nice_tty(sh.java.bake('-cp', launcher_builder)), file_dir / 'src') clear_and_copy(package_data['name'], client_dir, ghpages) pack_real_launcher(ghpages, launcher_version, launcher_fancy) write_jsons(ghpages, package_data['name'], package_data['title'], package_data['version'], launcher_version) upload_downloads(ghpages, package_data['version'], launcher_version) except Exception as e: l = len(e.args) if l == 0: fail(str(type(e))) elif l == 1: fail(str(e.args[0])) else: fail(str(e.args))
def pack_real_launcher(downloads, version_full, launcher_jar): target = Path(downloads) / 'data' / 'launcher-{}.jar.pack'.format(version_full) if target.exists(): target.unlink() bake_nice_tty(sh.pack200)('--no-gzip', str(target.absolute()), launcher_jar)
""" Main file for building the modpack + uploading """ import json import re import sh import shutil import sys from cmd import cd, bake_nice_tty from gradle import Gradle from log import log from pathlib import Path git = bake_nice_tty(sh.git) git_last_commit_message = git.log.bake('-1', '--pretty=%B') git_last_commit_sha = git.log.bake('-1', '--pretty=%H') java_jar = bake_nice_tty(sh.java.bake('-jar')) lv_regex = re.compile(r'version = ["\'](\d+\.\d+\.\d+(?:-SNAPSHOT)?)["\']') def fail(msg): exec = sys.exc_info() if exec[0]: if isinstance(exec[0], sh.ErrorReturnCode): print('Error code', exec[0].exit_code, file=sys.stderr) else: import traceback traceback.print_exc() print(msg, file=sys.stderr) sys.exit(1)