feat: support Fabric (#66)
* Initial scaffolding for Fabric. * refactor: extract common ModStructure * feat: add FabricModStructure * refactor: add name field to VersionRepoStructure * feat: FabricResolver * feat: support Fabric * docs: update README * Small changes. * Add additional note. * Upgrade helios-distribution-types. --------- Co-authored-by: Daniel Scalzi <d_scalzi@yahoo.com>
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
import { Stats } from 'fs'
|
||||
import { Type, Module } from 'helios-distribution-types'
|
||||
import { join } from 'path'
|
||||
import { URL } from 'url'
|
||||
import { Type } from 'helios-distribution-types'
|
||||
import { VersionSegmented } from '../../../util/VersionSegmented.js'
|
||||
import { MinecraftVersion } from '../../../util/MinecraftVersion.js'
|
||||
import { ToggleableModuleStructure } from './ToggleableModule.struct.js'
|
||||
import { BaseModStructure } from './Mod.struct.js'
|
||||
import { LibraryType } from '../../../model/claritas/ClaritasLibraryType.js'
|
||||
import { ClaritasException } from './Module.struct.js'
|
||||
import { UntrackedFilesOption } from '../../../model/nebula/ServerMeta.js'
|
||||
|
||||
export abstract class BaseForgeModStructure extends ToggleableModuleStructure implements VersionSegmented {
|
||||
export abstract class BaseForgeModStructure<T> extends BaseModStructure<T> implements VersionSegmented {
|
||||
|
||||
protected readonly EXAMPLE_MOD_ID = 'examplemod'
|
||||
|
||||
@@ -23,26 +20,8 @@ export abstract class BaseForgeModStructure extends ToggleableModuleStructure im
|
||||
super(absoluteRoot, relativeRoot, 'forgemods', baseUrl, minecraftVersion, Type.ForgeMod, untrackedFiles)
|
||||
}
|
||||
|
||||
public async getSpecModel(): Promise<Module[]> {
|
||||
// Sort by file name to allow control of load order.
|
||||
return (await super.getSpecModel()).sort((a, b) => {
|
||||
const aFileName = a.artifact.url.substring(a.artifact.url.lastIndexOf('/')+1)
|
||||
const bFileName = b.artifact.url.substring(b.artifact.url.lastIndexOf('/')+1)
|
||||
return aFileName.localeCompare(bFileName)
|
||||
})
|
||||
}
|
||||
|
||||
public abstract isForVersion(version: MinecraftVersion, libraryVersion: string): boolean
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
protected async getModuleUrl(name: string, path: string, stats: Stats): Promise<string> {
|
||||
return new URL(join(this.relativeRoot, this.getActiveNamespace(), name), this.baseUrl).toString()
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
protected async getModulePath(name: string, path: string, stats: Stats): Promise<string | null> {
|
||||
return null
|
||||
}
|
||||
|
||||
protected getClaritasExceptions(): ClaritasException[] {
|
||||
return [{
|
||||
exceptionName: 'optifine',
|
||||
|
||||
Reference in New Issue
Block a user