xf

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package xf provides utilities for XenForo installation detection and management.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrMetadataNotFound is returned when the metadata file cannot be found.
	ErrMetadataNotFound = errors.New("metadata not found")
)

Functions

func GetXenForoDir

func GetXenForoDir(startDir string) (string, error)

GetXenForoDir finds the XenForo root directory by traversing up from startDir. It also checks the XF_DIR environment variable as a fallback.

func UpdateMetadataVersion

func UpdateMetadataVersion(xfDir string, version *Version) error

UpdateMetadataVersion updates the version information in the metadata.

func WriteMetadata

func WriteMetadata(xfDir string, meta *Metadata) error

WriteMetadata updates the timestamps and writes metadata with mode 0600 when creating the file. Existing file permissions are not changed.

Types

type Metadata

type Metadata struct {
	LicenseKey string `json:"license_key"`

	InstanceName string `json:"instance_name"`

	InstalledProducts []string `json:"installed_products"`

	InstalledVersion string `json:"installed_version"`

	InstalledVersionID int `json:"installed_version_id"`

	CreatedAt time.Time `json:"created_at"`

	UpdatedAt time.Time `json:"updated_at"`
}

Metadata stores CLI-specific information about a XenForo installation. It records the license key, Docker instance name, installed products and version, and creation and update times for use by init and upgrade.

func ReadMetadata

func ReadMetadata(xfDir string) (*Metadata, error)

ReadMetadata reads the metadata file. Returns ErrMetadataNotFound if the file doesn't exist.

type Version

type Version struct {
	String string
	ID     int
	// contains filtered or unexported fields
}

Version represents a XenForo version with both string and ID representations. Its ID encodes major, two-digit minor and patch, stability, and release level.

func DetectVersion

func DetectVersion(xfDir string) (*Version, error)

DetectVersion reads the core add-on version, checking it against src/XF.php. If the core add-on manifest is absent, it uses src/XF.php alone.

func DetectVersionFS added in v0.5.0

func DetectVersionFS(installation fs.FS) (*Version, error)

DetectVersionFS is DetectVersion for a filesystem rooted at the installation. It prefers the numeric ID for parsing but retains the source version string; if no positive ID is found, it parses the version string instead.

func ParseVersionID

func ParseVersionID(versionID int) *Version

ParseVersionID converts a version ID into a Version structure.

Jump to

Keyboard shortcuts

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