mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
File structure refactor, move old files to old directory.
Removed legacy config path support in ConfigManager. Moved model files to corresponding subdirectories, rather than being in an uber model directory.
This commit is contained in:
parent
9097bafb5d
commit
75a7e0f713
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "helioslauncher",
|
"name": "helioslauncher",
|
||||||
"version": "1.7.0",
|
"version": "2.0.0-alpha.0",
|
||||||
"productName": "Helios Launcher",
|
"productName": "Helios Launcher",
|
||||||
"description": "Modded Minecraft Launcher",
|
"description": "Modded Minecraft Launcher",
|
||||||
"author": "Daniel Scalzi (https://github.com/dscalzi/)",
|
"author": "Daniel Scalzi (https://github.com/dscalzi/)",
|
||||||
|
0
src/main/asset/assetguardnew.ts
Normal file
0
src/main/asset/assetguardnew.ts
Normal file
@ -1,10 +1,10 @@
|
|||||||
interface LauncherJava {
|
export interface LauncherJava {
|
||||||
sha1: string
|
sha1: string
|
||||||
url: string
|
url: string
|
||||||
version: string
|
version: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LauncherVersions {
|
export interface LauncherVersions {
|
||||||
launcher: {
|
launcher: {
|
||||||
commit: string
|
commit: string
|
||||||
name: string
|
name: string
|
@ -15,7 +15,7 @@ export interface Natives {
|
|||||||
windows?: string
|
windows?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BaseArtifact {
|
export interface BaseArtifact {
|
||||||
|
|
||||||
sha1: string
|
sha1: string
|
||||||
size: number
|
size: number
|
@ -1,18 +1,19 @@
|
|||||||
import { LoggerUtil } from './loggerutil'
|
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { pathExistsSync, writeFileSync, ensureDirSync, moveSync, readFileSync } from 'fs-extra'
|
import { pathExistsSync, writeFileSync, ensureDirSync, readFileSync } from 'fs-extra'
|
||||||
import { totalmem } from 'os'
|
import { totalmem } from 'os'
|
||||||
import { SavedAccount } from './model/internal/config/SavedAccount'
|
import { SavedAccount } from './model/SavedAccount'
|
||||||
import { LauncherConfig } from './model/internal/config/LauncherConfig'
|
import { LauncherConfig } from './model/LauncherConfig'
|
||||||
import { ModConfig } from './model/internal/config/ModConfig'
|
import { ModConfig } from './model/ModConfig'
|
||||||
import { NewsCache } from './model/internal/config/NewsCache'
|
import { NewsCache } from './model/NewsCache'
|
||||||
|
import { LoggerUtil } from '../logging/loggerutil'
|
||||||
|
|
||||||
|
// TODO final review upon usage in implementation.
|
||||||
|
|
||||||
export class ConfigManager {
|
export class ConfigManager {
|
||||||
|
|
||||||
private static readonly logger = new LoggerUtil('%c[ConfigManager]', 'color: #a02d2a; font-weight: bold')
|
private static readonly logger = LoggerUtil.getLogger('ConfigManager')
|
||||||
private static readonly sysRoot = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Application Support' : process.env.HOME)
|
private static readonly sysRoot = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Application Support' : process.env.HOME)
|
||||||
// TODO change
|
private static readonly dataPath = join(ConfigManager.sysRoot as string, '.helioslauncher')
|
||||||
private static readonly dataPath = join(ConfigManager.sysRoot as string, '.westeroscraft')
|
|
||||||
|
|
||||||
// Forked processes do not have access to electron, so we have this workaround.
|
// Forked processes do not have access to electron, so we have this workaround.
|
||||||
private static readonly launcherDir = process.env.CONFIG_DIRECT_PATH || require('electron').remote.app.getPath('userData')
|
private static readonly launcherDir = process.env.CONFIG_DIRECT_PATH || require('electron').remote.app.getPath('userData')
|
||||||
@ -46,8 +47,7 @@ export class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static readonly configPath = join(ConfigManager.getLauncherDirectory(), 'config.json')
|
private static readonly configPath = join(ConfigManager.getLauncherDirectory(), 'config.json')
|
||||||
private static readonly configPathLEGACY = join(ConfigManager.dataPath, 'config.json') // TODO remove, it's been 1 year.
|
private static readonly firstLaunch = !pathExistsSync(ConfigManager.configPath)
|
||||||
private static readonly firstLaunch = !pathExistsSync(ConfigManager.configPath) && !pathExistsSync(ConfigManager.configPathLEGACY)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Three types of values:
|
* Three types of values:
|
||||||
@ -135,14 +135,10 @@ export class ConfigManager {
|
|||||||
if(!pathExistsSync(ConfigManager.configPath)){
|
if(!pathExistsSync(ConfigManager.configPath)){
|
||||||
// Create all parent directories.
|
// Create all parent directories.
|
||||||
ensureDirSync(join(ConfigManager.configPath, '..'))
|
ensureDirSync(join(ConfigManager.configPath, '..'))
|
||||||
if(pathExistsSync(ConfigManager.configPathLEGACY)){
|
|
||||||
moveSync(ConfigManager.configPathLEGACY, ConfigManager.configPath)
|
|
||||||
} else {
|
|
||||||
doLoad = false
|
doLoad = false
|
||||||
ConfigManager.config = ConfigManager.DEFAULT_CONFIG
|
ConfigManager.config = ConfigManager.DEFAULT_CONFIG
|
||||||
ConfigManager.save()
|
ConfigManager.save()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(doLoad){
|
if(doLoad){
|
||||||
let doValidate = false
|
let doValidate = false
|
||||||
try {
|
try {
|
||||||
@ -150,8 +146,8 @@ export class ConfigManager {
|
|||||||
doValidate = true
|
doValidate = true
|
||||||
} catch (err){
|
} catch (err){
|
||||||
ConfigManager.logger.error(err)
|
ConfigManager.logger.error(err)
|
||||||
ConfigManager.logger.log('Configuration file contains malformed JSON or is corrupt.')
|
ConfigManager.logger.info('Configuration file contains malformed JSON or is corrupt.')
|
||||||
ConfigManager.logger.log('Generating a new configuration file.')
|
ConfigManager.logger.info('Generating a new configuration file.')
|
||||||
ensureDirSync(join(ConfigManager.configPath, '..'))
|
ensureDirSync(join(ConfigManager.configPath, '..'))
|
||||||
ConfigManager.config = ConfigManager.DEFAULT_CONFIG
|
ConfigManager.config = ConfigManager.DEFAULT_CONFIG
|
||||||
ConfigManager.save()
|
ConfigManager.save()
|
||||||
@ -161,7 +157,7 @@ export class ConfigManager {
|
|||||||
ConfigManager.save()
|
ConfigManager.save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ConfigManager.logger.log('Successfully Loaded')
|
ConfigManager.logger.info('Successfully Loaded')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -4,7 +4,7 @@ import { join } from "path"
|
|||||||
import { readdirSync } from "fs-extra"
|
import { readdirSync } from "fs-extra"
|
||||||
import { format } from "url"
|
import { format } from "url"
|
||||||
import { autoUpdater } from 'electron-updater'
|
import { autoUpdater } from 'electron-updater'
|
||||||
import isdev from "./isdev"
|
import isdev from "./util/isdev"
|
||||||
|
|
||||||
const installExtensions = async () => {
|
const installExtensions = async () => {
|
||||||
const installer = require('electron-devtools-installer');
|
const installer = require('electron-devtools-installer');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Agent } from "./Agent";
|
import { Agent } from './Agent'
|
||||||
|
|
||||||
export interface AuthPayload {
|
export interface AuthPayload {
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
import { LoggerUtil } from '../logging/loggerutil'
|
import { LoggerUtil } from '../logging/loggerutil'
|
||||||
import { Agent } from '../model/mojang/auth/Agent'
|
import { Agent } from './model/auth/Agent'
|
||||||
import { Status, StatusColor } from './type/Status'
|
import { Status, StatusColor } from './model/internal/Status'
|
||||||
import axios, { AxiosError } from 'axios'
|
import axios, { AxiosError } from 'axios'
|
||||||
import { Session } from '../model/mojang/auth/Session'
|
import { Session } from './model/auth/Session'
|
||||||
import { AuthPayload } from '../model/mojang/auth/AuthPayload'
|
import { AuthPayload } from './model/auth/AuthPayload'
|
||||||
import { MojangResponse, MojangResponseCode, deciperResponseCode, isInternalError } from './type/Response'
|
import { MojangResponse, MojangResponseCode, deciperResponseCode, isInternalError } from './model/internal/Response'
|
||||||
|
|
||||||
export class Mojang {
|
export class Mojang {
|
||||||
|
|
||||||
|
@ -4,16 +4,16 @@ import { join } from 'path'
|
|||||||
import { pathExistsSync, pathExists, readdir, exists, readFileSync, createWriteStream, ensureDirSync, readFile, writeFileSync, unlink, createReadStream, readJsonSync } from 'fs-extra'
|
import { pathExistsSync, pathExists, readdir, exists, readFileSync, createWriteStream, ensureDirSync, readFile, writeFileSync, unlink, createReadStream, readJsonSync } from 'fs-extra'
|
||||||
import Registry from 'winreg'
|
import Registry from 'winreg'
|
||||||
import { exec, spawn } from 'child_process'
|
import { exec, spawn } from 'child_process'
|
||||||
import { LauncherJson } from './model/mojang/index/LauncherJson'
|
import { LauncherJson } from '../asset/model/mojang/LauncherJson'
|
||||||
import { createHash } from 'crypto'
|
import { createHash } from 'crypto'
|
||||||
import AdmZip from 'adm-zip'
|
import AdmZip from 'adm-zip'
|
||||||
import { forEachOfLimit, eachLimit } from 'async'
|
import { forEachOfLimit, eachLimit } from 'async'
|
||||||
import { extract } from 'tar-fs'
|
import { extract } from 'tar-fs'
|
||||||
import { createGunzip } from 'zlib'
|
import { createGunzip } from 'zlib'
|
||||||
import { VersionJson, AssetIndex, Rule, Natives, Library } from './model/mojang/index/VersionJson'
|
import { VersionJson, AssetIndex, Rule, Natives, Library } from '../asset/model/mojang/VersionJson'
|
||||||
|
|
||||||
import { ConfigManager } from './configmanager'
|
import { ConfigManager } from '../config/configmanager'
|
||||||
import isDev from './isdev'
|
import isDev from '../util/isdev'
|
||||||
const DistroManager = require('./distromanager')
|
const DistroManager = require('./distromanager')
|
||||||
|
|
||||||
// Constants
|
// Constants
|
@ -1,7 +1,7 @@
|
|||||||
import { LoggerUtil } from './loggerutil'
|
import { LoggerUtil } from './loggerutil'
|
||||||
import { ConfigManager } from './configmanager'
|
import { ConfigManager } from '../config/configmanager'
|
||||||
import { Mojang } from './mojang/mojang'
|
import { Mojang } from '../mojang/mojang'
|
||||||
import { SavedAccount } from './model/internal/config/SavedAccount'
|
import { SavedAccount } from '../config/model/SavedAccount'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AuthManager
|
* AuthManager
|
@ -3,7 +3,7 @@ import { Distribution, Module, Type, TypeMetadata, Server } from 'helios-distrib
|
|||||||
import { readJson, writeJson } from 'fs-extra'
|
import { readJson, writeJson } from 'fs-extra'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { LoggerUtil } from './loggerutil'
|
import { LoggerUtil } from './loggerutil'
|
||||||
import { ConfigManager } from './configmanager'
|
import { ConfigManager } from '../config/configmanager'
|
||||||
|
|
||||||
const logger = new LoggerUtil('%c[DistroManager]', 'color: #a02d2a; font-weight: bold')
|
const logger = new LoggerUtil('%c[DistroManager]', 'color: #a02d2a; font-weight: bold')
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { ConfigManager } from './configmanager'
|
import { ConfigManager } from '../config/configmanager'
|
||||||
import { DistroManager, DistributionWrapper } from './distromanager'
|
import { DistroManager, DistributionWrapper } from './distromanager'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { remove } from 'fs-extra'
|
import { remove } from 'fs-extra'
|
@ -4,14 +4,14 @@ import { join, basename } from 'path'
|
|||||||
import { ModuleWrapper, ServerWrapper } from './distromanager'
|
import { ModuleWrapper, ServerWrapper } from './distromanager'
|
||||||
import { Type, Required } from 'helios-distribution-types'
|
import { Type, Required } from 'helios-distribution-types'
|
||||||
import { LoggerUtil } from './loggerutil'
|
import { LoggerUtil } from './loggerutil'
|
||||||
import { ConfigManager } from './configmanager'
|
import { ConfigManager } from '../config/configmanager'
|
||||||
import { spawn } from 'child_process'
|
import { spawn } from 'child_process'
|
||||||
import { SavedAccount } from './model/internal/config/SavedAccount'
|
import { SavedAccount } from '../config/model/SavedAccount'
|
||||||
import { tmpdir, release } from 'os'
|
import { tmpdir, release } from 'os'
|
||||||
import { SubModConfig } from './model/internal/config/ModConfig'
|
import { SubModConfig } from '../config/model/ModConfig'
|
||||||
import { pseudoRandomBytes } from 'crypto'
|
import { pseudoRandomBytes } from 'crypto'
|
||||||
import { Util, LibraryInternal } from './assetguard'
|
import { Util, LibraryInternal } from './assetguard'
|
||||||
import { VersionJson, Rule } from './model/mojang/index/VersionJson'
|
import { VersionJson, Rule } from '../asset/model/mojang/VersionJson'
|
||||||
import { URL } from 'url'
|
import { URL } from 'url'
|
||||||
|
|
||||||
const logger = new LoggerUtil('%c[ProcessBuilder]', 'color: #003996; font-weight: bold')
|
const logger = new LoggerUtil('%c[ProcessBuilder]', 'color: #003996; font-weight: bold')
|
@ -2,8 +2,8 @@ import { Mojang } from "../../src/main/mojang/mojang"
|
|||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import nock from 'nock'
|
import nock from 'nock'
|
||||||
import { URL } from 'url'
|
import { URL } from 'url'
|
||||||
import { Session } from "../../src/main/model/mojang/auth/Session"
|
import { Session } from "../../src/main/mojang/model/auth/Session"
|
||||||
import { MojangResponseCode } from "../../src/main/mojang/type/Response"
|
import { MojangResponseCode } from "../../src/main/mojang/model/internal/Response"
|
||||||
|
|
||||||
function expectMojangResponse(res: any, responseCode: MojangResponseCode, negate = false) {
|
function expectMojangResponse(res: any, responseCode: MojangResponseCode, negate = false) {
|
||||||
expect(res).to.not.be.an('error')
|
expect(res).to.not.be.an('error')
|
||||||
|
Loading…
Reference in New Issue
Block a user