diff --git a/.gitignore b/.gitignore index 2ccb550..66207a5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ bin/ dist/ ext/ temp/ +gc*/ resources/js/neutralino.js resources/bg/official diff --git a/resources/index.html b/resources/index.html index f59f5ea..81a7e7a 100644 --- a/resources/index.html +++ b/resources/index.html @@ -8,6 +8,7 @@ + diff --git a/resources/js/gcdownloader.js b/resources/js/gcdownloader.js new file mode 100644 index 0000000..c1b5e1b --- /dev/null +++ b/resources/js/gcdownloader.js @@ -0,0 +1,24 @@ +async function clearGCInstallation() { + Neutralino.os.execCommand(`del /s /q "./gc"`) +} + +async function downloadGC(branch) { + const config = await getCfg() + + // If we are pulling from a new branch, delete the old installation + if (config.grasscutterBranch !== branch) await clearGCInstallation() + + // Keystore for branch (since they can differ) + const keystoreUrl = `https://github.com/Grasscutters/Grasscutter/raw/${branch}/keystore.p12` + + // External service that allows un-authed artifact downloading + const artiUrl = `https://nightly.link/Grasscutters/Grasscutter/workflows/build/${branch}/Grasscutter.zip` + + // Run installer + createCmdWindow(`.\\scripts\\gcdownload.cmd ${artiUrl} ${keystoreUrl} ${branch}`) + + // Set current installation in config + config.grasscutterBranch = branch + + Neutralino.storage.setData('config', JSON.stringify(config)) +} \ No newline at end of file diff --git a/resources/js/helpers.js b/resources/js/helpers.js index c0b31c0..ad313fa 100644 --- a/resources/js/helpers.js +++ b/resources/js/helpers.js @@ -12,6 +12,7 @@ serverLaunchPanel: false, language: 'en', useHttps: true, + grasscutterBranch: '', } const cfgStr = await Neutralino.storage.getData('config').catch(e => { // The data isn't set, so this is our first time opening diff --git a/scripts/gcdownload.cmd b/scripts/gcdownload.cmd new file mode 100644 index 0000000..9105de2 --- /dev/null +++ b/scripts/gcdownload.cmd @@ -0,0 +1,34 @@ +@echo off + +set KEYSTORE_URL=%1 +set ARTIFACT_URL=%2 +set BRANCH=%3 +set FOLDER_NAME=".\gc-%BRANCH%" + +if not exist %FOLDER_NAME% mkdir %FOLDER_NAME% +if not exist ".\temp" mkdir ".\temp" + +echo Downloading Grasscutter prebuilt jar... + +:: Download the jar +powershell Invoke-WebRequest -Uri %KEYSTORE_URL% -OutFile "./temp/gcjar.zip" + +echo Extracting... + +powershell Expand-Archive -Path "./temp/gcjar.zip" -DestinationPath %FOLDER_NAME% -Force + +:: Download the keystore.p12 file + +echo Downloading keystore.p12... + +powershell Invoke-WebRequest -Uri %ARTIFACT_URL% -OutFile "./%FOLDER_NAME%/keystore.p12" + +:: Remove temp stuff +del /s /q "./temp" + +echo Done, latest Grasscutter %BRANCH% now downloaded in %FOLDER_NAME% + +pause + +exit /b +