packwiz

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDependencyDepth = 5

MaxDependencyDepth bounds transitive resolution to avoid runaway API fan-out.

Variables

This section is empty.

Functions

This section is empty.

Types

type DependencyInstallReport

type DependencyInstallReport struct {
	Root       ModItem         `json:"root"`
	Added      []ModItem       `json:"added"`      // transitive deps newly installed
	Skipped    []string        `json:"skipped"`    // slugs already present in the pack
	Unresolved []DependencyRef `json:"unresolved"` // required deps with no compatible version
}

DependencyInstallReport summarises a dependency-aware mod install.

type DependencyRef

type DependencyRef struct {
	Platform       string `json:"platform"`   // "modrinth" | "curseforge"
	ProjectID      string `json:"project_id"` // Modrinth project id/slug or CurseForge numeric mod id
	VersionID      string `json:"version_id,omitempty"`
	Title          string `json:"title,omitempty"`
	DependencyType string `json:"dependency_type"` // "required" | "optional"
}

DependencyRef describes a single mod dependency discovered during resolution.

type DirectURLModRequest

type DirectURLModRequest struct {
	Name        string `json:"name"`
	FileName    string `json:"file_name"`
	DownloadURL string `json:"download_url"`
	Side        string `json:"side"` // "both", "client", "server"
	Pinned      bool   `json:"pinned"`
}

DirectURLModRequest defines parameters for adding a mod from external URL

type ImportOptions

type ImportOptions struct {
	Name          string `json:"name"`
	Author        string `json:"author"`
	Version       string `json:"version"`
	MCVersion     string `json:"mc_version"`
	ModLoader     string `json:"mod_loader"`
	LoaderVersion string `json:"loader_version"`
}

ImportOptions defines settings for modpack import

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(baseDir string, log *logger.Logger) *Manager

func (*Manager) AddDatapackFile added in v1.0.39

func (m *Manager) AddDatapackFile(packID, fileName string, r io.Reader) error

AddDatapackFile installs a datapack archive into the pack's datapacks override directory. The archive is validated as a real Minecraft datapack before it lands, repairing the common wrapper-folder packaging mistake when needed.

func (*Manager) AddMod

func (m *Manager) AddMod(packID string, mod ModItem) error

func (*Manager) AddModFromURL

func (m *Manager) AddModFromURL(packID string, req DirectURLModRequest) (*ModItem, error)

AddModFromURL downloads/inspects a direct URL mod and generates a valid .pw.toml

func (*Manager) AddModWithDependencies

func (m *Manager) AddModWithDependencies(packID string, mod ModItem, loader, mcVersion string, fetcher VersionDependencyFetcher) (*DependencyInstallReport, error)

AddModWithDependencies installs mod plus all of its transitive required dependencies (for loader/mcVersion), skipping anything already in the pack. Unresolvable required deps are reported, never fatal.

func (*Manager) ApplyMigration

func (m *Manager) ApplyMigration(packID, targetMC, targetLoader string) (*MigrationReport, error)

ApplyMigration applies target MC and loader version to the pack and upgrades compatible mods

func (*Manager) ApplyModUpdate

func (m *Manager) ApplyModUpdate(packID, slug, targetVersionID, targetFileName, targetURL string) error

ApplyModUpdate updates an individual mod with new version details

func (*Manager) BakeToServer

func (m *Manager) BakeToServer(packID, modsDir string) (int, error)

BakeToServer extracts server-side mods directly into /data/mods

func (*Manager) CheckModUpdates

func (m *Manager) CheckModUpdates(packID string) ([]ModUpdateInfo, error)

CheckModUpdates queries platform APIs for updates to mods in the pack

func (*Manager) ClonePack

func (m *Manager) ClonePack(packID, newName string) (*Pack, error)

ClonePack creates an independent duplicate of an existing pack

func (*Manager) CreatePack

func (m *Manager) CreatePack(p *Pack) (*Pack, error)

func (*Manager) DeleteMod

func (m *Manager) DeleteMod(packID, slug string) error

func (*Manager) DeletePack

func (m *Manager) DeletePack(id string) error

func (*Manager) DeletePackFile

func (m *Manager) DeletePackFile(packID, relPath string) error

DeletePackFile removes an override file and updates the pack index

func (*Manager) DryRunMCVersion

func (m *Manager) DryRunMCVersion(packID, newMCVersion string) (*StaleReport, error)

DryRunMCVersion reports which mods would go stale if the pack moved to newMCVersion, without writing anything.

func (*Manager) ExportCurseForge

func (m *Manager) ExportCurseForge(packID string, w io.Writer) error

ExportCurseForge generates a CurseForge .zip modpack

func (*Manager) ExportMrpack

func (m *Manager) ExportMrpack(packID string, w io.Writer) error

ExportMrpack generates a Modrinth .mrpack archive

func (*Manager) ExportPackwizZip

func (m *Manager) ExportPackwizZip(packID string, w io.Writer) error

ExportPackwizZip exports the full native Packwiz archive (.zip with pack.toml, index.toml, mods/, and overrides)

func (*Manager) GetPack

func (m *Manager) GetPack(id string) (*Pack, error)

func (*Manager) ImportCurseForge

func (m *Manager) ImportCurseForge(r io.ReaderAt, size int64, opts ImportOptions) (*Pack, error)

ImportCurseForge imports a CurseForge .zip modpack into a new Packwiz project

func (*Manager) ImportMrpack

func (m *Manager) ImportMrpack(r io.ReaderAt, size int64, opts ImportOptions) (*Pack, error)

ImportMrpack imports a Modrinth .mrpack archive into a new Packwiz project

func (*Manager) ImportPackwizZip

func (m *Manager) ImportPackwizZip(r io.ReaderAt, size int64, opts ImportOptions) (*Pack, error)

ImportPackwizZip imports a native Packwiz archive (.zip containing pack.toml, index.toml, mods/)

func (*Manager) ListPackFiles

func (m *Manager) ListPackFiles(packID string) ([]PackFileInfo, error)

ListPackFiles lists non-mod override files in the modpack

func (*Manager) ListPacks

func (m *Manager) ListPacks() ([]PackSummary, error)

func (*Manager) NewHTTPDependencyFetcher

func (m *Manager) NewHTTPDependencyFetcher() VersionDependencyFetcher

NewHTTPDependencyFetcher returns the production fetcher for a Manager.

func (*Manager) RefreshPack

func (m *Manager) RefreshPack(packID string) error

RefreshPack re-indexes all mod and override files, recomputing hashes according to packwiz refresh

func (*Manager) ResolveTransitiveDependencies

func (m *Manager) ResolveTransitiveDependencies(fetcher VersionDependencyFetcher, platform, projectID, loader, mcVersion string, maxDepth int) ([]DependencyRef, error)

ResolveTransitiveDependencies walks required dependencies breadth-first, cycle-safe and depth-bounded. It returns every distinct required dependency (excluding the root project itself).

func (*Manager) SavePackFile

func (m *Manager) SavePackFile(packID, relPath string, r io.Reader) error

SavePackFile writes an override file and updates the pack index

func (*Manager) ServePackFile

func (m *Manager) ServePackFile(packID, relativePath string) ([]byte, string, error)

func (*Manager) SetMCVersion

func (m *Manager) SetMCVersion(packID, newMCVersion string) (*StaleReport, error)

SetMCVersion switches the pack to newMCVersion without touching installed mod versions, and reports every mod that is now stale. Only version-tracked mods (curseforge, or modrinth with a project ID) carry an MC-scoped upstream version: direct-URL ("url") mods — including ones that round-tripped through pack files without update metadata — are never marked stale. Callers should follow up with SimulateMigration/ApplyMigration to offer the update-and-resolve-conflicts flow.

func (*Manager) SimulateMigration

func (m *Manager) SimulateMigration(packID, targetMC, targetLoader string) (*MigrationReport, error)

SimulateMigration tests if mods in a pack support a new target Minecraft & loader version

func (*Manager) UpdateMod

func (m *Manager) UpdateMod(packID, slug, side string, pinned bool) error

func (*Manager) UpdatePack

func (m *Manager) UpdatePack(p *Pack) error

type MigrationModItem

type MigrationModItem struct {
	Slug              string `json:"slug"`
	Name              string `json:"name"`
	Platform          string `json:"platform"`
	CurrentVersionID  string `json:"current_version_id"`
	TargetVersionID   string `json:"target_version_id,omitempty"`
	TargetFileName    string `json:"target_file_name,omitempty"`
	TargetDownloadURL string `json:"target_download_url,omitempty"`
	Compatible        bool   `json:"compatible"`
}

MigrationModItem represents compatibility of an individual mod during migration

type MigrationReport

type MigrationReport struct {
	PackID            string             `json:"pack_id"`
	CurrentMC         string             `json:"current_mc"`
	CurrentLoader     string             `json:"current_loader"`
	TargetMC          string             `json:"target_mc"`
	TargetLoader      string             `json:"target_loader"`
	TotalMods         int                `json:"total_mods"`
	CompatibleCount   int                `json:"compatible_count"`
	IncompatibleCount int                `json:"incompatible_count"`
	Mods              []MigrationModItem `json:"mods"`
}

MigrationReport holds the outcome of a version migration check/apply

type ModItem

type ModItem struct {
	Slug        string `json:"slug"`
	Name        string `json:"name"`
	FileName    string `json:"file_name"`
	Side        string `json:"side"` // "both", "client", "server"
	Platform    string `json:"platform"`
	ProjectID   string `json:"project_id"`
	VersionID   string `json:"version_id"`
	DownloadURL string `json:"download_url"`
	FileSize    int64  `json:"file_size"`
	Pinned      bool   `json:"pinned"`
}

type ModUpdateInfo

type ModUpdateInfo struct {
	Slug              string `json:"slug"`
	Name              string `json:"name"`
	Platform          string `json:"platform"`
	CurrentVersionID  string `json:"current_version_id"`
	LatestVersionID   string `json:"latest_version_id"`
	LatestFileName    string `json:"latest_file_name"`
	LatestDownloadURL string `json:"latest_download_url"`
	Changelog         string `json:"changelog,omitempty"`
	UpdateAvailable   bool   `json:"update_available"`
	Pinned            bool   `json:"pinned"`
}

ModUpdateInfo represents available updates for a mod

type Pack

type Pack struct {
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	Author        string    `json:"author"`
	Version       string    `json:"version"`
	MCVersion     string    `json:"mc_version"`
	ModLoader     string    `json:"mod_loader"`
	LoaderVersion string    `json:"loader_version"`
	UpdatedAt     time.Time `json:"updated_at"`
	Mods          []ModItem `json:"mods"`
}

type PackFileInfo

type PackFileInfo struct {
	Path     string    `json:"path"`
	Size     int64     `json:"size"`
	ModTime  time.Time `json:"mod_time"`
	Category string    `json:"category"`
}

PackFileInfo represents extra non-mod override files in packwiz

type PackSummary

type PackSummary struct {
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	Author        string    `json:"author"`
	Version       string    `json:"version"`
	MCVersion     string    `json:"mc_version"`
	ModLoader     string    `json:"mod_loader"`
	LoaderVersion string    `json:"loader_version"`
	ModCount      int       `json:"mod_count"`
	UpdatedAt     time.Time `json:"updated_at"`
}

type StaleModInfo

type StaleModInfo struct {
	Slug             string `json:"slug"`
	Name             string `json:"name"`
	Platform         string `json:"platform"`
	CurrentVersionID string `json:"current_version_id"`
	Reason           string `json:"reason"` // "mc_version_changed"
}

StaleModInfo marks a single mod as stale after the pack's Minecraft version changed: its installed version was resolved for the previous MC version and must be re-checked (update) before the pack is consistent again.

type StaleReport

type StaleReport struct {
	PackID     string         `json:"pack_id"`
	PreviousMC string         `json:"previous_mc"`
	NewMC      string         `json:"new_mc"`
	StaleMods  []StaleModInfo `json:"stale_mods"`
	StaleCount int            `json:"stale_count"`
}

StaleReport is returned when a pack's Minecraft version changes.

type VersionDependencyFetcher

type VersionDependencyFetcher interface {
	// LatestCompatibleMod returns install metadata for the newest version of
	// projectID compatible with loader/mcVersion, plus its required deps.
	LatestCompatibleMod(platform, projectID, loader, mcVersion string) (ModItem, []DependencyRef, error)
}

VersionDependencyFetcher resolves the latest compatible version metadata for a project plus that version's own required dependencies. The default implementation queries the Modrinth / CurseForge APIs over HTTP; tests inject a stub.

Jump to

Keyboard shortcuts

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