workspace

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package workspace provides multi-project monorepo management for Buffalo.

Index

Constants

This section is empty.

Variables

View Source
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

func FindConfig(dir string) (string, error)

FindConfig searches for a workspace configuration file.

func SaveConfig

func SaveConfig(path string, cfg *Config) error

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

func InitConfig(name string) *Config

InitConfig creates a new workspace configuration with defaults.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads workspace configuration from a file.

func (*Config) BuildDependencyGraph

func (c *Config) BuildDependencyGraph() *DependencyGraph

BuildDependencyGraph builds the project dependency graph.

func (*Config) DetectCycles

func (c *Config) DetectCycles() [][]string

DetectCycles finds circular dependencies in the workspace.

func (*Config) GetEnabledProjects

func (c *Config) GetEnabledProjects() []*Project

GetEnabledProjects returns all enabled projects.

func (*Config) GetProject

func (c *Config) GetProject(name string) *Project

GetProject returns a project by name.

func (*Config) GetProjectsByTag

func (c *Config) GetProjectsByTag(tag string) []*Project

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

func NewManager(configPath string, log *logger.Logger) (*Manager, error)

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) Config

func (m *Manager) Config() *Config

Config returns the workspace configuration.

func (*Manager) GetAffected

func (m *Manager) GetAffected(since string) (*AffectedResult, error)

GetAffected returns projects affected by changes.

func (*Manager) GetAllTags

func (m *Manager) GetAllTags() []string

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) List

func (m *Manager) List() []*Project

List returns all projects in the workspace.

func (*Manager) ListByTag

func (m *Manager) ListByTag(tag string) []*Project

ListByTag returns projects matching the given tag.

func (*Manager) RootDir

func (m *Manager) RootDir() string

RootDir returns the workspace root directory.

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 allows sharing dependencies across projects.
	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.

func (*Project) IsEnabled

func (p *Project) IsEnabled() bool

IsEnabled returns true if the project is enabled (default: true).

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.

Jump to

Keyboard shortcuts

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