Documentation ¶
Overview ¶
Package manifest defines the file format that describes a mod or modpack. The "minepkg.toml" manifest is the way minepkg defines packages. Packages can be mods or modpacks.
Learn More ¶
For more details visit https://minepkg.io/docs/manifest
Index ¶
- Constants
- Variables
- type Dependencies
- type DependencyLock
- type FabricLock
- type ForgeLock
- type InterpretedDependency
- type Lockfile
- func (l *Lockfile) AddDependency(dep *DependencyLock)
- func (l *Lockfile) Buffer() *bytes.Buffer
- func (l *Lockfile) ClearDependencies()
- func (l *Lockfile) HasRequirements() bool
- func (l *Lockfile) McManifestName() string
- func (l *Lockfile) MinecraftVersion() string
- func (l *Lockfile) PlatformLock() PlatformLock
- func (l *Lockfile) String() string
- type Manifest
- func (m *Manifest) AddDependency(name string, version string)
- func (m *Manifest) AddDevDependency(name string, version string)
- func (m *Manifest) AuthorEmail() string
- func (m *Manifest) AuthorName() string
- func (m *Manifest) Buffer() *bytes.Buffer
- func (m *Manifest) InterpretedDependencies() []*InterpretedDependency
- func (m *Manifest) InterpretedDevDependencies() []*InterpretedDependency
- func (m *Manifest) PlatformString() string
- func (m *Manifest) PlatformVersion() string
- func (m *Manifest) RemoveDependency(name string)
- func (m *Manifest) RemoveDevDependency(name string)
- func (m *Manifest) String() string
- func (m *Manifest) Validate() Problems
- type PlatformLock
- type Problems
- type ValidationError
- type VanillaLock
Examples ¶
Constants ¶
const ( // TypeMod indicates a package containing a single mod TypeMod = "mod" // TypeModpack indicates a package containing a list of mods (modpack) TypeModpack = "modpack" )
const ( ErrorLevelWarn = iota ErrorLevelFatal )
const LockfileVersion = 1
LockfileVersion is the current version of the lockfile template
Variables ¶
var ( // ErrDependencyConflicts is returned when trying to add a dependency that is already present ErrDependencyConflicts = errors.New("a dependency with that name is already present") // DependencyLockTypeMod describes a mod dependency DependencyLockTypeMod = "mod" // DependencyLockTypeModpack describes a modpack dependency DependencyLockTypeModpack = "modpack" PlatformFabric = "fabric" PlatformForge = "forge" PlatformVanilla = "vanilla" )
var ( // ErrUnsupportedManifestVersion is returned when the manifest version is not supported. ErrUnsupportedManifestVersion = ValidationError{ Path: "manifestVersion", Level: ErrorLevelWarn, // contains filtered or unexported fields } // ErrNameEmpty is returned when the manifest name is empty. ErrNameEmpty = ValidationError{ Path: "package.name", Level: ErrorLevelWarn, // contains filtered or unexported fields } // ErrNameInvalid is returned when the manifest name is invalid. ErrNameInvalid = ValidationError{ Path: "package.name", Level: ErrorLevelWarn, // contains filtered or unexported fields } // ErrInvalidType is returned when the manifest type is not supported. ErrInvalidType = ValidationError{ Path: "package.type", Level: ErrorLevelFatal, // contains filtered or unexported fields } // ErrNoMinecraftRequirement is returned when the manifest does not contain a Minecraft requirement. ErrNoMinecraftRequirement = ValidationError{ Path: "requirements.minecraft", Level: ErrorLevelFatal, // contains filtered or unexported fields } // ErrInvalidMinecraftRequirement is returned when the manifest contains an invalid Minecraft requirement. ErrInvalidMinecraftRequirement = ValidationError{ Path: "requirements.minecraft", Level: ErrorLevelFatal, // contains filtered or unexported fields } // ErrNoLoaderRequirement is returned when the manifest does not contain a loader requirement. ErrNoLoaderRequirement = ValidationError{ Path: "requirements", Level: ErrorLevelFatal, // contains filtered or unexported fields } // ErrInvalidFabricLoaderRequirement is returned when the manifest contains an invalid Fabric loader requirement. ErrInvalidFabricLoaderRequirement = ValidationError{ Path: "requirements.fabric", Level: ErrorLevelFatal, // contains filtered or unexported fields } )
Functions ¶
This section is empty.
Types ¶
type Dependencies ¶
Dependencies are the dependencies of a mod or modpack as a map
type DependencyLock ¶
type DependencyLock struct { Name string `toml:"name" json:"name"` Version string `toml:"version" json:"version"` Type string `toml:"type" json:"type"` IPFSHash string `toml:"ipfsHash" json:"ipfsHash"` Sha256 string `toml:"Sha256" json:"Sha256"` URL string `toml:"url" json:"url"` // Provider usually is minepkg but can also be https Provider string `toml:"provider" json:"provider"` // Dependend is the package that requires this mod. can be _root if top package Dependend string `toml:"dependend" json:"dependend"` // IsDev is true if this is a dev dependency IsDev bool `toml:"isDev,omitempty" json:"isDev,omitempty"` }
DependencyLock is a single resolved dependency
func (*DependencyLock) FileExt ¶
func (d *DependencyLock) FileExt() string
FileExt returns ".jar" for mods and ".zip" for modpacks
func (*DependencyLock) Filename ¶
func (d *DependencyLock) Filename() string
Filename returns the dependency in the "[name]-[version].jar" format
func (*DependencyLock) ID ¶
func (d *DependencyLock) ID() string
ID returns the a sha256 of "provider:name:version"
type FabricLock ¶
type FabricLock struct { Minecraft string `toml:"minecraft" json:"minecraft"` FabricLoader string `toml:"fabricLoader" json:"fabricLoader"` Mapping string `toml:"mapping" json:"mapping"` }
FabricLock describes resolved fabric requirements
func (*FabricLock) MinecraftVersion ¶
func (f *FabricLock) MinecraftVersion() string
MinecraftVersion returns the minecraft version
func (*FabricLock) PlatformName ¶
func (f *FabricLock) PlatformName() string
PlatformName returns the string fabric
func (*FabricLock) PlatformVersion ¶
func (f *FabricLock) PlatformVersion() string
PlatformVersion returns the fabric mod loader version
type ForgeLock ¶
type ForgeLock struct { Minecraft string `toml:"minecraft" json:"minecraft"` ForgeLoader string `toml:"forgeLoader" json:"forgeLoader"` }
ForgeLock describes resolved forge requirements this is not used for now, because forge does not provide a API to resolve this
func (*ForgeLock) MinecraftVersion ¶
MinecraftVersion returns the minecraft version
func (*ForgeLock) PlatformName ¶
PlatformName returns the string vanilla
func (*ForgeLock) PlatformVersion ¶
MinecraftVersion returns the forge loader version
type InterpretedDependency ¶
type InterpretedDependency struct { // Provider is the system that should be used to fetch this dependency. // This usually is `minepkg` and can also be `https`. There might be more providers in the future Provider string // Name is the name of the package Name string // Source is what `Provider` will need to fetch the given Dependency // In practice this is a version number for `Provider === "minepkg"` and // a https url for `Provider === "https"` Source string // IsDev is true if this is a dev dependency IsDev bool }
InterpretedDependency is a key-value dependency that has been interpreted. It can help to fetch the dependency more easily
type Lockfile ¶
type Lockfile struct { LockfileVersion int `toml:"lockfileVersion" json:"lockfileVersion"` Fabric *FabricLock `toml:"fabric,omitempty" json:"fabric,omitempty"` Forge *ForgeLock `toml:"forge,omitempty" json:"forge,omitempty"` Vanilla *VanillaLock `toml:"vanilla,omitempty" json:"vanilla,omitempty"` Dependencies map[string]*DependencyLock `toml:"dependencies,omitempty" json:"dependencies,omitempty"` }
Lockfile includes resolved dependencies and requirements
func NewLockfileFromFile ¶ added in v0.1.5
NewFromFile tries to parse a local lockfile file
func (*Lockfile) AddDependency ¶
func (l *Lockfile) AddDependency(dep *DependencyLock)
AddDependency adds a new dependency to the lockfile
func (*Lockfile) ClearDependencies ¶
func (l *Lockfile) ClearDependencies()
ClearDependencies removes all dependencies
func (*Lockfile) HasRequirements ¶
HasRequirements returns true if lockfile has some requirements
func (*Lockfile) McManifestName ¶
McManifestName returns the Minecraft Launcher Manifest name
func (*Lockfile) MinecraftVersion ¶
MinecraftVersion returns the Minecraft version
func (*Lockfile) PlatformLock ¶
func (l *Lockfile) PlatformLock() PlatformLock
PlatformLock returns the platform lock object (fabric, forge or vanilla lock)
type Manifest ¶
type Manifest struct { // ManifestVersion specifies the format version // This field is REQUIRED ManifestVersion int `toml:"manifestVersion" comment:"Preview of the minepkg.toml format! Could break anytime!" json:"manifestVersion"` Package struct { // Type should be one of `TypeMod` ("mod") or `TypeModpack` ("modpack") // this field is REQUIRED Type string `toml:"type" json:"type"` // Name is the name of the package. It may NOT include spaces. It may ONLY consist of // alphanumeric chars but can also include `-` and `_` // Should be unique. (This will be enforced by the minepkg api) // This field is REQUIRED Name string `toml:"name" json:"name"` // Description can be any free text that describes this package. Should be short(ish) Description string `toml:"description" json:"description"` // Version is the version number of this package. A proceeding `v` (like `v2.1.1`) is NOT // allowed to preserve consistency // The version may include prerelease information like `1.2.2-beta.0` or build // related information `1.2.1+B7382-2018`. // The version can be omitted. Publishing will require a version number as flag in that case Version string `toml:"version,omitempty" json:"version,omitempty"` // Platform indicates the supported playform of this package. can be `fabric`, `forge` or `vanilla` Platform string `toml:"platform,omitempty" json:"platform,omitempty"` // Licence for this project. Should be a valid SPDX identifier if possible // see https://spdx.org/licenses/ License string `toml:"license,omitempty" json:"license,omitempty"` // Source is an URL that should point to the source code repository of this package (if any) Source string `toml:"source,omitempty" json:"source,omitempty"` // Homepage is an URL that should point to the website of this package (if any) Homepage string `toml:"homepage,omitempty" json:"homepage,omitempty"` // Author in the form of "Full Name <email@example.com>". Email can be omitted and Full Name does not have to be a real name Author string `toml:"author,omitempty" json:"author,omitempty"` // BasedOn can be a another package that this one is based on. // Most notably, this field is used for instances to determine what modpack is actually running // This field is striped when publishing the package to the minepkg api BasedOn string `toml:"basedOn,omitempty" json:"basedOn,omitempty"` // Savegame can be the name of the primary savegame on this modpack. Not applicable for other package types. // This savegame will be used when launching this package via `minepkg try`. // This should be the folder name of the savegame Savegame string `toml:"savegame,omitempty" json:"savegame,omitempty"` } `toml:"package" json:"package"` Requirements struct { // Minecraft is a semver version string describing the required Minecraft version // The Minecraft version is binding and implementers should not install // Mods for non-matching Minecraft versions. // Modpack & Mod Authors are encouraged to use semver to allow a broader install range. // This field is REQUIRED Minecraft string `toml:"minecraft" json:"minecraft"` // FabricLoader is a semver version string describing the required FabricLoader version // Only one of `Forge` or `FabricLoader` may be used FabricLoader string `toml:"fabricLoader,omitempty" json:"fabricLoader,omitempty"` // ForgeLoader is the minimum forge version required // no semver here, because forge does not follow semver ForgeLoader string `toml:"forgeLoader,omitempty" json:"forgeLoader,omitempty"` // MinepkgCompanion is the version of the minepkg companion plugin that is going to be added to modpacks. // This has no effect on other types of packages // `latest` is assumed if this field is omitted. `none` can be used to exclude the companion // plugin from a modpack – but this is not recommended MinepkgCompanion string `toml:"minepkgCompanion,omitempty" json:"minepkgCompanion,omitempty"` // old names, are only here for migration Fabric string `toml:"fabric,omitempty" json:"fabric,omitempty"` Forge string `toml:"forge,omitempty" json:"forge,omitempty"` } `toml:"requirements" comment:"These are global requirements" json:"requirements"` // Dependencies lists runtime dependencies of this package // this list can contain mods and modpacks Dependencies `toml:"dependencies" json:"dependencies,omitempty"` // Dev contains development & testing related options Dev struct { // BuildCommand is the command used for building this package (usually "./gradlew build") BuildCommand string `toml:"buildCommand,omitempty" json:"buildCommand,omitempty"` // Jar defines the target location glob to the built jar file for mods. Can be empty. Example: "lib/builds/my-mod-v*.jar" Jar string `toml:"jar,omitempty" json:"jar,omitempty"` // Dependencies inside the dev struct should only be installed if this package is defined locally. // They should never be installed for published packages Dependencies `toml:"dependencies,omitempty" json:"dependencies,omitempty"` } `toml:"dev" json:"dev"` }
Manifest is a collection of data that describes a mod a modpack
Example (Marshal) ¶
Marshal a struct to toml
package main import ( "fmt" "github.com/minepkg/minepkg/pkg/manifest" ) func main() { manifest := manifest.New() manifest.Package.Name = "test-mansion" fmt.Println(manifest.String()) // or manifest.Buffer() to get it as a buffer }
Output:
Example (Unmarshal) ¶
Unmarshal a toml to a manifest struct
raw := []byte(` manifestVersion = 0 [package] name="test-utils" version="1.0.0" `) var man manifest.Manifest toml.Unmarshal(raw, &man) fmt.Println(man.Package.Name)
Output: test-utils
func NewFromFile ¶ added in v0.1.5
NewFromFile tries to parse a local manifest file
func NewInstanceLike ¶
NewInstanceLike takes an existing manifest and copies most fields
func (*Manifest) AddDependency ¶
AddDependency adds a new dependency to the manifest
func (*Manifest) AddDevDependency ¶ added in v0.0.61
AddDevDependency adds a new dev dependency to the manifest
func (*Manifest) AuthorEmail ¶ added in v0.0.62
AuthorEmail returns the email of the author or empty string if none is set
func (*Manifest) AuthorName ¶ added in v0.0.62
AuthorName returns the name of the author (excluding the email address if set)
func (*Manifest) InterpretedDependencies ¶
func (m *Manifest) InterpretedDependencies() []*InterpretedDependency
InterpretedDependencies returns the dependencies in a `[]*InterpretedDependency` slice. See `InterpretedDependency` for details
func (*Manifest) InterpretedDevDependencies ¶ added in v0.0.61
func (m *Manifest) InterpretedDevDependencies() []*InterpretedDependency
InterpretedDevDependencies returns the dev.dependencies in a `[]*InterpretedDependency` slice. See `InterpretedDependency` for details
func (*Manifest) PlatformString ¶
PlatformString returns the required platform as a string (vanilla, fabric or forge)
func (*Manifest) PlatformVersion ¶
PlatformVersion returns the required platform version
func (*Manifest) RemoveDependency ¶
RemoveDependency removes a dependency from the manifest
func (*Manifest) RemoveDevDependency ¶ added in v0.0.61
RemoveDevDependency removes a dev dependency from the manifest
type PlatformLock ¶
type PlatformLock interface { PlatformName() string MinecraftVersion() string PlatformVersion() string }
PlatformLock describes a queryable platform (fabric, forge)
type Problems ¶ added in v0.1.3
type Problems []ValidationError
type ValidationError ¶ added in v0.1.3
func (ValidationError) Error ¶ added in v0.1.3
func (e ValidationError) Error() string
type VanillaLock ¶
type VanillaLock struct {
Minecraft string `toml:"minecraft" json:"minecraft"`
}
VanillaLock describes resolved vanilla requirements
func (*VanillaLock) MinecraftVersion ¶
func (v *VanillaLock) MinecraftVersion() string
MinecraftVersion returns the minecraft version
func (*VanillaLock) PlatformName ¶
func (v *VanillaLock) PlatformName() string
PlatformName returns the string vanilla
func (*VanillaLock) PlatformVersion ¶
func (f *VanillaLock) PlatformVersion() string
PlatformVersion returns ""