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 IntegrateMainGo(projectRoot string, integration MainIntegration) error
- func IntegrateRouterGo(projectRoot string, integration RouterIntegration) error
- 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 RemoveMainGo(projectRoot string, integration MainIntegration) error
- func RemoveRouterGo(projectRoot string, integration RouterIntegration) 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 ConflictInfo
- type Dependency
- type Detector
- type Feature
- type FeatureDependencies
- type FeatureRemover
- type FeaturesFile
- type FileAction
- type FileActionType
- type FileChange
- type InstalledFeature
- type Installer
- type MainIntegration
- type MainReplacement
- 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 RollbackLimitation
- type RollbackManager
- func (rm *RollbackManager) ClearSnapshots()
- func (rm *RollbackManager) CreateSnapshot(description string) (*Snapshot, error)
- func (rm *RollbackManager) ListSnapshots() []*Snapshot
- func (rm *RollbackManager) RollbackLast() error
- func (rm *RollbackManager) RollbackTo(snap *Snapshot) error
- func (rm *RollbackManager) VerifyRollback(snap *Snapshot) error
- type RouterIntegration
- type Snapshot
- 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 IntegrateMainGo ¶ added in v0.3.1
func IntegrateMainGo(projectRoot string, integration MainIntegration) error
IntegrateMainGo safely integrates a feature into main.go
func IntegrateRouterGo ¶ added in v0.3.1
func IntegrateRouterGo(projectRoot string, integration RouterIntegration) error
IntegrateRouterGo safely integrates a feature into router.go It handles multiple features by properly merging imports and middleware calls
func RemoveEnvironment ¶
RemoveEnvironment removes environment variables from .env.example.
func RemoveInstalledFeature ¶
RemoveInstalledFeature removes a feature from the installed list.
func RemoveMainGo ¶ added in v0.3.1
func RemoveMainGo(projectRoot string, integration MainIntegration) error
RemoveMainGo safely removes a feature's integration from main.go
func RemoveRouterGo ¶ added in v0.3.1
func RemoveRouterGo(projectRoot string, integration RouterIntegration) error
RemoveRouterGo safely removes a feature's integration from router.go It only removes the specific feature's import and middleware call, preserving other features
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 ConflictInfo ¶ added in v0.3.1
ConflictInfo represents a detected conflict
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).
func (*Installer) Conflicts ¶ added in v0.3.1
func (i *Installer) Conflicts() []ConflictInfo
Conflicts returns the list of detected conflicts
type MainIntegration ¶ added in v0.3.1
type MainIntegration struct {
ModulePath string
ImportPath string
ImportCheck string
BlankImport bool // If true, use blank import (_ "path") instead of regular import
Replacements []MainReplacement
}
MainIntegration holds the configuration for integrating a feature into main.go
type MainReplacement ¶ added in v0.3.1
type MainReplacement struct {
OldStr string
NewStr string
Check string // Optional: only replace if Check is found
}
MainReplacement represents a string replacement in main.go
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 RollbackLimitation ¶ added in v0.3.1
RollbackLimitation describes what rollback can and cannot do.
func GetRollbackLimitations ¶ added in v0.3.1
func GetRollbackLimitations() RollbackLimitation
GetRollbackLimitations returns the rollback capabilities and limitations.
type RollbackManager ¶ added in v0.3.1
type RollbackManager struct {
// contains filtered or unexported fields
}
RollbackManager manages project state snapshots for rollback operations.
func NewRollbackManager ¶ added in v0.3.1
func NewRollbackManager(projectRoot string) *RollbackManager
NewRollbackManager creates a new rollback manager for a project.
func (*RollbackManager) ClearSnapshots ¶ added in v0.3.1
func (rm *RollbackManager) ClearSnapshots()
ClearSnapshots removes all snapshots.
func (*RollbackManager) CreateSnapshot ¶ added in v0.3.1
func (rm *RollbackManager) CreateSnapshot(description string) (*Snapshot, error)
CreateSnapshot captures the current project state.
func (*RollbackManager) ListSnapshots ¶ added in v0.3.1
func (rm *RollbackManager) ListSnapshots() []*Snapshot
ListSnapshots returns all available snapshots.
func (*RollbackManager) RollbackLast ¶ added in v0.3.1
func (rm *RollbackManager) RollbackLast() error
RollbackLast restores to the most recent snapshot.
func (*RollbackManager) RollbackTo ¶ added in v0.3.1
func (rm *RollbackManager) RollbackTo(snap *Snapshot) error
RollbackTo restores the project state to a specific snapshot.
func (*RollbackManager) VerifyRollback ¶ added in v0.3.1
func (rm *RollbackManager) VerifyRollback(snap *Snapshot) error
VerifyRollback verifies that the project state matches the snapshot.
type RouterIntegration ¶ added in v0.3.1
type RouterIntegration struct {
ModulePath string
ImportPath string
MiddlewareCall string
MiddlewareCheck string // String to check if already integrated
}
RouterIntegration holds the configuration for integrating a feature into router.go
type Snapshot ¶ added in v0.3.1
type Snapshot struct {
ID string
Timestamp time.Time
GoMod []byte
GoSum []byte
ForgeFiles map[string][]byte
EnvExample []byte
Description string
}
Snapshot represents a complete project state at a point in time.
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.