Documentation
¶
Overview ¶
Package workspace provides multi-project monorepo management for Buffalo.
Index ¶
- Variables
- func FindConfig(dir string) (string, error)
- func SaveConfig(path string, cfg *Config) error
- type AffectedResult
- type BuildOptions
- type BuildResult
- type BuildStatus
- type Config
- func (c *Config) BuildDependencyGraph() *DependencyGraph
- func (c *Config) DetectCycles() [][]string
- func (c *Config) GetEnabledProjects() []*Project
- func (c *Config) GetProject(name string) *Project
- func (c *Config) GetProjectsByTag(tag string) []*Project
- func (c *Config) Validate() *ValidationResult
- type DependencyGraph
- type Manager
- func (m *Manager) Build(ctx context.Context, opts BuildOptions) ([]*BuildResult, error)
- func (m *Manager) Config() *Config
- func (m *Manager) GetAffected(since string) (*AffectedResult, error)
- func (m *Manager) GetAllTags() []string
- func (m *Manager) GetState(name string) *ProjectState
- func (m *Manager) List() []*Project
- func (m *Manager) ListByTag(tag string) []*Project
- func (m *Manager) RootDir() string
- func (m *Manager) Validate() *ValidationResult
- type Policies
- type Project
- type ProjectState
- type ValidationError
- type ValidationResult
- type ValidationWarning
- type WorkspaceSettings
Constants ¶
This section is empty.
Variables ¶
var DefaultConfigFiles = []string{
"buffalo-workspace.yaml",
"buffalo-workspace.yml",
".buffalo-workspace.yaml",
".buffalo-workspace.yml",
}
DefaultConfigFiles are the default workspace configuration file names.
Functions ¶
func FindConfig ¶
FindConfig searches for a workspace configuration file.
func SaveConfig ¶
SaveConfig saves workspace configuration to a file.
Types ¶
type AffectedResult ¶
type AffectedResult struct {
// ChangedFiles lists files that changed.
ChangedFiles []string
// DirectlyAffected lists projects directly affected by changes.
DirectlyAffected []*Project
// TransitivelyAffected lists projects indirectly affected through dependencies.
TransitivelyAffected []*Project
// RecommendedBuild suggests which projects to build.
RecommendedBuild []string
}
AffectedResult contains analysis of affected projects.
type BuildOptions ¶
type BuildOptions struct {
// Projects to build (empty means all).
Projects []string
// Tags to filter by.
Tags []string
// Affected only builds projects affected by changes.
Affected bool
// Since is the git ref to compare against for affected.
Since string
// DryRun only shows what would be built.
DryRun bool
// Force rebuilds even if cached.
Force bool
// ContinueOnError continues building after failures.
ContinueOnError bool
// Parallel enables parallel builds.
Parallel bool
// Workers is the number of parallel workers.
Workers int
}
BuildOptions contains options for building.
type BuildResult ¶
type BuildResult struct {
// Project is the project that was built.
Project *Project
// Status is the build status.
Status BuildStatus
// Duration is how long the build took.
Duration time.Duration
// Error contains any error that occurred.
Error error
// OutputFiles lists the generated files.
OutputFiles []string
// CacheHit indicates if the build used cached results.
CacheHit bool
}
BuildResult contains the result of building a project.
type BuildStatus ¶
type BuildStatus string
BuildStatus represents the build state of a project.
const ( // StatusUnknown when status is not determined. StatusUnknown BuildStatus = "unknown" // StatusPending when build is pending. StatusPending BuildStatus = "pending" // StatusBuilding when build is in progress. StatusBuilding BuildStatus = "building" // StatusSuccess when build succeeded. StatusSuccess BuildStatus = "success" // StatusFailed when build failed. StatusFailed BuildStatus = "failed" // StatusSkipped when build was skipped. StatusSkipped BuildStatus = "skipped" )
type Config ¶
type Config struct {
// Workspace contains workspace-level settings.
Workspace WorkspaceSettings `yaml:"workspace" json:"workspace"`
// Projects is the list of projects in the workspace.
Projects []Project `yaml:"projects" json:"projects"`
// Policies contains workspace-wide policies.
Policies Policies `yaml:"policies" json:"policies"`
}
Config represents a workspace configuration (buffalo-workspace.yaml).
func InitConfig ¶
InitConfig creates a new workspace configuration with defaults.
func LoadConfig ¶
LoadConfig loads workspace configuration from a file.
func (*Config) BuildDependencyGraph ¶
func (c *Config) BuildDependencyGraph() *DependencyGraph
BuildDependencyGraph builds the project dependency graph.
func (*Config) DetectCycles ¶
DetectCycles finds circular dependencies in the workspace.
func (*Config) GetEnabledProjects ¶
GetEnabledProjects returns all enabled projects.
func (*Config) GetProject ¶
GetProject returns a project by name.
func (*Config) GetProjectsByTag ¶
GetProjectsByTag returns all projects with the given tag.
func (*Config) Validate ¶
func (c *Config) Validate() *ValidationResult
Validate validates the workspace configuration.
type DependencyGraph ¶
type DependencyGraph struct {
// Projects maps project names to their dependencies.
Projects map[string][]string
// Reverse maps project names to projects that depend on them.
Reverse map[string][]string
}
DependencyGraph represents the project dependency graph.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages workspace operations.
func NewManager ¶
NewManager creates a new workspace manager.
func (*Manager) Build ¶
func (m *Manager) Build(ctx context.Context, opts BuildOptions) ([]*BuildResult, error)
Build builds projects in the workspace.
func (*Manager) GetAffected ¶
func (m *Manager) GetAffected(since string) (*AffectedResult, error)
GetAffected returns projects affected by changes.
func (*Manager) GetAllTags ¶
GetAllTags returns all unique tags in the workspace.
func (*Manager) GetState ¶
func (m *Manager) GetState(name string) *ProjectState
GetState returns the current state of a project.
func (*Manager) Validate ¶
func (m *Manager) Validate() *ValidationResult
Validate validates the workspace configuration.
type Policies ¶
type Policies struct {
// ConsistentVersions requires all projects to use the same proto plugin versions.
ConsistentVersions bool `yaml:"consistent_versions" json:"consistent_versions"`
SharedDependencies bool `yaml:"shared_dependencies" json:"shared_dependencies"`
// NoCircularDeps prevents circular dependencies between projects.
NoCircularDeps bool `yaml:"no_circular_deps" json:"no_circular_deps"`
// RequireTags requires all projects to have at least one tag.
RequireTags bool `yaml:"require_tags" json:"require_tags"`
// AllowedTags limits which tags can be used.
AllowedTags []string `yaml:"allowed_tags,omitempty" json:"allowed_tags,omitempty"`
}
Policies contains workspace-wide build and validation policies.
type Project ¶
type Project struct {
// Name is the unique project identifier.
Name string `yaml:"name" json:"name"`
// Path is the relative path to the project directory.
Path string `yaml:"path" json:"path"`
// Tags for categorizing projects.
Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"`
// DependsOn lists project dependencies.
DependsOn []string `yaml:"depends_on,omitempty" json:"depends_on,omitempty"`
// Config is an optional project-specific config file override.
Config string `yaml:"config,omitempty" json:"config,omitempty"`
// Enabled indicates if the project is active.
Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
}
Project represents a proto project within the workspace.
type ProjectState ¶
type ProjectState struct {
// Project is the project configuration.
Project *Project
// LastBuild is when the project was last built.
LastBuild time.Time
// LastModified is when the project was last modified.
LastModified time.Time
// Hash is the content hash of the project's proto files.
Hash string
// Status is the current build status.
Status BuildStatus
// Error contains any error from the last build.
Error error
}
ProjectState represents the current state of a project.
type ValidationError ¶
type ValidationError struct {
// Project is the affected project (empty for workspace-level).
Project string
// Field is the invalid field.
Field string
// Message describes the error.
Message string
}
ValidationError represents a validation error.
type ValidationResult ¶
type ValidationResult struct {
// Valid indicates if the workspace is valid.
Valid bool
// Errors contains validation errors.
Errors []ValidationError
// Warnings contains validation warnings.
Warnings []ValidationWarning
}
ValidationResult contains workspace validation results.
type ValidationWarning ¶
type ValidationWarning struct {
// Project is the affected project (empty for workspace-level).
Project string
// Message describes the warning.
Message string
}
ValidationWarning represents a validation warning.
type WorkspaceSettings ¶
type WorkspaceSettings struct {
// Name is the workspace name.
Name string `yaml:"name" json:"name"`
// Description of the workspace.
Description string `yaml:"description,omitempty" json:"description,omitempty"`
// Version of the workspace configuration.
Version string `yaml:"version,omitempty" json:"version,omitempty"`
}
WorkspaceSettings contains workspace-level configuration.