Documentation
¶
Overview ¶
Package manifest loads and validates pawn.json and pawn.yaml files.
Index ¶
Constants ¶
const ( CodeParseError = "pawn-project:manifest-parse-error" CodeInvalidType = "pawn-project:manifest-invalid-type" CodeInvalidPreset = "pawn-project:manifest-invalid-preset" CodeEmptyEntry = "pawn-project:manifest-empty-entry" CodeEmptyOutput = "pawn-project:manifest-empty-output" CodeInvalidDependency = "pawn-project:manifest-invalid-dependency" CodeSchemaVersionMissing = "pawn-project:manifest-pawnkit-schema-version-missing" CodeSchemaVersionInvalid = "pawn-project:manifest-pawnkit-schema-version-unsupported" CodeInvalidProfile = "pawn-project:manifest-invalid-profile" CodeUnknownPawnKitField = "pawn-project:manifest-unknown-pawnkit-field" CodePathTraversal = "pawn-project:manifest-path-traversal" CodeMissingBuildName = "pawn-project:manifest-missing-build-name" CodeMissingRuntimeName = "pawn-project:manifest-missing-runtime-name" CodeMissingResourceField = "pawn-project:manifest-missing-resource-field" )
Diagnostic codes emitted by Load. Never repurposed once shipped, per the shared engineering baseline's diagnostic-code stability rule.
const ( // ProfileOpenMP selects the open.mp target profile. ProfileOpenMP = "openmp" // ProfileSAMP selects the SA-MP target profile. ProfileSAMP = "samp" )
const Source = "pawn-project"
Source is the diagnostic.Source value used for every diagnostic this package produces.
Variables ¶
This section is empty.
Functions ¶
func EncodeJSON ¶ added in v0.1.10
EncodeJSON returns an indented pawn.json document with a trailing newline.
Types ¶
type Build ¶
type Build struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Args []string `json:"args,omitempty" yaml:"args,omitempty"`
Constants map[string]any `json:"constants,omitempty" yaml:"constants,omitempty"`
Compiler *CompilerRef `json:"compiler,omitempty" yaml:"compiler,omitempty"`
Input string `json:"input,omitempty" yaml:"input,omitempty"`
Output string `json:"output,omitempty" yaml:"output,omitempty"`
Includes []string `json:"includes,omitempty" yaml:"includes,omitempty"`
}
Build mirrors the schema's "build"/"builds[]" object.
type CompilerRef ¶
type CompilerRef struct {
Site string `json:"site,omitempty" yaml:"site,omitempty"`
User string `json:"user,omitempty" yaml:"user,omitempty"`
Repo string `json:"repo,omitempty" yaml:"repo,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
}
CompilerRef mirrors the schema's "build.compiler" object.
type CreateOptions ¶ added in v0.1.10
CreateOptions describes a new PawnKit project manifest.
type Dependency ¶
type Dependency struct {
Raw string
Scheme Scheme
User string
Repo string
RefKind RefKind
Ref string
}
Dependency is a parsed sampctl dependency reference.
func ParseDependency ¶
func ParseDependency(raw string) (Dependency, error)
ParseDependency parses a sampctl dependency reference.
type Experimental ¶
type Experimental struct {
// BuildFile distinguishes an omitted value from false.
BuildFile *bool `json:"build_file,omitempty" yaml:"build_file,omitempty"`
}
Experimental mirrors the schema's "experimental" object.
func (Experimental) BuildFileEnabled ¶
func (e Experimental) BuildFileEnabled() bool
BuildFileEnabled reports the effective value of Experimental.BuildFile, applying the schema's documented default of true.
type LoadResult ¶
type LoadResult struct {
Manifest *Manifest
Diagnostics []diagnostic.Diagnostic
}
LoadResult contains a manifest and any content diagnostics.
type Manifest ¶
type Manifest struct {
Entry string `json:"entry,omitempty" yaml:"entry,omitempty"`
Output string `json:"output,omitempty" yaml:"output,omitempty"`
User string `json:"user,omitempty" yaml:"user,omitempty"`
Repo string `json:"repo,omitempty" yaml:"repo,omitempty"`
Dependencies []Dependency `json:"-" yaml:"-"`
DevDependencies []Dependency `json:"-" yaml:"-"`
Preset string `json:"preset,omitempty" yaml:"preset,omitempty"`
Local bool `json:"local,omitempty" yaml:"local,omitempty"`
IncludePath string `json:"include_path,omitempty" yaml:"include_path,omitempty"`
Resources []Resource `json:"resources,omitempty" yaml:"resources,omitempty"`
ExtractIgnorePatterns []string `json:"extract_ignore_patterns,omitempty" yaml:"extract_ignore_patterns,omitempty"`
Contributors []any `json:"contributors,omitempty" yaml:"contributors,omitempty"`
Website string `json:"website,omitempty" yaml:"website,omitempty"`
Experimental Experimental `json:"experimental" yaml:"experimental"`
Build *Build `json:"build,omitempty" yaml:"build,omitempty"`
Builds []Build `json:"builds,omitempty" yaml:"builds,omitempty"`
Runtime *Runtime `json:"runtime,omitempty" yaml:"runtime,omitempty"`
Runtimes []Runtime `json:"runtimes,omitempty" yaml:"runtimes,omitempty"`
PawnKit *PawnKitExtension `json:"pawnkit,omitempty" yaml:"pawnkit,omitempty"`
// SourcePath is the absolute path passed to Load.
SourcePath string `json:"-" yaml:"-"`
}
Manifest is a decoded project manifest.
func New ¶ added in v0.1.10
func New(options CreateOptions) (*Manifest, error)
New creates a manifest with sampctl-compatible fields and optional PawnKit settings.
func (*Manifest) EffectiveIncludePaths ¶
EffectiveIncludePaths returns all declared include paths in search order.
type PawnKitExtension ¶
type PawnKitExtension struct {
SchemaVersion int `json:"schemaVersion" yaml:"schemaVersion"`
Profile string `json:"profile,omitempty" yaml:"profile,omitempty"`
IncludePaths []string `json:"includePaths,omitempty" yaml:"includePaths,omitempty"`
Tests map[string]any `json:"tests,omitempty" yaml:"tests,omitempty"`
Tool map[string]map[string]any `json:"tool,omitempty" yaml:"tool,omitempty"`
Lockfile string `json:"lockfile,omitempty" yaml:"lockfile,omitempty"`
}
PawnKitExtension contains optional PawnKit settings.
func (*PawnKitExtension) LockfilePath ¶
func (p *PawnKitExtension) LockfilePath() string
LockfilePath returns the configured lockfile path, applying the schema's documented default of "pawn.lock".
type Resource ¶ added in v0.3.8
type Resource struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Platform string `json:"platform,omitempty" yaml:"platform,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
Archive bool `json:"archive,omitempty" yaml:"archive,omitempty"`
Includes []string `json:"includes,omitempty" yaml:"includes,omitempty"`
Plugins []string `json:"plugins,omitempty" yaml:"plugins,omitempty"`
Files map[string]string `json:"files,omitempty" yaml:"files,omitempty"`
}
Resource describes one sampctl release asset.
type Runtime ¶
type Runtime struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
Mode string `json:"mode,omitempty" yaml:"mode,omitempty"`
Port int `json:"port,omitempty" yaml:"port,omitempty"`
Gamemodes []string `json:"gamemodes,omitempty" yaml:"gamemodes,omitempty"`
Filterscripts []string `json:"filterscripts,omitempty" yaml:"filterscripts,omitempty"`
Plugins []string `json:"plugins,omitempty" yaml:"plugins,omitempty"`
RCONPassword string `json:"rcon_password,omitempty" yaml:"rcon_password,omitempty"`
Announce *bool `json:"announce,omitempty" yaml:"announce,omitempty"`
MaxPlayers int `json:"maxplayers,omitempty" yaml:"maxplayers,omitempty"`
LANMode *bool `json:"lanmode,omitempty" yaml:"lanmode,omitempty"`
Query *bool `json:"query,omitempty" yaml:"query,omitempty"`
RCON *bool `json:"rcon,omitempty" yaml:"rcon,omitempty"`
LogQueries *bool `json:"logqueries,omitempty" yaml:"logqueries,omitempty"`
StreamRate int `json:"stream_rate,omitempty" yaml:"stream_rate,omitempty"`
StreamDistance float64 `json:"stream_distance,omitempty" yaml:"stream_distance,omitempty"`
Sleep any `json:"sleep,omitempty" yaml:"sleep,omitempty"`
MaxNPC int `json:"maxnpc,omitempty" yaml:"maxnpc,omitempty"`
OnFootRate int `json:"onfoot_rate,omitempty" yaml:"onfoot_rate,omitempty"`
InCarRate int `json:"incar_rate,omitempty" yaml:"incar_rate,omitempty"`
WeaponRate int `json:"weapon_rate,omitempty" yaml:"weapon_rate,omitempty"`
ChatLogging *bool `json:"chatlogging,omitempty" yaml:"chatlogging,omitempty"`
Timestamp *bool `json:"timestamp,omitempty" yaml:"timestamp,omitempty"`
Bind string `json:"bind,omitempty" yaml:"bind,omitempty"`
Password string `json:"password,omitempty" yaml:"password,omitempty"`
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
Language string `json:"language,omitempty" yaml:"language,omitempty"`
MapName string `json:"mapname,omitempty" yaml:"mapname,omitempty"`
WebURL string `json:"weburl,omitempty" yaml:"weburl,omitempty"`
GameModeText string `json:"gamemodetext,omitempty" yaml:"gamemodetext,omitempty"`
NoSign string `json:"nosign,omitempty" yaml:"nosign,omitempty"`
LogTimeFormat string `json:"logtimeformat,omitempty" yaml:"logtimeformat,omitempty"`
MessageHoleLimit int `json:"messageholelimit,omitempty" yaml:"messageholelimit,omitempty"`
MessagesLimit int `json:"messageslimit,omitempty" yaml:"messageslimit,omitempty"`
AckLimit int `json:"ackslimit,omitempty" yaml:"ackslimit,omitempty"`
PlayerTimeout int `json:"playertimeout,omitempty" yaml:"playertimeout,omitempty"`
MinConnectionTime int `json:"minconnectiontime,omitempty" yaml:"minconnectiontime,omitempty"`
LagCompMode int `json:"lagcompmode,omitempty" yaml:"lagcompmode,omitempty"`
ConnectionSeed int `json:"connseedtime,omitempty" yaml:"connseedtime,omitempty"`
DBLogging *bool `json:"db_logging,omitempty" yaml:"db_logging,omitempty"`
DBLogQueries *bool `json:"db_log_queries,omitempty" yaml:"db_log_queries,omitempty"`
ConnectionCookies *bool `json:"conncookies,omitempty" yaml:"conncookies,omitempty"`
CookieLogging *bool `json:"cookielogging,omitempty" yaml:"cookielogging,omitempty"`
Extra map[string]any `json:"extra,omitempty" yaml:"extra,omitempty"`
}
Runtime describes a server configuration. Extra preserves unknown fields.