build

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 29 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 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. Exec commands run on the host, except for the @php, @composer, and @xf aliases, which use the environment when configured. 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 default to the build start time, not source modification times.

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 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 WithTaskProgress added in v0.4.0

func WithTaskProgress(progress func(Task) func(error)) Option

WithTaskProgress registers a callback before each task, including file collection. The returned function, if non-nil, is called when the task finishes with its error, or nil on success. Callbacks run synchronously in task order.

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 captures the current time once at the start.

func WithoutDependencyInstall

func WithoutDependencyInstall() Option

WithoutDependencyInstall skips Composer installation without skipping other build tasks.

type Task added in v0.4.0

type Task string

Task identifies a stage in the release build pipeline.

const (
	TaskComposer Task = "composer"
	TaskExport   Task = "export"
	TaskRollup   Task = "rollup"
	TaskMinify   Task = "minify"
	TaskExec     Task = "exec"
	TaskHashes   Task = "hashes"
	TaskArchive  Task = "archive"
)

Release build stages, reported only when enabled for the current build.

type WatchOptions

type WatchOptions struct {

	// Stderr receives build errors.
	Stderr io.Writer

	// OnBuild runs before each build, including the initial build. Its optional
	// completion callback receives the build error or nil on success. Callbacks
	// run serially; cancellation is reported to the completion callback too.
	OnBuild func() func(error)
	// contains filtered or unexported fields
}

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