From 7312c36b91f0cc4dfa5dabf77c9d1d2d4e4662a3 Mon Sep 17 00:00:00 2001 From: Davide Ceschia Date: Wed, 14 Nov 2018 13:37:52 +0100 Subject: [PATCH] Bugfixes for macOS --- app/actions/instancesManager.js | 24 ++++++++++------- app/components/DInstance/DInstance.js | 2 +- app/components/Home/Home.js | 8 +++--- .../ModsManager/ModsBrowser/ModPage.js | 26 +++++++++---------- app/constants.js | 2 +- app/utils/MCLaunchCommand.js | 2 +- app/utils/cli.js | 3 ++- app/utils/javaLocationFinder.js | 4 +-- package.json | 2 +- 9 files changed, 40 insertions(+), 33 deletions(-) diff --git a/app/actions/instancesManager.js b/app/actions/instancesManager.js index 6215e8fc1..cc51a11cd 100644 --- a/app/actions/instancesManager.js +++ b/app/actions/instancesManager.js @@ -1,7 +1,9 @@ import { message } from 'antd'; import log from 'electron-log'; import { exec } from 'child_process'; +import path from 'path'; import launchCommand from '../utils/MCLaunchCommand'; +import { PACKS_PATH } from '../constants'; export const SELECT_INSTANCE = 'SELECT_INSTANCE'; export const START_INSTANCE = 'START_INSTANCE'; @@ -25,7 +27,7 @@ export function selectInstanceNullable(name) { } export function selectInstance(name) { - return (dispatch) => { + return dispatch => { dispatch({ type: SELECT_INSTANCE, payload: name @@ -36,14 +38,18 @@ export function selectInstance(name) { export function startInstance(instanceName) { return async (dispatch, getState) => { const { auth } = getState(); - const start = exec(await launchCommand(instanceName, auth), (error, stdout, stderr) => { - if (error) { - console.error(`exec error: ${error}`); - return; + const start = exec( + await launchCommand(instanceName, auth), + { cwd: path.join(PACKS_PATH, instanceName) }, + (error, stdout, stderr) => { + if (error) { + console.error(`exec error: ${error}`); + return; + } + console.log(`stdout: ${stdout}`); + console.log(`stderr: ${stderr}`); } - console.log(`stdout: ${stdout}`); - console.log(`stderr: ${stderr}`); - }); + ); dispatch({ type: START_INSTANCE, payload: instanceName, @@ -55,7 +61,7 @@ export function startInstance(instanceName) { payload: instanceName }); }); - start.on('error', (err) => { + start.on('error', err => { message.error('There was an error while starting the instance'); log.error(err); }); diff --git a/app/components/DInstance/DInstance.js b/app/components/DInstance/DInstance.js index 82033c42e..43a710df2 100644 --- a/app/components/DInstance/DInstance.js +++ b/app/components/DInstance/DInstance.js @@ -126,11 +126,11 @@ export default class DInstance extends Component { selectInstance(null); message.success('Instance deleted'); } catch (err) { - hideMenu(`contextMenu-${name}`); message.error('Error deleting instance'); log.error(err); } finally { this.setState({ deleting: false }); + hideMenu(`contextMenu-${name}`); } }; diff --git a/app/components/Home/Home.js b/app/components/Home/Home.js index f24a8a0a1..9b02b20ff 100644 --- a/app/components/Home/Home.js +++ b/app/components/Home/Home.js @@ -121,9 +121,9 @@ export default class Home extends Component { marginTop: 15, textAlign: 'center' }} - title="Try out the new v1.13.1" + title="Try out the new v1.13.2" > - V1.13.1 has just been released. Wanna try it out? + V1.13.2 has just been released. Wanna try it out? {this.state.latestBtnClicked || this.state.latestInstalled ? ( { loading={this.props.packCreationLoading} style={{ display: 'block', margin: '35px auto' }} onClick={() => { - this.props.createPack('1.13.1', '1.13.1'); + this.props.createPack('1.13.2', '1.13.2'); this.setState({ latestBtnClicked: true }); }} > - Install and Start v1.13.1 + Install and Start v1.13.2 )} diff --git a/app/components/InstanceManagerModal/ModsManager/ModsBrowser/ModPage.js b/app/components/InstanceManagerModal/ModsManager/ModsBrowser/ModPage.js index 3444f3d65..b651aff64 100644 --- a/app/components/InstanceManagerModal/ModsManager/ModsBrowser/ModPage.js +++ b/app/components/InstanceManagerModal/ModsManager/ModsBrowser/ModPage.js @@ -1,15 +1,13 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; -import Link from 'react-router-dom/Link'; import axios from 'axios'; import ContentLoader from 'react-content-loader'; import path from 'path'; -import log from 'electron-log'; +import Promise from 'bluebird'; import _ from 'lodash'; -import { List, Avatar, Button, Input, Select, Icon, Popover } from 'antd'; +import { Button, Select } from 'antd'; import { PACKS_PATH, CURSEMETA_API_URL } from '../../../../constants'; import { downloadFile } from '../../../../utils/downloader'; -import { numberToRoundedWord } from '../../../../utils/numbers'; import styles from './ModPage.scss'; @@ -86,18 +84,20 @@ class ModPage extends Component { }; getAddonData = async addon => { - const { data } = await axios.get( - `${CURSEMETA_API_URL}/direct/addon/${addon}` - ); + const [{ data }, files] = await Promise.all([ + axios.get(`${CURSEMETA_API_URL}/direct/addon/${addon}`), + axios.get(`${CURSEMETA_API_URL}/direct/addon/${addon}/files`) + ]); - const files = (await axios.get( - `${CURSEMETA_API_URL}/direct/addon/${addon}/files` - )).data.filter(el => + const filteredFiles = files.data.filter(el => el.gameVersion.includes(this.props.match.params.version) ); this.setState({ - data: { ...data, allFiles: _.orderBy(files, ['fileDate'], ['desc']) } + data: { + ...data, + allFiles: _.orderBy(filteredFiles, ['fileDate'], ['desc']) + } }); }; @@ -219,8 +219,8 @@ class ModPage extends Component { {this.isInstalling(this.state.selectedVersion) ? 'Installing' : this.isDownloadCompleted(this.state.selectedVersion) - ? 'Installed' - : 'Install Selected Mod'} + ? 'Installed' + : 'Install Selected Mod'} diff --git a/app/constants.js b/app/constants.js index c8e6318ec..c2bbec9a5 100644 --- a/app/constants.js +++ b/app/constants.js @@ -35,7 +35,7 @@ export const CURSEFORGE_MODLOADERS_API = 'https://modloaders.cursecdn.com/647622546/maven'; export const NEWS_URL = 'https://minecraft.net/en-us/api/tiles/channel/not_set,Community%20content/region/None/category/Culture,Insider,News/page/1'; -export const JAVA_URL = 'https://java.com/download'; +export const JAVA_URL = 'https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html'; export const UPDATE_URL = 'https://raw.githubusercontent.com/gorilla-devs/GDLauncher/master/package.json'; export const THEMES = { diff --git a/app/utils/MCLaunchCommand.js b/app/utils/MCLaunchCommand.js index 583dc7ba8..55f575666 100644 --- a/app/utils/MCLaunchCommand.js +++ b/app/utils/MCLaunchCommand.js @@ -52,7 +52,7 @@ const getMCArguments = (vanilla, forge, packName, userData) => { return Arguments .replace('${auth_player_name}', userData.displayName) .replace('${auth_session}', userData.accessToken) // Legacy check for really old versions - .replace('${game_directory}', path.join(PACKS_PATH, packName)) + .replace('${game_directory}', `"${path.join(PACKS_PATH, packName)}"`) .replace('${game_assets}', path.join(INSTANCES_PATH, 'assets', vanilla.assets === 'legacy' ? '/virtual/legacy' : '')) // Another check for really old versions .replace('${version_name}', forge !== null ? forge.versionInfo.id : vanilla.id) .replace('${assets_root}', path.join(INSTANCES_PATH, 'assets', vanilla.assets === 'legacy' ? '/virtual/legacy' : '')) diff --git a/app/utils/cli.js b/app/utils/cli.js index ec2e18eb3..fbbb80eb7 100644 --- a/app/utils/cli.js +++ b/app/utils/cli.js @@ -4,7 +4,8 @@ import launchCommand from './MCLaunchCommand'; import store from '../localStore'; const parseCLI = async (data, callback) => { - const instanceName = (minimist(data.slice(1)).i).toString(); + // toString is used if the instance name is a number (1132) or other values different from a string + const instanceName = minimist(data.slice(1)).i.toString(); const auth = store.get('user'); const start = exec( await launchCommand(instanceName, auth), diff --git a/app/utils/javaLocationFinder.js b/app/utils/javaLocationFinder.js index 4627e2bc7..b62e1089e 100644 --- a/app/utils/javaLocationFinder.js +++ b/app/utils/javaLocationFinder.js @@ -12,10 +12,10 @@ const findJavaHome = async () => { switch (os.platform()) { case LINUX: case DARWIN: - command = 'which javaw'; + command = 'which java'; break; case WINDOWS: - command = 'where javaw'; + command = 'where java'; break; default: break; diff --git a/package.json b/package.json index 24f0bcd64..5cc8385be 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "gdlauncher", "productName": "GDLauncher", "main": "./app/main.prod.js", - "version": "0.8.7", + "version": "0.8.8", "description": "GDLauncher is simple, yet powerful Minecraft custom launcher with a strong focus on the user experience", "scripts": { "build": "yarn build-antd && concurrently \"yarn build-main\" \"yarn build-renderer\"",