From 474994e30f9671d0c3c3ab9d4b412fde57d1b152 Mon Sep 17 00:00:00 2001 From: Jota Date: Sat, 21 Aug 2021 11:57:29 -0300 Subject: [PATCH 1/2] Fix for config file not being created --- index.html | 2 +- modules/config.ts | 21 +++++---------------- modules/mod_list_loader.ts | 1 - patchnotes-page/patchnotes.html | 2 +- patchnotes-page/patchnotespage-preload.ts | 2 +- preload.ts | 2 +- 6 files changed, 9 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index 4f2d14c..b2ba3f7 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,7 @@ - + Creators.TF Launcher - Alpha Version diff --git a/modules/config.ts b/modules/config.ts index e035789..2d11d04 100644 --- a/modules/config.ts +++ b/modules/config.ts @@ -42,7 +42,7 @@ class Config { //Try to populate the default values of the steam directory and tf2 directory automatically. this.config.steam_directory = await Config.GetSteamDirectory(); - log.log(`Auto locater for the users steam directory returned '${this.config.steam_directory}'`); + log.log(`Auto locater for the users steam directory returned "${this.config.steam_directory}"`); if (this.config.steam_directory != "") { //Try to find the users tf2 directory automatically. @@ -102,7 +102,6 @@ class Config { public static async GetConfigFullPath(): Promise { const _path = (process.env.APPDATA || (process.platform == "darwin" ? process.env.HOME + "/Library/Preferences" : process.env.HOME + "/.local/share")) + "/creators-tf-launcher"; - await FsExtensions.ensureDirectoryExists(_path); const configName = "config.json"; @@ -121,9 +120,9 @@ class Config { * @returns First existing path in steamPaths or null if none of the paths exist, with prefix added */ - async function getExistingPath(steamPaths: Array, pathPrefix: string): Promise { + async function getExistingPath(steamPaths: Array): Promise { for (let steamPath of steamPaths) { - steamPath = path.join(pathPrefix, steamPath); + steamPath = path.join(steamPath); if (await FsExtensions.pathExists(steamPath)) { return steamPath; } @@ -136,24 +135,14 @@ class Config { //We check the most likely install paths. if (os.platform() == "win32") { const steamPaths = ["C:/Program Files (x86)/Steam", "C:/Program Files/Steam"]; - //@ts-ignore basedir = await getExistingPath(steamPaths); } else if (os.platform() == "linux" || "freebsd" || "openbsd") { //Linux solution is untested const homedir = process.env.HOME; - const steamPaths = [ - { - "paths": [".steam/steam"], - "prefix": homedir - }, - { - "paths": [".local/share/steam"], - "prefix": "" - } - ]; + const steamPaths = [".steam/steam", ".local/share/steam"]; for (const pathGroup of steamPaths) { - basedir = await getExistingPath(pathGroup["paths"], pathGroup["prefix"]); + basedir = homedir + await getExistingPath(pathGroup["paths"]); if (basedir != "") { break; } diff --git a/modules/mod_list_loader.ts b/modules/mod_list_loader.ts index fb55b04..660d60f 100644 --- a/modules/mod_list_loader.ts +++ b/modules/mod_list_loader.ts @@ -10,7 +10,6 @@ import Utilities from "./utilities"; //More than one allows fallbacks. const modListURLs = [ "https://fastdl.creators.tf/launcher/mods.json", - "https://raw.githubusercontent.com/ampersoftware/Creators.TF-Community-Launcher/master/internal/mods.json", "https://raw.githubusercontent.com/CreatorsTF/Creators.TF-Community-Launcher/master/internal/mods.json" ]; diff --git a/patchnotes-page/patchnotes.html b/patchnotes-page/patchnotes.html index 0ff383b..d4d9e61 100644 --- a/patchnotes-page/patchnotes.html +++ b/patchnotes-page/patchnotes.html @@ -1,7 +1,7 @@ - + Creators.TF Launcher - Alpha Version - Patch Notes diff --git a/patchnotes-page/patchnotespage-preload.ts b/patchnotes-page/patchnotespage-preload.ts index 08ec915..230662a 100644 --- a/patchnotes-page/patchnotespage-preload.ts +++ b/patchnotes-page/patchnotespage-preload.ts @@ -10,7 +10,7 @@ marked.setOptions({ }); window.addEventListener("DOMContentLoaded", () => { - fetch("https://raw.githubusercontent.com/ampersoftware/Creators.TF-Community-Launcher/master/changelog.md").then(async (res) => { + fetch("https://raw.githubusercontent.com/CreatorsTF/Creators.TF-Community-Launcher/master/changelog.md").then(async (res) => { if (res.status === 200) { res.text().then((data) => { document.getElementById("patchnotes").innerHTML = marked(data); diff --git a/preload.ts b/preload.ts index 9f9f186..c16f066 100644 --- a/preload.ts +++ b/preload.ts @@ -62,7 +62,7 @@ ipcRenderer.on("ShowMods", (event, data) => { const launcherVersionBox = document.getElementById("launcher-version"); const config: any = fs.readFileSync(path.join(__dirname, "package.json")); const currentClientVersion: number = JSON.parse(config).version; - fetch("https://api.github.com/repos/ampersoftware/Creators.TF-Community-Launcher/releases/latest").then((res) => { + fetch("https://api.github.com/repos/CreatorsTF/Creators.TF-Community-Launcher/releases/latest").then((res) => { if (res.status === 200) { res.json().then((data) => { const version = data.tag_name; From 2a50b096bcadc527ccc61d4672384b6c79f0a1ae Mon Sep 17 00:00:00 2001 From: Jota Date: Sat, 21 Aug 2021 12:36:00 -0300 Subject: [PATCH 2/2] Applying requested changes on merge request Make basedir use path.join Removed 'You can also report if via our Discord.' from error messages. --- main.ts | 2 +- modules/config.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.ts b/main.ts index 40d069e..7759102 100644 --- a/main.ts +++ b/main.ts @@ -19,7 +19,7 @@ log.transports.file.fileName = "main.log"; log.transports.file.maxSize = 10485760; log.transports.file.getFile(); -const majorErrorMessageEnd = "\nIf this error persists, please report it on our GitHub page by making a new 'Issue'.\nVisit creators.tf/launcher for more info.\nYou can also report if via our Discord."; +const majorErrorMessageEnd = "\nIf this error persists, please report it on our GitHub page by creating a new 'Issue'.\nVisit creators.tf/launcher for more info."; class Main { public static mainWindow: BrowserWindow; diff --git a/modules/config.ts b/modules/config.ts index 2d11d04..e46b5df 100644 --- a/modules/config.ts +++ b/modules/config.ts @@ -116,7 +116,6 @@ class Config { /** * Gets first existing path in an array of strings * @param {string[]} steamPaths An array of directory paths - * @param {string} pathPrefix A path to add before each path in steamPaths before checking * @returns First existing path in steamPaths or null if none of the paths exist, with prefix added */ @@ -142,7 +141,8 @@ class Config { const homedir = process.env.HOME; const steamPaths = [".steam/steam", ".local/share/steam"]; for (const pathGroup of steamPaths) { - basedir = homedir + await getExistingPath(pathGroup["paths"]); + let existingPath = await getExistingPath(pathGroup["paths"]); + basedir = path.join(homedir, existingPath); if (basedir != "") { break; }