Move code to common.

Renderer will be only react/redux code.
Common code can be used in both main and renderer.
This commit is contained in:
Daniel Scalzi 2020-05-24 15:44:16 -04:00
parent 5944f70a2a
commit 9a67087766
No known key found for this signature in database
GPG Key ID: D18EA3FB4B142A57
32 changed files with 27 additions and 26 deletions

View File

@ -1,14 +1,14 @@
import { IndexProcessor } from '../model/engine/IndexProcessor'
import got, { HTTPError, RequestError, ParseError, TimeoutError } from 'got'
import { LoggerUtil } from '../../logging/loggerutil'
import { LoggerUtil } from 'common/logging/loggerutil'
import { pathExists, readFile, ensureDir, writeFile, readJson } from 'fs-extra'
import { MojangVersionManifest } from '../model/mojang/VersionManifest'
import { calculateHash, getVersionJsonPath, validateLocalFile, getLibraryDir, getVersionJarPath } from '../../util/FileUtils'
import { calculateHash, getVersionJsonPath, validateLocalFile, getLibraryDir, getVersionJarPath } from 'common/util/FileUtils'
import { dirname, join } from 'path'
import { VersionJson, AssetIndex, LibraryArtifact } from '../model/mojang/VersionJson'
import { AssetGuardError } from '../model/engine/AssetGuardError'
import { Asset } from '../model/engine/Asset'
import { isLibraryCompatible, getMojangOS } from '../../util/MojangUtils'
import { isLibraryCompatible, getMojangOS } from 'common/util/MojangUtils'
export class MojangIndexProcessor extends IndexProcessor {

View File

@ -1,4 +1,4 @@
import { Rule, Natives } from "../asset/model/mojang/VersionJson"
import { Rule, Natives } from "../../main/asset/model/mojang/VersionJson"
export function getMojangOS(): string {
const opSys = process.platform

View File

@ -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 "./util/isdev"
import isdev from "../common/util/isdev"
const installExtensions = async () => {
const installer = require('electron-devtools-installer');

View File

@ -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 '../asset/model/mojang/LauncherJson'
import { LauncherJson } from 'common/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 '../asset/model/mojang/VersionJson'
import { VersionJson, AssetIndex, Rule, Natives, Library } from 'common/asset/model/mojang/VersionJson'
import { ConfigManager } from '../config/configmanager'
import isDev from '../util/isdev'
import { ConfigManager } from 'common/config/configmanager'
import isDev from 'common/util/isdev'
const DistroManager = require('./distromanager')
// Constants

View File

@ -1,7 +1,7 @@
import { LoggerUtil } from './loggerutil'
import { ConfigManager } from '../config/configmanager'
import { Mojang } from '../mojang/mojang'
import { SavedAccount } from '../config/model/SavedAccount'
import { ConfigManager } from '../../common/config/configmanager'
import { Mojang } from '../../common/mojang/mojang'
import { SavedAccount } from '../../common/config/model/SavedAccount'
/**
* AuthManager

View File

@ -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 '../config/configmanager'
import { ConfigManager } from '../../common/config/configmanager'
const logger = new LoggerUtil('%c[DistroManager]', 'color: #a02d2a; font-weight: bold')

View File

@ -1,4 +1,4 @@
import { ConfigManager } from '../config/configmanager'
import { ConfigManager } from '../../common/config/configmanager'
import { DistroManager, DistributionWrapper } from './distromanager'
import { join } from 'path'
import { remove } from 'fs-extra'

View File

@ -4,11 +4,11 @@ import { join, basename } from 'path'
import { ModuleWrapper, ServerWrapper } from './distromanager'
import { Type, Required } from 'helios-distribution-types'
import { LoggerUtil } from './loggerutil'
import { ConfigManager } from '../config/configmanager'
import { ConfigManager } from '../../common/config/configmanager'
import { spawn } from 'child_process'
import { SavedAccount } from '../config/model/SavedAccount'
import { SavedAccount } from '../../common/config/model/SavedAccount'
import { tmpdir, release } from 'os'
import { SubModConfig } from '../config/model/ModConfig'
import { SubModConfig } from '../../common/config/model/ModConfig'
import { pseudoRandomBytes } from 'crypto'
import { Util, LibraryInternal } from './assetguard'
import { VersionJson, Rule } from '../asset/model/mojang/VersionJson'

View File

@ -1,10 +1,10 @@
import nock from 'nock'
import { URL } from 'url'
import { MojangIndexProcessor } from '../../src/main/asset/processor/MojangIndexProcessor'
import { MojangIndexProcessor } from 'common/asset/processor/MojangIndexProcessor'
import { dirname, join } from 'path'
import { expect } from 'chai'
import { remove, pathExists } from 'fs-extra'
import { getVersionJsonPath } from '../../src/main/util/FileUtils'
import { getVersionJsonPath } from 'common/util/FileUtils'
// @ts-ignore (JSON Modules enabled in tsconfig.test.json)
import versionManifest from './files/version_manifest.json'

View File

@ -1,8 +1,8 @@
import { Mojang } from "../../src/main/mojang/mojang"
import { Mojang } from "common/mojang/mojang"
import { expect } from 'chai'
import nock from 'nock'
import { Session } from "../../src/main/mojang/model/auth/Session"
import { MojangResponseCode } from "../../src/main/mojang/model/internal/Response"
import { Session } from "common/mojang/model/auth/Session"
import { MojangResponseCode } from "common/mojang/model/internal/Response"
function expectMojangResponse(res: any, responseCode: MojangResponseCode, negate = false) {
expect(res).to.not.be.an('error')

View File

@ -16,10 +16,11 @@
// *"sourceMap": true, /* Generates corresponding '.map' file. */
// *"outDir": "dist", /* Redirect output structure to the directory. */
// *"strict": true,
// "baseUrl": ".", /* Base directory to resolve non-absolute module names. */
// "paths": { /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "*": ["node_modules/*"]
// },
"baseUrl": ".", /* Base directory to resolve non-absolute module names. */
"paths": {
"@/*": ["src/main/*"],
"common/*": ["src/common/*"]
},
// *"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
},
// *"include": [