xf

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package xf provides utilities for XenForo installation detection and management.

Index

Constants

View Source
const MaxInstanceNameLength = 32

MaxInstanceNameLength bounds every generated Docker instance name.

Instance names become Compose project names, container and volume name prefixes and hostnames, so they are kept short enough to stay valid in each.

Variables

View Source
var (
	// ErrInvalidInput indicates invalid input was provided.
	ErrInvalidInput = errors.New("invalid input")

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

Functions

func GenerateInstanceName

func GenerateInstanceName(dirName string) string

GenerateInstanceName generates a Docker-safe instance name from a directory name.

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 MetadataPath

func MetadataPath(xfDir string) string

MetadataPath returns the path to the metadata file.

func ReadEnvFile

func ReadEnvFile(path string) (map[string]string, error)

ReadEnvFile reads environment variables from an .env file.

func StripQuotes

func StripQuotes(s string) string

StripQuotes removes surrounding single or double quotes from a string.

func UpdateMetadataVersion

func UpdateMetadataVersion(xfDir string, version *Version) error

UpdateMetadataVersion updates the version information in the metadata.

func WriteEnvFile

func WriteEnvFile(path string, values map[string]string) error

WriteEnvFile writes values to an .env file. It preserves comments and formatting from an existing file if present.

func WriteMetadata

func WriteMetadata(xfDir string, meta *Metadata) error

WriteMetadata writes metadata to the metadata file.

Types

type Metadata

type Metadata struct {
	// LicenseKey is the license key used for this installation
	LicenseKey string `json:"license_key"`

	// InstanceName is the Docker instance name
	InstanceName string `json:"instance_name"`

	// InstalledProducts tracks which products were installed
	InstalledProducts []string `json:"installed_products"`

	// InstalledVersion is the version that was installed
	InstalledVersion string `json:"installed_version"`

	// InstalledVersionID is the version ID that was installed
	InstalledVersionID int `json:"installed_version_id"`

	// CreatedAt is when the installation was created
	CreatedAt time.Time `json:"created_at"`

	// UpdatedAt is when the metadata was last updated
	UpdatedAt time.Time `json:"updated_at"`
}

Metadata stores CLI-specific information about a XenForo installation. This file is created during `init` and used by `upgrade` to remember settings.

func ReadMetadata

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

ReadMetadata reads the metadata file. Returns nil (not an error) if the file doesn't exist.

type Stability

type Stability string

Stability represents the release stability of a XenForo version.

const (
	StabilityAlpha   Stability = "alpha"
	StabilityBeta    Stability = "beta"
	StabilityRC      Stability = "rc"
	StabilityStable  Stability = "stable"
	StabilityPL      Stability = "pl"
	StabilityUnknown Stability = "unknown"
)

Stability constants represent different release stages.

type Version

type Version struct {
	String    string    // e.g., "2.3.8"
	ID        int       // e.g., 2030871
	Major     int       // e.g., 2
	Minor     int       // e.g., 3
	Patch     int       // e.g., 8
	Stability Stability // alpha, beta, rc, stable, pl
	StabNum   int       // stability number (1=alpha, 3=beta, 5=rc, 7=stable, 9=pl)
	PLLevel   int       // patch level (0-9)
}

Version represents a XenForo version with both string and ID representations.

func DetectVersion

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

DetectVersion parses src/XF.php for the version string and ID.

func ParseVersionID

func ParseVersionID(versionID int) *Version

ParseVersionID converts a version ID into a Version structure.

func ParseVersionString

func ParseVersionString(versionStr string) (*Version, error)

ParseVersionString parses a version string into a Version structure.

Jump to

Keyboard shortcuts

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