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
- func ModulePath(dir string) (string, error)
- func RegisterSlice(dir, module, pkg string) (bool, error)
- func Write(opts Options) ([]string, error)
- func WriteSlice(opts SliceOptions) ([]string, error)
- func WriteStarterAssets(dir, shape string) ([]string, error)
- type Fault
- type Options
- type SliceOptions
Constants ¶
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.
const ( // Datastar is the default adapter. Datastar = "datastar" // Htmx is the other adapter. Htmx = "htmx" )
The hypermedia adapters that a shape can carry.
const ( // DefaultAveroVersion is the version of the host. DefaultAveroVersion = "v0.2.1" // DefaultGoVersion is the version line of go.mod. DefaultGoVersion = "1.26.2" // DefaultTemplVersion is the version of the templ generator. The ssr // shape writes its pages as .templ files, and the generator writes the // Go file of each one. DefaultTemplVersion = "v0.3.1020" // DefaultDrelVersion is the version of drel. Every shape states its // models with it, and its generator writes the repositories and the // migrations. DefaultDrelVersion = "v0.7.1" )
The versions that go.mod carries when the caller names none.
const DrelConfig = "drel.yaml"
DrelConfig is the name of the drel configuration file. drel reads the model package of each slice from its modules block.
Variables ¶
This section is empty.
Functions ¶
func ModulePath ¶
ModulePath returns the module path that go.mod names.
func RegisterSlice ¶
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 ¶
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.
func WriteStarterAssets ¶ added in v0.2.0
WriteStarterAssets writes the output directory of the assets of an application that already exists.
A clone of a repository holds no built asset, because an application ignores its output directory. The command that runs an example calls this function, so the embedded file system holds a document before the first build.
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.
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
// TemplVersion is the version of the templ generator that an ssr
// application requires.
TemplVersion string
// DrelVersion is the version of drel that an application requires.
DrelVersion 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.