scaffold

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scaffold is heraut init: the interactive wizard, its defaults, and writing .heraut.yml, keeping the keys the wizard does not ask about on an update.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectedForge added in v1.0.1

func DetectedForge(getenv func(string) string, gitOrigin string) (typ, project string, ok bool)

DetectedForge reports the publishing forge a run would find on its own: CI markers first, then a git origin on github.com or gitlab.com. ok is false for anything else, Azure DevOps included, since it has no publish driver.

func DroppedEnvFields added in v0.35.0

func DroppedEnvFields(cfg *config.Config, rebuilt []EnvAnswer) []string

DroppedEnvFields returns the YAML paths of per-environment settings that could not be matched after the wizard ran. An env is "lost" when the original config contained an environment that no rebuilt entry matched by name — i.e. the user renamed or removed an environment during the wizard.

Call this after RunWizard (post-wizard) to emit a targeted warning only when carry- through actually failed, rather than a pre-wizard "these might be dropped" notice.

func DroppedPlatformFields added in v0.35.0

func DroppedPlatformFields(cfg *config.Config, rebuilt []PlatformAnswer) []string

DroppedPlatformFields returns the YAML paths of per-platform settings that could not be carried through to the rebuilt platform list after the wizard ran. A field is "dropped" only when the original config had more entries of a given platform type than the rebuilt list — i.e. the user removed or changed the type of a platform during the wizard, leaving a tail of original entries with no positional match.

Call this after RunWizard (post-wizard) to emit a targeted warning only when carry- through actually failed, rather than the pre-wizard "these might be dropped" notice that T99 originally placed.

func GenerateUpdatedYAML added in v1.0.1

func GenerateUpdatedYAML(existing *config.Config, a Answers, version string) (string, error)

GenerateUpdatedYAML is GenerateYAML for the "Update it?" flow: the answers are laid over the existing config, so every key the wizard does not ask about (hooks, git, bump, branches, rendering, commit rules, per-target assets, …) is kept as it was. A nil existing config is a new file.

func GenerateYAML

func GenerateYAML(a Answers, version string) (string, error)

GenerateYAML converts answers to a .heraut.yml string with a yaml-language-server header. version is the heraut build version (e.g. "v1.2.3"); empty or "dev" falls back to main.

func GitOrigin added in v1.0.1

func GitOrigin() string

GitOrigin returns the origin remote URL of the current directory's repository, or "" when there is none.

func RunWizard

func RunWizard(a *Answers) error

RunWizard runs the interactive huh-based wizard and populates a.

func ValidateCalVerFormat

func ValidateCalVerFormat(format string) error

ValidateCalVerFormat validates a CalVer format string for use in .heraut.yml.

Types

type Answers

type Answers struct {
	Strategy  string // semver, calver, semver-per-env, calver-per-env
	TagPrefix string // version prefix, e.g. "v" or ""
	Format    string // CalVer format string, e.g. "YYYY.MM.PATCH"

	EnableChangelog bool
	ChangelogOutput string // e.g. "CHANGELOG.md"

	Platforms []PlatformAnswer

	// PublishReleases answers the single collapsed "create a release?" question (T220,
	// release-atomicity design): release: presence always means "generate notes and publish,"
	// together, so there is no longer an independent notes toggle. PublishReleases gates both
	// whether runPlatformWizard runs and whether cfg.Release is emitted at all in generate.go. A
	// false answer clears Platforms (see applyPublishChoice) so a stale, pre-populated slice
	// from an edit-existing-config round trip can't survive into GenerateYAML.
	PublishReleases bool

	// Sprint is the current sprint counter, required when Format contains SPRINT.
	// Not clock-derived: advance it with `heraut version sprint bump`.
	Sprint int

	// Per-env strategies only.
	TagFormat    string
	Environments []EnvAnswer

	// Assets and Tickets are not wizard-editable; they are carried through verbatim from an
	// existing config on "Update it?" (T107).
	Assets  []string
	Tickets []config.Ticket

	// EnrichmentPolicy and EnrichmentForge are wizard-editable via runEnrichmentWizard (T201).
	EnrichmentPolicy string
	EnrichmentForge  string
}

Answers holds the user's responses from the init wizard.

func ConfigToAnswers

func ConfigToAnswers(cfg *config.Config) Answers

ConfigToAnswers populates an Answers from an existing Config for wizard pre-population.

func Defaults

func Defaults() Answers

Defaults returns opinionated non-interactive defaults: semver, prefix "v", changelog and release enabled. It names no platform: each run finds the forge from the CI job or the git origin, so the file fits a GitHub, GitLab.com or self-hosted GitLab repository alike.

type EnvAnswer

type EnvAnswer struct {
	Name             string
	Bump             string // "auto" or "promote"
	TagFormat        string
	Source           string
	Branch           string
	DisableChangelog bool
	// DisableRelease matches config.Environment.DisableRelease (T217): turns off the entire
	// release: behavior (notes and publish, together) for this environment, not just notes.
	DisableRelease bool

	// Passthrough fields: not wizard-editable, carried verbatim from existing config (T109).
	Changelog *config.ContentDriver
	Release   *config.EnvRelease
}

EnvAnswer holds answers for one per-env environment.

type PlatformAnswer

type PlatformAnswer struct {
	Type       string // "github" or "gitlab"
	Repository string // github: "owner/repo"
	Project    string // gitlab: "namespace/project"
	TokenEnv   string
	APIMode    string // gitlab only: "rest" (default) or "graphql"

	// Passthrough fields: not wizard-editable, carried verbatim from existing config (T108).
	// There is no Prerelease field — GitHub's pre-release flag is derived from the resolved
	// version, not a per-target setting the wizard carries through at all (ADR-0064, T337).
	Name    string
	BaseURL string
	Draft   bool
}

PlatformAnswer holds answers for one release platform.

Jump to

Keyboard shortcuts

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