templates

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package templates provides template rendering functionality for Shipyard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultChangelogTemplate

func DefaultChangelogTemplate(templateName string) string

DefaultChangelogTemplate returns the default changelog template based on template name

func DefaultCommitTemplate

func DefaultCommitTemplate(repoType config.RepoType) string

DefaultCommitTemplate returns the default git commit message template

func DefaultTagTemplate

func DefaultTagTemplate(repoType config.RepoType) string

DefaultTagTemplate returns the default git tag template

Types

type ChangelogChange

type ChangelogChange struct {
	Summary       string // Summary of the consignment change
	ChangeType    string // e.g., "patch", "minor", "major"
	Section       string // e.g., "Added", "Fixed", "Changed"
	PackageName   string // for monorepo projects
	ConsignmentID string // ID of the original consignment
}

ChangelogChange represents a single change in a changelog entry

type ChangelogEntry

type ChangelogEntry struct {
	Version      string
	Date         string                       // Formatted date
	DateTime     string                       // Full datetime
	ShipmentDate string                       // Date when shipment was created
	Changes      map[string][]ChangelogChange // section -> list of consignment changes
	PackageName  string                       // for monorepo projects
	ShipmentID   string                       // ID of the shipment
}

ChangelogEntry represents a single shipment entry in the changelog

type ChangelogTemplateData

type ChangelogTemplateData struct {
	TemplateData
	ShipmentEntries       []ChangelogEntry             // All shipment entries in the changelog
	CurrentShipment       *ChangelogEntry              // Current shipment entry being rendered
	ConsignmentsBySection map[string][]ChangelogChange // Consignments grouped by section
}

ChangelogTemplateData represents data specifically for changelog templates

type CommitTemplateData

type CommitTemplateData struct {
	TemplateData
	CommitType   string   // Type of commit (release, etc.)
	FilesChanged []string // List of files being committed
}

CommitTemplateData represents data specifically for git commit templates

type TagTemplateData

type TagTemplateData struct {
	TemplateData
	TagName string // The tag name being created
}

TagTemplateData represents data specifically for git tag templates

type TemplateData

type TemplateData struct {
	// Repository information
	RepoURL   string
	RepoOwner string
	RepoName  string
	RepoType  string // "monorepo" or "single-repo"

	// Package information
	Package  string   // Current package name
	Packages []string // All package names

	// Shipment information (version being released)
	Version     string            // Current version being shipped
	Versions    map[string]string // All package versions in this shipment
	PrevVersion string            // Previous shipped version

	// Consignment information (changes being shipped)
	ChangeType           string   // The change type (patch, minor, major, etc.)
	ChangeTypes          []string // All change types in this shipment
	ConsignmentSummary   string   // Summary of consignment changes
	ConsignmentSummaries []string // All consignment summaries in this shipment

	// Date information
	Date         string // Current date in YYYY-MM-DD format
	DateTime     string // Current date and time
	Timestamp    int64  // Unix timestamp
	ShipmentDate string // Date when shipment is being created

	// Git information
	GitHash   string // Current git commit hash
	GitBranch string // Current git branch

	// Custom fields
	Custom map[string]interface{} // Custom template variables
}

TemplateData represents the data available to templates

type TemplateEngine

type TemplateEngine struct {
	// contains filtered or unexported fields
}

TemplateEngine provides template rendering functionality

func NewTemplateEngine

func NewTemplateEngine(projectConfig *config.ProjectConfig) *TemplateEngine

NewTemplateEngine creates a new template engine

func (*TemplateEngine) RenderChangelogTemplate

func (e *TemplateEngine) RenderChangelogTemplate(entries []ChangelogEntry, templateName string) (string, error)

RenderChangelogTemplate renders a changelog using the specified template

func (*TemplateEngine) RenderCommitTemplate

func (e *TemplateEngine) RenderCommitTemplate(versions map[string]*semver.Version, summaries []string, customData map[string]interface{}) (string, error)

RenderCommitTemplate renders a git commit message template

func (*TemplateEngine) RenderTagTemplate

func (e *TemplateEngine) RenderTagTemplate(packageName string, version *semver.Version, customData map[string]interface{}) (string, error)

RenderTagTemplate renders a git tag template

func (*TemplateEngine) ValidateTemplate

func (e *TemplateEngine) ValidateTemplate(templateStr string) error

ValidateTemplate validates a template string

Jump to

Keyboard shortcuts

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