Adds the composable monorepo template system that generates project skeletons with pluggable components (service, worker, app-react, app-astro, cli). Key changes: - Monorepo skeleton templates with shared pkg/, scripts/, and git hooks - Component templates (service, worker, app-react, app-astro, cli) with Dockerfiles, CI steps, and component.yaml manifests - Component domain model with validation and dependency resolution - Component handler endpoints for CRUD and composition - Template provider extended with BuildComposableProject and component assembly - Deployer extended with composable project deployment support - Handler timeout constants (TimeoutFastLookup through TimeoutLongRunning) - envutil package for centralized env var reads with defaults - api.DecodeJSON helper for standardized request body decoding - Standardized response helpers (WriteBadRequest, WriteNotFound, etc.) - Replaced fullstack-app cookbook with composable-app cookbook - Hardened handler timeouts, logging, and error responses across all handlers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
90 lines
3.6 KiB
Go
90 lines
3.6 KiB
Go
// Package port defines interfaces (ports) for external dependencies.
|
|
package port
|
|
|
|
import "context"
|
|
|
|
// TemplateProvider seeds repositories with starter files.
|
|
type TemplateProvider interface {
|
|
// SeedRepo populates a repository with template files.
|
|
// templateName specifies which template to use (e.g., "default", "astro-landing").
|
|
// vars contains template variables for interpolation (e.g., PROJECT_NAME, DOMAIN).
|
|
SeedRepo(ctx context.Context, owner, repo, templateName string, vars map[string]string) error
|
|
|
|
// SeedSkeleton populates a repository with the monorepo skeleton template.
|
|
// This creates the base monorepo structure without any components.
|
|
// Components are added later via POST /projects/{id}/components.
|
|
SeedSkeleton(ctx context.Context, owner, repo string, vars map[string]string) error
|
|
|
|
// ListTemplates returns available templates.
|
|
ListTemplates(ctx context.Context) ([]TemplateInfo, error)
|
|
|
|
// GetTemplate returns info about a specific template.
|
|
GetTemplate(ctx context.Context, name string) (*TemplateInfo, error)
|
|
|
|
// GetSkeleton returns info about the monorepo skeleton template.
|
|
GetSkeleton(ctx context.Context) (*TemplateInfo, error)
|
|
|
|
// GetComponentTemplate returns info about a specific component template.
|
|
// componentType is one of: service, worker, app-astro, app-react, cli
|
|
GetComponentTemplate(ctx context.Context, componentType string) (*ComponentTemplateInfo, error)
|
|
|
|
// ListComponentTemplates returns available component templates.
|
|
// If componentType is empty, returns all component templates.
|
|
// Otherwise, returns only templates matching the specified type.
|
|
ListComponentTemplates(ctx context.Context, componentType string) ([]ComponentTemplateInfo, error)
|
|
|
|
// GetComponentFiles returns the files for a component template with variables interpolated.
|
|
// destPath is the destination path prefix (e.g., "services/my-api" or "apps/landing").
|
|
// vars contains template variables for interpolation.
|
|
GetComponentFiles(ctx context.Context, componentType string, destPath string, vars map[string]string) ([]ComponentFile, error)
|
|
|
|
// GetComponentWoodpeckerStep returns the .woodpecker.step.yml content for a component.
|
|
// This is the CI step that should be inserted into the main .woodpecker.yml file.
|
|
GetComponentWoodpeckerStep(ctx context.Context, componentType string, vars map[string]string) (string, error)
|
|
}
|
|
|
|
// TemplateInfo describes an available project template.
|
|
type TemplateInfo struct {
|
|
// Name is the template identifier (e.g., "astro-landing")
|
|
Name string
|
|
|
|
// Description explains what the template provides
|
|
Description string
|
|
|
|
// Stack indicates the technology stack (e.g., "astro", "go", "generic")
|
|
Stack string
|
|
|
|
// Files lists the files included in the template
|
|
Files []string
|
|
}
|
|
|
|
// ComponentTemplateInfo describes a component template for monorepo projects.
|
|
type ComponentTemplateInfo struct {
|
|
// Type is the component type (e.g., "service", "worker", "app-astro", "app-react", "cli")
|
|
Type string
|
|
|
|
// Description explains what the component provides
|
|
Description string
|
|
|
|
// Stack indicates the technology stack (e.g., "go", "astro", "react")
|
|
Stack string
|
|
|
|
// DefaultPort is the default port for this component type (0 if not applicable)
|
|
DefaultPort int
|
|
|
|
// DestDir is the destination directory for this component type (e.g., "services", "workers", "apps", "cli")
|
|
DestDir string
|
|
|
|
// Files lists the files included in the template
|
|
Files []string
|
|
}
|
|
|
|
// ComponentFile represents a file to be created for a component.
|
|
type ComponentFile struct {
|
|
// Path is the file path relative to the repository root
|
|
Path string
|
|
|
|
// Content is the file content (already interpolated with variables)
|
|
Content string
|
|
}
|