Documentation
¶
Index ¶
- func AddDependencies(projectRoot string, deps []Dependency) error
- func AddInstalledFeature(projectRoot, name, version string) error
- func FeaturesPath(projectRoot string) string
- func FileExists(path string) bool
- func MkdirAll(path string, perm os.FileMode) error
- func ReadFile(path string) ([]byte, error)
- func RemoveEnvironment(projectRoot string, envVars []string) error
- func RemoveInstalledFeature(projectRoot, name string) error
- func RunGoFmt(projectRoot string) error
- func RunGoModTidy(projectRoot string) error
- func SaveFeatures(projectRoot string, f FeaturesFile) error
- func UpdateEnvironment(projectRoot string, envVars []string) error
- func WriteFile(path string, content []byte) error
- type Conflict
- type Dependency
- type Detector
- type Feature
- type FeatureDependencies
- type FeatureRemover
- type FeaturesFile
- type FileAction
- type FileActionType
- type FileChange
- type InstalledFeature
- type Installer
- type Manifest
- type Plan
- type ProjectContext
- type ProjectType
- type Registry
- func (r *Registry) Get(name string) (Feature, bool)
- func (r *Registry) HasCycles(names []string) bool
- func (r *Registry) List() []Feature
- func (r *Registry) Register(f Feature)
- func (r *Registry) Require(name string) (Feature, error)
- func (r *Registry) ResolveDependencies(names []string) ([]Feature, error)
- type TemplateRenderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDependencies ¶
func AddDependencies(projectRoot string, deps []Dependency) error
AddDependencies adds Go module dependencies to go.mod.
func AddInstalledFeature ¶
AddInstalledFeature adds a feature to the installed list.
func FeaturesPath ¶
FeaturesPath returns the path to the features tracking file.
func RemoveEnvironment ¶
RemoveEnvironment removes environment variables from .env.example.
func RemoveInstalledFeature ¶
RemoveInstalledFeature removes a feature from the installed list.
func RunGoModTidy ¶
RunGoModTidy runs go mod tidy in the project directory.
func SaveFeatures ¶
func SaveFeatures(projectRoot string, f FeaturesFile) error
SaveFeatures saves the installed features to .forge/features.yaml.
func UpdateEnvironment ¶
UpdateEnvironment appends environment variables to .env.example.
Types ¶
type Dependency ¶
Dependency represents a Go module dependency.
type Detector ¶
type Detector struct{}
Detector detects and loads information about a ForgeKit project.
func (Detector) Detect ¶
func (Detector) Detect(root string) (ProjectContext, error)
Detect inspects the project root and returns its context. Strict mode: requires ForgeKit project structure (.forge or legacy features.yaml).
func (Detector) DetectLoose ¶
func (Detector) DetectLoose(root string) (ProjectContext, error)
DetectLoose inspects the project root and returns its context. Loose mode: accepts ForgeKit projects, legacy projects, and external compatible Go projects.
type Feature ¶
type Feature interface {
Name() string
Description() string
Version() string
Check(ctx context.Context, project ProjectContext) error
Plan(ctx context.Context, project ProjectContext) (Plan, error)
Apply(ctx context.Context, project ProjectContext, plan Plan) error
}
Feature represents an installable ForgeKit feature.
type FeatureDependencies ¶
type FeatureDependencies interface {
DependsOn() []string
}
FeatureDependencies is an optional interface for features that declare dependencies on other features.
type FeatureRemover ¶
type FeatureRemover interface {
Remove(ctx context.Context, project ProjectContext, plan Plan) error
}
FeatureRemover is an optional interface for features that support removal.
type FeaturesFile ¶
type FeaturesFile struct {
Features []InstalledFeature `yaml:"features"`
}
FeaturesFile represents the .forge/features.yaml file.
func LoadFeatures ¶
func LoadFeatures(projectRoot string) (FeaturesFile, error)
LoadFeatures loads the installed features from .forge/features.yaml.
type FileAction ¶
type FileAction struct {
Source string
Destination string
Action FileActionType
}
FileAction describes a file operation performed by a feature.
type FileActionType ¶
type FileActionType string
FileActionType represents the type of file operation.
const ( FileActionCreate FileActionType = "create" FileActionModify FileActionType = "modify" FileActionDelete FileActionType = "delete" )
type FileChange ¶
FileChange represents a file modification for rollback tracking.
type InstalledFeature ¶
type InstalledFeature struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
InstalledAt time.Time `yaml:"installed_at"`
}
InstalledFeature represents a feature installed in the project.
func IsInstalled ¶
func IsInstalled(projectRoot, name string) (bool, *InstalledFeature, error)
IsInstalled checks if a feature is already installed.
type Installer ¶
type Installer struct {
// contains filtered or unexported fields
}
Installer applies feature plans with rollback capability.
func NewInstaller ¶
NewInstaller creates an installer for a project.
func (*Installer) Changes ¶
func (i *Installer) Changes() []FileChange
Changes returns the list of recorded changes (for inspection).
type Manifest ¶
type Manifest struct {
Name string
Version string
Description string
Dependencies []Dependency
Files []FileAction
Environment []string
}
Manifest describes the resources required by a feature.
type Plan ¶
type Plan struct {
Feature string
Version string
Files []FileAction
Dependencies []Dependency
Environment []string
Conflicts []Conflict
}
Plan describes the changes a feature intends to make.
type ProjectContext ¶
type ProjectContext struct {
Root string
Module string
GoVersion string
HTTPPort int
Type ProjectType
}
ProjectContext describes the ForgeKit project receiving a feature.
type ProjectType ¶
type ProjectType int
ProjectType represents the type of project detected.
const ( ProjectTypeUnknown ProjectType = iota ProjectTypeForgeKit ProjectTypeLegacyForgeKit ProjectTypeExternalCompatible ProjectTypeInvalidForgeKit )
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores the available ForgeKit features.
func NewRegistry ¶
NewRegistry creates a feature registry.
func (*Registry) HasCycles ¶
HasCycles checks if there are circular dependencies among the given feature names.
func (*Registry) ResolveDependencies ¶
ResolveDependencies returns features in topological order based on their DependsOn() declarations. Features without FeatureDependencies interface are treated as having no dependencies. Returns an error if a cycle is detected or a dependency is not registered.
type TemplateRenderer ¶
type TemplateRenderer struct {
// contains filtered or unexported fields
}
TemplateRenderer renders template files.
func NewTemplateRenderer ¶
func NewTemplateRenderer(data map[string]string) *TemplateRenderer
NewTemplateRenderer creates a template renderer.
func (*TemplateRenderer) RenderFile ¶
func (t *TemplateRenderer) RenderFile(sourcePath, destPath string) error
RenderFile reads a template file and replaces placeholders.