scaffold

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package scaffold writes a new Avero application, S14.

One template set holds the files that every shape needs, and one set holds the files of each shape: ssr, spa and api. The scaffolder writes plain Go, so a person can read every file, change it and delete it. See design rule 4.

Index

Constants

View Source
const (
	// ShapeSSR is a server rendered application.
	ShapeSSR = "ssr"
	// ShapeSPA is an application with an embedded single page front end.
	ShapeSPA = "spa"
	// ShapeAPI is a JSON service.
	ShapeAPI = "api"
)

The shapes that the scaffolder writes.

View Source
const (
	// Datastar is the default adapter.
	Datastar = "datastar"
	// Htmx is the other adapter.
	Htmx = "htmx"
)

The hypermedia adapters that a shape can carry.

View Source
const (
	// DefaultAveroVersion is the version of the host.
	DefaultAveroVersion = "v0.1.0"
	// DefaultGoVersion is the version line of go.mod.
	DefaultGoVersion = "1.26.2"
)

The versions that go.mod carries when the caller names none.

Variables

This section is empty.

Functions

func ModulePath

func ModulePath(dir string) (string, error)

ModulePath returns the module path that go.mod names.

func RegisterSlice

func RegisterSlice(dir, module, pkg string) (bool, error)

RegisterSlice adds the feature to wire.go: the import and the module in the call to avero.Modules. It reports whether it changed the file.

It changes nothing when it does not find the two places, so it never breaks a wiring that a person wrote by hand. The caller then states the two lines to write.

func Write

func Write(opts Options) ([]string, error)

Write writes one application and returns the files that it wrote, in order.

It refuses a directory that already holds files, so it never writes over the work of a person.

func WriteSlice

func WriteSlice(opts SliceOptions) ([]string, error)

WriteSlice writes one feature slice and its migration. It returns the files that it wrote, in order.

`avero slice` calls it, and the MCP tool scaffold_slice calls the same function, so an agent and a person write the same files. See the SDD, S16.

Types

type Fault

type Fault struct {
	// Message states the fault.
	Message string `json:"message"`
	// Repair states what to do. It is one sentence.
	Repair string `json:"repair"`
}

Fault is one scaffolder fault. It states what went wrong and states the repair in one sentence. See DX-7.

func (*Fault) Error

func (f *Fault) Error() string

Error returns the message and the repair.

type Options

type Options struct {
	// Name is the name of the application. It becomes the directory, the
	// module path and the binary.
	Name string
	// Dir is the directory that receives the files. An empty value is the
	// name inside the working directory.
	Dir string
	// Shape is ssr, spa or api.
	Shape string
	// Hypermedia is datastar or htmx. An api shape carries none.
	Hypermedia string
	// Module is the module path. An empty value is the name.
	Module string
	// AveroVersion is the version of the host that go.mod requires.
	AveroVersion string
	// Replace points the module at a local copy of Avero. A test and the
	// gate of this repository set it. An empty value writes no replace
	// directive.
	Replace string
	// GoVersion is the version line of go.mod.
	GoVersion string
}

Options states one application.

type SliceOptions

type SliceOptions struct {
	// Name is the name of the feature, such as comment or order.
	Name string
	// Dir is the root of the application.
	Dir string
	// Module is the module path of the application. An empty value reads
	// go.mod.
	Module string
}

SliceOptions states one feature slice.

Jump to

Keyboard shortcuts

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