manifest

package
v0.0.60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 7 Imported by: 0

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.

Structure

Example manifest.toml:

manifestVersion = 0
[package]
  type = "modpack"
  name = "examplepack"
  version = "0.1.0"
  authors = ["John Doe <example@example.com>"]

[requirements]
  minecraft = "1.14.x"
  # Only fabric OR forge can be set. never both
  fabric = "0.1.0"
  # forge = "0.1.0"

[dependencies]
  # semver version range
  rftools = "~1.4.2"

  # exactly this version
  ender-io = "=1.0.2"

  # any version (you usually define the version instead)
  # * is equal to "latest" for minepkg. So it will try to fetch the latest
  # version that works
  some-modpack = "*"

[dev]
  buildCommand = "gradle build"

Dependencies

The dependencies map (map[string]string) contains all dependencies of a package.

The "key" always is the package name. For example `test-utils`

The "value" usually is a semver version number, like this: `^1.4.2` This will allow any update except major versions.

The following semver formats are allowed:

test-utils = "^1.0.0" # caret operator (default)
test-utils = "~1.0.0" # tilde operator
test-utils = "2.0.1-beta.2" # prerelease
test-utils = "1.0.0 - 3.0.0" # range
test-utils = "1.x.x" # range

https://github.com/npm/node-semver#ranges provides a good explanation of the operators mentioned above

Other sources may be specified by using the `source:` syntax in the "value" like this: `raw:https://example.com/package.zip`. The "key" will still be the package name when using the source syntax.

For more details visit https://minepkg.io/docs/manifest

Index

Examples

Constants

View Source
const (
	// TypeMod indicates a package containing a single mod
	TypeMod = "mod"
	// TypeModpack indicates a package containing a list of mods (modpack)
	TypeModpack = "modpack"
)
View Source
const LockfileVersion = 1

LockfileVersion is the current version of the lockfile template

Variables

View Source
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"
)

Functions

This section is empty.

Types

type Dependencies

type Dependencies map[string]string

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"`
}

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 "sha256.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

func (f *ForgeLock) MinecraftVersion() string

MinecraftVersion returns the minecraft version

func (*ForgeLock) PlatformName

func (f *ForgeLock) PlatformName() string

PlatformName returns the string vanilla

func (*ForgeLock) PlatformVersion

func (f *ForgeLock) PlatformVersion() string

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
}

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 NewLockfile

func NewLockfile() *Lockfile

NewLockfile returns a new lockfile

func (*Lockfile) AddDependency

func (l *Lockfile) AddDependency(dep *DependencyLock)

AddDependency adds a new dependency to the lockfile

func (*Lockfile) Buffer

func (l *Lockfile) Buffer() *bytes.Buffer

Buffer returns the manifest as toml in Buffer form

func (*Lockfile) ClearDependencies

func (l *Lockfile) ClearDependencies()

ClearDependencies removes all dependencies

func (*Lockfile) HasRequirements

func (l *Lockfile) HasRequirements() bool

HasRequirements returns true if lockfile has some requirements

func (*Lockfile) McManifestName

func (l *Lockfile) McManifestName() string

McManifestName returns the Minecraft Launcher Manifest name

func (*Lockfile) MinecraftVersion

func (l *Lockfile) MinecraftVersion() string

MinecraftVersion returns the Minecraft version

func (*Lockfile) PlatformLock

func (l *Lockfile) PlatformLock() PlatformLock

PlatformLock returns the platform lock object (fabric, forge or vanilla lock)

func (*Lockfile) String

func (l *Lockfile) String() string

type Manifest

type Manifest struct {
	// ManifestVersion specifies the format version
	// This field is REQUIRED
	ManifestVersion int `toml:"manifestVersion" json:"manifestVersion"`
	Package         struct {
		// Type should be one of `TypeMod` ("mod") or `TypeModpack` ("modpack")
		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 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"`
		License  string   `toml:"license,omitempty" json:"license,omitempty"`
		Provides []string `toml:"provides,omitempty" json:"provides,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:"build,omitempty" json:"build,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"`
		// Fabric is a semver version string describing the required Fabric version
		// Only one of `Forge` or `Fabric` may be used
		Fabric string `toml:"fabric,omitempty" json:"fabric,omitempty"`
		// Forge is the minimum forge version required
		// no semver here, because forge does not follow semver
		Forge string `toml:"forge,omitempty" json:"forge,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"`
	} `toml:"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"`
	} `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

package main

import (
	"fmt"

	"github.com/BurntSushi/toml"
	"github.com/minepkg/minepkg/pkg/manifest"
)

func main() {
	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 New

func New() *Manifest

New returns a new manifest

func NewInstanceLike

func NewInstanceLike(from *Manifest) *Manifest

NewInstanceLike takes an existing manifest and copies most fields

func (*Manifest) AddDependency

func (m *Manifest) AddDependency(name string, version string)

AddDependency adds a new dependency to the manifest

func (*Manifest) Buffer

func (m *Manifest) Buffer() *bytes.Buffer

Buffer returns the manifest as toml in Buffer form

func (*Manifest) InterpretedDependencies

func (m *Manifest) InterpretedDependencies() []*InterpretedDependency

InterpretedDependencies returns the dependencies in a `[]*InterpretedDependency` slice. See `InterpretedDependency` for details

func (*Manifest) PlatformString

func (m *Manifest) PlatformString() string

PlatformString returns the required platform as a string (vanilla, fabric or forge)

func (*Manifest) PlatformVersion

func (m *Manifest) PlatformVersion() string

PlatformVersion returns the required platform version

func (*Manifest) RemoveDependency

func (m *Manifest) RemoveDependency(name string)

RemoveDependency removes a dependency from the manifest

func (*Manifest) String

func (m *Manifest) String() string

type PlatformLock

type PlatformLock interface {
	PlatformName() string
	MinecraftVersion() string
	PlatformVersion() string
}

PlatformLock describes a queryable platform (fabric, forge)

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 ""

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL