Parse version manifest and download forge libraries.
TODO: Integrate base url propagation. Integrate PackXZExtract to calculate hashes of jar.pack.xz files. OR ammend the distribution spec to accept different hash algos (requires helioslauncher update).
This commit is contained in:
20
src/model/forge/versionmanifest.ts
Normal file
20
src/model/forge/versionmanifest.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export interface VersionManifest {
|
||||
|
||||
id: string
|
||||
time: string
|
||||
releaseTime: string
|
||||
type: string
|
||||
minecraftArguments: string
|
||||
mainClass: string
|
||||
inheritsFrom: string
|
||||
jar: string
|
||||
logging: any
|
||||
libraries: Array<{
|
||||
name: string,
|
||||
url?: string,
|
||||
checksums?: string[],
|
||||
serverreq?: boolean,
|
||||
clientreq?: boolean
|
||||
}>
|
||||
|
||||
}
|
||||
@@ -43,8 +43,8 @@ export abstract class ModuleStructure extends BaseModelStructure<Module> {
|
||||
for (const file of files) {
|
||||
const filePath = resolve(this.containerDirectory, file)
|
||||
const stats = await lstat(filePath)
|
||||
const buf = await readFile(filePath)
|
||||
if (stats.isFile()) {
|
||||
const buf = await readFile(filePath)
|
||||
const mdl: Module = {
|
||||
id: await this.getModuleId(file, filePath, stats, buf),
|
||||
name: await this.getModuleName(file, filePath, stats, buf),
|
||||
|
||||
@@ -15,8 +15,8 @@ export abstract class BaseMavenRepo extends BaseFileStructure {
|
||||
super(absoluteRoot, relativeRoot, structRoot)
|
||||
}
|
||||
|
||||
public getArtifactById(mavenIdentifier: string): string | null {
|
||||
const resolved = MavenUtil.mavenIdentifierToString(mavenIdentifier)
|
||||
public getArtifactById(mavenIdentifier: string, extension?: string): string | null {
|
||||
const resolved = MavenUtil.mavenIdentifierToString(mavenIdentifier, extension)
|
||||
return resolved == null ? null : resolve(this.containerDirectory, resolved)
|
||||
}
|
||||
|
||||
@@ -30,9 +30,17 @@ export abstract class BaseMavenRepo extends BaseFileStructure {
|
||||
return pathExists(path)
|
||||
}
|
||||
|
||||
public async downloadArtifact(url: string, group: string, artifact: string, version: string,
|
||||
classifier?: string, extension?: string) {
|
||||
const relative = MavenUtil.mavenComponentsToString(group, artifact, version, classifier, extension)
|
||||
public async downloadArtifactById(url: string, mavenIdentifier: string, extension?: string) {
|
||||
return this.downloadArtifactBase(url, MavenUtil.mavenIdentifierToString(mavenIdentifier, extension) as string)
|
||||
}
|
||||
|
||||
public async downloadArtifactByComponents(url: string, group: string, artifact: string, version: string,
|
||||
classifier?: string, extension?: string) {
|
||||
return this.downloadArtifactBase(url,
|
||||
MavenUtil.mavenComponentsToString(group, artifact, version, classifier, extension))
|
||||
}
|
||||
|
||||
private async downloadArtifactBase(url: string, relative: string) {
|
||||
const resolvedURL = resolveURL(url, relative).toString()
|
||||
console.debug(`Downloading ${resolvedURL}..`)
|
||||
const response = await axios({
|
||||
|
||||
Reference in New Issue
Block a user