Help us shape the future of Go! Take the 2026 Go Developer Survey

themeproject

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidContractRef   = errors.New("invalid contract reference")
	ErrContractNotPublished = errors.New("contract is not published on umono.dev")
	ErrRegistryUnreachable  = errors.New("umono.dev is unreachable")
)
View Source
var DefaultRegistry = Registry{BaseURL: "https://umono.dev", Client: &http.Client{Timeout: 30 * time.Second}}

DefaultRegistry is umono.dev, the only registry in v0.9.

View Source
var ErrExists = errors.New("already exists")

ErrExists is returned when a file or a directory already has the name of the project. Nothing is overwritten.

View Source
var ErrNotThemeProject = errors.New("not a theme project: theme.toml is missing")

ErrNotThemeProject is returned when the directory has no theme.toml.

Functions

func Create

func Create(dir string, m Manifest) (err error)

Create validates m and creates the theme project dir with the boilerplate files: theme.toml, assets/theme.css and .gitignore. Once dir is made, an error removes it, so a failed run leaves nothing behind.

func EnsureContract

func EnsureContract(ctx context.Context, projectDir, ref string, r Registry) (string, error)

EnsureContract returns the cache path of ref in projectDir, .dev/contracts/{org}/{id}/v{major}.{minor}.toml. The file is fetched from r only when it is missing: contracts are immutable, so a cached file never changes.

func Render

func Render(m Manifest) []byte

Render returns the theme.toml text of m.

func RenderBuilt

func RenderBuilt(m themecore.Manifest, version int, at time.Time) []byte

RenderBuilt returns built.toml: the values of theme.toml unchanged, with the detected theme-api-version and the build time in UTC.

Types

type BuildResult

type BuildResult struct {
	// Path is the built file, dist/{org}_{id}_{version}.umono-theme.
	Path   string
	Report themecore.BuildReport
	// PreservedComment reports a comment starting with /*! in
	// assets/theme.css. Comments do not go into the package; a note meant
	// to stay belongs in LICENSE.
	PreservedComment bool
}

BuildResult is the outcome of Build.

func Build

func Build(ctx context.Context, dir string, r Registry, now time.Time) (BuildResult, error)

Build checks the theme project dir and writes its built file into dist/. The contract is the cached file of the reference in theme.toml, fetched from r when missing. dist/ is touched only after every check has passed.

type Manifest

type Manifest struct {
	ID          string
	Name        string
	Contract    string
	Version     string
	Description string
	License     string
	Homepage    string
	Repository  string
	AuthorName  string
	AuthorURL   string
}

Manifest holds the answers of umono theme create. Empty optional fields are not written. AuthorName and AuthorURL make the single [[authors]] entry.

func (Manifest) Validate

func (m Manifest) Validate() error

Validate checks m with the rules of theme.toml, so that create writes nothing that build would reject.

type Registry

type Registry struct {
	BaseURL string
	Client  *http.Client
}

Registry is where contracts are fetched from.

Jump to

Keyboard shortcuts

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