Added winston for logging.
This commit is contained in:
@@ -6,9 +6,12 @@ import { VersionUtil } from '../../../../../util/versionutil'
|
||||
import { ModsToml } from '../../../../forge/modstoml'
|
||||
import { BaseForgeModStructure } from '../forgemod.struct'
|
||||
import { MinecraftVersion } from '../../../../../util/MinecraftVersion'
|
||||
import { LoggerUtil } from '../../../../../util/LoggerUtil'
|
||||
|
||||
export class ForgeModStructure113 extends BaseForgeModStructure {
|
||||
|
||||
private static readonly logger = LoggerUtil.getLogger('ForgeModStructure (1.13)')
|
||||
|
||||
public static readonly IMPLEMENTATION_VERSION_REGEX = /^Implementation-Version: (.+)[\r\n]/
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@@ -83,25 +86,25 @@ export class ForgeModStructure113 extends BaseForgeModStructure {
|
||||
let version = '0.0.0'
|
||||
const manifest = zip.readAsText('META-INF/MANIFEST.MF')
|
||||
const keys = manifest.split('\n')
|
||||
console.log(keys)
|
||||
ForgeModStructure113.logger.debug(keys)
|
||||
for (const key of keys) {
|
||||
const match = ForgeModStructure113.IMPLEMENTATION_VERSION_REGEX.exec(key)
|
||||
if (match != null) {
|
||||
version = match[1]
|
||||
}
|
||||
}
|
||||
console.debug(`ForgeMod ${name} contains a version wildcard, inferring ${version}`)
|
||||
ForgeModStructure113.logger.debug(`ForgeMod ${name} contains a version wildcard, inferring ${version}`)
|
||||
parsed.mods[0].version = version
|
||||
}
|
||||
|
||||
this.forgeModMetadata[name] = parsed
|
||||
|
||||
} catch (err) {
|
||||
console.error(`ForgeMod ${name} contains an invalid mods.toml file.`)
|
||||
ForgeModStructure113.logger.error(`ForgeMod ${name} contains an invalid mods.toml file.`)
|
||||
createDefault = true
|
||||
}
|
||||
} else {
|
||||
console.error(`ForgeMod ${name} does not contain mods.toml file.`)
|
||||
ForgeModStructure113.logger.error(`ForgeMod ${name} does not contain mods.toml file.`)
|
||||
createDefault = true
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,12 @@ import { McModInfo } from '../../../../forge/mcmodinfo'
|
||||
import { McModInfoList } from '../../../../forge/mcmodinfolist'
|
||||
import { BaseForgeModStructure } from '../forgemod.struct'
|
||||
import { MinecraftVersion } from '../../../../../util/MinecraftVersion'
|
||||
import { LoggerUtil } from '../../../../../util/LoggerUtil'
|
||||
|
||||
export class ForgeModStructure17 extends BaseForgeModStructure {
|
||||
|
||||
private static readonly logger = LoggerUtil.getLogger('ForgeModStructure (1.7)')
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public static isForVersion(version: MinecraftVersion, libraryVersion: string): boolean {
|
||||
return VersionUtil.isVersionAcceptable(version, [7, 8, 9, 10, 11, 12])
|
||||
@@ -92,11 +95,11 @@ export class ForgeModStructure17 extends BaseForgeModStructure {
|
||||
this.forgeModMetadata[name]!.version = '0.0.0'
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`ForgeMod ${name} contains an invalid mcmod.info file.`)
|
||||
ForgeModStructure17.logger.error(`ForgeMod ${name} contains an invalid mcmod.info file.`)
|
||||
createDefault = true
|
||||
}
|
||||
} else {
|
||||
console.error(`ForgeMod ${name} does not contain mcmod.info file.`)
|
||||
ForgeModStructure17.logger.error(`ForgeMod ${name} does not contain mcmod.info file.`)
|
||||
createDefault = true
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,12 @@ import { MiscFileStructure } from './module/file.struct'
|
||||
import { LiteModStructure } from './module/litemod.struct'
|
||||
import { LibraryStructure } from './module/library.struct'
|
||||
import { MinecraftVersion } from '../../../util/MinecraftVersion'
|
||||
import { LoggerUtil } from '../../../util/LoggerUtil'
|
||||
|
||||
export class ServerStructure extends BaseModelStructure<Server> {
|
||||
|
||||
private static readonly logger = LoggerUtil.getLogger('ServerStructure')
|
||||
|
||||
private readonly ID_REGEX = /(.+-(.+)$)/
|
||||
|
||||
constructor(
|
||||
@@ -41,7 +44,7 @@ export class ServerStructure extends BaseModelStructure<Server> {
|
||||
const relativeServerRoot = join(this.relativeRoot, effectiveId)
|
||||
|
||||
if (await pathExists(absoluteServerRoot)) {
|
||||
console.error('Server already exists! Aborting.')
|
||||
ServerStructure.logger.error('Server already exists! Aborting.')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -86,8 +89,8 @@ export class ServerStructure extends BaseModelStructure<Server> {
|
||||
|
||||
const match = this.ID_REGEX.exec(file)
|
||||
if (match == null) {
|
||||
console.warn(`Server directory ${file} does not match the defined standard.`)
|
||||
console.warn('All server ids must end with -<minecraft version> (ex. -1.12.2)')
|
||||
ServerStructure.logger.warn(`Server directory ${file} does not match the defined standard.`)
|
||||
ServerStructure.logger.warn('All server ids must end with -<minecraft version> (ex. -1.12.2)')
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -103,7 +106,7 @@ export class ServerStructure extends BaseModelStructure<Server> {
|
||||
}
|
||||
|
||||
if (!iconUrl) {
|
||||
console.warn(`No icon file found for server ${file}.`)
|
||||
ServerStructure.logger.warn(`No icon file found for server ${file}.`)
|
||||
iconUrl = '<FILL IN MANUALLY>'
|
||||
}
|
||||
|
||||
@@ -167,7 +170,7 @@ export class ServerStructure extends BaseModelStructure<Server> {
|
||||
})
|
||||
|
||||
} else {
|
||||
console.warn(`Path ${file} in server directory is not a directory!`)
|
||||
ServerStructure.logger.warn(`Path ${file} in server directory is not a directory!`)
|
||||
}
|
||||
}
|
||||
return accumulator
|
||||
|
||||
@@ -4,9 +4,12 @@ import { dirname, join, resolve } from 'path'
|
||||
import { resolve as resolveURL } from 'url'
|
||||
import { MavenUtil } from '../../../util/maven'
|
||||
import { BaseFileStructure } from '../BaseFileStructure'
|
||||
import { LoggerUtil } from '../../../util/LoggerUtil'
|
||||
|
||||
export abstract class BaseMavenRepo extends BaseFileStructure {
|
||||
|
||||
private static readonly logger = LoggerUtil.getLogger('BaseMavenRepo')
|
||||
|
||||
constructor(
|
||||
absoluteRoot: string,
|
||||
relativeRoot: string,
|
||||
@@ -54,7 +57,7 @@ export abstract class BaseMavenRepo extends BaseFileStructure {
|
||||
}
|
||||
|
||||
public async downloadArtifactDirect(url: string, path: string): Promise<void> {
|
||||
console.debug(`Downloading ${url}..`)
|
||||
BaseMavenRepo.logger.debug(`Downloading ${url}..`)
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url,
|
||||
@@ -67,7 +70,7 @@ export abstract class BaseMavenRepo extends BaseFileStructure {
|
||||
// tslint:disable-next-line: no-shadowed-variable
|
||||
return new Promise((resolve, reject) => {
|
||||
writer.on('finish', () => {
|
||||
console.debug(`Completed download of ${url}.`)
|
||||
BaseMavenRepo.logger.debug(`Completed download of ${url}.`)
|
||||
resolve()
|
||||
})
|
||||
writer.on('error', reject)
|
||||
|
||||
Reference in New Issue
Block a user