Documentation
¶
Index ¶
- Constants
- Variables
- func CompareVersions(a, b Version) int
- func ConfigurableUpdateToml(w io.Writer, p PackageInfo, data []byte, unmarshal Unmarshaler, indent bool) error
- func CopyFile(src, dst string) error
- func Exists(path string) bool
- func IsSemVer(s string) bool
- func UpdateTOML(w io.Writer, p PackageInfo, data []byte, indent bool) error
- type Manifest
- type PackageInfo
- type Unmarshaler
- type Version
Constants ¶
const ( MAJOR string = "major" MINOR string = "minor" PATCH string = "patch" )
Variables ¶
var ErrInvalidIncrement = errors.New("invalid version incrementation, must be one of [major|minor|patch]")
var ErrInvalidManifest = errors.New("not a valid typst manifest")
var ErrInvalidVersion = errors.New("not a valid semantic version")
var ErrLoadingTypstToml = errors.New("could not load typst.toml")
Functions ¶
func CompareVersions ¶ added in v0.3.4
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 IsSemVer ¶ added in v0.3.4
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 ¶
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 Version ¶ added in v0.3.4
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
Parse a string into a Version Struct