Documentation
¶
Overview ¶
Package changeset provides core types and operations for managing changesets.
Index ¶
- Variables
- func ChangesetDirExists(dir string) bool
- func DeleteChangeset(cs *Changeset) error
- func DeleteManifest(dir string) error
- func GenerateID() string
- func IncrementVersion(current string, bump Bump) (string, error)
- func InitChangeset(dir string, cfg *Config) error
- func ManifestExists(dir string) bool
- func WriteChangeset(dir string, cs *Changeset) error
- func WriteConfig(dir string, cfg *Config) error
- func WriteManifest(dir string, m *Manifest) error
- type Bump
- type Changeset
- type Config
- type Manifest
- type Release
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoChangesets = errors.New("no changesets found") ErrNoManifest = errors.New("release manifest not found") ErrInvalidChangeset = errors.New("invalid changeset format") ErrInvalidVersion = errors.New("invalid semantic version") ErrUncommitted = errors.New("uncommitted changes exist") )
Sentinel errors for changeset operations.
Functions ¶
func ChangesetDirExists ¶
ChangesetDirExists returns true if the .changeset directory exists.
func DeleteChangeset ¶
DeleteChangeset removes a changeset file.
func DeleteManifest ¶
DeleteManifest removes .changeset/release-manifest.json.
func GenerateID ¶
func GenerateID() string
GenerateID returns a random changeset ID (e.g., "hungry-tiger-jump").
func IncrementVersion ¶
IncrementVersion bumps a semantic version by the given bump type.
func InitChangeset ¶
InitChangeset creates the .changeset directory with config and README.
func ManifestExists ¶
ManifestExists returns true if release-manifest.json exists.
func WriteChangeset ¶
WriteChangeset writes a changeset to the .changeset directory. Generates a random ID if cs.ID is empty.
func WriteConfig ¶
WriteConfig writes config to .changeset/config.json.
func WriteManifest ¶
WriteManifest writes the manifest to .changeset/release-manifest.json.
Types ¶
type Bump ¶
type Bump string
Bump represents a semantic version bump type.
type Changeset ¶
type Changeset struct {
ID string // Filename without extension (e.g., "hungry-tiger-jump")
Modules map[string]Bump // Module short name -> bump type
Summary string // Markdown description
FilePath string // Full path to the file
}
Changeset represents a single changeset file.
func ParseChangeset ¶
ParseChangeset reads and parses a single changeset file. Returns error if file format is invalid.
func ReadChangesets ¶
ReadChangesets reads all changeset files from the .changeset directory. Skips config.json, README.md, and release-manifest.json.
type Config ¶
type Config struct {
Root string `json:"root"` // Root module path
BaseBranch string `json:"baseBranch"` // Default: "main"
Ignore []string `json:"ignore"` // Modules to ignore
IgnorePaths []string `json:"ignorePaths"` // File paths to ignore in CI check
DependentBump Bump `json:"dependentBump"` // How to bump dependents (default: "patch")
}
Config represents .changeset/config.json.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with sensible defaults.
func ReadConfig ¶
ReadConfig reads .changeset/config.json. Returns DefaultConfig if file doesn't exist.
type Manifest ¶
type Manifest struct {
Releases []Release `json:"releases"`
}
Manifest represents .changeset/release-manifest.json.
func ReadManifest ¶
ReadManifest reads .changeset/release-manifest.json. Returns error if file doesn't exist.
type Release ¶
type Release struct {
Module string `json:"module"`
Version string `json:"version"`
PreviousVersion string `json:"previousVersion"`
Bump Bump `json:"bump"`
Reason string `json:"reason,omitempty"` // "dependency" if auto-bumped
}
Release represents a computed release for a module.
func ComputeReleases ¶
func ComputeReleases( changesets []*Changeset, graph *module.Graph, tags map[string]string, cfg *Config, ) ([]Release, error)
ComputeReleases calculates version bumps from changesets.
Algorithm:
- Aggregate bumps per module (highest bump wins)
- Get current versions from git tags
- Cascade bumps to dependent modules
- Compute next versions
Parameters:
- changesets: All pending changesets
- graph: Module dependency graph
- tags: Current git tags (module short name -> version)
- cfg: Config for dependent bump behavior
Returns releases sorted by module name.
func FilterIgnored ¶
FilterIgnored removes ignored modules from the releases list.