Documentation
¶
Overview ¶
Package project reads, creates and builds mod source projects. A project is a directory with mod.json, whose manifest names the mod and its language; building it writes the built mod, a directory modlock-host loads, to the project's build directory.
Index ¶
Constants ¶
const BuildDir = "build"
BuildDir is the built mod's directory within a project.
const Entry = "mod.wasm"
Entry is the built WebAssembly module's file name in a built mod.
const LibraryDir = ".modlock"
LibraryDir is where a Luau or Python project's copy of the modlock library lives, so the checker and editors resolve it.
const ManifestFile = check.ManifestFile
ManifestFile is the manifest's file name in a project and a built mod.
const MapsDir = "maps"
MapsDir is the directory of a project, and of its built mod, that holds the map the mod plays on when the mod ships its own: maps/<map>.vpk, and maps/<map>.bsp for the Quake collision its movement model walks on.
const Module = "github.com/paralin/modlock"
Module is the Go module of the Modlock library mods import.
const ScriptEntry = "mod.js"
ScriptEntry is the bundled JavaScript's file name in a built mod.
const SourcesEntry = "mod.zip"
SourcesEntry is the zip of a Luau or Python mod's sources in a built mod, which its runtime reads in place.
Variables ¶
This section is empty.
Functions ¶
func ReadManifest ¶
ReadManifest reads the mod.json in dir, a project or a built mod.
Types ¶
type CheckError ¶
type CheckError struct {
// Err describes the failure in one line.
Err error
// Diagnostics lists the problems.
Diagnostics []*cli.Diagnostic
}
CheckError is a build that failed on problems in the sources. Diagnostics locates each problem the checks and compilers reported.
func (*CheckError) Error ¶
func (e *CheckError) Error() string
Error returns the one-line description.
func (*CheckError) Unwrap ¶
func (e *CheckError) Unwrap() error
Unwrap returns the one-line description's error.
type Project ¶
type Project struct {
// Dir is the project directory.
Dir string
// Manifest is the project's mod.json.
Manifest *wasm.Manifest
}
Project is a mod's source directory.
func New ¶
func New(ctx context.Context, dir, name string, language wasm.Manifest_Language, version string, output io.Writer) (*Project, error)
New writes a project for a mod named name in language to dir, which must not exist or be empty. A Go project fetches the Modlock library at version, such as "v0.2.0" or "latest"; a script, Luau or Python project receives this release's library. output receives the tools' messages.
func (*Project) Build ¶
Build checks the project and writes the built mod to Output. Check and compiler errors go to output and fail the build with a *CheckError that locates them; a failed build leaves the previous built mod in place.