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",
|
||||
"version": "1.7.0",
|
||||
"version": "2.0.0-alpha.0",
|
||||
"productName": "Helios Launcher",
|
||||
"description": "Modded Minecraft Launcher",
|
||||
"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
|
||||
url: string
|
||||
version: string
|
||||
}
|
||||
|
||||
interface LauncherVersions {
|
||||
export interface LauncherVersions {
|
||||
launcher: {
|
||||
commit: string
|
||||
name: string
|
@ -15,7 +15,7 @@ export interface Natives {
|
||||
windows?: string
|
||||
}
|
||||
|
||||
interface BaseArtifact {
|
||||
export interface BaseArtifact {
|
||||
|
||||
sha1: string
|
||||
size: number
|
@ -1,18 +1,19 @@
|
||||
import { LoggerUtil } from './loggerutil'
|
||||
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 { SavedAccount } from './model/internal/config/SavedAccount'
|
||||
import { LauncherConfig } from './model/internal/config/LauncherConfig'
|
||||
import { ModConfig } from './model/internal/config/ModConfig'
|
||||
import { NewsCache } from './model/internal/config/NewsCache'
|
||||
import { SavedAccount } from './model/SavedAccount'
|
||||
import { LauncherConfig } from './model/LauncherConfig'
|
||||
import { ModConfig } from './model/ModConfig'
|
||||
import { NewsCache } from './model/NewsCache'
|
||||
import { LoggerUtil } from '../logging/loggerutil'
|
||||
|
||||
// TODO final review upon usage in implementation.
|
||||
|
||||
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)
|
||||
// TODO change
|
||||
private static readonly dataPath = join(ConfigManager.sysRoot as string, '.westeroscraft')
|
||||
private static readonly dataPath = join(ConfigManager.sysRoot as string, '.helioslauncher')
|
||||
|
||||
// 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')
|
||||
@ -46,8 +47,7 @@ export class ConfigManager {
|
||||
}
|
||||
|
||||
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) && !pathExistsSync(ConfigManager.configPathLEGACY)
|
||||
private static readonly firstLaunch = !pathExistsSync(ConfigManager.configPath)
|
||||
|
||||
/**
|
||||
* Three types of values:
|
||||
@ -135,13 +135,9 @@ export class ConfigManager {
|
||||
if(!pathExistsSync(ConfigManager.configPath)){
|
||||
// Create all parent directories.
|
||||
ensureDirSync(join(ConfigManager.configPath, '..'))
|
||||
if(pathExistsSync(ConfigManager.configPathLEGACY)){
|
||||
moveSync(ConfigManager.configPathLEGACY, ConfigManager.configPath)
|
||||
} else {
|
||||
doLoad = false
|
||||
ConfigManager.config = ConfigManager.DEFAULT_CONFIG
|
||||
ConfigManager.save()
|
||||
}
|
||||
doLoad = false
|
||||
ConfigManager.config = ConfigManager.DEFAULT_CONFIG
|
||||
ConfigManager.save()
|
||||
}
|
||||
if(doLoad){
|
||||
let doValidate = false
|
||||
@ -150,8 +146,8 @@ export class ConfigManager {
|
||||
doValidate = true
|
||||
} catch (err){
|
||||
ConfigManager.logger.error(err)
|
||||
ConfigManager.logger.log('Configuration file contains malformed JSON or is corrupt.')
|
||||
ConfigManager.logger.log('Generating a new configuration file.')
|
||||
ConfigManager.logger.info('Configuration file contains malformed JSON or is corrupt.')
|
||||
ConfigManager.logger.info('Generating a new configuration file.')
|
||||
ensureDirSync(join(ConfigManager.configPath, '..'))
|
||||
ConfigManager.config = ConfigManager.DEFAULT_CONFIG
|
||||
ConfigManager.save()
|
||||
@ -161,7 +157,7 @@ export class ConfigManager {
|
||||
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 { format } from "url"
|
||||
import { autoUpdater } from 'electron-updater'
|
||||
import isdev from "./isdev"
|
||||
import isdev from "./util/isdev"
|
||||
|
||||
const installExtensions = async () => {
|
||||
const installer = require('electron-devtools-installer');
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Agent } from "./Agent";
|
||||
import { Agent } from './Agent'
|
||||
|
||||
export interface AuthPayload {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { LoggerUtil } from '../logging/loggerutil'
|
||||
import { Agent } from '../model/mojang/auth/Agent'
|
||||
import { Status, StatusColor } from './type/Status'
|
||||
import { Agent } from './model/auth/Agent'
|
||||
import { Status, StatusColor } from './model/internal/Status'
|
||||
import axios, { AxiosError } from 'axios'
|
||||
import { Session } from '../model/mojang/auth/Session'
|
||||
import { AuthPayload } from '../model/mojang/auth/AuthPayload'
|
||||
import { MojangResponse, MojangResponseCode, deciperResponseCode, isInternalError } from './type/Response'
|
||||
import { Session } from './model/auth/Session'
|
||||
import { AuthPayload } from './model/auth/AuthPayload'
|
||||
import { MojangResponse, MojangResponseCode, deciperResponseCode, isInternalError } from './model/internal/Response'
|
||||
|
||||
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 Registry from 'winreg'
|
||||
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 AdmZip from 'adm-zip'
|
||||
import { forEachOfLimit, eachLimit } from 'async'
|
||||
import { extract } from 'tar-fs'
|
||||
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 isDev from './isdev'
|
||||
import { ConfigManager } from '../config/configmanager'
|
||||
import isDev from '../util/isdev'
|
||||
const DistroManager = require('./distromanager')
|
||||
|
||||
// Constants
|
@ -1,7 +1,7 @@
|
||||
import { LoggerUtil } from './loggerutil'
|
||||
import { ConfigManager } from './configmanager'
|
||||
import { Mojang } from './mojang/mojang'
|
||||
import { SavedAccount } from './model/internal/config/SavedAccount'
|
||||
import { ConfigManager } from '../config/configmanager'
|
||||
import { Mojang } from '../mojang/mojang'
|
||||
import { SavedAccount } from '../config/model/SavedAccount'
|
||||
|
||||
/**
|
||||
* AuthManager
|
@ -3,7 +3,7 @@ import { Distribution, Module, Type, TypeMetadata, Server } from 'helios-distrib
|
||||
import { readJson, writeJson } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
import { LoggerUtil } from './loggerutil'
|
||||
import { ConfigManager } from './configmanager'
|
||||
import { ConfigManager } from '../config/configmanager'
|
||||
|
||||
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 { join } from 'path'
|
||||
import { remove } from 'fs-extra'
|
@ -4,14 +4,14 @@ import { join, basename } from 'path'
|
||||
import { ModuleWrapper, ServerWrapper } from './distromanager'
|
||||
import { Type, Required } from 'helios-distribution-types'
|
||||
import { LoggerUtil } from './loggerutil'
|
||||
import { ConfigManager } from './configmanager'
|
||||
import { ConfigManager } from '../config/configmanager'
|
||||
import { spawn } from 'child_process'
|
||||
import { SavedAccount } from './model/internal/config/SavedAccount'
|
||||
import { SavedAccount } from '../config/model/SavedAccount'
|
||||
import { tmpdir, release } from 'os'
|
||||
import { SubModConfig } from './model/internal/config/ModConfig'
|
||||
import { SubModConfig } from '../config/model/ModConfig'
|
||||
import { pseudoRandomBytes } from 'crypto'
|
||||
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'
|
||||
|
||||
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 nock from 'nock'
|
||||
import { URL } from 'url'
|
||||
import { Session } from "../../src/main/model/mojang/auth/Session"
|
||||
import { MojangResponseCode } from "../../src/main/mojang/type/Response"
|
||||
import { Session } from "../../src/main/mojang/model/auth/Session"
|
||||
import { MojangResponseCode } from "../../src/main/mojang/model/internal/Response"
|
||||
|
||||
function expectMojangResponse(res: any, responseCode: MojangResponseCode, negate = false) {
|
||||
expect(res).to.not.be.an('error')
|
||||
|
Loading…
Reference in New Issue
Block a user