Fix confilicts

This commit is contained in:
GeekCornerGH 2021-10-25 17:17:36 +02:00
commit 7132d2c402
19 changed files with 1201 additions and 1027 deletions

29
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Build/release
on: push
jobs:
release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- name: Check out Git repository
uses: actions/checkout@v1
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 16
- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
with:
github_token: ${{ secrets.github_token }}
# If the commit is tagged with a version (e.g. "v1.0.0"),
# release the app after building
release: ${{ startsWith(github.ref, 'refs/tags/v') }}

2
.nvmrc
View File

@ -1 +1 @@
12
16

View File

@ -1,45 +0,0 @@
matrix:
include:
- os: osx
osx_image: xcode11.3
language: node_js
node_js: "12"
env:
- ELECTRON_CACHE=$HOME/.cache/electron
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
- ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true
- CSC_IDENTITY_AUTO_DISCOVERY=false
- os: linux
services: docker
language: generic
node_js: "12"
env:
- ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true
cache:
directories:
- node_modules
- $HOME/.cache/electron
- $HOME/.cache/electron-builder
script:
- |
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
ENVS=`env | grep -iE '(DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS|APPVEYOR_|CSC_|_TOKEN|_KEY|AWS_|STRIP|BUILD_)' | sed -n '/^[^\t]/s/=.*//p' | sed '/^$/d' | sed 's/^/-e /g' | tr '\n' ' '`
docker run $ENVS --rm \
-v ${PWD}:/project \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:wine \
/bin/bash -c "node -v && npm ci && npm run cilinux"
else
npm run cidarwin
fi
before_cache:
- rm -rf $HOME/.cache/electron-builder/wine
branches:
except:
- "/^v\\d+\\.\\d+\\.\\d+$/"

21
LICENSE.txt Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017-2021 Daniel D. Scalzi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -53,9 +53,10 @@ If you download from the [Releases](https://github.com/dscalzi/HeliosLauncher/re
| Platform | File |
| -------- | ---- |
| Windows x64 | `helioslauncher-setup-VERSION.exe` |
| macOS | `helioslauncher-VERSION.dmg` |
| Linux x64 | `helioslauncher-VERSION-x86_64.AppImage` |
| Windows x64 | `Helios-Launcher-setup-VERSION.exe` |
| macOS x64 | `Helios-Launcher-setup-VERSION.dmg` |
| macOS arm64 | `Helios-Launcher-setup-VERSION-arm64.dmg` |
| Linux x64 | `Helios-Launcher-setup-VERSION.AppImage` |
## Console
@ -76,11 +77,13 @@ If you want to export the console output, simply right click anywhere on the con
## Development
This section details the setup of a basic developmentment environment.
### Getting Started
**System Requirements**
* [Node.js][nodejs] v12
* [Node.js][nodejs] v16
---
@ -175,14 +178,7 @@ Note that you **cannot** open the DevTools window while using this debug configu
### Note on Third-Party Usage
You may use this software in your own project so long as the following conditions are met.
* Credit is expressly given to the original authors (Daniel Scalzi).
* Include a link to the original source on the launcher's About page.
* Credit the authors and provide a link to the original source in any publications or download pages.
* The source code remain **public** as a fork of this repository.
We reserve the right to update these conditions at any time, please check back periodically.
Please give credit to the original author and provide a link to the original source. This is free software, please do at least this much.
---

View File

@ -5,6 +5,7 @@ const child_process = require('child_process')
const crypto = require('crypto')
const EventEmitter = require('events')
const fs = require('fs-extra')
const StreamZip = require('node-stream-zip')
const path = require('path')
const Registry = require('winreg')
const request = require('request')
@ -222,42 +223,6 @@ class JavaGuard extends EventEmitter {
this.mcVersion = mcVersion
}
// /**
// * @typedef OracleJREData
// * @property {string} uri The base uri of the JRE.
// * @property {{major: string, update: string, build: string}} version Object containing version information.
// */
// /**
// * Resolves the latest version of Oracle's JRE and parses its download link.
// *
// * @returns {Promise.<OracleJREData>} Promise which resolved to an object containing the JRE download data.
// */
// static _latestJREOracle(){
// const url = 'https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html'
// const regex = /https:\/\/.+?(?=\/java)\/java\/jdk\/([0-9]+u[0-9]+)-(b[0-9]+)\/([a-f0-9]{32})?\/jre-\1/
// return new Promise((resolve, reject) => {
// request(url, (err, resp, body) => {
// if(!err){
// const arr = body.match(regex)
// const verSplit = arr[1].split('u')
// resolve({
// uri: arr[0],
// version: {
// major: verSplit[0],
// update: verSplit[1],
// build: arr[2]
// }
// })
// } else {
// resolve(null)
// }
// })
// })
// }
/**
* @typedef OpenJDKData
* @property {string} uri The base uri of the JRE.
@ -281,30 +246,41 @@ class JavaGuard extends EventEmitter {
if(process.platform === 'darwin') {
return this._latestCorretto(major)
} else {
return this._latestAdoptOpenJDK(major)
return this._latestAdoptium(major)
}
}
static _latestAdoptOpenJDK(major) {
static _latestAdoptium(major) {
const majorNum = Number(major)
const sanitizedOS = process.platform === 'win32' ? 'windows' : (process.platform === 'darwin' ? 'mac' : process.platform)
const url = `https://api.adoptopenjdk.net/v2/latestAssets/nightly/openjdk${major}?os=${sanitizedOS}&arch=x64&heap_size=normal&openjdk_impl=hotspot&type=jre`
const url = `https://api.adoptium.net/v3/assets/latest/${major}/hotspot?vendor=eclipse`
return new Promise((resolve, reject) => {
request({url, json: true}, (err, resp, body) => {
if(!err && body.length > 0){
resolve({
uri: body[0].binary_link,
size: body[0].binary_size,
name: body[0].binary_name
const targetBinary = body.find(entry => {
return entry.version.major === majorNum
&& entry.binary.os === sanitizedOS
&& entry.binary.image_type === 'jdk'
&& entry.binary.architecture === 'x64'
})
if(targetBinary != null) {
resolve({
uri: targetBinary.binary.package.link,
size: targetBinary.binary.package.size,
name: targetBinary.binary.package.name
})
} else {
resolve(null)
}
} else {
resolve(null)
}
})
})
}
static _latestCorretto(major) {
@ -839,6 +815,7 @@ class JavaGuard extends EventEmitter {
pathSet1 = new Set([
...pathSet1,
...(await JavaGuard._scanFileSystem('C:\\Program Files\\Java')),
...(await JavaGuard._scanFileSystem('C:\\Program Files\\Eclipse Foundation')),
...(await JavaGuard._scanFileSystem('C:\\Program Files\\AdoptOpenJDK'))
])
}
@ -1583,21 +1560,7 @@ class AssetGuard extends EventEmitter {
this.java = new DLTracker([jre], jre.size, (a, self) => {
if(verData.name.endsWith('zip')){
const zip = new AdmZip(a.to)
const pos = path.join(dataDir, zip.getEntries()[0].entryName)
zip.extractAllToAsync(dataDir, true, (err) => {
if(err){
console.log(err)
self.emit('complete', 'java', JavaGuard.javaExecFromRoot(pos))
} else {
fs.unlink(a.to, err => {
if(err){
console.log(err)
}
self.emit('complete', 'java', JavaGuard.javaExecFromRoot(pos))
})
}
})
this._extractJdkZip(a.to, dataDir, self)
} else {
// Tar.gz
@ -1638,6 +1601,32 @@ class AssetGuard extends EventEmitter {
}
async _extractJdkZip(zipPath, runtimeDir, self) {
const zip = new StreamZip.async({
file: zipPath,
storeEntries: true
})
let pos = ''
try {
const entries = await zip.entries()
pos = path.join(runtimeDir, Object.keys(entries)[0])
console.log('Extracting jdk..')
await zip.extract(null, runtimeDir)
console.log('Cleaning up..')
await fs.remove(zipPath)
console.log('Jdk extraction complete.')
} catch(err) {
console.log(err)
} finally {
zip.close()
self.emit('complete', 'java', JavaGuard.javaExecFromRoot(pos))
}
}
// _enqueueOracleJRE(dataDir){
// return new Promise((resolve, reject) => {
// JavaGuard._latestJREOracle().then(verData => {

View File

@ -9,7 +9,7 @@ const sysRoot = process.env.APPDATA || (process.platform == 'darwin' ? process.e
const dataPath = path.join(sysRoot, '.helioslauncher')
// Forked processes do not have access to electron, so we have this workaround.
const launcherDir = process.env.CONFIG_DIRECT_PATH || require('electron').remote.app.getPath('userData')
const launcherDir = process.env.CONFIG_DIRECT_PATH || require('@electron/remote').app.getPath('userData')
/**
* Retrieve the absolute path of the launcher directory.

View File

@ -92,14 +92,17 @@ exports.addDropinMods = function(files, modsdir) {
* @param {string} modsDir The path to the mods directory.
* @param {string} fullName The fullName of the discovered mod to delete.
*
* @returns {boolean} True if the mod was deleted, otherwise false.
* @returns {Promise.<boolean>} True if the mod was deleted, otherwise false.
*/
exports.deleteDropinMod = function(modsDir, fullName){
const res = shell.moveItemToTrash(path.join(modsDir, fullName))
if(!res){
exports.deleteDropinMod = async function(modsDir, fullName){
try {
await shell.trashItem(path.join(modsDir, fullName))
return true
} catch(error) {
shell.beep()
console.error('Error deleting drop-in mod.', error)
return false
}
return res
}
/**

View File

@ -130,7 +130,7 @@ function updateSelectedAccount(authUser){
username = authUser.displayName
}
if(authUser.uuid != null){
document.getElementById('avatarContainer').style.backgroundImage = `url('https://crafatar.com/renders/body/${authUser.uuid}')`
document.getElementById('avatarContainer').style.backgroundImage = `url('https://mc-heads.net/body/${authUser.uuid}/right')`
}
}
user_text.innerHTML = username
@ -327,7 +327,7 @@ function asyncSystemScan(mcVersion, launchAfter = true){
// Show this information to the user.
setOverlayContent(
'No Compatible<br>Java Installation Found',
'In order to join WesterosCraft, you need a 64-bit installation of Java 8. Would you like us to install a copy? By installing, you accept <a href="http://www.oracle.com/technetwork/java/javase/terms/license/index.html">Oracle\'s license agreement</a>.',
'In order to join WesterosCraft, you need a 64-bit installation of Java 8. Would you like us to install a copy?',
'Install Java',
'Install Manually'
)

View File

@ -299,7 +299,7 @@ function populateAccountListings(){
let htmlString = ''
for(let i=0; i<accounts.length; i++){
htmlString += `<button class="accountListing" uuid="${accounts[i].uuid}" ${i===0 ? 'selected' : ''}>
<img src="https://crafatar.com/renders/head/${accounts[i].uuid}?scale=2&default=MHF_Steve&overlay">
<img src="https://mc-heads.net/head/${accounts[i].uuid}/40">
<div class="accountListingName">${accounts[i].displayName}</div>
</button>`
}

View File

@ -444,7 +444,7 @@ function populateAuthAccounts(){
const acc = authAccounts[val]
authAccountStr += `<div class="settingsAuthAccount" uuid="${acc.uuid}">
<div class="settingsAuthAccountLeft">
<img class="settingsAuthAccountImage" alt="${acc.displayName}" src="https://crafatar.com/renders/body/${acc.uuid}?scale=3&default=MHF_Steve&overlay">
<img class="settingsAuthAccountImage" alt="${acc.displayName}" src="https://mc-heads.net/body/${acc.uuid}/60">
</div>
<div class="settingsAuthAccountRight">
<div class="settingsAuthAccountDetails">
@ -687,9 +687,9 @@ function resolveDropinModsForUI(){
function bindDropinModsRemoveButton(){
const sEls = settingsModsContainer.querySelectorAll('[remmod]')
Array.from(sEls).map((v, index, arr) => {
v.onclick = () => {
v.onclick = async () => {
const fullName = v.getAttribute('remmod')
const res = DropinModUtil.deleteDropinMod(CACHE_SETTINGS_MODS_DIR, fullName)
const res = await DropinModUtil.deleteDropinMod(CACHE_SETTINGS_MODS_DIR, fullName)
if(res){
document.getElementById(fullName).remove()
} else {

View File

@ -6,7 +6,8 @@
*/
// Requirements
const $ = require('jquery')
const {ipcRenderer, remote, shell, webFrame} = require('electron')
const {ipcRenderer, shell, webFrame} = require('electron')
const remote = require('@electron/remote')
const isDev = require('./assets/js/isdev')
const LoggerUtil = require('./assets/js/loggerutil')
@ -48,7 +49,7 @@ if(!isDev){
loggerAutoUpdaterSuccess.log('New update available', info.version)
if(process.platform === 'darwin'){
info.darwindownload = `https://github.com/dscalzi/HeliosLauncher/releases/download/v${info.version}/helioslauncher-setup-${info.version}.dmg`
info.darwindownload = `https://github.com/dscalzi/HeliosLauncher/releases/download/v${info.version}/helioslauncher-setup-${info.version}${process.arch === 'arm64' ? '-arm64' : ''}.dmg`
showUpdateUI(info)
}

View File

@ -29,7 +29,7 @@
</div>
<div id="loginOptions">
<span class="loginSpanDim">
<a href="https://my.minecraft.net/en-us/password/forgot/">forgot password?</a>
<a href="https://minecraft.net/password/forgot/">forgot password?</a>
</span>
<label id="checkmarkContainer">
<input id="loginRememberOption" type="checkbox" checked>
@ -54,7 +54,7 @@
</button>
<div id="loginDisclaimer">
<span class="loginSpanDim" id="loginRegisterSpan">
<a href="https://minecraft.net/en-us/store/minecraft/">Need an Account?</a>
<a href="https://minecraft.net/store/minecraft-java-edition/">Need an Account?</a>
</span>
<p class="loginDisclaimerText">Your password is sent directly to mojang and never stored.</p>
<p class="loginDisclaimerText">Helios Launcher is not affiliated with Mojang AB.</p>

View File

@ -1,68 +0,0 @@
const builder = require('electron-builder')
const Platform = builder.Platform
function getCurrentPlatform(){
switch(process.platform){
case 'win32':
return Platform.WINDOWS
case 'darwin':
return Platform.MAC
case 'linux':
return Platform.linux
default:
console.error('Cannot resolve current platform!')
return undefined
}
}
builder.build({
targets: (process.argv[2] != null && Platform[process.argv[2]] != null ? Platform[process.argv[2]] : getCurrentPlatform()).createTarget(),
config: {
appId: 'helioslauncher',
productName: 'Helios Launcher',
artifactName: '${productName}-setup-${version}.${ext}',
copyright: 'Copyright © 2018-2020 Daniel Scalzi',
directories: {
buildResources: 'build',
output: 'dist'
},
win: {
target: [
{
target: 'nsis',
arch: 'x64'
}
]
},
nsis: {
oneClick: false,
perMachine: false,
allowElevation: true,
allowToChangeInstallationDirectory: true
},
mac: {
target: 'dmg',
category: 'public.app-category.games'
},
linux: {
target: 'AppImage',
maintainer: 'Daniel Scalzi',
vendor: 'Daniel Scalzi',
synopsis: 'Modded Minecraft Launcher',
description: 'Custom launcher which allows users to join modded servers. All mods, configurations, and updates are handled automatically.',
category: 'Game'
},
compression: 'maximum',
files: [
'!{dist,.gitignore,.vscode,docs,dev-app-update.yml,.travis.yml,.nvmrc,.eslintrc.json,build.js}'
],
extraResources: [
'libraries'
],
asar: true
}
}).then(() => {
console.log('Build complete!')
}).catch(err => {
console.error('Error during build!', err)
})

51
electron-builder.yml Normal file
View File

@ -0,0 +1,51 @@
appId: 'helioslauncher'
productName: 'Helios Launcher'
artifactName: '${productName}-setup-${version}.${ext}'
copyright: 'Copyright © 2018-2021 Daniel Scalzi'
asar: true
compression: 'maximum'
files:
- '!{dist,.gitignore,.vscode,docs,dev-app-update.yml,.travis.yml,.nvmrc,.eslintrc.json,build.js}'
extraResources:
- 'libraries'
# Windows Configuration
win:
target:
- target: 'nsis'
arch: 'x64'
# Windows Installer Configuration
nsis:
oneClick: false
perMachine: false
allowElevation: true
allowToChangeInstallationDirectory: true
# macOS Configuration
mac:
target:
- target: 'dmg'
arch:
- 'x64'
- 'arm64'
artifactName: '${productName}-setup-${version}-${arch}.${ext}'
category: 'public.app-category.games'
# Linux Configuration
linux:
target: 'AppImage'
maintainer: 'Daniel Scalzi'
vendor: 'Daniel Scalzi'
synopsis: 'Modded Minecraft Launcher'
description: 'Custom launcher which allows users to join modded servers. All mods, configurations, and updates are handled automatically.'
category: 'Game'
directories:
buildResources: 'build'
output: 'dist'

View File

@ -1,3 +1,6 @@
const remoteMain = require('@electron/remote/main')
remoteMain.initialize()
// Requirements
const { app, BrowserWindow, ipcMain, Menu } = require('electron')
const autoUpdater = require('electron-updater').autoUpdater
@ -6,7 +9,7 @@ const fs = require('fs')
const isDev = require('./app/assets/js/isdev')
const path = require('path')
const semver = require('semver')
const url = require('url')
const { pathToFileURL } = require('url')
// Setup auto updater.
function initAutoUpdater(event, data) {
@ -85,9 +88,6 @@ ipcMain.on('distributionIndexDone', (event, res) => {
// https://electronjs.org/docs/tutorial/offscreen-rendering
app.disableHardwareAcceleration()
// https://github.com/electron/electron/issues/18397
app.allowRendererProcessReuse = true
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
@ -102,20 +102,15 @@ function createWindow() {
webPreferences: {
preload: path.join(__dirname, 'app', 'assets', 'js', 'preloader.js'),
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
worldSafeExecuteJavaScript: true
contextIsolation: false
},
backgroundColor: '#171614'
})
remoteMain.enable(win.webContents)
ejse.data('bkid', Math.floor((Math.random() * fs.readdirSync(path.join(__dirname, 'app', 'assets', 'images', 'backgrounds')).length)))
win.loadURL(url.format({
pathname: path.join(__dirname, 'app', 'app.ejs'),
protocol: 'file:',
slashes: true
}))
win.loadURL(pathToFileURL(path.join(__dirname, 'app', 'app.ejs')).toString())
/*win.once('ready-to-show', () => {
win.show()

Binary file not shown.

1779
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,37 +13,36 @@
"main": "index.js",
"scripts": {
"start": "electron .",
"cilinux": "node build.js WINDOWS && node build.js LINUX",
"cidarwin": "node build.js MAC",
"dist": "cross-env ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true node build.js",
"dist:win": "npm run dist -- WINDOWS",
"dist:mac": "npm run dist -- MAC",
"dist:linux": "npm run dist -- LINUX",
"dist": "electron-builder build",
"dist:win": "npm run dist -- -w",
"dist:mac": "npm run dist -- -m",
"dist:linux": "npm run dist -- -l",
"lint": "eslint --config .eslintrc.json ."
},
"engines": {
"node": "12.x.x"
"node": "16.x.x"
},
"dependencies": {
"adm-zip": "^0.5.1",
"async": "^3.2.0",
"discord-rpc": "^3.1.4",
"ejs": "^3.1.5",
"@electron/remote": "^2.0.1",
"adm-zip": "^0.5.9",
"async": "^3.2.1",
"discord-rpc": "^3.2.0",
"ejs": "^3.1.6",
"ejs-electron": "^2.1.1",
"electron-updater": "^4.3.5",
"fs-extra": "^9.0.1",
"electron-updater": "^4.3.9",
"fs-extra": "^10.0.0",
"github-syntax-dark": "^0.5.0",
"jquery": "^3.5.1",
"jquery": "^3.6.0",
"node-stream-zip": "^1.15.0",
"request": "^2.88.2",
"semver": "^7.3.4",
"semver": "^7.3.5",
"tar-fs": "^2.1.1",
"winreg": "^1.2.4"
},
"devDependencies": {
"cross-env": "^7.0.3",
"electron": "^11.0.5",
"electron-builder": "^22.9.1",
"eslint": "^7.15.0"
"electron": "^15.2.0",
"electron-builder": "^22.13.1",
"eslint": "^8.0.1"
},
"repository": {
"type": "git",