Support for 1.13+ Forge Resolution.

Tested versions: 1.13.2
TODO: Test 1.14.4, 1.15.1
TODO: Read mod metadata from mods.toml in 1.13+
This commit is contained in:
Daniel Scalzi
2020-01-19 10:58:02 -05:00
parent e827dea7ff
commit 4d342b7b0a
10 changed files with 318 additions and 27 deletions

View File

@@ -0,0 +1,25 @@
export interface VersionManifest113 {
id: string
time: string
releaseTime: string
type: string
mainClass: string
inheritsFrom: string
logging: any
arguments: {
game: string[]
}
libraries: Array<{
name: string,
downloads: {
artifact: {
path: string,
url: string,
sha1: string,
size: number
}
}
}>
}

View File

@@ -1,4 +1,4 @@
export interface VersionManifest {
export interface VersionManifest17 {
id: string
time: string

View File

@@ -2,6 +2,9 @@ import { BaseMavenRepo } from './BaseMavenRepo'
export class LibRepoStructure extends BaseMavenRepo {
public static readonly MINECRAFT_GROUP = 'net.minecraft'
public static readonly MINECRAFT_CLIENT_ARTIFACT = 'client'
constructor(
absoluteRoot: string,
relativeRoot: string

View File

@@ -3,12 +3,14 @@ import { BaseFileStructure } from '../BaseFileStructure'
import { ForgeRepoStructure } from './forgerepo.struct'
import { LibRepoStructure } from './librepo.struct'
import { LiteLoaderRepoStructure } from './liteloaderrepo.struct'
import { VersionRepoStructure } from './versionrepo.struct'
export class RepoStructure extends BaseFileStructure {
private forgeRepoStruct: ForgeRepoStructure
private liteloaderRepoStruct: LiteLoaderRepoStructure
private libRepoStruct: LibRepoStructure
private versionRepoStruct: VersionRepoStructure
constructor(
absoluteRoot: string,
@@ -18,6 +20,7 @@ export class RepoStructure extends BaseFileStructure {
this.forgeRepoStruct = new ForgeRepoStructure(this.containerDirectory, this.relativeRoot)
this.liteloaderRepoStruct = new LiteLoaderRepoStructure(this.containerDirectory, this.relativeRoot)
this.libRepoStruct = new LibRepoStructure(this.containerDirectory, this.relativeRoot)
this.versionRepoStruct = new VersionRepoStructure(this.containerDirectory, this.relativeRoot)
}
public async init() {
@@ -25,6 +28,7 @@ export class RepoStructure extends BaseFileStructure {
await this.forgeRepoStruct.init()
await this.liteloaderRepoStruct.init()
await this.libRepoStruct.init()
await this.versionRepoStruct.init()
}
public getForgeRepoStruct() {
@@ -39,6 +43,10 @@ export class RepoStructure extends BaseFileStructure {
return this.libRepoStruct
}
public getVersionRepoStruct() {
return this.versionRepoStruct
}
public getTempDirectory() {
return join(this.absoluteRoot, 'temp')
}

View File

@@ -0,0 +1,28 @@
import { join } from 'path'
import { resolve as resolveURL } from 'url'
import { BaseFileStructure } from '../BaseFileStructure'
export class VersionRepoStructure extends BaseFileStructure {
constructor(
absoluteRoot: string,
relativeRoot: string
) {
super(absoluteRoot, relativeRoot, 'versions')
}
public getFileName(minecraftVersion: string, forgeVersion: string) {
return `${minecraftVersion}-forge-${forgeVersion}`
}
public getVersionManifest(minecraftVersion: string, forgeVersion: string) {
const fileName = this.getFileName(minecraftVersion, forgeVersion)
return join(this.containerDirectory, fileName, `${fileName}.json`)
}
public getVersionManifestURL(url: string, minecraftVersion: string, forgeVersion: string) {
const fileName = this.getFileName(minecraftVersion, forgeVersion)
return resolveURL(url, join(this.relativeRoot, fileName, `${fileName}.json`))
}
}