project

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package project ties the pieces together: it finds the project, plans every file and migration, decides who owns each file and applies the plan atomically.

Index

Constants

View Source
const (
	ConfigFile    = "codebuild.json"
	SpecsDir      = "specs"
	MigrationsDir = "migrations"
	SnapshotName  = "codebuild.snapshot.json"
	SnapshotFile  = MigrationsDir + "/" + SnapshotName
)
View Source
const LockFile = ".codebuild.lock"
View Source
const WorkFile = "go.work"

Variables

This section is empty.

Functions

func ValidateSpec

func ValidateSpec(dir, file string, content []byte) (schema.Diagnostics, error)

func Within

func Within(root, path string) error

Within reports whether path stays inside root. Symbolic links are resolved first; otherwise a link inside the project could send the MCP server anywhere on the disk.

Types

type Action

type Action string
const (
	ActionCreate    Action = "create"
	ActionUpdate    Action = "update"
	ActionUnchanged Action = "unchanged"
	ActionSkip      Action = "skip"
	ActionConflict  Action = "conflict"
	ActionStale     Action = "stale"
	ActionDelete    Action = "delete"
)

type ApplyResult

type ApplyResult struct {
	Written []string `json:"written"`
	Deleted []string `json:"deleted"`
}

func Apply

func Apply(p *Plan) (*ApplyResult, error)

type Config

type Config struct {
	Dialect      string         `json:"dialect"`
	Pagination   gen.Pagination `json:"pagination"`
	ManualWiring []string       `json:"manualWiring"`
	Generate     gen.Parts      `json:"generate"`
}

func DefaultConfig

func DefaultConfig(dialectName string) Config

func ParseConfig

func ParseConfig(data []byte) (Config, error)

func (Config) Marshal

func (c Config) Marshal() []byte

func (Config) Validate

func (c Config) Validate() error

type DomainInfo

type DomainInfo struct {
	Domain   string `json:"domain"`
	Service  string `json:"service,omitempty"`
	Entity   string `json:"entity"`
	Table    string `json:"table"`
	File     string `json:"file"`
	Path     string `json:"path"`
	Routes   bool   `json:"routes"`
	ReadOnly bool   `json:"readOnly"`
}

type Error

type Error struct {
	Kind        ErrorKind          `json:"-"`
	Code        string             `json:"code"`
	Message     string             `json:"message"`
	Details     map[string]string  `json:"details,omitempty"`
	Diagnostics schema.Diagnostics `json:"diagnostics,omitempty"`
}

func (*Error) Error

func (e *Error) Error() string

type ErrorKind

type ErrorKind int
const (
	KindInternal ErrorKind = iota
	KindUsage
	KindInvalidSpec
	KindUnsupportedGo
	KindToolchain
	KindOwnership
	KindConfig
)

type FileChange

type FileChange struct {
	Path    string `json:"path"`
	Action  Action `json:"action"`
	Owner   Owner  `json:"owner"`
	Added   int    `json:"added,omitempty"`
	Removed int    `json:"removed,omitempty"`
	Reason  string `json:"reason,omitempty"`
	// contains filtered or unexported fields
}

type GoUpgrade

type GoUpgrade struct {
	From string `json:"from"`
	To   string `json:"to"`
}

type Info

type Info struct {
	Root         string                 `json:"root"`
	Module       string                 `json:"module"`
	Dialect      string                 `json:"dialect"`
	Configured   bool                   `json:"configured"`
	GoVersion    string                 `json:"goVersion"`
	Toolchain    string                 `json:"toolchain,omitempty"`
	Status       goversion.Status       `json:"status"`
	Capabilities goversion.Capabilities `json:"capabilities"`
	Services     []ServiceInfo          `json:"services,omitempty"`
	Domains      []DomainInfo           `json:"domains"`
	Diagnostics  schema.Diagnostics     `json:"diagnostics,omitempty"`
}

func Inspect

func Inspect(dir string) (*Info, error)

type MigrationInfo

type MigrationInfo struct {
	Database string `json:"database,omitempty"`
	Version  uint64 `json:"version"`
	Name     string `json:"name"`
	Up       string `json:"up"`
	Down     string `json:"down"`
}

type Options

type Options struct {
	Dir           string
	Starter       bool
	Module        string
	Dialect       string
	ChangeDialect bool
	UpgradeGo     bool
	Prune         bool
	Minimal       bool
	Confirm       func(question string) (bool, error)
	Toolchain     func(ctx context.Context) (goversion.Toolchain, error)
}

type Owner

type Owner string
const (
	OwnerGenerated Owner = "generated"
	OwnerUser      Owner = "user"
	OwnerMigration Owner = "migration"
	OwnerState     Owner = "state"
	OwnerConfig    Owner = "config"
	OwnerGoMod     Owner = "gomod"
)

type Plan

type Plan struct {
	Root            string             `json:"root"`
	Module          string             `json:"module"`
	Starter         bool               `json:"starter"`
	Dialect         string             `json:"dialect"`
	PreviousDialect string             `json:"previousDialect,omitempty"`
	Target          goversion.Target   `json:"target"`
	GoUpgrade       *GoUpgrade         `json:"goUpgrade,omitempty"`
	Toolchain       *ToolchainStatus   `json:"toolchain,omitempty"`
	Domains         []string           `json:"domains"`
	Files           []FileChange       `json:"files"`
	Migration       *MigrationInfo     `json:"migration,omitempty"`
	Migrations      []MigrationInfo    `json:"migrations,omitempty"`
	Warnings        []string           `json:"warnings,omitempty"`
	Diagnostics     schema.Diagnostics `json:"diagnostics,omitempty"`
	NextSteps       []string           `json:"nextSteps,omitempty"`
}

func BuildPlan

func BuildPlan(ctx context.Context, opts Options) (*Plan, error)

func (*Plan) Conflicts

func (p *Plan) Conflicts() []FileChange

func (*Plan) HasChanges

func (p *Plan) HasChanges() bool

func (*Plan) UnifiedDiff

func (p *Plan) UnifiedDiff() string

type ServiceInfo

type ServiceInfo struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	File     string `json:"file"`
	Database string `json:"database"`
}

type ToolchainStatus

type ToolchainStatus struct {
	Local    string `json:"local"`
	Setting  string `json:"setting"`
	Required string `json:"required"`
}

Jump to

Keyboard shortcuts

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