build

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package build creates XenForo add-on releases and builds JavaScript assets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildJavaScript

func BuildJavaScript(ctx context.Context, rootDir, addOnID string) error

BuildJavaScript runs the add-on's configured minify and rollup tasks.

rootDir and addOnID have the same meaning as in Build. It does not install dependencies, run configured commands, or create a release.

func WatchJavaScript

func WatchJavaScript(ctx context.Context, rootDir, addOnID string, options WatchOptions) error

WatchJavaScript rebuilds the add-on's JavaScript when sources or configuration change.

rootDir and addOnID have the same meaning as in Build. Build errors are reported on options.Stderr without stopping the watcher. It blocks until ctx is canceled or watching fails. Cancellation returns an error wrapping ctx.Err().

Types

type BuildResult

type BuildResult struct {
	// HashesPath is the absolute path to the generated hash manifest.
	HashesPath string

	// ZipPath is the absolute path to the release archive.
	ZipPath string

	// FileCount counts archived files other than the generated hash manifest.
	FileCount int

	// TotalSize is the total uncompressed size of the files counted by FileCount,
	// in bytes.
	TotalSize int64
}

BuildResult describes a completed release.

func Build

func Build(ctx context.Context, rootDir, addOnID string, options ...Option) (*BuildResult, error)

Build runs an add-on's build tasks and writes its hash manifest and release ZIP.

rootDir names the XenForo installation; addOnID is an ID such as "Vendor/AddOn". The add-on's optional build.json determines the build root and file selection. Without it, all eligible files beneath the add-on directory are included. Composer uses the project's Docker environment when configured and runs on the host otherwise. Configured exec commands always run on the host. Data is exported from prepared _output after Composer and before JavaScript tasks. The export creates the add-on's _data directory if needed. ZIP timestamps are fixed by default and do not use source modification times.

type Option

type Option func(*buildOptions)

Option configures a call to Build.

func WithIO

func WithIO(stdin io.Reader, stdout, stderr io.Writer) Option

WithIO sets the streams for subprocesses and build warnings.

A nil stdin provides no input; nil stdout and stderr discard output. These are also the defaults when WithIO is not supplied.

func WithTimestamp

func WithTimestamp(timestamp time.Time) Option

WithTimestamp sets the modification time of every ZIP entry, including generated files. The time is normalized to UTC with whole-second precision and must fall between 1980-01-01 and 2106-02-07 06:28:15 UTC. Without this option, Build uses 1980-01-01 00:00:00 UTC.

func WithoutDependencyInstall

func WithoutDependencyInstall() Option

WithoutDependencyInstall skips Composer installation without skipping other build tasks.

type WatchOptions

type WatchOptions struct {
	// Stdout receives successful build status messages.
	Stdout io.Writer

	// Stderr receives build errors.
	Stderr io.Writer
}

WatchOptions controls reporting from WatchJavaScript. Its zero value discards all output.

Jump to

Keyboard shortcuts

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