custom

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package custom implements user-defined mod sources configured declaratively via YAML files in <configDir>/sources/. See the design doc: docs/plans/2026-07-13-custom-sources-design.md

Index

Constants

View Source
const (
	TypeDirectory = "directory"
	TypeManifest  = "manifest"
	TypeAPI       = "api"
)

Source type identifiers for SourceDefinition.Type.

Variables

This section is empty.

Functions

func New

New constructs a ModSource from a validated definition. It returns an error for definition types whose implementation has not shipped yet, so startup can warn-and-skip instead of failing.

Types

type APIConfig

type APIConfig struct {
	BaseURL string `yaml:"base_url"`
}

APIConfig configures a declarative REST source (expanded in Phase 4).

type Directory

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

Directory is a ModSource backed by a local directory: each subdirectory (or .zip/.jar archive) is one mod. The directory is rescanned on each operation so edits show up without restarting lmm; scans are local and cheap.

func NewDirectory

func NewDirectory(def SourceDefinition) (*Directory, error)

NewDirectory constructs a directory source from a validated definition. The configured path must exist and be a directory.

func (*Directory) AuthURL

func (d *Directory) AuthURL() string

AuthURL implements source.ModSource; directory sources need no auth.

func (*Directory) Capabilities

func (d *Directory) Capabilities() source.Capabilities

Capabilities implements source.CapabilityReporter.

func (*Directory) CheckUpdates

func (d *Directory) CheckUpdates(ctx context.Context, installed []domain.InstalledMod) ([]domain.Update, error)

CheckUpdates implements source.ModSource by comparing installed versions to the current scan.

func (*Directory) ExchangeToken

func (d *Directory) ExchangeToken(ctx context.Context, code string) (*source.Token, error)

ExchangeToken implements source.ModSource.

func (*Directory) GetDependencies

func (d *Directory) GetDependencies(ctx context.Context, mod *domain.Mod) ([]domain.ModReference, error)

GetDependencies implements source.ModSource; directory mods declare none.

func (*Directory) GetDownloadURL

func (d *Directory) GetDownloadURL(ctx context.Context, mod *domain.Mod, fileID string) (string, error)

GetDownloadURL implements source.ModSource, returning a file:// URL that Service.DownloadModToCache ingests by local copy instead of HTTP download.

func (*Directory) GetMod

func (d *Directory) GetMod(ctx context.Context, gameID, modID string) (*domain.Mod, error)

GetMod implements source.ModSource. gameID is accepted from any game and not used to look up the mod (see Search); it is echoed onto the returned mod so downstream installs are attributed to the correct game.

func (*Directory) GetModFiles

func (d *Directory) GetModFiles(ctx context.Context, mod *domain.Mod) ([]domain.DownloadableFile, error)

GetModFiles implements source.ModSource: every mod has exactly one synthetic file ("main") representing its directory or archive.

func (*Directory) ID

func (d *Directory) ID() string

ID implements source.ModSource.

func (*Directory) Name

func (d *Directory) Name() string

Name implements source.ModSource.

func (*Directory) Search

Search implements source.ModSource with client-side matching: case-insensitive substring on name and summary; name matches rank first, then alphabetical. GameID is accepted from any game (a directory source applies to any game that maps it — it does not filter by GameID) but is echoed onto every returned mod so downstream installs are attributed to the correct game.

type DirectoryConfig

type DirectoryConfig struct {
	Path string `yaml:"path"`
}

DirectoryConfig configures a local-directory source.

type ManifestConfig

type ManifestConfig struct {
	URL     string `yaml:"url"`
	Refresh string `yaml:"refresh"` // Go duration string, e.g. "15m"; empty = default
}

ManifestConfig configures a manifest source (Phase 3).

type SourceDefinition

type SourceDefinition struct {
	ID        string           `yaml:"id"`
	Name      string           `yaml:"name"`
	Type      string           `yaml:"type"`
	AllowHTTP bool             `yaml:"allow_http"`
	Directory *DirectoryConfig `yaml:"directory"`
	Manifest  *ManifestConfig  `yaml:"manifest"`
	API       *APIConfig       `yaml:"api"`
}

SourceDefinition is one user-defined source, parsed from a YAML file in <configDir>/sources/. Exactly one of Directory/Manifest/API must be set, matching Type.

func (*SourceDefinition) Validate

func (d *SourceDefinition) Validate() error

Validate checks the definition for structural errors. It does not touch the filesystem or network; existence checks happen when the source is constructed.

Directories

Path Synopsis
Package metadata extracts mod metadata from well-known files inside a mod directory (e.g.
Package metadata extracts mod metadata from well-known files inside a mod directory (e.g.

Jump to

Keyboard shortcuts

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