scaffold

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAIDir = ".hamr/ai"

DefaultAIDir is the default directory for AI command artifacts.

View Source
const DefaultLatestReleaseTimeout = 3 * time.Second

DefaultLatestReleaseTimeout is the default network timeout for FetchLatestRelease.

View Source
const HamrRepoURL = "https://github.com/FyrmForge/hamr.git"

HamrRepoURL is the default repository URL for diffing scaffold changes.

Variables

This section is empty.

Functions

func ResolveAIDir

func ResolveAIDir(tomlPath string) string

ResolveAIDir loads metadata from tomlPath and returns the AI directory. Falls back to DefaultAIDir on any error, logging a warning when the file exists but cannot be parsed.

func UpdateVersion

func UpdateVersion(path string, newVersion string) error

UpdateVersion reads hamr.toml, replaces the version value under [hamr], and writes back. Uses line-level replacement to preserve comments and formatting. The original file is restored if verification fails.

Types

type AIConfig

type AIConfig struct {
	Dir string `toml:"dir"`
}

AIConfig holds the [ai] section of hamr.toml.

type DiffProjectInfo

type DiffProjectInfo struct {
	BaseVersion    string  `json:"base_version"`
	CurrentVersion string  `json:"current_version"`
	ScaffoldedAt   string  `json:"scaffolded_at,omitempty"`
	Options        Options `json:"options"`
}

DiffProjectInfo describes the project's scaffold state for a diff report.

type DiffReport

type DiffReport struct {
	Project  DiffProjectInfo `json:"project"`
	Diff     string          `json:"diff"`
	DiffStat string          `json:"diff_stat"`
}

DiffReport is the structured output of the git-based upgrade command.

func GitDiff

func GitDiff(ctx context.Context, repoURL, baseVersion, currentVersion string) (*DiffReport, error)

GitDiff clones the given repo (bare, partial) and produces a unified diff between two version tags. The repoURL parameter allows tests to pass a local repository path instead of hitting the network.

type HamrSection

type HamrSection struct {
	Version      string `toml:"version"`
	ScaffoldedAt string `toml:"scaffolded_at"`
}

HamrSection holds the HAMR scaffold tracking fields.

type LocaleSection

type LocaleSection struct {
	Default string `toml:"default"`
}

LocaleSection holds the [locale] table fields the CLI reads.

type Metadata

type Metadata struct {
	Hamr    HamrSection   `toml:"hamr"`
	Options Options       `toml:"options"`
	AI      AIConfig      `toml:"ai"`
	Locale  LocaleSection `toml:"locale"`
}

Metadata represents the [hamr], [options], [ai], and [locale] sections of hamr.toml.

func LoadMetadata

func LoadMetadata(path string) (Metadata, error)

LoadMetadata reads hamr.toml and decodes the [hamr] and [options] sections. Returns zero Metadata (with empty version) when [hamr] is absent.

func (Metadata) AIDir

func (m Metadata) AIDir() string

AIDir returns the configured AI directory, falling back to DefaultAIDir.

func (Metadata) HasHamrSection

func (m Metadata) HasHamrSection() bool

HasHamrSection reports whether the loaded metadata contained a [hamr] section. When false, the project was scaffolded before metadata tracking was added.

type Options

type Options struct {
	Database    string `toml:"database"`
	DBConnector string `toml:"db_connector"`
	Auth        string `toml:"auth"`
	CSS         string `toml:"css"`
	WebSockets  bool   `toml:"websockets"`
	E2E         bool   `toml:"e2e"`
	Stripe      bool   `toml:"stripe"`
	Locale      bool   `toml:"locale"`
	Storage     string `toml:"storage"`
	Alpine      bool   `toml:"alpine"`
}

Options records the scaffold choices made when the project was generated.

type Version

type Version struct {
	Major int
	Minor int
	Patch int
}

Version represents a semantic version with major, minor, and patch components.

func FetchLatestRelease

func FetchLatestRelease(ctx context.Context) (Version, error)

FetchLatestRelease queries GitHub for the most recent hamr release and returns the parsed version. The supplied context bounds the request; a timeout shorter than DefaultLatestReleaseTimeout is recommended for interactive commands so users are not left hanging on network issues.

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion parses a version string like "v0.3.2", "0.3.2", or "0.3.2-dev" into a Version. Pre-release suffixes ("-dev", "-rc.1") and SemVer build metadata ("+build.42") are both stripped.

func (Version) Less

func (v Version) Less(other Version) bool

Less returns true if v is strictly less than other.

func (Version) String

func (v Version) String() string

String returns the version as "major.minor.patch".

Jump to

Keyboard shortcuts

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