template

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ProjectNameValidateRegex = `^[a-zA-Z][a-zA-Z0-9_-]*$`

ProjectNameValidateRegex is the default regex for template and project names in minimal scaffolds.

Variables

This section is empty.

Functions

func Add

func Add(sourcePath string) error

Add copies a local directory into the templates store. The destination name is the base name of sourcePath.

func CopyDirForTest

func CopyDirForTest(src, dst string) error

CopyDirForTest exposes copyDir for internal use in tests and other packages that need to reuse the same semantics. It is not part of the public API surface.

func CreateMinimalLocalTemplate added in v0.5.0

func CreateMinimalLocalTemplate(destRoot, name, description, language, architecture, author string) error

CreateMinimalLocalTemplate creates destRoot/<name>/ with scaffold.yaml and template/.gitkeep. If destRoot is empty, TemplatesDir() is used.

func Exists

func Exists(name string) (bool, error)

Exists reports whether a local template directory exists in the store.

func InstallFromGitHub added in v0.5.0

func InstallFromGitHub(client GitHubCloner, ref *GitHubRef, opts InstallFromGitHubOptions) error

InstallFromGitHub clones ref into a temp dir, validates scaffold.yaml, and copies into the local template store.

func Remove

func Remove(name string) error

Remove deletes a local template from the store.

func TemplatesDir

func TemplatesDir() string

TemplatesDir returns the absolute path to ~/.structify/templates.

func WriteTemplateMeta

func WriteTemplateMeta(dir string, meta *TemplateMeta) error

WriteTemplateMeta writes .structify-meta.yaml inside dir with the given metadata.

Types

type AnalysisResult added in v0.2.0

type AnalysisResult struct {
	ProjectName     string
	Language        string
	Architecture    string
	DetectedVars    []DetectedVar
	FilesToInclude  []string
	FilesToIgnore   []string
	TotalFiles      int
	DetectedDeps    []DetectedDependency
	SuggestedInputs []SuggestedInput
	Confidence      float64
}

func AnalyzeProject added in v0.2.0

func AnalyzeProject(path string) (*AnalysisResult, error)

type DetectedDependency added in v0.6.1

type DetectedDependency struct {
	Name    string
	Alias   string
	Purpose string
}

type DetectedVar added in v0.2.0

type DetectedVar struct {
	ID          string
	Description string
	Type        string
	Occurrences []Occurrence
	SuggestAs   string
}

type GitHubClient

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

GitHubClient provides operations over GitHub repositories required by Structify.

func NewGitHubClient

func NewGitHubClient() *GitHubClient

NewGitHubClient returns a GitHubClient with sane defaults.

func (*GitHubClient) Clone

func (c *GitHubClient) Clone(ref *GitHubRef, destDir string) error

Clone clones the given GitHub repository into destDir. If ref.Ref is empty, Clone will use the repository's default branch. For now, Clone performs a shallow clone (depth=1) regardless of ref shape.

func (*GitHubClient) ResolveDefaultBranch

func (c *GitHubClient) ResolveDefaultBranch(ref *GitHubRef) (string, error)

ResolveDefaultBranch returns the default branch name for the given repository using the public GitHub API.

func (*GitHubClient) ValidateTemplateRepo

func (c *GitHubClient) ValidateTemplateRepo(clonedPath string) (*dsl.Manifest, error)

ValidateTemplateRepo verifies that clonedPath contains a valid Structify template. It expects scaffold.yaml at the repository root.

type GitHubCloner added in v0.5.0

type GitHubCloner interface {
	Clone(ref *GitHubRef, destDir string) error
}

GitHubCloner clones a repository reference (implemented by *GitHubClient and test fakes).

type GitHubRef

type GitHubRef struct {
	Owner  string
	Repo   string
	Ref    string
	RawURL string
}

GitHubRef represents a normalized GitHub repository reference.

func ParseGitHubURL

func ParseGitHubURL(raw string) (*GitHubRef, error)

ParseGitHubURL parses and normalizes supported GitHub URL formats:

type InstallFromGitHubOptions added in v0.5.0

type InstallFromGitHubOptions struct {
	Force     bool
	LocalName string // optional; defaults to repo name from ref
}

InstallFromGitHubOptions configures installation from a cloned GitHub repo.

type Occurrence added in v0.2.0

type Occurrence struct {
	File    string
	Line    int
	Context string
}

type ScaffoldRequest

type ScaffoldRequest struct {
	Template  *Template
	OutputDir string
	Variables dsl.Context
	DryRun    bool
}

ScaffoldRequest contains everything needed to scaffold a project.

type ScaffoldResult

type ScaffoldResult struct {
	FilesCreated  []string
	FilesSkipped  []string
	StepsExecuted []StepResult
	StepsFailed   []StepResult
}

ScaffoldResult summarizes what the engine did.

type StepResult

type StepResult struct {
	Name    string
	Command string
	Output  string
	Error   error
	Skipped bool
}

StepResult is the outcome of executing a single step.

type SuggestedInput added in v0.6.1

type SuggestedInput struct {
	Input   dsl.Input
	Reason  string
	Default string
}

type Template

type Template struct {
	Manifest *dsl.Manifest
	Path     string
	Source   string // "builtin" | "local" | "github"
	Meta     *TemplateMeta
}

Template represents a scaffolding template loaded from some source.

func Get

func Get(name string) (*Template, error)

Get returns a local template by directory name from ~/.structify/templates/<name>/.

func List

func List() ([]*Template, error)

List returns all locally installed templates from ~/.structify/templates/. Folders without scaffold.yaml are ignored (not an error).

func LoadBuiltins

func LoadBuiltins() ([]*Template, error)

LoadBuiltins loads templates embedded in the binary.

func LoadFromPath

func LoadFromPath(path string) (*Template, error)

LoadFromPath loads a template from a local filesystem path.

type TemplateMeta

type TemplateMeta struct {
	SourceURL   string
	SourceRef   string
	InstalledAt string
}

TemplateMeta contains optional metadata about the origin of a template.

Jump to

Keyboard shortcuts

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