Documentation
¶
Index ¶
- Constants
- type DependencyInstallReport
- type DependencyRef
- type DirectURLModRequest
- type ImportOptions
- type Manager
- func (m *Manager) AddMod(packID string, mod ModItem) error
- func (m *Manager) AddModFromURL(packID string, req DirectURLModRequest) (*ModItem, error)
- func (m *Manager) AddModWithDependencies(packID string, mod ModItem, loader, mcVersion string, ...) (*DependencyInstallReport, error)
- func (m *Manager) ApplyMigration(packID, targetMC, targetLoader string) (*MigrationReport, error)
- func (m *Manager) ApplyModUpdate(packID, slug, targetVersionID, targetFileName, targetURL string) error
- func (m *Manager) BakeToServer(packID, modsDir string) (int, error)
- func (m *Manager) CheckModUpdates(packID string) ([]ModUpdateInfo, error)
- func (m *Manager) ClonePack(packID, newName string) (*Pack, error)
- func (m *Manager) CreatePack(p *Pack) (*Pack, error)
- func (m *Manager) DeleteMod(packID, slug string) error
- func (m *Manager) DeletePack(id string) error
- func (m *Manager) DeletePackFile(packID, relPath string) error
- func (m *Manager) DryRunMCVersion(packID, newMCVersion string) (*StaleReport, error)
- func (m *Manager) ExportCurseForge(packID string, w io.Writer) error
- func (m *Manager) ExportMrpack(packID string, w io.Writer) error
- func (m *Manager) ExportPackwizZip(packID string, w io.Writer) error
- func (m *Manager) GetPack(id string) (*Pack, error)
- func (m *Manager) ImportCurseForge(r io.ReaderAt, size int64, opts ImportOptions) (*Pack, error)
- func (m *Manager) ImportMrpack(r io.ReaderAt, size int64, opts ImportOptions) (*Pack, error)
- func (m *Manager) ImportPackwizZip(r io.ReaderAt, size int64, opts ImportOptions) (*Pack, error)
- func (m *Manager) ListPackFiles(packID string) ([]PackFileInfo, error)
- func (m *Manager) ListPacks() ([]PackSummary, error)
- func (m *Manager) NewHTTPDependencyFetcher() VersionDependencyFetcher
- func (m *Manager) RefreshPack(packID string) error
- func (m *Manager) ResolveTransitiveDependencies(fetcher VersionDependencyFetcher, ...) ([]DependencyRef, error)
- func (m *Manager) SavePackFile(packID, relPath string, r io.Reader) error
- func (m *Manager) ServePackFile(packID, relativePath string) ([]byte, string, error)
- func (m *Manager) SetMCVersion(packID, newMCVersion string) (*StaleReport, error)
- func (m *Manager) SimulateMigration(packID, targetMC, targetLoader string) (*MigrationReport, error)
- func (m *Manager) UpdateMod(packID, slug, side string, pinned bool) error
- func (m *Manager) UpdatePack(p *Pack) error
- type MigrationModItem
- type MigrationReport
- type ModItem
- type ModUpdateInfo
- type Pack
- type PackFileInfo
- type PackSummary
- type StaleModInfo
- type StaleReport
- type VersionDependencyFetcher
Constants ¶
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 (*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 ¶
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) DeletePack ¶
func (*Manager) DeletePackFile ¶
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 ¶
ExportCurseForge generates a CurseForge .zip modpack
func (*Manager) ExportMrpack ¶
ExportMrpack generates a Modrinth .mrpack archive
func (*Manager) ExportPackwizZip ¶
ExportPackwizZip exports the full native Packwiz archive (.zip with pack.toml, index.toml, mods/, and overrides)
func (*Manager) ImportCurseForge ¶
ImportCurseForge imports a CurseForge .zip modpack into a new Packwiz project
func (*Manager) ImportMrpack ¶
ImportMrpack imports a Modrinth .mrpack archive into a new Packwiz project
func (*Manager) ImportPackwizZip ¶
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 ¶
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 ¶
SavePackFile writes an override file and updates the pack index
func (*Manager) ServePackFile ¶
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) UpdatePack ¶
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.