Documentation
¶
Overview ¶
Package build creates XenForo add-on releases and builds JavaScript assets.
Index ¶
- func Build(ctx context.Context, rootDir, addOnID string, options ...Option) (*buildResult, error)
- func BuildJavaScript(ctx context.Context, rootDir, addOnID string) error
- func WatchJavaScript(ctx context.Context, rootDir, addOnID string, options WatchOptions) error
- type Option
- type Task
- type WatchOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
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 ¶
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 ¶
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
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 ¶
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 identifies dependency installation. TaskComposer Task = "composer" // TaskExport identifies development-output export. TaskExport Task = "export" // TaskRollup identifies JavaScript bundling. TaskRollup Task = "rollup" // TaskMinify identifies JavaScript minification. TaskMinify Task = "minify" // TaskExec identifies configured command execution. TaskExec Task = "exec" // TaskHashes identifies file selection and hash manifest creation. TaskHashes Task = "hashes" // TaskArchive identifies release archive creation. TaskArchive Task = "archive" )
type WatchOptions ¶
type WatchOptions struct {
Stderr io.Writer
OnBuild func() func(error)
// contains filtered or unexported fields
}
WatchOptions controls reporting from WatchJavaScript. Its zero value discards all output. stdout receives successful build status messages, and Stderr receives errors. OnBuild runs before each build, including the initial build. Its optional completion callback receives the build error or nil on success. Callbacks run serially, and cancellation is reported to the completion callback.