files

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAJOR string = "major"
	MINOR string = "minor"
	PATCH string = "patch"
)

Variables

View Source
var ErrInvalidIncrement = errors.New("invalid version incrementation, must be one of [major|minor|patch]")
View Source
var ErrInvalidManifest = errors.New("not a valid typst manifest")
View Source
var ErrInvalidVersion = errors.New("not a valid semantic version")
View Source
var ErrLoadingTypstToml = errors.New("could not load typst.toml")

Functions

func CompareVersions added in v0.3.4

func CompareVersions(a, b Version) int

Compare two version structs. Useful to sort arrays of Versions

func ConfigurableUpdateToml

func ConfigurableUpdateToml(w io.Writer, p PackageInfo, data []byte, unmarshal Unmarshaler, indent bool) error

Write the Packageinfo (name, version and entrypoint) to io.Writer

The Unmarshal Function can be configured (e.g. for testing Purposes)

func CopyFile

func CopyFile(src, dst string) error

Copy a file from src to dst

func Exists

func Exists(path string) bool

Check if a file or directory exists

func IsSemVer added in v0.3.4

func IsSemVer(s string) bool

Check if a given string is a valid semantic version (e.g. 0.1.0)

  • No Letters, just positive Numbers
  • 3 Components (Numbers) separated with '.'

func UpdateTOML

func UpdateTOML(w io.Writer, p PackageInfo, data []byte, indent bool) error

Update the Packageinfo (name, version and entrypoint)

Types

type Manifest

type Manifest struct {
	Package PackageInfo `toml:"package"`
}

type PackageInfo

type PackageInfo struct {
	// The Name of the Package
	Name string `toml:"name"`
	// The Version of the Package
	Version string `toml:"version"`
	// The Entrypoint of the Package
	Entrypoint string `toml:"entrypoint"`
}

Structure with the required Typst TOML fields

func ConfigureableUnmarshalToPackage

func ConfigureableUnmarshalToPackage(data []byte, unmarshal Unmarshaler) (PackageInfo, error)

Unmarshal a byte slice into a PackageInfo Struct

The Unmarshal Function can be configured (e.g. for testing Purposes)

func LoadPackageFromDirectory

func LoadPackageFromDirectory(directory string) (PackageInfo, error)

Load a typst Package from a directory. Returns an error if not existing.

func NewPackageInfo added in v0.3.4

func NewPackageInfo() *PackageInfo

Convenient Package Struct initializer for the tests

func UnmarshalToPackage

func UnmarshalToPackage(data []byte) (PackageInfo, error)

Unmarshal a byte slice into a PackageInfo Struct

func (*PackageInfo) Bump added in v0.3.4

func (p *PackageInfo) Bump(increment string) error

func (*PackageInfo) SetVersion added in v0.3.4

func (p *PackageInfo) SetVersion(version string)

func (*PackageInfo) ValidateVersion

func (p *PackageInfo) ValidateVersion() bool

type Unmarshaler

type Unmarshaler func([]byte, any) error

type Version added in v0.3.4

type Version struct {
	Major uint64
	Minor uint64
	Patch uint64
}

A Semantic Version struct, where only positive integers are allowed

func NewVersion added in v0.3.4

func NewVersion() Version

Create a new Version struct with all Fields set to Zero

func ParseVersion added in v0.3.4

func ParseVersion(s string) (Version, error)

Parse a string into a Version Struct

func (*Version) Bump added in v0.3.4

func (v *Version) Bump(increment string) error

Bump the Version by the given increment (major, minor, patch) Returns an ErrInvalidIncrement if the wrong increment is used.

func (Version) String added in v0.3.4

func (v Version) String() string

Jump to

Keyboard shortcuts

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