project

package
v0.1.3 Latest Latest
Warning

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

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

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

View Source
const BuildDir = "build"

BuildDir is the built mod's directory within a project.

View Source
const Entry = "mod.wasm"

Entry is the built WebAssembly module's file name in a built mod.

View Source
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.

View Source
const ManifestFile = check.ManifestFile

ManifestFile is the manifest's file name in a project and a built mod.

View Source
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.

View Source
const Module = "github.com/paralin/modlock"

Module is the Go module of the Modlock library mods import.

View Source
const ScriptEntry = "mod.js"

ScriptEntry is the bundled JavaScript's file name in a built mod.

View Source
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

func ReadManifest(dir string) (*wasm.Manifest, error)

ReadManifest reads the mod.json in dir, a project or a built mod.

func WriteManifest

func WriteManifest(path string, manifest *wasm.Manifest) error

WriteManifest writes manifest to path as indented JSON, one field per line, with enums by name. It replaces path whole.

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 Open

func Open(dir string) (*Project, error)

Open reads the project in dir.

func (*Project) Build

func (p *Project) Build(ctx context.Context, output io.Writer) error

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.

func (*Project) Output

func (p *Project) Output() string

Output returns the built mod's directory.

func (*Project) Watch

func (p *Project) Watch(ctx context.Context, changed func()) error

Watch calls changed after the project's sources change, once per burst of changes, until ctx ends. It skips the build directory, the installed library and hidden directories.

Jump to

Keyboard shortcuts

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