pkgcontext

package
v0.0.0-...-b66b17e Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotRemotePackage = errors.New("remote repository does not declare a package")

ErrNotRemotePackage describes a repository that does not contain a package definition file

Functions

func CleanInvalidRepository

func CleanInvalidRepository(path string) error

CleanInvalidRepository removes a repository if it fails validation

func DiagnoseRepository

func DiagnoseRepository(path string) (diagnosis string, healthy bool)

DiagnoseRepository provides detailed diagnostic information about a repository

func RepairRepository

func RepairRepository(path string) error

RepairRepository attempts to repair a corrupted repository

func ValidateRepository

func ValidateRepository(path string) (valid bool, err error)

ValidateRepository performs checks on a git repository to ensure it's in a healthy state

func ValidateRepositoryWithRefs

func ValidateRepositoryWithRefs(path string, requiredRefs []string) (valid bool, err error)

ValidateRepositoryWithRefs performs validation and also checks if specific refs exist

func WrapGitError

func WrapGitError(err error, meta versioning.DependencyMeta) error

WrapGitError provides concise, helpful error messages for Git operations

Types

type PackageContext

type PackageContext struct {
	Package         pawnpackage.Package         // the package this context wraps
	GitHub          *github.Client              // GitHub client for downloading plugins
	GitAuth         transport.AuthMethod        // Authentication method for git
	Platform        string                      // the platform this package targets
	CacheDir        string                      // the cache directory
	AllDependencies []versioning.DependencyMeta // flattened list of dependencies
	AllPlugins      []versioning.DependencyMeta // flattened list of plugin dependencies
	AllIncludePaths []string                    // any additional include paths specified by resources
	ActualRuntime   run.Runtime                 // actual runtime configuration to use for running the package
	ActualBuild     build.Config                // actual build configuration to use for running the package

	// Runtime specific fields
	Runtime     string // the runtime config to use, defaults to `default`
	Container   bool   // whether or not to run the package in a container
	AppVersion  string // the version of sampctl
	BuildName   string // Build configuration to use
	ForceBuild  bool   // Force a build before running
	ForceEnsure bool   // Force an ensure before building before running
	NoCache     bool   // Don't use a cache, download all plugin dependencies
	BuildFile   string // File to increment build number
	Relative    bool   // Show output as relative paths
}

PackageContext stores state for a package during its lifecycle.

func NewPackageContext

func NewPackageContext(
	gh *github.Client,
	auth transport.AuthMethod,
	parent bool,
	dir string,
	platform string,
	cacheDir string,
	vendor string,
	init bool,
) (pcx *PackageContext, err error)

NewPackageContext attempts to parse a directory as a Package by looking for a `pawn.json` or `pawn.yaml` file and unmarshalling it - additional parameters are required to specify whether or not the package is a "parent package" and where the vendor directory is.

func (*PackageContext) Build

func (pcx *PackageContext) Build(
	ctx context.Context,
	build string,
	ensure bool,
	dry bool,
	relative bool,
	buildFile string,
) (
	problems build.Problems,
	result build.Result,
	err error,
)

Build compiles a package, dependencies are ensured and a list of paths are sent to the compiler.

func (*PackageContext) BuildWatch

func (pcx *PackageContext) BuildWatch(
	ctx context.Context,
	name string,
	ensure bool,
	buildFile string,
	relative bool,
	trigger chan build.Problems,
) (err error)

BuildWatch runs the Build code on file changes

func (*PackageContext) EnsureDependencies

func (pcx *PackageContext) EnsureDependencies(ctx context.Context, forceUpdate bool) (err error)

EnsureDependencies traverses package dependencies and ensures they are up to date

func (*PackageContext) EnsureDependenciesCached

func (pcx *PackageContext) EnsureDependenciesCached() (errOuter error)

EnsureDependenciesCached will recursively visit a parent package dependencies in the cache, pulling them if they do not exist yet.

func (PackageContext) EnsureDependencyCached

func (pcx PackageContext) EnsureDependencyCached(
	meta versioning.DependencyMeta,
	forceUpdate bool,
) (repo *git.Repository, err error)

EnsureDependencyCached clones a package to path using the default branch

func (PackageContext) EnsureDependencyFromCache

func (pcx PackageContext) EnsureDependencyFromCache(
	meta versioning.DependencyMeta,
	path string,
	forceUpdate bool,
) (repo *git.Repository, err error)

EnsureDependencyFromCache ensures the repository at `path` is up to date

func (*PackageContext) EnsurePackage

func (pcx *PackageContext) EnsurePackage(meta versioning.DependencyMeta, forceUpdate bool) error

EnsurePackage will make sure a vendor directory contains the specified package. If the package is not present, it will clone it at the correct version tag, sha1 or HEAD If the package is present, it will ensure the directory contains the correct version

func (*PackageContext) GatherPlugins

func (pcx *PackageContext) GatherPlugins() (pluginDeps []versioning.DependencyMeta, err error)

GatherPlugins iterates the AllPlugins list and appends them to the runtime dependencies list

func (*PackageContext) Install

func (pcx *PackageContext) Install(
	ctx context.Context,
	targets []versioning.DependencyString,
	development bool,
) (err error)

Install adds a new dependency to an existing local parent package

func (*PackageContext) Run

func (pcx *PackageContext) Run(ctx context.Context, output io.Writer, input io.Reader) (err error)

Run will create a temporary server runtime and run the package output AMX as a gamemode using the runtime configuration in the package info.

func (*PackageContext) RunPrepare

func (pcx *PackageContext) RunPrepare(ctx context.Context) (err error)

RunPrepare prepares the context directory for executing the server.

func (*PackageContext) RunWatch

func (pcx *PackageContext) RunWatch(ctx context.Context) (err error)

RunWatch runs the Run code on file changes

func (*PackageContext) TagTaglessDependencies

func (pcx *PackageContext) TagTaglessDependencies(ctx context.Context, forceUpdate bool) (bool, error)

TagTaglessDependencies updates the root package definition file so any dependency without an explicit tag/branch/commit gets pinned to the latest available tag.

func (*PackageContext) Uninstall

func (pcx *PackageContext) Uninstall(
	targets []versioning.DependencyString,
	development bool,
) (err error)

Uninstall removes a dependency from a package and attempts to delete the contents

Jump to

Keyboard shortcuts

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