Documentation
¶
Index ¶
- Constants
- func Add(sourcePath string) error
- func CopyDirForTest(src, dst string) error
- func CreateMinimalLocalTemplate(destRoot, name, description, language, architecture, author string) error
- func Exists(name string) (bool, error)
- func InstallFromGitHub(client GitHubCloner, ref *GitHubRef, opts InstallFromGitHubOptions) error
- func Remove(name string) error
- func TemplatesDir() string
- func WriteTemplateMeta(dir string, meta *TemplateMeta) error
- type AnalysisResult
- type DetectedDependency
- type DetectedVar
- type GitHubClient
- type GitHubCloner
- type GitHubRef
- type InstallFromGitHubOptions
- type Occurrence
- type ScaffoldRequest
- type ScaffoldResult
- type StepResult
- type SuggestedInput
- type Template
- type TemplateMeta
Constants ¶
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 ¶
Add copies a local directory into the templates store. The destination name is the base name of sourcePath.
func CopyDirForTest ¶
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 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 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 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
GitHubCloner clones a repository reference (implemented by *GitHubClient and test fakes).
type GitHubRef ¶
GitHubRef represents a normalized GitHub repository reference.
func ParseGitHubURL ¶
ParseGitHubURL parses and normalizes supported GitHub URL formats:
- github.com/user/repo
- github.com/user/repo@v1.2.0
- https://github.com/user/repo
- https://github.com/user/repo.git
- git@github.com:user/repo.git
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 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 ¶
StepResult is the outcome of executing a single step.
type SuggestedInput ¶ added in v0.6.1
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 List ¶
List returns all locally installed templates from ~/.structify/templates/. Folders without scaffold.yaml are ignored (not an error).
func LoadBuiltins ¶
LoadBuiltins loads templates embedded in the binary.
func LoadFromPath ¶
LoadFromPath loads a template from a local filesystem path.
type TemplateMeta ¶
TemplateMeta contains optional metadata about the origin of a template.